Skip to content

Commit

Permalink
net/txgbe: fix IPv6 flow rule
Browse files Browse the repository at this point in the history
[ upstream commit 7147c01 ]

Convert the correct packet type and flow type, to fix IPv6 rule in FDIR.

Fixes: b973ee2 ("net/txgbe: parse flow director filter")

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
  • Loading branch information
Jiawen Wu authored and kevintraynor committed Oct 11, 2022
1 parent f1810ce commit d47522b
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions drivers/net/txgbe/txgbe_flow.c
Expand Up @@ -1583,9 +1583,7 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
* value. So, we need not do anything for the not provided fields later.
*/
memset(rule, 0, sizeof(struct txgbe_fdir_rule));
memset(&rule->mask, 0xFF, sizeof(struct txgbe_hw_fdir_mask));
rule->mask.vlan_tci_mask = 0;
rule->mask.flex_bytes_mask = 0;
memset(&rule->mask, 0, sizeof(struct txgbe_hw_fdir_mask));

/**
* The first not void item should be
Expand Down Expand Up @@ -1867,7 +1865,10 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
* as we must have a flow type.
*/
rule->input.flow_type |= TXGBE_ATR_L4TYPE_TCP;
ptype = txgbe_ptype_table[TXGBE_PT_IPV4_TCP];
if (rule->input.flow_type & TXGBE_ATR_FLOW_TYPE_IPV6)
ptype = txgbe_ptype_table[TXGBE_PT_IPV6_TCP];
else
ptype = txgbe_ptype_table[TXGBE_PT_IPV4_TCP];
/*Not supported last point for range*/
if (item->last) {
rte_flow_error_set(error, EINVAL,
Expand Down Expand Up @@ -1931,7 +1932,10 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
* as we must have a flow type.
*/
rule->input.flow_type |= TXGBE_ATR_L4TYPE_UDP;
ptype = txgbe_ptype_table[TXGBE_PT_IPV4_UDP];
if (rule->input.flow_type & TXGBE_ATR_FLOW_TYPE_IPV6)
ptype = txgbe_ptype_table[TXGBE_PT_IPV6_UDP];
else
ptype = txgbe_ptype_table[TXGBE_PT_IPV4_UDP];
/*Not supported last point for range*/
if (item->last) {
rte_flow_error_set(error, EINVAL,
Expand Down Expand Up @@ -1990,7 +1994,10 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
* as we must have a flow type.
*/
rule->input.flow_type |= TXGBE_ATR_L4TYPE_SCTP;
ptype = txgbe_ptype_table[TXGBE_PT_IPV4_SCTP];
if (rule->input.flow_type & TXGBE_ATR_FLOW_TYPE_IPV6)
ptype = txgbe_ptype_table[TXGBE_PT_IPV6_SCTP];
else
ptype = txgbe_ptype_table[TXGBE_PT_IPV4_SCTP];
/*Not supported last point for range*/
if (item->last) {
rte_flow_error_set(error, EINVAL,
Expand Down Expand Up @@ -2141,6 +2148,16 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,

rule->input.pkt_type = cpu_to_be16(txgbe_encode_ptype(ptype));

if (rule->input.flow_type & TXGBE_ATR_FLOW_TYPE_IPV6) {
if (rule->input.flow_type & TXGBE_ATR_L4TYPE_MASK)
rule->input.pkt_type &= 0xFFFF;
else
rule->input.pkt_type &= 0xF8FF;

rule->input.flow_type &= TXGBE_ATR_L3TYPE_MASK |
TXGBE_ATR_L4TYPE_MASK;
}

return txgbe_parse_fdir_act_attr(attr, actions, rule, error);
}

Expand Down Expand Up @@ -2827,8 +2844,10 @@ txgbe_flow_create(struct rte_eth_dev *dev,
ret = memcmp(&fdir_info->mask,
&fdir_rule.mask,
sizeof(struct txgbe_hw_fdir_mask));
if (ret)
if (ret) {
PMD_DRV_LOG(ERR, "only support one global mask");
goto out;
}

if (fdir_info->flex_bytes_offset !=
fdir_rule.flex_bytes_offset)
Expand Down

0 comments on commit d47522b

Please sign in to comment.