mlxsw: spectrum_acl: Implement region migration according to hints
[linux-2.6-block.git] / drivers / net / ethernet / mellanox / mlxsw / spectrum_acl_tcam.h
index 10512b7c6d50836706234cfaaa17a31be2f68a02..440a3483ed7bdcee9fb8c177dde863df282a251c 100644 (file)
@@ -17,6 +17,8 @@ struct mlxsw_sp_acl_tcam {
        unsigned long *used_groups;  /* bit array */
        unsigned int max_groups;
        unsigned int max_group_size;
+       struct list_head vregion_list;
+       u32 vregion_rehash_intrvl;   /* ms */
        unsigned long priv[0];
        /* priv has to be always the last item */
 };
@@ -43,7 +45,7 @@ struct mlxsw_sp_acl_profile_ops {
                               struct mlxsw_sp_port *mlxsw_sp_port,
                               bool ingress);
        u16 (*ruleset_group_id)(void *ruleset_priv);
-       size_t (*rule_priv_size)(struct mlxsw_sp *mlxsw_sp);
+       size_t rule_priv_size;
        int (*rule_add)(struct mlxsw_sp *mlxsw_sp,
                        void *ruleset_priv, void *rule_priv,
                        struct mlxsw_sp_acl_rule_info *rulei);
@@ -67,11 +69,10 @@ mlxsw_sp_acl_tcam_profile_ops(struct mlxsw_sp *mlxsw_sp,
        (MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN * BITS_PER_BYTE)
 
 struct mlxsw_sp_acl_tcam_group;
+struct mlxsw_sp_acl_tcam_vregion;
 
 struct mlxsw_sp_acl_tcam_region {
-       struct list_head list; /* Member of a TCAM group */
-       struct list_head chunk_list; /* List of chunks under this region */
-       struct mlxsw_sp_acl_tcam_group *group;
+       struct mlxsw_sp_acl_tcam_vregion *vregion;
        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];
@@ -161,9 +162,9 @@ struct mlxsw_sp_acl_atcam_region {
 };
 
 struct mlxsw_sp_acl_atcam_entry_ht_key {
-       char enc_key[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN]; /* Encoded key,
-                                                           * minus delta bits.
-                                                           */
+       char full_enc_key[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN]; /* Encoded
+                                                                * key.
+                                                                */
        u8 erp_id;
 };
 
@@ -175,7 +176,9 @@ struct mlxsw_sp_acl_atcam_entry {
        struct rhash_head ht_node;
        struct list_head list; /* Member in entries_list */
        struct mlxsw_sp_acl_atcam_entry_ht_key ht_key;
-       char full_enc_key[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN]; /* Encoded key */
+       char enc_key[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN]; /* Encoded key,
+                                                           * minus delta bits.
+                                                           */
        struct {
                u16 start;
                u8 mask;
@@ -205,6 +208,7 @@ mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp,
                               struct mlxsw_sp_acl_atcam *atcam,
                               struct mlxsw_sp_acl_atcam_region *aregion,
                               struct mlxsw_sp_acl_tcam_region *region,
+                              void *hints_priv,
                               const struct mlxsw_sp_acl_ctcam_region_ops *ops);
 void mlxsw_sp_acl_atcam_region_fini(struct mlxsw_sp_acl_atcam_region *aregion);
 void mlxsw_sp_acl_atcam_chunk_init(struct mlxsw_sp_acl_atcam_region *aregion,
@@ -228,6 +232,9 @@ int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp,
                            struct mlxsw_sp_acl_atcam *atcam);
 void mlxsw_sp_acl_atcam_fini(struct mlxsw_sp *mlxsw_sp,
                             struct mlxsw_sp_acl_atcam *atcam);
+void *
+mlxsw_sp_acl_atcam_rehash_hints_get(struct mlxsw_sp_acl_atcam_region *aregion);
+void mlxsw_sp_acl_atcam_rehash_hints_put(void *hints_priv);
 
 struct mlxsw_sp_acl_erp_delta;
 
@@ -258,7 +265,11 @@ void mlxsw_sp_acl_erp_bf_remove(struct mlxsw_sp *mlxsw_sp,
                                struct mlxsw_sp_acl_atcam_region *aregion,
                                struct mlxsw_sp_acl_erp_mask *erp_mask,
                                struct mlxsw_sp_acl_atcam_entry *aentry);
-int mlxsw_sp_acl_erp_region_init(struct mlxsw_sp_acl_atcam_region *aregion);
+void *
+mlxsw_sp_acl_erp_rehash_hints_get(struct mlxsw_sp_acl_atcam_region *aregion);
+void mlxsw_sp_acl_erp_rehash_hints_put(void *hints_priv);
+int mlxsw_sp_acl_erp_region_init(struct mlxsw_sp_acl_atcam_region *aregion,
+                                void *hints_priv);
 void mlxsw_sp_acl_erp_region_fini(struct mlxsw_sp_acl_atcam_region *aregion);
 int mlxsw_sp_acl_erps_init(struct mlxsw_sp *mlxsw_sp,
                           struct mlxsw_sp_acl_atcam *atcam);