From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Long Wu <long.wu@corigine.com>,
Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 5/5] net/nfp: use big-endian meta data for packet
Date: Tue, 5 Mar 2024 10:29:23 +0800 [thread overview]
Message-ID: <20240305022923.891544-6-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240305022923.891544-1-chaoyong.he@corigine.com>
From: Long Wu <long.wu@corigine.com>
Make sure all kinds of meta data are CPU-endian in process logic and
transform them to big-endian when prepend into packet.
Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 5 ++---
drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 5 ++---
drivers/net/nfp/nfp_net_meta.c | 2 +-
3 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index 7e281ae498..253872f4a1 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -181,9 +181,8 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
return 0;
meta_info = meta_data->header;
- meta_data->header = rte_cpu_to_be_32(meta_data->header);
meta = rte_pktmbuf_prepend(pkt, meta_data->length);
- memcpy(meta, &meta_data->header, sizeof(meta_data->header));
+ *(rte_be32_t *)meta = rte_cpu_to_be_32(meta_data->header);
meta += NFP_NET_META_HEADER_SIZE;
for (; meta_info != 0; meta_info >>= NFP_NET_META_FIELD_SIZE, layer++,
@@ -211,7 +210,7 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
return -ENOTSUP;
}
- memcpy(meta, &meta_data->data[layer], sizeof(meta_data->data[layer]));
+ *(rte_be32_t *)meta = rte_cpu_to_be_32(meta_data->data[layer]);
}
return 0;
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index b8592b1767..1911736e2b 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -215,9 +215,8 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
meta_type = meta_data.header;
header_offset = meta_type << NFP_NET_META_NFDK_LENGTH;
meta_data.header = header_offset | meta_data.length;
- meta_data.header = rte_cpu_to_be_32(meta_data.header);
meta = rte_pktmbuf_prepend(pkt, meta_data.length);
- memcpy(meta, &meta_data.header, sizeof(meta_data.header));
+ *(rte_be32_t *)meta = rte_cpu_to_be_32(meta_data.header);
meta += NFP_NET_META_HEADER_SIZE;
for (; meta_type != 0; meta_type >>= NFP_NET_META_FIELD_SIZE, layer++,
@@ -245,7 +244,7 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
return -ENOTSUP;
}
- memcpy(meta, &meta_data.data[layer], sizeof(meta_data.data[layer]));
+ *(rte_be32_t *)meta = rte_cpu_to_be_32(meta_data.data[layer]);
}
*metadata = NFDK_DESC_TX_CHAIN_META;
diff --git a/drivers/net/nfp/nfp_net_meta.c b/drivers/net/nfp/nfp_net_meta.c
index b39c55a868..fa7e0d3d00 100644
--- a/drivers/net/nfp/nfp_net_meta.c
+++ b/drivers/net/nfp/nfp_net_meta.c
@@ -300,7 +300,7 @@ nfp_net_meta_set_vlan(struct nfp_net_meta_raw *meta_data,
tpid = RTE_ETHER_TYPE_VLAN;
vlan_tci = pkt->vlan_tci;
- meta_data->data[layer] = rte_cpu_to_be_32(tpid << 16 | vlan_tci);
+ meta_data->data[layer] = tpid << 16 | vlan_tci;
}
void
--
2.39.1
next prev parent reply other threads:[~2024-03-05 2:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 2:29 [PATCH 0/5] add new meta data module Chaoyong He
2024-03-05 2:29 ` [PATCH 1/5] net/nfp: create " Chaoyong He
2024-03-05 2:29 ` [PATCH 2/5] net/nfp: uniform variable name format Chaoyong He
2024-03-05 2:29 ` [PATCH 3/5] net/nfp: uniform function " Chaoyong He
2024-03-05 2:29 ` [PATCH 4/5] net/nfp: use flag bits to control parsing meta data Chaoyong He
2024-03-05 2:29 ` Chaoyong He [this message]
2024-03-12 12:05 ` [PATCH 0/5] add new meta data module Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240305022923.891544-6-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=long.wu@corigine.com \
--cc=oss-drivers@corigine.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).