[PATCH] net/nfp: fix the VLAN push flow action

Chaoyong He chaoyong.he at corigine.com
Fri May 12 04:03:46 CEST 2023


When process VLAN push flow action, the former logic perform the
mask and shift operations directly on the big endian data, which
cause both the pcp and VLAN id are not correct for offloaded packets.

Fix it by convert the data from big endian to CPU endian before
perform the mask and shift operations.

Fixes: eb9277cb2fd1 ("net/nfp: support VLAN push flow action")
Cc: stable at dpdk.org

Signed-off-by: Chaoyong He <chaoyong.he at corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund at corigine.com>
---
 drivers/net/nfp/nfp_flow.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 41b722f4d8..fdf5c0f40e 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -2205,6 +2205,8 @@ static int
 nfp_flow_action_push_vlan(char *act_data,
 		const struct rte_flow_action *action)
 {
+	uint8_t pcp;
+	uint16_t vid;
 	size_t act_size;
 	struct nfp_fl_act_push_vlan *push_vlan;
 	const struct rte_flow_action_of_push_vlan *push_vlan_conf;
@@ -2227,9 +2229,11 @@ nfp_flow_action_push_vlan(char *act_data,
 			(action + 1)->conf;
 	vlan_vid_conf  = (const struct rte_flow_action_of_set_vlan_vid *)
 			(action + 2)->conf;
+
+	vid = rte_be_to_cpu_16(vlan_vid_conf->vlan_vid) & 0x0fff;
+	pcp = vlan_pcp_conf->vlan_pcp & 0x07;
 	push_vlan->vlan_tpid = push_vlan_conf->ethertype;
-	push_vlan->vlan_tci = ((vlan_pcp_conf->vlan_pcp & 0x07) << 13) |
-			(vlan_vid_conf->vlan_vid & 0x0fff);
+	push_vlan->vlan_tci = rte_cpu_to_be_16(vid | (pcp << 13));
 
 	return 0;
 }
-- 
2.39.1



More information about the stable mailing list