diff mbox series

[v3,net-next,2/9] net: devlink: region: Pass the region ops to the snapshot function

Message ID 20200909235827.3335881-3-andrew@lunn.ch
State New
Headers show
Series None | expand

Commit Message

Andrew Lunn Sept. 9, 2020, 11:58 p.m. UTC
Pass the region to be snapshotted to the function performing the
snapshot. This allows one function to operate on numerous regions.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/ethernet/intel/ice/ice_devlink.c | 2 ++
 drivers/net/netdevsim/dev.c                  | 6 ++++--
 include/net/devlink.h                        | 4 +++-
 net/core/devlink.c                           | 2 +-
 4 files changed, 10 insertions(+), 4 deletions(-)

Comments

Andrew Lunn Sept. 10, 2020, 3:09 p.m. UTC | #1
On Thu, Sep 10, 2020 at 07:38:16AM -0700, Jakub Kicinski wrote:
> On Thu, 10 Sep 2020 01:58:20 +0200 Andrew Lunn wrote:
> > diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c
> > index 111d6bfe4222..eb189d2070ae 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_devlink.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_devlink.c
> > @@ -413,6 +413,7 @@ void ice_devlink_destroy_port(struct ice_pf *pf)
> >   * error code on failure.
> >   */
> >  static int ice_devlink_nvm_snapshot(struct devlink *devlink,
> > +				    const struct devlink_region_ops *ops,
> >  				    struct netlink_ext_ack *extack, u8 **data)
> >  {
> >  	struct ice_pf *pf = devlink_priv(devlink);
> > @@ -468,6 +469,7 @@ static int ice_devlink_nvm_snapshot(struct devlink *devlink,
> >   */
> >  static int
> >  ice_devlink_devcaps_snapshot(struct devlink *devlink,
> > +			     const struct devlink_region_ops *ops,
> >  			     struct netlink_ext_ack *extack, u8 **data)
> >  {
> >  	struct ice_pf *pf = devlink_priv(devlink);
> 
> 
> drivers/net/ethernet/intel/ice/ice_devlink.c:418: warning: Function parameter or member 'ops' not described in 'ice_devlink_nvm_snapshot'
> drivers/net/ethernet/intel/ice/ice_devlink.c:474: warning: Function parameter or member 'ops' not described in 'ice_devlink_devcaps_snapshot'

Thanks Jakub

I did try a W=1 build, but there are so many warnings it is hard to
pick out the new ones. I assume you have some sort of automation for
this? Could you share it?

How far are we from just enabling W=1 by default under drivers/net ?
What is the best way to do this in the Makefiles? I think
drivers/net/phy is now W=1 clean, or very close. So it would be nice
to enable that checking by default.

Thanks
	Andrew
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c
index 111d6bfe4222..eb189d2070ae 100644
--- a/drivers/net/ethernet/intel/ice/ice_devlink.c
+++ b/drivers/net/ethernet/intel/ice/ice_devlink.c
@@ -413,6 +413,7 @@  void ice_devlink_destroy_port(struct ice_pf *pf)
  * error code on failure.
  */
 static int ice_devlink_nvm_snapshot(struct devlink *devlink,
+				    const struct devlink_region_ops *ops,
 				    struct netlink_ext_ack *extack, u8 **data)
 {
 	struct ice_pf *pf = devlink_priv(devlink);
@@ -468,6 +469,7 @@  static int ice_devlink_nvm_snapshot(struct devlink *devlink,
  */
 static int
 ice_devlink_devcaps_snapshot(struct devlink *devlink,
+			     const struct devlink_region_ops *ops,
 			     struct netlink_ext_ack *extack, u8 **data)
 {
 	struct ice_pf *pf = devlink_priv(devlink);
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index 32f339fedb21..cf763ec69bb7 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -40,7 +40,9 @@  static struct dentry *nsim_dev_ddir;
 #define NSIM_DEV_DUMMY_REGION_SIZE (1024 * 32)
 
 static int
-nsim_dev_take_snapshot(struct devlink *devlink, struct netlink_ext_ack *extack,
+nsim_dev_take_snapshot(struct devlink *devlink,
+		       const struct devlink_region_ops *ops,
+		       struct netlink_ext_ack *extack,
 		       u8 **data)
 {
 	void *dummy_data;
@@ -68,7 +70,7 @@  static ssize_t nsim_dev_take_snapshot_write(struct file *file,
 
 	devlink = priv_to_devlink(nsim_dev);
 
-	err = nsim_dev_take_snapshot(devlink, NULL, &dummy_data);
+	err = nsim_dev_take_snapshot(devlink, NULL, NULL, &dummy_data);
 	if (err)
 		return err;
 
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 86ce644260b3..e7de55223cd1 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -547,7 +547,9 @@  struct devlink_info_req;
 struct devlink_region_ops {
 	const char *name;
 	void (*destructor)(const void *data);
-	int (*snapshot)(struct devlink *devlink, struct netlink_ext_ack *extack,
+	int (*snapshot)(struct devlink *devlink,
+			const struct devlink_region_ops *ops,
+			struct netlink_ext_ack *extack,
 			u8 **data);
 	void *priv;
 };
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 91c12612f2b7..5e383a8c44d3 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -4322,7 +4322,7 @@  devlink_nl_cmd_region_new(struct sk_buff *skb, struct genl_info *info)
 		}
 	}
 
-	err = region->ops->snapshot(devlink, info->extack, &data);
+	err = region->ops->snapshot(devlink, region->ops, info->extack, &data);
 	if (err)
 		goto err_snapshot_capture;