diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/mlx5/mlx5_core/mlx5_eswitch.c | 80 | ||||
-rw-r--r-- | sys/dev/mlx5/mlx5_core/mlx5_mpfs.c | 5 | ||||
-rw-r--r-- | sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c | 3 | ||||
-rw-r--r-- | sys/dev/mlx5/mpfs.h | 3 |
4 files changed, 11 insertions, 80 deletions
diff --git a/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c b/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c index 8e3cd32f4cb5..907e2621beba 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c @@ -30,6 +30,7 @@ #include <dev/mlx5/mlx5_ifc.h> #include <dev/mlx5/vport.h> #include <dev/mlx5/fs.h> +#include <dev/mlx5/mpfs.h> #include "mlx5_core.h" #include "eswitch.h" @@ -212,81 +213,6 @@ static int modify_esw_vport_cvlan(struct mlx5_core_dev *dev, u32 vport, return modify_esw_vport_context_cmd(dev, vport, in, sizeof(in)); } -/* HW L2 Table (MPFS) management */ -static int set_l2_table_entry_cmd(struct mlx5_core_dev *dev, u32 index, - u8 *mac, u8 vlan_valid, u16 vlan) -{ - u32 in[MLX5_ST_SZ_DW(set_l2_table_entry_in)] = {0}; - u32 out[MLX5_ST_SZ_DW(set_l2_table_entry_out)] = {0}; - u8 *in_mac_addr; - - MLX5_SET(set_l2_table_entry_in, in, opcode, - MLX5_CMD_OP_SET_L2_TABLE_ENTRY); - MLX5_SET(set_l2_table_entry_in, in, table_index, index); - MLX5_SET(set_l2_table_entry_in, in, vlan_valid, vlan_valid); - MLX5_SET(set_l2_table_entry_in, in, vlan, vlan); - - in_mac_addr = MLX5_ADDR_OF(set_l2_table_entry_in, in, mac_address); - ether_addr_copy(&in_mac_addr[2], mac); - - return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); -} - -static int del_l2_table_entry_cmd(struct mlx5_core_dev *dev, u32 index) -{ - u32 in[MLX5_ST_SZ_DW(delete_l2_table_entry_in)] = {0}; - u32 out[MLX5_ST_SZ_DW(delete_l2_table_entry_out)] = {0}; - - MLX5_SET(delete_l2_table_entry_in, in, opcode, - MLX5_CMD_OP_DELETE_L2_TABLE_ENTRY); - MLX5_SET(delete_l2_table_entry_in, in, table_index, index); - return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); -} - -static int alloc_l2_table_index(struct mlx5_l2_table *l2_table, u32 *ix) -{ - int err = 0; - - *ix = find_first_zero_bit(l2_table->bitmap, l2_table->size); - if (*ix >= l2_table->size) - err = -ENOSPC; - else - __set_bit(*ix, l2_table->bitmap); - - return err; -} - -static void free_l2_table_index(struct mlx5_l2_table *l2_table, u32 ix) -{ - __clear_bit(ix, l2_table->bitmap); -} - -static int set_l2_table_entry(struct mlx5_core_dev *dev, u8 *mac, - u8 vlan_valid, u16 vlan, - u32 *index) -{ - struct mlx5_l2_table *l2_table = &dev->priv.eswitch->l2_table; - int err; - - err = alloc_l2_table_index(l2_table, index); - if (err) - return err; - - err = set_l2_table_entry_cmd(dev, *index, mac, vlan_valid, vlan); - if (err) - free_l2_table_index(l2_table, *index); - - return err; -} - -static void del_l2_table_entry(struct mlx5_core_dev *dev, u32 index) -{ - struct mlx5_l2_table *l2_table = &dev->priv.eswitch->l2_table; - - del_l2_table_entry_cmd(dev, index); - free_l2_table_index(l2_table, index); -} - /* E-Switch FDB */ static struct mlx5_flow_rule * esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u8 mac[ETH_ALEN], u32 vport) @@ -435,7 +361,7 @@ static int esw_add_uc_addr(struct mlx5_eswitch *esw, struct vport_addr *vaddr) return -ENOMEM; esw_uc->vport = vport; - err = set_l2_table_entry(esw->dev, mac, 0, 0, &esw_uc->table_index); + err = mlx5_mpfs_add_mac(esw->dev, &esw_uc->table_index, mac, 0, 0); if (err) goto abort; @@ -467,7 +393,7 @@ static int esw_del_uc_addr(struct mlx5_eswitch *esw, struct vport_addr *vaddr) esw_debug(esw->dev, "\tDELETE UC MAC: vport[%d] %pM index:%d fr(%p)\n", vport, mac, esw_uc->table_index, vaddr->flow_rule); - del_l2_table_entry(esw->dev, esw_uc->table_index); + mlx5_mpfs_del_mac(esw->dev, esw_uc->table_index); if (vaddr->flow_rule) mlx5_del_flow_rule(vaddr->flow_rule); diff --git a/sys/dev/mlx5/mlx5_core/mlx5_mpfs.c b/sys/dev/mlx5/mlx5_core/mlx5_mpfs.c index 698d6a2d5973..6835aa8f853b 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_mpfs.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_mpfs.c @@ -39,7 +39,8 @@ #define MPFS_UNLOCK(dev) spin_unlock(&(dev)->mpfs.spinlock) int -mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u32 *p_index, const u8 *mac) +mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u32 *p_index, const u8 *mac, + u8 vlan_valid, u16 vlan) { const u32 l2table_size = MIN(1U << MLX5_CAP_GEN(dev, log_max_l2_table), MLX5_MPFS_TABLE_MAX); @@ -65,6 +66,8 @@ mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u32 *p_index, const u8 *mac) MLX5_SET(set_l2_table_entry_in, in, opcode, MLX5_CMD_OP_SET_L2_TABLE_ENTRY); MLX5_SET(set_l2_table_entry_in, in, table_index, index); + MLX5_SET(set_l2_table_entry_in, in, vlan_valid, vlan_valid); + MLX5_SET(set_l2_table_entry_in, in, vlan, vlan); in_mac_addr = MLX5_ADDR_OF(set_l2_table_entry_in, in, mac_address); ether_addr_copy(&in_mac_addr[2], mac); diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c b/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c index 9c3bcaff675d..20e81fe806a5 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c @@ -861,7 +861,8 @@ retry: if (mlx5e_add_eth_addr_to_hash(priv->eth_addr.if_uc, hn) == 0) continue; if (hn->mpfs_index == -1U) - mlx5_mpfs_add_mac(priv->mdev, &hn->mpfs_index, hn->ai.addr); + mlx5_mpfs_add_mac(priv->mdev, &hn->mpfs_index, + hn->ai.addr, 0, 0); } /* insert L2 multicast addresses into hash list */ diff --git a/sys/dev/mlx5/mpfs.h b/sys/dev/mlx5/mpfs.h index d5d4809fc688..e0328729af50 100644 --- a/sys/dev/mlx5/mpfs.h +++ b/sys/dev/mlx5/mpfs.h @@ -29,7 +29,8 @@ #define _MLX5_MPFS_H_ struct mlx5_core_dev; -int mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u32 *p_index, const u8 *mac); +int mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u32 *p_index, const u8 *mac, + u8 vlan_valid, u16 bbvlan); int mlx5_mpfs_del_mac(struct mlx5_core_dev *dev, u32 index); int mlx5_mpfs_init(struct mlx5_core_dev *dev); void mlx5_mpfs_destroy(struct mlx5_core_dev *dev); |