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

Merge branch 'tools-ynl-fixes-for-the-page-pool-sample-and-the-generation-process'

Jakub Kicinski says:

====================
tools: ynl: fixes for the page-pool sample and the generation process

Minor fixes to the new sample and the Makefiles.
====================

Link: https://lore.kernel.org/r/20231129193622.2912353-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+15 -7
+2
tools/net/ynl/Makefile
··· 4 4 5 5 all: $(SUBDIRS) 6 6 7 + samples: | lib generated 8 + 7 9 $(SUBDIRS): 8 10 @if [ -f "$@/Makefile" ] ; then \ 9 11 $(MAKE) -C $@ ; \
+2
tools/net/ynl/samples/Makefile
··· 18 18 19 19 all: $(BINS) 20 20 21 + CFLAGS_page-pool=$(CFLAGS_netdev) 22 + 21 23 $(BINS): ../lib/ynl.a ../generated/protos.a $(SRCS) 22 24 @echo -e '\tCC sample $@' 23 25 @$(COMPILE.c) $(CFLAGS_$@) $@.c -o $@.o
+1 -1
tools/net/ynl/samples/page-pool.c
··· 81 81 struct stat *s = find_ifc(&a, pp->ifindex); 82 82 83 83 count(s, 1, pp); 84 - if (pp->_present.destroyed) 84 + if (pp->_present.detach_time) 85 85 count(s, 0, pp); 86 86 } 87 87 netdev_page_pool_get_list_free(pools);
+8 -4
tools/net/ynl/ynl-gen-c.py
··· 1164 1164 1165 1165 1166 1166 class CodeWriter: 1167 - def __init__(self, nlib, out_file=None): 1167 + def __init__(self, nlib, out_file=None, overwrite=True): 1168 1168 self.nlib = nlib 1169 + self._overwrite = overwrite 1169 1170 1170 1171 self._nl = False 1171 1172 self._block_end = False ··· 1187 1186 return 1188 1187 # Avoid modifying the file if contents didn't change 1189 1188 self._out.flush() 1190 - if os.path.isfile(self._out_file) and filecmp.cmp(self._out.name, self._out_file, shallow=False): 1191 - return 1189 + if not self._overwrite and os.path.isfile(self._out_file): 1190 + if filecmp.cmp(self._out.name, self._out_file, shallow=False): 1191 + return 1192 1192 with open(self._out_file, 'w+') as out_file: 1193 1193 self._out.seek(0) 1194 1194 shutil.copyfileobj(self._out, out_file) ··· 2518 2516 parser.add_argument('--header', dest='header', action='store_true', default=None) 2519 2517 parser.add_argument('--source', dest='header', action='store_false') 2520 2518 parser.add_argument('--user-header', nargs='+', default=[]) 2519 + parser.add_argument('--cmp-out', action='store_true', default=None, 2520 + help='Do not overwrite the output file if the new output is identical to the old') 2521 2521 parser.add_argument('--exclude-op', action='append', default=[]) 2522 2522 parser.add_argument('-o', dest='out_file', type=str, default=None) 2523 2523 args = parser.parse_args() ··· 2547 2543 print(f'Message enum-model {parsed.msg_id_model} not supported for {args.mode} generation') 2548 2544 os.sys.exit(1) 2549 2545 2550 - cw = CodeWriter(BaseNlLib(), args.out_file) 2546 + cw = CodeWriter(BaseNlLib(), args.out_file, overwrite=(not args.cmp_out)) 2551 2547 2552 2548 _, spec_kernel = find_kernel_root(args.spec) 2553 2549 if args.mode == 'uapi' or args.header:
+2 -2
tools/net/ynl/ynl-regen.sh
··· 30 30 fi 31 31 32 32 echo -e "\tGEN ${params[2]}\t$f" 33 - $TOOL --mode ${params[2]} --${params[3]} --spec $KDIR/${params[0]} \ 34 - $args -o $f 33 + $TOOL --cmp-out --mode ${params[2]} --${params[3]} \ 34 + --spec $KDIR/${params[0]} $args -o $f 35 35 done 36 36 37 37 popd >>/dev/null