DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/nfp: fix the VLAN push flow action
@ 2023-05-12  2:03 Chaoyong He
  2023-05-18 10:12 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: Chaoyong He @ 2023-05-12  2:03 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He, stable

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@dpdk.org

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-18 10:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-12  2:03 [PATCH] net/nfp: fix the VLAN push flow action Chaoyong He
2023-05-18 10:12 ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).