Commit c73c8a8e authored by David S. Miller's avatar David S. Miller

Merge branch 'nfp-flow-dissector-layer'

Pieter Jansen van Vuuren says:

====================
nfp: fix layer calculation and flow dissector use

Previously when calculating the supported key layers MPLS, IPv4/6
TTL and TOS were not considered. Formerly flow dissectors were referenced
without first checking that they are in use and correctly populated by TC.
Additionally this patch set fixes the incorrect use of mask field for vlan
matching.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 77146b5d 6afd33e4
...@@ -42,33 +42,29 @@ nfp_flower_compile_meta_tci(struct nfp_flower_meta_two *frame, ...@@ -42,33 +42,29 @@ nfp_flower_compile_meta_tci(struct nfp_flower_meta_two *frame,
struct tc_cls_flower_offload *flow, u8 key_type, struct tc_cls_flower_offload *flow, u8 key_type,
bool mask_version) bool mask_version)
{ {
struct fl_flow_key *target = mask_version ? flow->mask : flow->key;
struct flow_dissector_key_vlan *flow_vlan; struct flow_dissector_key_vlan *flow_vlan;
u16 tmp_tci; u16 tmp_tci;
memset(frame, 0, sizeof(struct nfp_flower_meta_two));
/* Populate the metadata frame. */ /* Populate the metadata frame. */
frame->nfp_flow_key_layer = key_type; frame->nfp_flow_key_layer = key_type;
frame->mask_id = ~0; frame->mask_id = ~0;
if (mask_version) { if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_VLAN)) {
frame->tci = cpu_to_be16(~0); flow_vlan = skb_flow_dissector_target(flow->dissector,
return; FLOW_DISSECTOR_KEY_VLAN,
} target);
/* Populate the tci field. */
flow_vlan = skb_flow_dissector_target(flow->dissector, if (flow_vlan->vlan_id) {
FLOW_DISSECTOR_KEY_VLAN, tmp_tci = FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO,
flow->key); flow_vlan->vlan_priority) |
FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID,
/* Populate the tci field. */ flow_vlan->vlan_id) |
if (!flow_vlan->vlan_id) { NFP_FLOWER_MASK_VLAN_CFI;
tmp_tci = 0; frame->tci = cpu_to_be16(tmp_tci);
} else { }
tmp_tci = FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO,
flow_vlan->vlan_priority) |
FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID,
flow_vlan->vlan_id) |
NFP_FLOWER_MASK_VLAN_CFI;
} }
frame->tci = cpu_to_be16(tmp_tci);
} }
static void static void
...@@ -99,17 +95,18 @@ nfp_flower_compile_mac(struct nfp_flower_mac_mpls *frame, ...@@ -99,17 +95,18 @@ nfp_flower_compile_mac(struct nfp_flower_mac_mpls *frame,
bool mask_version) bool mask_version)
{ {
struct fl_flow_key *target = mask_version ? flow->mask : flow->key; struct fl_flow_key *target = mask_version ? flow->mask : flow->key;
struct flow_dissector_key_eth_addrs *flow_mac; struct flow_dissector_key_eth_addrs *addr;
flow_mac = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_ETH_ADDRS,
target);
memset(frame, 0, sizeof(struct nfp_flower_mac_mpls)); memset(frame, 0, sizeof(struct nfp_flower_mac_mpls));
/* Populate mac frame. */ if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
ether_addr_copy(frame->mac_dst, &flow_mac->dst[0]); addr = skb_flow_dissector_target(flow->dissector,
ether_addr_copy(frame->mac_src, &flow_mac->src[0]); FLOW_DISSECTOR_KEY_ETH_ADDRS,
target);
/* Populate mac frame. */
ether_addr_copy(frame->mac_dst, &addr->dst[0]);
ether_addr_copy(frame->mac_src, &addr->src[0]);
}
if (mask_version) if (mask_version)
frame->mpls_lse = cpu_to_be32(~0); frame->mpls_lse = cpu_to_be32(~0);
...@@ -121,14 +118,17 @@ nfp_flower_compile_tport(struct nfp_flower_tp_ports *frame, ...@@ -121,14 +118,17 @@ nfp_flower_compile_tport(struct nfp_flower_tp_ports *frame,
bool mask_version) bool mask_version)
{ {
struct fl_flow_key *target = mask_version ? flow->mask : flow->key; struct fl_flow_key *target = mask_version ? flow->mask : flow->key;
struct flow_dissector_key_ports *flow_tp; struct flow_dissector_key_ports *tp;
flow_tp = skb_flow_dissector_target(flow->dissector, memset(frame, 0, sizeof(struct nfp_flower_tp_ports));
FLOW_DISSECTOR_KEY_PORTS,
target);
frame->port_src = flow_tp->src; if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_PORTS)) {
frame->port_dst = flow_tp->dst; tp = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_PORTS,
target);
frame->port_src = tp->src;
frame->port_dst = tp->dst;
}
} }
static void static void
...@@ -137,25 +137,27 @@ nfp_flower_compile_ipv4(struct nfp_flower_ipv4 *frame, ...@@ -137,25 +137,27 @@ nfp_flower_compile_ipv4(struct nfp_flower_ipv4 *frame,
bool mask_version) bool mask_version)
{ {
struct fl_flow_key *target = mask_version ? flow->mask : flow->key; struct fl_flow_key *target = mask_version ? flow->mask : flow->key;
struct flow_dissector_key_ipv4_addrs *flow_ipv4; struct flow_dissector_key_ipv4_addrs *addr;
struct flow_dissector_key_basic *flow_basic; struct flow_dissector_key_basic *basic;
flow_ipv4 = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_IPV4_ADDRS,
target);
flow_basic = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_BASIC,
target);
/* Populate IPv4 frame. */
frame->reserved = 0;
frame->ipv4_src = flow_ipv4->src;
frame->ipv4_dst = flow_ipv4->dst;
frame->proto = flow_basic->ip_proto;
/* Wildcard TOS/TTL for now. */ /* Wildcard TOS/TTL for now. */
frame->tos = 0; memset(frame, 0, sizeof(struct nfp_flower_ipv4));
frame->ttl = 0;
if (dissector_uses_key(flow->dissector,
FLOW_DISSECTOR_KEY_IPV4_ADDRS)) {
addr = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_IPV4_ADDRS,
target);
frame->ipv4_src = addr->src;
frame->ipv4_dst = addr->dst;
}
if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_BASIC)) {
basic = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_BASIC,
target);
frame->proto = basic->ip_proto;
}
} }
static void static void
...@@ -164,26 +166,27 @@ nfp_flower_compile_ipv6(struct nfp_flower_ipv6 *frame, ...@@ -164,26 +166,27 @@ nfp_flower_compile_ipv6(struct nfp_flower_ipv6 *frame,
bool mask_version) bool mask_version)
{ {
struct fl_flow_key *target = mask_version ? flow->mask : flow->key; struct fl_flow_key *target = mask_version ? flow->mask : flow->key;
struct flow_dissector_key_ipv6_addrs *flow_ipv6; struct flow_dissector_key_ipv6_addrs *addr;
struct flow_dissector_key_basic *flow_basic; struct flow_dissector_key_basic *basic;
flow_ipv6 = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_IPV6_ADDRS,
target);
flow_basic = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_BASIC,
target);
/* Populate IPv6 frame. */
frame->reserved = 0;
frame->ipv6_src = flow_ipv6->src;
frame->ipv6_dst = flow_ipv6->dst;
frame->proto = flow_basic->ip_proto;
/* Wildcard LABEL/TOS/TTL for now. */ /* Wildcard LABEL/TOS/TTL for now. */
frame->ipv6_flow_label_exthdr = 0; memset(frame, 0, sizeof(struct nfp_flower_ipv6));
frame->tos = 0;
frame->ttl = 0; if (dissector_uses_key(flow->dissector,
FLOW_DISSECTOR_KEY_IPV6_ADDRS)) {
addr = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_IPV6_ADDRS,
target);
frame->ipv6_src = addr->src;
frame->ipv6_dst = addr->dst;
}
if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_BASIC)) {
basic = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_BASIC,
target);
frame->proto = basic->ip_proto;
}
} }
int nfp_flower_compile_flow_match(struct tc_cls_flower_offload *flow, int nfp_flower_compile_flow_match(struct tc_cls_flower_offload *flow,
......
...@@ -105,43 +105,62 @@ static int ...@@ -105,43 +105,62 @@ static int
nfp_flower_calculate_key_layers(struct nfp_fl_key_ls *ret_key_ls, nfp_flower_calculate_key_layers(struct nfp_fl_key_ls *ret_key_ls,
struct tc_cls_flower_offload *flow) struct tc_cls_flower_offload *flow)
{ {
struct flow_dissector_key_control *mask_enc_ctl; struct flow_dissector_key_basic *mask_basic = NULL;
struct flow_dissector_key_basic *mask_basic; struct flow_dissector_key_basic *key_basic = NULL;
struct flow_dissector_key_basic *key_basic; struct flow_dissector_key_ip *mask_ip = NULL;
u32 key_layer_two; u32 key_layer_two;
u8 key_layer; u8 key_layer;
int key_size; int key_size;
mask_enc_ctl = skb_flow_dissector_target(flow->dissector, if (dissector_uses_key(flow->dissector,
FLOW_DISSECTOR_KEY_ENC_CONTROL, FLOW_DISSECTOR_KEY_ENC_CONTROL)) {
flow->mask); struct flow_dissector_key_control *mask_enc_ctl =
skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_ENC_CONTROL,
flow->mask);
/* We are expecting a tunnel. For now we ignore offloading. */
if (mask_enc_ctl->addr_type)
return -EOPNOTSUPP;
}
mask_basic = skb_flow_dissector_target(flow->dissector, if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_BASIC)) {
FLOW_DISSECTOR_KEY_BASIC, mask_basic = skb_flow_dissector_target(flow->dissector,
flow->mask); FLOW_DISSECTOR_KEY_BASIC,
flow->mask);
key_basic = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_BASIC,
flow->key);
}
if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_IP))
mask_ip = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_IP,
flow->mask);
key_basic = skb_flow_dissector_target(flow->dissector,
FLOW_DISSECTOR_KEY_BASIC,
flow->key);
key_layer_two = 0; key_layer_two = 0;
key_layer = NFP_FLOWER_LAYER_PORT | NFP_FLOWER_LAYER_MAC; key_layer = NFP_FLOWER_LAYER_PORT | NFP_FLOWER_LAYER_MAC;
key_size = sizeof(struct nfp_flower_meta_one) + key_size = sizeof(struct nfp_flower_meta_one) +
sizeof(struct nfp_flower_in_port) + sizeof(struct nfp_flower_in_port) +
sizeof(struct nfp_flower_mac_mpls); sizeof(struct nfp_flower_mac_mpls);
/* We are expecting a tunnel. For now we ignore offloading. */ if (mask_basic && mask_basic->n_proto) {
if (mask_enc_ctl->addr_type)
return -EOPNOTSUPP;
if (mask_basic->n_proto) {
/* Ethernet type is present in the key. */ /* Ethernet type is present in the key. */
switch (key_basic->n_proto) { switch (key_basic->n_proto) {
case cpu_to_be16(ETH_P_IP): case cpu_to_be16(ETH_P_IP):
if (mask_ip && mask_ip->tos)
return -EOPNOTSUPP;
if (mask_ip && mask_ip->ttl)
return -EOPNOTSUPP;
key_layer |= NFP_FLOWER_LAYER_IPV4; key_layer |= NFP_FLOWER_LAYER_IPV4;
key_size += sizeof(struct nfp_flower_ipv4); key_size += sizeof(struct nfp_flower_ipv4);
break; break;
case cpu_to_be16(ETH_P_IPV6): case cpu_to_be16(ETH_P_IPV6):
if (mask_ip && mask_ip->tos)
return -EOPNOTSUPP;
if (mask_ip && mask_ip->ttl)
return -EOPNOTSUPP;
key_layer |= NFP_FLOWER_LAYER_IPV6; key_layer |= NFP_FLOWER_LAYER_IPV6;
key_size += sizeof(struct nfp_flower_ipv6); key_size += sizeof(struct nfp_flower_ipv6);
break; break;
...@@ -152,6 +171,11 @@ nfp_flower_calculate_key_layers(struct nfp_fl_key_ls *ret_key_ls, ...@@ -152,6 +171,11 @@ nfp_flower_calculate_key_layers(struct nfp_fl_key_ls *ret_key_ls,
case cpu_to_be16(ETH_P_ARP): case cpu_to_be16(ETH_P_ARP):
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* Currently we do not offload MPLS. */
case cpu_to_be16(ETH_P_MPLS_UC):
case cpu_to_be16(ETH_P_MPLS_MC):
return -EOPNOTSUPP;
/* Will be included in layer 2. */ /* Will be included in layer 2. */
case cpu_to_be16(ETH_P_8021Q): case cpu_to_be16(ETH_P_8021Q):
break; break;
...@@ -166,7 +190,7 @@ nfp_flower_calculate_key_layers(struct nfp_fl_key_ls *ret_key_ls, ...@@ -166,7 +190,7 @@ nfp_flower_calculate_key_layers(struct nfp_fl_key_ls *ret_key_ls,
} }
} }
if (mask_basic->ip_proto) { if (mask_basic && mask_basic->ip_proto) {
/* Ethernet type is present in the key. */ /* Ethernet type is present in the key. */
switch (key_basic->ip_proto) { switch (key_basic->ip_proto) {
case IPPROTO_TCP: case IPPROTO_TCP:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment