Skip to content

Commit

Permalink
net: switchdev: propagate extack to port attributes
Browse files Browse the repository at this point in the history
When a struct switchdev_attr is notified through switchdev, there is no
way to report informational messages, unlike for struct switchdev_obj.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Nikolay Aleksandrov <nikolay@nvidia.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vladimir Oltean authored and David S. Miller committed Feb 13, 2021
1 parent b0aae0b commit 4c08c58
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 11 deletions.
3 changes: 2 additions & 1 deletion drivers/net/ethernet/marvell/prestera/prestera_switchdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,8 @@ static int prestera_port_attr_stp_state_set(struct prestera_port *port,
}

static int prestera_port_obj_attr_set(struct net_device *dev,
const struct switchdev_attr *attr)
const struct switchdev_attr *attr,
struct netlink_ext_ack *extack)
{
struct prestera_port *port = netdev_priv(dev);
int err = 0;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,8 @@ mlxsw_sp_port_attr_br_mrouter_set(struct mlxsw_sp_port *mlxsw_sp_port,
}

static int mlxsw_sp_port_attr_set(struct net_device *dev,
const struct switchdev_attr *attr)
const struct switchdev_attr *attr,
struct netlink_ext_ack *extack)
{
struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
int err;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/mscc/ocelot_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,8 @@ static void ocelot_port_attr_mc_set(struct ocelot *ocelot, int port, bool mc)
}

static int ocelot_port_attr_set(struct net_device *dev,
const struct switchdev_attr *attr)
const struct switchdev_attr *attr,
struct netlink_ext_ack *extack)
{
struct ocelot_port_private *priv = netdev_priv(dev);
struct ocelot *ocelot = priv->port.ocelot;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/ti/am65-cpsw-switchdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ static int am65_cpsw_port_attr_br_flags_pre_set(struct net_device *netdev,
}

static int am65_cpsw_port_attr_set(struct net_device *ndev,
const struct switchdev_attr *attr)
const struct switchdev_attr *attr,
struct netlink_ext_ack *extack)
{
struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
int ret;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/ti/cpsw_switchdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ static int cpsw_port_attr_br_flags_pre_set(struct net_device *netdev,
}

static int cpsw_port_attr_set(struct net_device *ndev,
const struct switchdev_attr *attr)
const struct switchdev_attr *attr,
struct netlink_ext_ack *extack)
{
struct cpsw_priv *priv = netdev_priv(ndev);
int ret;
Expand Down
6 changes: 4 additions & 2 deletions include/net/switchdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ int switchdev_handle_port_attr_set(struct net_device *dev,
struct switchdev_notifier_port_attr_info *port_attr_info,
bool (*check_cb)(const struct net_device *dev),
int (*set_cb)(struct net_device *dev,
const struct switchdev_attr *attr));
const struct switchdev_attr *attr,
struct netlink_ext_ack *extack));
#else

static inline void switchdev_deferred_process(void)
Expand Down Expand Up @@ -372,7 +373,8 @@ switchdev_handle_port_attr_set(struct net_device *dev,
struct switchdev_notifier_port_attr_info *port_attr_info,
bool (*check_cb)(const struct net_device *dev),
int (*set_cb)(struct net_device *dev,
const struct switchdev_attr *attr))
const struct switchdev_attr *attr,
struct netlink_ext_ack *extack))
{
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
}

static int dsa_slave_port_attr_set(struct net_device *dev,
const struct switchdev_attr *attr)
const struct switchdev_attr *attr,
struct netlink_ext_ack *extack)
{
struct dsa_port *dp = dsa_slave_to_port(dev);
int ret;
Expand Down
11 changes: 8 additions & 3 deletions net/switchdev/switchdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,18 @@ static int __switchdev_handle_port_attr_set(struct net_device *dev,
struct switchdev_notifier_port_attr_info *port_attr_info,
bool (*check_cb)(const struct net_device *dev),
int (*set_cb)(struct net_device *dev,
const struct switchdev_attr *attr))
const struct switchdev_attr *attr,
struct netlink_ext_ack *extack))
{
struct netlink_ext_ack *extack;
struct net_device *lower_dev;
struct list_head *iter;
int err = -EOPNOTSUPP;

extack = switchdev_notifier_info_to_extack(&port_attr_info->info);

if (check_cb(dev)) {
err = set_cb(dev, port_attr_info->attr);
err = set_cb(dev, port_attr_info->attr, extack);
if (err != -EOPNOTSUPP)
port_attr_info->handled = true;
return err;
Expand Down Expand Up @@ -525,7 +529,8 @@ int switchdev_handle_port_attr_set(struct net_device *dev,
struct switchdev_notifier_port_attr_info *port_attr_info,
bool (*check_cb)(const struct net_device *dev),
int (*set_cb)(struct net_device *dev,
const struct switchdev_attr *attr))
const struct switchdev_attr *attr,
struct netlink_ext_ack *extack))
{
int err;

Expand Down

0 comments on commit 4c08c58

Please sign in to comment.