During the transition to resurrect flow director on top of rte_flow, mask handling was removed by mistake.
Fixes: 4c3e9bcdd52e ("net/mlx5: support flow director") Cc: sta...@dpdk.org Signed-off-by: Nelio Laranjeiro <nelio.laranje...@6wind.com> Acked-by: Adrien Mazarguil <adrien.mazarg...@6wind.com> --- drivers/net/mlx5/mlx5_flow.c | 59 ++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 7ba643b83..5e75afa7f 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2661,6 +2661,9 @@ mlx5_fdir_filter_convert(struct rte_eth_dev *dev, { struct priv *priv = dev->data->dev_private; const struct rte_eth_fdir_input *input = &fdir_filter->input; + const struct rte_eth_fdir_masks *mask = + &dev->data->dev_conf.fdir_conf.mask; + unsigned int i; /* Validate queue number. */ if (fdir_filter->action.rx_queue >= priv->rxqs_n) { @@ -2701,11 +2704,16 @@ mlx5_fdir_filter_convert(struct rte_eth_dev *dev, case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: attributes->l3.ipv4.hdr = (struct ipv4_hdr){ - .src_addr = input->flow.udp4_flow.ip.src_ip, - .dst_addr = input->flow.udp4_flow.ip.dst_ip, - .time_to_live = input->flow.udp4_flow.ip.ttl, - .type_of_service = input->flow.udp4_flow.ip.tos, - .next_proto_id = input->flow.udp4_flow.ip.proto, + .src_addr = input->flow.udp4_flow.ip.src_ip & + mask->ipv4_mask.src_ip, + .dst_addr = input->flow.udp4_flow.ip.dst_ip & + mask->ipv4_mask.dst_ip, + .time_to_live = input->flow.udp4_flow.ip.ttl & + mask->ipv4_mask.ttl, + .type_of_service = input->flow.udp4_flow.ip.tos & + mask->ipv4_mask.ttl, + .next_proto_id = input->flow.udp4_flow.ip.proto & + mask->ipv4_mask.proto, }; attributes->items[1] = (struct rte_flow_item){ .type = RTE_FLOW_ITEM_TYPE_IPV4, @@ -2720,12 +2728,17 @@ mlx5_fdir_filter_convert(struct rte_eth_dev *dev, .hop_limits = input->flow.udp6_flow.ip.hop_limits, .proto = input->flow.udp6_flow.ip.proto, }; - memcpy(attributes->l3.ipv6.hdr.src_addr, - input->flow.udp6_flow.ip.src_ip, - RTE_DIM(attributes->l3.ipv6.hdr.src_addr)); - memcpy(attributes->l3.ipv6.hdr.dst_addr, - input->flow.udp6_flow.ip.dst_ip, - RTE_DIM(attributes->l3.ipv6.hdr.src_addr)); + + for (i = 0; + i != RTE_DIM(attributes->l3.ipv6.hdr.src_addr); + ++i) { + attributes->l3.ipv6.hdr.src_addr[i] = + input->flow.udp6_flow.ip.src_ip[i] & + mask->ipv6_mask.src_ip[i]; + attributes->l3.ipv6.hdr.dst_addr[i] = + input->flow.udp6_flow.ip.dst_ip[i] & + mask->ipv6_mask.dst_ip[i]; + } attributes->items[1] = (struct rte_flow_item){ .type = RTE_FLOW_ITEM_TYPE_IPV6, .spec = &attributes->l3, @@ -2742,8 +2755,10 @@ mlx5_fdir_filter_convert(struct rte_eth_dev *dev, switch (fdir_filter->input.flow_type) { case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: attributes->l4.udp.hdr = (struct udp_hdr){ - .src_port = input->flow.udp4_flow.src_port, - .dst_port = input->flow.udp4_flow.dst_port, + .src_port = input->flow.udp4_flow.src_port & + mask->src_port_mask, + .dst_port = input->flow.udp4_flow.dst_port & + mask->dst_port_mask, }; attributes->items[2] = (struct rte_flow_item){ .type = RTE_FLOW_ITEM_TYPE_UDP, @@ -2753,8 +2768,10 @@ mlx5_fdir_filter_convert(struct rte_eth_dev *dev, break; case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: attributes->l4.tcp.hdr = (struct tcp_hdr){ - .src_port = input->flow.tcp4_flow.src_port, - .dst_port = input->flow.tcp4_flow.dst_port, + .src_port = input->flow.tcp4_flow.src_port & + mask->src_port_mask, + .dst_port = input->flow.tcp4_flow.dst_port & + mask->dst_port_mask, }; attributes->items[2] = (struct rte_flow_item){ .type = RTE_FLOW_ITEM_TYPE_TCP, @@ -2764,8 +2781,10 @@ mlx5_fdir_filter_convert(struct rte_eth_dev *dev, break; case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: attributes->l4.udp.hdr = (struct udp_hdr){ - .src_port = input->flow.udp6_flow.src_port, - .dst_port = input->flow.udp6_flow.dst_port, + .src_port = input->flow.udp6_flow.src_port & + mask->src_port_mask, + .dst_port = input->flow.udp6_flow.dst_port & + mask->dst_port_mask, }; attributes->items[2] = (struct rte_flow_item){ .type = RTE_FLOW_ITEM_TYPE_UDP, @@ -2775,8 +2794,10 @@ mlx5_fdir_filter_convert(struct rte_eth_dev *dev, break; case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: attributes->l4.tcp.hdr = (struct tcp_hdr){ - .src_port = input->flow.tcp6_flow.src_port, - .dst_port = input->flow.tcp6_flow.dst_port, + .src_port = input->flow.tcp6_flow.src_port & + mask->src_port_mask, + .dst_port = input->flow.tcp6_flow.dst_port & + mask->dst_port_mask, }; attributes->items[2] = (struct rte_flow_item){ .type = RTE_FLOW_ITEM_TYPE_TCP, -- 2.17.0