Commit 3ee6233e authored by Vlad Buslov's avatar Vlad Buslov Committed by Saeed Mahameed

net/mlx5: Bridge, identify port by vport_num+esw_owner_vhca_id pair

Following patches in series allow traffic between vports of different
eswitch instances, which requires addressing bridge port by
vport_num+esw_owner_vhca_id pair since vport_num is only unique
per-eswitch. As a preparation, extend struct mlx5_esw_bridge_port with
'esw_owner_vhca_id' field and use it as part of key for
mlx5_esw_bridge->vports xarray.

With this change we can't rely on switchdev_handle_port_obj_add() helper to
get mlx5 representor from stacked device because we need specifically
representor from parent eswitch that registered the callback to obtain
correct esw_owner_vhca_id. The helper doesn't allow passing additional
parameters to predicate function and doesn't provide access to the notifier
block to obtain eswitch through br_offloads. Implement custom helpers to
obtain mlx5 representor and use them in
mlx5_esw_bridge_port_obj_{add|del|attr_set}() implementations.

Remove direct pointer to parent bridge from struct mlx5_vport as it is no
longer needed.
Signed-off-by: default avatarVlad Buslov <vladbu@nvidia.com>
Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
Reviewed-by: default avatarMark Bloch <mbloch@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent a514d173
...@@ -18,6 +18,55 @@ struct mlx5_bridge_switchdev_fdb_work { ...@@ -18,6 +18,55 @@ struct mlx5_bridge_switchdev_fdb_work {
bool add; bool add;
}; };
static bool mlx5_esw_bridge_dev_same_esw(struct net_device *dev, struct mlx5_eswitch *esw)
{
struct mlx5e_priv *priv = netdev_priv(dev);
return esw == priv->mdev->priv.eswitch;
}
static int mlx5_esw_bridge_vport_num_vhca_id_get(struct net_device *dev, struct mlx5_eswitch *esw,
u16 *vport_num, u16 *esw_owner_vhca_id)
{
struct mlx5e_rep_priv *rpriv;
struct mlx5e_priv *priv;
if (!mlx5e_eswitch_rep(dev) || !mlx5_esw_bridge_dev_same_esw(dev, esw))
return -ENODEV;
priv = netdev_priv(dev);
rpriv = priv->ppriv;
*vport_num = rpriv->rep->vport;
*esw_owner_vhca_id = MLX5_CAP_GEN(priv->mdev, vhca_id);
return 0;
}
static int
mlx5_esw_bridge_lower_rep_vport_num_vhca_id_get(struct net_device *dev, struct mlx5_eswitch *esw,
u16 *vport_num, u16 *esw_owner_vhca_id)
{
struct net_device *lower_dev;
struct list_head *iter;
if (mlx5e_eswitch_rep(dev) && mlx5_esw_bridge_dev_same_esw(dev, esw))
return mlx5_esw_bridge_vport_num_vhca_id_get(dev, esw, vport_num,
esw_owner_vhca_id);
netdev_for_each_lower_dev(dev, lower_dev, iter) {
int err;
if (netif_is_bridge_master(lower_dev))
continue;
err = mlx5_esw_bridge_lower_rep_vport_num_vhca_id_get(lower_dev, esw, vport_num,
esw_owner_vhca_id);
if (!err)
return 0;
}
return -ENODEV;
}
static int mlx5_esw_bridge_port_changeupper(struct notifier_block *nb, void *ptr) static int mlx5_esw_bridge_port_changeupper(struct notifier_block *nb, void *ptr)
{ {
struct mlx5_esw_bridge_offloads *br_offloads = container_of(nb, struct mlx5_esw_bridge_offloads *br_offloads = container_of(nb,
...@@ -25,37 +74,27 @@ static int mlx5_esw_bridge_port_changeupper(struct notifier_block *nb, void *ptr ...@@ -25,37 +74,27 @@ static int mlx5_esw_bridge_port_changeupper(struct notifier_block *nb, void *ptr
netdev_nb); netdev_nb);
struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct netdev_notifier_changeupper_info *info = ptr; struct netdev_notifier_changeupper_info *info = ptr;
struct net_device *upper = info->upper_dev;
u16 vport_num, esw_owner_vhca_id;
struct netlink_ext_ack *extack; struct netlink_ext_ack *extack;
struct mlx5e_rep_priv *rpriv; int ifindex = upper->ifindex;
struct mlx5_eswitch *esw; int err;
struct mlx5_vport *vport;
struct net_device *upper;
struct mlx5e_priv *priv;
u16 vport_num;
if (!mlx5e_eswitch_rep(dev))
return 0;
upper = info->upper_dev;
if (!netif_is_bridge_master(upper)) if (!netif_is_bridge_master(upper))
return 0; return 0;
esw = br_offloads->esw; err = mlx5_esw_bridge_vport_num_vhca_id_get(dev, br_offloads->esw, &vport_num,
priv = netdev_priv(dev); &esw_owner_vhca_id);
if (esw != priv->mdev->priv.eswitch) if (err)
return 0; return 0;
rpriv = priv->ppriv;
vport_num = rpriv->rep->vport;
vport = mlx5_eswitch_get_vport(esw, vport_num);
if (IS_ERR(vport))
return PTR_ERR(vport);
extack = netdev_notifier_info_to_extack(&info->info); extack = netdev_notifier_info_to_extack(&info->info);
return info->linking ? return info->linking ?
mlx5_esw_bridge_vport_link(upper->ifindex, br_offloads, vport, extack) : mlx5_esw_bridge_vport_link(ifindex, vport_num, esw_owner_vhca_id, br_offloads,
mlx5_esw_bridge_vport_unlink(upper->ifindex, br_offloads, vport, extack); extack) :
mlx5_esw_bridge_vport_unlink(ifindex, vport_num, esw_owner_vhca_id, br_offloads,
extack);
} }
static int mlx5_esw_bridge_switchdev_port_event(struct notifier_block *nb, static int mlx5_esw_bridge_switchdev_port_event(struct notifier_block *nb,
...@@ -75,31 +114,29 @@ static int mlx5_esw_bridge_switchdev_port_event(struct notifier_block *nb, ...@@ -75,31 +114,29 @@ static int mlx5_esw_bridge_switchdev_port_event(struct notifier_block *nb,
return notifier_from_errno(err); return notifier_from_errno(err);
} }
static int mlx5_esw_bridge_port_obj_add(struct net_device *dev, static int
const void *ctx, mlx5_esw_bridge_port_obj_add(struct net_device *dev,
const struct switchdev_obj *obj, struct switchdev_notifier_port_obj_info *port_obj_info,
struct netlink_ext_ack *extack) struct mlx5_esw_bridge_offloads *br_offloads)
{ {
struct netlink_ext_ack *extack = switchdev_notifier_info_to_extack(&port_obj_info->info);
const struct switchdev_obj *obj = port_obj_info->obj;
const struct switchdev_obj_port_vlan *vlan; const struct switchdev_obj_port_vlan *vlan;
struct mlx5e_rep_priv *rpriv; u16 vport_num, esw_owner_vhca_id;
struct mlx5_eswitch *esw; int err;
struct mlx5_vport *vport;
struct mlx5e_priv *priv;
u16 vport_num;
int err = 0;
priv = netdev_priv(dev); err = mlx5_esw_bridge_vport_num_vhca_id_get(dev, br_offloads->esw, &vport_num,
rpriv = priv->ppriv; &esw_owner_vhca_id);
vport_num = rpriv->rep->vport; if (err)
esw = priv->mdev->priv.eswitch; return 0;
vport = mlx5_eswitch_get_vport(esw, vport_num);
if (IS_ERR(vport)) port_obj_info->handled = true;
return PTR_ERR(vport);
switch (obj->id) { switch (obj->id) {
case SWITCHDEV_OBJ_ID_PORT_VLAN: case SWITCHDEV_OBJ_ID_PORT_VLAN:
vlan = SWITCHDEV_OBJ_PORT_VLAN(obj); vlan = SWITCHDEV_OBJ_PORT_VLAN(obj);
err = mlx5_esw_bridge_port_vlan_add(vlan->vid, vlan->flags, esw, vport, extack); err = mlx5_esw_bridge_port_vlan_add(vport_num, esw_owner_vhca_id, vlan->vid,
vlan->flags, br_offloads, extack);
break; break;
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -107,29 +144,27 @@ static int mlx5_esw_bridge_port_obj_add(struct net_device *dev, ...@@ -107,29 +144,27 @@ static int mlx5_esw_bridge_port_obj_add(struct net_device *dev,
return err; return err;
} }
static int mlx5_esw_bridge_port_obj_del(struct net_device *dev, static int
const void *ctx, mlx5_esw_bridge_port_obj_del(struct net_device *dev,
const struct switchdev_obj *obj) struct switchdev_notifier_port_obj_info *port_obj_info,
struct mlx5_esw_bridge_offloads *br_offloads)
{ {
const struct switchdev_obj *obj = port_obj_info->obj;
const struct switchdev_obj_port_vlan *vlan; const struct switchdev_obj_port_vlan *vlan;
struct mlx5e_rep_priv *rpriv; u16 vport_num, esw_owner_vhca_id;
struct mlx5_eswitch *esw; int err;
struct mlx5_vport *vport;
struct mlx5e_priv *priv;
u16 vport_num;
priv = netdev_priv(dev); err = mlx5_esw_bridge_vport_num_vhca_id_get(dev, br_offloads->esw, &vport_num,
rpriv = priv->ppriv; &esw_owner_vhca_id);
vport_num = rpriv->rep->vport; if (err)
esw = priv->mdev->priv.eswitch; return 0;
vport = mlx5_eswitch_get_vport(esw, vport_num);
if (IS_ERR(vport)) port_obj_info->handled = true;
return PTR_ERR(vport);
switch (obj->id) { switch (obj->id) {
case SWITCHDEV_OBJ_ID_PORT_VLAN: case SWITCHDEV_OBJ_ID_PORT_VLAN:
vlan = SWITCHDEV_OBJ_PORT_VLAN(obj); vlan = SWITCHDEV_OBJ_PORT_VLAN(obj);
mlx5_esw_bridge_port_vlan_del(vlan->vid, esw, vport); mlx5_esw_bridge_port_vlan_del(vport_num, esw_owner_vhca_id, vlan->vid, br_offloads);
break; break;
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -137,25 +172,22 @@ static int mlx5_esw_bridge_port_obj_del(struct net_device *dev, ...@@ -137,25 +172,22 @@ static int mlx5_esw_bridge_port_obj_del(struct net_device *dev,
return 0; return 0;
} }
static int mlx5_esw_bridge_port_obj_attr_set(struct net_device *dev, static int
const void *ctx, mlx5_esw_bridge_port_obj_attr_set(struct net_device *dev,
const struct switchdev_attr *attr, struct switchdev_notifier_port_attr_info *port_attr_info,
struct netlink_ext_ack *extack) struct mlx5_esw_bridge_offloads *br_offloads)
{ {
struct mlx5e_rep_priv *rpriv; struct netlink_ext_ack *extack = switchdev_notifier_info_to_extack(&port_attr_info->info);
struct mlx5_eswitch *esw; const struct switchdev_attr *attr = port_attr_info->attr;
struct mlx5_vport *vport; u16 vport_num, esw_owner_vhca_id;
struct mlx5e_priv *priv; int err;
u16 vport_num;
int err = 0;
priv = netdev_priv(dev); err = mlx5_esw_bridge_lower_rep_vport_num_vhca_id_get(dev, br_offloads->esw, &vport_num,
rpriv = priv->ppriv; &esw_owner_vhca_id);
vport_num = rpriv->rep->vport; if (err)
esw = priv->mdev->priv.eswitch; return 0;
vport = mlx5_eswitch_get_vport(esw, vport_num);
if (IS_ERR(vport)) port_attr_info->handled = true;
return PTR_ERR(vport);
switch (attr->id) { switch (attr->id) {
case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS: case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS:
...@@ -167,10 +199,12 @@ static int mlx5_esw_bridge_port_obj_attr_set(struct net_device *dev, ...@@ -167,10 +199,12 @@ static int mlx5_esw_bridge_port_obj_attr_set(struct net_device *dev,
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS: case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
break; break;
case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME: case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME:
err = mlx5_esw_bridge_ageing_time_set(attr->u.ageing_time, esw, vport); err = mlx5_esw_bridge_ageing_time_set(vport_num, esw_owner_vhca_id,
attr->u.ageing_time, br_offloads);
break; break;
case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING: case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING:
err = mlx5_esw_bridge_vlan_filtering_set(attr->u.vlan_filtering, esw, vport); err = mlx5_esw_bridge_vlan_filtering_set(vport_num, esw_owner_vhca_id,
attr->u.vlan_filtering, br_offloads);
break; break;
default: default:
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
...@@ -179,27 +213,24 @@ static int mlx5_esw_bridge_port_obj_attr_set(struct net_device *dev, ...@@ -179,27 +213,24 @@ static int mlx5_esw_bridge_port_obj_attr_set(struct net_device *dev,
return err; return err;
} }
static int mlx5_esw_bridge_event_blocking(struct notifier_block *unused, static int mlx5_esw_bridge_event_blocking(struct notifier_block *nb,
unsigned long event, void *ptr) unsigned long event, void *ptr)
{ {
struct mlx5_esw_bridge_offloads *br_offloads = container_of(nb,
struct mlx5_esw_bridge_offloads,
nb_blk);
struct net_device *dev = switchdev_notifier_info_to_dev(ptr); struct net_device *dev = switchdev_notifier_info_to_dev(ptr);
int err; int err;
switch (event) { switch (event) {
case SWITCHDEV_PORT_OBJ_ADD: case SWITCHDEV_PORT_OBJ_ADD:
err = switchdev_handle_port_obj_add(dev, ptr, err = mlx5_esw_bridge_port_obj_add(dev, ptr, br_offloads);
mlx5e_eswitch_rep,
mlx5_esw_bridge_port_obj_add);
break; break;
case SWITCHDEV_PORT_OBJ_DEL: case SWITCHDEV_PORT_OBJ_DEL:
err = switchdev_handle_port_obj_del(dev, ptr, err = mlx5_esw_bridge_port_obj_del(dev, ptr, br_offloads);
mlx5e_eswitch_rep,
mlx5_esw_bridge_port_obj_del);
break; break;
case SWITCHDEV_PORT_ATTR_SET: case SWITCHDEV_PORT_ATTR_SET:
err = switchdev_handle_port_attr_set(dev, ptr, err = mlx5_esw_bridge_port_obj_attr_set(dev, ptr, br_offloads);
mlx5e_eswitch_rep,
mlx5_esw_bridge_port_obj_attr_set);
break; break;
default: default:
err = 0; err = 0;
...@@ -222,27 +253,27 @@ static void mlx5_esw_bridge_switchdev_fdb_event_work(struct work_struct *work) ...@@ -222,27 +253,27 @@ static void mlx5_esw_bridge_switchdev_fdb_event_work(struct work_struct *work)
container_of(work, struct mlx5_bridge_switchdev_fdb_work, work); container_of(work, struct mlx5_bridge_switchdev_fdb_work, work);
struct switchdev_notifier_fdb_info *fdb_info = struct switchdev_notifier_fdb_info *fdb_info =
&fdb_work->fdb_info; &fdb_work->fdb_info;
struct mlx5_esw_bridge_offloads *br_offloads;
struct net_device *dev = fdb_work->dev; struct net_device *dev = fdb_work->dev;
struct mlx5e_rep_priv *rpriv; u16 vport_num, esw_owner_vhca_id;
struct mlx5_eswitch *esw;
struct mlx5_vport *vport;
struct mlx5e_priv *priv; struct mlx5e_priv *priv;
u16 vport_num; int err;
rtnl_lock(); rtnl_lock();
priv = netdev_priv(dev); priv = netdev_priv(dev);
rpriv = priv->ppriv; br_offloads = priv->mdev->priv.eswitch->br_offloads;
vport_num = rpriv->rep->vport; err = mlx5_esw_bridge_vport_num_vhca_id_get(dev, br_offloads->esw, &vport_num,
esw = priv->mdev->priv.eswitch; &esw_owner_vhca_id);
vport = mlx5_eswitch_get_vport(esw, vport_num); if (err)
if (IS_ERR(vport))
goto out; goto out;
if (fdb_work->add) if (fdb_work->add)
mlx5_esw_bridge_fdb_create(dev, esw, vport, fdb_info); mlx5_esw_bridge_fdb_create(dev, vport_num, esw_owner_vhca_id, br_offloads,
fdb_info);
else else
mlx5_esw_bridge_fdb_remove(dev, esw, vport, fdb_info); mlx5_esw_bridge_fdb_remove(dev, vport_num, esw_owner_vhca_id, br_offloads,
fdb_info);
out: out:
rtnl_unlock(); rtnl_unlock();
...@@ -288,18 +319,10 @@ static int mlx5_esw_bridge_switchdev_event(struct notifier_block *nb, ...@@ -288,18 +319,10 @@ static int mlx5_esw_bridge_switchdev_event(struct notifier_block *nb,
struct mlx5_bridge_switchdev_fdb_work *work; struct mlx5_bridge_switchdev_fdb_work *work;
struct switchdev_notifier_info *info = ptr; struct switchdev_notifier_info *info = ptr;
struct net_device *upper; struct net_device *upper;
struct mlx5e_priv *priv;
if (!mlx5e_eswitch_rep(dev))
return NOTIFY_DONE;
priv = netdev_priv(dev);
if (priv->mdev->priv.eswitch != br_offloads->esw)
return NOTIFY_DONE;
if (event == SWITCHDEV_PORT_ATTR_SET) { if (event == SWITCHDEV_PORT_ATTR_SET) {
int err = switchdev_handle_port_attr_set(dev, ptr, int err = mlx5_esw_bridge_port_obj_attr_set(dev, ptr, br_offloads);
mlx5e_eswitch_rep,
mlx5_esw_bridge_port_obj_attr_set);
return notifier_from_errno(err); return notifier_from_errno(err);
} }
...@@ -309,6 +332,11 @@ static int mlx5_esw_bridge_switchdev_event(struct notifier_block *nb, ...@@ -309,6 +332,11 @@ static int mlx5_esw_bridge_switchdev_event(struct notifier_block *nb,
if (!netif_is_bridge_master(upper)) if (!netif_is_bridge_master(upper))
return NOTIFY_DONE; return NOTIFY_DONE;
if (!mlx5e_eswitch_rep(dev))
return NOTIFY_DONE;
if (!mlx5_esw_bridge_dev_same_esw(dev, br_offloads->esw))
return NOTIFY_DONE;
switch (event) { switch (event) {
case SWITCHDEV_FDB_ADD_TO_DEVICE: case SWITCHDEV_FDB_ADD_TO_DEVICE:
case SWITCHDEV_FDB_DEL_TO_DEVICE: case SWITCHDEV_FDB_DEL_TO_DEVICE:
......
...@@ -56,7 +56,6 @@ struct mlx5_esw_bridge { ...@@ -56,7 +56,6 @@ struct mlx5_esw_bridge {
struct list_head fdb_list; struct list_head fdb_list;
struct rhashtable fdb_ht; struct rhashtable fdb_ht;
struct xarray vports;
struct mlx5_flow_table *egress_ft; struct mlx5_flow_table *egress_ft;
struct mlx5_flow_group *egress_vlan_fg; struct mlx5_flow_group *egress_vlan_fg;
...@@ -576,7 +575,6 @@ static struct mlx5_esw_bridge *mlx5_esw_bridge_create(int ifindex, ...@@ -576,7 +575,6 @@ static struct mlx5_esw_bridge *mlx5_esw_bridge_create(int ifindex,
goto err_fdb_ht; goto err_fdb_ht;
INIT_LIST_HEAD(&bridge->fdb_list); INIT_LIST_HEAD(&bridge->fdb_list);
xa_init(&bridge->vports);
bridge->ifindex = ifindex; bridge->ifindex = ifindex;
bridge->refcnt = 1; bridge->refcnt = 1;
bridge->ageing_time = clock_t_to_jiffies(BR_DEFAULT_AGEING_TIME); bridge->ageing_time = clock_t_to_jiffies(BR_DEFAULT_AGEING_TIME);
...@@ -603,7 +601,6 @@ static void mlx5_esw_bridge_put(struct mlx5_esw_bridge_offloads *br_offloads, ...@@ -603,7 +601,6 @@ static void mlx5_esw_bridge_put(struct mlx5_esw_bridge_offloads *br_offloads,
return; return;
mlx5_esw_bridge_egress_table_cleanup(bridge); mlx5_esw_bridge_egress_table_cleanup(bridge);
WARN_ON(!xa_empty(&bridge->vports));
list_del(&bridge->list); list_del(&bridge->list);
rhashtable_destroy(&bridge->fdb_ht); rhashtable_destroy(&bridge->fdb_ht);
kvfree(bridge); kvfree(bridge);
...@@ -639,22 +636,34 @@ mlx5_esw_bridge_lookup(int ifindex, struct mlx5_esw_bridge_offloads *br_offloads ...@@ -639,22 +636,34 @@ mlx5_esw_bridge_lookup(int ifindex, struct mlx5_esw_bridge_offloads *br_offloads
return bridge; return bridge;
} }
static unsigned long mlx5_esw_bridge_port_key_from_data(u16 vport_num, u16 esw_owner_vhca_id)
{
return vport_num | (unsigned long)esw_owner_vhca_id << sizeof(vport_num) * BITS_PER_BYTE;
}
static unsigned long mlx5_esw_bridge_port_key(struct mlx5_esw_bridge_port *port)
{
return mlx5_esw_bridge_port_key_from_data(port->vport_num, port->esw_owner_vhca_id);
}
static int mlx5_esw_bridge_port_insert(struct mlx5_esw_bridge_port *port, static int mlx5_esw_bridge_port_insert(struct mlx5_esw_bridge_port *port,
struct mlx5_esw_bridge *bridge) struct mlx5_esw_bridge_offloads *br_offloads)
{ {
return xa_insert(&bridge->vports, port->vport_num, port, GFP_KERNEL); return xa_insert(&br_offloads->ports, mlx5_esw_bridge_port_key(port), port, GFP_KERNEL);
} }
static struct mlx5_esw_bridge_port * static struct mlx5_esw_bridge_port *
mlx5_esw_bridge_port_lookup(u16 vport_num, struct mlx5_esw_bridge *bridge) mlx5_esw_bridge_port_lookup(u16 vport_num, u16 esw_owner_vhca_id,
struct mlx5_esw_bridge_offloads *br_offloads)
{ {
return xa_load(&bridge->vports, vport_num); return xa_load(&br_offloads->ports, mlx5_esw_bridge_port_key_from_data(vport_num,
esw_owner_vhca_id));
} }
static void mlx5_esw_bridge_port_erase(struct mlx5_esw_bridge_port *port, static void mlx5_esw_bridge_port_erase(struct mlx5_esw_bridge_port *port,
struct mlx5_esw_bridge *bridge) struct mlx5_esw_bridge_offloads *br_offloads)
{ {
xa_erase(&bridge->vports, port->vport_num); xa_erase(&br_offloads->ports, mlx5_esw_bridge_port_key(port));
} }
static void mlx5_esw_bridge_fdb_entry_refresh(unsigned long lastuse, static void mlx5_esw_bridge_fdb_entry_refresh(unsigned long lastuse,
...@@ -875,13 +884,13 @@ static void mlx5_esw_bridge_port_vlans_flush(struct mlx5_esw_bridge_port *port, ...@@ -875,13 +884,13 @@ static void mlx5_esw_bridge_port_vlans_flush(struct mlx5_esw_bridge_port *port,
} }
static struct mlx5_esw_bridge_vlan * static struct mlx5_esw_bridge_vlan *
mlx5_esw_bridge_port_vlan_lookup(u16 vid, u16 vport_num, struct mlx5_esw_bridge *bridge, mlx5_esw_bridge_port_vlan_lookup(u16 vid, u16 vport_num, u16 esw_owner_vhca_id,
struct mlx5_eswitch *esw) struct mlx5_esw_bridge *bridge, struct mlx5_eswitch *esw)
{ {
struct mlx5_esw_bridge_port *port; struct mlx5_esw_bridge_port *port;
struct mlx5_esw_bridge_vlan *vlan; struct mlx5_esw_bridge_vlan *vlan;
port = mlx5_esw_bridge_port_lookup(vport_num, bridge); port = mlx5_esw_bridge_port_lookup(vport_num, esw_owner_vhca_id, bridge->br_offloads);
if (!port) { if (!port) {
/* FDB is added asynchronously on wq while port might have been deleted /* FDB is added asynchronously on wq while port might have been deleted
* concurrently. Report on 'info' logging level and skip the FDB offload. * concurrently. Report on 'info' logging level and skip the FDB offload.
...@@ -904,9 +913,9 @@ mlx5_esw_bridge_port_vlan_lookup(u16 vid, u16 vport_num, struct mlx5_esw_bridge ...@@ -904,9 +913,9 @@ mlx5_esw_bridge_port_vlan_lookup(u16 vid, u16 vport_num, struct mlx5_esw_bridge
} }
static struct mlx5_esw_bridge_fdb_entry * static struct mlx5_esw_bridge_fdb_entry *
mlx5_esw_bridge_fdb_entry_init(struct net_device *dev, u16 vport_num, const unsigned char *addr, mlx5_esw_bridge_fdb_entry_init(struct net_device *dev, u16 vport_num, u16 esw_owner_vhca_id,
u16 vid, bool added_by_user, struct mlx5_eswitch *esw, const unsigned char *addr, u16 vid, bool added_by_user,
struct mlx5_esw_bridge *bridge) struct mlx5_eswitch *esw, struct mlx5_esw_bridge *bridge)
{ {
struct mlx5_esw_bridge_vlan *vlan = NULL; struct mlx5_esw_bridge_vlan *vlan = NULL;
struct mlx5_esw_bridge_fdb_entry *entry; struct mlx5_esw_bridge_fdb_entry *entry;
...@@ -915,7 +924,8 @@ mlx5_esw_bridge_fdb_entry_init(struct net_device *dev, u16 vport_num, const unsi ...@@ -915,7 +924,8 @@ mlx5_esw_bridge_fdb_entry_init(struct net_device *dev, u16 vport_num, const unsi
int err; int err;
if (bridge->flags & MLX5_ESW_BRIDGE_VLAN_FILTERING_FLAG && vid) { if (bridge->flags & MLX5_ESW_BRIDGE_VLAN_FILTERING_FLAG && vid) {
vlan = mlx5_esw_bridge_port_vlan_lookup(vid, vport_num, bridge, esw); vlan = mlx5_esw_bridge_port_vlan_lookup(vid, vport_num, esw_owner_vhca_id, bridge,
esw);
if (IS_ERR(vlan)) if (IS_ERR(vlan))
return ERR_CAST(vlan); return ERR_CAST(vlan);
} }
...@@ -928,6 +938,7 @@ mlx5_esw_bridge_fdb_entry_init(struct net_device *dev, u16 vport_num, const unsi ...@@ -928,6 +938,7 @@ mlx5_esw_bridge_fdb_entry_init(struct net_device *dev, u16 vport_num, const unsi
entry->key.vid = vid; entry->key.vid = vid;
entry->dev = dev; entry->dev = dev;
entry->vport_num = vport_num; entry->vport_num = vport_num;
entry->esw_owner_vhca_id = esw_owner_vhca_id;
entry->lastuse = jiffies; entry->lastuse = jiffies;
if (added_by_user) if (added_by_user)
entry->flags |= MLX5_ESW_BRIDGE_FLAG_ADDED_BY_USER; entry->flags |= MLX5_ESW_BRIDGE_FLAG_ADDED_BY_USER;
...@@ -998,26 +1009,31 @@ mlx5_esw_bridge_fdb_entry_init(struct net_device *dev, u16 vport_num, const unsi ...@@ -998,26 +1009,31 @@ mlx5_esw_bridge_fdb_entry_init(struct net_device *dev, u16 vport_num, const unsi
return ERR_PTR(err); return ERR_PTR(err);
} }
int mlx5_esw_bridge_ageing_time_set(unsigned long ageing_time, struct mlx5_eswitch *esw, int mlx5_esw_bridge_ageing_time_set(u16 vport_num, u16 esw_owner_vhca_id, unsigned long ageing_time,
struct mlx5_vport *vport) struct mlx5_esw_bridge_offloads *br_offloads)
{ {
if (!vport->bridge) struct mlx5_esw_bridge_port *port;
port = mlx5_esw_bridge_port_lookup(vport_num, esw_owner_vhca_id, br_offloads);
if (!port)
return -EINVAL; return -EINVAL;
vport->bridge->ageing_time = clock_t_to_jiffies(ageing_time); port->bridge->ageing_time = clock_t_to_jiffies(ageing_time);
return 0; return 0;
} }
int mlx5_esw_bridge_vlan_filtering_set(bool enable, struct mlx5_eswitch *esw, int mlx5_esw_bridge_vlan_filtering_set(u16 vport_num, u16 esw_owner_vhca_id, bool enable,
struct mlx5_vport *vport) struct mlx5_esw_bridge_offloads *br_offloads)
{ {
struct mlx5_esw_bridge_port *port;
struct mlx5_esw_bridge *bridge; struct mlx5_esw_bridge *bridge;
bool filtering; bool filtering;
if (!vport->bridge) port = mlx5_esw_bridge_port_lookup(vport_num, esw_owner_vhca_id, br_offloads);
if (!port)
return -EINVAL; return -EINVAL;
bridge = vport->bridge; bridge = port->bridge;
filtering = bridge->flags & MLX5_ESW_BRIDGE_VLAN_FILTERING_FLAG; filtering = bridge->flags & MLX5_ESW_BRIDGE_VLAN_FILTERING_FLAG;
if (filtering == enable) if (filtering == enable)
return 0; return 0;
...@@ -1031,9 +1047,9 @@ int mlx5_esw_bridge_vlan_filtering_set(bool enable, struct mlx5_eswitch *esw, ...@@ -1031,9 +1047,9 @@ int mlx5_esw_bridge_vlan_filtering_set(bool enable, struct mlx5_eswitch *esw,
return 0; return 0;
} }
static int mlx5_esw_bridge_vport_init(struct mlx5_esw_bridge_offloads *br_offloads, static int mlx5_esw_bridge_vport_init(u16 vport_num, u16 esw_owner_vhca_id,
struct mlx5_esw_bridge *bridge, struct mlx5_esw_bridge_offloads *br_offloads,
struct mlx5_vport *vport) struct mlx5_esw_bridge *bridge)
{ {
struct mlx5_eswitch *esw = br_offloads->esw; struct mlx5_eswitch *esw = br_offloads->esw;
struct mlx5_esw_bridge_port *port; struct mlx5_esw_bridge_port *port;
...@@ -1043,17 +1059,19 @@ static int mlx5_esw_bridge_vport_init(struct mlx5_esw_bridge_offloads *br_offloa ...@@ -1043,17 +1059,19 @@ static int mlx5_esw_bridge_vport_init(struct mlx5_esw_bridge_offloads *br_offloa
if (!port) if (!port)
return -ENOMEM; return -ENOMEM;
port->vport_num = vport->vport; port->vport_num = vport_num;
port->esw_owner_vhca_id = esw_owner_vhca_id;
port->bridge = bridge;
xa_init(&port->vlans); xa_init(&port->vlans);
err = mlx5_esw_bridge_port_insert(port, bridge); err = mlx5_esw_bridge_port_insert(port, br_offloads);
if (err) { if (err) {
esw_warn(esw->dev, "Failed to insert port metadata (vport=%u,err=%d)\n", esw_warn(esw->dev,
vport->vport, err); "Failed to insert port metadata (vport=%u,esw_owner_vhca_id=%u,err=%d)\n",
port->vport_num, port->esw_owner_vhca_id, err);
goto err_port_insert; goto err_port_insert;
} }
trace_mlx5_esw_bridge_vport_init(port); trace_mlx5_esw_bridge_vport_init(port);
vport->bridge = bridge;
return 0; return 0;
err_port_insert: err_port_insert:
...@@ -1062,46 +1080,38 @@ static int mlx5_esw_bridge_vport_init(struct mlx5_esw_bridge_offloads *br_offloa ...@@ -1062,46 +1080,38 @@ static int mlx5_esw_bridge_vport_init(struct mlx5_esw_bridge_offloads *br_offloa
} }
static int mlx5_esw_bridge_vport_cleanup(struct mlx5_esw_bridge_offloads *br_offloads, static int mlx5_esw_bridge_vport_cleanup(struct mlx5_esw_bridge_offloads *br_offloads,
struct mlx5_vport *vport) struct mlx5_esw_bridge_port *port)
{ {
struct mlx5_esw_bridge *bridge = vport->bridge; u16 vport_num = port->vport_num, esw_owner_vhca_id = port->esw_owner_vhca_id;
struct mlx5_esw_bridge *bridge = port->bridge;
struct mlx5_esw_bridge_fdb_entry *entry, *tmp; struct mlx5_esw_bridge_fdb_entry *entry, *tmp;
struct mlx5_esw_bridge_port *port;
list_for_each_entry_safe(entry, tmp, &bridge->fdb_list, list) list_for_each_entry_safe(entry, tmp, &bridge->fdb_list, list)
if (entry->vport_num == vport->vport) if (entry->vport_num == vport_num && entry->esw_owner_vhca_id == esw_owner_vhca_id)
mlx5_esw_bridge_fdb_entry_cleanup(entry, bridge); mlx5_esw_bridge_fdb_entry_cleanup(entry, bridge);
port = mlx5_esw_bridge_port_lookup(vport->vport, bridge);
if (!port) {
WARN(1, "Vport %u metadata not found on bridge", vport->vport);
return -EINVAL;
}
trace_mlx5_esw_bridge_vport_cleanup(port); trace_mlx5_esw_bridge_vport_cleanup(port);
mlx5_esw_bridge_port_vlans_flush(port, bridge); mlx5_esw_bridge_port_vlans_flush(port, bridge);
mlx5_esw_bridge_port_erase(port, bridge); mlx5_esw_bridge_port_erase(port, br_offloads);
kvfree(port); kvfree(port);
mlx5_esw_bridge_put(br_offloads, bridge); mlx5_esw_bridge_put(br_offloads, bridge);
vport->bridge = NULL;
return 0; return 0;
} }
int mlx5_esw_bridge_vport_link(int ifindex, struct mlx5_esw_bridge_offloads *br_offloads, int mlx5_esw_bridge_vport_link(int ifindex, u16 vport_num, u16 esw_owner_vhca_id,
struct mlx5_vport *vport, struct netlink_ext_ack *extack) struct mlx5_esw_bridge_offloads *br_offloads,
struct netlink_ext_ack *extack)
{ {
struct mlx5_esw_bridge *bridge; struct mlx5_esw_bridge *bridge;
int err; int err;
WARN_ON(vport->bridge);
bridge = mlx5_esw_bridge_lookup(ifindex, br_offloads); bridge = mlx5_esw_bridge_lookup(ifindex, br_offloads);
if (IS_ERR(bridge)) { if (IS_ERR(bridge)) {
NL_SET_ERR_MSG_MOD(extack, "Error checking for existing bridge with same ifindex"); NL_SET_ERR_MSG_MOD(extack, "Error checking for existing bridge with same ifindex");
return PTR_ERR(bridge); return PTR_ERR(bridge);
} }
err = mlx5_esw_bridge_vport_init(br_offloads, bridge, vport); err = mlx5_esw_bridge_vport_init(vport_num, esw_owner_vhca_id, br_offloads, bridge);
if (err) { if (err) {
NL_SET_ERR_MSG_MOD(extack, "Error initializing port"); NL_SET_ERR_MSG_MOD(extack, "Error initializing port");
goto err_vport; goto err_vport;
...@@ -1113,34 +1123,37 @@ int mlx5_esw_bridge_vport_link(int ifindex, struct mlx5_esw_bridge_offloads *br_ ...@@ -1113,34 +1123,37 @@ int mlx5_esw_bridge_vport_link(int ifindex, struct mlx5_esw_bridge_offloads *br_
return err; return err;
} }
int mlx5_esw_bridge_vport_unlink(int ifindex, struct mlx5_esw_bridge_offloads *br_offloads, int mlx5_esw_bridge_vport_unlink(int ifindex, u16 vport_num, u16 esw_owner_vhca_id,
struct mlx5_vport *vport, struct netlink_ext_ack *extack) struct mlx5_esw_bridge_offloads *br_offloads,
struct netlink_ext_ack *extack)
{ {
struct mlx5_esw_bridge *bridge = vport->bridge; struct mlx5_esw_bridge_port *port;
int err; int err;
if (!bridge) { port = mlx5_esw_bridge_port_lookup(vport_num, esw_owner_vhca_id, br_offloads);
if (!port) {
NL_SET_ERR_MSG_MOD(extack, "Port is not attached to any bridge"); NL_SET_ERR_MSG_MOD(extack, "Port is not attached to any bridge");
return -EINVAL; return -EINVAL;
} }
if (bridge->ifindex != ifindex) { if (port->bridge->ifindex != ifindex) {
NL_SET_ERR_MSG_MOD(extack, "Port is attached to another bridge"); NL_SET_ERR_MSG_MOD(extack, "Port is attached to another bridge");
return -EINVAL; return -EINVAL;
} }
err = mlx5_esw_bridge_vport_cleanup(br_offloads, vport); err = mlx5_esw_bridge_vport_cleanup(br_offloads, port);
if (err) if (err)
NL_SET_ERR_MSG_MOD(extack, "Port cleanup failed"); NL_SET_ERR_MSG_MOD(extack, "Port cleanup failed");
return err; return err;
} }
int mlx5_esw_bridge_port_vlan_add(u16 vid, u16 flags, struct mlx5_eswitch *esw, int mlx5_esw_bridge_port_vlan_add(u16 vport_num, u16 esw_owner_vhca_id, u16 vid, u16 flags,
struct mlx5_vport *vport, struct netlink_ext_ack *extack) struct mlx5_esw_bridge_offloads *br_offloads,
struct netlink_ext_ack *extack)
{ {
struct mlx5_esw_bridge_port *port; struct mlx5_esw_bridge_port *port;
struct mlx5_esw_bridge_vlan *vlan; struct mlx5_esw_bridge_vlan *vlan;
port = mlx5_esw_bridge_port_lookup(vport->vport, vport->bridge); port = mlx5_esw_bridge_port_lookup(vport_num, esw_owner_vhca_id, br_offloads);
if (!port) if (!port)
return -EINVAL; return -EINVAL;
...@@ -1148,10 +1161,10 @@ int mlx5_esw_bridge_port_vlan_add(u16 vid, u16 flags, struct mlx5_eswitch *esw, ...@@ -1148,10 +1161,10 @@ int mlx5_esw_bridge_port_vlan_add(u16 vid, u16 flags, struct mlx5_eswitch *esw,
if (vlan) { if (vlan) {
if (vlan->flags == flags) if (vlan->flags == flags)
return 0; return 0;
mlx5_esw_bridge_vlan_cleanup(port, vlan, vport->bridge); mlx5_esw_bridge_vlan_cleanup(port, vlan, port->bridge);
} }
vlan = mlx5_esw_bridge_vlan_create(vid, flags, port, esw); vlan = mlx5_esw_bridge_vlan_create(vid, flags, port, br_offloads->esw);
if (IS_ERR(vlan)) { if (IS_ERR(vlan)) {
NL_SET_ERR_MSG_MOD(extack, "Failed to create VLAN entry"); NL_SET_ERR_MSG_MOD(extack, "Failed to create VLAN entry");
return PTR_ERR(vlan); return PTR_ERR(vlan);
...@@ -1159,36 +1172,38 @@ int mlx5_esw_bridge_port_vlan_add(u16 vid, u16 flags, struct mlx5_eswitch *esw, ...@@ -1159,36 +1172,38 @@ int mlx5_esw_bridge_port_vlan_add(u16 vid, u16 flags, struct mlx5_eswitch *esw,
return 0; return 0;
} }
void mlx5_esw_bridge_port_vlan_del(u16 vid, struct mlx5_eswitch *esw, struct mlx5_vport *vport) void mlx5_esw_bridge_port_vlan_del(u16 vport_num, u16 esw_owner_vhca_id, u16 vid,
struct mlx5_esw_bridge_offloads *br_offloads)
{ {
struct mlx5_esw_bridge_port *port; struct mlx5_esw_bridge_port *port;
struct mlx5_esw_bridge_vlan *vlan; struct mlx5_esw_bridge_vlan *vlan;
port = mlx5_esw_bridge_port_lookup(vport->vport, vport->bridge); port = mlx5_esw_bridge_port_lookup(vport_num, esw_owner_vhca_id, br_offloads);
if (!port) if (!port)
return; return;
vlan = mlx5_esw_bridge_vlan_lookup(vid, port); vlan = mlx5_esw_bridge_vlan_lookup(vid, port);
if (!vlan) if (!vlan)
return; return;
mlx5_esw_bridge_vlan_cleanup(port, vlan, vport->bridge); mlx5_esw_bridge_vlan_cleanup(port, vlan, port->bridge);
} }
void mlx5_esw_bridge_fdb_create(struct net_device *dev, struct mlx5_eswitch *esw, void mlx5_esw_bridge_fdb_create(struct net_device *dev, u16 vport_num, u16 esw_owner_vhca_id,
struct mlx5_vport *vport, struct mlx5_esw_bridge_offloads *br_offloads,
struct switchdev_notifier_fdb_info *fdb_info) struct switchdev_notifier_fdb_info *fdb_info)
{ {
struct mlx5_esw_bridge *bridge = vport->bridge;
struct mlx5_esw_bridge_fdb_entry *entry; struct mlx5_esw_bridge_fdb_entry *entry;
u16 vport_num = vport->vport; struct mlx5_esw_bridge_port *port;
struct mlx5_esw_bridge *bridge;
if (!bridge) { port = mlx5_esw_bridge_port_lookup(vport_num, esw_owner_vhca_id, br_offloads);
esw_info(esw->dev, "Vport is not assigned to bridge (vport=%u)\n", vport_num); if (!port)
return; return;
}
entry = mlx5_esw_bridge_fdb_entry_init(dev, vport_num, fdb_info->addr, fdb_info->vid, bridge = port->bridge;
fdb_info->added_by_user, esw, bridge); entry = mlx5_esw_bridge_fdb_entry_init(dev, vport_num, esw_owner_vhca_id, fdb_info->addr,
fdb_info->vid, fdb_info->added_by_user,
br_offloads->esw, bridge);
if (IS_ERR(entry)) if (IS_ERR(entry))
return; return;
...@@ -1201,20 +1216,21 @@ void mlx5_esw_bridge_fdb_create(struct net_device *dev, struct mlx5_eswitch *esw ...@@ -1201,20 +1216,21 @@ void mlx5_esw_bridge_fdb_create(struct net_device *dev, struct mlx5_eswitch *esw
SWITCHDEV_FDB_ADD_TO_BRIDGE); SWITCHDEV_FDB_ADD_TO_BRIDGE);
} }
void mlx5_esw_bridge_fdb_remove(struct net_device *dev, struct mlx5_eswitch *esw, void mlx5_esw_bridge_fdb_remove(struct net_device *dev, u16 vport_num, u16 esw_owner_vhca_id,
struct mlx5_vport *vport, struct mlx5_esw_bridge_offloads *br_offloads,
struct switchdev_notifier_fdb_info *fdb_info) struct switchdev_notifier_fdb_info *fdb_info)
{ {
struct mlx5_esw_bridge *bridge = vport->bridge; struct mlx5_eswitch *esw = br_offloads->esw;
struct mlx5_esw_bridge_fdb_entry *entry; struct mlx5_esw_bridge_fdb_entry *entry;
struct mlx5_esw_bridge_fdb_key key; struct mlx5_esw_bridge_fdb_key key;
u16 vport_num = vport->vport; struct mlx5_esw_bridge_port *port;
struct mlx5_esw_bridge *bridge;
if (!bridge) { port = mlx5_esw_bridge_port_lookup(vport_num, esw_owner_vhca_id, br_offloads);
esw_warn(esw->dev, "Vport is not assigned to bridge (vport=%u)\n", vport_num); if (!port)
return; return;
}
bridge = port->bridge;
ether_addr_copy(key.addr, fdb_info->addr); ether_addr_copy(key.addr, fdb_info->addr);
key.vid = fdb_info->vid; key.vid = fdb_info->vid;
entry = rhashtable_lookup_fast(&bridge->fdb_ht, &key, fdb_ht_params); entry = rhashtable_lookup_fast(&bridge->fdb_ht, &key, fdb_ht_params);
...@@ -1258,13 +1274,11 @@ void mlx5_esw_bridge_update(struct mlx5_esw_bridge_offloads *br_offloads) ...@@ -1258,13 +1274,11 @@ void mlx5_esw_bridge_update(struct mlx5_esw_bridge_offloads *br_offloads)
static void mlx5_esw_bridge_flush(struct mlx5_esw_bridge_offloads *br_offloads) static void mlx5_esw_bridge_flush(struct mlx5_esw_bridge_offloads *br_offloads)
{ {
struct mlx5_eswitch *esw = br_offloads->esw; struct mlx5_esw_bridge_port *port;
struct mlx5_vport *vport;
unsigned long i; unsigned long i;
mlx5_esw_for_each_vport(esw, i, vport) xa_for_each(&br_offloads->ports, i, port)
if (vport->bridge) mlx5_esw_bridge_vport_cleanup(br_offloads, port);
mlx5_esw_bridge_vport_cleanup(br_offloads, vport);
WARN_ONCE(!list_empty(&br_offloads->bridges), WARN_ONCE(!list_empty(&br_offloads->bridges),
"Cleaning up bridge offloads while still having bridges attached\n"); "Cleaning up bridge offloads while still having bridges attached\n");
...@@ -1279,6 +1293,7 @@ struct mlx5_esw_bridge_offloads *mlx5_esw_bridge_init(struct mlx5_eswitch *esw) ...@@ -1279,6 +1293,7 @@ struct mlx5_esw_bridge_offloads *mlx5_esw_bridge_init(struct mlx5_eswitch *esw)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
INIT_LIST_HEAD(&br_offloads->bridges); INIT_LIST_HEAD(&br_offloads->bridges);
xa_init(&br_offloads->ports);
br_offloads->esw = esw; br_offloads->esw = esw;
esw->br_offloads = br_offloads; esw->br_offloads = br_offloads;
...@@ -1293,6 +1308,7 @@ void mlx5_esw_bridge_cleanup(struct mlx5_eswitch *esw) ...@@ -1293,6 +1308,7 @@ void mlx5_esw_bridge_cleanup(struct mlx5_eswitch *esw)
return; return;
mlx5_esw_bridge_flush(br_offloads); mlx5_esw_bridge_flush(br_offloads);
WARN_ON(!xa_empty(&br_offloads->ports));
esw->br_offloads = NULL; esw->br_offloads = NULL;
kvfree(br_offloads); kvfree(br_offloads);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/xarray.h>
#include "eswitch.h" #include "eswitch.h"
struct mlx5_flow_table; struct mlx5_flow_table;
...@@ -15,6 +16,8 @@ struct mlx5_flow_group; ...@@ -15,6 +16,8 @@ struct mlx5_flow_group;
struct mlx5_esw_bridge_offloads { struct mlx5_esw_bridge_offloads {
struct mlx5_eswitch *esw; struct mlx5_eswitch *esw;
struct list_head bridges; struct list_head bridges;
struct xarray ports;
struct notifier_block netdev_nb; struct notifier_block netdev_nb;
struct notifier_block nb_blk; struct notifier_block nb_blk;
struct notifier_block nb; struct notifier_block nb;
...@@ -31,23 +34,27 @@ struct mlx5_esw_bridge_offloads { ...@@ -31,23 +34,27 @@ struct mlx5_esw_bridge_offloads {
struct mlx5_esw_bridge_offloads *mlx5_esw_bridge_init(struct mlx5_eswitch *esw); struct mlx5_esw_bridge_offloads *mlx5_esw_bridge_init(struct mlx5_eswitch *esw);
void mlx5_esw_bridge_cleanup(struct mlx5_eswitch *esw); void mlx5_esw_bridge_cleanup(struct mlx5_eswitch *esw);
int mlx5_esw_bridge_vport_link(int ifindex, struct mlx5_esw_bridge_offloads *br_offloads, int mlx5_esw_bridge_vport_link(int ifindex, u16 vport_num, u16 esw_owner_vhca_id,
struct mlx5_vport *vport, struct netlink_ext_ack *extack); struct mlx5_esw_bridge_offloads *br_offloads,
int mlx5_esw_bridge_vport_unlink(int ifindex, struct mlx5_esw_bridge_offloads *br_offloads, struct netlink_ext_ack *extack);
struct mlx5_vport *vport, struct netlink_ext_ack *extack); int mlx5_esw_bridge_vport_unlink(int ifindex, u16 vport_num, u16 esw_owner_vhca_id,
void mlx5_esw_bridge_fdb_create(struct net_device *dev, struct mlx5_eswitch *esw, struct mlx5_esw_bridge_offloads *br_offloads,
struct mlx5_vport *vport, struct netlink_ext_ack *extack);
void mlx5_esw_bridge_fdb_create(struct net_device *dev, u16 vport_num, u16 esw_owner_vhca_id,
struct mlx5_esw_bridge_offloads *br_offloads,
struct switchdev_notifier_fdb_info *fdb_info); struct switchdev_notifier_fdb_info *fdb_info);
void mlx5_esw_bridge_fdb_remove(struct net_device *dev, struct mlx5_eswitch *esw, void mlx5_esw_bridge_fdb_remove(struct net_device *dev, u16 vport_num, u16 esw_owner_vhca_id,
struct mlx5_vport *vport, struct mlx5_esw_bridge_offloads *br_offloads,
struct switchdev_notifier_fdb_info *fdb_info); struct switchdev_notifier_fdb_info *fdb_info);
void mlx5_esw_bridge_update(struct mlx5_esw_bridge_offloads *br_offloads); void mlx5_esw_bridge_update(struct mlx5_esw_bridge_offloads *br_offloads);
int mlx5_esw_bridge_ageing_time_set(unsigned long ageing_time, struct mlx5_eswitch *esw, int mlx5_esw_bridge_ageing_time_set(u16 vport_num, u16 esw_owner_vhca_id, unsigned long ageing_time,
struct mlx5_vport *vport); struct mlx5_esw_bridge_offloads *br_offloads);
int mlx5_esw_bridge_vlan_filtering_set(bool enable, struct mlx5_eswitch *esw, int mlx5_esw_bridge_vlan_filtering_set(u16 vport_num, u16 esw_owner_vhca_id, bool enable,
struct mlx5_vport *vport); struct mlx5_esw_bridge_offloads *br_offloads);
int mlx5_esw_bridge_port_vlan_add(u16 vid, u16 flags, struct mlx5_eswitch *esw, int mlx5_esw_bridge_port_vlan_add(u16 vport_num, u16 esw_owner_vhca_id, u16 vid, u16 flags,
struct mlx5_vport *vport, struct netlink_ext_ack *extack); struct mlx5_esw_bridge_offloads *br_offloads,
void mlx5_esw_bridge_port_vlan_del(u16 vid, struct mlx5_eswitch *esw, struct mlx5_vport *vport); struct netlink_ext_ack *extack);
void mlx5_esw_bridge_port_vlan_del(u16 vport_num, u16 esw_owner_vhca_id, u16 vid,
struct mlx5_esw_bridge_offloads *br_offloads);
#endif /* __MLX5_ESW_BRIDGE_H__ */ #endif /* __MLX5_ESW_BRIDGE_H__ */
...@@ -28,6 +28,7 @@ struct mlx5_esw_bridge_fdb_entry { ...@@ -28,6 +28,7 @@ struct mlx5_esw_bridge_fdb_entry {
struct list_head list; struct list_head list;
struct list_head vlan_list; struct list_head vlan_list;
u16 vport_num; u16 vport_num;
u16 esw_owner_vhca_id;
u16 flags; u16 flags;
struct mlx5_flow_handle *ingress_handle; struct mlx5_flow_handle *ingress_handle;
...@@ -47,6 +48,8 @@ struct mlx5_esw_bridge_vlan { ...@@ -47,6 +48,8 @@ struct mlx5_esw_bridge_vlan {
struct mlx5_esw_bridge_port { struct mlx5_esw_bridge_port {
u16 vport_num; u16 vport_num;
u16 esw_owner_vhca_id;
struct mlx5_esw_bridge *bridge;
struct xarray vlans; struct xarray vlans;
}; };
......
...@@ -85,11 +85,15 @@ DECLARE_EVENT_CLASS(mlx5_esw_bridge_port_template, ...@@ -85,11 +85,15 @@ DECLARE_EVENT_CLASS(mlx5_esw_bridge_port_template,
TP_ARGS(port), TP_ARGS(port),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(u16, vport_num) __field(u16, vport_num)
__field(u16, esw_owner_vhca_id)
), ),
TP_fast_assign( TP_fast_assign(
__entry->vport_num = port->vport_num; __entry->vport_num = port->vport_num;
__entry->esw_owner_vhca_id = port->esw_owner_vhca_id;
), ),
TP_printk("vport_num=%hu", __entry->vport_num) TP_printk("vport_num=%hu esw_owner_vhca_id=%hu",
__entry->vport_num,
__entry->esw_owner_vhca_id)
); );
DEFINE_EVENT(mlx5_esw_bridge_port_template, DEFINE_EVENT(mlx5_esw_bridge_port_template,
......
...@@ -160,8 +160,6 @@ enum mlx5_eswitch_vport_event { ...@@ -160,8 +160,6 @@ enum mlx5_eswitch_vport_event {
MLX5_VPORT_PROMISC_CHANGE = BIT(3), MLX5_VPORT_PROMISC_CHANGE = BIT(3),
}; };
struct mlx5_esw_bridge;
struct mlx5_vport { struct mlx5_vport {
struct mlx5_core_dev *dev; struct mlx5_core_dev *dev;
struct hlist_head uc_list[MLX5_L2_ADDR_HASH_SIZE]; struct hlist_head uc_list[MLX5_L2_ADDR_HASH_SIZE];
...@@ -190,7 +188,6 @@ struct mlx5_vport { ...@@ -190,7 +188,6 @@ struct mlx5_vport {
enum mlx5_eswitch_vport_event enabled_events; enum mlx5_eswitch_vport_event enabled_events;
int index; int index;
struct devlink_port *dl_port; struct devlink_port *dl_port;
struct mlx5_esw_bridge *bridge;
}; };
struct mlx5_esw_indir_table; struct mlx5_esw_indir_table;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment