Skip to content

Commit 611ba75

Browse files
committed
Merge branch 'HW-support-for-VCAP-IS1-and-ES0-in-mscc_ocelot'
Vladimir Oltean says: ==================== HW support for VCAP IS1 and ES0 in mscc_ocelot The patches from RFC series "Offload tc-flower to mscc_ocelot switch using VCAP chains" have been split into 2: https://patchwork.ozlabs.org/project/netdev/list/?series=204810&state=* This is the boring part, that deals with the prerequisites, and not with tc-flower integration. Apart from the initialization of some hardware blocks, which at this point still don't do anything, no new functionality is introduced. - Key and action field offsets are defined for the supported switches. - VCAP properties are added to the driver for the new TCAM blocks. But instead of adding them manually as was done for IS2, which is error prone, the driver is refactored to read these parameters from hardware, which is possible. - Some improvements regarding the processing of struct ocelot_vcap_filter. - Extending the code to be compatible with full and quarter keys. This series was tested, along with other patches not yet submitted, on the Felix and Seville switches. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 879456b + 98642d1 commit 611ba75

File tree

14 files changed

+1140
-377
lines changed

14 files changed

+1140
-377
lines changed

arch/mips/boot/dts/mscc/ocelot.dtsi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,13 @@
134134
<0x1280000 0x100>,
135135
<0x1800000 0x80000>,
136136
<0x1880000 0x10000>,
137+
<0x1040000 0x10000>,
138+
<0x1050000 0x10000>,
137139
<0x1060000 0x10000>;
138140
reg-names = "sys", "rew", "qs", "ptp", "port0", "port1",
139141
"port2", "port3", "port4", "port5", "port6",
140142
"port7", "port8", "port9", "port10", "qsys",
141-
"ana", "s2";
143+
"ana", "s0", "s1", "s2";
142144
interrupts = <18 21 22>;
143145
interrupt-names = "ptp_rdy", "xtr", "inj";
144146

drivers/net/dsa/ocelot/felix.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,6 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)
435435
ocelot->num_stats = felix->info->num_stats;
436436
ocelot->shared_queue_sz = felix->info->shared_queue_sz;
437437
ocelot->num_mact_rows = felix->info->num_mact_rows;
438-
ocelot->vcap_is2_keys = felix->info->vcap_is2_keys;
439-
ocelot->vcap_is2_actions= felix->info->vcap_is2_actions;
440438
ocelot->vcap = felix->info->vcap;
441439
ocelot->ops = felix->info->ops;
442440
ocelot->inj_prefix = OCELOT_TAG_PREFIX_SHORT;

drivers/net/dsa/ocelot/felix.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ struct felix_info {
2121
unsigned int num_stats;
2222
int num_ports;
2323
int num_tx_queues;
24-
struct vcap_field *vcap_is2_keys;
25-
struct vcap_field *vcap_is2_actions;
26-
const struct vcap_props *vcap;
24+
struct vcap_props *vcap;
2725
int switch_pci_bar;
2826
int imdio_pci_bar;
2927
const struct ptp_clock_info *ptp_caps;

drivers/net/dsa/ocelot/felix_vsc9959.c

Lines changed: 168 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
#include <linux/pci.h>
1717
#include "felix.h"
1818

19-
#define VSC9959_VCAP_IS2_CNT 1024
20-
#define VSC9959_VCAP_IS2_ENTRY_WIDTH 376
21-
#define VSC9959_VCAP_PORT_CNT 6
2219
#define VSC9959_TAS_GCL_ENTRY_MAX 63
2320

2421
static const u32 vsc9959_ana_regmap[] = {
@@ -138,14 +135,27 @@ static const u32 vsc9959_qs_regmap[] = {
138135
REG_RESERVED(QS_INH_DBG),
139136
};
140137

141-
static const u32 vsc9959_s2_regmap[] = {
142-
REG(S2_CORE_UPDATE_CTRL, 0x000000),
143-
REG(S2_CORE_MV_CFG, 0x000004),
144-
REG(S2_CACHE_ENTRY_DAT, 0x000008),
145-
REG(S2_CACHE_MASK_DAT, 0x000108),
146-
REG(S2_CACHE_ACTION_DAT, 0x000208),
147-
REG(S2_CACHE_CNT_DAT, 0x000308),
148-
REG(S2_CACHE_TG_DAT, 0x000388),
138+
static const u32 vsc9959_vcap_regmap[] = {
139+
/* VCAP_CORE_CFG */
140+
REG(VCAP_CORE_UPDATE_CTRL, 0x000000),
141+
REG(VCAP_CORE_MV_CFG, 0x000004),
142+
/* VCAP_CORE_CACHE */
143+
REG(VCAP_CACHE_ENTRY_DAT, 0x000008),
144+
REG(VCAP_CACHE_MASK_DAT, 0x000108),
145+
REG(VCAP_CACHE_ACTION_DAT, 0x000208),
146+
REG(VCAP_CACHE_CNT_DAT, 0x000308),
147+
REG(VCAP_CACHE_TG_DAT, 0x000388),
148+
/* VCAP_CONST */
149+
REG(VCAP_CONST_VCAP_VER, 0x000398),
150+
REG(VCAP_CONST_ENTRY_WIDTH, 0x00039c),
151+
REG(VCAP_CONST_ENTRY_CNT, 0x0003a0),
152+
REG(VCAP_CONST_ENTRY_SWCNT, 0x0003a4),
153+
REG(VCAP_CONST_ENTRY_TG_WIDTH, 0x0003a8),
154+
REG(VCAP_CONST_ACTION_DEF_CNT, 0x0003ac),
155+
REG(VCAP_CONST_ACTION_WIDTH, 0x0003b0),
156+
REG(VCAP_CONST_CNT_WIDTH, 0x0003b4),
157+
REG(VCAP_CONST_CORE_CNT, 0x0003b8),
158+
REG(VCAP_CONST_IF_CNT, 0x0003bc),
149159
};
150160

151161
static const u32 vsc9959_qsys_regmap[] = {
@@ -359,7 +369,9 @@ static const u32 *vsc9959_regmap[TARGET_MAX] = {
359369
[QSYS] = vsc9959_qsys_regmap,
360370
[REW] = vsc9959_rew_regmap,
361371
[SYS] = vsc9959_sys_regmap,
362-
[S2] = vsc9959_s2_regmap,
372+
[S0] = vsc9959_vcap_regmap,
373+
[S1] = vsc9959_vcap_regmap,
374+
[S2] = vsc9959_vcap_regmap,
363375
[PTP] = vsc9959_ptp_regmap,
364376
[GCB] = vsc9959_gcb_regmap,
365377
[DEV_GMII] = vsc9959_dev_gmii_regmap,
@@ -392,6 +404,16 @@ static const struct resource vsc9959_target_io_res[TARGET_MAX] = {
392404
.end = 0x001ffff,
393405
.name = "sys",
394406
},
407+
[S0] = {
408+
.start = 0x0040000,
409+
.end = 0x00403ff,
410+
.name = "s0",
411+
},
412+
[S1] = {
413+
.start = 0x0050000,
414+
.end = 0x00503ff,
415+
.name = "s1",
416+
},
395417
[S2] = {
396418
.start = 0x0060000,
397419
.end = 0x00603ff,
@@ -596,6 +618,112 @@ static const struct ocelot_stat_layout vsc9959_stats_layout[] = {
596618
{ .offset = 0x111, .name = "drop_green_prio_7", },
597619
};
598620

621+
static const struct vcap_field vsc9959_vcap_es0_keys[] = {
622+
[VCAP_ES0_EGR_PORT] = { 0, 3},
623+
[VCAP_ES0_IGR_PORT] = { 3, 3},
624+
[VCAP_ES0_RSV] = { 6, 2},
625+
[VCAP_ES0_L2_MC] = { 8, 1},
626+
[VCAP_ES0_L2_BC] = { 9, 1},
627+
[VCAP_ES0_VID] = { 10, 12},
628+
[VCAP_ES0_DP] = { 22, 1},
629+
[VCAP_ES0_PCP] = { 23, 3},
630+
};
631+
632+
static const struct vcap_field vsc9959_vcap_es0_actions[] = {
633+
[VCAP_ES0_ACT_PUSH_OUTER_TAG] = { 0, 2},
634+
[VCAP_ES0_ACT_PUSH_INNER_TAG] = { 2, 1},
635+
[VCAP_ES0_ACT_TAG_A_TPID_SEL] = { 3, 2},
636+
[VCAP_ES0_ACT_TAG_A_VID_SEL] = { 5, 1},
637+
[VCAP_ES0_ACT_TAG_A_PCP_SEL] = { 6, 2},
638+
[VCAP_ES0_ACT_TAG_A_DEI_SEL] = { 8, 2},
639+
[VCAP_ES0_ACT_TAG_B_TPID_SEL] = { 10, 2},
640+
[VCAP_ES0_ACT_TAG_B_VID_SEL] = { 12, 1},
641+
[VCAP_ES0_ACT_TAG_B_PCP_SEL] = { 13, 2},
642+
[VCAP_ES0_ACT_TAG_B_DEI_SEL] = { 15, 2},
643+
[VCAP_ES0_ACT_VID_A_VAL] = { 17, 12},
644+
[VCAP_ES0_ACT_PCP_A_VAL] = { 29, 3},
645+
[VCAP_ES0_ACT_DEI_A_VAL] = { 32, 1},
646+
[VCAP_ES0_ACT_VID_B_VAL] = { 33, 12},
647+
[VCAP_ES0_ACT_PCP_B_VAL] = { 45, 3},
648+
[VCAP_ES0_ACT_DEI_B_VAL] = { 48, 1},
649+
[VCAP_ES0_ACT_RSV] = { 49, 23},
650+
[VCAP_ES0_ACT_HIT_STICKY] = { 72, 1},
651+
};
652+
653+
static const struct vcap_field vsc9959_vcap_is1_keys[] = {
654+
[VCAP_IS1_HK_TYPE] = { 0, 1},
655+
[VCAP_IS1_HK_LOOKUP] = { 1, 2},
656+
[VCAP_IS1_HK_IGR_PORT_MASK] = { 3, 7},
657+
[VCAP_IS1_HK_RSV] = { 10, 9},
658+
[VCAP_IS1_HK_OAM_Y1731] = { 19, 1},
659+
[VCAP_IS1_HK_L2_MC] = { 20, 1},
660+
[VCAP_IS1_HK_L2_BC] = { 21, 1},
661+
[VCAP_IS1_HK_IP_MC] = { 22, 1},
662+
[VCAP_IS1_HK_VLAN_TAGGED] = { 23, 1},
663+
[VCAP_IS1_HK_VLAN_DBL_TAGGED] = { 24, 1},
664+
[VCAP_IS1_HK_TPID] = { 25, 1},
665+
[VCAP_IS1_HK_VID] = { 26, 12},
666+
[VCAP_IS1_HK_DEI] = { 38, 1},
667+
[VCAP_IS1_HK_PCP] = { 39, 3},
668+
/* Specific Fields for IS1 Half Key S1_NORMAL */
669+
[VCAP_IS1_HK_L2_SMAC] = { 42, 48},
670+
[VCAP_IS1_HK_ETYPE_LEN] = { 90, 1},
671+
[VCAP_IS1_HK_ETYPE] = { 91, 16},
672+
[VCAP_IS1_HK_IP_SNAP] = {107, 1},
673+
[VCAP_IS1_HK_IP4] = {108, 1},
674+
/* Layer-3 Information */
675+
[VCAP_IS1_HK_L3_FRAGMENT] = {109, 1},
676+
[VCAP_IS1_HK_L3_FRAG_OFS_GT0] = {110, 1},
677+
[VCAP_IS1_HK_L3_OPTIONS] = {111, 1},
678+
[VCAP_IS1_HK_L3_DSCP] = {112, 6},
679+
[VCAP_IS1_HK_L3_IP4_SIP] = {118, 32},
680+
/* Layer-4 Information */
681+
[VCAP_IS1_HK_TCP_UDP] = {150, 1},
682+
[VCAP_IS1_HK_TCP] = {151, 1},
683+
[VCAP_IS1_HK_L4_SPORT] = {152, 16},
684+
[VCAP_IS1_HK_L4_RNG] = {168, 8},
685+
/* Specific Fields for IS1 Half Key S1_5TUPLE_IP4 */
686+
[VCAP_IS1_HK_IP4_INNER_TPID] = { 42, 1},
687+
[VCAP_IS1_HK_IP4_INNER_VID] = { 43, 12},
688+
[VCAP_IS1_HK_IP4_INNER_DEI] = { 55, 1},
689+
[VCAP_IS1_HK_IP4_INNER_PCP] = { 56, 3},
690+
[VCAP_IS1_HK_IP4_IP4] = { 59, 1},
691+
[VCAP_IS1_HK_IP4_L3_FRAGMENT] = { 60, 1},
692+
[VCAP_IS1_HK_IP4_L3_FRAG_OFS_GT0] = { 61, 1},
693+
[VCAP_IS1_HK_IP4_L3_OPTIONS] = { 62, 1},
694+
[VCAP_IS1_HK_IP4_L3_DSCP] = { 63, 6},
695+
[VCAP_IS1_HK_IP4_L3_IP4_DIP] = { 69, 32},
696+
[VCAP_IS1_HK_IP4_L3_IP4_SIP] = {101, 32},
697+
[VCAP_IS1_HK_IP4_L3_PROTO] = {133, 8},
698+
[VCAP_IS1_HK_IP4_TCP_UDP] = {141, 1},
699+
[VCAP_IS1_HK_IP4_TCP] = {142, 1},
700+
[VCAP_IS1_HK_IP4_L4_RNG] = {143, 8},
701+
[VCAP_IS1_HK_IP4_IP_PAYLOAD_S1_5TUPLE] = {151, 32},
702+
};
703+
704+
static const struct vcap_field vsc9959_vcap_is1_actions[] = {
705+
[VCAP_IS1_ACT_DSCP_ENA] = { 0, 1},
706+
[VCAP_IS1_ACT_DSCP_VAL] = { 1, 6},
707+
[VCAP_IS1_ACT_QOS_ENA] = { 7, 1},
708+
[VCAP_IS1_ACT_QOS_VAL] = { 8, 3},
709+
[VCAP_IS1_ACT_DP_ENA] = { 11, 1},
710+
[VCAP_IS1_ACT_DP_VAL] = { 12, 1},
711+
[VCAP_IS1_ACT_PAG_OVERRIDE_MASK] = { 13, 8},
712+
[VCAP_IS1_ACT_PAG_VAL] = { 21, 8},
713+
[VCAP_IS1_ACT_RSV] = { 29, 9},
714+
[VCAP_IS1_ACT_VID_REPLACE_ENA] = { 38, 1},
715+
[VCAP_IS1_ACT_VID_ADD_VAL] = { 39, 12},
716+
[VCAP_IS1_ACT_FID_SEL] = { 51, 2},
717+
[VCAP_IS1_ACT_FID_VAL] = { 53, 13},
718+
[VCAP_IS1_ACT_PCP_DEI_ENA] = { 66, 1},
719+
[VCAP_IS1_ACT_PCP_VAL] = { 67, 3},
720+
[VCAP_IS1_ACT_DEI_VAL] = { 70, 1},
721+
[VCAP_IS1_ACT_VLAN_POP_CNT_ENA] = { 71, 1},
722+
[VCAP_IS1_ACT_VLAN_POP_CNT] = { 72, 2},
723+
[VCAP_IS1_ACT_CUSTOM_ACE_TYPE_ENA] = { 74, 4},
724+
[VCAP_IS1_ACT_HIT_STICKY] = { 78, 1},
725+
};
726+
599727
static struct vcap_field vsc9959_vcap_is2_keys[] = {
600728
/* Common: 41 bits */
601729
[VCAP_IS2_TYPE] = { 0, 4},
@@ -694,15 +822,32 @@ static struct vcap_field vsc9959_vcap_is2_actions[] = {
694822
[VCAP_IS2_ACT_HIT_CNT] = { 49, 32},
695823
};
696824

697-
static const struct vcap_props vsc9959_vcap_props[] = {
825+
static struct vcap_props vsc9959_vcap_props[] = {
826+
[VCAP_ES0] = {
827+
.action_type_width = 0,
828+
.action_table = {
829+
[ES0_ACTION_TYPE_NORMAL] = {
830+
.width = 72, /* HIT_STICKY not included */
831+
.count = 1,
832+
},
833+
},
834+
.target = S0,
835+
.keys = vsc9959_vcap_es0_keys,
836+
.actions = vsc9959_vcap_es0_actions,
837+
},
838+
[VCAP_IS1] = {
839+
.action_type_width = 0,
840+
.action_table = {
841+
[IS1_ACTION_TYPE_NORMAL] = {
842+
.width = 78, /* HIT_STICKY not included */
843+
.count = 4,
844+
},
845+
},
846+
.target = S1,
847+
.keys = vsc9959_vcap_is1_keys,
848+
.actions = vsc9959_vcap_is1_actions,
849+
},
698850
[VCAP_IS2] = {
699-
.tg_width = 2,
700-
.sw_count = 4,
701-
.entry_count = VSC9959_VCAP_IS2_CNT,
702-
.entry_width = VSC9959_VCAP_IS2_ENTRY_WIDTH,
703-
.action_count = VSC9959_VCAP_IS2_CNT +
704-
VSC9959_VCAP_PORT_CNT + 2,
705-
.action_width = 89,
706851
.action_type_width = 1,
707852
.action_table = {
708853
[IS2_ACTION_TYPE_NORMAL] = {
@@ -714,8 +859,9 @@ static const struct vcap_props vsc9959_vcap_props[] = {
714859
.count = 4
715860
},
716861
},
717-
.counter_words = 4,
718-
.counter_width = 32,
862+
.target = S2,
863+
.keys = vsc9959_vcap_is2_keys,
864+
.actions = vsc9959_vcap_is2_actions,
719865
},
720866
};
721867

@@ -1184,8 +1330,6 @@ static const struct felix_info felix_info_vsc9959 = {
11841330
.ops = &vsc9959_ops,
11851331
.stats_layout = vsc9959_stats_layout,
11861332
.num_stats = ARRAY_SIZE(vsc9959_stats_layout),
1187-
.vcap_is2_keys = vsc9959_vcap_is2_keys,
1188-
.vcap_is2_actions = vsc9959_vcap_is2_actions,
11891333
.vcap = vsc9959_vcap_props,
11901334
.shared_queue_sz = 128 * 1024,
11911335
.num_mact_rows = 2048,

0 commit comments

Comments
 (0)