Skip to content

Commit 6afb936

Browse files
committed
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/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 987b71f + a115b92 commit 6afb936

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

tools/net/ynl/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ SUBDIRS = lib generated samples
44

55
all: $(SUBDIRS)
66

7+
samples: | lib generated
8+
79
$(SUBDIRS):
810
@if [ -f "$@/Makefile" ] ; then \
911
$(MAKE) -C $@ ; \

tools/net/ynl/samples/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ include $(wildcard *.d)
1818

1919
all: $(BINS)
2020

21+
CFLAGS_page-pool=$(CFLAGS_netdev)
22+
2123
$(BINS): ../lib/ynl.a ../generated/protos.a $(SRCS)
2224
@echo -e '\tCC sample $@'
2325
@$(COMPILE.c) $(CFLAGS_$@) $@.c -o $@.o

tools/net/ynl/samples/page-pool.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ int main(int argc, char **argv)
8181
struct stat *s = find_ifc(&a, pp->ifindex);
8282

8383
count(s, 1, pp);
84-
if (pp->_present.destroyed)
84+
if (pp->_present.detach_time)
8585
count(s, 0, pp);
8686
}
8787
netdev_page_pool_get_list_free(pools);

tools/net/ynl/ynl-gen-c.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -1164,8 +1164,9 @@ def __init__(self, cw, family, ku_space, op, op_mode, attr_set=None):
11641164

11651165

11661166
class CodeWriter:
1167-
def __init__(self, nlib, out_file=None):
1167+
def __init__(self, nlib, out_file=None, overwrite=True):
11681168
self.nlib = nlib
1169+
self._overwrite = overwrite
11691170

11701171
self._nl = False
11711172
self._block_end = False
@@ -1186,8 +1187,9 @@ def close_out_file(self):
11861187
return
11871188
# Avoid modifying the file if contents didn't change
11881189
self._out.flush()
1189-
if os.path.isfile(self._out_file) and filecmp.cmp(self._out.name, self._out_file, shallow=False):
1190-
return
1190+
if not self._overwrite and os.path.isfile(self._out_file):
1191+
if filecmp.cmp(self._out.name, self._out_file, shallow=False):
1192+
return
11911193
with open(self._out_file, 'w+') as out_file:
11921194
self._out.seek(0)
11931195
shutil.copyfileobj(self._out, out_file)
@@ -2516,6 +2518,8 @@ def main():
25162518
parser.add_argument('--header', dest='header', action='store_true', default=None)
25172519
parser.add_argument('--source', dest='header', action='store_false')
25182520
parser.add_argument('--user-header', nargs='+', default=[])
2521+
parser.add_argument('--cmp-out', action='store_true', default=None,
2522+
help='Do not overwrite the output file if the new output is identical to the old')
25192523
parser.add_argument('--exclude-op', action='append', default=[])
25202524
parser.add_argument('-o', dest='out_file', type=str, default=None)
25212525
args = parser.parse_args()
@@ -2543,7 +2547,7 @@ def main():
25432547
print(f'Message enum-model {parsed.msg_id_model} not supported for {args.mode} generation')
25442548
os.sys.exit(1)
25452549

2546-
cw = CodeWriter(BaseNlLib(), args.out_file)
2550+
cw = CodeWriter(BaseNlLib(), args.out_file, overwrite=(not args.cmp_out))
25472551

25482552
_, spec_kernel = find_kernel_root(args.spec)
25492553
if args.mode == 'uapi' or args.header:

tools/net/ynl/ynl-regen.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ for f in $files; do
3030
fi
3131

3232
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
3535
done
3636

3737
popd >>/dev/null

0 commit comments

Comments
 (0)