Add extack to shared buffer set operations, so that meaningful error
messages could be propagated to the user.

Signed-off-by: Ido Schimmel <[email protected]>
Acked-by: Jiri Pirko <[email protected]>
Reviewed-by: Petr Machata <[email protected]>
Cc: Jakub Kicinski <[email protected]>
---
 drivers/net/ethernet/mellanox/mlxsw/core.c    |  9 +++++---
 .../net/ethernet/netronome/nfp/nfp_devlink.c  |  3 ++-
 include/net/devlink.h                         |  8 ++++---
 net/core/devlink.c                            | 22 +++++++++++--------
 4 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c 
b/drivers/net/ethernet/mellanox/mlxsw/core.c
index 9e8e3e92f369..a6533d42b285 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -781,7 +781,8 @@ mlxsw_devlink_sb_pool_get(struct devlink *devlink,
 static int
 mlxsw_devlink_sb_pool_set(struct devlink *devlink,
                          unsigned int sb_index, u16 pool_index, u32 size,
-                         enum devlink_sb_threshold_type threshold_type)
+                         enum devlink_sb_threshold_type threshold_type,
+                         struct netlink_ext_ack *extack)
 {
        struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
        struct mlxsw_driver *mlxsw_driver = mlxsw_core->driver;
@@ -829,7 +830,8 @@ static int mlxsw_devlink_sb_port_pool_get(struct 
devlink_port *devlink_port,
 
 static int mlxsw_devlink_sb_port_pool_set(struct devlink_port *devlink_port,
                                          unsigned int sb_index, u16 pool_index,
-                                         u32 threshold)
+                                         u32 threshold,
+                                         struct netlink_ext_ack *extack)
 {
        struct mlxsw_core *mlxsw_core = devlink_priv(devlink_port->devlink);
        struct mlxsw_driver *mlxsw_driver = mlxsw_core->driver;
@@ -864,7 +866,8 @@ static int
 mlxsw_devlink_sb_tc_pool_bind_set(struct devlink_port *devlink_port,
                                  unsigned int sb_index, u16 tc_index,
                                  enum devlink_sb_pool_type pool_type,
-                                 u16 pool_index, u32 threshold)
+                                 u16 pool_index, u32 threshold,
+                                 struct netlink_ext_ack *extack)
 {
        struct mlxsw_core *mlxsw_core = devlink_priv(devlink_port->devlink);
        struct mlxsw_driver *mlxsw_driver = mlxsw_core->driver;
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c 
b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
index 8e7591241e7c..c50fce42f473 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
@@ -144,7 +144,8 @@ nfp_devlink_sb_pool_get(struct devlink *devlink, unsigned 
int sb_index,
 static int
 nfp_devlink_sb_pool_set(struct devlink *devlink, unsigned int sb_index,
                        u16 pool_index,
-                       u32 size, enum devlink_sb_threshold_type threshold_type)
+                       u32 size, enum devlink_sb_threshold_type threshold_type,
+                       struct netlink_ext_ack *extack)
 {
        struct nfp_pf *pf = devlink_priv(devlink);
 
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 70c7d1ac8344..4f5e41613503 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -491,13 +491,14 @@ struct devlink_ops {
                           struct devlink_sb_pool_info *pool_info);
        int (*sb_pool_set)(struct devlink *devlink, unsigned int sb_index,
                           u16 pool_index, u32 size,
-                          enum devlink_sb_threshold_type threshold_type);
+                          enum devlink_sb_threshold_type threshold_type,
+                          struct netlink_ext_ack *extack);
        int (*sb_port_pool_get)(struct devlink_port *devlink_port,
                                unsigned int sb_index, u16 pool_index,
                                u32 *p_threshold);
        int (*sb_port_pool_set)(struct devlink_port *devlink_port,
                                unsigned int sb_index, u16 pool_index,
-                               u32 threshold);
+                               u32 threshold, struct netlink_ext_ack *extack);
        int (*sb_tc_pool_bind_get)(struct devlink_port *devlink_port,
                                   unsigned int sb_index,
                                   u16 tc_index,
@@ -507,7 +508,8 @@ struct devlink_ops {
                                   unsigned int sb_index,
                                   u16 tc_index,
                                   enum devlink_sb_pool_type pool_type,
-                                  u16 pool_index, u32 threshold);
+                                  u16 pool_index, u32 threshold,
+                                  struct netlink_ext_ack *extack);
        int (*sb_occ_snapshot)(struct devlink *devlink,
                               unsigned int sb_index);
        int (*sb_occ_max_clear)(struct devlink *devlink,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index b2715a187a11..7b91605e75d6 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -1047,14 +1047,15 @@ static int devlink_nl_cmd_sb_pool_get_dumpit(struct 
sk_buff *msg,
 
 static int devlink_sb_pool_set(struct devlink *devlink, unsigned int sb_index,
                               u16 pool_index, u32 size,
-                              enum devlink_sb_threshold_type threshold_type)
+                              enum devlink_sb_threshold_type threshold_type,
+                              struct netlink_ext_ack *extack)
 
 {
        const struct devlink_ops *ops = devlink->ops;
 
        if (ops->sb_pool_set)
                return ops->sb_pool_set(devlink, sb_index, pool_index,
-                                       size, threshold_type);
+                                       size, threshold_type, extack);
        return -EOPNOTSUPP;
 }
 
@@ -1082,7 +1083,8 @@ static int devlink_nl_cmd_sb_pool_set_doit(struct sk_buff 
*skb,
 
        size = nla_get_u32(info->attrs[DEVLINK_ATTR_SB_POOL_SIZE]);
        return devlink_sb_pool_set(devlink, devlink_sb->index,
-                                  pool_index, size, threshold_type);
+                                  pool_index, size, threshold_type,
+                                  info->extack);
 }
 
 static int devlink_nl_sb_port_pool_fill(struct sk_buff *msg,
@@ -1243,14 +1245,15 @@ static int 
devlink_nl_cmd_sb_port_pool_get_dumpit(struct sk_buff *msg,
 
 static int devlink_sb_port_pool_set(struct devlink_port *devlink_port,
                                    unsigned int sb_index, u16 pool_index,
-                                   u32 threshold)
+                                   u32 threshold,
+                                   struct netlink_ext_ack *extack)
 
 {
        const struct devlink_ops *ops = devlink_port->devlink->ops;
 
        if (ops->sb_port_pool_set)
                return ops->sb_port_pool_set(devlink_port, sb_index,
-                                            pool_index, threshold);
+                                            pool_index, threshold, extack);
        return -EOPNOTSUPP;
 }
 
@@ -1273,7 +1276,7 @@ static int devlink_nl_cmd_sb_port_pool_set_doit(struct 
sk_buff *skb,
 
        threshold = nla_get_u32(info->attrs[DEVLINK_ATTR_SB_THRESHOLD]);
        return devlink_sb_port_pool_set(devlink_port, devlink_sb->index,
-                                       pool_index, threshold);
+                                       pool_index, threshold, info->extack);
 }
 
 static int
@@ -1472,7 +1475,8 @@ devlink_nl_cmd_sb_tc_pool_bind_get_dumpit(struct sk_buff 
*msg,
 static int devlink_sb_tc_pool_bind_set(struct devlink_port *devlink_port,
                                       unsigned int sb_index, u16 tc_index,
                                       enum devlink_sb_pool_type pool_type,
-                                      u16 pool_index, u32 threshold)
+                                      u16 pool_index, u32 threshold,
+                                      struct netlink_ext_ack *extack)
 
 {
        const struct devlink_ops *ops = devlink_port->devlink->ops;
@@ -1480,7 +1484,7 @@ static int devlink_sb_tc_pool_bind_set(struct 
devlink_port *devlink_port,
        if (ops->sb_tc_pool_bind_set)
                return ops->sb_tc_pool_bind_set(devlink_port, sb_index,
                                                tc_index, pool_type,
-                                               pool_index, threshold);
+                                               pool_index, threshold, extack);
        return -EOPNOTSUPP;
 }
 
@@ -1515,7 +1519,7 @@ static int devlink_nl_cmd_sb_tc_pool_bind_set_doit(struct 
sk_buff *skb,
        threshold = nla_get_u32(info->attrs[DEVLINK_ATTR_SB_THRESHOLD]);
        return devlink_sb_tc_pool_bind_set(devlink_port, devlink_sb->index,
                                           tc_index, pool_type,
-                                          pool_index, threshold);
+                                          pool_index, threshold, info->extack);
 }
 
 static int devlink_nl_cmd_sb_occ_snapshot_doit(struct sk_buff *skb,
-- 
2.20.1

Reply via email to