Skip to content

Commit 135c211

Browse files
HoratiuVulturkuba-moo
authored andcommitted
net: lan966x: Add TC support for IS1 VCAP
Enable TC command to use IS1 VCAP Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent a4d9b3e commit 135c211

File tree

1 file changed

+102
-3
lines changed

1 file changed

+102
-3
lines changed

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

Lines changed: 102 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,61 @@ lan966x_tc_flower_handler_basic_usage(struct vcap_tc_flower_parse_usage *st)
7979
VCAP_BIT_1);
8080
if (err)
8181
goto out;
82+
} else if (st->l3_proto == ETH_P_IPV6 &&
83+
st->admin->vtype == VCAP_TYPE_IS1) {
84+
/* Don't set any keys in this case */
85+
} else if (st->l3_proto == ETH_P_SNAP &&
86+
st->admin->vtype == VCAP_TYPE_IS1) {
87+
err = vcap_rule_add_key_bit(st->vrule,
88+
VCAP_KF_ETYPE_LEN_IS,
89+
VCAP_BIT_0);
90+
if (err)
91+
goto out;
92+
93+
err = vcap_rule_add_key_bit(st->vrule,
94+
VCAP_KF_IP_SNAP_IS,
95+
VCAP_BIT_1);
96+
if (err)
97+
goto out;
98+
} else if (st->admin->vtype == VCAP_TYPE_IS1) {
99+
err = vcap_rule_add_key_bit(st->vrule,
100+
VCAP_KF_ETYPE_LEN_IS,
101+
VCAP_BIT_1);
102+
if (err)
103+
goto out;
104+
105+
err = vcap_rule_add_key_u32(st->vrule, VCAP_KF_ETYPE,
106+
st->l3_proto, ~0);
107+
if (err)
108+
goto out;
82109
}
83110
}
84111
if (match.mask->ip_proto) {
85112
st->l4_proto = match.key->ip_proto;
86113

87114
if (st->l4_proto == IPPROTO_TCP) {
115+
if (st->admin->vtype == VCAP_TYPE_IS1) {
116+
err = vcap_rule_add_key_bit(st->vrule,
117+
VCAP_KF_TCP_UDP_IS,
118+
VCAP_BIT_1);
119+
if (err)
120+
goto out;
121+
}
122+
88123
err = vcap_rule_add_key_bit(st->vrule,
89124
VCAP_KF_TCP_IS,
90125
VCAP_BIT_1);
91126
if (err)
92127
goto out;
93128
} else if (st->l4_proto == IPPROTO_UDP) {
129+
if (st->admin->vtype == VCAP_TYPE_IS1) {
130+
err = vcap_rule_add_key_bit(st->vrule,
131+
VCAP_KF_TCP_UDP_IS,
132+
VCAP_BIT_1);
133+
if (err)
134+
goto out;
135+
}
136+
94137
err = vcap_rule_add_key_bit(st->vrule,
95138
VCAP_KF_TCP_IS,
96139
VCAP_BIT_0);
@@ -112,12 +155,30 @@ lan966x_tc_flower_handler_basic_usage(struct vcap_tc_flower_parse_usage *st)
112155
return err;
113156
}
114157

158+
static int
159+
lan966x_tc_flower_handler_cvlan_usage(struct vcap_tc_flower_parse_usage *st)
160+
{
161+
if (st->admin->vtype != VCAP_TYPE_IS1) {
162+
NL_SET_ERR_MSG_MOD(st->fco->common.extack,
163+
"cvlan not supported in this VCAP");
164+
return -EINVAL;
165+
}
166+
167+
return vcap_tc_flower_handler_cvlan_usage(st);
168+
}
169+
115170
static int
116171
lan966x_tc_flower_handler_vlan_usage(struct vcap_tc_flower_parse_usage *st)
117172
{
118-
return vcap_tc_flower_handler_vlan_usage(st,
119-
VCAP_KF_8021Q_VID_CLS,
120-
VCAP_KF_8021Q_PCP_CLS);
173+
enum vcap_key_field vid_key = VCAP_KF_8021Q_VID_CLS;
174+
enum vcap_key_field pcp_key = VCAP_KF_8021Q_PCP_CLS;
175+
176+
if (st->admin->vtype == VCAP_TYPE_IS1) {
177+
vid_key = VCAP_KF_8021Q_VID0;
178+
pcp_key = VCAP_KF_8021Q_PCP0;
179+
}
180+
181+
return vcap_tc_flower_handler_vlan_usage(st, vid_key, pcp_key);
121182
}
122183

123184
static int
@@ -128,6 +189,7 @@ static int
128189
[FLOW_DISSECTOR_KEY_CONTROL] = lan966x_tc_flower_handler_control_usage,
129190
[FLOW_DISSECTOR_KEY_PORTS] = vcap_tc_flower_handler_portnum_usage,
130191
[FLOW_DISSECTOR_KEY_BASIC] = lan966x_tc_flower_handler_basic_usage,
192+
[FLOW_DISSECTOR_KEY_CVLAN] = lan966x_tc_flower_handler_cvlan_usage,
131193
[FLOW_DISSECTOR_KEY_VLAN] = lan966x_tc_flower_handler_vlan_usage,
132194
[FLOW_DISSECTOR_KEY_TCP] = vcap_tc_flower_handler_tcp_usage,
133195
[FLOW_DISSECTOR_KEY_ARP] = vcap_tc_flower_handler_arp_usage,
@@ -143,6 +205,7 @@ static int lan966x_tc_flower_use_dissectors(struct flow_cls_offload *f,
143205
.fco = f,
144206
.vrule = vrule,
145207
.l3_proto = ETH_P_ALL,
208+
.admin = admin,
146209
};
147210
int err = 0;
148211

@@ -221,6 +284,31 @@ static int lan966x_tc_flower_action_check(struct vcap_control *vctrl,
221284
return 0;
222285
}
223286

287+
/* Add the actionset that is the default for the VCAP type */
288+
static int lan966x_tc_set_actionset(struct vcap_admin *admin,
289+
struct vcap_rule *vrule)
290+
{
291+
enum vcap_actionfield_set aset;
292+
int err = 0;
293+
294+
switch (admin->vtype) {
295+
case VCAP_TYPE_IS1:
296+
aset = VCAP_AFS_S1;
297+
break;
298+
case VCAP_TYPE_IS2:
299+
aset = VCAP_AFS_BASE_TYPE;
300+
break;
301+
default:
302+
return -EINVAL;
303+
}
304+
305+
/* Do not overwrite any current actionset */
306+
if (vrule->actionset == VCAP_AFS_NO_VALUE)
307+
err = vcap_set_rule_set_actionset(vrule, aset);
308+
309+
return err;
310+
}
311+
224312
static int lan966x_tc_flower_add(struct lan966x_port *port,
225313
struct flow_cls_offload *f,
226314
struct vcap_admin *admin,
@@ -253,6 +341,13 @@ static int lan966x_tc_flower_add(struct lan966x_port *port,
253341
flow_action_for_each(idx, act, &frule->action) {
254342
switch (act->id) {
255343
case FLOW_ACTION_TRAP:
344+
if (admin->vtype != VCAP_TYPE_IS2) {
345+
NL_SET_ERR_MSG_MOD(f->common.extack,
346+
"Trap action not supported in this VCAP");
347+
err = -EOPNOTSUPP;
348+
goto out;
349+
}
350+
256351
err = vcap_rule_add_action_bit(vrule,
257352
VCAP_AF_CPU_COPY_ENA,
258353
VCAP_BIT_1);
@@ -266,6 +361,10 @@ static int lan966x_tc_flower_add(struct lan966x_port *port,
266361

267362
break;
268363
case FLOW_ACTION_GOTO:
364+
err = lan966x_tc_set_actionset(admin, vrule);
365+
if (err)
366+
goto out;
367+
269368
break;
270369
default:
271370
NL_SET_ERR_MSG_MOD(f->common.extack,

0 commit comments

Comments
 (0)