All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, ast@kernel.org,
	daniel@iogearbox.net, andrii@kernel.org, davem@davemloft.net,
	hawk@kernel.org, pabeni@redhat.com, edumazet@google.com,
	toke@redhat.com, memxor@gmail.com, alardam@gmail.com,
	saeedm@nvidia.com, anthony.l.nguyen@intel.com,
	gospo@broadcom.com, vladimir.oltean@nxp.com, nbd@nbd.name,
	john@phrozen.org, leon@kernel.org, simon.horman@corigine.com,
	aelior@marvell.com, christophe.jaillet@wanadoo.fr,
	ecree.xilinx@gmail.com, mst@redhat.com, bjorn@kernel.org,
	magnus.karlsson@intel.com, maciej.fijalkowski@intel.com,
	intel-wired-lan@lists.osuosl.org, lorenzo.bianconi@redhat.com,
	niklas.soderlund@corigine.com
Subject: Re: [PATCH bpf-next 1/7] netdev-genl: create a simple family for netdev stuff
Date: Mon, 23 Jan 2023 00:00:15 +0100	[thread overview]
Message-ID: <Y82//2EX6QQoZkV/@lore-desk> (raw)
In-Reply-To: <20230120191126.06c9d514@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 5083 bytes --]

> On Fri, 20 Jan 2023 18:16:50 +0100 Lorenzo Bianconi wrote:
> > From: Jakub Kicinski <kuba@kernel.org>
> > 
> > Add a Netlink spec-compatible family for netdevs.
> > This is a very simple implementation without much
> > thought going into it.
> > 
> > It allows us to reap all the benefits of Netlink specs,
> > one can use the generic client to issue the commands:
> > 
> >   $ ./gen.py --spec netdev.yaml --do dev_get --json='{"ifindex": 2}'
> >   {'ifindex': 2, 'xdp-features': 31}
> > 
> >   $ ./gen.py --spec netdev.yaml --dump dev_get
> >   [{'ifindex': 1, 'xdp-features': 0}, {'ifindex': 2, 'xdp-features': 31}]
> 
> In the meantime I added support for rendering enums in Python.
> So you can show names in the example. eg:
> 
> $ ./cli.py --spec netdev.yaml --dump dev_get 
> [{'ifindex': 1, 'xdp-features': set()},
>  {'ifindex': 2,
>   'xdp-features': {'ndo-xmit', 'pass', 'redirect', 'aborted', 'drop'}},
>  {'ifindex': 3, 'xdp-features': {'rx-sg'}}]
> 
> > the generic python library does not have flags-by-name
> > support, yet, but we also don't have to carry strings
> > in the messages, as user space can get the names from
> > the spec.
> > 
> > Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > Co-developed-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> > Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> > Co-developed-by: Marek Majtyka <alardam@gmail.com>
> > Signed-off-by: Marek Majtyka <alardam@gmail.com>
> > Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> > ---
> >  Documentation/netlink/specs/netdev.yaml |  72 ++++++++++
> 
> FWIW I'm not 100% sure if we should scope the family to all of netdev
> or just xdp. Same for the name of the op, should we call the op dev_get
> or dev_xdp_get..

is it likely we are going to add non-xdp info here in the near future? If not
I would say we can target just xdp for the moment.

> 
> > diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h
> > new file mode 100644
> > index 000000000000..254fc336d469
> > --- /dev/null
> > +++ b/include/uapi/linux/netdev.h
> > @@ -0,0 +1,66 @@
> > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> > +/* Do not edit directly, auto-generated from: */
> 
> Like this line says, you can't hand edit this file.
> Next time someone adds an attribute all your changes will be wiped.

ack, right.

> 
> > +/*	Documentation/netlink/specs/netdev.yaml */
> > +/* YNL-GEN uapi header */
> > +
> > +#ifndef _UAPI_LINUX_NETDEV_H
> > +#define _UAPI_LINUX_NETDEV_H
> > +
> > +#define NETDEV_FAMILY_NAME	"netdev"
> > +#define NETDEV_FAMILY_VERSION	1
> > +
> > +enum netdev_xdp_act {
> > +	NETDEV_XDP_ACT_ABORTED_BIT,
> > +	NETDEV_XDP_ACT_DROP_BIT,
> > +	NETDEV_XDP_ACT_PASS_BIT,
> > +	NETDEV_XDP_ACT_TX_BIT,
> > +	NETDEV_XDP_ACT_REDIRECT_BIT,
> > +	NETDEV_XDP_ACT_NDO_XMIT_BIT,
> > +	NETDEV_XDP_ACT_XSK_ZEROCOPY_BIT,
> > +	NETDEV_XDP_ACT_HW_OFFLOAD_BIT,
> > +	NETDEV_XDP_ACT_RX_SG_BIT,
> > +	NETDEV_XDP_ACT_NDO_XMIT_SG_BIT
> 
> You need to add -bit to all the enum names in the yaml if you want 
> to have _BIT in the name here.

ack, I do not think it is needed (according to the comment below).

> 
> > +};
> > +
> > +#define NETDEV_XDP_ACT_ABORTED		BIT(NETDEV_XDP_ACT_ABORTED_BIT)
> > +#define NETDEV_XDP_ACT_DROP		BIT(NETDEV_XDP_ACT_DROP_BIT)
> > +#define NETDEV_XDP_ACT_PASS		BIT(NETDEV_XDP_ACT_PASS_BIT)
> > +#define NETDEV_XDP_ACT_TX		BIT(NETDEV_XDP_ACT_TX_BIT)
> > +#define NETDEV_XDP_ACT_REDIRECT		BIT(NETDEV_XDP_ACT_REDIRECT_BIT)
> > +#define NETDEV_XDP_ACT_NDO_XMIT		BIT(NETDEV_XDP_ACT_NDO_XMIT_BIT)
> > +#define NETDEV_XDP_ACT_XSK_ZEROCOPY	BIT(NETDEV_XDP_ACT_XSK_ZEROCOPY_BIT)
> > +#define NETDEV_XDP_ACT_HW_OFFLOAD	BIT(NETDEV_XDP_ACT_HW_OFFLOAD_BIT)
> > +#define NETDEV_XDP_ACT_RX_SG		BIT(NETDEV_XDP_ACT_RX_SG_BIT)
> > +#define NETDEV_XDP_ACT_NDO_XMIT_SG	BIT(NETDEV_XDP_ACT_NDO_XMIT_SG_BIT)
> > +
> > +#define NETDEV_XDP_ACT_BASIC		(NETDEV_XDP_ACT_DROP |	\
> > +					 NETDEV_XDP_ACT_PASS |	\
> > +					 NETDEV_XDP_ACT_TX |	\
> > +					 NETDEV_XDP_ACT_ABORTED)
> > +#define NETDEV_XDP_ACT_FULL		(NETDEV_XDP_ACT_BASIC |	\
> > +					 NETDEV_XDP_ACT_REDIRECT)
> > +#define NETDEV_XDP_ACT_ZC		(NETDEV_XDP_ACT_FULL |	\
> > +					 NETDEV_XDP_ACT_XSK_ZEROCOPY)
> 
> These defines don't belong in uAPI. Especially the use of BIT().

since netdev xdp_features is a bitmask, can we use 'flags' as type for definitions in
netdev.yaml so we can get rid of this BIT() definitions for both user and
kernel space?

> 
> > +			if (err < 0)
> > +				break;
> > +cont:
> > +			idx++;
> > +		}
> > +	}
> > +
> > +	rtnl_unlock();
> > +
> > +	if (err != -EMSGSIZE)
> > +		return err;
> > +
> > +	cb->args[1] = idx;
> > +	cb->args[0] = h;
> > +	cb->seq = net->dev_base_seq;
> > +	nl_dump_check_consistent(cb, nlmsg_hdr(skb));
> 
> I think that this line can be dropped.

ack, I will fix it.

Regards,
Lorenzo

> 
> > +	return skb->len;
> > +}

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: mst@redhat.com, vladimir.oltean@nxp.com, ast@kernel.org,
	edumazet@google.com, anthony.l.nguyen@intel.com,
	daniel@iogearbox.net, niklas.soderlund@corigine.com,
	andrii@kernel.org, intel-wired-lan@lists.osuosl.org,
	simon.horman@corigine.com, pabeni@redhat.com, aelior@marvell.com,
	hawk@kernel.org, christophe.jaillet@wanadoo.fr, memxor@gmail.com,
	john@phrozen.org, bjorn@kernel.org, bpf@vger.kernel.org,
	magnus.karlsson@intel.com, leon@kernel.org,
	netdev@vger.kernel.org, toke@redhat.com, ecree.xilinx@gmail.com,
	alardam@gmail.com, gospo@broadcom.com, saeedm@nvidia.com,
	davem@davemloft.net, nbd@nbd.name
Subject: Re: [Intel-wired-lan] [PATCH bpf-next 1/7] netdev-genl: create a simple family for netdev stuff
Date: Mon, 23 Jan 2023 00:00:15 +0100	[thread overview]
Message-ID: <Y82//2EX6QQoZkV/@lore-desk> (raw)
In-Reply-To: <20230120191126.06c9d514@kernel.org>


[-- Attachment #1.1: Type: text/plain, Size: 5083 bytes --]

> On Fri, 20 Jan 2023 18:16:50 +0100 Lorenzo Bianconi wrote:
> > From: Jakub Kicinski <kuba@kernel.org>
> > 
> > Add a Netlink spec-compatible family for netdevs.
> > This is a very simple implementation without much
> > thought going into it.
> > 
> > It allows us to reap all the benefits of Netlink specs,
> > one can use the generic client to issue the commands:
> > 
> >   $ ./gen.py --spec netdev.yaml --do dev_get --json='{"ifindex": 2}'
> >   {'ifindex': 2, 'xdp-features': 31}
> > 
> >   $ ./gen.py --spec netdev.yaml --dump dev_get
> >   [{'ifindex': 1, 'xdp-features': 0}, {'ifindex': 2, 'xdp-features': 31}]
> 
> In the meantime I added support for rendering enums in Python.
> So you can show names in the example. eg:
> 
> $ ./cli.py --spec netdev.yaml --dump dev_get 
> [{'ifindex': 1, 'xdp-features': set()},
>  {'ifindex': 2,
>   'xdp-features': {'ndo-xmit', 'pass', 'redirect', 'aborted', 'drop'}},
>  {'ifindex': 3, 'xdp-features': {'rx-sg'}}]
> 
> > the generic python library does not have flags-by-name
> > support, yet, but we also don't have to carry strings
> > in the messages, as user space can get the names from
> > the spec.
> > 
> > Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > Co-developed-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> > Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> > Co-developed-by: Marek Majtyka <alardam@gmail.com>
> > Signed-off-by: Marek Majtyka <alardam@gmail.com>
> > Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> > ---
> >  Documentation/netlink/specs/netdev.yaml |  72 ++++++++++
> 
> FWIW I'm not 100% sure if we should scope the family to all of netdev
> or just xdp. Same for the name of the op, should we call the op dev_get
> or dev_xdp_get..

is it likely we are going to add non-xdp info here in the near future? If not
I would say we can target just xdp for the moment.

> 
> > diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h
> > new file mode 100644
> > index 000000000000..254fc336d469
> > --- /dev/null
> > +++ b/include/uapi/linux/netdev.h
> > @@ -0,0 +1,66 @@
> > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> > +/* Do not edit directly, auto-generated from: */
> 
> Like this line says, you can't hand edit this file.
> Next time someone adds an attribute all your changes will be wiped.

ack, right.

> 
> > +/*	Documentation/netlink/specs/netdev.yaml */
> > +/* YNL-GEN uapi header */
> > +
> > +#ifndef _UAPI_LINUX_NETDEV_H
> > +#define _UAPI_LINUX_NETDEV_H
> > +
> > +#define NETDEV_FAMILY_NAME	"netdev"
> > +#define NETDEV_FAMILY_VERSION	1
> > +
> > +enum netdev_xdp_act {
> > +	NETDEV_XDP_ACT_ABORTED_BIT,
> > +	NETDEV_XDP_ACT_DROP_BIT,
> > +	NETDEV_XDP_ACT_PASS_BIT,
> > +	NETDEV_XDP_ACT_TX_BIT,
> > +	NETDEV_XDP_ACT_REDIRECT_BIT,
> > +	NETDEV_XDP_ACT_NDO_XMIT_BIT,
> > +	NETDEV_XDP_ACT_XSK_ZEROCOPY_BIT,
> > +	NETDEV_XDP_ACT_HW_OFFLOAD_BIT,
> > +	NETDEV_XDP_ACT_RX_SG_BIT,
> > +	NETDEV_XDP_ACT_NDO_XMIT_SG_BIT
> 
> You need to add -bit to all the enum names in the yaml if you want 
> to have _BIT in the name here.

ack, I do not think it is needed (according to the comment below).

> 
> > +};
> > +
> > +#define NETDEV_XDP_ACT_ABORTED		BIT(NETDEV_XDP_ACT_ABORTED_BIT)
> > +#define NETDEV_XDP_ACT_DROP		BIT(NETDEV_XDP_ACT_DROP_BIT)
> > +#define NETDEV_XDP_ACT_PASS		BIT(NETDEV_XDP_ACT_PASS_BIT)
> > +#define NETDEV_XDP_ACT_TX		BIT(NETDEV_XDP_ACT_TX_BIT)
> > +#define NETDEV_XDP_ACT_REDIRECT		BIT(NETDEV_XDP_ACT_REDIRECT_BIT)
> > +#define NETDEV_XDP_ACT_NDO_XMIT		BIT(NETDEV_XDP_ACT_NDO_XMIT_BIT)
> > +#define NETDEV_XDP_ACT_XSK_ZEROCOPY	BIT(NETDEV_XDP_ACT_XSK_ZEROCOPY_BIT)
> > +#define NETDEV_XDP_ACT_HW_OFFLOAD	BIT(NETDEV_XDP_ACT_HW_OFFLOAD_BIT)
> > +#define NETDEV_XDP_ACT_RX_SG		BIT(NETDEV_XDP_ACT_RX_SG_BIT)
> > +#define NETDEV_XDP_ACT_NDO_XMIT_SG	BIT(NETDEV_XDP_ACT_NDO_XMIT_SG_BIT)
> > +
> > +#define NETDEV_XDP_ACT_BASIC		(NETDEV_XDP_ACT_DROP |	\
> > +					 NETDEV_XDP_ACT_PASS |	\
> > +					 NETDEV_XDP_ACT_TX |	\
> > +					 NETDEV_XDP_ACT_ABORTED)
> > +#define NETDEV_XDP_ACT_FULL		(NETDEV_XDP_ACT_BASIC |	\
> > +					 NETDEV_XDP_ACT_REDIRECT)
> > +#define NETDEV_XDP_ACT_ZC		(NETDEV_XDP_ACT_FULL |	\
> > +					 NETDEV_XDP_ACT_XSK_ZEROCOPY)
> 
> These defines don't belong in uAPI. Especially the use of BIT().

since netdev xdp_features is a bitmask, can we use 'flags' as type for definitions in
netdev.yaml so we can get rid of this BIT() definitions for both user and
kernel space?

> 
> > +			if (err < 0)
> > +				break;
> > +cont:
> > +			idx++;
> > +		}
> > +	}
> > +
> > +	rtnl_unlock();
> > +
> > +	if (err != -EMSGSIZE)
> > +		return err;
> > +
> > +	cb->args[1] = idx;
> > +	cb->args[0] = h;
> > +	cb->seq = net->dev_base_seq;
> > +	nl_dump_check_consistent(cb, nlmsg_hdr(skb));
> 
> I think that this line can be dropped.

ack, I will fix it.

Regards,
Lorenzo

> 
> > +	return skb->len;
> > +}

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 162 bytes --]

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

  reply	other threads:[~2023-01-22 23:00 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 17:16 [PATCH bpf-next 0/7] xdp: introduce xdp-feature support Lorenzo Bianconi
2023-01-20 17:16 ` [Intel-wired-lan] " Lorenzo Bianconi
2023-01-20 17:16 ` [PATCH bpf-next 1/7] netdev-genl: create a simple family for netdev stuff Lorenzo Bianconi
2023-01-20 17:16   ` [Intel-wired-lan] " Lorenzo Bianconi
2023-01-21  1:19   ` Alexei Starovoitov
2023-01-21  1:19     ` [Intel-wired-lan] " Alexei Starovoitov
2023-01-22 17:45     ` Lorenzo Bianconi
2023-01-22 17:45       ` [Intel-wired-lan] " Lorenzo Bianconi
2023-01-21  3:11   ` Jakub Kicinski
2023-01-21  3:11     ` [Intel-wired-lan] " Jakub Kicinski
2023-01-22 23:00     ` Lorenzo Bianconi [this message]
2023-01-22 23:00       ` Lorenzo Bianconi
2023-01-23 20:01       ` Jakub Kicinski
2023-01-23 20:01         ` [Intel-wired-lan] " Jakub Kicinski
2023-01-23 23:29         ` Lorenzo Bianconi
2023-01-23 23:29           ` [Intel-wired-lan] " Lorenzo Bianconi
2023-01-21  4:42   ` kernel test robot
2023-01-21  4:42     ` [Intel-wired-lan] " kernel test robot
2023-01-20 17:16 ` [PATCH bpf-next 2/7] drivers: net: turn on XDP features Lorenzo Bianconi
2023-01-20 17:16   ` [Intel-wired-lan] " Lorenzo Bianconi
2023-01-21  3:11   ` Jakub Kicinski
2023-01-21  3:11     ` [Intel-wired-lan] " Jakub Kicinski
2023-01-22 11:49     ` Lorenzo Bianconi
2023-01-22 11:49       ` [Intel-wired-lan] " Lorenzo Bianconi
2023-01-23 20:03       ` Jakub Kicinski
2023-01-23 20:03         ` [Intel-wired-lan] " Jakub Kicinski
2023-01-20 17:16 ` [PATCH bpf-next 3/7] xsk: add usage of XDP features flags Lorenzo Bianconi
2023-01-20 17:16   ` [Intel-wired-lan] " Lorenzo Bianconi
2023-01-20 17:16 ` [PATCH bpf-next 4/7] libbpf: add the capability to specify netlink proto in libbpf_netlink_send_recv Lorenzo Bianconi
2023-01-20 17:16   ` [Intel-wired-lan] " Lorenzo Bianconi
2023-01-20 17:16 ` [PATCH bpf-next 5/7] libbpf: add API to get XDP/XSK supported features Lorenzo Bianconi
2023-01-20 17:16   ` [Intel-wired-lan] " Lorenzo Bianconi
2023-01-21  3:20   ` Jakub Kicinski
2023-01-21  3:20     ` [Intel-wired-lan] " Jakub Kicinski
2023-01-22 12:09     ` Lorenzo Bianconi
2023-01-22 12:09       ` [Intel-wired-lan] " Lorenzo Bianconi
2023-01-20 17:16 ` [PATCH bpf-next 6/7] bpf: devmap: check XDP features in bpf_map_update_elem and __xdp_enqueue Lorenzo Bianconi
2023-01-20 17:16   ` [Intel-wired-lan] " Lorenzo Bianconi
2023-01-21  2:02   ` Martin KaFai Lau
2023-01-21  2:02     ` [Intel-wired-lan] " Martin KaFai Lau
2023-01-22 12:13     ` Lorenzo Bianconi
2023-01-22 12:13       ` [Intel-wired-lan] " Lorenzo Bianconi
2023-01-23 20:09       ` Jakub Kicinski
2023-01-23 20:09         ` [Intel-wired-lan] " Jakub Kicinski
2023-01-23 23:29         ` Lorenzo Bianconi
2023-01-23 23:29           ` [Intel-wired-lan] " Lorenzo Bianconi
2023-01-20 17:16 ` [PATCH bpf-next 7/7] selftests/bpf: introduce XDP compliance test tool Lorenzo Bianconi
2023-01-20 17:16   ` [Intel-wired-lan] " Lorenzo Bianconi
2023-01-24  6:34   ` Martin KaFai Lau
2023-01-24  6:34     ` [Intel-wired-lan] " Martin KaFai Lau
2023-01-24 11:12     ` Lorenzo Bianconi
2023-01-24 11:12       ` [Intel-wired-lan] " Lorenzo Bianconi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y82//2EX6QQoZkV/@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=aelior@marvell.com \
    --cc=alardam@gmail.com \
    --cc=andrii@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@google.com \
    --cc=gospo@broadcom.com \
    --cc=hawk@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=john@phrozen.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=memxor@gmail.com \
    --cc=mst@redhat.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=niklas.soderlund@corigine.com \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=simon.horman@corigine.com \
    --cc=toke@redhat.com \
    --cc=vladimir.oltean@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.