From 7147c01a49a0020b62608ab6605cae421a773685 Mon Sep 17 00:00:00 2001 From: Jiawen Wu Date: Fri, 2 Sep 2022 11:00:03 +0800 Subject: [PATCH] net/txgbe: fix IPv6 flow rule Convert the correct packet type and flow type, to fix IPv6 rule in FDIR. Fixes: b973ee26747a ("net/txgbe: parse flow director filter") Cc: stable@dpdk.org Signed-off-by: Jiawen Wu --- drivers/net/txgbe/txgbe_flow.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/drivers/net/txgbe/txgbe_flow.c b/drivers/net/txgbe/txgbe_flow.c index 9288af05b2..7b18dca7e8 100644 --- a/drivers/net/txgbe/txgbe_flow.c +++ b/drivers/net/txgbe/txgbe_flow.c @@ -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 @@ -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, @@ -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, @@ -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, @@ -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); } @@ -2834,8 +2851,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)