Skip to content

Commit 98e60dc

Browse files
committed
Merge branch 'mlxsw-Introduce-initial-Spectrum-2-support'
Ido Schimmel says: ==================== mlxsw: Introduce initial Spectrum-2 support This patch set adds initial support for the Spectrum-2 ASIC. The first two patches add Spectrum-2 specific KVD linear (KVDL) manager. Unlike the Spectrum ASIC, there is no linear memory and instead the type of the entry (e.g., nexthop) and its index are hashed and the entry is placed in the computed address in the hash-based KVD memory. The third patch adds Spectrum-2 stubs in the multicast routing code. Support for multicast routing will be added later on. Patches 4-15 add ACL support. The Spectrum-2 ASIC includes an algorithmic TCAM (A-TCAM) and a regular circuit TCAM (C-TCAM) for rules that can't be inserted into the A-TCAM. This set does not make use of the A-TCAM and only places rules in the C-TCAM. This provides equivalent scale and performance to the Spectrum ASIC. A follow-up patch set will introduce A-TCAM support. The last patch extends the main driver file to work with both ASICs. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents c0b7803 + c3ab435 commit 98e60dc

18 files changed

+1467
-86
lines changed

drivers/net/ethernet/mellanox/mlxsw/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ mlxsw_switchx2-objs := switchx2.o
1515
obj-$(CONFIG_MLXSW_SPECTRUM) += mlxsw_spectrum.o
1616
mlxsw_spectrum-objs := spectrum.o spectrum_buffers.o \
1717
spectrum_switchdev.o spectrum_router.o \
18-
spectrum1_kvdl.o spectrum_kvdl.o \
18+
spectrum1_kvdl.o spectrum2_kvdl.o \
19+
spectrum_kvdl.o \
1920
spectrum_acl_tcam.o spectrum_acl_ctcam.o \
20-
spectrum1_acl_tcam.o \
21+
spectrum_acl_atcam.o \
22+
spectrum1_acl_tcam.o spectrum2_acl_tcam.o \
2123
spectrum_acl.o \
2224
spectrum_flower.o spectrum_cnt.o \
2325
spectrum_fid.o spectrum_ipip.o \
2426
spectrum_acl_flex_actions.o \
2527
spectrum_acl_flex_keys.o \
26-
spectrum1_mr_tcam.o \
28+
spectrum1_mr_tcam.o spectrum2_mr_tcam.o \
2729
spectrum_mr_tcam.o spectrum_mr.o \
2830
spectrum_qdisc.o spectrum_span.o
2931
mlxsw_spectrum-$(CONFIG_MLXSW_SPECTRUM_DCB) += spectrum_dcb.o

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,12 @@ char *mlxsw_afa_block_first_set(struct mlxsw_afa_block *block)
430430
}
431431
EXPORT_SYMBOL(mlxsw_afa_block_first_set);
432432

433+
char *mlxsw_afa_block_cur_set(struct mlxsw_afa_block *block)
434+
{
435+
return block->cur_set->ht_key.enc_actions;
436+
}
437+
EXPORT_SYMBOL(mlxsw_afa_block_cur_set);
438+
433439
u32 mlxsw_afa_block_first_kvdl_index(struct mlxsw_afa_block *block)
434440
{
435441
/* First set is never in KVD linear. So the first set
@@ -441,6 +447,15 @@ u32 mlxsw_afa_block_first_kvdl_index(struct mlxsw_afa_block *block)
441447
}
442448
EXPORT_SYMBOL(mlxsw_afa_block_first_kvdl_index);
443449

450+
int mlxsw_afa_block_activity_get(struct mlxsw_afa_block *block, bool *activity)
451+
{
452+
u32 kvdl_index = mlxsw_afa_block_first_kvdl_index(block);
453+
454+
return block->afa->ops->kvdl_set_activity_get(block->afa->ops_priv,
455+
kvdl_index, activity);
456+
}
457+
EXPORT_SYMBOL(mlxsw_afa_block_activity_get);
458+
444459
int mlxsw_afa_block_continue(struct mlxsw_afa_block *block)
445460
{
446461
if (block->finished)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ struct mlxsw_afa_ops {
4545
int (*kvdl_set_add)(void *priv, u32 *p_kvdl_index,
4646
char *enc_actions, bool is_first);
4747
void (*kvdl_set_del)(void *priv, u32 kvdl_index, bool is_first);
48+
int (*kvdl_set_activity_get)(void *priv, u32 kvdl_index,
49+
bool *activity);
4850
int (*kvdl_fwd_entry_add)(void *priv, u32 *p_kvdl_index, u8 local_port);
4951
void (*kvdl_fwd_entry_del)(void *priv, u32 kvdl_index);
5052
int (*counter_index_get)(void *priv, unsigned int *p_counter_index);
@@ -65,7 +67,9 @@ struct mlxsw_afa_block *mlxsw_afa_block_create(struct mlxsw_afa *mlxsw_afa);
6567
void mlxsw_afa_block_destroy(struct mlxsw_afa_block *block);
6668
int mlxsw_afa_block_commit(struct mlxsw_afa_block *block);
6769
char *mlxsw_afa_block_first_set(struct mlxsw_afa_block *block);
70+
char *mlxsw_afa_block_cur_set(struct mlxsw_afa_block *block);
6871
u32 mlxsw_afa_block_first_kvdl_index(struct mlxsw_afa_block *block);
72+
int mlxsw_afa_block_activity_get(struct mlxsw_afa_block *block, bool *activity);
6973
int mlxsw_afa_block_continue(struct mlxsw_afa_block *block);
7074
int mlxsw_afa_block_jump(struct mlxsw_afa_block *block, u16 group_id);
7175
int mlxsw_afa_block_terminate(struct mlxsw_afa_block *block);

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

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -416,24 +416,74 @@ void mlxsw_afk_values_add_buf(struct mlxsw_afk_element_values *values,
416416
}
417417
EXPORT_SYMBOL(mlxsw_afk_values_add_buf);
418418

419+
static void mlxsw_sp_afk_encode_u32(const struct mlxsw_item *storage_item,
420+
const struct mlxsw_item *output_item,
421+
char *storage, char *output)
422+
{
423+
u32 value;
424+
425+
value = __mlxsw_item_get32(storage, storage_item, 0);
426+
__mlxsw_item_set32(output, output_item, 0, value);
427+
}
428+
429+
static void mlxsw_sp_afk_encode_buf(const struct mlxsw_item *storage_item,
430+
const struct mlxsw_item *output_item,
431+
char *storage, char *output)
432+
{
433+
char *storage_data = __mlxsw_item_data(storage, storage_item, 0);
434+
char *output_data = __mlxsw_item_data(output, output_item, 0);
435+
size_t len = output_item->size.bytes;
436+
437+
memcpy(output_data, storage_data, len);
438+
}
439+
440+
static void
441+
mlxsw_sp_afk_encode_one(const struct mlxsw_afk_element_inst *elinst,
442+
char *output, char *storage)
443+
{
444+
const struct mlxsw_item *storage_item = &elinst->info->item;
445+
const struct mlxsw_item *output_item = &elinst->item;
446+
447+
if (elinst->type == MLXSW_AFK_ELEMENT_TYPE_U32)
448+
mlxsw_sp_afk_encode_u32(storage_item, output_item,
449+
storage, output);
450+
else if (elinst->type == MLXSW_AFK_ELEMENT_TYPE_BUF)
451+
mlxsw_sp_afk_encode_buf(storage_item, output_item,
452+
storage, output);
453+
}
454+
455+
#define MLXSW_SP_AFK_KEY_BLOCK_MAX_SIZE 16
456+
419457
void mlxsw_afk_encode(struct mlxsw_afk *mlxsw_afk,
420458
struct mlxsw_afk_key_info *key_info,
421459
struct mlxsw_afk_element_values *values,
422460
char *key, char *mask)
423461
{
462+
char block_mask[MLXSW_SP_AFK_KEY_BLOCK_MAX_SIZE];
463+
char block_key[MLXSW_SP_AFK_KEY_BLOCK_MAX_SIZE];
424464
const struct mlxsw_afk_element_inst *elinst;
425465
enum mlxsw_afk_element element;
426-
int block_index;
466+
int block_index, i;
467+
468+
for (i = 0; i < key_info->blocks_count; i++) {
469+
memset(block_key, 0, MLXSW_SP_AFK_KEY_BLOCK_MAX_SIZE);
470+
memset(block_mask, 0, MLXSW_SP_AFK_KEY_BLOCK_MAX_SIZE);
471+
472+
mlxsw_afk_element_usage_for_each(element, &values->elusage) {
473+
elinst = mlxsw_afk_key_info_elinst_get(key_info,
474+
element,
475+
&block_index);
476+
if (!elinst || block_index != i)
477+
continue;
478+
479+
mlxsw_sp_afk_encode_one(elinst, block_key,
480+
values->storage.key);
481+
mlxsw_sp_afk_encode_one(elinst, block_mask,
482+
values->storage.mask);
483+
}
427484

428-
mlxsw_afk_element_usage_for_each(element, &values->elusage) {
429-
elinst = mlxsw_afk_key_info_elinst_get(key_info, element,
430-
&block_index);
431-
if (!elinst)
432-
continue;
433-
mlxsw_afk->ops->encode_one(elinst, block_index,
434-
values->storage.key, key);
435-
mlxsw_afk->ops->encode_one(elinst, block_index,
436-
values->storage.mask, mask);
485+
mlxsw_afk->ops->encode_block(block_key, i, key);
486+
mlxsw_afk->ops->encode_block(block_mask, i, mask);
437487
}
438488
}
439489
EXPORT_SYMBOL(mlxsw_afk_encode);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ struct mlxsw_afk;
219219
struct mlxsw_afk_ops {
220220
const struct mlxsw_afk_block *blocks;
221221
unsigned int blocks_count;
222-
void (*encode_one)(const struct mlxsw_afk_element_inst *elinst,
223-
int block_index, char *storage, char *output);
222+
void (*encode_block)(char *block, int block_index, char *output);
224223
};
225224

226225
struct mlxsw_afk *mlxsw_afk_create(unsigned int max_blocks,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
#define PCI_DEVICE_ID_MELLANOX_SWITCHX2 0xc738
4141
#define PCI_DEVICE_ID_MELLANOX_SPECTRUM 0xcb84
42+
#define PCI_DEVICE_ID_MELLANOX_SPECTRUM2 0xcf6c
4243
#define PCI_DEVICE_ID_MELLANOX_SWITCHIB 0xcb20
4344
#define PCI_DEVICE_ID_MELLANOX_SWITCHIB2 0xcf08
4445

0 commit comments

Comments
 (0)