Skip to content

Commit

Permalink
net/cnxk: fix mbuf fields in multi-segment Tx
Browse files Browse the repository at this point in the history
[ upstream commit 8ed5ca4dda858c991b27ad6ce5a5525e26a960c0 ]

Currently in debug mode when a buffer is allocated in SW,
nb_segs will have invalid values as it didn't come from driver
Rx path. Hence reset mbuf next and nb_segs fields in multi-seg Tx path.

Fixes: 3626d51 ("net/cnxk: add multi-segment Tx for CN10K")

Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
  • Loading branch information
Rahul Bhansali authored and bluca committed Mar 13, 2024
1 parent 430b276 commit ba9eb97
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/net/cnxk/cn10k_tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@ cn10k_nix_prepare_mseg(struct rte_mbuf *m, uint64_t *cmd, const uint16_t flags)
len -= sg_u & 0xFFFF;
nb_segs = m->nb_segs - 1;
m_next = m->next;
m->nb_segs = 1;
slist = &cmd[3 + off + 1];

/* Set invert df if buffer is not to be freed by H/W */
Expand Down Expand Up @@ -1404,6 +1405,7 @@ cn10k_nix_prepare_mseg_vec_list(struct rte_mbuf *m, uint64_t *cmd,
#endif

m->next = NULL;
m->nb_segs = 1;
m = m_next;
/* Fill mbuf segments */
do {
Expand Down
20 changes: 20 additions & 0 deletions drivers/net/cnxk/cn9k_tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ cn9k_nix_prepare_mseg(struct rte_mbuf *m, uint64_t *cmd, const uint16_t flags)
if (!(sg_u & (1ULL << 55)))
RTE_MEMPOOL_CHECK_COOKIES(m->pool, (void **)&m, 1, 0);
rte_io_wmb();
#endif
#ifdef RTE_ENABLE_ASSERT
m->next = NULL;
m->nb_segs = 1;
#endif
m = m_next;
if (!m)
Expand Down Expand Up @@ -483,6 +487,9 @@ cn9k_nix_prepare_mseg(struct rte_mbuf *m, uint64_t *cmd, const uint16_t flags)
sg_u = sg->u;
slist++;
}
#ifdef RTE_ENABLE_ASSERT
m->next = NULL;
#endif
m = m_next;
} while (nb_segs);

Expand All @@ -496,6 +503,9 @@ cn9k_nix_prepare_mseg(struct rte_mbuf *m, uint64_t *cmd, const uint16_t flags)
segdw += (off >> 1) + 1 + !!(flags & NIX_TX_OFFLOAD_TSTAMP_F);
send_hdr->w0.sizem1 = segdw - 1;

#ifdef RTE_ENABLE_ASSERT
rte_io_wmb();
#endif
return segdw;
}

Expand Down Expand Up @@ -699,6 +709,10 @@ cn9k_nix_prepare_mseg_vec_list(struct rte_mbuf *m, uint64_t *cmd,
rte_io_wmb();
#endif

#ifdef RTE_ENABLE_ASSERT
m->next = NULL;
m->nb_segs = 1;
#endif
m = m_next;
/* Fill mbuf segments */
do {
Expand Down Expand Up @@ -728,6 +742,9 @@ cn9k_nix_prepare_mseg_vec_list(struct rte_mbuf *m, uint64_t *cmd,
sg_u = sg->u;
slist++;
}
#ifdef RTE_ENABLE_ASSERT
m->next = NULL;
#endif
m = m_next;
} while (nb_segs);

Expand All @@ -743,6 +760,9 @@ cn9k_nix_prepare_mseg_vec_list(struct rte_mbuf *m, uint64_t *cmd,
!!(flags & NIX_TX_OFFLOAD_TSTAMP_F);
sh->sizem1 = segdw - 1;

#ifdef RTE_ENABLE_ASSERT
rte_io_wmb();
#endif
return segdw;
}

Expand Down

0 comments on commit ba9eb97

Please sign in to comment.