net/cnxk: resolve mbuf data length update issue
PATCH 1/1 net/cnxk: resolve mbuf data length update issue
If multi-segment is enabled and single segment/packet is received, then mbuf data_len is not updated in cn9k_nix_cqe_to_mbuf function.
Also, in case of timestamp is enabled, mbuf data_len and pkt_len will be updated for all packets including multi segmented packets.
---
Depends-on: Series-21246 ("[v2,1/4] net/cnxk: avoid command copy from Tx queue")
drivers/event/cnxk/cn10k_worker.h | 2 -- drivers/event/cnxk/cn9k_worker.h | 2 -- drivers/net/cnxk/cn10k_rx.h | 9 +++++++-- drivers/net/cnxk/cn9k_rx.h | 18 +++++++++++------- drivers/net/cnxk/cnxk_ethdev.h | 9 +++------ 5 files changed, 21 insertions(+), 19 deletions(-)
drivers/event/cnxk/cn10k_worker.h +0 -2
@@ -174,7 +174,6 @@ cn10k_process_vwqe(uintptr_t vwqe, uint16_t port_id, const uint32_t flags, CNXK_SSO_WQE_SG_PTR);cnxk_nix_mbuf_to_tstamp ((struct rte_mbuf *)mbuf, tstamp, flags &NIX_RX_OFFLOAD_TSTAMP_F , - flags &NIX_RX_MULTI_SEG_F , (uint64_t *)tstamp_ptr); wqe[0 ] = (uint64_t *)mbuf; non_vec--;
@@ -266,7 +265,6 @@ cn10k_sso_hws_get_work(struct cn10k_sso_hws *ws, struct rte_event *ev,cnxk_nix_mbuf_to_tstamp ((struct rte_mbuf *)mbuf, ws->tstamp, flags &NIX_RX_OFFLOAD_TSTAMP_F , - flags &NIX_RX_MULTI_SEG_F , (uint64_t *)tstamp_ptr); gw.u64[1 ] = mbuf; } else if (CNXK_EVENT_TYPE_FROM_TAG(gw.u64[0]) ==
drivers/event/cnxk/cn9k_worker.h +0 -2
@@ -208,7 +208,6 @@ cn9k_sso_hws_dual_get_work(uint64_t base, uint64_t pair_base,cnxk_nix_mbuf_to_tstamp ((struct rte_mbuf *)mbuf, dws->tstamp, flags &NIX_RX_OFFLOAD_TSTAMP_F , - flags &NIX_RX_MULTI_SEG_F , (uint64_t *)tstamp_ptr); gw.u64[1 ] = mbuf; }
@@ -285,7 +284,6 @@ cn9k_sso_hws_get_work(struct cn9k_sso_hws *ws, struct rte_event *ev,cnxk_nix_mbuf_to_tstamp ((struct rte_mbuf *)mbuf, ws->tstamp, flags &NIX_RX_OFFLOAD_TSTAMP_F , - flags &NIX_RX_MULTI_SEG_F , (uint64_t *)tstamp_ptr); gw.u64[1 ] = mbuf; }
drivers/net/cnxk/cn10k_rx.h +7 -2
@@ -364,7 +364,13 @@ cn10k_nix_cqe_to_mbuf(const struct nix_cqe_hdr_s *cq, const uint32_t tag, *(uint64_t *)(&mbuf->rearm_data) = val;if (flag &NIX_RX_MULTI_SEG_F ) -nix_cqe_xtract_mseg (rx, mbuf, val, flag); +/* +* For multi segment packets, mbuf length correction according +* to Rx timestamp length will be handled later during +* timestamp data process. +* Hence, flag argument is not required. +*/ +nix_cqe_xtract_mseg (rx, mbuf, val,0 );else mbuf->next =NULL ; }
@@ -452,7 +458,6 @@ cn10k_nix_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts, flags);cnxk_nix_mbuf_to_tstamp (mbuf, rxq->tstamp, (flags &NIX_RX_OFFLOAD_TSTAMP_F ), - (flags &NIX_RX_MULTI_SEG_F ), (uint64_t *)((uint8_t *)mbuf + data_off)); rx_pkts[packets++] = mbuf;
drivers/net/cnxk/cn9k_rx.h +11 -7
@@ -345,13 +345,18 @@ cn9k_nix_cqe_to_mbuf(const struct nix_cqe_hdr_s *cq, const uint32_t tag, mbuf->ol_flags = ol_flags; *(uint64_t *)(&mbuf->rearm_data) = val; mbuf->pkt_len = len; - -if (flag &NIX_RX_MULTI_SEG_F ) { -nix_cqe_xtract_mseg (rx, mbuf, val, flag); - }else { - mbuf->data_len = len; + mbuf->data_len = len; + +if (flag &NIX_RX_MULTI_SEG_F ) +/* +* For multi segment packets, mbuf length correction according +* to Rx timestamp length will be handled later during +* timestamp data process. +* Hence, flag argument is not required. +*/ +nix_cqe_xtract_mseg (rx, mbuf, val,0 ); +else mbuf->next =NULL ; - } } static inline uint16_t
@@ -414,7 +419,6 @@ cn9k_nix_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts, flags);cnxk_nix_mbuf_to_tstamp (mbuf, rxq->tstamp, (flags &NIX_RX_OFFLOAD_TSTAMP_F ), - (flags &NIX_RX_MULTI_SEG_F ), (uint64_t *)((uint8_t *)mbuf + data_off)); rx_pkts[packets++] = mbuf;
drivers/net/cnxk/cnxk_ethdev.h +3 -6
@@ -685,14 +685,11 @@ cnxk_nix_timestamp_dynfield(struct rte_mbuf *mbuf, static __rte_always_inline voidcnxk_nix_mbuf_to_tstamp (struct rte_mbuf *mbuf,struct cnxk_timesync_info *tstamp, -const uint8_t ts_enable,const uint8_t mseg_enable, -uint64_t *tstamp_ptr) +const uint8_t ts_enable,uint64_t *tstamp_ptr) {if (ts_enable) { -if (!mseg_enable) { - mbuf->pkt_len -=CNXK_NIX_TIMESYNC_RX_OFFSET ; - mbuf->data_len -=CNXK_NIX_TIMESYNC_RX_OFFSET ; - } + mbuf->pkt_len -=CNXK_NIX_TIMESYNC_RX_OFFSET ; + mbuf->data_len -=CNXK_NIX_TIMESYNC_RX_OFFSET ;/* Reading the rx timestamp inserted by CGX, viz at * starting of the packet data.
--
2.25.1
Quoted 9 lines · Rahul Bhansali
If multi-segment is enabled and single segment/packet is received, then mbuf
data_lenis not updated incn9k_nix_cqe_to_mbuffunction.
Also, in case of timestamp is enabled, mbufdata_lenandpkt_lenwill be updated for all packets including multi segmented packets.Signed-off-by Rahul Bhansali <[email protected]>
Changed the git commit as follows and Applied to
dpdk-next-net-mrvl/for-next-net. Thanks
net/cnxk: fix mbuf data length
If multi-segment is enabled and single segment/packet is received, then mbuf data_len is not updated in cn9k_nix_cqe_to_mbuf() function.
Also, in case of timestamp is enabled, mbuf data_len and pkt_len will be updated for all packets including multi segmented packets.
Quoted 140 lines
---
Depends-on: Series-21246 ("[v2,1/4] net/cnxk: avoid command copy from Tx queue")drivers/event/cnxk/cn10k_worker.h | 2 -- drivers/event/cnxk/cn9k_worker.h | 2 -- drivers/net/cnxk/cn10k_rx.h | 9 +++++++-- drivers/net/cnxk/cn9k_rx.h | 18 +++++++++++------- drivers/net/cnxk/cnxk_ethdev.h | 9 +++------ 5 files changed, 21 insertions(+), 19 deletions(-)drivers/event/cnxk/cn10k_worker.h +0
-2@@ -174,7 +174,6 @@ cn10k_process_vwqe(uintptr_t vwqe, uint16_t port_id, const uint32_t flags, CNXK_SSO_WQE_SG_PTR);cnxk_nix_mbuf_to_tstamp ((struct rte_mbuf *)mbuf, tstamp, flags &NIX_RX_OFFLOAD_TSTAMP_F , - flags &NIX_RX_MULTI_SEG_F , (uint64_t *)tstamp_ptr); wqe[0 ] = (uint64_t *)mbuf; non_vec--;@@ -266,7 +265,6 @@ cn10k_sso_hws_get_work(struct cn10k_sso_hws *ws, struct rte_event *ev,cnxk_nix_mbuf_to_tstamp ((struct rte_mbuf *)mbuf, ws->tstamp, flags &NIX_RX_OFFLOAD_TSTAMP_F , - flags &NIX_RX_MULTI_SEG_F , (uint64_t *)tstamp_ptr); gw.u64[1 ] = mbuf; } else if (CNXK_EVENT_TYPE_FROM_TAG(gw.u64[0]) ==drivers/event/cnxk/cn9k_worker.h +0
-2@@ -208,7 +208,6 @@ cn9k_sso_hws_dual_get_work(uint64_t base, uint64_t pair_base,cnxk_nix_mbuf_to_tstamp ((struct rte_mbuf *)mbuf, dws->tstamp, flags &NIX_RX_OFFLOAD_TSTAMP_F , - flags &NIX_RX_MULTI_SEG_F , (uint64_t *)tstamp_ptr); gw.u64[1 ] = mbuf; }@@ -285,7 +284,6 @@ cn9k_sso_hws_get_work(struct cn9k_sso_hws *ws, struct rte_event *ev,cnxk_nix_mbuf_to_tstamp ((struct rte_mbuf *)mbuf, ws->tstamp, flags &NIX_RX_OFFLOAD_TSTAMP_F , - flags &NIX_RX_MULTI_SEG_F , (uint64_t *)tstamp_ptr); gw.u64[1 ] = mbuf; }drivers/net/cnxk/cn10k_rx.h +7
-2@@ -364,7 +364,13 @@ cn10k_nix_cqe_to_mbuf(const struct nix_cqe_hdr_s *cq, const uint32_t tag, *(uint64_t *)(&mbuf->rearm_data) = val;if (flag &NIX_RX_MULTI_SEG_F ) -nix_cqe_xtract_mseg (rx, mbuf, val, flag); +/* +* For multi segment packets, mbuf length correction according +* to Rx timestamp length will be handled later during +* timestamp data process. +* Hence, flag argument is not required. +*/ +nix_cqe_xtract_mseg (rx, mbuf, val,0 );else mbuf->next =NULL ; }@@ -452,7 +458,6 @@ cn10k_nix_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts, flags);cnxk_nix_mbuf_to_tstamp (mbuf, rxq->tstamp, (flags &NIX_RX_OFFLOAD_TSTAMP_F ), - (flags &NIX_RX_MULTI_SEG_F ), (uint64_t *)((uint8_t *)mbuf + data_off)); rx_pkts[packets++] = mbuf;drivers/net/cnxk/cn9k_rx.h +11
-7@@ -345,13 +345,18 @@ cn9k_nix_cqe_to_mbuf(const struct nix_cqe_hdr_s *cq, const uint32_t tag, mbuf->ol_flags = ol_flags; *(uint64_t *)(&mbuf->rearm_data) = val; mbuf->pkt_len = len; - -if (flag &NIX_RX_MULTI_SEG_F ) { -nix_cqe_xtract_mseg (rx, mbuf, val, flag); - }else { - mbuf->data_len = len; + mbuf->data_len = len; + +if (flag &NIX_RX_MULTI_SEG_F ) +/* +* For multi segment packets, mbuf length correction according +* to Rx timestamp length will be handled later during +* timestamp data process. +* Hence, flag argument is not required. +*/ +nix_cqe_xtract_mseg (rx, mbuf, val,0 ); +else mbuf->next =NULL ; - } } static inline uint16_t@@ -414,7 +419,6 @@ cn9k_nix_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts, flags);cnxk_nix_mbuf_to_tstamp (mbuf, rxq->tstamp, (flags &NIX_RX_OFFLOAD_TSTAMP_F ), - (flags &NIX_RX_MULTI_SEG_F ), (uint64_t *)((uint8_t *)mbuf + data_off)); rx_pkts[packets++] = mbuf;drivers/net/cnxk/cnxk_ethdev.h +3
-7@@ -685,14 +685,11 @@ cnxk_nix_timestamp_dynfield(struct rte_mbuf *mbuf, static __rte_always_inline voidcnxk_nix_mbuf_to_tstamp (struct rte_mbuf *mbuf,struct cnxk_timesync_info *tstamp, -const uint8_t ts_enable,const uint8_t mseg_enable, -uint64_t *tstamp_ptr) +const uint8_t ts_enable,uint64_t *tstamp_ptr) {if (ts_enable) { -if (!mseg_enable) { - mbuf->pkt_len -=CNXK_NIX_TIMESYNC_RX_OFFSET ; - mbuf->data_len -=CNXK_NIX_TIMESYNC_RX_OFFSET ; - } + mbuf->pkt_len -=CNXK_NIX_TIMESYNC_RX_OFFSET ; + mbuf->data_len -=CNXK_NIX_TIMESYNC_RX_OFFSET ;/* Reading the rx timestamp inserted by CGX, viz at * starting of the packet data. -- 2.25.1