Skip to content

Commit

Permalink
cxgb4: add tc flower match support for vlan
Browse files Browse the repository at this point in the history
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 <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>
  • Loading branch information
Kumar Sanghvi authored and David S. Miller committed Oct 20, 2017
1 parent bda1e22 commit ad9af3e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,40 @@ static void cxgb4_process_flow_match(struct net_device *dev,
fs->mask.tos = mask->tos;
}

if (dissector_uses_key(cls->dissector, FLOW_DISSECTOR_KEY_VLAN)) {
struct flow_dissector_key_vlan *key, *mask;
u16 vlan_tci, vlan_tci_mask;

key = skb_flow_dissector_target(cls->dissector,
FLOW_DISSECTOR_KEY_VLAN,
cls->key);
mask = skb_flow_dissector_target(cls->dissector,
FLOW_DISSECTOR_KEY_VLAN,
cls->mask);
vlan_tci = key->vlan_id | (key->vlan_priority <<
VLAN_PRIO_SHIFT);
vlan_tci_mask = mask->vlan_id | (mask->vlan_priority <<
VLAN_PRIO_SHIFT);
fs->val.ivlan = cpu_to_be16(vlan_tci);
fs->mask.ivlan = cpu_to_be16(vlan_tci_mask);

/* Chelsio adapters use ivlan_vld bit to match vlan packets
* as 802.1Q. Also, when vlan tag is present in packets,
* ethtype match is used then to match on ethtype of inner
* header ie. the header following the vlan header.
* So, set the ivlan_vld based on ethtype info supplied by
* TC for vlan packets if its 802.1Q. And then reset the
* ethtype value else, hw will try to match the supplied
* ethtype value with ethtype of inner header.
*/
if (fs->val.ethtype == ETH_P_8021Q) {
fs->val.ivlan_vld = 1;
fs->mask.ivlan_vld = 1;
fs->val.ethtype = 0;
fs->mask.ethtype = 0;
}
}

/* Match only packets coming from the ingress port where this
* filter will be created.
*/
Expand All @@ -179,6 +213,7 @@ static int cxgb4_validate_flow_match(struct net_device *dev,
BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS) |
BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS) |
BIT(FLOW_DISSECTOR_KEY_PORTS) |
BIT(FLOW_DISSECTOR_KEY_VLAN) |
BIT(FLOW_DISSECTOR_KEY_IP))) {
netdev_warn(dev, "Unsupported key used: 0x%x\n",
cls->dissector->used_keys);
Expand Down

0 comments on commit ad9af3e

Please sign in to comment.