Currently, handling of ntuple filter priority is incorrect: it directly
translates values inside the valid range (001b-111b), and clamps all
invalid to 1. This leads to equivalence between rte_flow highest priority
value (0), and rte_flow lower priority values (8+), both of which are
mapped to 1 (lowest priority), while the 1-7 range is reversed (in ntuple,
111b is highest priority, but in rte_flow it is the lowest).
Fix the calculation by
- Translating highest rte_flow priority to highest ntuple priority
- Only clamping low priority values to 1 (lowest priority)
- Reversing the 1-7 mapping to preserve semantic meaning
Fixes: 672be56d76a2 ("net/ixgbe: parse n-tuple filter")
Cc: [email protected]
Signed-off-by: Anatoly Burakov <[email protected]>
---
drivers/net/intel/ixgbe/ixgbe_flow.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/net/intel/ixgbe/ixgbe_flow.c
b/drivers/net/intel/ixgbe/ixgbe_flow.c
index 76eec33839b..547c6621d3e 100644
--- a/drivers/net/intel/ixgbe/ixgbe_flow.c
+++ b/drivers/net/intel/ixgbe/ixgbe_flow.c
@@ -209,6 +209,7 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
const struct rte_flow_item_vlan *vlan_mask;
struct rte_flow_item_eth eth_null;
struct rte_flow_item_vlan vlan_null;
+ uint16_t priority;
/* Priority must be 16-bit */
if (attr->priority > UINT16_MAX) {
@@ -503,9 +504,21 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
filter->queue = q_act->index;
- filter->priority = (uint16_t)attr->priority;
- if (attr->priority < IXGBE_MIN_N_TUPLE_PRIO || attr->priority >
IXGBE_MAX_N_TUPLE_PRIO)
- filter->priority = 1;
+ /*
+ * rte_flow priority: 0 through UINT32_MAX, 0 is highest
+ *
+ * ntuple priority: 001b through 111b, 111b is highest
+ *
+ * which means we need to transform priority from rte_flow to ntuple:
+ *
+ * 1) clamp max value
+ * 2) reverse
+ * 3) add min value
+ */
+ priority = RTE_MIN(IXGBE_MAX_N_TUPLE_PRIO - 1,
(uint16_t)attr->priority);
+ priority = IXGBE_MAX_N_TUPLE_PRIO - 1 - priority;
+ priority += IXGBE_MIN_N_TUPLE_PRIO;
+ filter->priority = priority;
return 0;
}
--
2.52.0