aboutsummaryrefslogtreecommitdiff
path: root/tools/net/ynl/lib
AgeCommit message (Collapse)AuthorFilesLines
2023-03-08tools: ynl: move the enum classes to shared codeJakub Kicinski2-3/+100
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 Kicinski3-3/+3
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: net: add __pycache__ to gitignoreJakub Kicinski1-0/+1
Python will generate its customary cache when running ynl scripts: ?? tools/net/ynl/lib/__pycache__/ Reported-by: Chuck Lever III <[email protected]> Signed-off-by: Jakub Kicinski <[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: use operation names from spec on the CLIJakub Kicinski1-0/+6
When I wrote the first version of the Python code I was quite excited that we can generate class methods directly from the spec. Unfortunately we need to use valid identifiers for method names (specifically no dashes are allowed). Don't reuse those names on the CLI, it's much more natural to use the operation names exactly as listed in the spec. Instead of: ./cli --do rings_get use: ./cli --do rings-get Signed-off-by: Jakub Kicinski <[email protected]>
2023-01-31tools: ynl: support pretty printing bad attribute namesJakub Kicinski1-0/+40
One of my favorite features of the Netlink specs is that they make decoding structured extack a ton easier. Implement pretty printing bad attribute names in YNL. For example it will now say: 'bad-attr': '.header.flags' rather than the useless: 'bad-attr-offs': 32 Proof: $ ./cli.py --spec ethtool.yaml --do rings_get \ --json '{"header":{"dev-index":1, "flags":4}}' Netlink error: Invalid argument nl_len = 68 (52) nl_flags = 0x300 nl_type = 2 error: -22 extack: {'msg': 'reserved bit set', 'bad-attr': '.header.flags'} Signed-off-by: Jakub Kicinski <[email protected]>
2023-01-31tools: ynl: support multi-attrJakub Kicinski1-7/+14
Ethtool uses mutli-attr, add the support to YNL. Signed-off-by: Jakub Kicinski <[email protected]>
2023-01-31tools: ynl: support directional enum-model in CLIJakub Kicinski1-4/+4
Support families which use different IDs for messages to and from the kernel. Signed-off-by: Jakub Kicinski <[email protected]>
2023-01-31tools: ynl: add support for types needed by ethtoolJakub Kicinski1-1/+10
Ethtool needs support for handful of extra types. It doesn't have the definitions section yet. Signed-off-by: Jakub Kicinski <[email protected]>
2023-01-31tools: ynl: use the common YAML loading and validation codeJakub Kicinski1-93/+25
Adapt the common object hierarchy in code gen and CLI. Signed-off-by: Jakub Kicinski <[email protected]>
2023-01-31tools: ynl: add an object hierarchy to represent parsed specJakub Kicinski2-1/+304
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]>
2023-01-31tools: ynl: move the cli and netlink code aroundJakub Kicinski2-0/+539
Move the CLI code out of samples/ and the library part of it into tools/net/ynl/lib/. This way we can start sharing some code with the code gen. Initially I thought that code gen is too C-specific to share anything but basic stuff like calculating values for enums can easily be shared. Signed-off-by: Jakub Kicinski <[email protected]>