[PATCH RFC net-next v2 07/18] net: ethtool: Add support for ethnl_info_init_ntf helper function

Kory Maincent posted 18 patches 3 weeks, 4 days ago
There is a newer version of this series
[PATCH RFC net-next v2 07/18] net: ethtool: Add support for ethnl_info_init_ntf helper function
Posted by Kory Maincent 3 weeks, 4 days ago
From: Kory Maincent (Dent Project) <kory.maincent@bootlin.com>

Introduce support for the ethnl_info_init_ntf helper function to enable
initialization of ethtool notifications outside of the netlink.c file.
This change allows for more flexible notification handling.

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---

changes in v2:
- new patch.
---
 net/ethtool/netlink.c | 5 +++++
 net/ethtool/netlink.h | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index e3f0ef6b851b..808cc8096f93 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -805,6 +805,11 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
 typedef void (*ethnl_notify_handler_t)(struct net_device *dev, unsigned int cmd,
 				       const void *data);
 
+void ethnl_info_init_ntf(struct genl_info *info, u8 cmd)
+{
+	genl_info_init_ntf(info, &ethtool_genl_family, cmd);
+}
+
 static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
 	[ETHTOOL_MSG_LINKINFO_NTF]	= ethnl_default_notify,
 	[ETHTOOL_MSG_LINKMODES_NTF]	= ethnl_default_notify,
diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
index 203b08eb6c6f..d04a8e9d54db 100644
--- a/net/ethtool/netlink.h
+++ b/net/ethtool/netlink.h
@@ -322,6 +322,8 @@ struct ethnl_sock_priv {
 int ethnl_sock_priv_set(struct sk_buff *skb, struct net_device *dev, u32 portid,
 			enum ethnl_sock_type type);
 
+void ethnl_info_init_ntf(struct genl_info *info, u8 cmd);
+
 /**
  * struct ethnl_request_ops - unified handling of GET and SET requests
  * @request_cmd:      command id for request (GET)

-- 
2.34.1
Re: [PATCH RFC net-next v2 07/18] net: ethtool: Add support for ethnl_info_init_ntf helper function
Posted by Andrew Lunn 3 weeks, 3 days ago
On Wed, Oct 30, 2024 at 05:53:09PM +0100, Kory Maincent wrote:
> From: Kory Maincent (Dent Project) <kory.maincent@bootlin.com>
> 
> Introduce support for the ethnl_info_init_ntf helper function to enable
> initialization of ethtool notifications outside of the netlink.c file.
> This change allows for more flexible notification handling.
> 
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> ---
> 
> changes in v2:
> - new patch.
> ---
>  net/ethtool/netlink.c | 5 +++++
>  net/ethtool/netlink.h | 2 ++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
> index e3f0ef6b851b..808cc8096f93 100644
> --- a/net/ethtool/netlink.c
> +++ b/net/ethtool/netlink.c
> @@ -805,6 +805,11 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
>  typedef void (*ethnl_notify_handler_t)(struct net_device *dev, unsigned int cmd,
>  				       const void *data);
>  
> +void ethnl_info_init_ntf(struct genl_info *info, u8 cmd)
> +{
> +	genl_info_init_ntf(info, &ethtool_genl_family, cmd);
> +}
> +

I've not looked at the users yet. Does this need EXPORT_SYMBOL_GPL()?

	Andrew
Re: [PATCH RFC net-next v2 07/18] net: ethtool: Add support for ethnl_info_init_ntf helper function
Posted by Kory Maincent 2 weeks, 5 days ago
On Thu, 31 Oct 2024 22:44:51 +0100
Andrew Lunn <andrew@lunn.ch> wrote:

> On Wed, Oct 30, 2024 at 05:53:09PM +0100, Kory Maincent wrote:
> > From: Kory Maincent (Dent Project) <kory.maincent@bootlin.com>
> > 
> > Introduce support for the ethnl_info_init_ntf helper function to enable
> > initialization of ethtool notifications outside of the netlink.c file.
> > This change allows for more flexible notification handling.
> > 
> > Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> > ---
> > 
> > changes in v2:
> > - new patch.
> > ---
> >  net/ethtool/netlink.c | 5 +++++
> >  net/ethtool/netlink.h | 2 ++
> >  2 files changed, 7 insertions(+)
> > 
> > diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
> > index e3f0ef6b851b..808cc8096f93 100644
> > --- a/net/ethtool/netlink.c
> > +++ b/net/ethtool/netlink.c
> > @@ -805,6 +805,11 @@ static void ethnl_default_notify(struct net_device
> > *dev, unsigned int cmd, typedef void (*ethnl_notify_handler_t)(struct
> > net_device *dev, unsigned int cmd, const void *data);
> >  
> > +void ethnl_info_init_ntf(struct genl_info *info, u8 cmd)
> > +{
> > +	genl_info_init_ntf(info, &ethtool_genl_family, cmd);
> > +}
> > +  
> 
> I've not looked at the users yet. Does this need EXPORT_SYMBOL_GPL()?

No it doesn't as the user is net/ethtool/pse-pd.c

Regards,
-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com