aboutsummaryrefslogtreecommitdiff
path: root/tools/net/ynl/lib/nlspec.py
AgeCommit message (Collapse)AuthorFilesLines
2023-03-30tools: ynl: ethtool testing toolStanislav Fomichev1-0/+9
This is what I've been using to see whether the spec makes sense. A small subset of getters (mostly the unprivileged ones) is implemented. Some setters (channels) also work. Setters for messages with bitmasks are not implemented. Initially I was trying to make this tool look 1:1 like real ethtool, but eventually gave up :-) Sample output: $ ./tools/net/ynl/ethtool enp0s31f6 Settings for enp0s31f6: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supported pause frame use: no Supports auto-negotiation: yes Supported FEC modes: Not reported Speed: Unknown! Duplex: Unknown! (255) Auto-negotiation: on Port: Twisted Pair PHYAD: 2 Transceiver: Internal MDI-X: Unknown (auto) Current message level: drv probe link Link detected: no Signed-off-by: Stanislav Fomichev <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
2023-03-30tools: ynl: support byte-order in cliStanislav Fomichev1-0/+1
Used by ethtool spec. Signed-off-by: Stanislav Fomichev <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
2023-03-28tools: ynl: Add fixed-header support to ynlDonald Hunter1-8/+13
Add support for netlink families that add an optional fixed header structure after the genetlink header and before any attributes. The fixed-header can be specified on a per op basis, or once for all operations, which serves as a default value that can be overridden. Signed-off-by: Donald Hunter <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
2023-03-28tools: ynl: Add struct attr decoding to ynlDonald Hunter1-0/+2
Add support for decoding attributes that contain C structs. Signed-off-by: Donald Hunter <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
2023-03-28tools: ynl: Add C array attribute decoding to ynlDonald Hunter1-2/+5
Add support for decoding C arrays from binay blobs in genetlink-legacy messages. Signed-off-by: Donald Hunter <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
2023-03-28tools: ynl: Add struct parsing to nlspecDonald Hunter1-0/+43
Add python classes for struct definitions to nlspec Signed-off-by: Donald Hunter <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
2023-03-27tools: ynl: default to treating enums as flags for mask generationJakub Kicinski1-4/+4
I was a bit too optimistic in commit bf51d27704c9 ("tools: ynl: fix get_mask utility routine"), not every mask we use is necessarily coming from an enum of type "flags". We also allow flipping an enum into flags on per-attribute basis. That's done by the 'enum-as-flags' property of an attribute. Restore this functionality, it's not currently used by any in-tree family. Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-03-16ynl: make the tooling check the licenseJakub Kicinski1-0/+8
The (only recently documented) expectation is that all specs are under a certain license, but we don't actually enforce it. What's worse we then go ahead and assume the license was right, outputting the expected license into generated files. Fixes: 37d9df224d1e ("ynl: re-license uniformly under GPL-2.0 OR BSD-3-Clause") Reviewed-by: Chuck Lever <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
2023-03-16tools: ynl: make definitions optional againJakub Kicinski1-1/+2
definitions are optional, commit in question breaks cli for ethtool. Fixes: 6517a60b0307 ("tools: ynl: move the enum classes to shared code") Reviewed-by: Chuck Lever <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
2023-03-10tools: ynl: fix get_mask utility routineLorenzo Bianconi1-4/+2
Fix get_mask utility routine in order to take into account possible gaps in the elements list. Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink") Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
2023-03-08tools: ynl: fix enum-as-flags in the generic CLIJakub Kicinski1-2/+5
Lorenzo points out that the generic CLI is broken for the netdev family. When I added the support for documentation of enums (and sparse enums) the client script was not updated. It expects the values in enum to be a list of names, now it can also be a dict (YAML object). Reported-by: Lorenzo Bianconi <[email protected]> Fixes: e4b48ed460d3 ("tools: ynl: add a completely generic client") Signed-off-by: Jakub Kicinski <[email protected]>
2023-03-08tools: ynl: move the enum classes to shared codeJakub Kicinski1-0/+96
Move bulk of the EnumSet and EnumEntry code to shared code for reuse by cli. Signed-off-by: Jakub Kicinski <[email protected]>
2023-03-07ynl: re-license uniformly under GPL-2.0 OR BSD-3-ClauseJakub Kicinski1-1/+1
I was intending to make all the Netlink Spec code BSD-3-Clause to ease the adoption but it appears that: - I fumbled the uAPI and used "GPL WITH uAPI note" there - it gives people pause as they expect GPL in the kernel As suggested by Chuck re-license under dual. This gives us benefit of full BSD freedom while fulfilling the broad "kernel is under GPL" expectations. Link: https://lore.kernel.org/all/[email protected]/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2023-03-03tools: ynl: use 1 as the default for first entry in attrs/opsJakub Kicinski1-3/+3
Pretty much all families use value: 1 or reserve as unspec the first entry in attribute set and the first operation. Make this the default. Update documentation (the doc for values of operations just refers back to doc for attrs so updating only attrs). Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-03-03tools: ynl: fully inherit attrs in subsetsJakub Kicinski1-8/+15
To avoid having to repeat the entire definition of an attribute (including the value) use the Attr object from the original set. In fact this is already the documented expectation. Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink") Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-02-24tools: ynl-gen: re-raise the exception instead of printingJakub Kicinski1-3/+1
traceback.print_exception() seems tricky to call, we're missing some argument, so re-raise instead. Reported-by: Chuck Lever III <[email protected]> Fixes: 3aacf8281336 ("tools: ynl: add an object hierarchy to represent parsed spec") Signed-off-by: Jakub Kicinski <[email protected]>
2023-01-31tools: ynl: load jsonschema on demandJakub Kicinski1-1/+10
The CLI script tries to validate jsonschema by default. It's seems better to validate too many times than too few. However, when copying the scripts to random servers having to install jsonschema is tedious. Load jsonschema via importlib, and let the user opt out. Signed-off-by: Jakub Kicinski <[email protected]>
2023-01-31tools: ynl: add an object hierarchy to represent parsed specJakub Kicinski1-0/+301
There's a lot of copy and pasting going on between the "cli" and code gen when it comes to representing the parsed spec. Create a library which both can use. Signed-off-by: Jakub Kicinski <[email protected]>