Skip to content

Commit ab88c2b

Browse files
jstancekkuba-moo
authored andcommitted
tools: ynl: move python code to separate sub-directory
Move python code to a separate directory so it can be packaged as a python module. Updates existing references in selftests and docs. Also rename ynl-gen-[c|rst] to ynl_gen_[c|rst], avoid dashes as these prevent easy imports for entrypoints. Signed-off-by: Jan Stancek <[email protected]> Reviewed-by: Donald Hunter <[email protected]> Link: https://patch.msgid.link/a4151bad0e6984e7164d395125ce87fd2e048bf1.1736343575.git.jstancek@redhat.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 93e505a commit ab88c2b

File tree

21 files changed

+20
-17
lines changed

21 files changed

+20
-17
lines changed

Documentation/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
104104
YNL_INDEX:=$(srctree)/Documentation/networking/netlink_spec/index.rst
105105
YNL_RST_DIR:=$(srctree)/Documentation/networking/netlink_spec
106106
YNL_YAML_DIR:=$(srctree)/Documentation/netlink/specs
107-
YNL_TOOL:=$(srctree)/tools/net/ynl/ynl-gen-rst.py
107+
YNL_TOOL:=$(srctree)/tools/net/ynl/pyynl/ynl_gen_rst.py
108108

109109
YNL_RST_FILES_TMP := $(patsubst %.yaml,%.rst,$(wildcard $(YNL_YAML_DIR)/*.yaml))
110110
YNL_RST_FILES := $(patsubst $(YNL_YAML_DIR)%,$(YNL_RST_DIR)%, $(YNL_RST_FILES_TMP))

Documentation/networking/multi-pf-netdev.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Observability
8989
=============
9090
The relation between PF, irq, napi, and queue can be observed via netlink spec::
9191

92-
$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml --dump queue-get --json='{"ifindex": 13}'
92+
$ ./tools/net/ynl/pyynl/cli.py --spec Documentation/netlink/specs/netdev.yaml --dump queue-get --json='{"ifindex": 13}'
9393
[{'id': 0, 'ifindex': 13, 'napi-id': 539, 'type': 'rx'},
9494
{'id': 1, 'ifindex': 13, 'napi-id': 540, 'type': 'rx'},
9595
{'id': 2, 'ifindex': 13, 'napi-id': 541, 'type': 'rx'},
@@ -101,7 +101,7 @@ The relation between PF, irq, napi, and queue can be observed via netlink spec::
101101
{'id': 3, 'ifindex': 13, 'napi-id': 542, 'type': 'tx'},
102102
{'id': 4, 'ifindex': 13, 'napi-id': 543, 'type': 'tx'}]
103103

104-
$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml --dump napi-get --json='{"ifindex": 13}'
104+
$ ./tools/net/ynl/pyynl/cli.py --spec Documentation/netlink/specs/netdev.yaml --dump napi-get --json='{"ifindex": 13}'
105105
[{'id': 543, 'ifindex': 13, 'irq': 42},
106106
{'id': 542, 'ifindex': 13, 'irq': 41},
107107
{'id': 541, 'ifindex': 13, 'irq': 40},

Documentation/networking/napi.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,13 @@ parameters mentioned above use hyphens instead of underscores:
199199

200200
Per-NAPI configuration can be done programmatically in a user application
201201
or by using a script included in the kernel source tree:
202-
``tools/net/ynl/cli.py``.
202+
``tools/net/ynl/pyynl/cli.py``.
203203

204204
For example, using the script:
205205

206206
.. code-block:: bash
207207
208-
$ kernel-source/tools/net/ynl/cli.py \
208+
$ kernel-source/tools/net/ynl/pyynl/cli.py \
209209
--spec Documentation/netlink/specs/netdev.yaml \
210210
--do napi-set \
211211
--json='{"id": 345,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
SPDX-License-Identifier: GPL-2.0
22

33
This file is populated during the build of the documentation (htmldocs) by the
4-
tools/net/ynl/ynl-gen-rst.py script.
4+
tools/net/ynl/pyynl/ynl_gen_rst.py script.

Documentation/userspace-api/netlink/intro-specs.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ developing Netlink related code. The tool is implemented in Python
1515
and can use a YAML specification to issue Netlink requests
1616
to the kernel. Only Generic Netlink is supported.
1717

18-
The tool is located at ``tools/net/ynl/cli.py``. It accepts
18+
The tool is located at ``tools/net/ynl/pyynl/cli.py``. It accepts
1919
a handul of arguments, the most important ones are:
2020

2121
- ``--spec`` - point to the spec file
@@ -27,7 +27,7 @@ YAML specs can be found under ``Documentation/netlink/specs/``.
2727

2828
Example use::
2929

30-
$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/ethtool.yaml \
30+
$ ./tools/net/ynl/pyynl/cli.py --spec Documentation/netlink/specs/ethtool.yaml \
3131
--do rings-get \
3232
--json '{"header":{"dev-index": 18}}'
3333
{'header': {'dev-index': 18, 'dev-name': 'eni1np1'},
@@ -75,7 +75,7 @@ the two marker lines like above to a file, add that file to git,
7575
and run the regeneration tool. Grep the tree for ``YNL-GEN``
7676
to see other examples.
7777

78-
The code generation itself is performed by ``tools/net/ynl/ynl-gen-c.py``
78+
The code generation itself is performed by ``tools/net/ynl/pyynl/ynl_gen_c.py``
7979
but it takes a few arguments so calling it directly for each file
8080
quickly becomes tedious.
8181

@@ -84,7 +84,7 @@ YNL lib
8484

8585
``tools/net/ynl/lib/`` contains an implementation of a C library
8686
(based on libmnl) which integrates with code generated by
87-
``tools/net/ynl/ynl-gen-c.py`` to create easy to use netlink wrappers.
87+
``tools/net/ynl/pyynl/ynl_gen_c.py`` to create easy to use netlink wrappers.
8888

8989
YNL basics
9090
----------

tools/net/ynl/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ clean distclean:
2121
fi \
2222
done
2323
rm -f libynl.a
24+
rm -rf pyynl/__pycache__
25+
rm -rf pyynl/lib/__pycache__
2426

2527
.PHONY: all clean distclean $(SUBDIRS)

tools/net/ynl/generated/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ include ../Makefile.deps
1212
YNL_GEN_ARG_ethtool:=--user-header linux/ethtool_netlink.h \
1313
--exclude-op stats-get
1414

15-
TOOL:=../ynl-gen-c.py
15+
TOOL:=../pyynl/ynl_gen_c.py
1616

1717
GENS_PATHS=$(shell grep -nrI --files-without-match \
1818
'protocol: netlink' \

tools/net/ynl/lib/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
__pycache__/
21
*.d

tools/net/ynl/lib/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ ynl.a: $(OBJS)
1919

2020
clean:
2121
rm -f *.o *.d *~
22-
rm -rf __pycache__
2322

2423
distclean: clean
2524
rm -f *.a

tools/net/ynl/pyynl/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__pycache__/
2+
lib/__pycache__/

0 commit comments

Comments
 (0)