mlxsw: reg: Prepare PERERP register for A-TCAM usage
authorIdo Schimmel <idosch@mellanox.com>
Wed, 25 Jul 2018 06:23:50 +0000 (09:23 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 25 Jul 2018 23:46:01 +0000 (16:46 -0700)
Before introducing A-TCAM support we need to make sure all the necessary
fields are configurable and not hard coded to values that worked for the
C-TCAM only use case.

This includes - for example - the ability to configure the eRP table
used by the TCAM region.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/reg.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c

index 596fddfb3850c3625a84dc6ebb13c50f01837df6..f4e16ac20feaf275608dfd7f844fa5801736a1fa 100644 (file)
@@ -2663,12 +2663,28 @@ MLXSW_ITEM_BIT_ARRAY(reg, pererp, erpt_vector, 0x14, 4, 1);
  */
 MLXSW_ITEM32(reg, pererp, master_rp_id, 0x18, 0, 4);
 
-static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id)
+static inline void mlxsw_reg_pererp_erp_vector_pack(char *payload,
+                                                   unsigned long *erp_vector,
+                                                   unsigned long size)
+{
+       unsigned long bit;
+
+       for_each_set_bit(bit, erp_vector, size)
+               mlxsw_reg_pererp_erpt_vector_set(payload, bit, true);
+}
+
+static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id,
+                                        bool ctcam_le, bool erpt_pointer_valid,
+                                        u8 erpt_bank_pointer, u8 erpt_pointer,
+                                        u8 master_rp_id)
 {
        MLXSW_REG_ZERO(pererp, payload);
        mlxsw_reg_pererp_region_id_set(payload, region_id);
-       mlxsw_reg_pererp_ctcam_le_set(payload, true);
-       mlxsw_reg_pererp_erpt_pointer_valid_set(payload, true);
+       mlxsw_reg_pererp_ctcam_le_set(payload, ctcam_le);
+       mlxsw_reg_pererp_erpt_pointer_valid_set(payload, erpt_pointer_valid);
+       mlxsw_reg_pererp_erpt_bank_pointer_set(payload, erpt_bank_pointer);
+       mlxsw_reg_pererp_erpt_pointer_set(payload, erpt_pointer);
+       mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id);
 }
 
 /* IEDR - Infrastructure Entry Delete Register
index b1b3b0e0c00ee640e8a00897c8892047bf19edc5..a27d3b0f9fcb41fc3d4e2469bf9be178bb488b59 100644 (file)
@@ -72,7 +72,7 @@ mlxsw_sp_acl_atcam_region_erp_init(struct mlxsw_sp *mlxsw_sp,
 {
        char pererp_pl[MLXSW_REG_PERERP_LEN];
 
-       mlxsw_reg_pererp_pack(pererp_pl, region_id);
+       mlxsw_reg_pererp_pack(pererp_pl, region_id, true, true, 0, 0, 0);
        return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pererp), pererp_pl);
 }