Skip to content

Commit ad9af3e

Browse files
Kumar Sanghvidavem330
authored andcommitted
cxgb4: add tc flower match support for vlan
Add support for matching on vlan tci. Construct vlan tci match param based on vlan-id and vlan-pcp values supplied by tc. Signed-off-by: Kumar Sanghvi <[email protected]> Signed-off-by: Rahul Lakkireddy <[email protected]> Signed-off-by: Ganesh Goudar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bda1e22 commit ad9af3e

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,40 @@ static void cxgb4_process_flow_match(struct net_device *dev,
160160
fs->mask.tos = mask->tos;
161161
}
162162

163+
if (dissector_uses_key(cls->dissector, FLOW_DISSECTOR_KEY_VLAN)) {
164+
struct flow_dissector_key_vlan *key, *mask;
165+
u16 vlan_tci, vlan_tci_mask;
166+
167+
key = skb_flow_dissector_target(cls->dissector,
168+
FLOW_DISSECTOR_KEY_VLAN,
169+
cls->key);
170+
mask = skb_flow_dissector_target(cls->dissector,
171+
FLOW_DISSECTOR_KEY_VLAN,
172+
cls->mask);
173+
vlan_tci = key->vlan_id | (key->vlan_priority <<
174+
VLAN_PRIO_SHIFT);
175+
vlan_tci_mask = mask->vlan_id | (mask->vlan_priority <<
176+
VLAN_PRIO_SHIFT);
177+
fs->val.ivlan = cpu_to_be16(vlan_tci);
178+
fs->mask.ivlan = cpu_to_be16(vlan_tci_mask);
179+
180+
/* Chelsio adapters use ivlan_vld bit to match vlan packets
181+
* as 802.1Q. Also, when vlan tag is present in packets,
182+
* ethtype match is used then to match on ethtype of inner
183+
* header ie. the header following the vlan header.
184+
* So, set the ivlan_vld based on ethtype info supplied by
185+
* TC for vlan packets if its 802.1Q. And then reset the
186+
* ethtype value else, hw will try to match the supplied
187+
* ethtype value with ethtype of inner header.
188+
*/
189+
if (fs->val.ethtype == ETH_P_8021Q) {
190+
fs->val.ivlan_vld = 1;
191+
fs->mask.ivlan_vld = 1;
192+
fs->val.ethtype = 0;
193+
fs->mask.ethtype = 0;
194+
}
195+
}
196+
163197
/* Match only packets coming from the ingress port where this
164198
* filter will be created.
165199
*/
@@ -179,6 +213,7 @@ static int cxgb4_validate_flow_match(struct net_device *dev,
179213
BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS) |
180214
BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS) |
181215
BIT(FLOW_DISSECTOR_KEY_PORTS) |
216+
BIT(FLOW_DISSECTOR_KEY_VLAN) |
182217
BIT(FLOW_DISSECTOR_KEY_IP))) {
183218
netdev_warn(dev, "Unsupported key used: 0x%x\n",
184219
cls->dissector->used_keys);

0 commit comments

Comments
 (0)