Skip to content

Commit

Permalink
net: switchdev: Add extack to switchdev_handle_port_obj_add() callback
Browse files Browse the repository at this point in the history
Drivers use switchdev_handle_port_obj_add() to handle recursive descent
through lower devices. Change this function prototype to take add_cb
that itself takes an extack argument. Decode extack from
switchdev_notifier_port_obj_info and pass it to add_cb.

Update mlxsw and ocelot drivers which use this helper.

Signed-off-by: Petr Machata <[email protected]>
Acked-by: Jiri Pirko <[email protected]>
Acked-by: Ivan Vecera <[email protected]>
Reviewed-by: Ido Schimmel <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
pmachata authored and davem330 committed Dec 13, 2018
1 parent 479c86d commit 6921351
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
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 @@ -1777,7 +1777,8 @@ static void mlxsw_sp_span_respin_schedule(struct mlxsw_sp *mlxsw_sp)

static int mlxsw_sp_port_obj_add(struct net_device *dev,
const struct switchdev_obj *obj,
struct switchdev_trans *trans)
struct switchdev_trans *trans,
struct netlink_ext_ack *extack)
{
struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
const struct switchdev_obj_port_vlan *vlan;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/mscc/ocelot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,8 @@ static int ocelot_port_obj_del_mdb(struct net_device *dev,

static int ocelot_port_obj_add(struct net_device *dev,
const struct switchdev_obj *obj,
struct switchdev_trans *trans)
struct switchdev_trans *trans,
struct netlink_ext_ack *extack)
{
int ret = 0;

Expand Down
6 changes: 4 additions & 2 deletions include/net/switchdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ int switchdev_handle_port_obj_add(struct net_device *dev,
bool (*check_cb)(const struct net_device *dev),
int (*add_cb)(struct net_device *dev,
const struct switchdev_obj *obj,
struct switchdev_trans *trans));
struct switchdev_trans *trans,
struct netlink_ext_ack *extack));
int switchdev_handle_port_obj_del(struct net_device *dev,
struct switchdev_notifier_port_obj_info *port_obj_info,
bool (*check_cb)(const struct net_device *dev),
Expand Down Expand Up @@ -304,7 +305,8 @@ switchdev_handle_port_obj_add(struct net_device *dev,
bool (*check_cb)(const struct net_device *dev),
int (*add_cb)(struct net_device *dev,
const struct switchdev_obj *obj,
struct switchdev_trans *trans))
struct switchdev_trans *trans,
struct netlink_ext_ack *extack))
{
return 0;
}
Expand Down
12 changes: 9 additions & 3 deletions net/switchdev/switchdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,16 +616,21 @@ static int __switchdev_handle_port_obj_add(struct net_device *dev,
bool (*check_cb)(const struct net_device *dev),
int (*add_cb)(struct net_device *dev,
const struct switchdev_obj *obj,
struct switchdev_trans *trans))
struct switchdev_trans *trans,
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_obj_info->info);

if (check_cb(dev)) {
/* This flag is only checked if the return value is success. */
port_obj_info->handled = true;
return add_cb(dev, port_obj_info->obj, port_obj_info->trans);
return add_cb(dev, port_obj_info->obj, port_obj_info->trans,
extack);
}

/* Switch ports might be stacked under e.g. a LAG. Ignore the
Expand All @@ -650,7 +655,8 @@ int switchdev_handle_port_obj_add(struct net_device *dev,
bool (*check_cb)(const struct net_device *dev),
int (*add_cb)(struct net_device *dev,
const struct switchdev_obj *obj,
struct switchdev_trans *trans))
struct switchdev_trans *trans,
struct netlink_ext_ack *extack))
{
int err;

Expand Down

0 comments on commit 6921351

Please sign in to comment.