* [PATCH net-next 0/5] tools: ynl-gen: print setters for multi-val attrs
@ 2025-07-22 16:19 Jakub Kicinski
2025-07-22 16:19 ` [PATCH net-next 1/5] tools: ynl-gen: don't add suffix for pure types Jakub Kicinski
` (5 more replies)
0 siblings, 6 replies; 13+ messages in thread
From: Jakub Kicinski @ 2025-07-22 16:19 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, donald.hunter,
almasrymina, sdf, Jakub Kicinski
ncdevmem seems to manually prepare the queue attributes. This is not
ideal, YNL should be providing helpers for this. Make YNL output
allocation and setter helpers for multi-val attrs.
Jakub Kicinski (5):
tools: ynl-gen: don't add suffix for pure types
tools: ynl-gen: move free printing to the print_type_full() helper
tools: ynl-gen: print alloc helper for multi-val attrs
tools: ynl-gen: print setters for multi-val attrs
selftests: drv-net: devmem: use new mattr ynl helpers
.../selftests/drivers/net/hw/ncdevmem.c | 8 ++-
tools/net/ynl/pyynl/ynl_gen_c.py | 49 ++++++++++++++-----
2 files changed, 39 insertions(+), 18 deletions(-)
--
2.50.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net-next 1/5] tools: ynl-gen: don't add suffix for pure types
2025-07-22 16:19 [PATCH net-next 0/5] tools: ynl-gen: print setters for multi-val attrs Jakub Kicinski
@ 2025-07-22 16:19 ` Jakub Kicinski
2025-07-23 8:52 ` Donald Hunter
2025-07-22 16:19 ` [PATCH net-next 2/5] tools: ynl-gen: move free printing to the print_type_full() helper Jakub Kicinski
` (4 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Jakub Kicinski @ 2025-07-22 16:19 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, donald.hunter,
almasrymina, sdf, Jakub Kicinski
Don't add _req to helper names for pure types. We don't currently
print those so it makes no difference to existing codegen.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
tools/net/ynl/pyynl/ynl_gen_c.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index 76032e01c2e7..1bdcc368e776 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -1879,7 +1879,9 @@ _C_KW = {
def op_prefix(ri, direction, deref=False):
suffix = f"_{ri.type_name}"
- if not ri.op_mode or ri.op_mode == 'do':
+ if not ri.op_mode:
+ pass
+ elif ri.op_mode == 'do':
suffix += f"{direction_to_suffix[direction]}"
else:
if direction == 'request':
--
2.50.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 2/5] tools: ynl-gen: move free printing to the print_type_full() helper
2025-07-22 16:19 [PATCH net-next 0/5] tools: ynl-gen: print setters for multi-val attrs Jakub Kicinski
2025-07-22 16:19 ` [PATCH net-next 1/5] tools: ynl-gen: don't add suffix for pure types Jakub Kicinski
@ 2025-07-22 16:19 ` Jakub Kicinski
2025-07-23 8:58 ` Donald Hunter
2025-07-22 16:19 ` [PATCH net-next 3/5] tools: ynl-gen: print alloc helper for multi-val attrs Jakub Kicinski
` (3 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Jakub Kicinski @ 2025-07-22 16:19 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, donald.hunter,
almasrymina, sdf, Jakub Kicinski
Just to avoid making the main function even more enormous,
before adding more things to print move the free printing
to a helper which already prints the type.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
tools/net/ynl/pyynl/ynl_gen_c.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index 1bdcc368e776..dc78542e6c88 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -2546,6 +2546,10 @@ _C_KW = {
def print_type_full(ri, struct):
_print_type(ri, "", struct)
+ if struct.request and struct.in_multi_val:
+ free_rsp_nested_prototype(ri)
+ ri.cw.nl()
+
def print_type_helpers(ri, direction, deref=False):
print_free_prototype(ri, direction)
@@ -3517,9 +3521,6 @@ _C_KW = {
for attr_set, struct in parsed.pure_nested_structs.items():
ri = RenderInfo(cw, parsed, args.mode, "", "", attr_set)
print_type_full(ri, struct)
- if struct.request and struct.in_multi_val:
- free_rsp_nested_prototype(ri)
- cw.nl()
for op_name, op in parsed.ops.items():
cw.p(f"/* ============== {op.enum_name} ============== */")
--
2.50.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 3/5] tools: ynl-gen: print alloc helper for multi-val attrs
2025-07-22 16:19 [PATCH net-next 0/5] tools: ynl-gen: print setters for multi-val attrs Jakub Kicinski
2025-07-22 16:19 ` [PATCH net-next 1/5] tools: ynl-gen: don't add suffix for pure types Jakub Kicinski
2025-07-22 16:19 ` [PATCH net-next 2/5] tools: ynl-gen: move free printing to the print_type_full() helper Jakub Kicinski
@ 2025-07-22 16:19 ` Jakub Kicinski
2025-07-23 9:07 ` Donald Hunter
2025-07-22 16:19 ` [PATCH net-next 4/5] tools: ynl-gen: print setters " Jakub Kicinski
` (2 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Jakub Kicinski @ 2025-07-22 16:19 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, donald.hunter,
almasrymina, sdf, Jakub Kicinski
In general YNL provides allocation and free helpers for types.
For pure nested structs which are used as multi-attr (and therefore
have to be allocated dynamically) we already print a free helper
as it's needed by free of the containing struct.
Add printing of the alloc helper for consistency. The helper
takes the number of entries to allocate as an argument, e.g.:
static inline struct netdev_queue_id *netdev_queue_id_alloc(unsigned int n)
{
return calloc(n, sizeof(struct netdev_queue_id));
}
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
tools/net/ynl/pyynl/ynl_gen_c.py | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index dc78542e6c88..0394b786aa93 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -2472,11 +2472,22 @@ _C_KW = {
return 'obj'
-def print_alloc_wrapper(ri, direction):
+def print_alloc_wrapper(ri, direction, struct=None):
name = op_prefix(ri, direction)
- ri.cw.write_func_prot(f'static inline struct {name} *', f"{name}_alloc", [f"void"])
+ struct_name = name
+ if ri.type_name_conflict:
+ struct_name += '_'
+
+ arg = ["void"]
+ cnt = "1"
+ if struct and struct.in_multi_val:
+ arg = ["unsigned int n"]
+ cnt = "n"
+
+ ri.cw.write_func_prot(f'static inline struct {struct_name} *',
+ f"{name}_alloc", arg)
ri.cw.block_start()
- ri.cw.p(f'return calloc(1, sizeof(struct {name}));')
+ ri.cw.p(f'return calloc({cnt}, sizeof(struct {struct_name}));')
ri.cw.block_end()
@@ -2547,6 +2558,8 @@ _C_KW = {
_print_type(ri, "", struct)
if struct.request and struct.in_multi_val:
+ print_alloc_wrapper(ri, "", struct)
+ ri.cw.nl()
free_rsp_nested_prototype(ri)
ri.cw.nl()
--
2.50.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 4/5] tools: ynl-gen: print setters for multi-val attrs
2025-07-22 16:19 [PATCH net-next 0/5] tools: ynl-gen: print setters for multi-val attrs Jakub Kicinski
` (2 preceding siblings ...)
2025-07-22 16:19 ` [PATCH net-next 3/5] tools: ynl-gen: print alloc helper for multi-val attrs Jakub Kicinski
@ 2025-07-22 16:19 ` Jakub Kicinski
2025-07-23 9:15 ` Donald Hunter
2025-07-22 16:19 ` [PATCH net-next 5/5] selftests: drv-net: devmem: use new mattr ynl helpers Jakub Kicinski
2025-07-22 23:37 ` [PATCH net-next 0/5] tools: ynl-gen: print setters for multi-val attrs Stanislav Fomichev
5 siblings, 1 reply; 13+ messages in thread
From: Jakub Kicinski @ 2025-07-22 16:19 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, donald.hunter,
almasrymina, sdf, Jakub Kicinski
For basic types we "flatten" setters. If a request "a" has a simple
nest "b" with value "val" we print helpers like:
req_set_a_b(struct a *req, int val)
{
req->_present.a = 1;
req->b._present.val = 1;
req->b.val = ...
}
This is not possible for multi-attr because they have to be allocated
dynamically by the user. Print "object level" setters so that user
preparing the object doesn't have to futz with the presence bits
and other YNL internals.
Add the ability to pass in the variable name to generated setters.
Using "req" here doesn't feel right, while the attr is part of a request
it's not the request itself, so it seems cleaner to call it "obj".
Example:
static inline void
netdev_queue_id_set_id(struct netdev_queue_id *obj, __u32 id)
{
obj->_present.id = 1;
obj->id = id;
}
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
tools/net/ynl/pyynl/ynl_gen_c.py | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index 0394b786aa93..d27da46a87ee 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -275,9 +275,8 @@ from lib import SpecSubMessage, SpecSubMessageFormat
def _setter_lines(self, ri, member, presence):
raise Exception(f"Setter not implemented for class type {self.type}")
- def setter(self, ri, space, direction, deref=False, ref=None):
+ def setter(self, ri, space, direction, deref=False, ref=None, var="req"):
ref = (ref if ref else []) + [self.c_name]
- var = "req"
member = f"{var}->{'.'.join(ref)}"
local_vars = []
@@ -332,7 +331,7 @@ from lib import SpecSubMessage, SpecSubMessageFormat
def attr_get(self, ri, var, first):
pass
- def setter(self, ri, space, direction, deref=False, ref=None):
+ def setter(self, ri, space, direction, deref=False, ref=None, var=None):
pass
@@ -355,7 +354,7 @@ from lib import SpecSubMessage, SpecSubMessageFormat
def attr_policy(self, cw):
pass
- def setter(self, ri, space, direction, deref=False, ref=None):
+ def setter(self, ri, space, direction, deref=False, ref=None, var=None):
pass
@@ -695,13 +694,14 @@ from lib import SpecSubMessage, SpecSubMessageFormat
f"parg.data = &{var}->{self.c_name};"]
return get_lines, init_lines, None
- def setter(self, ri, space, direction, deref=False, ref=None):
+ def setter(self, ri, space, direction, deref=False, ref=None, var="req"):
ref = (ref if ref else []) + [self.c_name]
for _, attr in ri.family.pure_nested_structs[self.nested_attrs].member_list():
if attr.is_recursive():
continue
- attr.setter(ri, self.nested_attrs, direction, deref=deref, ref=ref)
+ attr.setter(ri, self.nested_attrs, direction, deref=deref, ref=ref,
+ var=var)
class TypeMultiAttr(Type):
@@ -2563,6 +2563,13 @@ _C_KW = {
free_rsp_nested_prototype(ri)
ri.cw.nl()
+ # Name conflicts are too hard to deal with with the current code base,
+ # they are very rare so don't bother printing setters in that case.
+ if ri.ku_space == 'user' and not ri.type_name_conflict:
+ for _, attr in struct.member_list():
+ attr.setter(ri, ri.attr_set, "", var="obj")
+ ri.cw.nl()
+
def print_type_helpers(ri, direction, deref=False):
print_free_prototype(ri, direction)
--
2.50.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 5/5] selftests: drv-net: devmem: use new mattr ynl helpers
2025-07-22 16:19 [PATCH net-next 0/5] tools: ynl-gen: print setters for multi-val attrs Jakub Kicinski
` (3 preceding siblings ...)
2025-07-22 16:19 ` [PATCH net-next 4/5] tools: ynl-gen: print setters " Jakub Kicinski
@ 2025-07-22 16:19 ` Jakub Kicinski
2025-07-22 21:05 ` Mina Almasry
2025-07-23 9:15 ` Donald Hunter
2025-07-22 23:37 ` [PATCH net-next 0/5] tools: ynl-gen: print setters for multi-val attrs Stanislav Fomichev
5 siblings, 2 replies; 13+ messages in thread
From: Jakub Kicinski @ 2025-07-22 16:19 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, donald.hunter,
almasrymina, sdf, Jakub Kicinski
Use the just-added YNL helpers instead of manually setting
"_present" bits in the queue attrs. Compile tested only.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
tools/testing/selftests/drivers/net/hw/ncdevmem.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/hw/ncdevmem.c b/tools/testing/selftests/drivers/net/hw/ncdevmem.c
index cc9b40d9c5d5..72f828021f83 100644
--- a/tools/testing/selftests/drivers/net/hw/ncdevmem.c
+++ b/tools/testing/selftests/drivers/net/hw/ncdevmem.c
@@ -526,12 +526,10 @@ static struct netdev_queue_id *create_queues(void)
struct netdev_queue_id *queues;
size_t i = 0;
- queues = calloc(num_queues, sizeof(*queues));
+ queues = netdev_queue_id_alloc(num_queues);
for (i = 0; i < num_queues; i++) {
- queues[i]._present.type = 1;
- queues[i]._present.id = 1;
- queues[i].type = NETDEV_QUEUE_TYPE_RX;
- queues[i].id = start_queue + i;
+ netdev_queue_id_set_type(&queues[i], NETDEV_QUEUE_TYPE_RX);
+ netdev_queue_id_set_id(&queues[i], start_queue + i);
}
return queues;
--
2.50.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 5/5] selftests: drv-net: devmem: use new mattr ynl helpers
2025-07-22 16:19 ` [PATCH net-next 5/5] selftests: drv-net: devmem: use new mattr ynl helpers Jakub Kicinski
@ 2025-07-22 21:05 ` Mina Almasry
2025-07-23 9:15 ` Donald Hunter
1 sibling, 0 replies; 13+ messages in thread
From: Mina Almasry @ 2025-07-22 21:05 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
donald.hunter, sdf
On Tue, Jul 22, 2025 at 9:19 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> Use the just-added YNL helpers instead of manually setting
> "_present" bits in the queue attrs. Compile tested only.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Mina Almasry <almasrymina@google.com>
--
Thanks,
Mina
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 0/5] tools: ynl-gen: print setters for multi-val attrs
2025-07-22 16:19 [PATCH net-next 0/5] tools: ynl-gen: print setters for multi-val attrs Jakub Kicinski
` (4 preceding siblings ...)
2025-07-22 16:19 ` [PATCH net-next 5/5] selftests: drv-net: devmem: use new mattr ynl helpers Jakub Kicinski
@ 2025-07-22 23:37 ` Stanislav Fomichev
5 siblings, 0 replies; 13+ messages in thread
From: Stanislav Fomichev @ 2025-07-22 23:37 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
donald.hunter, almasrymina, sdf
On 07/22, Jakub Kicinski wrote:
> ncdevmem seems to manually prepare the queue attributes. This is not
> ideal, YNL should be providing helpers for this. Make YNL output
> allocation and setter helpers for multi-val attrs.
>
> Jakub Kicinski (5):
> tools: ynl-gen: don't add suffix for pure types
> tools: ynl-gen: move free printing to the print_type_full() helper
> tools: ynl-gen: print alloc helper for multi-val attrs
> tools: ynl-gen: print setters for multi-val attrs
> selftests: drv-net: devmem: use new mattr ynl helpers
Nice improvement over manually doing _present.xxx = yyy!
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 1/5] tools: ynl-gen: don't add suffix for pure types
2025-07-22 16:19 ` [PATCH net-next 1/5] tools: ynl-gen: don't add suffix for pure types Jakub Kicinski
@ 2025-07-23 8:52 ` Donald Hunter
0 siblings, 0 replies; 13+ messages in thread
From: Donald Hunter @ 2025-07-23 8:52 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
almasrymina, sdf
Jakub Kicinski <kuba@kernel.org> writes:
> Don't add _req to helper names for pure types. We don't currently
> print those so it makes no difference to existing codegen.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 2/5] tools: ynl-gen: move free printing to the print_type_full() helper
2025-07-22 16:19 ` [PATCH net-next 2/5] tools: ynl-gen: move free printing to the print_type_full() helper Jakub Kicinski
@ 2025-07-23 8:58 ` Donald Hunter
0 siblings, 0 replies; 13+ messages in thread
From: Donald Hunter @ 2025-07-23 8:58 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
almasrymina, sdf
Jakub Kicinski <kuba@kernel.org> writes:
> Just to avoid making the main function even more enormous,
> before adding more things to print move the free printing
> to a helper which already prints the type.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 3/5] tools: ynl-gen: print alloc helper for multi-val attrs
2025-07-22 16:19 ` [PATCH net-next 3/5] tools: ynl-gen: print alloc helper for multi-val attrs Jakub Kicinski
@ 2025-07-23 9:07 ` Donald Hunter
0 siblings, 0 replies; 13+ messages in thread
From: Donald Hunter @ 2025-07-23 9:07 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
almasrymina, sdf
Jakub Kicinski <kuba@kernel.org> writes:
> In general YNL provides allocation and free helpers for types.
> For pure nested structs which are used as multi-attr (and therefore
> have to be allocated dynamically) we already print a free helper
> as it's needed by free of the containing struct.
>
> Add printing of the alloc helper for consistency. The helper
> takes the number of entries to allocate as an argument, e.g.:
>
> static inline struct netdev_queue_id *netdev_queue_id_alloc(unsigned int n)
> {
> return calloc(n, sizeof(struct netdev_queue_id));
> }
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> tools/net/ynl/pyynl/ynl_gen_c.py | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
> index dc78542e6c88..0394b786aa93 100755
> --- a/tools/net/ynl/pyynl/ynl_gen_c.py
> +++ b/tools/net/ynl/pyynl/ynl_gen_c.py
> @@ -2472,11 +2472,22 @@ _C_KW = {
> return 'obj'
>
>
> -def print_alloc_wrapper(ri, direction):
> +def print_alloc_wrapper(ri, direction, struct=None):
> name = op_prefix(ri, direction)
> - ri.cw.write_func_prot(f'static inline struct {name} *', f"{name}_alloc", [f"void"])
> + struct_name = name
> + if ri.type_name_conflict:
> + struct_name += '_'
> +
> + arg = ["void"]
Minor nit: maybe should be args since it is a list, or change it to
arg = "void" and listify in the write_func_prot() call.
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
> + cnt = "1"
> + if struct and struct.in_multi_val:
> + arg = ["unsigned int n"]
> + cnt = "n"
> +
> + ri.cw.write_func_prot(f'static inline struct {struct_name} *',
> + f"{name}_alloc", arg)
> ri.cw.block_start()
> - ri.cw.p(f'return calloc(1, sizeof(struct {name}));')
> + ri.cw.p(f'return calloc({cnt}, sizeof(struct {struct_name}));')
> ri.cw.block_end()
>
>
> @@ -2547,6 +2558,8 @@ _C_KW = {
> _print_type(ri, "", struct)
>
> if struct.request and struct.in_multi_val:
> + print_alloc_wrapper(ri, "", struct)
> + ri.cw.nl()
> free_rsp_nested_prototype(ri)
> ri.cw.nl()
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 4/5] tools: ynl-gen: print setters for multi-val attrs
2025-07-22 16:19 ` [PATCH net-next 4/5] tools: ynl-gen: print setters " Jakub Kicinski
@ 2025-07-23 9:15 ` Donald Hunter
0 siblings, 0 replies; 13+ messages in thread
From: Donald Hunter @ 2025-07-23 9:15 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
almasrymina, sdf
Jakub Kicinski <kuba@kernel.org> writes:
> For basic types we "flatten" setters. If a request "a" has a simple
> nest "b" with value "val" we print helpers like:
>
> req_set_a_b(struct a *req, int val)
> {
> req->_present.a = 1;
> req->b._present.val = 1;
> req->b.val = ...
> }
>
> This is not possible for multi-attr because they have to be allocated
> dynamically by the user. Print "object level" setters so that user
> preparing the object doesn't have to futz with the presence bits
> and other YNL internals.
>
> Add the ability to pass in the variable name to generated setters.
> Using "req" here doesn't feel right, while the attr is part of a request
> it's not the request itself, so it seems cleaner to call it "obj".
>
> Example:
>
> static inline void
> netdev_queue_id_set_id(struct netdev_queue_id *obj, __u32 id)
> {
> obj->_present.id = 1;
> obj->id = id;
> }
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 5/5] selftests: drv-net: devmem: use new mattr ynl helpers
2025-07-22 16:19 ` [PATCH net-next 5/5] selftests: drv-net: devmem: use new mattr ynl helpers Jakub Kicinski
2025-07-22 21:05 ` Mina Almasry
@ 2025-07-23 9:15 ` Donald Hunter
1 sibling, 0 replies; 13+ messages in thread
From: Donald Hunter @ 2025-07-23 9:15 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
almasrymina, sdf
Jakub Kicinski <kuba@kernel.org> writes:
> Use the just-added YNL helpers instead of manually setting
> "_present" bits in the queue attrs. Compile tested only.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-07-23 9:16 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-22 16:19 [PATCH net-next 0/5] tools: ynl-gen: print setters for multi-val attrs Jakub Kicinski
2025-07-22 16:19 ` [PATCH net-next 1/5] tools: ynl-gen: don't add suffix for pure types Jakub Kicinski
2025-07-23 8:52 ` Donald Hunter
2025-07-22 16:19 ` [PATCH net-next 2/5] tools: ynl-gen: move free printing to the print_type_full() helper Jakub Kicinski
2025-07-23 8:58 ` Donald Hunter
2025-07-22 16:19 ` [PATCH net-next 3/5] tools: ynl-gen: print alloc helper for multi-val attrs Jakub Kicinski
2025-07-23 9:07 ` Donald Hunter
2025-07-22 16:19 ` [PATCH net-next 4/5] tools: ynl-gen: print setters " Jakub Kicinski
2025-07-23 9:15 ` Donald Hunter
2025-07-22 16:19 ` [PATCH net-next 5/5] selftests: drv-net: devmem: use new mattr ynl helpers Jakub Kicinski
2025-07-22 21:05 ` Mina Almasry
2025-07-23 9:15 ` Donald Hunter
2025-07-22 23:37 ` [PATCH net-next 0/5] tools: ynl-gen: print setters for multi-val attrs Stanislav Fomichev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).