mlxsw: reg: Introduce Flex2 key type for PTAR register
authorJiri Pirko <jiri@mellanox.com>
Sun, 8 Jul 2018 07:00:15 +0000 (10:00 +0300)
committerDavid S. Miller <davem@davemloft.net>
Sun, 8 Jul 2018 08:05:19 +0000 (17:05 +0900)
Introduce Flex2 key type for PTAR register which is used in Spectrum-2.
Also, extend mlxsw_reg_ptar_pack() to set the value according to the
caller.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@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_tcam.c

index 1877d9f8a11a2b5d93fc2904fae773bb80fb630b..29c51ae912411ad6c74ad89520149814b573392e 100644 (file)
@@ -2132,14 +2132,18 @@ MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4);
 
 /* reg_ptar_action_set_type
  * Type of action set to be used on this region.
- * For Spectrum, this is always type 2 - "flexible"
+ * For Spectrum and Spectrum-2, this is always type 2 - "flexible"
  * Access: WO
  */
 MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8);
 
+enum mlxsw_reg_ptar_key_type {
+       MLXSW_REG_PTAR_KEY_TYPE_FLEX = 0x50, /* Spetrum */
+       MLXSW_REG_PTAR_KEY_TYPE_FLEX2 = 0x51, /* Spectrum-2 */
+};
+
 /* reg_ptar_key_type
  * TCAM key type for the region.
- * For Spectrum, this is always type 0x50 - "FLEX_KEY"
  * Access: WO
  */
 MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8);
@@ -2182,13 +2186,14 @@ MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8,
                    MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false);
 
 static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op,
+                                      enum mlxsw_reg_ptar_key_type key_type,
                                       u16 region_size, u16 region_id,
                                       const char *tcam_region_info)
 {
        MLXSW_REG_ZERO(ptar, payload);
        mlxsw_reg_ptar_op_set(payload, op);
        mlxsw_reg_ptar_action_set_type_set(payload, 2); /* "flexible" */
-       mlxsw_reg_ptar_key_type_set(payload, 0x50); /* "FLEX_KEY" */
+       mlxsw_reg_ptar_key_type_set(payload, key_type);
        mlxsw_reg_ptar_region_size_set(payload, region_size);
        mlxsw_reg_ptar_region_id_set(payload, region_id);
        mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info);
index ad1b548e3cace26f149ec9b9ac7eea1e493f8b6e..87fde93cec0c77392d95b646a1679d0099950fa2 100644 (file)
@@ -165,6 +165,7 @@ struct mlxsw_sp_acl_tcam_region {
        struct parman *parman;
        struct mlxsw_sp *mlxsw_sp;
        struct mlxsw_sp_acl_tcam_group *group;
+       enum mlxsw_reg_ptar_key_type key_type;
        u16 id; /* ACL ID and region ID - they are same */
        char tcam_region_info[MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN];
        struct mlxsw_afk_key_info *key_info;
@@ -455,6 +456,7 @@ mlxsw_sp_acl_tcam_region_alloc(struct mlxsw_sp *mlxsw_sp,
        int err;
 
        mlxsw_reg_ptar_pack(ptar_pl, MLXSW_REG_PTAR_OP_ALLOC,
+                           region->key_type,
                            MLXSW_SP_ACL_TCAM_REGION_BASE_COUNT,
                            region->id, region->tcam_region_info);
        encodings_count = mlxsw_afk_key_info_blocks_count_get(key_info);
@@ -477,7 +479,8 @@ mlxsw_sp_acl_tcam_region_free(struct mlxsw_sp *mlxsw_sp,
 {
        char ptar_pl[MLXSW_REG_PTAR_LEN];
 
-       mlxsw_reg_ptar_pack(ptar_pl, MLXSW_REG_PTAR_OP_FREE, 0, region->id,
+       mlxsw_reg_ptar_pack(ptar_pl, MLXSW_REG_PTAR_OP_FREE,
+                           region->key_type, 0, region->id,
                            region->tcam_region_info);
        mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptar), ptar_pl);
 }
@@ -490,7 +493,8 @@ mlxsw_sp_acl_tcam_region_resize(struct mlxsw_sp *mlxsw_sp,
        char ptar_pl[MLXSW_REG_PTAR_LEN];
 
        mlxsw_reg_ptar_pack(ptar_pl, MLXSW_REG_PTAR_OP_RESIZE,
-                           new_size, region->id, region->tcam_region_info);
+                           region->key_type, new_size, region->id,
+                           region->tcam_region_info);
        return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptar), ptar_pl);
 }
 
@@ -713,6 +717,7 @@ mlxsw_sp_acl_tcam_region_create(struct mlxsw_sp *mlxsw_sp,
        if (err)
                goto err_region_id_get;
 
+       region->key_type = MLXSW_REG_PTAR_KEY_TYPE_FLEX;
        err = mlxsw_sp_acl_tcam_region_alloc(mlxsw_sp, region);
        if (err)
                goto err_tcam_region_alloc;