Avoid per-pkt barrier with multi-seg with fast free and remove mbuf update to NULL. Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com> Signed-off-by: Jerin Jacob <jerinj@marvell.com> --- drivers/event/octeontx2/otx2_worker.h | 22 ++++++++-------------- drivers/net/octeontx2/otx2_tx.c | 8 ++++++-- drivers/net/octeontx2/otx2_tx.h | 12 ++++++++---- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/event/octeontx2/otx2_worker.h b/drivers/event/octeontx2/otx2_worker.h index 4501f4e..3efd3ba 100644 --- a/drivers/event/octeontx2/otx2_worker.h +++ b/drivers/event/octeontx2/otx2_worker.h @@ -288,18 +288,12 @@ otx2_ssogws_event_tx(struct otx2_ssogws *ws, struct rte_event ev[], /* Perform header writes before barrier for TSO */ otx2_nix_xmit_prepare_tso(m, flags); - /* Lets commit any changes in the packet here in case of single seg as - * no further changes to mbuf will be done. - * While for multi seg all mbufs used are set to NULL in - * otx2_nix_prepare_mseg() after preparing the sg list and these changes - * should be committed before LMTST. - * Also in no fast free case some mbuf fields are updated in - * otx2_nix_prefree_seg - * Hence otx2_nix_xmit_submit_lmt_release/otx2_nix_xmit_mseg_one_release - * has store barrier for multiseg. + /* Lets commit any changes in the packet here in case when + * fast free is set as no further changes will be made to mbuf. + * In case of fast free is not set, both otx2_nix_prepare_mseg() + * and otx2_nix_xmit_prepare() has a barrier after refcnt update. */ - if (!(flags & NIX_TX_MULTI_SEG_F) && - !(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F)) + if (!(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F)) rte_io_wmb(); txq = otx2_ssogws_xtract_meta(m, txq_data); otx2_ssogws_prepare_pkt(txq, m, cmd, flags); @@ -311,12 +305,12 @@ otx2_ssogws_event_tx(struct otx2_ssogws *ws, struct rte_event ev[], if (!ev->sched_type) { otx2_nix_xmit_mseg_prep_lmt(cmd, txq->lmt_addr, segdw); otx2_ssogws_head_wait(ws); - if (otx2_nix_xmit_submit_lmt_release(txq->io_addr) == 0) + if (otx2_nix_xmit_submit_lmt(txq->io_addr) == 0) otx2_nix_xmit_mseg_one(cmd, txq->lmt_addr, txq->io_addr, segdw); } else { - otx2_nix_xmit_mseg_one_release(cmd, txq->lmt_addr, - txq->io_addr, segdw); + otx2_nix_xmit_mseg_one(cmd, txq->lmt_addr, + txq->io_addr, segdw); } } else { /* Passing no of segdw as 4: HDR + EXT + SG + SMEM */ diff --git a/drivers/net/octeontx2/otx2_tx.c b/drivers/net/octeontx2/otx2_tx.c index 4458d8b..439c46f 100644 --- a/drivers/net/octeontx2/otx2_tx.c +++ b/drivers/net/octeontx2/otx2_tx.c @@ -77,11 +77,15 @@ nix_xmit_pkts_mseg(void *tx_queue, struct rte_mbuf **tx_pkts, otx2_nix_xmit_prepare_tso(tx_pkts[i], flags); } + /* Lets commit any changes in the packet here as no further changes + * to the packet will be done unless no fast free is enabled. + */ + if (!(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F)) + rte_io_wmb(); + for (i = 0; i < pkts; i++) { otx2_nix_xmit_prepare(tx_pkts[i], cmd, flags); segdw = otx2_nix_prepare_mseg(tx_pkts[i], cmd, flags); - /* Lets commit any changes in the packet */ - rte_io_wmb(); otx2_nix_xmit_prepare_tstamp(cmd, &txq->cmd[0], tx_pkts[i]->ol_flags, segdw, flags); diff --git a/drivers/net/octeontx2/otx2_tx.h b/drivers/net/octeontx2/otx2_tx.h index d6ea3b4..a97b160 100644 --- a/drivers/net/octeontx2/otx2_tx.h +++ b/drivers/net/octeontx2/otx2_tx.h @@ -440,13 +440,17 @@ otx2_nix_prepare_mseg(struct rte_mbuf *m, uint64_t *cmd, const uint16_t flags) sg_u = sg_u | ((uint64_t)m->data_len << (i << 4)); *slist = rte_mbuf_data_iova(m); /* Set invert df if buffer is not to be freed by H/W */ - if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) + if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) { sg_u |= (otx2_nix_prefree_seg(m) << (i + 55)); + /* Commit changes to mbuf */ + rte_io_wmb(); + } /* Mark mempool object as "put" since it is freed by NIX */ - if (!(sg_u & (1ULL << (i + 55)))) { - m->next = NULL; +#ifdef RTE_LIBRTE_MEMPOOL_DEBUG + if (!(sg_u & (1ULL << (i + 55)))) __mempool_check_cookies(m->pool, (void **)&m, 1, 0); - } + rte_io_wmb(); +#endif slist++; i++; nb_segs--; -- 2.8.4
Avoid per-pkt barrier with multi-seg with fast free and remove mbuf update to NULL. Fixes: ce8628c66a22 ("net/octeontx2: fix jumbo frame crash") Cc: hkalra@marvell.com Cc: stable@dpdk.org Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com> Signed-off-by: Jerin Jacob <jerinj@marvell.com> --- v2: - Add fixes tag and also cc stable drivers/event/octeontx2/otx2_worker.h | 22 ++++++++-------------- drivers/net/octeontx2/otx2_tx.c | 8 ++++++-- drivers/net/octeontx2/otx2_tx.h | 12 ++++++++---- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/event/octeontx2/otx2_worker.h b/drivers/event/octeontx2/otx2_worker.h index 4501f4e..3efd3ba 100644 --- a/drivers/event/octeontx2/otx2_worker.h +++ b/drivers/event/octeontx2/otx2_worker.h @@ -288,18 +288,12 @@ otx2_ssogws_event_tx(struct otx2_ssogws *ws, struct rte_event ev[], /* Perform header writes before barrier for TSO */ otx2_nix_xmit_prepare_tso(m, flags); - /* Lets commit any changes in the packet here in case of single seg as - * no further changes to mbuf will be done. - * While for multi seg all mbufs used are set to NULL in - * otx2_nix_prepare_mseg() after preparing the sg list and these changes - * should be committed before LMTST. - * Also in no fast free case some mbuf fields are updated in - * otx2_nix_prefree_seg - * Hence otx2_nix_xmit_submit_lmt_release/otx2_nix_xmit_mseg_one_release - * has store barrier for multiseg. + /* Lets commit any changes in the packet here in case when + * fast free is set as no further changes will be made to mbuf. + * In case of fast free is not set, both otx2_nix_prepare_mseg() + * and otx2_nix_xmit_prepare() has a barrier after refcnt update. */ - if (!(flags & NIX_TX_MULTI_SEG_F) && - !(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F)) + if (!(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F)) rte_io_wmb(); txq = otx2_ssogws_xtract_meta(m, txq_data); otx2_ssogws_prepare_pkt(txq, m, cmd, flags); @@ -311,12 +305,12 @@ otx2_ssogws_event_tx(struct otx2_ssogws *ws, struct rte_event ev[], if (!ev->sched_type) { otx2_nix_xmit_mseg_prep_lmt(cmd, txq->lmt_addr, segdw); otx2_ssogws_head_wait(ws); - if (otx2_nix_xmit_submit_lmt_release(txq->io_addr) == 0) + if (otx2_nix_xmit_submit_lmt(txq->io_addr) == 0) otx2_nix_xmit_mseg_one(cmd, txq->lmt_addr, txq->io_addr, segdw); } else { - otx2_nix_xmit_mseg_one_release(cmd, txq->lmt_addr, - txq->io_addr, segdw); + otx2_nix_xmit_mseg_one(cmd, txq->lmt_addr, + txq->io_addr, segdw); } } else { /* Passing no of segdw as 4: HDR + EXT + SG + SMEM */ diff --git a/drivers/net/octeontx2/otx2_tx.c b/drivers/net/octeontx2/otx2_tx.c index 4458d8b..439c46f 100644 --- a/drivers/net/octeontx2/otx2_tx.c +++ b/drivers/net/octeontx2/otx2_tx.c @@ -77,11 +77,15 @@ nix_xmit_pkts_mseg(void *tx_queue, struct rte_mbuf **tx_pkts, otx2_nix_xmit_prepare_tso(tx_pkts[i], flags); } + /* Lets commit any changes in the packet here as no further changes + * to the packet will be done unless no fast free is enabled. + */ + if (!(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F)) + rte_io_wmb(); + for (i = 0; i < pkts; i++) { otx2_nix_xmit_prepare(tx_pkts[i], cmd, flags); segdw = otx2_nix_prepare_mseg(tx_pkts[i], cmd, flags); - /* Lets commit any changes in the packet */ - rte_io_wmb(); otx2_nix_xmit_prepare_tstamp(cmd, &txq->cmd[0], tx_pkts[i]->ol_flags, segdw, flags); diff --git a/drivers/net/octeontx2/otx2_tx.h b/drivers/net/octeontx2/otx2_tx.h index d6ea3b4..a97b160 100644 --- a/drivers/net/octeontx2/otx2_tx.h +++ b/drivers/net/octeontx2/otx2_tx.h @@ -440,13 +440,17 @@ otx2_nix_prepare_mseg(struct rte_mbuf *m, uint64_t *cmd, const uint16_t flags) sg_u = sg_u | ((uint64_t)m->data_len << (i << 4)); *slist = rte_mbuf_data_iova(m); /* Set invert df if buffer is not to be freed by H/W */ - if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) + if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) { sg_u |= (otx2_nix_prefree_seg(m) << (i + 55)); + /* Commit changes to mbuf */ + rte_io_wmb(); + } /* Mark mempool object as "put" since it is freed by NIX */ - if (!(sg_u & (1ULL << (i + 55)))) { - m->next = NULL; +#ifdef RTE_LIBRTE_MEMPOOL_DEBUG + if (!(sg_u & (1ULL << (i + 55)))) __mempool_check_cookies(m->pool, (void **)&m, 1, 0); - } + rte_io_wmb(); +#endif slist++; i++; nb_segs--; -- 2.8.4
On Wed, Oct 28, 2020 at 5:17 PM Nithin Dabilpuram <ndabilpuram@marvell.com> wrote: > > Avoid per-pkt barrier with multi-seg with fast free > and remove mbuf update to NULL. > > Fixes: ce8628c66a22 ("net/octeontx2: fix jumbo frame crash") > Cc: hkalra@marvell.com > Cc: stable@dpdk.org > > Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com> > Signed-off-by: Jerin Jacob <jerinj@marvell.com> Applied to dpdk-next-net-mrvl/for-main. Thanks > --- > > v2: > - Add fixes tag and also cc stable > > drivers/event/octeontx2/otx2_worker.h | 22 ++++++++-------------- > drivers/net/octeontx2/otx2_tx.c | 8 ++++++-- > drivers/net/octeontx2/otx2_tx.h | 12 ++++++++---- > 3 files changed, 22 insertions(+), 20 deletions(-) > > diff --git a/drivers/event/octeontx2/otx2_worker.h b/drivers/event/octeontx2/otx2_worker.h > index 4501f4e..3efd3ba 100644 > --- a/drivers/event/octeontx2/otx2_worker.h > +++ b/drivers/event/octeontx2/otx2_worker.h > @@ -288,18 +288,12 @@ otx2_ssogws_event_tx(struct otx2_ssogws *ws, struct rte_event ev[], > > /* Perform header writes before barrier for TSO */ > otx2_nix_xmit_prepare_tso(m, flags); > - /* Lets commit any changes in the packet here in case of single seg as > - * no further changes to mbuf will be done. > - * While for multi seg all mbufs used are set to NULL in > - * otx2_nix_prepare_mseg() after preparing the sg list and these changes > - * should be committed before LMTST. > - * Also in no fast free case some mbuf fields are updated in > - * otx2_nix_prefree_seg > - * Hence otx2_nix_xmit_submit_lmt_release/otx2_nix_xmit_mseg_one_release > - * has store barrier for multiseg. > + /* Lets commit any changes in the packet here in case when > + * fast free is set as no further changes will be made to mbuf. > + * In case of fast free is not set, both otx2_nix_prepare_mseg() > + * and otx2_nix_xmit_prepare() has a barrier after refcnt update. > */ > - if (!(flags & NIX_TX_MULTI_SEG_F) && > - !(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F)) > + if (!(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F)) > rte_io_wmb(); > txq = otx2_ssogws_xtract_meta(m, txq_data); > otx2_ssogws_prepare_pkt(txq, m, cmd, flags); > @@ -311,12 +305,12 @@ otx2_ssogws_event_tx(struct otx2_ssogws *ws, struct rte_event ev[], > if (!ev->sched_type) { > otx2_nix_xmit_mseg_prep_lmt(cmd, txq->lmt_addr, segdw); > otx2_ssogws_head_wait(ws); > - if (otx2_nix_xmit_submit_lmt_release(txq->io_addr) == 0) > + if (otx2_nix_xmit_submit_lmt(txq->io_addr) == 0) > otx2_nix_xmit_mseg_one(cmd, txq->lmt_addr, > txq->io_addr, segdw); > } else { > - otx2_nix_xmit_mseg_one_release(cmd, txq->lmt_addr, > - txq->io_addr, segdw); > + otx2_nix_xmit_mseg_one(cmd, txq->lmt_addr, > + txq->io_addr, segdw); > } > } else { > /* Passing no of segdw as 4: HDR + EXT + SG + SMEM */ > diff --git a/drivers/net/octeontx2/otx2_tx.c b/drivers/net/octeontx2/otx2_tx.c > index 4458d8b..439c46f 100644 > --- a/drivers/net/octeontx2/otx2_tx.c > +++ b/drivers/net/octeontx2/otx2_tx.c > @@ -77,11 +77,15 @@ nix_xmit_pkts_mseg(void *tx_queue, struct rte_mbuf **tx_pkts, > otx2_nix_xmit_prepare_tso(tx_pkts[i], flags); > } > > + /* Lets commit any changes in the packet here as no further changes > + * to the packet will be done unless no fast free is enabled. > + */ > + if (!(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F)) > + rte_io_wmb(); > + > for (i = 0; i < pkts; i++) { > otx2_nix_xmit_prepare(tx_pkts[i], cmd, flags); > segdw = otx2_nix_prepare_mseg(tx_pkts[i], cmd, flags); > - /* Lets commit any changes in the packet */ > - rte_io_wmb(); > otx2_nix_xmit_prepare_tstamp(cmd, &txq->cmd[0], > tx_pkts[i]->ol_flags, segdw, > flags); > diff --git a/drivers/net/octeontx2/otx2_tx.h b/drivers/net/octeontx2/otx2_tx.h > index d6ea3b4..a97b160 100644 > --- a/drivers/net/octeontx2/otx2_tx.h > +++ b/drivers/net/octeontx2/otx2_tx.h > @@ -440,13 +440,17 @@ otx2_nix_prepare_mseg(struct rte_mbuf *m, uint64_t *cmd, const uint16_t flags) > sg_u = sg_u | ((uint64_t)m->data_len << (i << 4)); > *slist = rte_mbuf_data_iova(m); > /* Set invert df if buffer is not to be freed by H/W */ > - if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) > + if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) { > sg_u |= (otx2_nix_prefree_seg(m) << (i + 55)); > + /* Commit changes to mbuf */ > + rte_io_wmb(); > + } > /* Mark mempool object as "put" since it is freed by NIX */ > - if (!(sg_u & (1ULL << (i + 55)))) { > - m->next = NULL; > +#ifdef RTE_LIBRTE_MEMPOOL_DEBUG > + if (!(sg_u & (1ULL << (i + 55)))) > __mempool_check_cookies(m->pool, (void **)&m, 1, 0); > - } > + rte_io_wmb(); > +#endif > slist++; > i++; > nb_segs--; > -- > 2.8.4 >