forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h
....@@ -17,7 +17,10 @@
1717 unsigned long *used_groups; /* bit array */
1818 unsigned int max_groups;
1919 unsigned int max_group_size;
20
- unsigned long priv[0];
20
+ struct mutex lock; /* guards vregion list */
21
+ struct list_head vregion_list;
22
+ u32 vregion_rehash_intrvl; /* ms */
23
+ unsigned long priv[];
2124 /* priv has to be always the last item */
2225 };
2326
....@@ -26,6 +29,11 @@
2629 struct mlxsw_sp_acl_tcam *tcam);
2730 void mlxsw_sp_acl_tcam_fini(struct mlxsw_sp *mlxsw_sp,
2831 struct mlxsw_sp_acl_tcam *tcam);
32
+u32 mlxsw_sp_acl_tcam_vregion_rehash_intrvl_get(struct mlxsw_sp *mlxsw_sp,
33
+ struct mlxsw_sp_acl_tcam *tcam);
34
+int mlxsw_sp_acl_tcam_vregion_rehash_intrvl_set(struct mlxsw_sp *mlxsw_sp,
35
+ struct mlxsw_sp_acl_tcam *tcam,
36
+ u32 val);
2937 int mlxsw_sp_acl_tcam_priority_get(struct mlxsw_sp *mlxsw_sp,
3038 struct mlxsw_sp_acl_rule_info *rulei,
3139 u32 *priority, bool fillup_priority);
....@@ -34,7 +42,8 @@
3442 size_t ruleset_priv_size;
3543 int (*ruleset_add)(struct mlxsw_sp *mlxsw_sp,
3644 struct mlxsw_sp_acl_tcam *tcam, void *ruleset_priv,
37
- struct mlxsw_afk_element_usage *tmplt_elusage);
45
+ struct mlxsw_afk_element_usage *tmplt_elusage,
46
+ unsigned int *p_min_prio, unsigned int *p_max_prio);
3847 void (*ruleset_del)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv);
3948 int (*ruleset_bind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv,
4049 struct mlxsw_sp_port *mlxsw_sp_port,
....@@ -43,11 +52,13 @@
4352 struct mlxsw_sp_port *mlxsw_sp_port,
4453 bool ingress);
4554 u16 (*ruleset_group_id)(void *ruleset_priv);
46
- size_t (*rule_priv_size)(struct mlxsw_sp *mlxsw_sp);
55
+ size_t rule_priv_size;
4756 int (*rule_add)(struct mlxsw_sp *mlxsw_sp,
4857 void *ruleset_priv, void *rule_priv,
4958 struct mlxsw_sp_acl_rule_info *rulei);
5059 void (*rule_del)(struct mlxsw_sp *mlxsw_sp, void *rule_priv);
60
+ int (*rule_action_replace)(struct mlxsw_sp *mlxsw_sp, void *rule_priv,
61
+ struct mlxsw_sp_acl_rule_info *rulei);
5162 int (*rule_activity_get)(struct mlxsw_sp *mlxsw_sp, void *rule_priv,
5263 bool *activity);
5364 };
....@@ -65,17 +76,18 @@
6576 (MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN * BITS_PER_BYTE)
6677
6778 struct mlxsw_sp_acl_tcam_group;
79
+struct mlxsw_sp_acl_tcam_vregion;
6880
6981 struct mlxsw_sp_acl_tcam_region {
70
- struct list_head list; /* Member of a TCAM group */
71
- struct list_head chunk_list; /* List of chunks under this region */
82
+ struct mlxsw_sp_acl_tcam_vregion *vregion;
7283 struct mlxsw_sp_acl_tcam_group *group;
84
+ struct list_head list; /* Member of a TCAM group */
7385 enum mlxsw_reg_ptar_key_type key_type;
7486 u16 id; /* ACL ID and region ID - they are same */
7587 char tcam_region_info[MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN];
7688 struct mlxsw_afk_key_info *key_info;
7789 struct mlxsw_sp *mlxsw_sp;
78
- unsigned long priv[0];
90
+ unsigned long priv[];
7991 /* priv has to be always the last item */
8092 };
8193
....@@ -121,6 +133,10 @@
121133 struct mlxsw_sp_acl_ctcam_region *cregion,
122134 struct mlxsw_sp_acl_ctcam_chunk *cchunk,
123135 struct mlxsw_sp_acl_ctcam_entry *centry);
136
+int mlxsw_sp_acl_ctcam_entry_action_replace(struct mlxsw_sp *mlxsw_sp,
137
+ struct mlxsw_sp_acl_ctcam_region *cregion,
138
+ struct mlxsw_sp_acl_ctcam_entry *centry,
139
+ struct mlxsw_sp_acl_rule_info *rulei);
124140 static inline unsigned int
125141 mlxsw_sp_acl_ctcam_entry_offset(struct mlxsw_sp_acl_ctcam_entry *centry)
126142 {
....@@ -144,6 +160,7 @@
144160
145161 struct mlxsw_sp_acl_atcam_region {
146162 struct rhashtable entries_ht; /* A-TCAM only */
163
+ struct list_head entries_list; /* A-TCAM only */
147164 struct mlxsw_sp_acl_ctcam_region cregion;
148165 const struct mlxsw_sp_acl_atcam_region_ops *ops;
149166 struct mlxsw_sp_acl_tcam_region *region;
....@@ -154,7 +171,9 @@
154171 };
155172
156173 struct mlxsw_sp_acl_atcam_entry_ht_key {
157
- char enc_key[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN]; /* Encoded key */
174
+ char full_enc_key[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN]; /* Encoded
175
+ * key.
176
+ */
158177 u8 erp_id;
159178 };
160179
....@@ -164,10 +183,19 @@
164183
165184 struct mlxsw_sp_acl_atcam_entry {
166185 struct rhash_head ht_node;
186
+ struct list_head list; /* Member in entries_list */
167187 struct mlxsw_sp_acl_atcam_entry_ht_key ht_key;
188
+ char enc_key[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN]; /* Encoded key,
189
+ * minus delta bits.
190
+ */
191
+ struct {
192
+ u16 start;
193
+ u8 mask;
194
+ u8 value;
195
+ } delta_info;
168196 struct mlxsw_sp_acl_ctcam_entry centry;
169197 struct mlxsw_sp_acl_atcam_lkey_id *lkey_id;
170
- struct mlxsw_sp_acl_erp *erp;
198
+ struct mlxsw_sp_acl_erp_mask *erp_mask;
171199 };
172200
173201 static inline struct mlxsw_sp_acl_atcam_region *
....@@ -189,6 +217,7 @@
189217 struct mlxsw_sp_acl_atcam *atcam,
190218 struct mlxsw_sp_acl_atcam_region *aregion,
191219 struct mlxsw_sp_acl_tcam_region *region,
220
+ void *hints_priv,
192221 const struct mlxsw_sp_acl_ctcam_region_ops *ops);
193222 void mlxsw_sp_acl_atcam_region_fini(struct mlxsw_sp_acl_atcam_region *aregion);
194223 void mlxsw_sp_acl_atcam_chunk_init(struct mlxsw_sp_acl_atcam_region *aregion,
....@@ -204,25 +233,74 @@
204233 struct mlxsw_sp_acl_atcam_region *aregion,
205234 struct mlxsw_sp_acl_atcam_chunk *achunk,
206235 struct mlxsw_sp_acl_atcam_entry *aentry);
236
+int mlxsw_sp_acl_atcam_entry_action_replace(struct mlxsw_sp *mlxsw_sp,
237
+ struct mlxsw_sp_acl_atcam_region *aregion,
238
+ struct mlxsw_sp_acl_atcam_entry *aentry,
239
+ struct mlxsw_sp_acl_rule_info *rulei);
207240 int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp,
208241 struct mlxsw_sp_acl_atcam *atcam);
209242 void mlxsw_sp_acl_atcam_fini(struct mlxsw_sp *mlxsw_sp,
210243 struct mlxsw_sp_acl_atcam *atcam);
244
+void *
245
+mlxsw_sp_acl_atcam_rehash_hints_get(struct mlxsw_sp_acl_atcam_region *aregion);
246
+void mlxsw_sp_acl_atcam_rehash_hints_put(void *hints_priv);
211247
212
-struct mlxsw_sp_acl_erp;
248
+struct mlxsw_sp_acl_erp_delta;
213249
214
-bool mlxsw_sp_acl_erp_is_ctcam_erp(const struct mlxsw_sp_acl_erp *erp);
215
-u8 mlxsw_sp_acl_erp_id(const struct mlxsw_sp_acl_erp *erp);
216
-struct mlxsw_sp_acl_erp *
217
-mlxsw_sp_acl_erp_get(struct mlxsw_sp_acl_atcam_region *aregion,
218
- const char *mask, bool ctcam);
219
-void mlxsw_sp_acl_erp_put(struct mlxsw_sp_acl_atcam_region *aregion,
220
- struct mlxsw_sp_acl_erp *erp);
221
-int mlxsw_sp_acl_erp_region_init(struct mlxsw_sp_acl_atcam_region *aregion);
250
+u16 mlxsw_sp_acl_erp_delta_start(const struct mlxsw_sp_acl_erp_delta *delta);
251
+u8 mlxsw_sp_acl_erp_delta_mask(const struct mlxsw_sp_acl_erp_delta *delta);
252
+u8 mlxsw_sp_acl_erp_delta_value(const struct mlxsw_sp_acl_erp_delta *delta,
253
+ const char *enc_key);
254
+void mlxsw_sp_acl_erp_delta_clear(const struct mlxsw_sp_acl_erp_delta *delta,
255
+ const char *enc_key);
256
+
257
+struct mlxsw_sp_acl_erp_mask;
258
+
259
+bool
260
+mlxsw_sp_acl_erp_mask_is_ctcam(const struct mlxsw_sp_acl_erp_mask *erp_mask);
261
+u8 mlxsw_sp_acl_erp_mask_erp_id(const struct mlxsw_sp_acl_erp_mask *erp_mask);
262
+const struct mlxsw_sp_acl_erp_delta *
263
+mlxsw_sp_acl_erp_delta(const struct mlxsw_sp_acl_erp_mask *erp_mask);
264
+struct mlxsw_sp_acl_erp_mask *
265
+mlxsw_sp_acl_erp_mask_get(struct mlxsw_sp_acl_atcam_region *aregion,
266
+ const char *mask, bool ctcam);
267
+void mlxsw_sp_acl_erp_mask_put(struct mlxsw_sp_acl_atcam_region *aregion,
268
+ struct mlxsw_sp_acl_erp_mask *erp_mask);
269
+int mlxsw_sp_acl_erp_bf_insert(struct mlxsw_sp *mlxsw_sp,
270
+ struct mlxsw_sp_acl_atcam_region *aregion,
271
+ struct mlxsw_sp_acl_erp_mask *erp_mask,
272
+ struct mlxsw_sp_acl_atcam_entry *aentry);
273
+void mlxsw_sp_acl_erp_bf_remove(struct mlxsw_sp *mlxsw_sp,
274
+ struct mlxsw_sp_acl_atcam_region *aregion,
275
+ struct mlxsw_sp_acl_erp_mask *erp_mask,
276
+ struct mlxsw_sp_acl_atcam_entry *aentry);
277
+void *
278
+mlxsw_sp_acl_erp_rehash_hints_get(struct mlxsw_sp_acl_atcam_region *aregion);
279
+void mlxsw_sp_acl_erp_rehash_hints_put(void *hints_priv);
280
+int mlxsw_sp_acl_erp_region_init(struct mlxsw_sp_acl_atcam_region *aregion,
281
+ void *hints_priv);
222282 void mlxsw_sp_acl_erp_region_fini(struct mlxsw_sp_acl_atcam_region *aregion);
223283 int mlxsw_sp_acl_erps_init(struct mlxsw_sp *mlxsw_sp,
224284 struct mlxsw_sp_acl_atcam *atcam);
225285 void mlxsw_sp_acl_erps_fini(struct mlxsw_sp *mlxsw_sp,
226286 struct mlxsw_sp_acl_atcam *atcam);
227287
288
+struct mlxsw_sp_acl_bf;
289
+
290
+int
291
+mlxsw_sp_acl_bf_entry_add(struct mlxsw_sp *mlxsw_sp,
292
+ struct mlxsw_sp_acl_bf *bf,
293
+ struct mlxsw_sp_acl_atcam_region *aregion,
294
+ unsigned int erp_bank,
295
+ struct mlxsw_sp_acl_atcam_entry *aentry);
296
+void
297
+mlxsw_sp_acl_bf_entry_del(struct mlxsw_sp *mlxsw_sp,
298
+ struct mlxsw_sp_acl_bf *bf,
299
+ struct mlxsw_sp_acl_atcam_region *aregion,
300
+ unsigned int erp_bank,
301
+ struct mlxsw_sp_acl_atcam_entry *aentry);
302
+struct mlxsw_sp_acl_bf *
303
+mlxsw_sp_acl_bf_init(struct mlxsw_sp *mlxsw_sp, unsigned int num_erp_banks);
304
+void mlxsw_sp_acl_bf_fini(struct mlxsw_sp_acl_bf *bf);
305
+
228306 #endif