Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools: ynl: add --list-ops and --list-msgs to CLI

I often forget the exact naming of ops and have to look at
the spec to find it. Add support for listing the operations:

$ ./cli.py --spec .../netdev.yaml --list-ops
dev-get [ do, dump ]
page-pool-get [ do, dump ]
page-pool-stats-get [ do, dump ]
queue-get [ do, dump ]
napi-get [ do, dump ]
qstats-get [ dump ]

For completeness also support listing all ops (including
notifications:

# ./cli.py --spec .../netdev.yaml --list-msgs
dev-get [ dump, do ]
dev-add-ntf [ notify ]
dev-del-ntf [ notify ]
dev-change-ntf [ notify ]
page-pool-get [ dump, do ]
page-pool-add-ntf [ notify ]
page-pool-del-ntf [ notify ]
page-pool-change-ntf [ notify ]
page-pool-stats-get [ dump, do ]
queue-get [ dump, do ]
napi-get [ dump, do ]
qstats-get [ dump ]

Use double space after the name for slightly easier to read
output.

Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://lore.kernel.org/r/20240502164043.2130184-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+11
+9
tools/net/ynl/cli.py
··· 40 40 group.add_argument('--multi', dest='multi', nargs=2, action='append', 41 41 metavar=('DO-OPERATION', 'JSON_TEXT'), type=str) 42 42 group.add_argument('--dump', dest='dump', metavar='DUMP-OPERATION', type=str) 43 + group.add_argument('--list-ops', action='store_true') 44 + group.add_argument('--list-msgs', action='store_true') 43 45 44 46 parser.add_argument('--sleep', dest='sleep', type=int) 45 47 parser.add_argument('--subscribe', dest='ntf', type=str) ··· 82 80 83 81 if args.sleep: 84 82 time.sleep(args.sleep) 83 + 84 + if args.list_ops: 85 + for op_name, op in ynl.ops.items(): 86 + print(op_name, " [", ", ".join(op.modes), "]") 87 + if args.list_msgs: 88 + for op_name, op in ynl.msgs.items(): 89 + print(op_name, " [", ", ".join(op.modes), "]") 85 90 86 91 try: 87 92 if args.do:
+2
tools/net/ynl/lib/nlspec.py
··· 335 335 336 336 req_value numerical ID when serialized, user -> kernel 337 337 rsp_value numerical ID when serialized, user <- kernel 338 + modes supported operation modes (do, dump, event etc.) 338 339 is_call bool, whether the operation is a call 339 340 is_async bool, whether the operation is a notification 340 341 is_resv bool, whether the operation does not exist (it's just a reserved ID) ··· 351 350 self.req_value = req_value 352 351 self.rsp_value = rsp_value 353 352 353 + self.modes = yaml.keys() & {'do', 'dump', 'event', 'notify'} 354 354 self.is_call = 'do' in yaml or 'dump' in yaml 355 355 self.is_async = 'notify' in yaml or 'event' in yaml 356 356 self.is_resv = not self.is_async and not self.is_call