diff options
author | Jakub Kicinski <kuba@kernel.org> | 2023-06-09 14:43:35 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-06-12 11:01:02 +0100 |
commit | 008bcd6835a2f00a46bc91cad32de50d57d1b196 (patch) | |
tree | a615cea5fc885d36b7efa9df250935e895b82348 /tools/net | |
parent | b30a1f305b7bfde19c2ddbb053b51705eef65553 (diff) |
tools: ynl-gen: support excluding tricky ops
The ethtool family has a small handful of quite tricky ops
and a lot of simple very useful ops. Teach ynl-gen to skip
ops so that we can bypass the tricky ones.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/net')
-rw-r--r-- | tools/net/ynl/lib/nlspec.py | 12 | ||||
-rwxr-xr-x | tools/net/ynl/ynl-gen-c.py | 10 |
2 files changed, 17 insertions, 5 deletions
diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py index c5d4a6d476a0..1ba572cae27b 100644 --- a/tools/net/ynl/lib/nlspec.py +++ b/tools/net/ynl/lib/nlspec.py @@ -334,7 +334,7 @@ class SpecFamily(SpecElement): consts dict of all constants/enums fixed_header string, optional name of family default fixed header struct """ - def __init__(self, spec_path, schema_path=None): + def __init__(self, spec_path, schema_path=None, exclude_ops=None): with open(spec_path, "r") as stream: prefix = '# SPDX-License-Identifier: ' first = stream.readline().strip() @@ -349,6 +349,8 @@ class SpecFamily(SpecElement): super().__init__(self, spec) + self._exclude_ops = exclude_ops if exclude_ops else [] + self.proto = self.yaml.get('protocol', 'genetlink') self.msg_id_model = self.yaml['operations'].get('enum-model', 'unified') @@ -449,7 +451,13 @@ class SpecFamily(SpecElement): req_val = None if rsp_val == rsp_val_next: rsp_val = None - op = self.new_operation(elem, req_val, rsp_val) + + skip = False + for exclude in self._exclude_ops: + skip |= bool(exclude.match(elem['name'])) + if not skip: + op = self.new_operation(elem, req_val, rsp_val) + req_val = req_val_next rsp_val = rsp_val_next diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py index 7b051c00cfc3..a55c4cec2529 100755 --- a/tools/net/ynl/ynl-gen-c.py +++ b/tools/net/ynl/ynl-gen-c.py @@ -4,6 +4,7 @@ import argparse import collections import os +import re import yaml from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, SpecEnumEntry @@ -739,7 +740,7 @@ class Operation(SpecOperation): class Family(SpecFamily): - def __init__(self, file_name): + def __init__(self, file_name, exclude_ops): # Added by resolve: self.c_name = None delattr(self, "c_name") @@ -754,7 +755,7 @@ class Family(SpecFamily): self.hooks = None delattr(self, "hooks") - super().__init__(file_name) + super().__init__(file_name, exclude_ops=exclude_ops) self.fam_key = c_upper(self.yaml.get('c-family-name', self.yaml["name"] + '_FAMILY_NAME')) self.ver_key = c_upper(self.yaml.get('c-version-name', self.yaml["name"] + '_FAMILY_VERSION')) @@ -2241,6 +2242,7 @@ def main(): parser.add_argument('--header', dest='header', action='store_true', default=None) parser.add_argument('--source', dest='header', action='store_false') parser.add_argument('--user-header', nargs='+', default=[]) + parser.add_argument('--exclude-op', action='append', default=[]) parser.add_argument('-o', dest='out_file', type=str) args = parser.parse_args() @@ -2249,8 +2251,10 @@ def main(): if args.header is None: parser.error("--header or --source is required") + exclude_ops = [re.compile(expr) for expr in args.exclude_op] + try: - parsed = Family(args.spec) + parsed = Family(args.spec, exclude_ops) if parsed.license != '((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)': print('Spec license:', parsed.license) print('License must be: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)') |