Skip to content

Commit 65718c4

Browse files
committed
Merge branch 'lan966x-es0-vcap'
Horatiu Vultur says: ==================== net: lan966x: Add support for ES0 VCAP Provide the Egress Stage 0 (ES0) VCAP (Versatile Content-Aware Processor) support for the lan966x platform. The ES0 VCAP has only 1 lookup which is accessible with a TC chain id 10000000. Currently only one action is support which is vlan pop. Also it is possible to link the IS1 to ES0 using 'goto chain 10000000'. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 81ac272 + 85f0500 commit 65718c4

File tree

7 files changed

+485
-30
lines changed

7 files changed

+485
-30
lines changed

drivers/net/ethernet/microchip/lan966x/lan966x_main.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@
101101
#define LAN966X_VCAP_CID_IS2_L1 VCAP_CID_INGRESS_STAGE2_L1 /* IS2 lookup 1 */
102102
#define LAN966X_VCAP_CID_IS2_MAX (VCAP_CID_INGRESS_STAGE2_L2 - 1) /* IS2 Max */
103103

104+
#define LAN966X_VCAP_CID_ES0_L0 VCAP_CID_EGRESS_L0 /* ES0 lookup 0 */
105+
#define LAN966X_VCAP_CID_ES0_MAX (VCAP_CID_EGRESS_L1 - 1) /* ES0 Max */
106+
104107
/* MAC table entry types.
105108
* ENTRYTYPE_NORMAL is subject to aging.
106109
* ENTRYTYPE_LOCKED is not subject to aging.

drivers/net/ethernet/microchip/lan966x/lan966x_regs.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,12 +1471,27 @@ enum lan966x_target {
14711471
/* REW:PORT:PORT_CFG */
14721472
#define REW_PORT_CFG(g) __REG(TARGET_REW, 0, 1, 0, g, 10, 128, 8, 0, 1, 4)
14731473

1474+
#define REW_PORT_CFG_ES0_EN BIT(4)
1475+
#define REW_PORT_CFG_ES0_EN_SET(x)\
1476+
FIELD_PREP(REW_PORT_CFG_ES0_EN, x)
1477+
#define REW_PORT_CFG_ES0_EN_GET(x)\
1478+
FIELD_GET(REW_PORT_CFG_ES0_EN, x)
1479+
14741480
#define REW_PORT_CFG_NO_REWRITE BIT(0)
14751481
#define REW_PORT_CFG_NO_REWRITE_SET(x)\
14761482
FIELD_PREP(REW_PORT_CFG_NO_REWRITE, x)
14771483
#define REW_PORT_CFG_NO_REWRITE_GET(x)\
14781484
FIELD_GET(REW_PORT_CFG_NO_REWRITE, x)
14791485

1486+
/* REW:COMMON:STAT_CFG */
1487+
#define REW_STAT_CFG __REG(TARGET_REW, 0, 1, 3072, 0, 1, 528, 520, 0, 1, 4)
1488+
1489+
#define REW_STAT_CFG_STAT_MODE GENMASK(1, 0)
1490+
#define REW_STAT_CFG_STAT_MODE_SET(x)\
1491+
FIELD_PREP(REW_STAT_CFG_STAT_MODE, x)
1492+
#define REW_STAT_CFG_STAT_MODE_GET(x)\
1493+
FIELD_GET(REW_STAT_CFG_STAT_MODE, x)
1494+
14801495
/* SYS:SYSTEM:RESET_CFG */
14811496
#define SYS_RESET_CFG __REG(TARGET_SYS, 0, 1, 4128, 0, 1, 168, 0, 0, 1, 4)
14821497

drivers/net/ethernet/microchip/lan966x/lan966x_tc_flower.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "vcap_api_client.h"
66
#include "vcap_tc.h"
77

8+
#define LAN966X_FORCE_UNTAGED 3
9+
810
static bool lan966x_tc_is_known_etype(struct vcap_tc_flower_parse_usage *st,
911
u16 etype)
1012
{
@@ -29,6 +31,8 @@ static bool lan966x_tc_is_known_etype(struct vcap_tc_flower_parse_usage *st,
2931
return true;
3032
}
3133
break;
34+
case VCAP_TYPE_ES0:
35+
return true;
3236
default:
3337
NL_SET_ERR_MSG_MOD(st->fco->common.extack,
3438
"VCAP type not supported");
@@ -318,6 +322,9 @@ static int lan966x_tc_set_actionset(struct vcap_admin *admin,
318322
case VCAP_TYPE_IS2:
319323
aset = VCAP_AFS_BASE_TYPE;
320324
break;
325+
case VCAP_TYPE_ES0:
326+
aset = VCAP_AFS_VID;
327+
break;
321328
default:
322329
return -EINVAL;
323330
}
@@ -353,6 +360,10 @@ static int lan966x_tc_add_rule_link_target(struct vcap_admin *admin,
353360
/* Add IS2 specific PAG key (for chaining rules from IS1) */
354361
return vcap_rule_add_key_u32(vrule, VCAP_KF_LOOKUP_PAG,
355362
link_val, ~0);
363+
case VCAP_TYPE_ES0:
364+
/* Add ES0 specific ISDX key (for chaining rules from IS1) */
365+
return vcap_rule_add_key_u32(vrule, VCAP_KF_ISDX_CLS,
366+
link_val, ~0);
356367
default:
357368
break;
358369
}
@@ -389,6 +400,18 @@ static int lan966x_tc_add_rule_link(struct vcap_control *vctrl,
389400
0xff);
390401
if (err)
391402
return err;
403+
} else if (admin->vtype == VCAP_TYPE_IS1 &&
404+
to_admin->vtype == VCAP_TYPE_ES0) {
405+
/* This works for IS1->ES0 */
406+
err = vcap_rule_add_action_u32(vrule, VCAP_AF_ISDX_ADD_VAL,
407+
diff);
408+
if (err)
409+
return err;
410+
411+
err = vcap_rule_add_action_bit(vrule, VCAP_AF_ISDX_REPLACE_ENA,
412+
VCAP_BIT_1);
413+
if (err)
414+
return err;
392415
} else {
393416
NL_SET_ERR_MSG_MOD(f->common.extack,
394417
"Unsupported chain destination");
@@ -398,6 +421,23 @@ static int lan966x_tc_add_rule_link(struct vcap_control *vctrl,
398421
return err;
399422
}
400423

424+
static int lan966x_tc_add_rule_counter(struct vcap_admin *admin,
425+
struct vcap_rule *vrule)
426+
{
427+
int err = 0;
428+
429+
switch (admin->vtype) {
430+
case VCAP_TYPE_ES0:
431+
err = vcap_rule_mod_action_u32(vrule, VCAP_AF_ESDX,
432+
vrule->id);
433+
break;
434+
default:
435+
break;
436+
}
437+
438+
return err;
439+
}
440+
401441
static int lan966x_tc_flower_add(struct lan966x_port *port,
402442
struct flow_cls_offload *f,
403443
struct vcap_admin *admin,
@@ -465,6 +505,21 @@ static int lan966x_tc_flower_add(struct lan966x_port *port,
465505
if (err)
466506
goto out;
467507

508+
break;
509+
case FLOW_ACTION_VLAN_POP:
510+
if (admin->vtype != VCAP_TYPE_ES0) {
511+
NL_SET_ERR_MSG_MOD(f->common.extack,
512+
"Cannot use vlan pop on non es0");
513+
err = -EOPNOTSUPP;
514+
goto out;
515+
}
516+
517+
/* Force untag */
518+
err = vcap_rule_add_action_u32(vrule, VCAP_AF_PUSH_OUTER_TAG,
519+
LAN966X_FORCE_UNTAGED);
520+
if (err)
521+
goto out;
522+
468523
break;
469524
default:
470525
NL_SET_ERR_MSG_MOD(f->common.extack,
@@ -474,6 +529,12 @@ static int lan966x_tc_flower_add(struct lan966x_port *port,
474529
}
475530
}
476531

532+
err = lan966x_tc_add_rule_counter(admin, vrule);
533+
if (err) {
534+
vcap_set_tc_exterr(f, vrule);
535+
goto out;
536+
}
537+
477538
err = vcap_val_rule(vrule, l3_proto);
478539
if (err) {
479540
vcap_set_tc_exterr(f, vrule);

0 commit comments

Comments
 (0)