Skip to content

Commit ae6750e

Browse files
committed
Merge branch 'mlxsw-spectrum_acl-Add-Bloom-filter-support'
Ido Schimmel says: ==================== mlxsw: spectrum_acl: Add Bloom filter support Nir says: Spectrum-2 uses Bloom filter to reduce the number of lookups in the algorithmic TCAM (A-TCAM). HW performs multiple exact match lookups in a given region using a key composed of { packet & mask, mask ID, region ID }. The masks which are used in a region are called rule patterns or RP. When such multiple masks are used, the A-TCAM region uses an eRP (extended RP) table that describes which rule patterns are in use and defines the order of the lookup. When eRP table is used in a region, one way to reduce the number of the lookups is to consult a Bloom filter before doing the lookup. A Bloom filter is a space-efficient probabilistic data structure, on which a query returns either "possibly in set" or "definitely not in set". HW can skip a lookup if a query on the Bloom filter results a "definitely not set" response. The mlxsw driver implements a "counting filter" and when either a new entry is marked or the last entry is removed it will update the HW. Update of this counting filter occurs when rule is configured or deleted from a region. Patch #1 adds PEABFE register which is used for setting Bloom filter entries. Patch #2 adds Bloom filter resources. Patch #3 and patch #4 provide Bloom filter handling within mlxsw, by adding initialization and logic for updating the Bloom bit vector in HW. Patch #5 and patch #6 add required calls for Bloom filter update as part of rule configuration flow. Patch #7 handles transitions to and from eRP table. It uses a list to keep A-TCAM rules in order to update rules in Bloom filter, in cases of transitions from master mask based A-TCAM region to an eRP table based region and vice versa. Patch #8 removes a trick done on master RP index to a remaining RP, since Bloom filter is updated on eRP transitions. Finally, patch #9 activates Bloom filter mechanism in HW, by cancelling the bypass that was configured before and the remaining three patches are selftests that exercise the new code. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 0634d69 + 5d06a76 commit ae6750e

File tree

8 files changed

+661
-9
lines changed

8 files changed

+661
-9
lines changed

drivers/net/ethernet/mellanox/mlxsw/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mlxsw_spectrum-objs := spectrum.o spectrum_buffers.o \
2020
spectrum_acl_tcam.o spectrum_acl_ctcam.o \
2121
spectrum_acl_atcam.o spectrum_acl_erp.o \
2222
spectrum1_acl_tcam.o spectrum2_acl_tcam.o \
23-
spectrum_acl.o \
23+
spectrum_acl_bloom_filter.o spectrum_acl.o \
2424
spectrum_flower.o spectrum_cnt.o \
2525
spectrum_fid.o spectrum_ipip.o \
2626
spectrum_acl_flex_actions.o \

drivers/net/ethernet/mellanox/mlxsw/reg.h

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,7 +2743,7 @@ mlxsw_reg_perpt_pack(char *payload, u8 erpt_bank, u8 erpt_index,
27432743
mlxsw_reg_perpt_erpt_bank_set(payload, erpt_bank);
27442744
mlxsw_reg_perpt_erpt_index_set(payload, erpt_index);
27452745
mlxsw_reg_perpt_key_size_set(payload, key_size);
2746-
mlxsw_reg_perpt_bf_bypass_set(payload, true);
2746+
mlxsw_reg_perpt_bf_bypass_set(payload, false);
27472747
mlxsw_reg_perpt_erp_id_set(payload, erp_id);
27482748
mlxsw_reg_perpt_erpt_base_bank_set(payload, erpt_base_bank);
27492749
mlxsw_reg_perpt_erpt_base_index_set(payload, erpt_base_index);
@@ -3006,7 +3006,7 @@ static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id)
30063006
mlxsw_reg_percr_region_id_set(payload, region_id);
30073007
mlxsw_reg_percr_atcam_ignore_prune_set(payload, false);
30083008
mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false);
3009-
mlxsw_reg_percr_bf_bypass_set(payload, true);
3009+
mlxsw_reg_percr_bf_bypass_set(payload, false);
30103010
}
30113011

30123012
/* PERERP - Policy-Engine Region eRP Register
@@ -3095,6 +3095,72 @@ static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id,
30953095
mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id);
30963096
}
30973097

3098+
/* PEABFE - Policy-Engine Algorithmic Bloom Filter Entries Register
3099+
* ----------------------------------------------------------------
3100+
* This register configures the Bloom filter entries.
3101+
*/
3102+
#define MLXSW_REG_PEABFE_ID 0x3022
3103+
#define MLXSW_REG_PEABFE_BASE_LEN 0x10
3104+
#define MLXSW_REG_PEABFE_BF_REC_LEN 0x4
3105+
#define MLXSW_REG_PEABFE_BF_REC_MAX_COUNT 256
3106+
#define MLXSW_REG_PEABFE_LEN (MLXSW_REG_PEABFE_BASE_LEN + \
3107+
MLXSW_REG_PEABFE_BF_REC_LEN * \
3108+
MLXSW_REG_PEABFE_BF_REC_MAX_COUNT)
3109+
3110+
MLXSW_REG_DEFINE(peabfe, MLXSW_REG_PEABFE_ID, MLXSW_REG_PEABFE_LEN);
3111+
3112+
/* reg_peabfe_size
3113+
* Number of BF entries to be updated.
3114+
* Range 1..256
3115+
* Access: Op
3116+
*/
3117+
MLXSW_ITEM32(reg, peabfe, size, 0x00, 0, 9);
3118+
3119+
/* reg_peabfe_bf_entry_state
3120+
* Bloom filter state
3121+
* 0 - Clear
3122+
* 1 - Set
3123+
* Access: RW
3124+
*/
3125+
MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_state,
3126+
MLXSW_REG_PEABFE_BASE_LEN, 31, 1,
3127+
MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3128+
3129+
/* reg_peabfe_bf_entry_bank
3130+
* Bloom filter bank ID
3131+
* Range 0..cap_max_erp_table_banks-1
3132+
* Access: Index
3133+
*/
3134+
MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_bank,
3135+
MLXSW_REG_PEABFE_BASE_LEN, 24, 4,
3136+
MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3137+
3138+
/* reg_peabfe_bf_entry_index
3139+
* Bloom filter entry index
3140+
* Range 0..2^cap_max_bf_log-1
3141+
* Access: Index
3142+
*/
3143+
MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_index,
3144+
MLXSW_REG_PEABFE_BASE_LEN, 0, 24,
3145+
MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3146+
3147+
static inline void mlxsw_reg_peabfe_pack(char *payload)
3148+
{
3149+
MLXSW_REG_ZERO(peabfe, payload);
3150+
}
3151+
3152+
static inline void mlxsw_reg_peabfe_rec_pack(char *payload, int rec_index,
3153+
u8 state, u8 bank, u32 bf_index)
3154+
{
3155+
u8 num_rec = mlxsw_reg_peabfe_size_get(payload);
3156+
3157+
if (rec_index >= num_rec)
3158+
mlxsw_reg_peabfe_size_set(payload, rec_index + 1);
3159+
mlxsw_reg_peabfe_bf_entry_state_set(payload, rec_index, state);
3160+
mlxsw_reg_peabfe_bf_entry_bank_set(payload, rec_index, bank);
3161+
mlxsw_reg_peabfe_bf_entry_index_set(payload, rec_index, bf_index);
3162+
}
3163+
30983164
/* IEDR - Infrastructure Entry Delete Register
30993165
* ----------------------------------------------------
31003166
* This register is used for deleting entries from the entry tables.
@@ -9608,6 +9674,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
96089674
MLXSW_REG(pemrbt),
96099675
MLXSW_REG(ptce2),
96109676
MLXSW_REG(perpt),
9677+
MLXSW_REG(peabfe),
96119678
MLXSW_REG(perar),
96129679
MLXSW_REG(ptce3),
96139680
MLXSW_REG(percr),

drivers/net/ethernet/mellanox/mlxsw/resources.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ enum mlxsw_res_id {
4141
MLXSW_RES_ID_ACL_ERPT_ENTRIES_4KB,
4242
MLXSW_RES_ID_ACL_ERPT_ENTRIES_8KB,
4343
MLXSW_RES_ID_ACL_ERPT_ENTRIES_12KB,
44+
MLXSW_RES_ID_ACL_MAX_BF_LOG,
4445
MLXSW_RES_ID_MAX_CPU_POLICERS,
4546
MLXSW_RES_ID_MAX_VRS,
4647
MLXSW_RES_ID_MAX_RIFS,
@@ -93,6 +94,7 @@ static u16 mlxsw_res_ids[] = {
9394
[MLXSW_RES_ID_ACL_ERPT_ENTRIES_4KB] = 0x2951,
9495
[MLXSW_RES_ID_ACL_ERPT_ENTRIES_8KB] = 0x2952,
9596
[MLXSW_RES_ID_ACL_ERPT_ENTRIES_12KB] = 0x2953,
97+
[MLXSW_RES_ID_ACL_MAX_BF_LOG] = 0x2960,
9698
[MLXSW_RES_ID_MAX_CPU_POLICERS] = 0x2A13,
9799
[MLXSW_RES_ID_MAX_VRS] = 0x2C01,
98100
[MLXSW_RES_ID_MAX_RIFS] = 0x2C02,

drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp,
323323
aregion->region = region;
324324
aregion->atcam = atcam;
325325
mlxsw_sp_acl_atcam_region_type_init(aregion);
326+
INIT_LIST_HEAD(&aregion->entries_list);
326327

327328
err = rhashtable_init(&aregion->entries_ht,
328329
&mlxsw_sp_acl_atcam_entries_ht_params);
@@ -356,6 +357,7 @@ void mlxsw_sp_acl_atcam_region_fini(struct mlxsw_sp_acl_atcam_region *aregion)
356357
mlxsw_sp_acl_erp_region_fini(aregion);
357358
aregion->ops->fini(aregion);
358359
rhashtable_destroy(&aregion->entries_ht);
360+
WARN_ON(!list_empty(&aregion->entries_list));
359361
}
360362

361363
void mlxsw_sp_acl_atcam_chunk_init(struct mlxsw_sp_acl_atcam_region *aregion,
@@ -499,6 +501,12 @@ __mlxsw_sp_acl_atcam_entry_add(struct mlxsw_sp *mlxsw_sp,
499501
mlxsw_sp_acl_erp_delta_value(delta, aentry->full_enc_key);
500502
mlxsw_sp_acl_erp_delta_clear(delta, aentry->ht_key.enc_key);
501503

504+
/* Add rule to the list of A-TCAM rules, assuming this
505+
* rule is intended to A-TCAM. In case this rule does
506+
* not fit into A-TCAM it will be removed from the list.
507+
*/
508+
list_add(&aentry->list, &aregion->entries_list);
509+
502510
/* We can't insert identical rules into the A-TCAM, so fail and
503511
* let the rule spill into C-TCAM
504512
*/
@@ -508,6 +516,13 @@ __mlxsw_sp_acl_atcam_entry_add(struct mlxsw_sp *mlxsw_sp,
508516
if (err)
509517
goto err_rhashtable_insert;
510518

519+
/* Bloom filter must be updated here, before inserting the rule into
520+
* the A-TCAM.
521+
*/
522+
err = mlxsw_sp_acl_erp_bf_insert(mlxsw_sp, aregion, erp_mask, aentry);
523+
if (err)
524+
goto err_bf_insert;
525+
511526
err = mlxsw_sp_acl_atcam_region_entry_insert(mlxsw_sp, aregion, aentry,
512527
rulei);
513528
if (err)
@@ -516,9 +531,12 @@ __mlxsw_sp_acl_atcam_entry_add(struct mlxsw_sp *mlxsw_sp,
516531
return 0;
517532

518533
err_rule_insert:
534+
mlxsw_sp_acl_erp_bf_remove(mlxsw_sp, aregion, erp_mask, aentry);
535+
err_bf_insert:
519536
rhashtable_remove_fast(&aregion->entries_ht, &aentry->ht_node,
520537
mlxsw_sp_acl_atcam_entries_ht_params);
521538
err_rhashtable_insert:
539+
list_del(&aentry->list);
522540
mlxsw_sp_acl_erp_mask_put(aregion, erp_mask);
523541
return err;
524542
}
@@ -529,8 +547,10 @@ __mlxsw_sp_acl_atcam_entry_del(struct mlxsw_sp *mlxsw_sp,
529547
struct mlxsw_sp_acl_atcam_entry *aentry)
530548
{
531549
mlxsw_sp_acl_atcam_region_entry_remove(mlxsw_sp, aregion, aentry);
550+
mlxsw_sp_acl_erp_bf_remove(mlxsw_sp, aregion, aentry->erp_mask, aentry);
532551
rhashtable_remove_fast(&aregion->entries_ht, &aentry->ht_node,
533552
mlxsw_sp_acl_atcam_entries_ht_params);
553+
list_del(&aentry->list);
534554
mlxsw_sp_acl_erp_mask_put(aregion, aentry->erp_mask);
535555
}
536556

0 commit comments

Comments
 (0)