Skip to content

Commit cf2885a

Browse files
Kumar Sanghvidavem330
authored andcommitted
cxgb4: add support to offload action vlan
Add support for offloading tc-flower flows having vlan actions: pop, push and modify. Signed-off-by: Kumar Sanghvi <kumaras@chelsio.com> Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com> Signed-off-by: Ganesh Goudar <ganeshgr@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 62488e4 commit cf2885a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include <net/tc_act/tc_gact.h>
3636
#include <net/tc_act/tc_mirred.h>
37+
#include <net/tc_act/tc_vlan.h>
3738

3839
#include "cxgb4.h"
3940
#include "cxgb4_tc_flower.h"
@@ -185,6 +186,27 @@ static void cxgb4_process_flow_actions(struct net_device *in,
185186

186187
fs->action = FILTER_SWITCH;
187188
fs->eport = pi->port_id;
189+
} else if (is_tcf_vlan(a)) {
190+
u32 vlan_action = tcf_vlan_action(a);
191+
u8 prio = tcf_vlan_push_prio(a);
192+
u16 vid = tcf_vlan_push_vid(a);
193+
u16 vlan_tci = (prio << VLAN_PRIO_SHIFT) | vid;
194+
195+
switch (vlan_action) {
196+
case TCA_VLAN_ACT_POP:
197+
fs->newvlan |= VLAN_REMOVE;
198+
break;
199+
case TCA_VLAN_ACT_PUSH:
200+
fs->newvlan |= VLAN_INSERT;
201+
fs->vlan = vlan_tci;
202+
break;
203+
case TCA_VLAN_ACT_MODIFY:
204+
fs->newvlan |= VLAN_REWRITE;
205+
fs->vlan = vlan_tci;
206+
break;
207+
default:
208+
break;
209+
}
188210
}
189211
}
190212
}
@@ -222,6 +244,26 @@ static int cxgb4_validate_flow_actions(struct net_device *dev,
222244
__func__);
223245
return -EINVAL;
224246
}
247+
} else if (is_tcf_vlan(a)) {
248+
u16 proto = be16_to_cpu(tcf_vlan_push_proto(a));
249+
u32 vlan_action = tcf_vlan_action(a);
250+
251+
switch (vlan_action) {
252+
case TCA_VLAN_ACT_POP:
253+
break;
254+
case TCA_VLAN_ACT_PUSH:
255+
case TCA_VLAN_ACT_MODIFY:
256+
if (proto != ETH_P_8021Q) {
257+
netdev_err(dev, "%s: Unsupported vlan proto\n",
258+
__func__);
259+
return -EOPNOTSUPP;
260+
}
261+
break;
262+
default:
263+
netdev_err(dev, "%s: Unsupported vlan action\n",
264+
__func__);
265+
return -EOPNOTSUPP;
266+
}
225267
} else {
226268
netdev_err(dev, "%s: Unsupported action\n", __func__);
227269
return -EOPNOTSUPP;

0 commit comments

Comments
 (0)