Commit 20cce886 authored by John Hurley's avatar John Hurley Committed by David S. Miller

nfp: flower: enable MAC address sharing for offloadable devs

A MAC address is not necessarily a unique identifier for a netdev. Drivers
such as Linux bonds, for example, can apply the same MAC address to the
upper layer device and all lower layer devices.

NFP MAC offload for tunnel decap includes port verification for reprs but
also supports the offload of non-repr MAC addresses by assigning 'global'
indexes to these. This means that the FW will not verify the incoming port
of a packet matching this destination MAC.

Modify the MAC offload logic to assign global indexes based on MAC address
instead of net device (as it currently does). Use this to allow multiple
devices to share the same MAC. In other words, if a repr shares its MAC
address with another device then give the offloaded MAC a global index
rather than associate it with an ingress port. Track this so that changes
can be reverted as MACs stop being shared.

Implement this by removing the current list based assignment of global
indexes and replacing it with an rhashtable that maps an offloaded MAC
address to the number of devices sharing it, distributing global indexes
based on this.
Signed-off-by: default avatarJohn Hurley <john.hurley@netronome.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 13cf7103
...@@ -286,6 +286,7 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app, ...@@ -286,6 +286,7 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app,
nfp_repr = netdev_priv(repr); nfp_repr = netdev_priv(repr);
nfp_repr->app_priv = repr_priv; nfp_repr->app_priv = repr_priv;
repr_priv->nfp_repr = nfp_repr;
/* For now we only support 1 PF */ /* For now we only support 1 PF */
WARN_ON(repr_type == NFP_REPR_TYPE_PF && i); WARN_ON(repr_type == NFP_REPR_TYPE_PF && i);
...@@ -400,6 +401,7 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv) ...@@ -400,6 +401,7 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv)
nfp_repr = netdev_priv(repr); nfp_repr = netdev_priv(repr);
nfp_repr->app_priv = repr_priv; nfp_repr->app_priv = repr_priv;
repr_priv->nfp_repr = nfp_repr;
port = nfp_port_alloc(app, NFP_PORT_PHYS_PORT, repr); port = nfp_port_alloc(app, NFP_PORT_PHYS_PORT, repr);
if (IS_ERR(port)) { if (IS_ERR(port)) {
......
...@@ -58,20 +58,18 @@ struct nfp_fl_stats_id { ...@@ -58,20 +58,18 @@ struct nfp_fl_stats_id {
/** /**
* struct nfp_fl_tunnel_offloads - priv data for tunnel offloads * struct nfp_fl_tunnel_offloads - priv data for tunnel offloads
* @mac_index_list: List of unique 8-bit indexes for non NFP netdevs * @offloaded_macs: Hashtable of the offloaded MAC addresses
* @ipv4_off_list: List of IPv4 addresses to offload * @ipv4_off_list: List of IPv4 addresses to offload
* @neigh_off_list: List of neighbour offloads * @neigh_off_list: List of neighbour offloads
* @mac_index_lock: Lock for the MAC index list
* @ipv4_off_lock: Lock for the IPv4 address list * @ipv4_off_lock: Lock for the IPv4 address list
* @neigh_off_lock: Lock for the neighbour address list * @neigh_off_lock: Lock for the neighbour address list
* @mac_off_ids: IDA to manage id assignment for offloaded MACs * @mac_off_ids: IDA to manage id assignment for offloaded MACs
* @neigh_nb: Notifier to monitor neighbour state * @neigh_nb: Notifier to monitor neighbour state
*/ */
struct nfp_fl_tunnel_offloads { struct nfp_fl_tunnel_offloads {
struct list_head mac_index_list; struct rhashtable offloaded_macs;
struct list_head ipv4_off_list; struct list_head ipv4_off_list;
struct list_head neigh_off_list; struct list_head neigh_off_list;
struct mutex mac_index_lock;
struct mutex ipv4_off_lock; struct mutex ipv4_off_lock;
spinlock_t neigh_off_lock; spinlock_t neigh_off_lock;
struct ida mac_off_ids; struct ida mac_off_ids;
...@@ -178,14 +176,18 @@ struct nfp_flower_priv { ...@@ -178,14 +176,18 @@ struct nfp_flower_priv {
/** /**
* struct nfp_flower_repr_priv - Flower APP per-repr priv data * struct nfp_flower_repr_priv - Flower APP per-repr priv data
* @nfp_repr: Back pointer to nfp_repr
* @lag_port_flags: Extended port flags to record lag state of repr * @lag_port_flags: Extended port flags to record lag state of repr
* @mac_offloaded: Flag indicating a MAC address is offloaded for repr * @mac_offloaded: Flag indicating a MAC address is offloaded for repr
* @offloaded_mac_addr: MAC address that has been offloaded for repr * @offloaded_mac_addr: MAC address that has been offloaded for repr
* @mac_list: List entry of reprs that share the same offloaded MAC
*/ */
struct nfp_flower_repr_priv { struct nfp_flower_repr_priv {
struct nfp_repr *nfp_repr;
unsigned long lag_port_flags; unsigned long lag_port_flags;
bool mac_offloaded; bool mac_offloaded;
u8 offloaded_mac_addr[ETH_ALEN]; u8 offloaded_mac_addr[ETH_ALEN];
struct list_head mac_list;
}; };
/** /**
......
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