[PATCH 1/1] net/mana: enable 32 bit build for mana driver
Enable 32 bit build on x86 Linux. Fixed build warnings and errors when building in 32 bit. Cc: sta...@dpdk.org Signed-off-by: Wei Hu --- drivers/net/mana/mana.c | 2 +- drivers/net/mana/meson.build | 4 ++-- drivers/net/mana/mr.c| 18 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c index 7630118d4f..a20ca1a988 100644 --- a/drivers/net/mana/mana.c +++ b/drivers/net/mana/mana.c @@ -1260,7 +1260,7 @@ mana_probe_port(struct ibv_device *ibdev, struct ibv_device_attr_ex *dev_attr, /* Create a parent domain with the port number */ attr.pd = priv->ib_pd; attr.comp_mask = IBV_PARENT_DOMAIN_INIT_ATTR_PD_CONTEXT; - attr.pd_context = (void *)(uint64_t)port; + attr.pd_context = (void *)(size_t)port; priv->ib_parent_pd = ibv_alloc_parent_domain(ctx, &attr); if (!priv->ib_parent_pd) { DRV_LOG(ERR, "ibv_alloc_parent_domain failed port %d", port); diff --git a/drivers/net/mana/meson.build b/drivers/net/mana/meson.build index 493f0d26d4..2d72eca5a8 100644 --- a/drivers/net/mana/meson.build +++ b/drivers/net/mana/meson.build @@ -1,9 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2022 Microsoft Corporation -if not is_linux or not dpdk_conf.has('RTE_ARCH_X86_64') +if not is_linux or not dpdk_conf.has('RTE_ARCH_X86') build = false -reason = 'only supported on x86_64 Linux' +reason = 'only supported on x86 Linux' subdir_done() endif diff --git a/drivers/net/mana/mr.c b/drivers/net/mana/mr.c index fec0dc961c..b8e6ea0bbf 100644 --- a/drivers/net/mana/mr.c +++ b/drivers/net/mana/mr.c @@ -53,7 +53,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv, } DP_LOG(DEBUG, - "registering memory chunk start 0x%" PRIx64 " len %u", + "registering memory chunk start 0x%" PRIxPTR " len %u", ranges[i].start, ranges[i].len); if (rte_eal_process_type() == RTE_PROC_SECONDARY) { @@ -62,7 +62,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv, ranges[i].len); if (ret) { DP_LOG(ERR, - "MR failed start 0x%" PRIx64 " len %u", + "MR failed start 0x%" PRIxPTR " len %u", ranges[i].start, ranges[i].len); return ret; } @@ -72,7 +72,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv, ibv_mr = ibv_reg_mr(priv->ib_pd, (void *)ranges[i].start, ranges[i].len, IBV_ACCESS_LOCAL_WRITE); if (ibv_mr) { - DP_LOG(DEBUG, "MR lkey %u addr %p len %" PRIu64, + DP_LOG(DEBUG, "MR lkey %u addr %p len %zu", ibv_mr->lkey, ibv_mr->addr, ibv_mr->length); mr = rte_calloc("MANA MR", 1, sizeof(*mr), 0); @@ -99,7 +99,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv, return ret; } } else { - DP_LOG(ERR, "MR failed at 0x%" PRIx64 " len %u", + DP_LOG(ERR, "MR failed at 0x%" PRIxPTR " len %u", ranges[i].start, ranges[i].len); return -errno; } @@ -141,7 +141,7 @@ mana_find_pmd_mr(struct mana_mr_btree *local_mr_btree, struct mana_priv *priv, mr = mana_mr_btree_lookup(local_mr_btree, &idx, (uintptr_t)mbuf->buf_addr, mbuf->buf_len); if (mr) { - DP_LOG(DEBUG, "Local mr lkey %u addr 0x%" PRIx64 " len %" PRIu64, + DP_LOG(DEBUG, "Local mr lkey %u addr 0x%" PRIxPTR " len %zu", mr->lkey, mr->addr, mr->len); return mr; } @@ -162,7 +162,7 @@ mana_find_pmd_mr(struct mana_mr_btree *local_mr_btree, struct mana_priv *priv, } DP_LOG(DEBUG, - "Added local MR key %u addr 0x%" PRIx64 " len %" PRIu64, + "Added local MR key %u addr 0x%" PRIxPTR " len %zu", mr->lkey, mr->addr, mr->len); return mr; } @@ -266,7 +266,7 @@ mana_mr_btree_lookup(struct mana_mr_btree *bt, uint16_t *idx,
[PATCH 1/1] net/mana: add 32 bit short doorbell
Add 32 bit short doorbell support. Ring short doorbell when running in 32 bit applicactions. Cc: sta...@dpdk.org Signed-off-by: Wei Hu --- drivers/net/mana/gdma.c | 95 + drivers/net/mana/mana.h | 25 +++ drivers/net/mana/rx.c | 52 ++ drivers/net/mana/tx.c | 28 4 files changed, 200 insertions(+) diff --git a/drivers/net/mana/gdma.c b/drivers/net/mana/gdma.c index 65685fe236..d1da025d1b 100644 --- a/drivers/net/mana/gdma.c +++ b/drivers/net/mana/gdma.c @@ -166,6 +166,97 @@ gdma_post_work_request(struct mana_gdma_queue *queue, return 0; } +#ifdef RTE_ARCH_32 +union gdma_short_doorbell_entry { + uint32_t as_uint32; + + struct { + uint32_t tail_ptr_incr : 16; /* Number of CQEs */ + uint32_t id : 12; + uint32_t reserved : 3; + uint32_t arm: 1; + } cq; + + struct { + uint32_t tail_ptr_incr : 16; /* In number of bytes */ + uint32_t id : 12; + uint32_t reserved : 4; + } rq; + + struct { + uint32_t tail_ptr_incr : 16; /* In number of bytes */ + uint32_t id : 12; + uint32_t reserved : 4; + } sq; + + struct { + uint32_t tail_ptr_incr : 16; /* Number of EQEs */ + uint32_t id : 12; + uint32_t reserved : 3; + uint32_t arm: 1; + } eq; +}; /* HW DATA */ + +enum { + DOORBELL_SHORT_OFFSET_SQ = 0x10, + DOORBELL_SHORT_OFFSET_RQ = 0x410, + DOORBELL_SHORT_OFFSET_CQ = 0x810, + DOORBELL_SHORT_OFFSET_EQ = 0xFF0, +}; + +/* + * Write to hardware doorbell to notify new activity. + */ +int +mana_ring_short_doorbell(void *db_page, enum gdma_queue_types queue_type, +uint32_t queue_id, uint32_t tail_incr, uint8_t arm) +{ + uint8_t *addr = db_page; + union gdma_short_doorbell_entry e = {}; + + if ((queue_id & ~GDMA_SHORT_DB_QID_MASK) || + (tail_incr & ~GDMA_SHORT_DB_INC_MASK)) { + DP_LOG(ERR, "%s: queue_id %u or " + "tail_incr %u overflowed, queue type %d", + __func__, queue_id, tail_incr, queue_type); + return -EINVAL; + } + + switch (queue_type) { + case GDMA_QUEUE_SEND: + e.sq.id = queue_id; + e.sq.tail_ptr_incr = tail_incr; + addr += DOORBELL_SHORT_OFFSET_SQ; + break; + + case GDMA_QUEUE_RECEIVE: + e.rq.id = queue_id; + e.rq.tail_ptr_incr = tail_incr; + addr += DOORBELL_SHORT_OFFSET_RQ; + break; + + case GDMA_QUEUE_COMPLETION: + e.cq.id = queue_id; + e.cq.tail_ptr_incr = tail_incr; + e.cq.arm = arm; + addr += DOORBELL_SHORT_OFFSET_CQ; + break; + + default: + DP_LOG(ERR, "Unsupported queue type %d", queue_type); + return -1; + } + + /* Ensure all writes are done before ringing doorbell */ + rte_wmb(); + + DP_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u arm %u", + db_page, addr, queue_id, queue_type, tail_incr, arm); + + rte_write32(e.as_uint32, addr); + return 0; +} +#else union gdma_doorbell_entry { uint64_t as_uint64; @@ -248,6 +339,7 @@ mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type, rte_write64(e.as_uint64, addr); return 0; } +#endif /* * Poll completion queue for completions. @@ -287,6 +379,9 @@ gdma_poll_completion_queue(struct mana_gdma_queue *cq, num_comp++; cq->head++; +#ifdef RTE_ARCH_32 + cq->head_incr_to_short_db++; +#endif DP_LOG(DEBUG, "comp new 0x%x old 0x%x cqe 0x%x wq %u sq %u head %u", new_owner_bits, old_owner_bits, cqe_owner_bits, diff --git a/drivers/net/mana/mana.h b/drivers/net/mana/mana.h index 5801491d75..848d87c096 100644 --- a/drivers/net/mana/mana.h +++ b/drivers/net/mana/mana.h @@ -50,6 +50,19 @@ struct mana_shared_data { #define MAX_TX_WQE_SIZE 512 #define MAX_RX_WQE_SIZE 256 +/* For 32 bit only */ +#ifdef RTE_ARCH_32 +#defineGDMA_SHORT_DB_INC_MASK 0x +#defineGDMA_SHORT_DB_QID_MASK 0xfff + +#define GDMA_SHORT_DB_MAX_WQE (0x1 / GDMA_WQE_ALIGNMENT_UNIT_SIZE) + +#define TX_WQE_SHORT_DB_THRESHOLD \ + (GDMA_SHORT_DB_MAX_WQE - (2 * MAX_TX_WQE_SIZE)) +#define RX_WQE_SHORT_DB_THRESHOLD \ + (GDMA_SHORT_DB_MAX_WQE - (2 * MAX_RX_WQE_SIZE)) +#endif + /* Values from the GDMA specification document, WQE format description */ #define INLINE_OOB_SMALL_SIZE_IN_BYTES 8 #def
RE: [PATCH 1/1] net/mana: enable 32 bit build for mana driver
> From: Stephen Hemminger > Sent: Saturday, September 9, 2023 10:52 PM > > diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c index > > 7630118d4f..a20ca1a988 100644 > > --- a/drivers/net/mana/mana.c > > +++ b/drivers/net/mana/mana.c > > @@ -1260,7 +1260,7 @@ mana_probe_port(struct ibv_device *ibdev, > struct ibv_device_attr_ex *dev_attr, > > /* Create a parent domain with the port number */ > > attr.pd = priv->ib_pd; > > attr.comp_mask = IBV_PARENT_DOMAIN_INIT_ATTR_PD_CONTEXT; > > - attr.pd_context = (void *)(uint64_t)port; > > + attr.pd_context = (void *)(size_t)port; > > Since port is uint8_t, the better cast would be to uintptr_t which is always > an > unsigned value of same size as pointer. > > Also, not sure why using PRIxPTR is necessary; on all arch and platforms %p > should work for printing a pointer and is more common usage. Thanks Stephen. I will send out a v2 with port casting to uintptr_t. Regarding the use of PRIxPTR, I have seen this in couple other drivers. I think it is probably because the original variable is defined as uintptr_t, which was typedef'ed to unsigned long. We probably want to differentiate it from an actual pointer. And I was trying to stick to original code. Wei
[PATCH v2 1/1] net/mana: enable 32 bit build for mana driver
Enable 32 bit build on x86 Linux. Fixed build warnings and errors when building in 32 bit. Cc: sta...@dpdk.org Signed-off-by: Wei Hu --- v2: change port casting from size_t to uintptr_t. --- drivers/net/mana/mana.c | 2 +- drivers/net/mana/meson.build | 4 ++-- drivers/net/mana/mr.c| 18 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c index 7630118d4f..896b53ed35 100644 --- a/drivers/net/mana/mana.c +++ b/drivers/net/mana/mana.c @@ -1260,7 +1260,7 @@ mana_probe_port(struct ibv_device *ibdev, struct ibv_device_attr_ex *dev_attr, /* Create a parent domain with the port number */ attr.pd = priv->ib_pd; attr.comp_mask = IBV_PARENT_DOMAIN_INIT_ATTR_PD_CONTEXT; - attr.pd_context = (void *)(uint64_t)port; + attr.pd_context = (void *)(uintptr_t)port; priv->ib_parent_pd = ibv_alloc_parent_domain(ctx, &attr); if (!priv->ib_parent_pd) { DRV_LOG(ERR, "ibv_alloc_parent_domain failed port %d", port); diff --git a/drivers/net/mana/meson.build b/drivers/net/mana/meson.build index 493f0d26d4..2d72eca5a8 100644 --- a/drivers/net/mana/meson.build +++ b/drivers/net/mana/meson.build @@ -1,9 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2022 Microsoft Corporation -if not is_linux or not dpdk_conf.has('RTE_ARCH_X86_64') +if not is_linux or not dpdk_conf.has('RTE_ARCH_X86') build = false -reason = 'only supported on x86_64 Linux' +reason = 'only supported on x86 Linux' subdir_done() endif diff --git a/drivers/net/mana/mr.c b/drivers/net/mana/mr.c index fec0dc961c..b8e6ea0bbf 100644 --- a/drivers/net/mana/mr.c +++ b/drivers/net/mana/mr.c @@ -53,7 +53,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv, } DP_LOG(DEBUG, - "registering memory chunk start 0x%" PRIx64 " len %u", + "registering memory chunk start 0x%" PRIxPTR " len %u", ranges[i].start, ranges[i].len); if (rte_eal_process_type() == RTE_PROC_SECONDARY) { @@ -62,7 +62,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv, ranges[i].len); if (ret) { DP_LOG(ERR, - "MR failed start 0x%" PRIx64 " len %u", + "MR failed start 0x%" PRIxPTR " len %u", ranges[i].start, ranges[i].len); return ret; } @@ -72,7 +72,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv, ibv_mr = ibv_reg_mr(priv->ib_pd, (void *)ranges[i].start, ranges[i].len, IBV_ACCESS_LOCAL_WRITE); if (ibv_mr) { - DP_LOG(DEBUG, "MR lkey %u addr %p len %" PRIu64, + DP_LOG(DEBUG, "MR lkey %u addr %p len %zu", ibv_mr->lkey, ibv_mr->addr, ibv_mr->length); mr = rte_calloc("MANA MR", 1, sizeof(*mr), 0); @@ -99,7 +99,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv, return ret; } } else { - DP_LOG(ERR, "MR failed at 0x%" PRIx64 " len %u", + DP_LOG(ERR, "MR failed at 0x%" PRIxPTR " len %u", ranges[i].start, ranges[i].len); return -errno; } @@ -141,7 +141,7 @@ mana_find_pmd_mr(struct mana_mr_btree *local_mr_btree, struct mana_priv *priv, mr = mana_mr_btree_lookup(local_mr_btree, &idx, (uintptr_t)mbuf->buf_addr, mbuf->buf_len); if (mr) { - DP_LOG(DEBUG, "Local mr lkey %u addr 0x%" PRIx64 " len %" PRIu64, + DP_LOG(DEBUG, "Local mr lkey %u addr 0x%" PRIxPTR " len %zu", mr->lkey, mr->addr, mr->len); return mr; } @@ -162,7 +162,7 @@ mana_find_pmd_mr(struct mana_mr_btree *local_mr_btree, struct mana_priv *priv, } DP_LOG(DEBUG, - "Added local MR key %u addr 0x%" PRIx64 " len %" PRIu64, + "Added local MR key %u addr 0x%" PRIxPTR " len %zu", mr->lkey, mr->addr, mr->len); return mr; } @@ -266,7 +266,7
RE: [PATCH 1/1] net/mana: add 32 bit short doorbell
> -Original Message- > From: Long Li > Sent: Thursday, September 14, 2023 5:11 AM > To: Wei Hu ; dev@dpdk.org; Ferruh Yigit > ; Andrew Rybchenko > > Cc: sta...@dpdk.org > Subject: RE: [PATCH 1/1] net/mana: add 32 bit short doorbell > > > + > > +/* > > + * Write to hardware doorbell to notify new activity. > > + */ > > +int > > +mana_ring_short_doorbell(void *db_page, enum gdma_queue_types > > queue_type, > > +uint32_t queue_id, uint32_t tail_incr, uint8_t arm) { > > + uint8_t *addr = db_page; > > + union gdma_short_doorbell_entry e = {}; > > + > > + if ((queue_id & ~GDMA_SHORT_DB_QID_MASK) || > > + (tail_incr & ~GDMA_SHORT_DB_INC_MASK)) { > > + DP_LOG(ERR, "%s: queue_id %u or " > > + "tail_incr %u overflowed, queue type %d", > > + __func__, queue_id, tail_incr, queue_type); > > This should never happen. > > What does "overflowed" mean? Is it a hardware error or software error? If this > is a software error, the calling code needs to make sure it never overflows > when using short doorbells. > This is to guard any hardware and software bugs or weirdness, which could lead to silent failures if it doesn't log. The software code has already been made to avoid any intentional behaviors which could cause tail_incr overflow. Thanks, Wei
RE: [PATCH 1/1] net/mana: add 32 bit short doorbell
> -Original Message- > From: Long Li > Sent: Tuesday, September 19, 2023 4:02 AM > To: Wei Hu ; dev@dpdk.org > Cc: sta...@dpdk.org; Ferruh Yigit ; Luca Boccassi > ; Kevin Traynor > Subject: RE: [PATCH 1/1] net/mana: add 32 bit short doorbell > > > Subject: [PATCH 1/1] net/mana: add 32 bit short doorbell > > > > Add 32 bit short doorbell support. Ring short doorbell when running in > > 32 bit applicactions. > > > > Cc: sta...@dpdk.org > > > > Signed-off-by: Wei Hu > > --- > > drivers/net/mana/gdma.c | 95 > > + > > drivers/net/mana/mana.h | 25 +++ > > drivers/net/mana/rx.c | 52 ++ > > drivers/net/mana/tx.c | 28 > > 4 files changed, 200 insertions(+) > > > > diff --git a/drivers/net/mana/gdma.c b/drivers/net/mana/gdma.c index > > 65685fe236..d1da025d1b 100644 > > --- a/drivers/net/mana/gdma.c > > +++ b/drivers/net/mana/gdma.c > > @@ -166,6 +166,97 @@ gdma_post_work_request(struct > mana_gdma_queue > > *queue, > > return 0; > > } > > > > +#ifdef RTE_ARCH_32 > > +union gdma_short_doorbell_entry { > > + uint32_t as_uint32; > > + > > + struct { > > + uint32_t tail_ptr_incr : 16; /* Number of CQEs */ > > + uint32_t id : 12; > > + uint32_t reserved : 3; > > + uint32_t arm: 1; > > + } cq; > > + > > + struct { > > + uint32_t tail_ptr_incr : 16; /* In number of bytes */ > > + uint32_t id : 12; > > + uint32_t reserved : 4; > > + } rq; > > + > > + struct { > > + uint32_t tail_ptr_incr : 16; /* In number of bytes */ > > + uint32_t id : 12; > > + uint32_t reserved : 4; > > + } sq; > > + > > + struct { > > + uint32_t tail_ptr_incr : 16; /* Number of EQEs */ > > + uint32_t id : 12; > > + uint32_t reserved : 3; > > + uint32_t arm: 1; > > + } eq; > > +}; /* HW DATA */ > > + > > +enum { > > + DOORBELL_SHORT_OFFSET_SQ = 0x10, > > + DOORBELL_SHORT_OFFSET_RQ = 0x410, > > + DOORBELL_SHORT_OFFSET_CQ = 0x810, > > + DOORBELL_SHORT_OFFSET_EQ = 0xFF0, > > +}; > > + > > +/* > > + * Write to hardware doorbell to notify new activity. > > + */ > > +int > > +mana_ring_short_doorbell(void *db_page, enum gdma_queue_types > > queue_type, > > +uint32_t queue_id, uint32_t tail_incr, uint8_t arm) { > > + uint8_t *addr = db_page; > > + union gdma_short_doorbell_entry e = {}; > > + > > + if ((queue_id & ~GDMA_SHORT_DB_QID_MASK) || > > + (tail_incr & ~GDMA_SHORT_DB_INC_MASK)) { > > + DP_LOG(ERR, "%s: queue_id %u or " > > + "tail_incr %u overflowed, queue type %d", > > + __func__, queue_id, tail_incr, queue_type); > > + return -EINVAL; > > + } > > + > > + switch (queue_type) { > > + case GDMA_QUEUE_SEND: > > + e.sq.id = queue_id; > > + e.sq.tail_ptr_incr = tail_incr; > > + addr += DOORBELL_SHORT_OFFSET_SQ; > > + break; > > + > > + case GDMA_QUEUE_RECEIVE: > > + e.rq.id = queue_id; > > + e.rq.tail_ptr_incr = tail_incr; > > + addr += DOORBELL_SHORT_OFFSET_RQ; > > + break; > > + > > + case GDMA_QUEUE_COMPLETION: > > + e.cq.id = queue_id; > > + e.cq.tail_ptr_incr = tail_incr; > > + e.cq.arm = arm; > > + addr += DOORBELL_SHORT_OFFSET_CQ; > > + break; > > + > > + default: > > + DP_LOG(ERR, "Unsupported queue type %d", queue_type); > > + return -1; > > + } > > + > > + /* Ensure all writes are done before ringing doorbell */ > > + rte_wmb(); > > + > > + DP_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u > > arm %u", > > + db_page, addr, queue_id, queue_type, tail_incr, arm); > > + > > + rte_write32(e.as_uint32, addr); > > + return 0; > > +} > > +#else > > union gdma_doorbell_entry { > > uint64_t as_uint64; > > > > @@ -248,6 +339,7 @@ mana_ring_doorbell(void *db_page, enum > > gdma_queue_types queue_type, > &g
RE: [PATCH v2 1/1] net/mana: enable 32 bit build for mana driver
> -Original Message- > From: Ferruh Yigit > Sent: Tuesday, September 19, 2023 1:41 AM > To: Wei Hu ; dev@dpdk.org; Long Li > > Cc: sta...@dpdk.org; Kevin Traynor ; Luca Boccassi > > Subject: Re: [PATCH v2 1/1] net/mana: enable 32 bit build for mana driver > > On 9/13/2023 1:23 PM, Wei Hu wrote: > > Enable 32 bit build on x86 Linux. Fixed build warnings and errors when > > building in 32 bit. > > > > Cc: sta...@dpdk.org > > > > This is not a fix, but adding 32bit support to the driver, so not sure about > backporting. cc'ed Kevin & Luca for guidance. > > I will drop the tag while merging unles otherwise suggested by LTS > maintainers. Hi Ferruh, We have a customer who needs it to be on 22.11.x. That is why I put "Cc: sta...@dpdk.org" in it. > > > Signed-off-by: Wei Hu > > > > Hi Wei, > > Patch looks good, but it basically fixes the format specifiers that will cause > build error for 32 bit. > > Is there any other change required to make driver functional for 32 bit, or > does > it become functional with this change? > And if it does can you please confirm explicityly that driver tested on > 32 bit with this patch? Another patch, " net/mana: add 32 bit short doorbell", is required to make mana fully functional with 32 bit applications. This patch is to fix some build time errors and warnings when build in 32 bit. These patches can be independently built and they are addressing two different issues. So, I put them into two independent patches. I have tested it on 32 bit applications. They can run with this patch. Just mana would not work as the applications still use 64 bit long door bells, which do not work for 32 bit apps. Thanks, Wei
RE: [PATCH 1/1] net/mana: add 32 bit short doorbell
> -Original Message- > From: Ferruh Yigit > Sent: Tuesday, September 19, 2023 2:03 AM > To: Wei Hu ; dev@dpdk.org; Long Li > > Cc: sta...@dpdk.org; Kevin Traynor ; Luca Boccassi > > Subject: Re: [PATCH 1/1] net/mana: add 32 bit short doorbell > > On 9/9/2023 1:23 PM, Wei Hu wrote: > > Add 32 bit short doorbell support. Ring short doorbell when running in > > 32 bit applicactions. > > > > Hi Wei, > > Is this performance improvement for 32 bit, or is short doorbell support > required for 32 bit support? > > Hi Ferruh, This it not a performance improvement patch. Without this patch, 32 bit applications do not function. > This patch is using RTE_ARCH_32 compile time macro to enable short doorbell > support, so need to decide to support 32 bit or 64 bit in compile time. > > Also I guess 32 bit driver can run on 64 bit arch, what will be the result in > that > case? The patch is for those applications compiled in 32 bit, but running on a 64 bit Linux kernels. There is no 64 bit mana kernel driver available. So the kernel still needs to be in 64 bit. > > My point is, instead of using compile time flag, what do you think to detect > execution platform on runtime and use preferred doorbell according platform? > > I can see short descriptor support touches multiple functions, can the support > be abstracted to let to use it based on runtime detection? The 32 bit support request is from a specific customer who only has 32 bit applications. The customer needs to build and link its applications into 32bit libraries and drivers. Therefore, the DPDK mana driver needs to be in 32 bit anyway. 32bit applications cannot use 64bit doorbells. 64bit applications can use 32bit doorbells, however the performance would suffer and it definitely not recommended. IMHO, there is not much difference between compile time flag and "if...then...else" statement at runtime, except for in the latter case, a few more extra runtime instructions and maybe some branch overhead in either 64bit or 32bit case. Given we have limited 32bit use cases, I chose to just use the compile time flag, which seems to be simpler to implement and less work for our verification team. > > > Cc: sta...@dpdk.org > > > > Similar comment as previous patch, this patch is not a fix but adding new > support, not sure about backporting it. > The customer who needs 32bit support wants it to be on 22.11.x. That is why I put "Cc: sta...@dpdk.org" in it. > > Signed-off-by: Wei Hu > > > > <...> > > > @@ -97,6 +110,7 @@ mana_alloc_and_post_rx_wqe(struct mana_rxq *rxq) > > /* update queue for tracking pending packets */ > > desc->pkt = mbuf; > > desc->wqe_size_in_bu = wqe_size_in_bu; > > + rxq->wqe_cnt_to_short_db += wqe_size_in_bu; > > > > This variable always used within RTE_ARCH_32 block, but set here without > RTE_ARCH_32 ifdef, is this intentional? No, it is not intentional. Thanks for pointing this out. I will add ifdef in next round. Thanks, Wei
RE: [PATCH v2 1/1] net/mana: enable 32 bit build for mana driver
> -Original Message- > From: Ferruh Yigit > Sent: Tuesday, September 19, 2023 7:05 PM > To: Wei Hu ; dev@dpdk.org; Long Li > > Cc: sta...@dpdk.org; Kevin Traynor ; Luca Boccassi > > Subject: Re: [PATCH v2 1/1] net/mana: enable 32 bit build for mana driver > > On 9/19/2023 3:44 AM, Wei Hu wrote: > >> -Original Message- > >> From: Ferruh Yigit > >> Sent: Tuesday, September 19, 2023 1:41 AM > >> To: Wei Hu ; dev@dpdk.org; Long Li > >> > >> Cc: sta...@dpdk.org; Kevin Traynor ; Luca > >> Boccassi > >> Subject: Re: [PATCH v2 1/1] net/mana: enable 32 bit build for mana > >> driver > >> > >> On 9/13/2023 1:23 PM, Wei Hu wrote: > >>> Enable 32 bit build on x86 Linux. Fixed build warnings and errors > >>> when building in 32 bit. > >>> > >>> Cc: sta...@dpdk.org > >>> > >> > >> This is not a fix, but adding 32bit support to the driver, so not > >> sure about backporting. cc'ed Kevin & Luca for guidance. > >> > >> I will drop the tag while merging unles otherwise suggested by LTS > >> maintainers. > > > > Hi Ferruh, > > > > We have a customer who needs it to be on 22.11.x. That is why I put "Cc: > sta...@dpdk.org" in it. > > > > Got it, lets get comment from the LTS maintainers. > > >> > >>> Signed-off-by: Wei Hu > >>> > >> > >> Hi Wei, > >> > >> Patch looks good, but it basically fixes the format specifiers that > >> will cause build error for 32 bit. > >> > >> Is there any other change required to make driver functional for 32 > >> bit, or does it become functional with this change? > >> And if it does can you please confirm explicityly that driver tested > >> on > >> 32 bit with this patch? > > > > Another patch, " net/mana: add 32 bit short doorbell", is required to > > make mana fully functional with 32 bit applications. This patch is to > > fix some build time errors and warnings when build in 32 bit. These > > patches can be independently built and they are addressing two different > issues. So, I put them into two independent patches. > > > > I have tested it on 32 bit applications. They can run with this patch. > > Just mana would not work as the applications still use 64 bit long door > > bells, > which do not work for 32 bit apps. > > > > Thanks Wei, for clarification. > > As this patch enables the 32bit build of driver in meson, can you please add > comment log that 32bit driver is not functional yet? > > Or maybe meson update can be moved to short doorbell patch, where driver > becomes functional for 32 bit, this patch can mention in commit log that is > preparation for 32 bit support, what do you think? Thanks Ferruh. I would like to add comment log that 32bit driver is not fully functioning yet until short doorbell support is added. Meanwhile still keep the meson update in within this patch to keep it complete. Hope this works for you. Wei
RE: [PATCH 1/1] net/mana: add 32 bit short doorbell
> -Original Message- > From: Ferruh Yigit > > > > 32bit applications cannot use 64bit doorbells. 64bit applications can > > use 32bit doorbells, however the performance would suffer and it definitely > not recommended. > > > > OK, can you please add this detail to the commit log? > Will do. Thanks. Wei
RE: [PATCH 1/1] net/mana: add 32 bit short doorbell
> -Original Message- > From: Long Li > Sent: Wednesday, September 20, 2023 3:24 AM > To: Wei Hu ; dev@dpdk.org > Cc: sta...@dpdk.org; Ferruh Yigit ; Luca Boccassi > ; Kevin Traynor > Subject: RE: [PATCH 1/1] net/mana: add 32 bit short doorbell > > > > > +#ifdef RTE_ARCH_32 > > > > + uint16_t cqe_incr = > > > > +(uint16_t)rxq->gdma_cq.head_incr_to_short_db; > > > > > > How do you make sure head_incr_to_short_db doesn't overflow? > > > > > > > I have checked this with hardware team. In my opinion it would be > > easily overflown. > > The hw team seems suggesting the hw will take care of this. > > > > Thanks, > > Wei > > I'm not sure how HW can take care of this when it overflows. When it > happens, the HW will miss a doorbell and CQ queue will get full. And > eventually you'll lose completions for TX/RX. > > In mana_alloc_and_post_rx_wqes() and mana_rx_burst(), the code has check > for RX/TX_WQE_SHORT_DB_THRESHOLD to make sure tail_incr doesn't > overflow when ringing the doorbell. > > In gdma_poll_completion_queue(), you need to have a similar mechanism to > not overflow tail_incr when ringing the doorbell. > I am not sure what can be done here. Applications could run in poll mode without need to ring cq doorbell, or it could take very long time before it change the interrupt state. What we can do when cq->head_incr_to_short_db reaches 0x in gdma_poll_completion_queue()? If it breaks out the loop and return, the next time it enters it may still at0x because it has not rung doorbell the have it reset yet. If just resetting the value to 0 and let it keep going in the loop, it is no difference than casting it to 16 bit unsigned int, which would be done in mana_arm_cq() if it is eventually called. Anyway, ringing cq doorbell has not been tested as the driver doesn't support interrupts. Wei
[PATCH 0/2] net/mana: 32 bit support
This is to combine two patches into a patchset. These two patches can be compiled independently. But we need both to make mana functional in 32 bit. Review comments received previously were also incorporated. - change port casting from size_t to uintptr_t - remove short doorbell for CQ as it is not supported - add a couple missing ifdefs - fix the short doorbell threshold counting in wqes Need to backport these to 22.11.x Cc: sta...@dpdk.org Wei Hu (2): net/mana: enable 32 bit build for mana driver net/mana: add 32 bit short doorbell drivers/net/mana/gdma.c | 92 drivers/net/mana/mana.c | 2 +- drivers/net/mana/mana.h | 26 ++ drivers/net/mana/meson.build | 4 +- drivers/net/mana/mr.c| 18 +++ drivers/net/mana/rx.c| 45 ++ drivers/net/mana/tx.c| 25 ++ 7 files changed, 200 insertions(+), 12 deletions(-) -- 2.34.1
[PATCH 1/2] net/mana: enable 32 bit build for mana driver
Enable 32 bit build on x86 Linux. Fixed build warnings and errors when building in 32 bit. With this patch, mana will be able to build into 32 bit. However, another patch for mana short doorbell support is needed to make mana fully functional for 32 bit applicatons. Cc: sta...@dpdk.org Signed-off-by: Wei Hu --- drivers/net/mana/mana.c | 2 +- drivers/net/mana/meson.build | 4 ++-- drivers/net/mana/mr.c| 18 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c index 7630118d4f..896b53ed35 100644 --- a/drivers/net/mana/mana.c +++ b/drivers/net/mana/mana.c @@ -1260,7 +1260,7 @@ mana_probe_port(struct ibv_device *ibdev, struct ibv_device_attr_ex *dev_attr, /* Create a parent domain with the port number */ attr.pd = priv->ib_pd; attr.comp_mask = IBV_PARENT_DOMAIN_INIT_ATTR_PD_CONTEXT; - attr.pd_context = (void *)(uint64_t)port; + attr.pd_context = (void *)(uintptr_t)port; priv->ib_parent_pd = ibv_alloc_parent_domain(ctx, &attr); if (!priv->ib_parent_pd) { DRV_LOG(ERR, "ibv_alloc_parent_domain failed port %d", port); diff --git a/drivers/net/mana/meson.build b/drivers/net/mana/meson.build index 493f0d26d4..2d72eca5a8 100644 --- a/drivers/net/mana/meson.build +++ b/drivers/net/mana/meson.build @@ -1,9 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2022 Microsoft Corporation -if not is_linux or not dpdk_conf.has('RTE_ARCH_X86_64') +if not is_linux or not dpdk_conf.has('RTE_ARCH_X86') build = false -reason = 'only supported on x86_64 Linux' +reason = 'only supported on x86 Linux' subdir_done() endif diff --git a/drivers/net/mana/mr.c b/drivers/net/mana/mr.c index fec0dc961c..b8e6ea0bbf 100644 --- a/drivers/net/mana/mr.c +++ b/drivers/net/mana/mr.c @@ -53,7 +53,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv, } DP_LOG(DEBUG, - "registering memory chunk start 0x%" PRIx64 " len %u", + "registering memory chunk start 0x%" PRIxPTR " len %u", ranges[i].start, ranges[i].len); if (rte_eal_process_type() == RTE_PROC_SECONDARY) { @@ -62,7 +62,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv, ranges[i].len); if (ret) { DP_LOG(ERR, - "MR failed start 0x%" PRIx64 " len %u", + "MR failed start 0x%" PRIxPTR " len %u", ranges[i].start, ranges[i].len); return ret; } @@ -72,7 +72,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv, ibv_mr = ibv_reg_mr(priv->ib_pd, (void *)ranges[i].start, ranges[i].len, IBV_ACCESS_LOCAL_WRITE); if (ibv_mr) { - DP_LOG(DEBUG, "MR lkey %u addr %p len %" PRIu64, + DP_LOG(DEBUG, "MR lkey %u addr %p len %zu", ibv_mr->lkey, ibv_mr->addr, ibv_mr->length); mr = rte_calloc("MANA MR", 1, sizeof(*mr), 0); @@ -99,7 +99,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct mana_priv *priv, return ret; } } else { - DP_LOG(ERR, "MR failed at 0x%" PRIx64 " len %u", + DP_LOG(ERR, "MR failed at 0x%" PRIxPTR " len %u", ranges[i].start, ranges[i].len); return -errno; } @@ -141,7 +141,7 @@ mana_find_pmd_mr(struct mana_mr_btree *local_mr_btree, struct mana_priv *priv, mr = mana_mr_btree_lookup(local_mr_btree, &idx, (uintptr_t)mbuf->buf_addr, mbuf->buf_len); if (mr) { - DP_LOG(DEBUG, "Local mr lkey %u addr 0x%" PRIx64 " len %" PRIu64, + DP_LOG(DEBUG, "Local mr lkey %u addr 0x%" PRIxPTR " len %zu", mr->lkey, mr->addr, mr->len); return mr; } @@ -162,7 +162,7 @@ mana_find_pmd_mr(struct mana_mr_btree *local_mr_btree, struct mana_priv *priv, } DP_LOG(DEBUG, - "Added local MR key %u addr 0x%" PRIx64 " len %" PRIu64, + "Added local MR key %u addr 0x%" PRIxPTR " le
[PATCH 2/2] net/mana: add 32 bit short doorbell
Add 32 bit short doorbell support. Ring short doorbell when running in 32 bit applicactions. Both 32 bit and 64 bit doorbells are supported by mana hardware on same platform. 32 bit applications cannot use 64 bit doorbells. 64 bit applications can use 32 bit doorbells, however the performance would greatly suffer and it is not recommended. Cc: sta...@dpdk.org Signed-off-by: Wei Hu --- drivers/net/mana/gdma.c | 92 + drivers/net/mana/mana.h | 26 drivers/net/mana/rx.c | 45 drivers/net/mana/tx.c | 25 +++ 4 files changed, 188 insertions(+) diff --git a/drivers/net/mana/gdma.c b/drivers/net/mana/gdma.c index 65685fe236..7f66a7a7cf 100644 --- a/drivers/net/mana/gdma.c +++ b/drivers/net/mana/gdma.c @@ -166,6 +166,97 @@ gdma_post_work_request(struct mana_gdma_queue *queue, return 0; } +#ifdef RTE_ARCH_32 +union gdma_short_doorbell_entry { + uint32_t as_uint32; + + struct { + uint32_t tail_ptr_incr : 16; /* Number of CQEs */ + uint32_t id : 12; + uint32_t reserved : 3; + uint32_t arm: 1; + } cq; + + struct { + uint32_t tail_ptr_incr : 16; /* In number of bytes */ + uint32_t id : 12; + uint32_t reserved : 4; + } rq; + + struct { + uint32_t tail_ptr_incr : 16; /* In number of bytes */ + uint32_t id : 12; + uint32_t reserved : 4; + } sq; + + struct { + uint32_t tail_ptr_incr : 16; /* Number of EQEs */ + uint32_t id : 12; + uint32_t reserved : 3; + uint32_t arm: 1; + } eq; +}; /* HW DATA */ + +enum { + DOORBELL_SHORT_OFFSET_SQ = 0x10, + DOORBELL_SHORT_OFFSET_RQ = 0x410, + DOORBELL_SHORT_OFFSET_CQ = 0x810, + DOORBELL_SHORT_OFFSET_EQ = 0xFF0, +}; + +/* + * Write to hardware doorbell to notify new activity. + */ +int +mana_ring_short_doorbell(void *db_page, enum gdma_queue_types queue_type, +uint32_t queue_id, uint32_t tail_incr, uint8_t arm) +{ + uint8_t *addr = db_page; + union gdma_short_doorbell_entry e = {}; + + if ((queue_id & ~GDMA_SHORT_DB_QID_MASK) || + (tail_incr & ~GDMA_SHORT_DB_INC_MASK)) { + DP_LOG(ERR, "%s: queue_id %u or " + "tail_incr %u overflowed, queue type %d", + __func__, queue_id, tail_incr, queue_type); + return -EINVAL; + } + + switch (queue_type) { + case GDMA_QUEUE_SEND: + e.sq.id = queue_id; + e.sq.tail_ptr_incr = tail_incr; + addr += DOORBELL_SHORT_OFFSET_SQ; + break; + + case GDMA_QUEUE_RECEIVE: + e.rq.id = queue_id; + e.rq.tail_ptr_incr = tail_incr; + addr += DOORBELL_SHORT_OFFSET_RQ; + break; + + case GDMA_QUEUE_COMPLETION: + e.cq.id = queue_id; + e.cq.tail_ptr_incr = tail_incr; + e.cq.arm = arm; + addr += DOORBELL_SHORT_OFFSET_CQ; + break; + + default: + DP_LOG(ERR, "Unsupported queue type %d", queue_type); + return -1; + } + + /* Ensure all writes are done before ringing doorbell */ + rte_wmb(); + + DP_LOG(DEBUG, "db_page %p addr %p queue_id %u type %u tail %u arm %u", + db_page, addr, queue_id, queue_type, tail_incr, arm); + + rte_write32(e.as_uint32, addr); + return 0; +} +#else union gdma_doorbell_entry { uint64_t as_uint64; @@ -248,6 +339,7 @@ mana_ring_doorbell(void *db_page, enum gdma_queue_types queue_type, rte_write64(e.as_uint64, addr); return 0; } +#endif /* * Poll completion queue for completions. diff --git a/drivers/net/mana/mana.h b/drivers/net/mana/mana.h index 5801491d75..74e37706be 100644 --- a/drivers/net/mana/mana.h +++ b/drivers/net/mana/mana.h @@ -50,6 +50,21 @@ struct mana_shared_data { #define MAX_TX_WQE_SIZE 512 #define MAX_RX_WQE_SIZE 256 +/* For 32 bit only */ +#ifdef RTE_ARCH_32 +#defineGDMA_SHORT_DB_INC_MASK 0x +#defineGDMA_SHORT_DB_QID_MASK 0xfff + +#define GDMA_SHORT_DB_MAX_WQE (0x1 / GDMA_WQE_ALIGNMENT_UNIT_SIZE) + +#define TX_WQE_SHORT_DB_THRESHOLD \ + (GDMA_SHORT_DB_MAX_WQE -\ + (MAX_TX_WQE_SIZE / GDMA_WQE_ALIGNMENT_UNIT_SIZE)) +#define RX_WQE_SHORT_DB_THRESHOLD \ + (GDMA_SHORT_DB_MAX_WQE -\ + (MAX_RX_WQE_SIZE / GDMA_WQE_ALIGNMENT_UNIT_SIZE)) +#endif + /* Values from the GDMA specification document, WQE format description */ #
RE: [PATCH] net/netvsc: use rte_eth_dev_set_mtu to set VF MTU
> Subject: [PATCH] net/netvsc: use rte_eth_dev_set_mtu to set VF MTU > > From: Stephen Hemminger > > The current code uses unnecessary locking to set VF MTU, resulting in > deadlock on hot add/remove path. Fix this by using rte_eth_dev_set_mtu() to > set VF MTU. > > Signed-off-by: Stephen Hemminger > > Fixes: 45c83603087e ("net/netvsc: support MTU set") > Cc: sta...@dpdk.org > Signed-off-by: Long Li Reviewed-by: Wei Hu > --- > drivers/net/netvsc/hn_vf.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/netvsc/hn_vf.c b/drivers/net/netvsc/hn_vf.c index > 6b3d0eb0c8..b664beaa5d 100644 > --- a/drivers/net/netvsc/hn_vf.c > +++ b/drivers/net/netvsc/hn_vf.c > @@ -264,7 +264,7 @@ int hn_vf_add(struct rte_eth_dev *dev, struct > hn_data *hv) > goto exit; > } > > - ret = hn_vf_mtu_set(dev, dev->data->mtu); > + ret = rte_eth_dev_set_mtu(port, dev->data->mtu); > if (ret) { > PMD_DRV_LOG(ERR, "Failed to set VF MTU"); > goto exit; > @@ -796,7 +796,7 @@ int hn_vf_mtu_set(struct rte_eth_dev *dev, uint16_t > mtu) > rte_rwlock_read_lock(&hv->vf_lock); > vf_dev = hn_get_vf_dev(hv); > if (hv->vf_ctx.vf_vsc_switched && vf_dev) > - ret = vf_dev->dev_ops->mtu_set(vf_dev, mtu); > + ret = rte_eth_dev_set_mtu(vf_dev->data->port_id, mtu); > rte_rwlock_read_unlock(&hv->vf_lock); > > return ret; > -- > 2.43.0
[PATCH 1/1] net/mana: add vlan tagging support
For tx path, use LONG_PACKET_FORMAT if vlan tag is present. For rx, extract vlan id from oob, put into mbuf and set the vlan flags in mbuf. Also add myself to the maintainers list for vmbus, mana and netvsc. Signed-off-by: Wei Hu --- MAINTAINERS | 3 +++ drivers/net/mana/mana.h | 2 ++ drivers/net/mana/rx.c | 6 ++ drivers/net/mana/tx.c | 30 +++--- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 5fb3a73f84..9983d013a6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -608,6 +608,7 @@ F: app/test/test_vdev.c VMBUS bus driver M: Long Li +M: Wei Hu F: drivers/bus/vmbus/ @@ -867,6 +868,7 @@ F: doc/guides/nics/features/mlx5.ini Microsoft mana M: Long Li +M: Wei Hu F: drivers/net/mana/ F: doc/guides/nics/mana.rst F: doc/guides/nics/features/mana.ini @@ -878,6 +880,7 @@ F: doc/guides/nics/vdev_netvsc.rst Microsoft Hyper-V netvsc M: Long Li +M: Wei Hu F: drivers/net/netvsc/ F: doc/guides/nics/netvsc.rst F: doc/guides/nics/features/netvsc.ini diff --git a/drivers/net/mana/mana.h b/drivers/net/mana/mana.h index 4c56e6f746..2b65a19878 100644 --- a/drivers/net/mana/mana.h +++ b/drivers/net/mana/mana.h @@ -21,10 +21,12 @@ struct mana_shared_data { #define MANA_MAX_MAC_ADDR 1 #define MANA_DEV_RX_OFFLOAD_SUPPORT ( \ + RTE_ETH_RX_OFFLOAD_VLAN_STRIP | \ RTE_ETH_RX_OFFLOAD_CHECKSUM | \ RTE_ETH_RX_OFFLOAD_RSS_HASH) #define MANA_DEV_TX_OFFLOAD_SUPPORT ( \ + RTE_ETH_TX_OFFLOAD_VLAN_INSERT | \ RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \ RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \ RTE_ETH_TX_OFFLOAD_TCP_CKSUM | \ diff --git a/drivers/net/mana/rx.c b/drivers/net/mana/rx.c index acad5e26cd..506f073708 100644 --- a/drivers/net/mana/rx.c +++ b/drivers/net/mana/rx.c @@ -517,6 +517,12 @@ mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) mbuf->hash.rss = oob->packet_info[pkt_idx].packet_hash; } + if (oob->rx_vlan_tag_present) { + mbuf->ol_flags |= + RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED; + mbuf->vlan_tci = oob->rx_vlan_id; + } + pkts[pkt_received++] = mbuf; rxq->stats.packets++; rxq->stats.bytes += mbuf->data_len; diff --git a/drivers/net/mana/tx.c b/drivers/net/mana/tx.c index 58c4a1d976..f075fcb0f5 100644 --- a/drivers/net/mana/tx.c +++ b/drivers/net/mana/tx.c @@ -180,6 +180,15 @@ get_vsq_frame_num(uint32_t vsq) return v.vsq_frame; } +#define VLAN_PRIO_MASK 0xe000 /* Priority Code Point */ +#define VLAN_PRIO_SHIFT13 +#define VLAN_CFI_MASK 0x1000 /* Canonical Format Indicator / Drop Eligible Indicator */ +#define VLAN_VID_MASK 0x0fff /* VLAN Identifier */ + +#define mana_mbuf_vlan_tag_get_id(m) ((m)->vlan_tci & VLAN_VID_MASK) +#define mana_mbuf_vlan_tag_get_cfi(m) (!!((m)->vlan_tci & VLAN_CFI_MASK)) +#define mana_mbuf_vlan_tag_get_prio(m) (((m)->vlan_tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT) + uint16_t mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { @@ -254,7 +263,18 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) } /* Fill in the oob */ - tx_oob.short_oob.packet_format = SHORT_PACKET_FORMAT; + if (m_pkt->ol_flags & RTE_MBUF_F_TX_VLAN) { + tx_oob.short_oob.packet_format = LONG_PACKET_FORMAT; + tx_oob.long_oob.inject_vlan_prior_tag = 1; + tx_oob.long_oob.priority_code_point = + mana_mbuf_vlan_tag_get_prio(m_pkt); + tx_oob.long_oob.drop_eligible_indicator = + mana_mbuf_vlan_tag_get_cfi(m_pkt); + tx_oob.long_oob.vlan_identifier = + mana_mbuf_vlan_tag_get_id(m_pkt); + } else { + tx_oob.short_oob.packet_format = SHORT_PACKET_FORMAT; + } tx_oob.short_oob.tx_is_outer_ipv4 = m_pkt->ol_flags & RTE_MBUF_F_TX_IPV4 ? 1 : 0; tx_oob.short_oob.tx_is_outer_ipv6 = @@ -409,8 +429,12 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) work_req.sgl = sgl.gdma_sgl; work_req.num_sgl_elements = m_pkt->nb_segs; - work_req.inline_oob_size_in_bytes = - sizeof(struct transmit_short_oob_v2); + if (tx_oob.short_oob.packet_format == SHORT_PACKET_FORMAT) + work_req.inline_oob_size_in_bytes = +
RE: [PATCH 1/1] net/mana: add vlan tagging support
> -Original Message- > From: Ferruh Yigit > Sent: Saturday, February 10, 2024 12:06 AM > To: Wei Hu ; andrew.rybche...@oktetlabs.ru; Thomas > Monjalon ; Long Li > Cc: dev@dpdk.org > Subject: Re: [PATCH 1/1] net/mana: add vlan tagging support > > On 2/9/2024 8:52 AM, Wei Hu wrote: > > For tx path, use LONG_PACKET_FORMAT if vlan tag is present. For rx, > > extract vlan id from oob, put into mbuf and set the vlan flags in > > mbuf. > > > > Also add myself to the maintainers list for vmbus, mana and netvsc. > > > > Signed-off-by: Wei Hu > > --- > > MAINTAINERS | 3 +++ > > drivers/net/mana/mana.h | 2 ++ > > drivers/net/mana/rx.c | 6 ++ > > drivers/net/mana/tx.c | 30 +++--- > > 4 files changed, 38 insertions(+), 3 deletions(-) > > > > diff --git a/MAINTAINERS b/MAINTAINERS index 5fb3a73f84..9983d013a6 > > 100644 > > --- a/MAINTAINERS > > +++ b/MAINTAINERS > > @@ -608,6 +608,7 @@ F: app/test/test_vdev.c > > > > VMBUS bus driver > > M: Long Li > > +M: Wei Hu > > F: drivers/bus/vmbus/ > > > > > > @@ -867,6 +868,7 @@ F: doc/guides/nics/features/mlx5.ini > > > > Microsoft mana > > M: Long Li > > +M: Wei Hu > > F: drivers/net/mana/ > > F: doc/guides/nics/mana.rst > > F: doc/guides/nics/features/mana.ini > > @@ -878,6 +880,7 @@ F: doc/guides/nics/vdev_netvsc.rst > > > > Microsoft Hyper-V netvsc > > M: Long Li > > +M: Wei Hu > > F: drivers/net/netvsc/ > > F: doc/guides/nics/netvsc.rst > > F: doc/guides/nics/features/netvsc.ini > > > > Hi Wei, > > Can you please separate the maintainer file update to its own patch? Sure. I will remove the maintainer file update and send it out later separately. Thanks, Wei
RE: [PATCH 1/1] net/mana: add vlan tagging support
> -Original Message- > From: Long Li > Sent: Saturday, February 10, 2024 2:48 AM > To: Wei Hu ; ferruh.yi...@amd.com; > andrew.rybche...@oktetlabs.ru; Thomas Monjalon > ; Alan Elder > Cc: dev@dpdk.org > Subject: RE: [PATCH 1/1] net/mana: add vlan tagging support > > > + if (oob->rx_vlan_tag_present) { > > + mbuf->ol_flags |= > > + RTE_MBUF_F_RX_VLAN | > > RTE_MBUF_F_RX_VLAN_STRIPPED; > > + mbuf->vlan_tci = oob->rx_vlan_id; > > + } > > + > > Netvsc has the following code for dealing with vlan on RX mbufs (in > hn_rxtx.c): > /* NDIS always strips tag, put it back if necessary */ > if (!hv->vlan_strip && rte_vlan_insert(&m)) { > > It seems we should do the same? Not sure if we want to do the same. Two reasons. 1. Searching the netvsc source, I don't see a place that it set hv->vlan_strip to false. It means !hv->vlan_string is always false, and rte_vlan_insert(&m) never run. 2. Usually vlan_strip can be set to true or false if the hardware supports this feature. In the mana case, the hardware strips off the vlan tag anyway. There is no way to tell the mana hardware to keep the tag. Adding the tag back by software not only slows things down, but it also complicates the code and test. Not sure if there is any real application needs it. I am open to add it. But in my opinion, we don't need it. Let me know what you think. > > > pkts[pkt_received++] = mbuf; > > rxq->stats.packets++; > > rxq->stats.bytes += mbuf->data_len; diff --git > > a/drivers/net/mana/tx.c b/drivers/net/mana/tx.c index > > 58c4a1d976..f075fcb0f5 100644 > > --- a/drivers/net/mana/tx.c > > +++ b/drivers/net/mana/tx.c > > @@ -180,6 +180,15 @@ get_vsq_frame_num(uint32_t vsq) > > return v.vsq_frame; > > } > > > > +#define VLAN_PRIO_MASK 0xe000 /* Priority Code Point */ > > +#define VLAN_PRIO_SHIFT13 > > +#define VLAN_CFI_MASK 0x1000 /* Canonical Format Indicator > > / Drop Eligible Indicator */ > > +#define VLAN_VID_MASK 0x0fff /* VLAN Identifier */ > > + > > +#define mana_mbuf_vlan_tag_get_id(m) ((m)->vlan_tci & > > VLAN_VID_MASK) > > +#define mana_mbuf_vlan_tag_get_cfi(m) (!!((m)->vlan_tci & > > VLAN_CFI_MASK)) > > +#define mana_mbuf_vlan_tag_get_prio(m) (((m)->vlan_tci & > > VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT) > > + > > Those definitions look like those in @Alan Elder's patch for netvsc. Can we > consolidate some of those definitions into a common place? > > Maybe in "lib/net/rte_ether.h"? > Ok. Will add it to rte_ether.h. Thanks, Wei > Thanks, > > Long
[PATCH 1/1] maintainers: update for vmbus/mana/netvsc drivers
Add myself as maintainer for vmbus, mana and netvsc. Signed-off-by: Wei Hu --- MAINTAINERS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index c9adff9846..58947b57ce 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -624,6 +624,7 @@ F: app/test/test_vdev.c VMBUS bus driver M: Long Li +M: Wei Hu F: drivers/bus/vmbus/ @@ -882,6 +883,7 @@ F: doc/guides/nics/features/mlx5.ini Microsoft mana M: Long Li +M: Wei Hu F: drivers/net/mana/ F: doc/guides/nics/mana.rst F: doc/guides/nics/features/mana.ini @@ -893,6 +895,7 @@ F: doc/guides/nics/vdev_netvsc.rst Microsoft Hyper-V netvsc M: Long Li +M: Wei Hu F: drivers/net/netvsc/ F: doc/guides/nics/netvsc.rst F: doc/guides/nics/features/netvsc.ini -- 2.34.1
[PATCH v2 1/1] net/mana: add vlan tagging support
For tx path, use LONG_PACKET_FORMAT if vlan tag is present. For rx, extract vlan id from oob, put into mbuf and set the vlan flags in mbuf. Signed-off-by: Wei Hu --- v2: - Use existing vlan tag processing macros. - Add vlan header back if vlan_strip flag is not set on the receiving path. drivers/net/mana/mana.c | 3 +++ drivers/net/mana/mana.h | 4 drivers/net/mana/rx.c | 15 +++ drivers/net/mana/tx.c | 21 ++--- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c index 2df2461d2f..68c625258e 100644 --- a/drivers/net/mana/mana.c +++ b/drivers/net/mana/mana.c @@ -94,6 +94,9 @@ mana_dev_configure(struct rte_eth_dev *dev) return -EINVAL; } + priv->vlan_strip = !!(dev_conf->rxmode.offloads & + RTE_ETH_RX_OFFLOAD_VLAN_STRIP); + priv->num_queues = dev->data->nb_rx_queues; manadv_set_context_attr(priv->ib_ctx, MANADV_CTX_ATTR_BUF_ALLOCATORS, diff --git a/drivers/net/mana/mana.h b/drivers/net/mana/mana.h index 3626925871..37f654f0e6 100644 --- a/drivers/net/mana/mana.h +++ b/drivers/net/mana/mana.h @@ -21,10 +21,12 @@ struct mana_shared_data { #define MANA_MAX_MAC_ADDR 1 #define MANA_DEV_RX_OFFLOAD_SUPPORT ( \ + RTE_ETH_RX_OFFLOAD_VLAN_STRIP | \ RTE_ETH_RX_OFFLOAD_CHECKSUM | \ RTE_ETH_RX_OFFLOAD_RSS_HASH) #define MANA_DEV_TX_OFFLOAD_SUPPORT ( \ + RTE_ETH_TX_OFFLOAD_VLAN_INSERT | \ RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \ RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \ RTE_ETH_TX_OFFLOAD_TCP_CKSUM | \ @@ -345,6 +347,8 @@ struct mana_priv { /* IB device port */ uint8_t dev_port; + uint8_t vlan_strip; + struct ibv_context *ib_ctx; struct ibv_pd *ib_pd; struct ibv_pd *ib_parent_pd; diff --git a/drivers/net/mana/rx.c b/drivers/net/mana/rx.c index 16e647baf5..7f646fcee4 100644 --- a/drivers/net/mana/rx.c +++ b/drivers/net/mana/rx.c @@ -532,6 +532,21 @@ mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) mbuf->hash.rss = oob->packet_info[pkt_idx].packet_hash; } + if (oob->rx_vlan_tag_present) { + mbuf->ol_flags |= + RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED; + mbuf->vlan_tci = oob->rx_vlan_id; + + if (!priv->vlan_strip && rte_vlan_insert(&mbuf)) { + DRV_LOG(ERR, "vlan insert failed"); + rxq->stats.errors++; + rte_pktmbuf_free(mbuf); + + i++; + goto drop; + } + } + pkts[pkt_received++] = mbuf; rxq->stats.packets++; rxq->stats.bytes += mbuf->data_len; diff --git a/drivers/net/mana/tx.c b/drivers/net/mana/tx.c index 58c4a1d976..272a28bcba 100644 --- a/drivers/net/mana/tx.c +++ b/drivers/net/mana/tx.c @@ -254,7 +254,18 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) } /* Fill in the oob */ - tx_oob.short_oob.packet_format = SHORT_PACKET_FORMAT; + if (m_pkt->ol_flags & RTE_MBUF_F_TX_VLAN) { + tx_oob.short_oob.packet_format = LONG_PACKET_FORMAT; + tx_oob.long_oob.inject_vlan_prior_tag = 1; + tx_oob.long_oob.priority_code_point = + RTE_VLAN_TCI_PRI(m_pkt->vlan_tci); + tx_oob.long_oob.drop_eligible_indicator = + RTE_VLAN_TCI_DEI(m_pkt->vlan_tci); + tx_oob.long_oob.vlan_identifier = + RTE_VLAN_TCI_ID(m_pkt->vlan_tci); + } else { + tx_oob.short_oob.packet_format = SHORT_PACKET_FORMAT; + } tx_oob.short_oob.tx_is_outer_ipv4 = m_pkt->ol_flags & RTE_MBUF_F_TX_IPV4 ? 1 : 0; tx_oob.short_oob.tx_is_outer_ipv6 = @@ -409,8 +420,12 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) work_req.sgl = sgl.gdma_sgl; work_req.num_sgl_elements = m_pkt->nb_segs; - work_req.inline_oob_size_in_bytes = - sizeof(struct transmit_short_oob_v2); + if (tx_oob.short_oob.packet_format == SHORT_PACKET_FORMAT) + work_req.inline_oob_size_in_bytes = + sizeof(struct transmit_short_oob_v2); + else + work_req.inline_oob_size_in_bytes = +
[PATCH v3 1/1] net/mana: add vlan tagging support
For tx path, use LONG_PACKET_FORMAT if vlan tag is present. For rx, extract vlan id from oob, put into mbuf and set the vlan flags in mbuf. Signed-off-by: Wei Hu --- v3: - Adjust the pkt_idx position in the code so it will be executed even when adding vlan header fails. v2: - Use existing vlan tag processing macros. - Add vlan header back if vlan_strip flag is not set on the receiving path. drivers/net/mana/mana.c | 3 +++ drivers/net/mana/mana.h | 4 drivers/net/mana/rx.c | 22 ++ drivers/net/mana/tx.c | 21 ++--- 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c index 2df2461d2f..68c625258e 100644 --- a/drivers/net/mana/mana.c +++ b/drivers/net/mana/mana.c @@ -94,6 +94,9 @@ mana_dev_configure(struct rte_eth_dev *dev) return -EINVAL; } + priv->vlan_strip = !!(dev_conf->rxmode.offloads & + RTE_ETH_RX_OFFLOAD_VLAN_STRIP); + priv->num_queues = dev->data->nb_rx_queues; manadv_set_context_attr(priv->ib_ctx, MANADV_CTX_ATTR_BUF_ALLOCATORS, diff --git a/drivers/net/mana/mana.h b/drivers/net/mana/mana.h index 3626925871..37f654f0e6 100644 --- a/drivers/net/mana/mana.h +++ b/drivers/net/mana/mana.h @@ -21,10 +21,12 @@ struct mana_shared_data { #define MANA_MAX_MAC_ADDR 1 #define MANA_DEV_RX_OFFLOAD_SUPPORT ( \ + RTE_ETH_RX_OFFLOAD_VLAN_STRIP | \ RTE_ETH_RX_OFFLOAD_CHECKSUM | \ RTE_ETH_RX_OFFLOAD_RSS_HASH) #define MANA_DEV_TX_OFFLOAD_SUPPORT ( \ + RTE_ETH_TX_OFFLOAD_VLAN_INSERT | \ RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \ RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \ RTE_ETH_TX_OFFLOAD_TCP_CKSUM | \ @@ -345,6 +347,8 @@ struct mana_priv { /* IB device port */ uint8_t dev_port; + uint8_t vlan_strip; + struct ibv_context *ib_ctx; struct ibv_pd *ib_pd; struct ibv_pd *ib_parent_pd; diff --git a/drivers/net/mana/rx.c b/drivers/net/mana/rx.c index 16e647baf5..0c26702b73 100644 --- a/drivers/net/mana/rx.c +++ b/drivers/net/mana/rx.c @@ -532,10 +532,6 @@ mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) mbuf->hash.rss = oob->packet_info[pkt_idx].packet_hash; } - pkts[pkt_received++] = mbuf; - rxq->stats.packets++; - rxq->stats.bytes += mbuf->data_len; - pkt_idx++; /* Move on the next completion if all packets are processed */ if (pkt_idx >= RX_COM_OOB_NUM_PACKETINFO_SEGMENTS) { @@ -543,6 +539,24 @@ mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) i++; } + if (oob->rx_vlan_tag_present) { + mbuf->ol_flags |= + RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED; + mbuf->vlan_tci = oob->rx_vlan_id; + + if (!priv->vlan_strip && rte_vlan_insert(&mbuf)) { + DRV_LOG(ERR, "vlan insert failed"); + rxq->stats.errors++; + rte_pktmbuf_free(mbuf); + + goto drop; + } + } + + pkts[pkt_received++] = mbuf; + rxq->stats.packets++; + rxq->stats.bytes += mbuf->data_len; + drop: rxq->desc_ring_tail++; if (rxq->desc_ring_tail >= rxq->num_desc) diff --git a/drivers/net/mana/tx.c b/drivers/net/mana/tx.c index 58c4a1d976..272a28bcba 100644 --- a/drivers/net/mana/tx.c +++ b/drivers/net/mana/tx.c @@ -254,7 +254,18 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) } /* Fill in the oob */ - tx_oob.short_oob.packet_format = SHORT_PACKET_FORMAT; + if (m_pkt->ol_flags & RTE_MBUF_F_TX_VLAN) { + tx_oob.short_oob.packet_format = LONG_PACKET_FORMAT; + tx_oob.long_oob.inject_vlan_prior_tag = 1; + tx_oob.long_oob.priority_code_point = + RTE_VLAN_TCI_PRI(m_pkt->vlan_tci); + tx_oob.long_oob.drop_eligible_indicator = + RTE_VLAN_TCI_DEI(m_pkt->vlan_tci); + tx_oob.long_oob.vlan_identifier = + RTE_VLAN_TCI_ID(m_pkt->vlan_tci); + } else { + tx_oob.short_oob.packet_format = SHORT_PACKET_FORMAT; + } tx_oob.short_oob.tx_is_outer_ipv4 = m_pkt->ol_flags & RTE_MBUF_F_TX_IPV4 ? 1 : 0;
RE: [PATCH] bus/vmbus: remove unnecessary packed attribute
> -Original Message- > From: Stephen Hemminger > Sent: Tuesday, October 22, 2024 10:37 AM > To: dev@dpdk.org > Cc: Stephen Hemminger ; Long Li > ; Wei Hu > Subject: [PATCH] bus/vmbus: remove unnecessary packed attribute > > The VMBus ring structure was marked packed which will cause warnings if the > no-address-of-packed is enabled. The structure is all 32 bit values and the > packed attribute has no impact on the code layout; remove it. > > Signed-off-by: Stephen Hemminger > --- > drivers/bus/vmbus/rte_vmbus_reg.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/bus/vmbus/rte_vmbus_reg.h > b/drivers/bus/vmbus/rte_vmbus_reg.h > index e3299aa871..c4f2fa4c7e 100644 > --- a/drivers/bus/vmbus/rte_vmbus_reg.h > +++ b/drivers/bus/vmbus/rte_vmbus_reg.h > @@ -108,7 +108,7 @@ struct vmbus_bufring { >* !!! DO NOT place any fields below this !!! >*/ > uint8_t data[]; > -} __rte_packed; > +}; > > /* > * Channel packets > -- > 2.45.2 Reviewed-by: Wei Hu
[PATCH 1/1] net/mana: do not ring short doorbell for every mbuf allocation
In the 32bit rx path, it rings short doorbell after receiving one packet and alocating the new mbuf. This significantly impacets the rx performance. Fix this problem by ringing the short doorbell in batch. Fixes: eeb37809601b ("net/mana: use bulk mbuf allocation for Rx WQEs") Cc: sta...@dpdk.org Signed-off-by: Wei Hu --- drivers/net/mana/rx.c | 30 -- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/drivers/net/mana/rx.c b/drivers/net/mana/rx.c index 0c26702b73..f196d43aee 100644 --- a/drivers/net/mana/rx.c +++ b/drivers/net/mana/rx.c @@ -121,6 +121,10 @@ mana_alloc_and_post_rx_wqes(struct mana_rxq *rxq, uint32_t count) uint32_t i, batch_count; struct rte_mbuf *mbufs[MANA_MBUF_BULK]; +#ifdef RTE_ARCH_32 + rxq->wqe_cnt_to_short_db = 0; +#endif + more_mbufs: batch_count = RTE_MIN(count, MANA_MBUF_BULK); ret = rte_pktmbuf_alloc_bulk(rxq->mp, mbufs, batch_count); @@ -132,9 +136,6 @@ mana_alloc_and_post_rx_wqes(struct mana_rxq *rxq, uint32_t count) goto out; } -#ifdef RTE_ARCH_32 - rxq->wqe_cnt_to_short_db = 0; -#endif for (i = 0; i < batch_count; i++) { ret = mana_post_rx_wqe(rxq, mbufs[i]); if (ret) { @@ -448,10 +449,6 @@ mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) uint32_t i; int polled = 0; -#ifdef RTE_ARCH_32 - rxq->wqe_cnt_to_short_db = 0; -#endif - repoll: /* Polling on new completions if we have no backlog */ if (rxq->comp_buf_idx == rxq->comp_buf_len) { @@ -570,25 +567,6 @@ mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) wqe_consumed++; if (pkt_received == pkts_n) break; - -#ifdef RTE_ARCH_32 - /* Always post WQE as soon as it's consumed for short DB */ - ret = mana_alloc_and_post_rx_wqes(rxq, wqe_consumed); - if (ret) { - DRV_LOG(ERR, "failed to post %d WQEs, ret %d", - wqe_consumed, ret); - return pkt_received; - } - wqe_consumed = 0; - - /* Ring short doorbell if approaching the wqe increment -* limit. -*/ - if (rxq->wqe_cnt_to_short_db > RX_WQE_SHORT_DB_THRESHOLD) { - mana_rq_ring_doorbell(rxq); - rxq->wqe_cnt_to_short_db = 0; - } -#endif } rxq->backlog_idx = pkt_idx; -- 2.34.1
RE: [EXTERNAL] [PATCH] net/netvsc: add stats counters from VF
> -Original Message- > From: lon...@linuxonhyperv.com > Sent: Wednesday, February 19, 2025 5:13 AM > To: Stephen Hemminger ; Wei Hu > > Cc: dev@dpdk.org; Long Li ; sta...@dpdk.org > Subject: [EXTERNAL] [PATCH] net/netvsc: add stats counters from VF > > From: Long Li > > The netvsc driver should add per-queue and rx_nombuf counters from VF. > > Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device") > Cc: sta...@dpdk.org > Signed-off-by: Long Li > --- > drivers/net/netvsc/hn_ethdev.c | 10 +- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c > index 988c51928d..069d603d90 100644 > --- a/drivers/net/netvsc/hn_ethdev.c > +++ b/drivers/net/netvsc/hn_ethdev.c > @@ -824,8 +824,8 @@ static int hn_dev_stats_get(struct rte_eth_dev *dev, > stats->oerrors += txq->stats.errors; > > if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) { > - stats->q_opackets[i] = txq->stats.packets; > - stats->q_obytes[i] = txq->stats.bytes; > + stats->q_opackets[i] += txq->stats.packets; > + stats->q_obytes[i] += txq->stats.bytes; > } > } > > @@ -841,12 +841,12 @@ static int hn_dev_stats_get(struct rte_eth_dev > *dev, > stats->imissed += rxq->stats.ring_full; > > if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) { > - stats->q_ipackets[i] = rxq->stats.packets; > - stats->q_ibytes[i] = rxq->stats.bytes; > + stats->q_ipackets[i] += rxq->stats.packets; > + stats->q_ibytes[i] += rxq->stats.bytes; > } > } > > - stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed; > + stats->rx_nombuf += dev->data->rx_mbuf_alloc_failed; > return 0; > } > > -- > 2.34.1 Reviewed-by: Wei Hu
RE: [EXTERNAL] [Patch v2] net/mana: use mana_local_data for tracking usage data for primary process
> -Original Message- > From: lon...@linuxonhyperv.com > Sent: Wednesday, February 19, 2025 4:59 AM > To: Stephen Hemminger ; Wei Hu > > Cc: dev@dpdk.org; sta...@dpdk.org; Long Li > Subject: [EXTERNAL] [Patch v2] net/mana: use mana_local_data for tracking > usage data for primary process > > From: Long Li > > The driver uses mana_shared_data for tracking usage count for primary > process. This is not correct as the mana_shared_data is allocated by the > primary and is meant to track usage of secondary process by the primary > process. And it creates a race condition when the device is removed because > the counter is no longer available if this shared memory is freed. > > Move the usage count tracking to mana_local_data and fix the race condition > in mana_pci_remove(). > > Fixes: 517ed6e2d590 ("net/mana: add basic driver with build environment") > Signed-off-by: Long Li Reviewed-by: Wei Hu > --- > Changes: > v2: use atomic variable to track the secondary_cnt in shared memory, remove > the spinlock for shared memory > > drivers/net/mana/mana.c | 99 +++-- > drivers/net/mana/mana.h | 6 +-- > drivers/net/mana/mp.c | 2 +- > 3 files changed, 57 insertions(+), 50 deletions(-) > > diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c index > c37c4e3444..69cb7ab13f 100644 > --- a/drivers/net/mana/mana.c > +++ b/drivers/net/mana/mana.c > @@ -23,9 +23,14 @@ > #include "mana.h" > > /* Shared memory between primary/secondary processes, per driver */ > -/* Data to track primary/secondary usage */ struct mana_shared_data > *mana_shared_data; -static struct mana_shared_data mana_local_data; > + > +/* Local data to track device instance usage for primary/secondary > +processes */ static struct mana_local_data { > + int init_done; > + unsigned int primary_cnt; > + unsigned int secondary_cnt; > +} mana_local_data; > > /* The memory region for the above data */ static const struct rte_memzone > *mana_shared_mz; @@ -1167,8 +1172,12 @@ > mana_init_shared_data(void) > rte_spinlock_lock(&mana_shared_data_lock); > > /* Skip if shared data is already initialized */ > - if (mana_shared_data) > + if (mana_shared_data) { > + DRV_LOG(INFO, "shared data is already initialized"); > goto exit; > + } > + > + memset(&mana_local_data, 0, sizeof(mana_local_data)); > > if (rte_eal_process_type() == RTE_PROC_PRIMARY) { > mana_shared_mz = > rte_memzone_reserve(MZ_MANA_SHARED_DATA, > @@ -1181,8 +1190,7 @@ mana_init_shared_data(void) > } > > mana_shared_data = mana_shared_mz->addr; > - memset(mana_shared_data, 0, sizeof(*mana_shared_data)); > - rte_spinlock_init(&mana_shared_data->lock); > + rte_atomic32_set(&mana_shared_data->secondary_cnt, 0); > } else { > secondary_mz = > rte_memzone_lookup(MZ_MANA_SHARED_DATA); > if (!secondary_mz) { > @@ -1192,7 +1200,6 @@ mana_init_shared_data(void) > } > > mana_shared_data = secondary_mz->addr; > - memset(&mana_local_data, 0, sizeof(mana_local_data)); > } > > exit: > @@ -1213,11 +1220,11 @@ mana_init_once(void) > if (ret) > return ret; > > - rte_spinlock_lock(&mana_shared_data->lock); > + rte_spinlock_lock(&mana_shared_data_lock); > > switch (rte_eal_process_type()) { > case RTE_PROC_PRIMARY: > - if (mana_shared_data->init_done) > + if (mana_local_data.init_done) > break; > > ret = mana_mp_init_primary(); > @@ -1225,7 +1232,7 @@ mana_init_once(void) > break; > DRV_LOG(ERR, "MP INIT PRIMARY"); > > - mana_shared_data->init_done = 1; > + mana_local_data.init_done = 1; > break; > > case RTE_PROC_SECONDARY: > @@ -1248,7 +1255,7 @@ mana_init_once(void) > break; > } > > - rte_spinlock_unlock(&mana_shared_data->lock); > + rte_spinlock_unlock(&mana_shared_data_lock); > > return ret; > } > @@ -1319,11 +1326,6 @@ mana_probe_port(struct ibv_device *ibdev, > struct ibv_device_attr_ex *dev_attr, > eth_dev->tx_pkt_burst = mana_tx_burst; > eth_dev->rx_pkt_burst = mana_rx_burst; > > - rte_spinlock_lock(&mana_shared_data->lock); > - mana_shared_
Re: [dpdk-dev] [PATCH 2/9] net/hns3: get link state change through mailbox
Hi, Ferruh Yigit On 2019/12/3 21:19, Ferruh Yigit wrote: On 12/3/2019 1:16 PM, Ferruh Yigit wrote: On 12/2/2019 2:51 AM, Wei Hu (Xavier) wrote: From: Hongbo Zheng When link down occurs, firmware adds the function of sending message to PF driver through mailbox, hns3 PMD driver can recognize link state change faster through the message. Hi Xavier, As far as I can see the 'link_update' dev_ops (hns3_dev_link_update()), is just copying data from internal structure to "struct rte_eth_link". And you have timers set to regularly (ever second?) update the internal structure for link status. Instead, unless you are not using or need those status internally, you can pull the internal link status in the 'hns3_dev_link_update()', this way it can be possible to get rid of the timers. Also in current implementation, when used asked for the link status, it can be outdated regarding the status of the timers. In this patch, interrupt seems used to update the internal link status, this fixes the problem above that user is getting out of date link status. But instead of this, what do you think updating "struct rte_eth_link" too in the interrupt handler and advertising 'RTE_ETH_DEV_INTR_LSC' capability ("Link status event" feature in .ini file), so user can enable the lsc interrupt ('dev_conf.intr_conf.lsc') and gets the link status quicker because of the support in the API ('rte_eth_link_get')? Thanks, ferruh 'Wei Hu (Xavier) ' email address is failing, not sure what it is, adding the @huawei.com addresses. Sorry, there is something wrong for the email service: xavier.hu...@tom.com, Now I use the current mailbox that can provide relatively stable services as an alternative. Thanks, Xavier Signed-off-by: Hongbo Zheng Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 8 ++-- drivers/net/hns3/hns3_ethdev.h | 1 + drivers/net/hns3/hns3_mbx.c| 37 ++ drivers/net/hns3/hns3_mbx.h| 8 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index bf0ab458f..3c591be51 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -218,6 +218,8 @@ hns3_interrupt_handler(void *param) hns3_schedule_reset(hns); } else if (event_cause == HNS3_VECTOR0_EVENT_RST) hns3_schedule_reset(hns); + else if (event_cause == HNS3_VECTOR0_EVENT_MBX) + hns3_dev_handle_mbx_msg(hw); else hns3_err(hw, "Received unknown event"); @@ -3806,14 +3808,16 @@ hns3_get_mac_link_status(struct hns3_hw *hw) return !!link_status; } -static void +void hns3_update_link_status(struct hns3_hw *hw) { int state; state = hns3_get_mac_link_status(hw); - if (state != hw->mac.link_status) + if (state != hw->mac.link_status) { hw->mac.link_status = state; + hns3_warn(hw, "Link status change to %s!", state ? "up" : "down"); + } } static void diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index e9a3fe410..004cd75a9 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -631,6 +631,7 @@ int hns3_dev_filter_ctrl(struct rte_eth_dev *dev, enum rte_filter_op filter_op, void *arg); bool hns3_is_reset_pending(struct hns3_adapter *hns); bool hns3vf_is_reset_pending(struct hns3_adapter *hns); +void hns3_update_link_status(struct hns3_hw *hw); static inline bool is_reset_pending(struct hns3_adapter *hns) diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c index c1647af4b..26807bc4b 100644 --- a/drivers/net/hns3/hns3_mbx.c +++ b/drivers/net/hns3/hns3_mbx.c @@ -282,6 +282,40 @@ hns3_update_resp_position(struct hns3_hw *hw, uint32_t resp_msg) resp->tail = tail; } +static void +hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) +{ + switch (link_fail_code) { + case HNS3_MBX_LF_NORMAL: + break; + case HNS3_MBX_LF_REF_CLOCK_LOST: + hns3_warn(hw, "Reference clock lost!"); + break; + case HNS3_MBX_LF_XSFP_TX_DISABLE: + hns3_warn(hw, "SFP tx is disabled!"); + break; + case HNS3_MBX_LF_XSFP_ABSENT: + hns3_warn(hw, "SFP is absent!"); + break; + default: + hns3_warn(hw, "Unknown fail code:%u!", link_fail_code); + break; + } +} + +static void +hns3_handle_link_change_event(struct hns3_hw *hw, + struct hns3_mbx_pf_to_vf_cmd *req) +{ +#define LINK_STATUS_OFFSET 1 +#define LINK_FAIL_CODE_OFFSET 2 + + if (
Re: [dpdk-dev] [PATCH 2/9] net/hns3: get link state change through mailbox
Hi, Ferruh Yigit On 2019/12/3 21:16, Ferruh Yigit wrote: On 12/2/2019 2:51 AM, Wei Hu (Xavier) wrote: From: Hongbo Zheng When link down occurs, firmware adds the function of sending message to PF driver through mailbox, hns3 PMD driver can recognize link state change faster through the message. Hi Xavier, As far as I can see the 'link_update' dev_ops (hns3_dev_link_update()), is just copying data from internal structure to "struct rte_eth_link". And you have timers set to regularly (ever second?) update the internal structure for link status. Instead, unless you are not using or need those status internally, you can pull the internal link status in the 'hns3_dev_link_update()', this way it can be possible to get rid of the timers. Also in current implementation, when used asked for the link status, it can be outdated regarding the status of the timers. We will use the internal link status in the driver, the relevent patch will be sent later. In this patch, interrupt seems used to update the internal link status, this fixes the problem above that user is getting out of date link status. But instead of this, what do you think updating "struct rte_eth_link" too in the interrupt handler and advertising 'RTE_ETH_DEV_INTR_LSC' capability ("Link status event" feature in .ini file), so user can enable the lsc interrupt ('dev_conf.intr_conf.lsc') and gets the link status quicker because of the support in the API ('rte_eth_link_get')? Currently, firmware adds the function of sending message to PF driver through mailbox when the link status is changed, hns3 PMD driver can usually recognize link state change faster through the message. And in some extreme cases, this way is not faster than existing method regularly updating link status by issing the command every second in PF driver, because of the parallel processing of mailbox and command messages in firmware. So we reserve updating link status using timers in PF driver and don't advertising 'RTE_ETH_DEV_INTR_LSC' capability. And we will add querying link status by issuing command to the firmware in '.link_update' ops implementation function named hns3_dev_link_update to solve the out of date link status in patch V2. Thanks, Xavier Thanks, ferruh Signed-off-by: Hongbo Zheng Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 8 ++-- drivers/net/hns3/hns3_ethdev.h | 1 + drivers/net/hns3/hns3_mbx.c| 37 ++ drivers/net/hns3/hns3_mbx.h| 8 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index bf0ab458f..3c591be51 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -218,6 +218,8 @@ hns3_interrupt_handler(void *param) hns3_schedule_reset(hns); } else if (event_cause == HNS3_VECTOR0_EVENT_RST) hns3_schedule_reset(hns); + else if (event_cause == HNS3_VECTOR0_EVENT_MBX) + hns3_dev_handle_mbx_msg(hw); else hns3_err(hw, "Received unknown event"); @@ -3806,14 +3808,16 @@ hns3_get_mac_link_status(struct hns3_hw *hw) return !!link_status; } -static void +void hns3_update_link_status(struct hns3_hw *hw) { int state; state = hns3_get_mac_link_status(hw); - if (state != hw->mac.link_status) + if (state != hw->mac.link_status) { hw->mac.link_status = state; + hns3_warn(hw, "Link status change to %s!", state ? "up" : "down"); + } } static void diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index e9a3fe410..004cd75a9 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -631,6 +631,7 @@ int hns3_dev_filter_ctrl(struct rte_eth_dev *dev, enum rte_filter_op filter_op, void *arg); bool hns3_is_reset_pending(struct hns3_adapter *hns); bool hns3vf_is_reset_pending(struct hns3_adapter *hns); +void hns3_update_link_status(struct hns3_hw *hw); static inline bool is_reset_pending(struct hns3_adapter *hns) diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c index c1647af4b..26807bc4b 100644 --- a/drivers/net/hns3/hns3_mbx.c +++ b/drivers/net/hns3/hns3_mbx.c @@ -282,6 +282,40 @@ hns3_update_resp_position(struct hns3_hw *hw, uint32_t resp_msg) resp->tail = tail; } +static void +hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) +{ + switch (link_fail_code) { + case HNS3_MBX_LF_NORMAL: + break; + case HNS3_MBX_LF_REF_CLOCK_LOST: + hns3_warn(hw, "Reference clock lost!"); + break; + case HNS3_MBX_LF_XSFP_TX_D
[dpdk-dev] [PATCH v2 5/9] net/hns3: optimize RSS's default algorithm
From: Hao Chen This patch changed the default algorithm of RSS from simle_xor to toeplitz because toeplitz is used more frequently by upper applications such as ceph. Signed-off-by: Hao Chen Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_rss.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index b8c20e6d9..dfc42f840 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -211,7 +211,11 @@ hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, req->ipv6_fragment_en |= HNS3_IP_OTHER_BIT_MASK; break; default: - /* Other unsupported flow types won't change tuples */ + /* +* rss_hf doesn't include unsupported flow types +* because the API framework has checked it, and +* this branch will never go unless rss_hf is zero. +*/ break; } } @@ -251,8 +255,8 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, struct hns3_hw *hw = &hns->hw; struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets; struct hns3_rss_conf *rss_cfg = &hw->rss_info; - uint8_t algo = rss_cfg->conf.func; uint8_t key_len = rss_conf->rss_key_len; + uint8_t algo; uint64_t rss_hf = rss_conf->rss_hf; uint8_t *key = rss_conf->rss_key; int ret; @@ -285,6 +289,8 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, ret = -EINVAL; goto conf_err; } + algo = rss_cfg->conf.func == RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ? + HNS3_RSS_HASH_ALGO_SIMPLE : HNS3_RSS_HASH_ALGO_TOEPLITZ; ret = hns3_set_rss_algo_key(hw, algo, key); if (ret) goto conf_err; @@ -500,7 +506,9 @@ hns3_set_default_rss_args(struct hns3_hw *hw) int i; /* Default hash algorithm */ - rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; + rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; + + /* Default RSS key */ memcpy(rss_cfg->key, hns3_hash_key, HNS3_RSS_KEY_SIZE); /* Initialize RSS indirection table */ -- 2.23.0
[dpdk-dev] [PATCH v2 4/9] net/hns3: modify custom macro
From: Huisong Li This patch replaces custom macro named HNS3_MIN_FRAME_LEN for ethernet minimum frame length with the macro named RTE_ETHER_MIN_LEN that defined in dpdk framework. Signed-off-by: Huisong Li Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 2 +- drivers/net/hns3/hns3_ethdev.h | 1 - drivers/net/hns3/hns3_rxtx.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 5795b3b34..981e05b61 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2148,7 +2148,7 @@ hns3_set_mac_mtu(struct hns3_hw *hw, uint16_t new_mps) req = (struct hns3_config_max_frm_size_cmd *)desc.data; req->max_frm_size = rte_cpu_to_le_16(new_mps); - req->min_frm_size = HNS3_MIN_FRAME_LEN; + req->min_frm_size = RTE_ETHER_MIN_LEN; return hns3_cmd_send(hw, &desc, 1); } diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 004cd75a9..7422706a8 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -33,7 +33,6 @@ #define HNS3_MAX_BD_SIZE 65535 #define HNS3_MAX_TX_BD_PER_PKT 8 #define HNS3_MAX_FRAME_LEN 9728 -#define HNS3_MIN_FRAME_LEN 64 #define HNS3_VLAN_TAG_SIZE 4 #define HNS3_DEFAULT_RX_BUF_LEN2048 diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index e7f0c8fc9..0090cda31 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -1561,7 +1561,7 @@ hns3_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, m = tx_pkts[i]; /* check the size of packet */ - if (m->pkt_len < HNS3_MIN_FRAME_LEN) { + if (m->pkt_len < RTE_ETHER_MIN_LEN) { rte_errno = EINVAL; return i; } -- 2.23.0
[dpdk-dev] [PATCH v2 8/9] net/hns3: remove the unnecessary assignment
From: "Wei Hu (Xavier)" This patch removes the unncessary assignment in hns3_xmit_pkts function to avoid performance loss. Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_rxtx.c | 5 - 1 file changed, 5 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 0090cda31..18c07b85e 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -1612,7 +1612,6 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) struct rte_mbuf *m_seg; struct rte_mbuf *temp; uint32_t nb_hold = 0; - uint16_t tx_next_clean; uint16_t tx_next_use; uint16_t tx_bd_ready; uint16_t tx_pkt_num; @@ -1627,11 +1626,8 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) if (tx_bd_ready == 0) return 0; - tx_next_clean = txq->next_to_clean; tx_next_use = txq->next_to_use; tx_bd_max = txq->nb_tx_desc; - tx_bak_pkt = &txq->sw_ring[tx_next_clean]; - tx_pkt_num = (tx_bd_ready < nb_pkts) ? tx_bd_ready : nb_pkts; /* send packets */ @@ -1707,7 +1703,6 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) if (likely(nb_tx)) { hns3_queue_xmit(txq, nb_hold); - txq->next_to_clean = tx_next_clean; txq->tx_bd_ready = tx_bd_ready - nb_hold; } -- 2.23.0
[dpdk-dev] [PATCH v2 1/9] net/hns3: support Rx interrupt
From: Hao Chen This patch supports of receive packets through interrupt mode for hns3 PF/VF driver. The following ops functions should be implemented defined in struct eth_dev_ops: rx_queue_intr_enable rx_queue_intr_disable rx_queue_count Signed-off-by: Hao Chen Signed-off-by: Wei Hu (Xavier) --- doc/guides/nics/features/hns3.ini| 1 + doc/guides/nics/features/hns3_vf.ini | 1 + drivers/net/hns3/hns3_cmd.h | 28 + drivers/net/hns3/hns3_ethdev.c | 160 -- drivers/net/hns3/hns3_ethdev_vf.c| 166 --- drivers/net/hns3/hns3_mbx.h | 13 +++ drivers/net/hns3/hns3_regs.h | 3 + drivers/net/hns3/hns3_rxtx.c | 51 drivers/net/hns3/hns3_rxtx.h | 4 + 9 files changed, 405 insertions(+), 22 deletions(-) diff --git a/doc/guides/nics/features/hns3.ini b/doc/guides/nics/features/hns3.ini index 6df789ed1..cd5c08a9d 100644 --- a/doc/guides/nics/features/hns3.ini +++ b/doc/guides/nics/features/hns3.ini @@ -5,6 +5,7 @@ ; [Features] Link status = Y +Rx interrupt = Y MTU update = Y Jumbo frame = Y Promiscuous mode = Y diff --git a/doc/guides/nics/features/hns3_vf.ini b/doc/guides/nics/features/hns3_vf.ini index 41497c4c2..fd00ac3e2 100644 --- a/doc/guides/nics/features/hns3_vf.ini +++ b/doc/guides/nics/features/hns3_vf.ini @@ -5,6 +5,7 @@ ; [Features] Link status = Y +Rx interrupt = Y MTU update = Y Jumbo frame = Y Unicast MAC filter = Y diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h index be0ecbe86..897dc1420 100644 --- a/drivers/net/hns3/hns3_cmd.h +++ b/drivers/net/hns3/hns3_cmd.h @@ -209,6 +209,10 @@ enum hns3_opcode_type { /* SFP command */ HNS3_OPC_SFP_GET_SPEED = 0x7104, + /* Interrupts commands */ + HNS3_OPC_ADD_RING_TO_VECTOR = 0x1503, + HNS3_OPC_DEL_RING_TO_VECTOR = 0x1504, + /* Error INT commands */ HNS3_QUERY_MSIX_INT_STS_BD_NUM = 0x1513, HNS3_QUERY_CLEAR_ALL_MPF_MSIX_INT = 0x1514, @@ -673,6 +677,30 @@ struct hns3_tqp_map_cmd { uint8_t rsv[18]; }; +#define HNS3_RING_TYPE_B 0 +#define HNS3_RING_TYPE_TX 0 +#define HNS3_RING_TYPE_RX 1 +#define HNS3_RING_GL_IDX_S 0 +#define HNS3_RING_GL_IDX_M GENMASK(1, 0) +#define HNS3_RING_GL_RX0 +#define HNS3_RING_GL_TX1 + +#define HNS3_VECTOR_ELEMENTS_PER_CMD 10 + +#define HNS3_INT_TYPE_S0 +#define HNS3_INT_TYPE_MGENMASK(1, 0) +#define HNS3_TQP_ID_S 2 +#define HNS3_TQP_ID_M GENMASK(12, 2) +#define HNS3_INT_GL_IDX_S 13 +#define HNS3_INT_GL_IDX_M GENMASK(14, 13) +struct hns3_ctrl_vector_chain_cmd { + uint8_t int_vector_id; + uint8_t int_cause_num; + uint16_t tqp_type_and_id[HNS3_VECTOR_ELEMENTS_PER_CMD]; + uint8_t vfid; + uint8_t rsv; +}; + struct hns3_config_max_frm_size_cmd { uint16_t max_frm_size; uint8_t min_frm_size; diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 72315718a..bf0ab458f 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2021,6 +2021,40 @@ hns3_check_dcb_cfg(struct rte_eth_dev *dev) return hns3_check_mq_mode(dev); } +static int +hns3_bind_ring_with_vector(struct rte_eth_dev *dev, uint8_t vector_id, + bool mmap, uint16_t queue_id) +{ + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct hns3_cmd_desc desc; + struct hns3_ctrl_vector_chain_cmd *req = + (struct hns3_ctrl_vector_chain_cmd *)desc.data; + enum hns3_cmd_status status; + enum hns3_opcode_type op; + uint16_t tqp_type_and_id = 0; + + op = mmap ? HNS3_OPC_ADD_RING_TO_VECTOR : HNS3_OPC_DEL_RING_TO_VECTOR; + hns3_cmd_setup_basic_desc(&desc, op, false); + req->int_vector_id = vector_id; + + hns3_set_field(tqp_type_and_id, HNS3_INT_TYPE_M, HNS3_INT_TYPE_S, + HNS3_RING_TYPE_RX); + hns3_set_field(tqp_type_and_id, HNS3_TQP_ID_M, HNS3_TQP_ID_S, queue_id); + hns3_set_field(tqp_type_and_id, HNS3_INT_GL_IDX_M, HNS3_INT_GL_IDX_S, + HNS3_RING_GL_RX); + req->tqp_type_and_id[0] = rte_cpu_to_le_16(tqp_type_and_id); + + req->int_cause_num = 1; + status = hns3_cmd_send(hw, &desc, 1); + if (status) { + hns3_err(hw, "Map TQP %d fail, vector_id is %d, status is %d.", +queue_id, vector_id, status); + return -EIO; + } + + return 0; +} + static int hns3_dev_configure(struct rte_eth_dev *dev) { @@ -4020,15 +4054,83 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue) } static int -hns3_dev_start(struct rte_eth_dev *eth_dev) +hns3_map_rx_
[dpdk-dev] [PATCH v2 2/9] net/hns3: get link state change through mailbox
From: Hongbo Zheng Currently, firmware adds the function of sending message to PF driver through mailbox when the link status is changed, hns3 PMD driver can usually recognize link state change faster through the message. And in some extreme cases, this way is not faster than existing method regularly updating link status by issing the command every second in PF driver, because of the parallel processing of mailbox and command messages in firmware. So we reserve updating link status using timers in PF driver, and add querying link status by issuing command to the firmware in '.link_update' ops implementation function named hns3_dev_link_update to solve the out of date link status. Signed-off-by: Hongbo Zheng Signed-off-by: Wei Hu (Xavier) Signed-off-by: Huisong Li --- v1 -> v2: 1.Add querying link status by issuing command to the firmware in '.link_update' ops implementation function named hns3_dev_link_update to solve the out of date link status. --- drivers/net/hns3/hns3_ethdev.c | 14 +++-- drivers/net/hns3/hns3_ethdev.h | 1 + drivers/net/hns3/hns3_mbx.c| 37 ++ drivers/net/hns3/hns3_mbx.h| 8 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index bf0ab458f..5795b3b34 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -77,6 +77,7 @@ static enum hns3_reset_level hns3_get_reset_level(struct hns3_adapter *hns, static int hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); static int hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on); +static int hns3_update_speed_duplex(struct rte_eth_dev *eth_dev); static void hns3_pf_disable_irq0(struct hns3_hw *hw) @@ -218,6 +219,8 @@ hns3_interrupt_handler(void *param) hns3_schedule_reset(hns); } else if (event_cause == HNS3_VECTOR0_EVENT_RST) hns3_schedule_reset(hns); + else if (event_cause == HNS3_VECTOR0_EVENT_MBX) + hns3_dev_handle_mbx_msg(hw); else hns3_err(hw, "Received unknown event"); @@ -2302,6 +2305,11 @@ hns3_dev_link_update(struct rte_eth_dev *eth_dev, struct hns3_mac *mac = &hw->mac; struct rte_eth_link new_link; + if (!hns3_is_reset_pending(hns)) { + hns3_update_speed_duplex(eth_dev); + hns3_update_link_status(hw); + } + memset(&new_link, 0, sizeof(new_link)); switch (mac->link_speed) { case ETH_SPEED_NUM_10M: @@ -3806,14 +3814,16 @@ hns3_get_mac_link_status(struct hns3_hw *hw) return !!link_status; } -static void +void hns3_update_link_status(struct hns3_hw *hw) { int state; state = hns3_get_mac_link_status(hw); - if (state != hw->mac.link_status) + if (state != hw->mac.link_status) { hw->mac.link_status = state; + hns3_warn(hw, "Link status change to %s!", state ? "up" : "down"); + } } static void diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index e9a3fe410..004cd75a9 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -631,6 +631,7 @@ int hns3_dev_filter_ctrl(struct rte_eth_dev *dev, enum rte_filter_op filter_op, void *arg); bool hns3_is_reset_pending(struct hns3_adapter *hns); bool hns3vf_is_reset_pending(struct hns3_adapter *hns); +void hns3_update_link_status(struct hns3_hw *hw); static inline bool is_reset_pending(struct hns3_adapter *hns) diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c index c1647af4b..26807bc4b 100644 --- a/drivers/net/hns3/hns3_mbx.c +++ b/drivers/net/hns3/hns3_mbx.c @@ -282,6 +282,40 @@ hns3_update_resp_position(struct hns3_hw *hw, uint32_t resp_msg) resp->tail = tail; } +static void +hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) +{ + switch (link_fail_code) { + case HNS3_MBX_LF_NORMAL: + break; + case HNS3_MBX_LF_REF_CLOCK_LOST: + hns3_warn(hw, "Reference clock lost!"); + break; + case HNS3_MBX_LF_XSFP_TX_DISABLE: + hns3_warn(hw, "SFP tx is disabled!"); + break; + case HNS3_MBX_LF_XSFP_ABSENT: + hns3_warn(hw, "SFP is absent!"); + break; + default: + hns3_warn(hw, "Unknown fail code:%u!", link_fail_code); + break; + } +} + +static void +hns3_handle_link_change_event(struct hns3_hw *hw, + struct hns3_mbx_pf_to_vf_cmd *req) +{ +#define LINK_STATUS_OFFSET 1 +#define LINK_FAIL_CODE_OFFSET 2 + + if (!req->msg[LINK_STATUS_O
[dpdk-dev] [PATCH v2 3/9] net/hns3: modify the return value of enable msix
From: "Wei Hu (Xavier)" This patch replaces the return value "-1" with "-ENXIO". Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev_vf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 9b6bc83e4..781374c82 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -131,7 +131,7 @@ hns3vf_enable_msix(const struct rte_pci_device *device, bool op) (pos + PCI_MSIX_FLAGS)); return 0; } - return -1; + return -ENXIO; } static int -- 2.23.0
[dpdk-dev] [PATCH v2 7/9] net/hns3: remove the redundant variable initialization
From: "Wei Hu (Xavier)" This patch removes the redundant initialization of the variable named ret. Signed-off-by: Hongbo Zheng Signed-off-by: Hao Chen Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c| 10 +- drivers/net/hns3/hns3_ethdev_vf.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 981e05b61..a675c2064 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -3597,7 +3597,7 @@ hns3_dev_promiscuous_enable(struct rte_eth_dev *dev) struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; bool en_mc_pmc = (dev->data->all_multicast == 1) ? true : false; - int ret = 0; + int ret; rte_spinlock_lock(&hw->lock); ret = hns3_set_promisc_mode(hw, true, en_mc_pmc); @@ -3614,7 +3614,7 @@ hns3_dev_promiscuous_disable(struct rte_eth_dev *dev) struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; bool en_mc_pmc = (dev->data->all_multicast == 1) ? true : false; - int ret = 0; + int ret; /* If now in all_multicast mode, must remain in all_multicast mode. */ rte_spinlock_lock(&hw->lock); @@ -3632,7 +3632,7 @@ hns3_dev_allmulticast_enable(struct rte_eth_dev *dev) struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; bool en_uc_pmc = (dev->data->promiscuous == 1) ? true : false; - int ret = 0; + int ret; rte_spinlock_lock(&hw->lock); ret = hns3_set_promisc_mode(hw, en_uc_pmc, true); @@ -3649,7 +3649,7 @@ hns3_dev_allmulticast_disable(struct rte_eth_dev *dev) struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; bool en_uc_pmc = (dev->data->promiscuous == 1) ? true : false; - int ret = 0; + int ret; /* If now in promiscuous mode, must remain in all_multicast mode. */ if (dev->data->promiscuous == 1) @@ -4135,7 +4135,7 @@ hns3_dev_start(struct rte_eth_dev *dev) { struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; - int ret = 0; + int ret; PMD_INIT_FUNC_TRACE(); if (rte_atomic16_read(&hw->reset.resetting)) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 46d3efad0..45e061d96 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1465,7 +1465,7 @@ hns3vf_dev_start(struct rte_eth_dev *dev) { struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; - int ret = 0; + int ret; PMD_INIT_FUNC_TRACE(); if (rte_atomic16_read(&hw->reset.resetting)) -- 2.23.0
[dpdk-dev] [PATCH v2 0/9] updates for hns3 PMD driver
This series are updates for hns3 ethernet PMD driver. v1 -> v2: There are changes in the No.02 patch, and the other patches are not updated. Hao Chen (4): net/hns3: support Rx interrupt net/hns3: optimize RSS's default algorithm net/hns3: remove the redundant function call net/hns3: remove the unused macros Hongbo Zheng (1): net/hns3: get link state change through mailbox Huisong Li (1): net/hns3: modify custom macro Wei Hu (Xavier) (3): net/hns3: modify the return value of enable msix net/hns3: remove the redundant variable initialization net/hns3: remove the unnecessary assignment doc/guides/nics/features/hns3.ini| 1 + doc/guides/nics/features/hns3_vf.ini | 1 + drivers/net/hns3/hns3_cmd.h | 28 + drivers/net/hns3/hns3_ethdev.c | 182 --- drivers/net/hns3/hns3_ethdev.h | 2 +- drivers/net/hns3/hns3_ethdev_vf.c| 167 +--- drivers/net/hns3/hns3_mbx.c | 37 ++ drivers/net/hns3/hns3_mbx.h | 21 drivers/net/hns3/hns3_regs.h | 3 + drivers/net/hns3/hns3_rss.c | 14 ++- drivers/net/hns3/hns3_rss.h | 10 -- drivers/net/hns3/hns3_rxtx.c | 58 - drivers/net/hns3/hns3_rxtx.h | 4 + 13 files changed, 479 insertions(+), 49 deletions(-) -- 2.23.0
[dpdk-dev] [PATCH v2 6/9] net/hns3: remove the redundant function call
From: Hao Chen This patch removes the redundant statement calling hns3_stats_reset() to clear statistical information explicitly in the initialization of VF device, because hardware has been reseted by FLR in the initialization and the initial hardware and software statistics values are 0. Signed-off-by: Hao Chen Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev_vf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 781374c82..46d3efad0 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1167,7 +1167,6 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) hns3_set_default_rss_args(hw); - (void)hns3_stats_reset(eth_dev); return 0; err_get_config: -- 2.23.0
[dpdk-dev] [PATCH v2 9/9] net/hns3: remove the unused macros
From: Hao Chen This patch removed some unused macros defined in hns3_rss.h, these macros are used to set tuples for abandoned RTE_ETH_FILTER_HASH in hns3_dev_filter_ctrl(). Signed-off-by: Hao Chen Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_rss.h | 10 -- 1 file changed, 10 deletions(-) diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h index 7ffc15131..725970f89 100644 --- a/drivers/net/hns3/hns3_rss.h +++ b/drivers/net/hns3/hns3_rss.h @@ -27,7 +27,6 @@ #define HNS3_RSS_HASH_ALGO_TOEPLITZ0 #define HNS3_RSS_HASH_ALGO_SIMPLE 1 -#define HNS3_RSS_HASH_ALGO_SYMMETRIC 2 #define HNS3_RSS_HASH_ALGO_MASK0xf #define HNS3_RSS_INPUT_TUPLE_OTHER GENMASK(3, 0) @@ -56,15 +55,6 @@ struct hns3_rss_conf { uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */ }; -/* Bit 8 ~Bit 15 */ -#define HNS3_INSET_IPV4_SRC0x0100UL -#define HNS3_INSET_IPV4_DST0x0200UL -#define HNS3_INSET_IPV6_SRC0x0400UL -#define HNS3_INSET_IPV6_DST0x0800UL -#define HNS3_INSET_SRC_PORT0x1000UL -#define HNS3_INSET_DST_PORT0x2000UL -#define HNS3_INSET_SCTP_VT 0x4000UL - #ifndef ilog2 static inline int rss_ilog2(uint32_t x) { -- 2.23.0
[dpdk-dev] [PATCH v3 3/9] net/hns3: modify the return value of enable msix
From: "Wei Hu (Xavier)" This patch replaces the return value "-1" with "-ENXIO". Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev_vf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index bd52e199b..b5f3e9a86 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -131,7 +131,7 @@ hns3vf_enable_msix(const struct rte_pci_device *device, bool op) (pos + PCI_MSIX_FLAGS)); return 0; } - return -1; + return -ENXIO; } static int -- 2.23.0
[dpdk-dev] [PATCH v3 0/9] updates for hns3 PMD driver
This series are updates for hns3 ethernet PMD driver. Hao Chen (4): net/hns3: support Rx interrupt net/hns3: optimize RSS's default algorithm net/hns3: remove the redundant function call net/hns3: remove the unused macros Hongbo Zheng (1): net/hns3: get link state change through mailbox Huisong Li (1): net/hns3: modify custom macro Wei Hu (Xavier) (3): net/hns3: modify the return value of enable msix net/hns3: remove the redundant variable initialization net/hns3: remove the unnecessary assignment doc/guides/nics/features/hns3.ini| 1 + doc/guides/nics/features/hns3_vf.ini | 1 + drivers/net/hns3/hns3_cmd.h | 28 + drivers/net/hns3/hns3_ethdev.c | 181 --- drivers/net/hns3/hns3_ethdev.h | 2 +- drivers/net/hns3/hns3_ethdev_vf.c| 166 +--- drivers/net/hns3/hns3_mbx.c | 37 ++ drivers/net/hns3/hns3_mbx.h | 21 drivers/net/hns3/hns3_regs.h | 3 + drivers/net/hns3/hns3_rss.c | 14 ++- drivers/net/hns3/hns3_rss.h | 10 -- drivers/net/hns3/hns3_rxtx.c | 55 ++-- drivers/net/hns3/hns3_rxtx.h | 3 + 13 files changed, 468 insertions(+), 54 deletions(-) -- 2.23.0
[dpdk-dev] [PATCH v3 2/9] net/hns3: get link state change through mailbox
From: Hongbo Zheng Currently, firmware adds the function of sending message to PF driver through mailbox when the link status is changed, hns3 PMD driver can usually recognize link state change faster through the message. And in some extreme cases, this way is not faster than existing method regularly updating link status by issing the command every second in PF driver, because of the parallel processing of mailbox and command messages in firmware. So we reserve updating link status using timers in PF driver, and add querying link status by issuing command to the firmware in '.link_update' ops implementation function named hns3_dev_link_update to solve the out of date link status. Signed-off-by: Hongbo Zheng Signed-off-by: Wei Hu (Xavier) Signed-off-by: Huisong Li --- v2 -> v3: 1.No change. v1 -> v2: 1.Add querying link status by issuing command to the firmware in '.link_update' ops implementation function named hns3_dev_link_update to solve the out of date link status. --- drivers/net/hns3/hns3_ethdev.c | 14 +++-- drivers/net/hns3/hns3_ethdev.h | 1 + drivers/net/hns3/hns3_mbx.c| 37 ++ drivers/net/hns3/hns3_mbx.h| 8 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 8243ade21..fa0af847a 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -77,6 +77,7 @@ static enum hns3_reset_level hns3_get_reset_level(struct hns3_adapter *hns, static int hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); static int hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on); +static int hns3_update_speed_duplex(struct rte_eth_dev *eth_dev); static void hns3_pf_disable_irq0(struct hns3_hw *hw) @@ -218,6 +219,8 @@ hns3_interrupt_handler(void *param) hns3_schedule_reset(hns); } else if (event_cause == HNS3_VECTOR0_EVENT_RST) hns3_schedule_reset(hns); + else if (event_cause == HNS3_VECTOR0_EVENT_MBX) + hns3_dev_handle_mbx_msg(hw); else hns3_err(hw, "Received unknown event"); @@ -2302,6 +2305,11 @@ hns3_dev_link_update(struct rte_eth_dev *eth_dev, struct hns3_mac *mac = &hw->mac; struct rte_eth_link new_link; + if (!hns3_is_reset_pending(hns)) { + hns3_update_speed_duplex(eth_dev); + hns3_update_link_status(hw); + } + memset(&new_link, 0, sizeof(new_link)); switch (mac->link_speed) { case ETH_SPEED_NUM_10M: @@ -3806,14 +3814,16 @@ hns3_get_mac_link_status(struct hns3_hw *hw) return !!link_status; } -static void +void hns3_update_link_status(struct hns3_hw *hw) { int state; state = hns3_get_mac_link_status(hw); - if (state != hw->mac.link_status) + if (state != hw->mac.link_status) { hw->mac.link_status = state; + hns3_warn(hw, "Link status change to %s!", state ? "up" : "down"); + } } static void diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index e9a3fe410..004cd75a9 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -631,6 +631,7 @@ int hns3_dev_filter_ctrl(struct rte_eth_dev *dev, enum rte_filter_op filter_op, void *arg); bool hns3_is_reset_pending(struct hns3_adapter *hns); bool hns3vf_is_reset_pending(struct hns3_adapter *hns); +void hns3_update_link_status(struct hns3_hw *hw); static inline bool is_reset_pending(struct hns3_adapter *hns) diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c index c1647af4b..26807bc4b 100644 --- a/drivers/net/hns3/hns3_mbx.c +++ b/drivers/net/hns3/hns3_mbx.c @@ -282,6 +282,40 @@ hns3_update_resp_position(struct hns3_hw *hw, uint32_t resp_msg) resp->tail = tail; } +static void +hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) +{ + switch (link_fail_code) { + case HNS3_MBX_LF_NORMAL: + break; + case HNS3_MBX_LF_REF_CLOCK_LOST: + hns3_warn(hw, "Reference clock lost!"); + break; + case HNS3_MBX_LF_XSFP_TX_DISABLE: + hns3_warn(hw, "SFP tx is disabled!"); + break; + case HNS3_MBX_LF_XSFP_ABSENT: + hns3_warn(hw, "SFP is absent!"); + break; + default: + hns3_warn(hw, "Unknown fail code:%u!", link_fail_code); + break; + } +} + +static void +hns3_handle_link_change_event(struct hns3_hw *hw, + struct hns3_mbx_pf_to_vf_cmd *req) +{ +#define LINK_STATUS_OFFSET 1 +#define LINK_FAIL
[dpdk-dev] [PATCH v3 9/9] net/hns3: remove the unused macros
From: Hao Chen This patch removed some unused macros defined in hns3_rss.h, these macros are used to set tuples for abandoned RTE_ETH_FILTER_HASH in hns3_dev_filter_ctrl(). Signed-off-by: Hao Chen Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_rss.h | 10 -- 1 file changed, 10 deletions(-) diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h index 7ffc15131..725970f89 100644 --- a/drivers/net/hns3/hns3_rss.h +++ b/drivers/net/hns3/hns3_rss.h @@ -27,7 +27,6 @@ #define HNS3_RSS_HASH_ALGO_TOEPLITZ0 #define HNS3_RSS_HASH_ALGO_SIMPLE 1 -#define HNS3_RSS_HASH_ALGO_SYMMETRIC 2 #define HNS3_RSS_HASH_ALGO_MASK0xf #define HNS3_RSS_INPUT_TUPLE_OTHER GENMASK(3, 0) @@ -56,15 +55,6 @@ struct hns3_rss_conf { uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */ }; -/* Bit 8 ~Bit 15 */ -#define HNS3_INSET_IPV4_SRC0x0100UL -#define HNS3_INSET_IPV4_DST0x0200UL -#define HNS3_INSET_IPV6_SRC0x0400UL -#define HNS3_INSET_IPV6_DST0x0800UL -#define HNS3_INSET_SRC_PORT0x1000UL -#define HNS3_INSET_DST_PORT0x2000UL -#define HNS3_INSET_SCTP_VT 0x4000UL - #ifndef ilog2 static inline int rss_ilog2(uint32_t x) { -- 2.23.0
[dpdk-dev] [PATCH v3 4/9] net/hns3: modify custom macro
From: Huisong Li This patch replaces custom macro named HNS3_MIN_FRAME_LEN for ethernet minimum frame length with the macro named RTE_ETHER_MIN_LEN that defined in dpdk framework. Signed-off-by: Huisong Li Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 2 +- drivers/net/hns3/hns3_ethdev.h | 1 - drivers/net/hns3/hns3_rxtx.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index fa0af847a..4ce9515a9 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2148,7 +2148,7 @@ hns3_set_mac_mtu(struct hns3_hw *hw, uint16_t new_mps) req = (struct hns3_config_max_frm_size_cmd *)desc.data; req->max_frm_size = rte_cpu_to_le_16(new_mps); - req->min_frm_size = HNS3_MIN_FRAME_LEN; + req->min_frm_size = RTE_ETHER_MIN_LEN; return hns3_cmd_send(hw, &desc, 1); } diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 004cd75a9..7422706a8 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -33,7 +33,6 @@ #define HNS3_MAX_BD_SIZE 65535 #define HNS3_MAX_TX_BD_PER_PKT 8 #define HNS3_MAX_FRAME_LEN 9728 -#define HNS3_MIN_FRAME_LEN 64 #define HNS3_VLAN_TAG_SIZE 4 #define HNS3_DEFAULT_RX_BUF_LEN2048 diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index e1bdba972..d9219d123 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -1551,7 +1551,7 @@ hns3_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, m = tx_pkts[i]; /* check the size of packet */ - if (m->pkt_len < HNS3_MIN_FRAME_LEN) { + if (m->pkt_len < RTE_ETHER_MIN_LEN) { rte_errno = EINVAL; return i; } -- 2.23.0
[dpdk-dev] [PATCH v3 1/9] net/hns3: support Rx interrupt
From: Hao Chen This patch adds supports of receive packets through interrupt mode for hns3 PF/VF driver. The following ops functions should be implemented defined in the struct eth_dev_ops: rx_queue_intr_enable rx_queue_intr_disable Signed-off-by: Hao Chen Signed-off-by: Wei Hu (Xavier) --- v2 -> v3: 1.Remove the irrelevant '.rx_queue_count' ops implementation function from this patch. v1 -> v2: 1.No change. --- doc/guides/nics/features/hns3.ini| 1 + doc/guides/nics/features/hns3_vf.ini | 1 + drivers/net/hns3/hns3_cmd.h | 28 + drivers/net/hns3/hns3_ethdev.c | 159 -- drivers/net/hns3/hns3_ethdev_vf.c| 165 --- drivers/net/hns3/hns3_mbx.h | 13 +++ drivers/net/hns3/hns3_regs.h | 3 + drivers/net/hns3/hns3_rxtx.c | 41 +++ drivers/net/hns3/hns3_rxtx.h | 3 + 9 files changed, 392 insertions(+), 22 deletions(-) diff --git a/doc/guides/nics/features/hns3.ini b/doc/guides/nics/features/hns3.ini index 6df789ed1..cd5c08a9d 100644 --- a/doc/guides/nics/features/hns3.ini +++ b/doc/guides/nics/features/hns3.ini @@ -5,6 +5,7 @@ ; [Features] Link status = Y +Rx interrupt = Y MTU update = Y Jumbo frame = Y Promiscuous mode = Y diff --git a/doc/guides/nics/features/hns3_vf.ini b/doc/guides/nics/features/hns3_vf.ini index 41497c4c2..fd00ac3e2 100644 --- a/doc/guides/nics/features/hns3_vf.ini +++ b/doc/guides/nics/features/hns3_vf.ini @@ -5,6 +5,7 @@ ; [Features] Link status = Y +Rx interrupt = Y MTU update = Y Jumbo frame = Y Unicast MAC filter = Y diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h index be0ecbe86..897dc1420 100644 --- a/drivers/net/hns3/hns3_cmd.h +++ b/drivers/net/hns3/hns3_cmd.h @@ -209,6 +209,10 @@ enum hns3_opcode_type { /* SFP command */ HNS3_OPC_SFP_GET_SPEED = 0x7104, + /* Interrupts commands */ + HNS3_OPC_ADD_RING_TO_VECTOR = 0x1503, + HNS3_OPC_DEL_RING_TO_VECTOR = 0x1504, + /* Error INT commands */ HNS3_QUERY_MSIX_INT_STS_BD_NUM = 0x1513, HNS3_QUERY_CLEAR_ALL_MPF_MSIX_INT = 0x1514, @@ -673,6 +677,30 @@ struct hns3_tqp_map_cmd { uint8_t rsv[18]; }; +#define HNS3_RING_TYPE_B 0 +#define HNS3_RING_TYPE_TX 0 +#define HNS3_RING_TYPE_RX 1 +#define HNS3_RING_GL_IDX_S 0 +#define HNS3_RING_GL_IDX_M GENMASK(1, 0) +#define HNS3_RING_GL_RX0 +#define HNS3_RING_GL_TX1 + +#define HNS3_VECTOR_ELEMENTS_PER_CMD 10 + +#define HNS3_INT_TYPE_S0 +#define HNS3_INT_TYPE_MGENMASK(1, 0) +#define HNS3_TQP_ID_S 2 +#define HNS3_TQP_ID_M GENMASK(12, 2) +#define HNS3_INT_GL_IDX_S 13 +#define HNS3_INT_GL_IDX_M GENMASK(14, 13) +struct hns3_ctrl_vector_chain_cmd { + uint8_t int_vector_id; + uint8_t int_cause_num; + uint16_t tqp_type_and_id[HNS3_VECTOR_ELEMENTS_PER_CMD]; + uint8_t vfid; + uint8_t rsv; +}; + struct hns3_config_max_frm_size_cmd { uint16_t max_frm_size; uint8_t min_frm_size; diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 72315718a..8243ade21 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2021,6 +2021,40 @@ hns3_check_dcb_cfg(struct rte_eth_dev *dev) return hns3_check_mq_mode(dev); } +static int +hns3_bind_ring_with_vector(struct rte_eth_dev *dev, uint8_t vector_id, + bool mmap, uint16_t queue_id) +{ + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct hns3_cmd_desc desc; + struct hns3_ctrl_vector_chain_cmd *req = + (struct hns3_ctrl_vector_chain_cmd *)desc.data; + enum hns3_cmd_status status; + enum hns3_opcode_type op; + uint16_t tqp_type_and_id = 0; + + op = mmap ? HNS3_OPC_ADD_RING_TO_VECTOR : HNS3_OPC_DEL_RING_TO_VECTOR; + hns3_cmd_setup_basic_desc(&desc, op, false); + req->int_vector_id = vector_id; + + hns3_set_field(tqp_type_and_id, HNS3_INT_TYPE_M, HNS3_INT_TYPE_S, + HNS3_RING_TYPE_RX); + hns3_set_field(tqp_type_and_id, HNS3_TQP_ID_M, HNS3_TQP_ID_S, queue_id); + hns3_set_field(tqp_type_and_id, HNS3_INT_GL_IDX_M, HNS3_INT_GL_IDX_S, + HNS3_RING_GL_RX); + req->tqp_type_and_id[0] = rte_cpu_to_le_16(tqp_type_and_id); + + req->int_cause_num = 1; + status = hns3_cmd_send(hw, &desc, 1); + if (status) { + hns3_err(hw, "Map TQP %d fail, vector_id is %d, status is %d.", +queue_id, vector_id, status); + return -EIO; + } + + return 0; +} + static int hns3_dev_configure(struct rte_eth_dev *dev
[dpdk-dev] [PATCH v3 6/9] net/hns3: remove the redundant function call
From: Hao Chen This patch removes the redundant statement calling hns3_stats_reset() to clear statistical information explicitly in the initialization of VF device, because hardware has been reseted by FLR in the initialization and the initial hardware and software statistics values are 0. Signed-off-by: Hao Chen Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev_vf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index b5f3e9a86..92ed32631 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1167,7 +1167,6 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) hns3_set_default_rss_args(hw); - (void)hns3_stats_reset(eth_dev); return 0; err_get_config: -- 2.23.0
[dpdk-dev] [PATCH v3 7/9] net/hns3: remove the redundant variable initialization
From: "Wei Hu (Xavier)" This patch removes the redundant initialization of the variable named ret. Signed-off-by: Hongbo Zheng Signed-off-by: Hao Chen Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c| 10 +- drivers/net/hns3/hns3_ethdev_vf.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 4ce9515a9..49aef7dbc 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -3597,7 +3597,7 @@ hns3_dev_promiscuous_enable(struct rte_eth_dev *dev) struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; bool en_mc_pmc = (dev->data->all_multicast == 1) ? true : false; - int ret = 0; + int ret; rte_spinlock_lock(&hw->lock); ret = hns3_set_promisc_mode(hw, true, en_mc_pmc); @@ -3614,7 +3614,7 @@ hns3_dev_promiscuous_disable(struct rte_eth_dev *dev) struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; bool en_mc_pmc = (dev->data->all_multicast == 1) ? true : false; - int ret = 0; + int ret; /* If now in all_multicast mode, must remain in all_multicast mode. */ rte_spinlock_lock(&hw->lock); @@ -3632,7 +3632,7 @@ hns3_dev_allmulticast_enable(struct rte_eth_dev *dev) struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; bool en_uc_pmc = (dev->data->promiscuous == 1) ? true : false; - int ret = 0; + int ret; rte_spinlock_lock(&hw->lock); ret = hns3_set_promisc_mode(hw, en_uc_pmc, true); @@ -3649,7 +3649,7 @@ hns3_dev_allmulticast_disable(struct rte_eth_dev *dev) struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; bool en_uc_pmc = (dev->data->promiscuous == 1) ? true : false; - int ret = 0; + int ret; /* If now in promiscuous mode, must remain in all_multicast mode. */ if (dev->data->promiscuous == 1) @@ -4135,7 +4135,7 @@ hns3_dev_start(struct rte_eth_dev *dev) { struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; - int ret = 0; + int ret; PMD_INIT_FUNC_TRACE(); if (rte_atomic16_read(&hw->reset.resetting)) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 92ed32631..10969011b 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1465,7 +1465,7 @@ hns3vf_dev_start(struct rte_eth_dev *dev) { struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; - int ret = 0; + int ret; PMD_INIT_FUNC_TRACE(); if (rte_atomic16_read(&hw->reset.resetting)) -- 2.23.0
[dpdk-dev] [PATCH v3 5/9] net/hns3: optimize RSS's default algorithm
From: Hao Chen This patch changed the default algorithm of RSS from simle_xor to toeplitz because toeplitz is used more frequently by upper applications such as ceph. Signed-off-by: Hao Chen Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_rss.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index b8c20e6d9..dfc42f840 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -211,7 +211,11 @@ hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, req->ipv6_fragment_en |= HNS3_IP_OTHER_BIT_MASK; break; default: - /* Other unsupported flow types won't change tuples */ + /* +* rss_hf doesn't include unsupported flow types +* because the API framework has checked it, and +* this branch will never go unless rss_hf is zero. +*/ break; } } @@ -251,8 +255,8 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, struct hns3_hw *hw = &hns->hw; struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets; struct hns3_rss_conf *rss_cfg = &hw->rss_info; - uint8_t algo = rss_cfg->conf.func; uint8_t key_len = rss_conf->rss_key_len; + uint8_t algo; uint64_t rss_hf = rss_conf->rss_hf; uint8_t *key = rss_conf->rss_key; int ret; @@ -285,6 +289,8 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, ret = -EINVAL; goto conf_err; } + algo = rss_cfg->conf.func == RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ? + HNS3_RSS_HASH_ALGO_SIMPLE : HNS3_RSS_HASH_ALGO_TOEPLITZ; ret = hns3_set_rss_algo_key(hw, algo, key); if (ret) goto conf_err; @@ -500,7 +506,9 @@ hns3_set_default_rss_args(struct hns3_hw *hw) int i; /* Default hash algorithm */ - rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; + rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; + + /* Default RSS key */ memcpy(rss_cfg->key, hns3_hash_key, HNS3_RSS_KEY_SIZE); /* Initialize RSS indirection table */ -- 2.23.0
[dpdk-dev] [PATCH v3 8/9] net/hns3: remove the unnecessary assignment
From: "Wei Hu (Xavier)" This patch removes the unncessary assignment in the '.tx_pkt_burst' ops implementation function to avoid performance loss. Signed-off-by: Wei Hu (Xavier) Signed-off-by: Yisen Zhuang --- drivers/net/hns3/hns3_rxtx.c | 12 ++-- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index d9219d123..003a5bde4 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -1181,8 +1181,7 @@ hns3_tx_free_useless_buffer(struct hns3_tx_queue *txq) (tx_next_use != tx_next_clean || tx_bd_ready < tx_bd_max)) { mbuf = tx_bak_pkt->mbuf; if (mbuf) { - mbuf->next = NULL; - rte_pktmbuf_free(mbuf); + rte_pktmbuf_free_seg(mbuf); tx_bak_pkt->mbuf = NULL; } @@ -1600,9 +1599,7 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) struct rte_mbuf *new_pkt; struct rte_mbuf *tx_pkt; struct rte_mbuf *m_seg; - struct rte_mbuf *temp; uint32_t nb_hold = 0; - uint16_t tx_next_clean; uint16_t tx_next_use; uint16_t tx_bd_ready; uint16_t tx_pkt_num; @@ -1617,11 +1614,8 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) if (tx_bd_ready == 0) return 0; - tx_next_clean = txq->next_to_clean; tx_next_use = txq->next_to_use; tx_bd_max = txq->nb_tx_desc; - tx_bak_pkt = &txq->sw_ring[tx_next_clean]; - tx_pkt_num = (tx_bd_ready < nb_pkts) ? tx_bd_ready : nb_pkts; /* send packets */ @@ -1676,9 +1670,8 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) i = 0; do { fill_desc(txq, tx_next_use, m_seg, (i == 0), 0); - temp = m_seg->next; tx_bak_pkt->mbuf = m_seg; - m_seg = temp; + m_seg = m_seg->next; tx_next_use++; tx_bak_pkt++; if (tx_next_use >= tx_bd_max) { @@ -1697,7 +1690,6 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) if (likely(nb_tx)) { hns3_queue_xmit(txq, nb_hold); - txq->next_to_clean = tx_next_clean; txq->tx_bd_ready = tx_bd_ready - nb_hold; } -- 2.23.0
Re: [dpdk-dev] [PATCH v3 0/9] updates for hns3 PMD driver
Hi, Ferruh Yigit On 2020/1/9 2:18, Ferruh Yigit wrote: On 12/21/2019 10:32 AM, Wei Hu (Xavier) wrote: This series are updates for hns3 ethernet PMD driver. Hao Chen (4): net/hns3: support Rx interrupt net/hns3: optimize RSS's default algorithm net/hns3: remove the redundant function call net/hns3: remove the unused macros Hongbo Zheng (1): net/hns3: get link state change through mailbox Huisong Li (1): net/hns3: modify custom macro Wei Hu (Xavier) (3): net/hns3: modify the return value of enable msix net/hns3: remove the redundant variable initialization net/hns3: remove the unnecessary assignment Series applied to dpdk-next-net/master, thanks. Thank you very much. Xavier
[dpdk-dev] [PATCH 11/11] net/hns3: fix triggering reset proceduce in slave process
From: Chengwen Feng Currently, reset related operations can only be performed in the primary process and are not allowed in the slave process in hns3 PMD driver. In the internal function interface named hns3_cmd_send used for communication between driver and firmware, if the wrong head value is detected in the static subfunction hns3_cmd_csq_clean, driver will trigger a function level reset to make the hardware work normally again. This patch adds check condition to prevent triggering reset proceduce in the salve process to avoid failure. Fixes: 2790c6464725 ("net/hns3: support device reset") Cc: sta...@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_cmd.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c index 65a5af8e4..5ec3dfe01 100644 --- a/drivers/net/hns3/hns3_cmd.c +++ b/drivers/net/hns3/hns3_cmd.c @@ -215,12 +215,12 @@ hns3_cmd_csq_clean(struct hns3_hw *hw) head = hns3_read_dev(hw, HNS3_CMDQ_TX_HEAD_REG); if (!is_valid_csq_clean_head(csq, head)) { - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); hns3_err(hw, "wrong cmd head (%u, %u-%u)", head, csq->next_to_use, csq->next_to_clean); - rte_atomic16_set(&hw->reset.disable_cmd, 1); - - hns3_schedule_delayed_reset(hns); + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + rte_atomic16_set(&hw->reset.disable_cmd, 1); + hns3_schedule_delayed_reset(HNS3_DEV_HW_TO_ADAPTER(hw)); + } return -EIO; } -- 2.23.0
[dpdk-dev] [PATCH 00/11] misc updates and fixes for hns3 PMD driver
This series are updates and bugfixes for hns3 ethernet PMD driver. Chengwen Feng (1): net/hns3: fix triggering reset proceduce in slave process Hongbo Zheng (1): net/hns3: fix segment error when closing the port Wei Hu (Xavier) (8): net/hns3: support different numbered Rx and Tx queues net/hns3: support setting VF MAC address by PF driver net/hns3: remove io rmb call in Rx operation net/hns3: add free thresh in Rx operation net/hns3: fix Rx queue search miss RAS err when recv BC pkt net/hns3: fix ring vector related mailbox command format net/hns3: fix dumping VF register information net/hns3: fix link status when failure in issuing command Yisen Zhuang (1): net/hns3: reduce the judgements of free Tx ring space drivers/net/hns3/hns3_cmd.c | 8 +- drivers/net/hns3/hns3_dcb.c | 88 ++-- drivers/net/hns3/hns3_dcb.h | 4 +- drivers/net/hns3/hns3_ethdev.c| 101 +++-- drivers/net/hns3/hns3_ethdev.h| 17 +- drivers/net/hns3/hns3_ethdev_vf.c | 183 ++-- drivers/net/hns3/hns3_flow.c | 9 +- drivers/net/hns3/hns3_mbx.c | 14 +- drivers/net/hns3/hns3_mbx.h | 1 + drivers/net/hns3/hns3_regs.c | 29 +- drivers/net/hns3/hns3_rxtx.c | 727 -- drivers/net/hns3/hns3_rxtx.h | 14 +- drivers/net/hns3/hns3_stats.c | 3 - 13 files changed, 934 insertions(+), 264 deletions(-) -- 2.23.0
[dpdk-dev] [PATCH 03/11] net/hns3: reduce the judgements of free Tx ring space
From: Yisen Zhuang This patch reduces the number of the judgement of the free Tx ring space in the 'tx_pkt_burst' ops implementation function to avoid performance loss. According to hardware constraints, we need to reserve a Tx Buffer Descriptor in the TX ring in hns3 network engine. Signed-off-by: Yisen Zhuang Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_rxtx.c | 32 +++- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 3d13ed526..34919cd2c 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -591,7 +591,7 @@ hns3_init_tx_queue(struct hns3_tx_queue *queue) txq->next_to_use = 0; txq->next_to_clean = 0; - txq->tx_bd_ready = txq->nb_tx_desc; + txq->tx_bd_ready = txq->nb_tx_desc - 1; hns3_init_tx_queue_hw(txq); } @@ -1588,7 +1588,7 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, txq->hns = hns; txq->next_to_use = 0; txq->next_to_clean = 0; - txq->tx_bd_ready = txq->nb_tx_desc; + txq->tx_bd_ready = txq->nb_tx_desc - 1; txq->port_id = dev->data->port_id; txq->configured = true; txq->io_base = (void *)((char *)hw->io_base + HNS3_TQP_REG_OFFSET + @@ -1600,19 +1600,6 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, return 0; } -static inline int -tx_ring_dist(struct hns3_tx_queue *txq, int begin, int end) -{ - return (end - begin + txq->nb_tx_desc) % txq->nb_tx_desc; -} - -static inline int -tx_ring_space(struct hns3_tx_queue *txq) -{ - return txq->nb_tx_desc - - tx_ring_dist(txq, txq->next_to_clean, txq->next_to_use) - 1; -} - static inline void hns3_queue_xmit(struct hns3_tx_queue *txq, uint32_t buf_num) { @@ -1631,7 +1618,7 @@ hns3_tx_free_useless_buffer(struct hns3_tx_queue *txq) struct rte_mbuf *mbuf; while ((!hns3_get_bit(desc->tx.tp_fe_sc_vld_ra_ri, HNS3_TXD_VLD_B)) && - (tx_next_use != tx_next_clean || tx_bd_ready < tx_bd_max)) { + tx_next_use != tx_next_clean) { mbuf = tx_bak_pkt->mbuf; if (mbuf) { rte_pktmbuf_free_seg(mbuf); @@ -2054,7 +2041,6 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) struct rte_mbuf *m_seg; uint32_t nb_hold = 0; uint16_t tx_next_use; - uint16_t tx_bd_ready; uint16_t tx_pkt_num; uint16_t tx_bd_max; uint16_t nb_buf; @@ -2063,13 +2049,10 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) /* free useless buffer */ hns3_tx_free_useless_buffer(txq); - tx_bd_ready = txq->tx_bd_ready; - if (tx_bd_ready == 0) - return 0; tx_next_use = txq->next_to_use; tx_bd_max = txq->nb_tx_desc; - tx_pkt_num = (tx_bd_ready < nb_pkts) ? tx_bd_ready : nb_pkts; + tx_pkt_num = nb_pkts; /* send packets */ tx_bak_pkt = &txq->sw_ring[tx_next_use]; @@ -2078,7 +2061,7 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) nb_buf = tx_pkt->nb_segs; - if (nb_buf > tx_ring_space(txq)) { + if (nb_buf > txq->tx_bd_ready) { if (nb_tx == 0) return 0; @@ -2137,14 +2120,13 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) nb_hold += i; txq->next_to_use = tx_next_use; + txq->tx_bd_ready -= i; } end_of_tx: - if (likely(nb_tx)) { + if (likely(nb_tx)) hns3_queue_xmit(txq, nb_hold); - txq->tx_bd_ready = tx_bd_ready - nb_hold; - } return nb_tx; } -- 2.23.0
[dpdk-dev] [PATCH 10/11] net/hns3: fix link status when failure in issuing command
From: "Wei Hu (Xavier)" Currently, the hns3 PMD driver issues command to the firmware and gets link status information. When the driver fails to call internal interface function named hns3_cmd_send to query the status from firmware for some reason, the link status queried by the driver should be down. Fixes: 59fad0f32135 ("net/hns3: support link update operation") Cc: sta...@dpdk.org Signed-off-by: Hongbo Zheng Signed-off-by: Huisong Li Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index b05a55781..9866d147b 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -3836,7 +3836,7 @@ hns3_get_mac_link_status(struct hns3_hw *hw) ret = hns3_cmd_send(hw, &desc, 1); if (ret) { hns3_err(hw, "get link status cmd failed %d", ret); - return ret; + return ETH_LINK_DOWN; } req = (struct hns3_link_status_cmd *)desc.data; -- 2.23.0
[dpdk-dev] [PATCH 04/11] net/hns3: remove io rmb call in Rx operation
From: "Wei Hu (Xavier)" When receiving a packet, hns3 hardware network engine firstly writes the packet content to the memory pointed by the 'addr' field of the Rx Buffer Descriptor, secondly fills the result of parsing the packet include the valid field into the Rx Buffer Decriptor in one write operation, and thirdly writes the number of the Buffer Descriptor not processed by the driver to the HNS3_RING_RX_FBDNUM_REG register. This patch optimizes the Rx performance by removing one rte_io_rmb call in the '.rx_pkt_burst' ops implementation function named hns3_recv_pkts. The change as follows: 1. Driver no longer read HNS3_RING_RX_FBDNUM_REG register, so remove one rte_io_rmb call, and directly read the valid flag of Rx Buffer Descriptor to check whether the BD is ready. 2. Delete the non_vld_descs field from the statistic information of the hns3 driver because now it has become a common case that the valid flag of Rx Buffer Descriptor read by the driver is invalid. Signed-off-by: Chengwen Feng Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_rxtx.c | 12 +++- drivers/net/hns3/hns3_rxtx.h | 1 - drivers/net/hns3/hns3_stats.c | 3 --- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 34919cd2c..a1655e246 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -1174,7 +1174,6 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, rxq->io_base = (void *)((char *)hw->io_base + HNS3_TQP_REG_OFFSET + idx * HNS3_TQP_REG_SIZE); rxq->rx_buf_len = hw->rx_buf_len; - rxq->non_vld_descs = 0; rxq->l2_errors = 0; rxq->pkt_len_errors = 0; rxq->l3_csum_erros = 0; @@ -1421,7 +1420,6 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) uint16_t pkt_len; uint16_t nb_rx; uint16_t rx_id; - int num;/* num of desc in ring */ int ret; nb_rx = 0; @@ -1435,15 +1433,11 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) last_seg = rxq->pkt_last_seg; sw_ring = rxq->sw_ring; - /* Get num of packets in descriptor ring */ - num = hns3_read_dev(rxq, HNS3_RING_RX_FBDNUM_REG); - while (nb_rx_bd < num && nb_rx < nb_pkts) { + while (nb_rx < nb_pkts) { rxdp = &rx_ring[rx_id]; bd_base_info = rte_le_to_cpu_32(rxdp->rx.bd_base_info); - if (unlikely(!hns3_get_bit(bd_base_info, HNS3_RXD_VLD_B))) { - rxq->non_vld_descs++; + if (unlikely(!hns3_get_bit(bd_base_info, HNS3_RXD_VLD_B))) break; - } nmb = rte_mbuf_raw_alloc(rxq->mb_pool); if (unlikely(nmb == NULL)) { @@ -1454,7 +1448,7 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) nb_rx_bd++; rxe = &sw_ring[rx_id]; rx_id++; - if (rx_id == rxq->nb_rx_desc) + if (unlikely(rx_id == rxq->nb_rx_desc)) rx_id = 0; rte_prefetch0(sw_ring[rx_id].mbuf); diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h index a042c9902..943c6d8bb 100644 --- a/drivers/net/hns3/hns3_rxtx.h +++ b/drivers/net/hns3/hns3_rxtx.h @@ -245,7 +245,6 @@ struct hns3_rx_queue { bool rx_deferred_start; /* don't start this queue in dev start */ bool configured;/* indicate if rx queue has been configured */ - uint64_t non_vld_descs; /* num of non valid rx descriptors */ uint64_t l2_errors; uint64_t pkt_len_errors; uint64_t l3_csum_erros; diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c index 9948beb17..b3797ec53 100644 --- a/drivers/net/hns3/hns3_stats.c +++ b/drivers/net/hns3/hns3_stats.c @@ -219,8 +219,6 @@ static const struct hns3_xstats_name_offset hns3_reset_stats_strings[] = { /* The statistic of errors in Rx BD */ static const struct hns3_xstats_name_offset hns3_rx_bd_error_strings[] = { - {"NONE_VALIDATED_DESCRIPTORS", - HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(non_vld_descs)}, {"RX_PKT_LEN_ERRORS", HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(pkt_len_errors)}, {"L2_RX_ERRORS", @@ -510,7 +508,6 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) rxq = eth_dev->data->rx_queues[i]; if (rxq) { rxq->pkt_len_errors = 0; - rxq->non_vld_descs = 0; rxq->l2_errors = 0; rxq->l3_csum_erros = 0; rxq->l4_csum_erros = 0; -- 2.23.0
[dpdk-dev] [PATCH 02/11] net/hns3: support setting VF MAC address by PF driver
From: "Wei Hu (Xavier)" Currently, we only support VF device is bound to vfio_pci or igb_uio and then driven by DPDK driver when PF is driven by kernel mode hns3 ethdev driver, VF is not supported when PF is driven by hns3 DPDK driver. This patch adds support setting VF MAC address by hns3 PF kernel ethdev driver on the host by "ip link set ..." command. 1) If the hns3 PF kernel ethdev driver sets the MAC address for VF device before the initialization of the related VF device, hns3 VF PMD driver should get the MAC address from PF driver through mailbox and configure hardware using this MAC address in the initialization. The hns3 VF PMD driver get the MAC address form PF driver, if obtaining a non-zero MAC address from mailbox, VF driver will configure hardware using it, otherwise using a random MAC address in the initialization of VF device. 2) If the hns3 PF kernel ethdev driver sets the MAC address for VF device after the initialization of the related VF device, the PF driver will notify VF driver to reset VF device to make the new MAC address effective immediately. The hns3 VF PMD driver should check whether the MAC address has been changed by the PF kernel netdevice driver, if changed VF driver should configure hardware using the new MAC address in the recovering hardware configuration stage of the reset process. 3) When user has configured a mac address for VF device by "ip link set ..." command based on the PF device, the hns3 PF kernel ethdev driver does not allow VF driver to request reconfiguring a different default mac address and return -EPREM to VF driver through mailbox. Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) Signed-off-by: Hongbo Zheng --- drivers/net/hns3/hns3_ethdev_vf.c | 108 -- 1 file changed, 102 insertions(+), 6 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 71e358e81..92cf7ee99 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -208,12 +208,27 @@ hns3vf_set_default_mac_addr(struct rte_eth_dev *dev, ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_UNICAST, HNS3_MBX_MAC_VLAN_UC_MODIFY, addr_bytes, - HNS3_TWO_ETHER_ADDR_LEN, false, NULL, 0); + HNS3_TWO_ETHER_ADDR_LEN, true, NULL, 0); if (ret) { - rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "Failed to set mac addr(%s) for vf: %d", mac_str, -ret); + /* +* The hns3 VF PMD driver depends on the hns3 PF kernel ethdev +* driver. When user has configured a MAC address for VF device +* by "ip link set ..." command based on the PF device, the hns3 +* PF kernel ethdev driver does not allow VF driver to request +* reconfiguring a different default MAC address, and return +* -EPREM to VF driver through mailbox. +*/ + if (ret == -EPERM) { + rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, + old_addr); + hns3_warn(hw, "Has permanet mac addr(%s) for vf", + mac_str); + } else { + rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, + mac_addr); + hns3_err(hw, "Failed to set mac addr(%s) for vf: %d", +mac_str, ret); + } } rte_ether_addr_copy(mac_addr, @@ -784,6 +799,24 @@ hns3vf_get_tc_info(struct hns3_hw *hw) return 0; } +static int +hns3vf_get_host_mac_addr(struct hns3_hw *hw) +{ + uint8_t host_mac[RTE_ETHER_ADDR_LEN]; + int ret; + + ret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_MAC_ADDR, 0, NULL, 0, + true, host_mac, RTE_ETHER_ADDR_LEN); + if (ret) { + hns3_err(hw, "Failed to get mac addr from PF: %d", ret); + return ret; + } + + memcpy(hw->mac.mac_addr, host_mac, RTE_ETHER_ADDR_LEN); + + return 0; +} + static int hns3vf_get_configuration(struct hns3_hw *hw) { @@ -801,6 +834,11 @@ hns3vf_get_configuration(struct hns3_hw *hw) if (ret) return ret; + /* Get user defined VF MAC addr from PF */ + ret = hns3vf_get_host_mac_addr(hw); + if (ret) + return ret; + /* Get tc configuration from PF */ return hns3vf_get_tc_info(hw); } @@ -1170,7 +1208,20 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) goto err_get_config;
[dpdk-dev] [PATCH 06/11] net/hns3: fix Rx queue search miss RAS err when recv BC pkt
From: "Wei Hu (Xavier)" Currently, there is a certain probability of a type of RAS errors when receiving broadcast packets. This type of RAS errors are parsed as rx_q_search_miss error by hns3 PF PMD driver, the related log as below: :bd:00.0 hns3_find_highest_level(): PPP_MFP_ABNORMAL_INT_ST2 rx_q_search_miss found [error status=0x2000] When receiving broadcast packet, network engine select which functions need to accept it according to the function's promisc_bcast_en bit configuration. And then search TQP_MAP configuration to select which hardware queues the packet should enter, if can't find the target hardware queue, network engine will trigger rx_q_search_miss RAS error. The root cause as below: 1. VF's promisc_bcast_en bit configuration is not cleared by FLR reset, and the configuration has been setted in the previous application. 2. There is one bug in setting TQP_MAP configuration in the initialization of PF device: when tqp is allocated to VF, it is still marked as PF. This issue will affect the correctness of the TQP_MAP configuration. This patch fixes it with the following modification. 1. clear all VFs promisc_bcast_en bit in the initialization of PF device. 2. fix the issue to ensure the correct TQP_MAP configuration. Fixes: d51867db65c1 ("net/hns3: add initialization") Cc: sta...@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 32 +++- drivers/net/hns3/hns3_ethdev.h | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 800fa47cc..ca8718000 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2408,6 +2408,7 @@ hns3_query_pf_resource(struct hns3_hw *hw) hw->total_tqps_num = rte_le_to_cpu_16(req->tqp_num); pf->pkt_buf_size = rte_le_to_cpu_16(req->buf_size) << HNS3_BUF_UNIT_S; hw->tqps_num = RTE_MIN(hw->total_tqps_num, HNS3_MAX_TQP_NUM_PER_FUNC); + pf->func_num = rte_le_to_cpu_16(req->pf_own_fun_number); if (req->tx_buf_size) pf->tx_buf_size = @@ -2684,6 +2685,7 @@ hns3_map_tqp(struct hns3_hw *hw) uint16_t tqps_num = hw->total_tqps_num; uint16_t func_id; uint16_t tqp_id; + bool is_pf; int num; int ret; int i; @@ -2695,10 +2697,11 @@ hns3_map_tqp(struct hns3_hw *hw) tqp_id = 0; num = DIV_ROUND_UP(hw->total_tqps_num, HNS3_MAX_TQP_NUM_PER_FUNC); for (func_id = 0; func_id < num; func_id++) { + is_pf = func_id == 0 ? true : false; for (i = 0; i < HNS3_MAX_TQP_NUM_PER_FUNC && tqp_id < tqps_num; i++) { ret = hns3_map_tqps_to_func(hw, func_id, tqp_id++, i, - true); + is_pf); if (ret) return ret; } @@ -3599,6 +3602,26 @@ hns3_set_promisc_mode(struct hns3_hw *hw, bool en_uc_pmc, bool en_mc_pmc) return 0; } +static int +hns3_clear_all_vfs_promisc_mode(struct hns3_hw *hw) +{ + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); + struct hns3_pf *pf = &hns->pf; + struct hns3_promisc_param param; + uint16_t func_id; + int ret; + + /* func_id 0 is denoted PF, the VFs start from 1 */ + for (func_id = 1; func_id < pf->func_num; func_id++) { + hns3_promisc_param_init(¶m, false, false, false, func_id); + ret = hns3_cmd_set_promisc_mode(hw, ¶m); + if (ret) + return ret; + } + + return 0; +} + static int hns3_dev_promiscuous_enable(struct rte_eth_dev *dev) { @@ -3886,6 +3909,13 @@ hns3_init_hardware(struct hns3_adapter *hns) goto err_mac_init; } + ret = hns3_clear_all_vfs_promisc_mode(hw); + if (ret) { + PMD_INIT_LOG(ERR, "Failed to clear all vfs promisc mode: %d", +ret); + goto err_mac_init; + } + ret = hns3_init_vlan_config(hns); if (ret) { PMD_INIT_LOG(ERR, "Failed to init vlan: %d", ret); diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 2aa4c3cd7..d4a03065f 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -464,6 +464,7 @@ struct hns3_mp_param { struct hns3_pf { struct hns3_adapter *adapter; bool is_main_pf; + uint16_t func_num; /* num functions of this pf, include pf and vfs */ uint32_t pkt_buf_size; /* Total pf buf size for tx/rx */ uint32_t tx_buf_size; /* Tx buffer size for each TC */ -- 2.23.0
[dpdk-dev] [PATCH 07/11] net/hns3: fix segment error when closing the port
From: Hongbo Zheng Currently there is a certain probability of segment error in concurrent reset when the port is closing. The calltrace info: This GDB was configured as "aarch64-redhat-linux-gnu". Reading symbols from /usr/app/testpmd...(no debugging symbols found)... done. [New LWP 98204] [New LWP 98203] [New LWP 98206] [New LWP 98205] [New LWP 98207] [New LWP 98208] Missing separate debuginfo for /root/lib/libnuma.so.1 [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Core was generated by `/usr/app/testpmd --log-level=6 --socket-mem 16'. Program terminated with signal 11, Segmentation fault. Missing separate debuginfos, use: debuginfo-install glibc-2.17-260.el7.aarch64 (gdb) bt in hns3vf_service_handler () 1 0x006988b8 in eal_alarm_callback () 2 0x006969b4 in eal_intr_thread_main () 3 0xb08d6c48 in start_thread () from /lib64/libpthread.so.0 4 0xb0828600 in thread_start () from /lib64/libc.so.6 (gdb) Reset process may turn on the cancelled link state timer whether the current port status is on or off, in order to solve this problem, this patch add judge the current network port state before starting the timer, only the port in the running state can start the link state timer, so as to solve the problem that the link state timer accesses the null pointer and causes the segment error. Fixes: 2790c6464725 ("net/hns3: support device reset") Cc: sta...@dpdk.org Signed-off-by: Hongbo Zheng Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c| 11 +++ drivers/net/hns3/hns3_ethdev_vf.c | 7 +-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index ca8718000..b05a55781 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -4197,6 +4197,7 @@ hns3_dev_start(struct rte_eth_dev *dev) return ret; hns3_set_rxtx_function(dev); hns3_mp_req_start_rxtx(dev); + rte_eal_alarm_set(HNS3_SERVICE_INTERVAL, hns3_service_handler, dev); hns3_info(hw, "hns3 dev start successful!"); return 0; @@ -4279,6 +4280,7 @@ hns3_dev_stop(struct rte_eth_dev *dev) hns3_dev_release_mbufs(hns); hw->adapter_state = HNS3_NIC_CONFIGURED; } + rte_eal_alarm_cancel(hns3_service_handler, dev); rte_spinlock_unlock(&hw->lock); hns3_unmap_rx_interrupt(dev); } @@ -4301,7 +4303,6 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) hw->adapter_state = HNS3_NIC_CLOSING; hns3_reset_abort(hns); hw->adapter_state = HNS3_NIC_CLOSED; - rte_eal_alarm_cancel(hns3_service_handler, eth_dev); hns3_configure_all_mc_mac_addr(hns, true); hns3_remove_all_vlan_table(hns); @@ -4760,7 +4761,8 @@ hns3_stop_service(struct hns3_adapter *hns) struct rte_eth_dev *eth_dev; eth_dev = &rte_eth_devices[hw->data->port_id]; - rte_eal_alarm_cancel(hns3_service_handler, eth_dev); + if (hw->adapter_state == HNS3_NIC_STARTED) + rte_eal_alarm_cancel(hns3_service_handler, eth_dev); hw->mac.link_status = ETH_LINK_DOWN; hns3_set_rxtx_function(eth_dev); @@ -4801,7 +4803,9 @@ hns3_start_service(struct hns3_adapter *hns) eth_dev = &rte_eth_devices[hw->data->port_id]; hns3_set_rxtx_function(eth_dev); hns3_mp_req_start_rxtx(eth_dev); - hns3_service_handler(eth_dev); + if (hw->adapter_state == HNS3_NIC_STARTED) + hns3_service_handler(eth_dev); + return 0; } @@ -5059,7 +5063,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) hns3_notify_reset_ready(hw, false); } - rte_eal_alarm_set(HNS3_SERVICE_INTERVAL, hns3_service_handler, eth_dev); hns3_info(hw, "hns3 dev initialization successful!"); return 0; diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 92cf7ee99..35243b2be 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1559,6 +1559,7 @@ hns3vf_dev_start(struct rte_eth_dev *dev) hns3_set_rxtx_function(dev); hns3_mp_req_start_rxtx(dev); rte_eal_alarm_set(HNS3VF_SERVICE_INTERVAL, hns3vf_service_handler, dev); + return ret; } @@ -1671,7 +1672,8 @@ hns3vf_stop_service(struct hns3_adapter *hns) struct rte_eth_dev *eth_dev; eth_dev = &rte_eth_devices[hw->data->port_id]; - rte_eal_alarm_cancel(hns3vf_service_handler, eth_dev); + if (hw->adapter_state == HNS3_NIC_STARTED) + rte_eal_alarm_cancel(hns3vf_service_handler, eth_dev); hw->mac.link_status = ETH_LINK_DOWN; hns3_set_rxtx_function(eth_dev); @@ -1709,8 +1711,9 @@ hns3vf_start_service(str
[dpdk-dev] [PATCH 09/11] net/hns3: fix dumping VF register information
From: "Wei Hu (Xavier)" Currently, when the API interface named rte_eth_dev_get_reg_info is called by upper applications based on VF device, it returns error. We can read registers directly to get ring and interrupt related information in hns3 PF/VF PMD driver. But for some other internal table entries and common configuration information, we can get them only through the command interface between driver and firmware in PF driver, and VF driver has not the related access permission. This patch fixes it by preventing getting these information through the command interface based on VF device in 'get_reg' ops implementation function. Fixes: 936eda25e8da ("net/hns3: support dump register") Cc: sta...@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_regs.c | 29 ++--- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c index 23405030e..a3f2a51f9 100644 --- a/drivers/net/hns3/hns3_regs.c +++ b/drivers/net/hns3/hns3_regs.c @@ -118,15 +118,9 @@ hns3_get_regs_length(struct hns3_hw *hw, uint32_t *length) struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); int cmdq_lines, common_lines, ring_lines, tqp_intr_lines; uint32_t regs_num_32_bit, regs_num_64_bit; + uint32_t len; int ret; - ret = hns3_get_regs_num(hw, ®s_num_32_bit, ®s_num_64_bit); - if (ret) { - hns3_err(hw, "Get register number failed, ret = %d.", -ret); - return -ENOTSUP; - } - cmdq_lines = sizeof(cmdq_reg_addrs) / REG_LEN_PER_LINE + 1; if (hns->is_vf) common_lines = @@ -136,11 +130,21 @@ hns3_get_regs_length(struct hns3_hw *hw, uint32_t *length) ring_lines = sizeof(ring_reg_addrs) / REG_LEN_PER_LINE + 1; tqp_intr_lines = sizeof(tqp_intr_reg_addrs) / REG_LEN_PER_LINE + 1; - *length = (cmdq_lines + common_lines + ring_lines * hw->tqps_num + - tqp_intr_lines * hw->num_msi) * REG_LEN_PER_LINE + - regs_num_32_bit * sizeof(uint32_t) + - regs_num_64_bit * sizeof(uint64_t); + len = (cmdq_lines + common_lines + ring_lines * hw->tqps_num + + tqp_intr_lines * hw->num_msi) * REG_LEN_PER_LINE; + if (!hns->is_vf) { + ret = hns3_get_regs_num(hw, ®s_num_32_bit, ®s_num_64_bit); + if (ret) { + hns3_err(hw, "Get register number failed, ret = %d.", +ret); + return -ENOTSUP; + } + len += regs_num_32_bit * sizeof(uint32_t) + + regs_num_64_bit * sizeof(uint64_t); + } + + *length = len; return 0; } @@ -346,6 +350,9 @@ hns3_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs) /* fetching per-PF registers values from PF PCIe register space */ hns3_direct_access_regs(hw, data); + if (hns->is_vf) + return 0; + ret = hns3_get_regs_num(hw, ®s_num_32_bit, ®s_num_64_bit); if (ret) { hns3_err(hw, "Get register number failed, ret = %d", ret); -- 2.23.0
[dpdk-dev] [PATCH 08/11] net/hns3: fix ring vector related mailbox command format
From: "Wei Hu (Xavier)" The format of the ring vector related mailbox commands between driver and firmware is different from those of other mailbox commands in hns3 network engine. This patch fixes the error mailbox command format about the vector of the rings, the related command opcode as below: HNS3_MBX_MAP_RING_TO_VECTOR HNS3_MBX_UNMAP_RING_TO_VECTOR HNS3_MBX_GET_RING_VECTOR_MAP Fixes: 463e748964f5 ("net/hns3: support mailbox") Cc: sta...@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_mbx.c | 14 +++--- drivers/net/hns3/hns3_mbx.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c index 26807bc4b..0d03f5064 100644 --- a/drivers/net/hns3/hns3_mbx.c +++ b/drivers/net/hns3/hns3_mbx.c @@ -150,6 +150,8 @@ hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode, { struct hns3_mbx_vf_to_pf_cmd *req; struct hns3_cmd_desc desc; + bool is_ring_vector_msg; + int offset; int ret; req = (struct hns3_mbx_vf_to_pf_cmd *)desc.data; @@ -164,9 +166,15 @@ hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode, hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_MBX_VF_TO_PF, false); req->msg[0] = code; - req->msg[1] = subcode; - if (msg_data) - memcpy(&req->msg[HNS3_CMD_CODE_OFFSET], msg_data, msg_len); + is_ring_vector_msg = (code == HNS3_MBX_MAP_RING_TO_VECTOR) || +(code == HNS3_MBX_UNMAP_RING_TO_VECTOR) || +(code == HNS3_MBX_GET_RING_VECTOR_MAP); + if (!is_ring_vector_msg) + req->msg[1] = subcode; + if (msg_data) { + offset = is_ring_vector_msg ? 1 : HNS3_CMD_CODE_OFFSET; + memcpy(&req->msg[offset], msg_data, msg_len); + } /* synchronous send */ if (need_resp) { diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h index 3722c8760..b01eaacc3 100644 --- a/drivers/net/hns3/hns3_mbx.h +++ b/drivers/net/hns3/hns3_mbx.h @@ -41,6 +41,7 @@ enum HNS3_MBX_OPCODE { HNS3_MBX_GET_QID_IN_PF, /* (VF -> PF) get queue id in pf */ HNS3_MBX_HANDLE_VF_TBL = 38,/* (VF -> PF) store/clear hw cfg tbl */ + HNS3_MBX_GET_RING_VECTOR_MAP, /* (VF -> PF) get ring-to-vector map */ HNS3_MBX_PUSH_LINK_STATUS = 201, /* (IMP -> PF) get port link status */ }; -- 2.23.0
[dpdk-dev] [PATCH 01/11] net/hns3: support different numbered Rx and Tx queues
From: "Wei Hu (Xavier)" Hardware does not support individually enable/disable/reset the Tx or Rx queue in hns3 network engine, driver must enable/disable/reset Tx and Rx queues at the same time. Currently, hns3 PMD driver does not support the scenarios as below: 1) When calling the following function, the input parameter nb_rx_q and nb_tx_q are not equal. rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, const struct rte_eth_conf *dev_conf); 2) When calling the following functions to setup queues, the cumulatively setupped Rx queues are not the same as the setupped Tx queues. rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,,,); rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,,,); However, these are common usage scenarios in some applications, such as, l3fwd, ip_ressmbly and OVS-DPDK, etc. This patch adds support for this usage of these functions by setupping fake Tx or Rx queues to adjust numbers of Tx/Rx queues. But these fake queues are imperceptible, and can not be used by upper applications. Signed-off-by: Huisong Li Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_dcb.c | 88 ++-- drivers/net/hns3/hns3_dcb.h | 4 +- drivers/net/hns3/hns3_ethdev.c| 56 +-- drivers/net/hns3/hns3_ethdev.h| 16 +- drivers/net/hns3/hns3_ethdev_vf.c | 68 +-- drivers/net/hns3/hns3_flow.c | 9 +- drivers/net/hns3/hns3_rxtx.c | 675 +- drivers/net/hns3/hns3_rxtx.h | 11 + 8 files changed, 734 insertions(+), 193 deletions(-) diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c index 19235dfb9..369a40e6a 100644 --- a/drivers/net/hns3/hns3_dcb.c +++ b/drivers/net/hns3/hns3_dcb.c @@ -578,17 +578,33 @@ hns3_dcb_pri_shaper_cfg(struct hns3_hw *hw) } void -hns3_tc_queue_mapping_cfg(struct hns3_hw *hw) +hns3_set_rss_size(struct hns3_hw *hw, uint16_t nb_rx_q) +{ + uint16_t rx_qnum_per_tc; + + rx_qnum_per_tc = nb_rx_q / hw->num_tc; + rx_qnum_per_tc = RTE_MIN(hw->rss_size_max, rx_qnum_per_tc); + if (hw->alloc_rss_size != rx_qnum_per_tc) { + hns3_info(hw, "rss size changes from %u to %u", + hw->alloc_rss_size, rx_qnum_per_tc); + hw->alloc_rss_size = rx_qnum_per_tc; + } + hw->used_rx_queues = hw->num_tc * hw->alloc_rss_size; +} + +void +hns3_tc_queue_mapping_cfg(struct hns3_hw *hw, uint16_t nb_queue) { struct hns3_tc_queue_info *tc_queue; uint8_t i; + hw->tx_qnum_per_tc = nb_queue / hw->num_tc; for (i = 0; i < HNS3_MAX_TC_NUM; i++) { tc_queue = &hw->tc_queue[i]; if (hw->hw_tc_map & BIT(i) && i < hw->num_tc) { tc_queue->enable = true; - tc_queue->tqp_offset = i * hw->alloc_rss_size; - tc_queue->tqp_count = hw->alloc_rss_size; + tc_queue->tqp_offset = i * hw->tx_qnum_per_tc; + tc_queue->tqp_count = hw->tx_qnum_per_tc; tc_queue->tc = i; } else { /* Set to default queue if TC is disable */ @@ -598,30 +614,22 @@ hns3_tc_queue_mapping_cfg(struct hns3_hw *hw) tc_queue->tc = 0; } } + hw->used_tx_queues = hw->num_tc * hw->tx_qnum_per_tc; } static void -hns3_dcb_update_tc_queue_mapping(struct hns3_hw *hw, uint16_t queue_num) +hns3_dcb_update_tc_queue_mapping(struct hns3_hw *hw, uint16_t nb_rx_q, +uint16_t nb_tx_q) { struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); struct hns3_pf *pf = &hns->pf; - uint16_t tqpnum_per_tc; - uint16_t alloc_tqps; - - alloc_tqps = RTE_MIN(hw->tqps_num, queue_num); - hw->num_tc = RTE_MIN(alloc_tqps, hw->dcb_info.num_tc); - tqpnum_per_tc = RTE_MIN(hw->rss_size_max, alloc_tqps / hw->num_tc); - if (hw->alloc_rss_size != tqpnum_per_tc) { - PMD_INIT_LOG(INFO, "rss size changes from %d to %d", -hw->alloc_rss_size, tqpnum_per_tc); - hw->alloc_rss_size = tqpnum_per_tc; - } - hw->alloc_tqps = hw->num_tc * hw->alloc_rss_size; + hw->num_tc = hw->dcb_info.num_tc; + hns3_set_rss_size(hw, nb_rx_q); + hns3_tc_queue_mapping_cfg(hw, nb_tx_q); - hns3_tc_queue_mapping_cfg(hw); - - memcpy(pf->prio_tc, hw->dcb_info.prio_tc, HNS3_MAX_USER_PRIO); + if (!hns->is_vf) + memcpy(pf->prio_tc, hw->dcb_info.prio_tc, HNS3_MAX_USER_PRIO); } int @@ -1309,20 +1317,35 @@ hns3_dcb_info_cfg(struct hns3_adapter *hns) for (i = 0; i < HNS3_M
[dpdk-dev] [PATCH 05/11] net/hns3: add free thresh in Rx operation
From: "Wei Hu (Xavier)" This patch optimizes the Rx performance by adding the rx_free_thresh related process in the '.rx_pkt_burst' ops implementation function named hns3_recv_pkts. The related change as follows: 1. Adding the rx_free_thresh related process to reduce the number of writing the HNS3_RING_RX_HEAD_REG register. 2. Adjusting the internal macro named DEFAULT_RX_FREE_THRESH to 32 and adjusting HNS3_MIN_RING_DESC to 64 to make the effect of the thresh more obvious. Signed-off-by: Chengwen Feng Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_rxtx.c | 12 ++-- drivers/net/hns3/hns3_rxtx.h | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index a1655e246..6f74a7917 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -30,7 +30,7 @@ #include "hns3_logs.h" #define HNS3_CFG_DESC_NUM(num) ((num) / 8 - 1) -#define DEFAULT_RX_FREE_THRESH 16 +#define DEFAULT_RX_FREE_THRESH 32 static void hns3_rx_queue_release_mbufs(struct hns3_rx_queue *rxq) @@ -558,6 +558,7 @@ hns3_dev_rx_queue_start(struct hns3_adapter *hns, uint16_t idx) rxq->next_to_use = 0; rxq->next_to_clean = 0; + rxq->nb_rx_hold = 0; hns3_init_rx_queue_hw(rxq); return 0; @@ -572,6 +573,7 @@ hns3_fake_rx_queue_start(struct hns3_adapter *hns, uint16_t idx) rxq = (struct hns3_rx_queue *)hw->fkq_data.rx_queues[idx]; rxq->next_to_use = 0; rxq->next_to_clean = 0; + rxq->nb_rx_hold = 0; hns3_init_rx_queue_hw(rxq); } @@ -1525,7 +1527,13 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxq->next_to_clean = rx_id; rxq->pkt_first_seg = first_seg; rxq->pkt_last_seg = last_seg; - hns3_clean_rx_buffers(rxq, nb_rx_bd); + + nb_rx_bd = nb_rx_bd + rxq->nb_rx_hold; + if (nb_rx_bd > rxq->rx_free_thresh) { + hns3_clean_rx_buffers(rxq, nb_rx_bd); + nb_rx_bd = 0; + } + rxq->nb_rx_hold = nb_rx_bd; return nb_rx; } diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h index 943c6d8bb..1c2723ffb 100644 --- a/drivers/net/hns3/hns3_rxtx.h +++ b/drivers/net/hns3/hns3_rxtx.h @@ -5,7 +5,7 @@ #ifndef _HNS3_RXTX_H_ #define _HNS3_RXTX_H_ -#defineHNS3_MIN_RING_DESC 32 +#defineHNS3_MIN_RING_DESC 64 #defineHNS3_MAX_RING_DESC 32768 #define HNS3_DEFAULT_RING_DESC 1024 #defineHNS3_ALIGN_RING_DESC32 -- 2.23.0
[dpdk-dev] [PATCH 2/4] net/hns3: remove unnecessary input parameter valid judgement
From: Lijun Ou Since the input parameter named dev has been guaranteed not to be NULL in the rte layer of DPDK framework, it doesn't need to check dev whether is null in the 'filter_ctrl' ops implementation function named hns3_dev_filter_ctrl. Signed-off-by: Lijun Ou Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_flow.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index aa614175d..98affa567 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1887,8 +1887,6 @@ hns3_dev_filter_ctrl(struct rte_eth_dev *dev, enum rte_filter_type filter_type, struct hns3_hw *hw; int ret = 0; - if (dev == NULL) - return -EINVAL; hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); switch (filter_type) { case RTE_ETH_FILTER_GENERIC: -- 2.23.0
[dpdk-dev] [PATCH 0/4] improvement and cleanup for hns3 PMD driver
This series are improvement and cleanup for hns3 PMD driver. Chengwen Feng (1): net/hns3: replace memory barrier with data dependency order Lijun Ou (2): net/hns3: remove unnecessary input parameter valid judgement net/hns3: remove unnecessary branch Wei Hu (Xavier) (1): doc: update release notes for hns3 doc/guides/nics/hns3.rst | 1 + doc/guides/rel_notes/release_20_02.rst | 6 ++ drivers/net/hns3/hns3_ethdev.c | 2 - drivers/net/hns3/hns3_flow.c | 2 - drivers/net/hns3/hns3_rxtx.c | 85 ++ 5 files changed, 80 insertions(+), 16 deletions(-) -- 2.23.0
[dpdk-dev] [PATCH 1/4] net/hns3: replace memory barrier with data dependency order
From: Chengwen Feng This patch optimizes the Rx performance by using data dependency ordering to instead of memory barrier which is rte_cio_rmb in the '.rx_pkt_burst' ops implementation function named hns3_recv_pkts. Signed-off-by: Chengwen Feng Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_rxtx.c | 85 +++- 1 file changed, 73 insertions(+), 12 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 6f74a7917..9d8d0b7e1 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -1402,13 +1402,14 @@ hns3_rx_set_cksum_flag(struct rte_mbuf *rxm, uint64_t packet_type, uint16_t hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) { + volatile struct hns3_desc *rx_ring; /* RX ring (desc) */ + volatile struct hns3_desc *rxdp; /* pointer of the current desc */ struct hns3_rx_queue *rxq; /* RX queue */ - struct hns3_desc *rx_ring; /* RX ring (desc) */ struct hns3_entry *sw_ring; struct hns3_entry *rxe; - struct hns3_desc *rxdp; /* pointer of the current desc */ struct rte_mbuf *first_seg; struct rte_mbuf *last_seg; + struct hns3_desc rxd; struct rte_mbuf *nmb; /* pointer of the new mbuf */ struct rte_mbuf *rxm; struct rte_eth_dev *dev; @@ -1440,6 +1441,67 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) bd_base_info = rte_le_to_cpu_32(rxdp->rx.bd_base_info); if (unlikely(!hns3_get_bit(bd_base_info, HNS3_RXD_VLD_B))) break; + /* +* The interactive process between software and hardware of +* receiving a new packet in hns3 network engine: +* 1. Hardware network engine firstly writes the packet content +*to the memory pointed by the 'addr' field of the Rx Buffer +*Descriptor, secondly fills the result of parsing the +*packet include the valid field into the Rx Buffer +*Descriptor in one write operation. +* 2. Driver reads the Rx BD's valid field in the loop to check +*whether it's valid, if valid then assign a new address to +*the addr field, clear the valid field, get the other +*information of the packet by parsing Rx BD's other fields, +*finally write back the number of Rx BDs processed by the +*driver to the HNS3_RING_RX_HEAD_REG register to inform +*hardware. +* In the above process, the ordering is very important. We must +* make sure that CPU read Rx BD's other fields only after the +* Rx BD is valid. +* +* There are two type of re-ordering: compiler re-ordering and +* CPU re-ordering under the ARMv8 architecture. +* 1. we use volatile to deal with compiler re-ordering, so you +*can see that rx_ring/rxdp defined with volatile. +* 2. we commonly use memory barrier to deal with CPU +*re-ordering, but the cost is high. +* +* In order to solve the high cost of using memory barrier, we +* use the data dependency order under the ARMv8 architecture, +* for exmple: +* instr01: load A +* instr02: load B <- A +* the instr02 will always execute after instr01. +* +* To construct the data dependency ordering, we use the +* following assignment: +* rxd = rxdp[(bd_base_info & (1u << HNS3_RXD_VLD_B)) - +* (1u<mb_pool); if (unlikely(nmb == NULL)) { @@ -1463,14 +1525,13 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxe->mbuf = nmb; dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb)); - rxdp->addr = dma_addr; rxdp->rx.bd_base_info = 0; + rxdp->addr = dma_addr; - rte_cio_rmb(); /* Load remained descriptor data and extract necessary fields */ - data_len = (uint16_t)(rte_le_to_cpu_16(rxdp->rx.size)); - l234_info = rte_le_to_cpu_32(rxdp->rx.l234_info); - ol_info = rte_le_to_cpu_32(rxdp->rx.ol_info); + data_len = (uint16_t)(rte_le_to_cpu_16(rxd.rx.size)); + l234_info = rte_le_to_cpu_32(rxd.rx.l234_info); + ol_info = rte_le_to_cpu_32(rxd.rx.ol_info); if (first_seg == NULL) {
[dpdk-dev] [PATCH 3/4] net/hns3: remove unnecessary branch
From: Lijun Ou Because the rte layer of DPDK framework has already processed the case when the idx is zero before calling the '.mac_addr_remove' ops function, the input parameter named idx can not be zero in the '.mac_addr_remove' function. This patch removes unnecessary branch process to check whether input parameter named idx is zero in the '.mac_addr_remove' ops implementation function named hns3_remove_mac_addr. Signed-off-by: Lijun Ou Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 9866d147b..918fbe076 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -1473,8 +1473,6 @@ hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) return; } - if (idx == 0) - hw->mac.default_addr_setted = false; rte_spinlock_unlock(&hw->lock); } -- 2.23.0
[dpdk-dev] [PATCH 4/4] doc: update release notes for hns3
From: "Wei Hu (Xavier)" Update release doc briefly describing updates to hns3 PMD for 20.02 release. The support for these was added include the following commits: 1) commit 6e79a0ad1236 ("net/hns3: support Rx interrupt") 2) commit 34c5c2d5abb8 ("net/hns3: support setting VF MAC address by PF driver") Signed-off-by: Wei Hu (Xavier) --- doc/guides/nics/hns3.rst | 1 + doc/guides/rel_notes/release_20_02.rst | 6 ++ 2 files changed, 7 insertions(+) diff --git a/doc/guides/nics/hns3.rst b/doc/guides/nics/hns3.rst index 505488b6c..8d19f4851 100644 --- a/doc/guides/nics/hns3.rst +++ b/doc/guides/nics/hns3.rst @@ -22,6 +22,7 @@ Features of the HNS3 PMD are: - Port hardware statistics - Jumbo frames - Link state information +- Interrupt mode for RX - VLAN stripping - NUMA support diff --git a/doc/guides/rel_notes/release_20_02.rst b/doc/guides/rel_notes/release_20_02.rst index 1e83e659a..b69f45046 100644 --- a/doc/guides/rel_notes/release_20_02.rst +++ b/doc/guides/rel_notes/release_20_02.rst @@ -76,6 +76,12 @@ New Features Added support for L2TPv3 over IP rte_flow patterns to the testpmd application. +* **Updated Hisilicon hns3 driver.** + + Updated Hisilicon hns3 driver with new features and improvements, including: + + * Added support for Rx interrupt. + * Added support setting VF MAC address by PF driver. Removed Items - -- 2.23.0
[dpdk-dev] [PATCH] ethdev: move non null judgment of ops function pointer ahead
From: "Wei Hu (Xavier)" This patch moves the following judgement statement to the first half of the function named rte_eth_dev_set_vlan_offload, so we can avoid changing the content of dev->data->dev_conf.rxmode.offloads even when the pointer named dev->dev_ops->vlan_offload_set is NULL: RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP); Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chunsong Feng Signed-off-by: Min Wang (Jushui) Signed-off-by: Min Hu (Connor) --- lib/librte_ethdev/rte_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index aec2d0f70..21f24cd7f 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3257,6 +3257,7 @@ rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask) RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP); /* save original values in case of failure */ orig_offloads = dev->data->dev_conf.rxmode.offloads; @@ -3307,7 +3308,6 @@ rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask) if (mask == 0) return ret; - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP); ret = (*dev->dev_ops->vlan_offload_set)(dev, mask); if (ret) { /* hit an error restore original values */ -- 2.23.0
Re: [dpdk-dev] [PATCH] ethdev: move non null judgment of ops function pointer ahead
Hi, Ferruh Yigit On 2020/1/17 5:08, Ferruh Yigit wrote: On 1/16/2020 12:27 PM, Wei Hu (Xavier) wrote: From: "Wei Hu (Xavier)" This patch moves the following judgement statement to the first half of the function named rte_eth_dev_set_vlan_offload, so we can avoid changing the content of dev->data->dev_conf.rxmode.offloads even when the pointer named dev->dev_ops->vlan_offload_set is NULL: RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP); Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chunsong Feng Signed-off-by: Min Wang (Jushui) Signed-off-by: Min Hu (Connor) --- lib/librte_ethdev/rte_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index aec2d0f70..21f24cd7f 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3257,6 +3257,7 @@ rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask) RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP); /* save original values in case of failure */ orig_offloads = dev->data->dev_conf.rxmode.offloads; @@ -3307,7 +3308,6 @@ rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask) if (mask == 0) return ret; - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP); ret = (*dev->dev_ops->vlan_offload_set)(dev, mask); if (ret) { /* hit an error restore original values */ I agree this side affect is a defect, thanks for spotting. Above approach would work, but also I think it was good approach to return success (0) when no change at all requested, we are loosing it here. What do you think, - Update a local 'dev_offloads' variable, instead of directly updating the device config data - if no change requested, "mask == 0", return success - if change requested, check the 'vlan_offload_set' dev_ops in this stage - assign the local 'dev_offloads' to 'dev->data->dev_conf.rxmode.offloads' and call the dev_ops - On error recover the 'dev->data->dev_conf.rxmode.offloads' to 'orig_offloads' This way both side affect can be prevented and API returns success if no change requested. I agree your opinion and will send V2. Thanks Xavier
[dpdk-dev] [PATCH v2] ethdev: fix updating device data when ops pointer is NULL
From: "Wei Hu (Xavier)" Currently, there is a potential problem that changing the content of dev->data->dev_conf.rxmode.offloads even when the pointer named dev->dev_ops->vlan_offload_set is NULL in the API function named rte_eth_dev_set_vlan_offload. It is a good idea that prevent the side effect and make the API return success if no change requested. This patch fixes the problem, the detail information as below: - Update a local 'dev_offloads' variable, instead of directly updating the device config data - if no change requested, "mask == 0", return success - if change requested, check the 'vlan_offload_set' dev_ops in this stage - assign the local 'dev_offloads' to 'dev->data->dev_conf.rxmode.offloads' and call the dev_ops - On error recover the 'dev->data->dev_conf.rxmode.offloads' to 'orig_offloads' Fixes: 01eb53eefeb4 ("ethdev: rename folder to library name") Cc: sta...@dpdk.org Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chunsong Feng Signed-off-by: Min Wang (Jushui) Signed-off-by: Min Hu (Connor) --- v1 -> v2: 1. Update the modification according to Ferruh Yigit's comment. The related link as below: http://patches.dpdk.org/patch/64779/ 2. Update the commit log and title of the patch. --- lib/librte_ethdev/rte_ethdev.c | 31 --- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index aec2d0f70..9232503f7 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3253,53 +3253,53 @@ rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask) int mask = 0; int cur, org = 0; uint64_t orig_offloads; - uint64_t *dev_offloads; + uint64_t dev_offloads; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; /* save original values in case of failure */ orig_offloads = dev->data->dev_conf.rxmode.offloads; - dev_offloads = &dev->data->dev_conf.rxmode.offloads; + dev_offloads = orig_offloads; /*check which option changed by application*/ cur = !!(offload_mask & ETH_VLAN_STRIP_OFFLOAD); - org = !!(*dev_offloads & DEV_RX_OFFLOAD_VLAN_STRIP); + org = !!(dev_offloads & DEV_RX_OFFLOAD_VLAN_STRIP); if (cur != org) { if (cur) - *dev_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; + dev_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; else - *dev_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; + dev_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; mask |= ETH_VLAN_STRIP_MASK; } cur = !!(offload_mask & ETH_VLAN_FILTER_OFFLOAD); - org = !!(*dev_offloads & DEV_RX_OFFLOAD_VLAN_FILTER); + org = !!(dev_offloads & DEV_RX_OFFLOAD_VLAN_FILTER); if (cur != org) { if (cur) - *dev_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; + dev_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; else - *dev_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER; + dev_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER; mask |= ETH_VLAN_FILTER_MASK; } cur = !!(offload_mask & ETH_VLAN_EXTEND_OFFLOAD); - org = !!(*dev_offloads & DEV_RX_OFFLOAD_VLAN_EXTEND); + org = !!(dev_offloads & DEV_RX_OFFLOAD_VLAN_EXTEND); if (cur != org) { if (cur) - *dev_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND; + dev_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND; else - *dev_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND; + dev_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND; mask |= ETH_VLAN_EXTEND_MASK; } cur = !!(offload_mask & ETH_QINQ_STRIP_OFFLOAD); - org = !!(*dev_offloads & DEV_RX_OFFLOAD_QINQ_STRIP); + org = !!(dev_offloads & DEV_RX_OFFLOAD_QINQ_STRIP); if (cur != org) { if (cur) - *dev_offloads |= DEV_RX_OFFLOAD_QINQ_STRIP; + dev_offloads |= DEV_RX_OFFLOAD_QINQ_STRIP; else - *dev_offloads &= ~DEV_RX_OFFLOAD_QINQ_STRIP; + dev_offloads &= ~DEV_RX_OFFLOAD_QINQ_STRIP; mask |= ETH_QINQ_STRIP_MASK; } @@ -3308,10 +3308,11 @@ rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask) return ret; RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP); + dev->data->dev_conf.rxmode.of
Re: [dpdk-dev] [PATCH v2] ethdev: fix updating device data when ops pointer is NULL
Hi,Andrew Rybchenko On 2020/1/17 15:57, Andrew Rybchenko wrote: On 1/17/20 9:23 AM, Wei Hu (Xavier) wrote: From: "Wei Hu (Xavier)" I think summary is misleading. It is too generic and does not mention VLAN offloads. Consider something like: ethdev: fix VLAN offloads set if no driver callback Currently, there is a potential problem that changing the content of dev->data->dev_conf.rxmode.offloads even when the pointer named dev->dev_ops->vlan_offload_set is NULL in the API function named rte_eth_dev_set_vlan_offload. Consider to change "when the pointer named dev->dev_ops->vlan_offload_set is NULL in the API function named rte_eth_dev_set_vlan_offload." to "when there is no vlan_offload_set driver callback." It is a good idea that prevent the side effect and make the API return success if no change requested. This patch fixes the problem, the detail information as below: - Update a local 'dev_offloads' variable, instead of directly updating the device config data - if no change requested, "mask == 0", return success - if change requested, check the 'vlan_offload_set' dev_ops in this stage - assign the local 'dev_offloads' to 'dev->data->dev_conf.rxmode.offloads' and call the dev_ops - On error recover the 'dev->data->dev_conf.rxmode.offloads' to 'orig_offloads' I see no point to repeat in description what the code does. IMHO it is sufficient to mention main ideas: - keep possibility to do dummy set even if there is no driver callback - do not touch Rx mode offloads in device data before checking the driver callback availability - ensure that Rx mode offloads are rolled back correctly if driver callback returns error Fixes: 01eb53eefeb4 ("ethdev: rename folder to library name") I think it is wrong Fixes. Rename just moves the code, it is not the changeset which introduces the bug. Cc: sta...@dpdk.org Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chunsong Feng Signed-off-by: Min Wang (Jushui) Signed-off-by: Min Hu (Connor) with above notes processed Reviewed-by: Andrew Rybchenko Thanks for your comments, I will update it and send V3. Regards Xavier
[dpdk-dev] [PATCH v3] ethdev: fix VLAN offloads set if no driver callback
From: "Wei Hu (Xavier)" Currently, there is a potential problem that changing the content of dev->data->dev_conf.rxmode.offloads even when there is no vlan_offload_set driver callback. It is a good idea that prevent the side effect and make the API return success if no change requested. This patch fixes the problem, the detail information as below: - keep possibility to do dummy set even if there is no driver callback - do not touch Rx mode offloads in device data before checking the driver callback availability - ensure that Rx mode offloads are rolled back correctly if driver callback returns error Fixes: dfebfc9882fb ("ethdev: support dynamic configuration of QinQ strip") Cc: sta...@dpdk.org Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chunsong Feng Signed-off-by: Min Wang (Jushui) Signed-off-by: Min Hu (Connor) Reviewed-by: Andrew Rybchenko --- v2 -> v3: 1. Update the commit log and titile of the patch according to Andrew Rybchenko's comments. The related link as below: http://patches.dpdk.org/patch/64825/ v1 -> v2: 1. Update the modification according to Ferruh Yigit's comment. The related link as below: http://patches.dpdk.org/patch/64779/ 2. Update the commit log and title of the patch. --- lib/librte_ethdev/rte_ethdev.c | 31 --- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index aec2d0f70..9232503f7 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3253,53 +3253,53 @@ rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask) int mask = 0; int cur, org = 0; uint64_t orig_offloads; - uint64_t *dev_offloads; + uint64_t dev_offloads; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; /* save original values in case of failure */ orig_offloads = dev->data->dev_conf.rxmode.offloads; - dev_offloads = &dev->data->dev_conf.rxmode.offloads; + dev_offloads = orig_offloads; /*check which option changed by application*/ cur = !!(offload_mask & ETH_VLAN_STRIP_OFFLOAD); - org = !!(*dev_offloads & DEV_RX_OFFLOAD_VLAN_STRIP); + org = !!(dev_offloads & DEV_RX_OFFLOAD_VLAN_STRIP); if (cur != org) { if (cur) - *dev_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; + dev_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; else - *dev_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; + dev_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; mask |= ETH_VLAN_STRIP_MASK; } cur = !!(offload_mask & ETH_VLAN_FILTER_OFFLOAD); - org = !!(*dev_offloads & DEV_RX_OFFLOAD_VLAN_FILTER); + org = !!(dev_offloads & DEV_RX_OFFLOAD_VLAN_FILTER); if (cur != org) { if (cur) - *dev_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; + dev_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; else - *dev_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER; + dev_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER; mask |= ETH_VLAN_FILTER_MASK; } cur = !!(offload_mask & ETH_VLAN_EXTEND_OFFLOAD); - org = !!(*dev_offloads & DEV_RX_OFFLOAD_VLAN_EXTEND); + org = !!(dev_offloads & DEV_RX_OFFLOAD_VLAN_EXTEND); if (cur != org) { if (cur) - *dev_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND; + dev_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND; else - *dev_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND; + dev_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND; mask |= ETH_VLAN_EXTEND_MASK; } cur = !!(offload_mask & ETH_QINQ_STRIP_OFFLOAD); - org = !!(*dev_offloads & DEV_RX_OFFLOAD_QINQ_STRIP); + org = !!(dev_offloads & DEV_RX_OFFLOAD_QINQ_STRIP); if (cur != org) { if (cur) - *dev_offloads |= DEV_RX_OFFLOAD_QINQ_STRIP; + dev_offloads |= DEV_RX_OFFLOAD_QINQ_STRIP; else - *dev_offloads &= ~DEV_RX_OFFLOAD_QINQ_STRIP; + dev_offloads &= ~DEV_RX_OFFLOAD_QINQ_STRIP; mask |= ETH_QINQ_STRIP_MASK; } @@ -3308,10 +3308,11 @@ rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask) return ret; RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP); + dev->data->dev_conf.rxmode.offloads = dev_offloads; ret = (*dev->dev_op
[dpdk-dev] [PATCH 0/3] app/testpmd: fixes for testpmd application
These patchset are fixes for testpmd application. Wei Hu (Xavier) (3): app/testpmd: update Rx offload after setting MTU sccessfully app/testpmd: fix the initial value when setting PFC app/testpmd: fix uninitialized members when setting PFC app/test-pmd/cmdline.c | 3 ++- app/test-pmd/config.c | 18 +- 2 files changed, 19 insertions(+), 2 deletions(-) -- 2.23.0
[dpdk-dev] [PATCH 3/3] app/testpmd: fix uninitialized members when setting PFC
From: "Wei Hu (Xavier)" Only a part of members in the local structure variable named pfc_conf are initialized in the function named cmd_priority_flow_ctrl_set_parsed when typing "set pfc_ctrl..." command, and others are random values. However, those uninitialized members may cause failure. This patch adds clearing zero operation before calling the API named rte_eth_dev_priority_flow_ctrl_set API with pfc_conf as the input parameter. Fixes: 9b53e542e9e1 ("app/testpmd: add priority flow control") Cc: sta...@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Wei Hu (Xavier) Signed-off-by: Xuan Li --- app/test-pmd/cmdline.c | 1 + 1 file changed, 1 insertion(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index a09cb87e1..b6d8ef0f0 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -7090,6 +7090,7 @@ cmd_priority_flow_ctrl_set_parsed(void *parsed_result, {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} }; + memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf)); rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; -- 2.23.0
[dpdk-dev] [PATCH 2/3] app/testpmd: fix the initial value when setting PFC
From: "Wei Hu (Xavier)" Currently, the initial values of the local structure variable named rx_tx_onoff_2_lfc_mode and rx_tx_onoff_2_pfc_mode are different in the similar part of these two following functions: cmd_link_flow_ctrl_set_parsed cmd_priority_flow_ctrl_set_parsed 1) The code snippset in cmd_link_flow_ctrl_set_parsed function: static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} }; if (!cmd || cmd == &cmd_link_flow_control_set_rx) rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; if (!cmd || cmd == &cmd_link_flow_control_set_tx) tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; <...> ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); <...> 2) The code snippset in cmd_priority_flow_ctrl_set_parsed function: static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL} }; rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; <...> ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); <...> The initial value of rx_tx_onoff_2_pfc_mode is wrong, it should be the same as rx_tx_onoff_2_lfc_mode. Fixes: 9b53e542e9e1 ("app/testpmd: add priority flow control") Cc: sta...@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Wei Hu (Xavier) Signed-off-by: Xuan Li --- app/test-pmd/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index dab22bc4d..a09cb87e1 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -7087,7 +7087,7 @@ cmd_priority_flow_ctrl_set_parsed(void *parsed_result, * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. */ static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { - {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL} + {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} }; rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; -- 2.23.0
[dpdk-dev] [PATCH 1/3] app/testpmd: update Rx offload after setting MTU sccessfully
From: "Wei Hu (Xavier)" Currently, Rx offload capabilities and max_rx_pkt_len in the struct variable named rte_port are not updated after setting mtu successfully in port_mtu_set function by 'port config mtu ' command. This may lead to reconfig mtu to the initial value in the driver when recalling rte_eth_dev_configure API interface. This patch updates Rx offload capabilities and max_rx_pkt_len after setting mtu successfully when configuring mtu. Fixes: ae03d0d18adf ("app/testpmd: command to configure MTU") Cc: sta...@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Wei Hu (Xavier) --- app/test-pmd/config.c | 18 +- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 9669cbd4c..09a1579f5 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1216,7 +1216,9 @@ void port_mtu_set(portid_t port_id, uint16_t mtu) { int diag; + struct rte_port *rte_port = &ports[port_id]; struct rte_eth_dev_info dev_info; + uint16_t eth_overhead; int ret; if (port_id_is_invalid(port_id, ENABLED_WARN)) @@ -1232,8 +1234,22 @@ port_mtu_set(portid_t port_id, uint16_t mtu) return; } diag = rte_eth_dev_set_mtu(port_id, mtu); - if (diag == 0) + if (diag == 0) { + /* +* Ether overhead in driver is equal to the difference of +* max_rx_pktlen and max_mtu in rte_eth_dev_info. +*/ + eth_overhead = dev_info.max_rx_pktlen - dev_info.max_mtu; + if (mtu > RTE_ETHER_MAX_LEN - eth_overhead) + rte_port->dev_conf.rxmode.offloads |= + DEV_RX_OFFLOAD_JUMBO_FRAME; + else + rte_port->dev_conf.rxmode.offloads &= + ~DEV_RX_OFFLOAD_JUMBO_FRAME; + rte_port->dev_conf.rxmode.max_rx_pkt_len = mtu + eth_overhead; + return; + } printf("Set MTU failed. diag=%d\n", diag); } -- 2.23.0
Re: [dpdk-dev] [EXT] Re: [PATCH v4 2/2] ethdev: fix VLAN offloads set if no relative capabilities
On 2020/6/29 22:47, Harman Kalra wrote: Acked-by: Harman Kalra Hi,Harman Kalra Thanks Xavier On Mon, Jun 29, 2020 at 09:34:00AM +0800, Wei Hu (Xavier) wrote: External Email -- Hi, Heinrich Kuhn & Harman Kalra & Jerin Jacob & Nithin Dabilpuram & Kiran Kumar K & Rasesh Mody & Shahed Shaikh & Qi Zhang & Xiao Wang & Beilei Xing & Jeff Guo. Could you please help to review this patch and give 'Acked-by' if there are no objects. Thanks, Xavier On 2020/6/22 16:09, Wei Hu (Xavier) wrote: Currently, there is a potential problem that calling the API function rte_eth_dev_set_vlan_offload to start VLAN hardware offloads which the driver does not support. If the PMD driver does not support certain VLAN hardware offloads and does not check for it, the hardware setting will not change, but the VLAN offloads in dev->data->dev_conf.rxmode.offloads will be turned on. It is supposed to check the hardware capabilities to decide whether the relative callback needs to be called just like the behavior in the API function named rte_eth_dev_configure. And it is also needed to cleanup duplicated checks which are done in some PMDs. Also, note that it is behaviour change for some PMDs which simply ignore (with error/warning log message) unsupported VLAN offloads, but now it will fail. Fixes: a4996bd89c42 ("ethdev: new Rx/Tx offloads API") Cc: sta...@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) Acked-by: Andrew Rybchenko Acked-by: Hyong Youb Kim --- v3 -> v4: Delete "next_mask" label and modify the function that when the offload is not supported the function fail. v2 -> v3: Add __rte_unused to avoid unused parameter 'dev' and 'mask' warning. v1 -> v2: Cleanup duplicated checks which are done in some PMDs. --- drivers/net/dpaa2/dpaa2_ethdev.c | 12 +++- drivers/net/enic/enic_ethdev.c | 12 drivers/net/fm10k/fm10k_ethdev.c | 23 ++- drivers/net/hinic/hinic_pmd_ethdev.c | 6 -- drivers/net/i40e/i40e_ethdev.c | 5 - drivers/net/nfp/nfp_net.c | 5 - drivers/net/octeontx/octeontx_ethdev_ops.c | 10 -- drivers/net/octeontx2/otx2_vlan.c | 5 - drivers/net/qede/qede_ethdev.c | 3 --- lib/librte_ethdev/rte_ethdev.c | 21 + 10 files changed, 26 insertions(+), 76 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 2f031ec..17a7a49 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -147,7 +147,7 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) { struct dpaa2_dev_priv *priv = dev->data->dev_private; struct fsl_mc_io *dpni = dev->process_private; - int ret; + int ret = 0; PMD_INIT_FUNC_TRACE(); @@ -155,7 +155,7 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) /* VLAN Filter not avaialble */ if (!priv->max_vlan_filters) { DPAA2_PMD_INFO("VLAN filter not available"); - goto next_mask; + return -ENOTSUP; } if (dev->data->dev_conf.rxmode.offloads & @@ -168,14 +168,8 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) if (ret < 0) DPAA2_PMD_INFO("Unable to set vlan filter = %d", ret); } -next_mask: - if (mask & ETH_VLAN_EXTEND_MASK) { - if (dev->data->dev_conf.rxmode.offloads & - DEV_RX_OFFLOAD_VLAN_EXTEND) - DPAA2_PMD_INFO("VLAN extend offload not supported"); - } - return 0; + return ret; } static int diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 32d5397..ef8900d 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -374,18 +374,6 @@ static int enicpmd_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask) enic->ig_vlan_strip_en = 0; } - if ((mask & ETH_VLAN_FILTER_MASK) && - (offloads & DEV_RX_OFFLOAD_VLAN_FILTER)) { - dev_warning(enic, - "Configuration of VLAN filter is not supported\n"); - } - - if ((mask & ETH_VLAN_EXTEND_MASK) && - (offloads & DEV_RX_OFFLOAD_VLAN_EXTEND)) { - dev_warning(enic, - "Configuration of extended VLAN is not supported\n"); - } - return enic_set_vlan_strip(enic); } diff --git a/drivers/net/fm10k/fm10k_ethdev.c b
[dpdk-dev] [PATCH 00/10] misc updates for hns3 PMD driver
This series are minor features and bugfixes for hns3 PMD driver. Chengchang Tang (2): net/hns3: decrease non-nearby memory access in Rx net/hns3: support setting VF PVID by PF driver Hongbo Zheng (1): net/hns3: clear residual hardware configurations on init Lijun Ou (2): net/hns3: support symmetric RSS net/hns3: report Tx descriptor segment limitations Wei Hu (Xavier) (5): net/hns3: support LRO net/hns3: get device capability in primary process net/hns3: fix Rx buffer size net/hns3: fix reassembling multiple segment packets in Tx net/hns3: add Scattered Rx and Multiprocess to feature list doc/guides/nics/features/hns3.ini| 3 + doc/guides/nics/features/hns3_vf.ini | 3 + doc/guides/nics/hns3.rst | 1 + drivers/net/hns3/hns3_cmd.h | 3 + drivers/net/hns3/hns3_ethdev.c | 150 + drivers/net/hns3/hns3_ethdev.h | 16 ++- drivers/net/hns3/hns3_ethdev_vf.c| 122 drivers/net/hns3/hns3_flow.c | 12 +- drivers/net/hns3/hns3_mbx.c | 33 ++ drivers/net/hns3/hns3_mbx.h | 3 + drivers/net/hns3/hns3_rss.c | 27 +++-- drivers/net/hns3/hns3_rss.h | 5 +- drivers/net/hns3/hns3_rxtx.c | 210 +-- drivers/net/hns3/hns3_rxtx.h | 25 - 14 files changed, 512 insertions(+), 101 deletions(-) -- 2.7.4
[dpdk-dev] [PATCH 01/10] net/hns3: support symmetric RSS
From: Lijun Ou This patch adds support of symmetric algorithm of RSS. Signed-off-by: Lijun Ou Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chengwen Feng --- drivers/net/hns3/hns3_flow.c | 12 +++- drivers/net/hns3/hns3_rss.c | 27 +-- drivers/net/hns3/hns3_rss.h | 5 +++-- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index c7851b2..1e58ad7 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1287,6 +1287,7 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev, case RTE_ETH_HASH_FUNCTION_DEFAULT: case RTE_ETH_HASH_FUNCTION_TOEPLITZ: case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: + case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ: break; default: return rte_flow_error_set(error, ENOTSUP, @@ -1365,6 +1366,9 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: *hash_algo = HNS3_RSS_HASH_ALGO_SIMPLE; break; + case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ: + *hash_algo = HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP; + break; default: hns3_err(hw, "Invalid RSS algorithm configuration(%u)", algo_func); @@ -1378,9 +1382,6 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, static int hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) { - uint8_t hash_algo = - (hw->rss_info.conf.func == RTE_ETH_HASH_FUNCTION_TOEPLITZ ? -HNS3_RSS_HASH_ALGO_TOEPLITZ : HNS3_RSS_HASH_ALGO_SIMPLE); struct hns3_rss_tuple_cfg *tuple; int ret; @@ -1388,11 +1389,12 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) hns3_parse_rss_key(hw, rss_config); /* Parse hash algorithm */ - ret = hns3_parse_rss_algorithm(hw, &rss_config->func, &hash_algo); + ret = hns3_parse_rss_algorithm(hw, &rss_config->func, + &hw->rss_info.hash_algo); if (ret) return ret; - ret = hns3_set_rss_algo_key(hw, hash_algo, rss_config->key); + ret = hns3_set_rss_algo_key(hw, rss_config->key); if (ret) return ret; diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index a6cab29..247bd7d 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -28,7 +28,7 @@ static const uint8_t hns3_hash_key[] = { * Used to set algorithm, key_offset and hash key of rss. */ int -hns3_set_rss_algo_key(struct hns3_hw *hw, uint8_t hash_algo, const uint8_t *key) +hns3_set_rss_algo_key(struct hns3_hw *hw, const uint8_t *key) { #define HNS3_KEY_OFFSET_MAX3 #define HNS3_SET_HASH_KEY_BYTE_FOUR2 @@ -51,7 +51,8 @@ hns3_set_rss_algo_key(struct hns3_hw *hw, uint8_t hash_algo, const uint8_t *key) hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_GENERIC_CONFIG, false); - req->hash_config |= (hash_algo & HNS3_RSS_HASH_ALGO_MASK); + req->hash_config |= + (hw->rss_info.hash_algo & HNS3_RSS_HASH_ALGO_MASK); req->hash_config |= (key_offset << HNS3_RSS_HASH_KEY_OFFSET_B); if (key_offset == HNS3_SET_HASH_KEY_BYTE_FOUR) @@ -256,7 +257,6 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets; struct hns3_rss_conf *rss_cfg = &hw->rss_info; uint8_t key_len = rss_conf->rss_key_len; - uint8_t algo; uint64_t rss_hf = rss_conf->rss_hf; uint8_t *key = rss_conf->rss_key; int ret; @@ -292,9 +292,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, ret = -EINVAL; goto conf_err; } - algo = rss_cfg->conf.func == RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ? - HNS3_RSS_HASH_ALGO_SIMPLE : HNS3_RSS_HASH_ALGO_TOEPLITZ; - ret = hns3_set_rss_algo_key(hw, algo, key); + ret = hns3_set_rss_algo_key(hw, key); if (ret) goto conf_err; } @@ -529,20 +527,29 @@ hns3_config_rss(struct hns3_adapter *hns) { struct hns3_hw *hw = &hns->hw; struct hns3_rss_conf *rss_cfg = &hw->rss_info; - uint8_t hash_algo = - (hw->rss_info.conf.func == RTE_ETH_HASH_FUNCTION_TOEPLITZ ? -HNS3_RSS_HASH_ALGO_TOEPLITZ : HNS3_RSS_HASH_ALGO_SIMPLE); uint8_t *hash_key = rss_cfg->key; int ret, ret1; enum rte_eth_rx_mq_mode mq_mode = hw-&
[dpdk-dev] [PATCH 02/10] net/hns3: support LRO
This patch adds support of LRO offload for hns3 PMD driver. Signed-off-by: Hongbo Zheng Signed-off-by: Wei Hu (Xavier) --- doc/guides/nics/features/hns3.ini| 1 + doc/guides/nics/features/hns3_vf.ini | 1 + doc/guides/nics/hns3.rst | 1 + drivers/net/hns3/hns3_ethdev.c | 35 drivers/net/hns3/hns3_ethdev.h | 2 +- drivers/net/hns3/hns3_ethdev_vf.c| 16 - drivers/net/hns3/hns3_rxtx.c | 45 drivers/net/hns3/hns3_rxtx.h | 4 +++- 8 files changed, 82 insertions(+), 23 deletions(-) diff --git a/doc/guides/nics/features/hns3.ini b/doc/guides/nics/features/hns3.ini index c3a8544..66abda7 100644 --- a/doc/guides/nics/features/hns3.ini +++ b/doc/guides/nics/features/hns3.ini @@ -9,6 +9,7 @@ Rx interrupt = Y MTU update = Y Jumbo frame = Y TSO = Y +LRO = Y Promiscuous mode = Y Allmulticast mode= Y Unicast MAC filter = Y diff --git a/doc/guides/nics/features/hns3_vf.ini b/doc/guides/nics/features/hns3_vf.ini index 80773ac..71d246a 100644 --- a/doc/guides/nics/features/hns3_vf.ini +++ b/doc/guides/nics/features/hns3_vf.ini @@ -9,6 +9,7 @@ Rx interrupt = Y MTU update = Y Jumbo frame = Y TSO = Y +LRO = Y Promiscuous mode = Y Allmulticast mode= Y Unicast MAC filter = Y diff --git a/doc/guides/nics/hns3.rst b/doc/guides/nics/hns3.rst index 05dbe41..ae3c5f6 100644 --- a/doc/guides/nics/hns3.rst +++ b/doc/guides/nics/hns3.rst @@ -18,6 +18,7 @@ Features of the HNS3 PMD are: - Packet type information - Checksum offload - TSO offload +- LRO offload - Promiscuous mode - Multicast mode - Port hardware statistics diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 62d8758..7758855 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -1099,25 +1099,6 @@ hns3_config_tso(struct hns3_hw *hw, unsigned int tso_mss_min, return hns3_cmd_send(hw, &desc, 1); } -int -hns3_config_gro(struct hns3_hw *hw, bool en) -{ - struct hns3_cfg_gro_status_cmd *req; - struct hns3_cmd_desc desc; - int ret; - - hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_GRO_GENERIC_CONFIG, false); - req = (struct hns3_cfg_gro_status_cmd *)desc.data; - - req->gro_en = rte_cpu_to_le_16(en ? 1 : 0); - - ret = hns3_cmd_send(hw, &desc, 1); - if (ret) - hns3_err(hw, "GRO hardware config cmd failed, ret = %d", ret); - - return ret; -} - static int hns3_set_umv_space(struct hns3_hw *hw, uint16_t space_size, uint16_t *allocated_size, bool is_alloc) @@ -2276,6 +2257,7 @@ hns3_dev_configure(struct rte_eth_dev *dev) uint16_t nb_tx_q = dev->data->nb_tx_queues; struct rte_eth_rss_conf rss_conf; uint16_t mtu; + bool gro_en; int ret; /* @@ -2342,6 +2324,12 @@ hns3_dev_configure(struct rte_eth_dev *dev) if (ret) goto cfg_err; + /* config hardware GRO */ + gro_en = conf->rxmode.offloads & DEV_RX_OFFLOAD_TCP_LRO ? true : false; + ret = hns3_config_gro(hw, gro_en); + if (ret) + goto cfg_err; + hw->adapter_state = HNS3_NIC_CONFIGURED; return 0; @@ -2449,6 +2437,7 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) info->min_rx_bufsize = hw->rx_buf_len; info->max_mac_addrs = HNS3_UC_MACADDR_NUM; info->max_mtu = info->max_rx_pktlen - HNS3_ETH_OVERHEAD; + info->max_lro_pkt_size = HNS3_MAX_LRO_SIZE; info->rx_offload_capa = (DEV_RX_OFFLOAD_IPV4_CKSUM | DEV_RX_OFFLOAD_TCP_CKSUM | DEV_RX_OFFLOAD_UDP_CKSUM | @@ -2460,7 +2449,8 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) DEV_RX_OFFLOAD_VLAN_STRIP | DEV_RX_OFFLOAD_VLAN_FILTER | DEV_RX_OFFLOAD_JUMBO_FRAME | -DEV_RX_OFFLOAD_RSS_HASH); +DEV_RX_OFFLOAD_RSS_HASH | +DEV_RX_OFFLOAD_TCP_LRO); info->tx_queue_offload_capa = DEV_TX_OFFLOAD_MBUF_FAST_FREE; info->tx_offload_capa = (DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM | DEV_TX_OFFLOAD_IPV4_CKSUM | @@ -4381,6 +4371,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) hns3_enable_hw_error_intr(hns, false); hns3_rss_uninit(hns); + (void)hns3_config_gro(hw, false); hns3_promisc_uninit(hw); hns3_fdir_filter_uninit(hns); hns3_uninit_umv_space(hw); @@ -5215,6 +5206,10 @@ hns3_restore_conf(struct hns3_adapter *h
[dpdk-dev] [PATCH 06/10] net/hns3: clear residual hardware configurations on init
From: Hongbo Zheng When the last driver exits abnormally, for example, it is killed by 'kill -9', it may be too late to clear the configuration and cause the configuration to remain. Therefore, to ensure that the hardware environment is clean during initialization, the PF driver actively clear the hardware environment during initialization, including PF and corresponding VFs' vlan, mac, flow table configurations, etc. Fixes: d51867db65c1 ("net/hns3: add initialization") Cc: sta...@dpdk.org Signed-off-by: Hongbo Zheng Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chengwen Feng --- drivers/net/hns3/hns3_cmd.h| 3 +++ drivers/net/hns3/hns3_ethdev.c | 27 +++ 2 files changed, 30 insertions(+) diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h index da770ac..b203e66 100644 --- a/drivers/net/hns3/hns3_cmd.h +++ b/drivers/net/hns3/hns3_cmd.h @@ -207,6 +207,9 @@ enum hns3_opcode_type { HNS3_OPC_FD_AD_OP = 0x1204, HNS3_OPC_FD_COUNTER_OP = 0x1205, + /* Clear hardware state command */ + HNS3_OPC_CLEAR_HW_STATE = 0x700A, + /* SFP command */ HNS3_OPC_SFP_GET_SPEED = 0x7104, diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index a43ed82..1c234da 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -4322,6 +4322,21 @@ hns3_init_hardware(struct hns3_adapter *hns) } static int +hns3_clear_hw(struct hns3_hw *hw) +{ + struct hns3_cmd_desc desc; + int ret; + + hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_CLEAR_HW_STATE, false); + + ret = hns3_cmd_send(hw, &desc, 1); + if (ret && ret != -EOPNOTSUPP) + return ret; + + return 0; +} + +static int hns3_init_pf(struct rte_eth_dev *eth_dev) { struct rte_device *dev = eth_dev->device; @@ -4351,6 +4366,18 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) goto err_cmd_init; } + /* +* To ensure that the hardware environment is clean during +* initialization, the driver actively clear the hardware environment +* during initialization, including PF and corresponding VFs' vlan, mac, +* flow table configurations, etc. +*/ + ret = hns3_clear_hw(hw); + if (ret) { + PMD_INIT_LOG(ERR, "failed to clear hardware: %d", ret); + goto err_cmd_init; + } + ret = rte_intr_callback_register(&pci_dev->intr_handle, hns3_interrupt_handler, eth_dev); -- 2.7.4
[dpdk-dev] [PATCH 09/10] net/hns3: fix reassembling multiple segment packets in Tx
Because of the hardware constraints, hns3 network engine doesn't support sending packets with more than eight fragments. And hns3 pmd driver tries to reassemble these kind of packets to meet hardware requirements. Currently, there are two problems: 1) when the input buffer_len * 8 < pkt_len, the packets are impossible to be reassembled into 8 Buffer Descriptors. In this case, the packets will be passed to hardware, which eventually causes a hardware reset. 2) The meta data in origin packets which are required to fill into the descriptor haven't been copied into the reassembled pkts. This patch adds a check for 1) to ensure such packets will be dropped by driver and copies useful meta data from the origin packets to the reassembled packets. Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") Cc: sta...@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chengwen Feng --- drivers/net/hns3/hns3_rxtx.c | 25 + 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 931d89a..8892fc1 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -2095,6 +2095,20 @@ hns3_tx_alloc_mbufs(struct hns3_tx_queue *txq, struct rte_mempool *mb_pool, return 0; } +static inline void +hns3_pktmbuf_copy_hdr(struct rte_mbuf *new_pkt, struct rte_mbuf *old_pkt) +{ + new_pkt->ol_flags = old_pkt->ol_flags; + new_pkt->pkt_len = rte_pktmbuf_pkt_len(old_pkt); + new_pkt->outer_l2_len = old_pkt->outer_l2_len; + new_pkt->outer_l3_len = old_pkt->outer_l3_len; + new_pkt->l2_len = old_pkt->l2_len; + new_pkt->l3_len = old_pkt->l3_len; + new_pkt->l4_len = old_pkt->l4_len; + new_pkt->vlan_tci_outer = old_pkt->vlan_tci_outer; + new_pkt->vlan_tci = old_pkt->vlan_tci; +} + static int hns3_reassemble_tx_pkts(void *tx_queue, struct rte_mbuf *tx_pkt, struct rte_mbuf **new_pkt) @@ -2118,9 +2132,11 @@ hns3_reassemble_tx_pkts(void *tx_queue, struct rte_mbuf *tx_pkt, mb_pool = tx_pkt->pool; buf_size = tx_pkt->buf_len - RTE_PKTMBUF_HEADROOM; - nb_new_buf = (tx_pkt->pkt_len - 1) / buf_size + 1; + nb_new_buf = (rte_pktmbuf_pkt_len(tx_pkt) - 1) / buf_size + 1; + if (nb_new_buf > HNS3_MAX_NON_TSO_BD_PER_PKT) + return -EINVAL; - last_buf_len = tx_pkt->pkt_len % buf_size; + last_buf_len = rte_pktmbuf_pkt_len(tx_pkt) % buf_size; if (last_buf_len == 0) last_buf_len = buf_size; @@ -2132,7 +2148,7 @@ hns3_reassemble_tx_pkts(void *tx_queue, struct rte_mbuf *tx_pkt, /* Copy the original packet content to the new mbufs */ temp = tx_pkt; s = rte_pktmbuf_mtod(temp, char *); - len_s = temp->data_len; + len_s = rte_pktmbuf_data_len(temp); temp_new = new_mbuf; for (i = 0; i < nb_new_buf; i++) { d = rte_pktmbuf_mtod(temp_new, char *); @@ -2155,13 +2171,14 @@ hns3_reassemble_tx_pkts(void *tx_queue, struct rte_mbuf *tx_pkt, if (temp == NULL) break; s = rte_pktmbuf_mtod(temp, char *); - len_s = temp->data_len; + len_s = rte_pktmbuf_data_len(temp); } } temp_new->data_len = buf_len; temp_new = temp_new->next; } + hns3_pktmbuf_copy_hdr(new_mbuf, tx_pkt); /* free original mbufs */ rte_pktmbuf_free(tx_pkt); -- 2.7.4
[dpdk-dev] [PATCH 10/10] net/hns3: add Scattered Rx and Multiprocess to feature list
This patch adds 'Scattered Rx' and 'Multiprocess aware' those are supported by current hns3 PMD driver for feature list file named hns3.ini and hns3_vf.ini. Signed-off-by: Wei Hu (Xavier) --- doc/guides/nics/features/hns3.ini| 2 ++ doc/guides/nics/features/hns3_vf.ini | 2 ++ 2 files changed, 4 insertions(+) diff --git a/doc/guides/nics/features/hns3.ini b/doc/guides/nics/features/hns3.ini index 66abda7..2533345 100644 --- a/doc/guides/nics/features/hns3.ini +++ b/doc/guides/nics/features/hns3.ini @@ -8,6 +8,7 @@ Link status = Y Rx interrupt = Y MTU update = Y Jumbo frame = Y +Scattered Rx = Y TSO = Y LRO = Y Promiscuous mode = Y @@ -31,6 +32,7 @@ Basic stats = Y Extended stats = Y Stats per queue = Y FW version = Y +Multiprocess aware = Y Linux UIO= Y Linux VFIO = Y ARMv8= Y diff --git a/doc/guides/nics/features/hns3_vf.ini b/doc/guides/nics/features/hns3_vf.ini index 71d246a..05a32c8 100644 --- a/doc/guides/nics/features/hns3_vf.ini +++ b/doc/guides/nics/features/hns3_vf.ini @@ -8,6 +8,7 @@ Link status = Y Rx interrupt = Y MTU update = Y Jumbo frame = Y +Scattered Rx = Y TSO = Y LRO = Y Promiscuous mode = Y @@ -28,6 +29,7 @@ Inner L4 checksum= Y Basic stats = Y Extended stats = Y Stats per queue = Y +Multiprocess aware = Y Linux UIO= Y Linux VFIO = Y ARMv8= Y -- 2.7.4
[dpdk-dev] [PATCH 04/10] net/hns3: support setting VF PVID by PF driver
From: Chengchang Tang This patch adds support setting VF PVID by hns3 PF kernel ethdev driver on the host by "ip link set vf vlan " command. Because of the hardware constraints, the striped VLAN tag will always in Rx descriptors which should has been dropped when PVID is enabled and the PVID will overwrite the outer VLAN tag in Tx descriptor. So, hns3 PMD driver need to change the processing of VLAN tags in the process of Tx and Rx according to whether PVID is enabled. 1) If the hns3 PF kernel ethdev driver sets the PVID for VF device before the initialization of the related VF device, hns3 VF PMD driver should get the PVID state from PF driver through mailbox and update the related state in txq and rxq maintained by hns3 VF driver to change the process of Tx and Rx. 2) If the hns3 PF kernel ethdev driver sets the PVID for VF device after initialization of the related VF device, the PF driver will notify VF driver to update the PVID state. The VF driver will update the PVID configuration state immediately to ensure that the VLAN process in Tx and Rx is correct. But in the window period of this state transition, packets loss or packets with wrong VLAN may occur. 3) Due to hardware limitations, we only support two-layer VLAN hardware offload in Tx direction based on hns3 network engine, so when PVID is enabled, QinQ insert is no longer supported. And when PVID is enabled, in the following two cases: i) packets with more than two VLAN tags. ii) packets with one VLAN tag while the hardware VLAN insert is enabled. The packets will be regarded as abnormal packets and discarded by hardware in Tx direction. For debugging purposes, a validation check for these types of packets is added to the '.tx_pkt_prepare' ops implementation function named hns3_prep_pkts to inform users that these packets will be discarded. Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chengwen Feng --- drivers/net/hns3/hns3_ethdev.c| 5 ++-- drivers/net/hns3/hns3_ethdev.h| 9 +++ drivers/net/hns3/hns3_ethdev_vf.c | 56 --- drivers/net/hns3/hns3_mbx.c | 33 +++ drivers/net/hns3/hns3_mbx.h | 3 +++ drivers/net/hns3/hns3_rxtx.c | 47 6 files changed, 147 insertions(+), 6 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 926efce..5a2f049 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2476,14 +2476,13 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) DEV_TX_OFFLOAD_TCP_CKSUM | DEV_TX_OFFLOAD_UDP_CKSUM | DEV_TX_OFFLOAD_SCTP_CKSUM | -DEV_TX_OFFLOAD_VLAN_INSERT | -DEV_TX_OFFLOAD_QINQ_INSERT | DEV_TX_OFFLOAD_MULTI_SEGS | DEV_TX_OFFLOAD_TCP_TSO | DEV_TX_OFFLOAD_VXLAN_TNL_TSO | DEV_TX_OFFLOAD_GRE_TNL_TSO | DEV_TX_OFFLOAD_GENEVE_TNL_TSO | -info->tx_queue_offload_capa); +info->tx_queue_offload_capa | +hns3_txvlan_cap_get(hw)); info->rx_desc_lim = (struct rte_eth_desc_lim) { .nb_max = HNS3_MAX_RING_DESC, diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 93fe2fe..a4db1c9 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -673,4 +673,13 @@ is_reset_pending(struct hns3_adapter *hns) return ret; } +static inline uint64_t +hns3_txvlan_cap_get(struct hns3_hw *hw) +{ + if (hw->port_base_vlan_cfg.state) + return DEV_TX_OFFLOAD_VLAN_INSERT; + else + return DEV_TX_OFFLOAD_VLAN_INSERT | DEV_TX_OFFLOAD_QINQ_INSERT; +} + #endif /* _HNS3_ETHDEV_H_ */ diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index ccf44a1..afa79a7 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -926,14 +926,13 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) DEV_TX_OFFLOAD_TCP_CKSUM | DEV_TX_OFFLOAD_UDP_CKSUM | DEV_TX_OFFLOAD_SCTP_CKSUM | -DEV_TX_OFFLOAD_VLAN_INSERT | -DEV_TX_OFFLOAD_QINQ_INSERT | DEV_TX_OFFLOAD_MULTI_SEGS | DEV_TX_OFFLOAD_TCP_TSO |
[dpdk-dev] [PATCH 07/10] net/hns3: report Tx descriptor segment limitations
From: Lijun Ou According to the user manual of Kunpeng920 SoC, the max allowed number of segments per whole packet is 63 and the max number of segments per packet is 8 in datapath. This patch reports the Two segment parameters of Tx descriptor limitations to DPDK framework. Signed-off-by: Lijun Ou Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c| 2 ++ drivers/net/hns3/hns3_ethdev_vf.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 1c234da..7bc9b17 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2494,6 +2494,8 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) .nb_max = HNS3_MAX_RING_DESC, .nb_min = HNS3_MIN_RING_DESC, .nb_align = HNS3_ALIGN_RING_DESC, + .nb_seg_max = HNS3_MAX_TSO_BD_PER_PKT, + .nb_mtu_seg_max = HNS3_MAX_NON_TSO_BD_PER_PKT, }; info->vmdq_queue_num = 0; diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 04a8364..9c45ffa 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -944,6 +944,8 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) .nb_max = HNS3_MAX_RING_DESC, .nb_min = HNS3_MIN_RING_DESC, .nb_align = HNS3_ALIGN_RING_DESC, + .nb_seg_max = HNS3_MAX_TSO_BD_PER_PKT, + .nb_mtu_seg_max = HNS3_MAX_NON_TSO_BD_PER_PKT, }; info->vmdq_queue_num = 0; -- 2.7.4
[dpdk-dev] [PATCH 05/10] net/hns3: get device capability in primary process
This patch optimizes the code to get device capability in primary process, and moves the code of getting PCI revison id in order to avoid evaluating the private hw->revision of shared PMD-specific private data in slave process. Signed-off-by: Wei Hu (Xavier) Signed-off-by: Huisong Li Signed-off-by: Chengwen Feng Signed-off-by: Chengchang Tang --- drivers/net/hns3/hns3_ethdev.c| 57 +-- drivers/net/hns3/hns3_ethdev.h| 4 +-- drivers/net/hns3/hns3_ethdev_vf.c | 43 - 3 files changed, 69 insertions(+), 35 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 5a2f049..a43ed82 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2798,6 +2798,36 @@ hns3_parse_speed(int speed_cmd, uint32_t *speed) } static int +hns3_get_capability(struct hns3_hw *hw) +{ + struct rte_pci_device *pci_dev; + struct rte_eth_dev *eth_dev; + uint16_t device_id; + uint8_t revision; + int ret; + + eth_dev = &rte_eth_devices[hw->data->port_id]; + pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); + device_id = pci_dev->id.device_id; + + if (device_id == HNS3_DEV_ID_25GE_RDMA || + device_id == HNS3_DEV_ID_50GE_RDMA || + device_id == HNS3_DEV_ID_100G_RDMA_MACSEC) + hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_DCB_B, 1); + + /* Get PCI revision id */ + ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN, + HNS3_PCI_REVISION_ID); + if (ret != HNS3_PCI_REVISION_ID_LEN) { + PMD_INIT_LOG(ERR, "failed to read pci revision id: %d", ret); + return -EIO; + } + hw->revision = revision; + + return 0; +} + +static int hns3_get_board_configuration(struct hns3_hw *hw) { struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); @@ -2872,6 +2902,13 @@ hns3_get_configuration(struct hns3_hw *hw) return ret; } + /* Get device capability */ + ret = hns3_get_capability(hw); + if (ret) { + PMD_INIT_LOG(ERR, "failed to get device capability: %d.", ret); + return ret; + } + /* Get pf resource */ ret = hns3_query_pf_resource(hw); if (ret) { @@ -5366,26 +5403,12 @@ static const struct hns3_reset_ops hns3_reset_ops = { static int hns3_dev_init(struct rte_eth_dev *eth_dev) { - struct rte_device *dev = eth_dev->device; - struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev); struct hns3_adapter *hns = eth_dev->data->dev_private; struct hns3_hw *hw = &hns->hw; - uint16_t device_id = pci_dev->id.device_id; - uint8_t revision; int ret; PMD_INIT_FUNC_TRACE(); - /* Get PCI revision id */ - ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN, - HNS3_PCI_REVISION_ID); - if (ret != HNS3_PCI_REVISION_ID_LEN) { - PMD_INIT_LOG(ERR, "Failed to read pci revision id, ret = %d", -ret); - return -EIO; - } - hw->revision = revision; - eth_dev->process_private = (struct hns3_process_private *) rte_zmalloc_socket("hns3_filter_list", sizeof(struct hns3_process_private), @@ -5407,12 +5430,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) hns3_mp_init_primary(); hw->adapter_state = HNS3_NIC_UNINITIALIZED; - - if (device_id == HNS3_DEV_ID_25GE_RDMA || - device_id == HNS3_DEV_ID_50GE_RDMA || - device_id == HNS3_DEV_ID_100G_RDMA_MACSEC) - hns3_set_bit(hw->flag, HNS3_DEV_SUPPORT_DCB_B, 1); - hns->is_vf = false; hw->data = eth_dev->data; diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index a4db1c9..c390263 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -402,7 +402,7 @@ struct hns3_hw { uint16_t alloc_rss_size;/* RX queue number per TC */ uint16_t tx_qnum_per_tc;/* TX queue number per TC */ - uint32_t flag; + uint32_t capability; struct hns3_port_base_vlan_config port_base_vlan_cfg; /* @@ -533,7 +533,7 @@ struct hns3_adapter { #define HNS3_DEV_SUPPORT_DCB_B 0x0 #define hns3_dev_dcb_supported(hw) \ - hns3_get_bit((hw)->flag, HNS3_DEV_SUPPORT_DCB_B) + hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_DCB_B) #define HNS3_DEV_PRIVATE_TO_HW(adapter) \ (&((struct hns3_adapter *)adapter)->hw) diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index afa79a7..04a8364 100644 --- a/drivers/net/hns3/hns3_ethdev
[dpdk-dev] [PATCH 08/10] net/hns3: fix Rx buffer size
Currently, rx_buf_size of hns3 PMD driver is fixed on, and it's value depends on the firmware which will decrease the flexibility of PMD. The receive side mbufs was allocated from the mempool given by upper application calling rte_eth_rx_queue_setup API function. So the memory chunk used for net device DMA is depend on the data room size of the objects in this mempool. Hns3 PMD driver should set the rx_buf_len smaller than the data room size of mempool and our hardware only support the following four specifications: 512, 1024, 2148 and 4096. Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") Cc: sta...@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c| 3 +-- drivers/net/hns3/hns3_ethdev.h| 1 - drivers/net/hns3/hns3_ethdev_vf.c | 5 +--- drivers/net/hns3/hns3_rxtx.c | 56 +-- drivers/net/hns3/hns3_rxtx.h | 8 ++ 5 files changed, 64 insertions(+), 9 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 7bc9b17..00ed3e2 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2453,7 +2453,7 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) info->max_rx_queues = queue_num; info->max_tx_queues = hw->tqps_num; info->max_rx_pktlen = HNS3_MAX_FRAME_LEN; /* CRC included */ - info->min_rx_bufsize = hw->rx_buf_len; + info->min_rx_bufsize = HNS3_MIN_BD_BUF_SIZE; info->max_mac_addrs = HNS3_UC_MACADDR_NUM; info->max_mtu = info->max_rx_pktlen - HNS3_ETH_OVERHEAD; info->max_lro_pkt_size = HNS3_MAX_LRO_SIZE; @@ -2851,7 +2851,6 @@ hns3_get_board_configuration(struct hns3_hw *hw) hw->mac.media_type = cfg.media_type; hw->rss_size_max = cfg.rss_size_max; hw->rss_dis_flag = false; - hw->rx_buf_len = cfg.rx_buf_len; memcpy(hw->mac.mac_addr, cfg.mac_addr, RTE_ETHER_ADDR_LEN); hw->mac.phy_addr = cfg.phy_addr; hw->mac.default_addr_setted = false; diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index c390263..3c991f4 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -375,7 +375,6 @@ struct hns3_hw { uint16_t tqps_num; /* num task queue pairs of this function */ uint16_t intr_tqps_num; /* num queue pairs mapping interrupt */ uint16_t rss_size_max; /* HW defined max RSS task queue */ - uint16_t rx_buf_len; uint16_t num_tx_desc; /* desc num of per tx queue */ uint16_t num_rx_desc; /* desc num of per rx queue */ diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 9c45ffa..3c5998a 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -902,7 +902,7 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) info->max_rx_queues = q_num; info->max_tx_queues = hw->tqps_num; info->max_rx_pktlen = HNS3_MAX_FRAME_LEN; /* CRC included */ - info->min_rx_bufsize = hw->rx_buf_len; + info->min_rx_bufsize = HNS3_MIN_BD_BUF_SIZE; info->max_mac_addrs = HNS3_VF_UC_MACADDR_NUM; info->max_mtu = info->max_rx_pktlen - HNS3_ETH_OVERHEAD; info->max_lro_pkt_size = HNS3_MAX_LRO_SIZE; @@ -1096,8 +1096,6 @@ hns3vf_check_tqp_info(struct hns3_hw *hw) return -EINVAL; } - if (hw->rx_buf_len == 0) - hw->rx_buf_len = HNS3_DEFAULT_RX_BUF_LEN; hw->alloc_rss_size = RTE_MIN(hw->rss_size_max, hw->tqps_num); return 0; @@ -1162,7 +1160,6 @@ hns3vf_get_queue_info(struct hns3_hw *hw) memcpy(&hw->tqps_num, &resp_msg[0], sizeof(uint16_t)); memcpy(&hw->rss_size_max, &resp_msg[2], sizeof(uint16_t)); - memcpy(&hw->rx_buf_len, &resp_msg[4], sizeof(uint16_t)); return hns3vf_check_tqp_info(hw); } diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 0f9825f..931d89a 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -909,7 +909,7 @@ hns3_fake_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, nb_rx_q = dev->data->nb_rx_queues; rxq->io_base = (void *)((char *)hw->io_base + HNS3_TQP_REG_OFFSET + (nb_rx_q + idx) * HNS3_TQP_REG_SIZE); - rxq->rx_buf_len = hw->rx_buf_len; + rxq->rx_buf_len = HNS3_MIN_BD_BUF_SIZE; rte_spinlock_lock(&hw->lock); hw->fkq_data.rx_queues[idx] = rxq; @@ -1185,6 +1185,48 @@ hns3_dev_release_mbufs(struct hns3_adapter *hns) } } +static int +hns3_rx_buf_len_calc(struct rte_mempool *mp,
[dpdk-dev] [PATCH 03/10] net/hns3: decrease non-nearby memory access in Rx
From: Chengchang Tang Currently, hns3 PMD driver needs know the PVID configuration state and do different processing in the 'rx_pkt_burst' ops implementation function. This patch adds a member to struct hns3_rx_queue/hns3_tx_queue of the driver to indicate the PVID configuration status, so it isn't need to access other data structure in the 'rx_pkt_burst' ops implementation, to avoid performance loss because of reducing cache miss. Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c | 21 - drivers/net/hns3/hns3_rxtx.c | 37 +++-- drivers/net/hns3/hns3_rxtx.h | 13 + 3 files changed, 64 insertions(+), 7 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 7758855..926efce 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -908,6 +908,8 @@ hns3_vlan_pvid_set(struct rte_eth_dev *dev, uint16_t pvid, int on) { struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; + bool pvid_en_state_change; + uint16_t pvid_state; int ret; if (pvid > RTE_ETHER_MAX_VLAN_ID) { @@ -916,10 +918,27 @@ hns3_vlan_pvid_set(struct rte_eth_dev *dev, uint16_t pvid, int on) return -EINVAL; } + /* +* If PVID configuration state change, should refresh the PVID +* configuration state in struct hns3_tx_queue/hns3_rx_queue. +*/ + pvid_state = hw->port_base_vlan_cfg.state; + if ((on && pvid_state == HNS3_PORT_BASE_VLAN_ENABLE) || + (!on && pvid_state == HNS3_PORT_BASE_VLAN_DISABLE)) + pvid_en_state_change = false; + else + pvid_en_state_change = true; + rte_spinlock_lock(&hw->lock); ret = hns3_vlan_pvid_configure(hns, pvid, on); rte_spinlock_unlock(&hw->lock); - return ret; + if (ret) + return ret; + + if (pvid_en_state_change) + hns3_update_all_queues_pvid_state(hw); + + return 0; } static void diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 4e3391d..d744d85 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -316,6 +316,31 @@ hns3_init_tx_queue_hw(struct hns3_tx_queue *txq) } void +hns3_update_all_queues_pvid_state(struct hns3_hw *hw) +{ + uint16_t nb_rx_q = hw->data->nb_rx_queues; + uint16_t nb_tx_q = hw->data->nb_tx_queues; + struct hns3_rx_queue *rxq; + struct hns3_tx_queue *txq; + int pvid_state; + int i; + + pvid_state = hw->port_base_vlan_cfg.state; + for (i = 0; i < hw->cfg_max_queues; i++) { + if (i < nb_rx_q) { + rxq = hw->data->rx_queues[i]; + if (rxq != NULL) + rxq->pvid_state = pvid_state; + } + if (i < nb_tx_q) { + txq = hw->data->tx_queues[i]; + if (txq != NULL) + txq->pvid_state = pvid_state; + } + } +} + +void hns3_enable_all_queues(struct hns3_hw *hw, bool en) { uint16_t nb_rx_q = hw->data->nb_rx_queues; @@ -1223,6 +1248,7 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, rxq->pkt_first_seg = NULL; rxq->pkt_last_seg = NULL; rxq->port_id = dev->data->port_id; + rxq->pvid_state = hw->port_base_vlan_cfg.state; rxq->configured = true; rxq->io_base = (void *)((char *)hw->io_base + HNS3_TQP_REG_OFFSET + idx * HNS3_TQP_REG_SIZE); @@ -1451,7 +1477,7 @@ hns3_rx_set_cksum_flag(struct rte_mbuf *rxm, uint64_t packet_type, } static inline void -hns3_rxd_to_vlan_tci(struct rte_eth_dev *dev, struct rte_mbuf *mb, +hns3_rxd_to_vlan_tci(struct hns3_rx_queue *rxq, struct rte_mbuf *mb, uint32_t l234_info, const struct hns3_desc *rxd) { #define HNS3_STRP_STATUS_NUM 0x4 @@ -1459,8 +1485,6 @@ hns3_rxd_to_vlan_tci(struct rte_eth_dev *dev, struct rte_mbuf *mb, #define HNS3_NO_STRP_VLAN_VLD 0x0 #define HNS3_INNER_STRP_VLAN_VLD 0x1 #define HNS3_OUTER_STRP_VLAN_VLD 0x2 - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; uint32_t strip_status; uint32_t report_mode; @@ -1486,7 +1510,7 @@ hns3_rxd_to_vlan_tci(struct rte_eth_dev *dev, struct rte_mbuf *mb, }; strip_status = hns3_get_field(l234_info, HNS3_RXD_STRP_TAGP_M, HNS3_RXD_STRP_TAGP_S); - report_mode = report_type[hw->port_base_vlan_cfg.state][strip_sta
Re: [dpdk-dev] [PATCH] dedicated queues: delete redundant check valid_bonded_port_id has include check_for_bonded_ethdev, no need to check again.
Hi, pandongyang The title is too long, and lack of the commit log. You can use this script to check your commit when making patch ./devtools/check-git-log.sh -[num] On 2020/6/21 21:34, 197020...@qq.com wrote: From: pandongyang <197020...@qq.com> Signed-off-by: pandongyang <197020...@qq.com> --- drivers/net/bonding/rte_eth_bond_8023ad.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c index b77a37d..3393743 100644 --- a/drivers/net/bonding/rte_eth_bond_8023ad.c +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c @@ -1675,9 +1675,6 @@ rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port) dev = &rte_eth_devices[port]; internals = dev->data->dev_private; - if (check_for_bonded_ethdev(dev) != 0) - return -1; - if (bond_8023ad_slow_pkt_hw_filter_supported(port) != 0) return -1; Maybe it is better to remove another place as follows int rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port) { int retval = 0; struct rte_eth_dev *dev; struct bond_dev_private *internals; if (valid_bonded_port_id(port) != 0) return -EINVAL; dev = &rte_eth_devices[port]; internals = dev->data->dev_private; -if (check_for_bonded_ethdev(dev) != 0) -return -1; [snip] @@ -1704,9 +1701,6 @@ rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port) dev = &rte_eth_devices[port]; internals = dev->data->dev_private; - if (check_for_bonded_ethdev(dev) != 0) - return -1; - /* Device must be stopped to set up slow queue */ if (dev->data->dev_started) return -1; similar to above comment int rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port) { int retval = 0; struct rte_eth_dev *dev; struct bond_dev_private *internals; if (valid_bonded_port_id(port) != 0) return -EINVAL; dev = &rte_eth_devices[port]; internals = dev->data->dev_private; -if (check_for_bonded_ethdev(dev) != 0) -return -1; [snip] Thanks, Xavier
Re: [dpdk-dev] [PATCH v4 2/2] ethdev: fix VLAN offloads set if no relative capabilities
Hi, Heinrich Kuhn & Jerin Jacob & Nithin Dabilpuram & Kiran Kumar K & Rasesh Mody & Shahed Shaikh & Qi Zhang & Xiao Wang & Beilei Xing & Jeff Guo. Could you please help to review this patch and give 'Acked-by' if there are no objects. Thanks, Xavier On 2020/6/29 9:34, Wei Hu (Xavier) wrote: Hi, Heinrich Kuhn & Harman Kalra & Jerin Jacob & Nithin Dabilpuram & Kiran Kumar K & Rasesh Mody & Shahed Shaikh & Qi Zhang & Xiao Wang & Beilei Xing & Jeff Guo. Could you please help to review this patch and give 'Acked-by' if there are no objects. Thanks, Xavier On 2020/6/22 16:09, Wei Hu (Xavier) wrote: Currently, there is a potential problem that calling the API function rte_eth_dev_set_vlan_offload to start VLAN hardware offloads which the driver does not support. If the PMD driver does not support certain VLAN hardware offloads and does not check for it, the hardware setting will not change, but the VLAN offloads in dev->data->dev_conf.rxmode.offloads will be turned on. It is supposed to check the hardware capabilities to decide whether the relative callback needs to be called just like the behavior in the API function named rte_eth_dev_configure. And it is also needed to cleanup duplicated checks which are done in some PMDs. Also, note that it is behaviour change for some PMDs which simply ignore (with error/warning log message) unsupported VLAN offloads, but now it will fail. Fixes: a4996bd89c42 ("ethdev: new Rx/Tx offloads API") Cc: sta...@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) Acked-by: Andrew Rybchenko Acked-by: Hyong Youb Kim --- v3 -> v4: Delete "next_mask" label and modify the function that when the offload is not supported the function fail. v2 -> v3: Add __rte_unused to avoid unused parameter 'dev' and 'mask' warning. v1 -> v2: Cleanup duplicated checks which are done in some PMDs. --- drivers/net/dpaa2/dpaa2_ethdev.c | 12 +++- drivers/net/enic/enic_ethdev.c | 12 drivers/net/fm10k/fm10k_ethdev.c | 23 ++- drivers/net/hinic/hinic_pmd_ethdev.c | 6 -- drivers/net/i40e/i40e_ethdev.c | 5 - drivers/net/nfp/nfp_net.c | 5 - drivers/net/octeontx/octeontx_ethdev_ops.c | 10 -- drivers/net/octeontx2/otx2_vlan.c | 5 - drivers/net/qede/qede_ethdev.c | 3 --- lib/librte_ethdev/rte_ethdev.c | 21 + 10 files changed, 26 insertions(+), 76 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 2f031ec..17a7a49 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -147,7 +147,7 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) { struct dpaa2_dev_priv *priv = dev->data->dev_private; struct fsl_mc_io *dpni = dev->process_private; -int ret; +int ret = 0; PMD_INIT_FUNC_TRACE(); @@ -155,7 +155,7 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) /* VLAN Filter not avaialble */ if (!priv->max_vlan_filters) { DPAA2_PMD_INFO("VLAN filter not available"); -goto next_mask; +return -ENOTSUP; } if (dev->data->dev_conf.rxmode.offloads & @@ -168,14 +168,8 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) if (ret < 0) DPAA2_PMD_INFO("Unable to set vlan filter = %d", ret); } -next_mask: -if (mask & ETH_VLAN_EXTEND_MASK) { -if (dev->data->dev_conf.rxmode.offloads & -DEV_RX_OFFLOAD_VLAN_EXTEND) -DPAA2_PMD_INFO("VLAN extend offload not supported"); -} -return 0; +return ret; } static int diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 32d5397..ef8900d 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -374,18 +374,6 @@ static int enicpmd_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask) enic->ig_vlan_strip_en = 0; } -if ((mask & ETH_VLAN_FILTER_MASK) && -(offloads & DEV_RX_OFFLOAD_VLAN_FILTER)) { -dev_warning(enic, -"Configuration of VLAN filter is not supported\n"); -} - -if ((mask & ETH_VLAN_EXTEND_MASK) && -(offloads & DEV_RX_OFFLOAD_VLAN_EXTEND)) { -dev_warning(enic, -"Configuration of extended VLAN is not supported\n"); -} - return enic_set_vlan_strip(enic); } diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index f537ab2..f5b854e 100644 --- a/drivers/net/fm1
Re: [dpdk-dev] [PATCH V2] net/bonding: delete redundant code
On 2020/7/4 9:15, 197020...@qq.com wrote: From: pandongyang <197020...@qq.com> The function valid_bonded_port_id() has already contains function rte_eth_dev_is_valid_port(), so delete redundant check. Fixes: 588ae95e7983 ("net/bonding: fix port ID check") Cc: sta...@dpdk.org Signed-off-by: pandongyang <197020...@qq.com> Reviewed-by: Wei Hu (Xavier) --- v1 -> v2: Adjust commit info --- drivers/net/bonding/rte_eth_bond_8023ad.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c index b77a37ddb..339374337 100644 --- a/drivers/net/bonding/rte_eth_bond_8023ad.c +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c @@ -1675,9 +1675,6 @@ rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port) dev = &rte_eth_devices[port]; internals = dev->data->dev_private; - if (check_for_bonded_ethdev(dev) != 0) - return -1; - if (bond_8023ad_slow_pkt_hw_filter_supported(port) != 0) return -1; @@ -1704,9 +1701,6 @@ rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port) dev = &rte_eth_devices[port]; internals = dev->data->dev_private; - if (check_for_bonded_ethdev(dev) != 0) - return -1; - /* Device must be stopped to set up slow queue */ if (dev->data->dev_started) return -1;
[dpdk-dev] [PATCH 4/4] doc: update feature list of hns3 rst document
From: Lijun Ou This patch updates the feature list for hns3 PMD driver document. Signed-off-by: Lijun Ou Signed-off-by: Wei Hu (Xavier) --- doc/guides/nics/hns3.rst | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/hns3.rst b/doc/guides/nics/hns3.rst index ae3c5f6..a62fcfd 100644 --- a/doc/guides/nics/hns3.rst +++ b/doc/guides/nics/hns3.rst @@ -25,7 +25,16 @@ Features of the HNS3 PMD are: - Jumbo frames - Link state information - Interrupt mode for RX -- VLAN stripping +- VLAN stripping and inserting +- QinQ inserting +- DCB +- Scattered and gather for TX and RX +- Flow director +- Dump register +- SR-IOV VF +- Multi-process +- MAC/VLAN filter +- MTU update - NUMA support Prerequisites -- 2.7.4
[dpdk-dev] [PATCH 2/4] net/hns3: cleanup duplicate code when processing TSO in Tx
From: Chengchang Tang This patch fixes up paylen calculation twice when processing TSO request in the '.tx_pkt_burst' ops implementation function to avoid performance loss. Fixes: 6dca716c9e1d ("net/hns3: support TSO") Cc: sta...@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) Signed-off-by: Hongbo Zheng --- drivers/net/hns3/hns3_rxtx.c | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 8892fc1..07640db 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -1979,12 +1979,11 @@ hns3_pkt_is_tso(struct rte_mbuf *m) } static void -hns3_set_tso(struct hns3_desc *desc, -uint64_t ol_flags, struct rte_mbuf *rxm) +hns3_set_tso(struct hns3_desc *desc, uint64_t ol_flags, + uint32_t paylen, struct rte_mbuf *rxm) { - uint32_t paylen, hdr_len; - uint32_t tmp; uint8_t l2_len = rxm->l2_len; + uint32_t tmp; if (!hns3_pkt_is_tso(rxm)) return; @@ -1992,10 +1991,6 @@ hns3_set_tso(struct hns3_desc *desc, if (hns3_tso_proc_tunnel(desc, ol_flags, rxm, &l2_len)) return; - hdr_len = rxm->l2_len + rxm->l3_len + rxm->l4_len; - hdr_len += (ol_flags & PKT_TX_TUNNEL_MASK) ? - rxm->outer_l2_len + rxm->outer_l3_len : 0; - paylen = rxm->pkt_len - hdr_len; if (paylen <= rxm->tso_segsz) return; @@ -2036,7 +2031,7 @@ fill_desc(struct hns3_tx_queue *txq, uint16_t tx_desc_id, struct rte_mbuf *rxm, rxm->outer_l2_len + rxm->outer_l3_len : 0; paylen = rxm->pkt_len - hdr_len; desc->tx.paylen = rte_cpu_to_le_32(paylen); - hns3_set_tso(desc, ol_flags, rxm); + hns3_set_tso(desc, ol_flags, paylen, rxm); } hns3_set_bit(rrcfv, HNS3_TXD_FE_B, frag_end); -- 2.7.4
[dpdk-dev] [PATCH 0/4] updates for hns3 PMD driver
This series are updates for hns3 PMD driver. Chengchang Tang (1): net/hns3: cleanup duplicate code when processing TSO in Tx Lijun Ou (1): doc: update feature list of hns3 rst document Wei Hu (Xavier) (2): net/hns3: check if registering mp action successfully net/hns3: fix VLAN tag inserted in wrong position in Tx doc/guides/nics/hns3.rst | 11 +++- drivers/net/hns3/hns3_ethdev.c| 22 +++- drivers/net/hns3/hns3_ethdev_vf.c | 20 ++- drivers/net/hns3/hns3_mp.c| 34 ++-- drivers/net/hns3/hns3_mp.h| 4 +- drivers/net/hns3/hns3_rxtx.c | 113 +++--- 6 files changed, 147 insertions(+), 57 deletions(-) -- 2.7.4
[dpdk-dev] [PATCH 3/4] net/hns3: fix VLAN tag inserted in wrong position in Tx
Based on hns3 network engine, in order to configure hardware VLAN insert offload in Tx direction, PMD driver reads the VLAN tags from the vlan_tci_outer and vlan_tci of the structure rte_mbuf, fills them into the Tx Buffer Descriptor and sets the related offload flag for every packet. Currently, there are two VLAN related problems in the 'tx_pkt_burst' ops implementation function: 1) When setting the related offload flag, PMD driver inserts the VLAN tag into the position that close to L3 header. So, when upper application sends a packet with a VLAN tag in the data buffer, the VLAN offloaded by hardware will be added to the wrong position. It is supposed to add the VLAN tag from the rte_mbuf to the position close to the MAC header in the packet when using VLAN insertion. And when PF PVID is enabled by calling the API function named rte_eth_dev_set_vlan_pvid or VF PVID is enabled by hns3 PF kernel ether driver, the VLAN tag from the structure rte_mbuf to enable the VLAN insertion should be filled into the position that close to L3 header to avoid to be overwittern by the PVID which will always be inserted in the position that close to the MAC address. 2) When sending multiple segment packets, VLAN information is required to be filled into the first Tx Buffer descriptor. However, currently hns3 PMD driver incorrectly placed it in the last Tx Buffer Descriptor. This results in VLAN insert offload failure when sending multiple segment packets. This patch fixed them by filling the VLAN information into the position of the Tx Buffer Descriptor. Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") Cc: sta...@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_rxtx.c | 102 +++ 1 file changed, 65 insertions(+), 37 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 07640db..b0253d5 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -2007,51 +2007,58 @@ hns3_set_tso(struct hns3_desc *desc, uint64_t ol_flags, desc->tx.mss = rte_cpu_to_le_16(rxm->tso_segsz); } +static inline void +hns3_fill_per_desc(struct hns3_desc *desc, struct rte_mbuf *rxm) +{ + desc->addr = rte_mbuf_data_iova(rxm); + desc->tx.send_size = rte_cpu_to_le_16(rte_pktmbuf_data_len(rxm)); + desc->tx.tp_fe_sc_vld_ra_ri = rte_cpu_to_le_16(BIT(HNS3_TXD_VLD_B)); +} + static void -fill_desc(struct hns3_tx_queue *txq, uint16_t tx_desc_id, struct rte_mbuf *rxm, - bool first, int offset) +hns3_fill_first_desc(struct hns3_tx_queue *txq, struct hns3_desc *desc, +struct rte_mbuf *rxm) { - struct hns3_desc *tx_ring = txq->tx_ring; - struct hns3_desc *desc = &tx_ring[tx_desc_id]; - uint8_t frag_end = rxm->next == NULL ? 1 : 0; uint64_t ol_flags = rxm->ol_flags; - uint16_t size = rxm->data_len; - uint16_t rrcfv = 0; uint32_t hdr_len; uint32_t paylen; - uint32_t tmp; - desc->addr = rte_mbuf_data_iova(rxm) + offset; - desc->tx.send_size = rte_cpu_to_le_16(size); - hns3_set_bit(rrcfv, HNS3_TXD_VLD_B, 1); - - if (first) { - hdr_len = rxm->l2_len + rxm->l3_len + rxm->l4_len; - hdr_len += (ol_flags & PKT_TX_TUNNEL_MASK) ? + hdr_len = rxm->l2_len + rxm->l3_len + rxm->l4_len; + hdr_len += (ol_flags & PKT_TX_TUNNEL_MASK) ? rxm->outer_l2_len + rxm->outer_l3_len : 0; - paylen = rxm->pkt_len - hdr_len; - desc->tx.paylen = rte_cpu_to_le_32(paylen); - hns3_set_tso(desc, ol_flags, paylen, rxm); - } - - hns3_set_bit(rrcfv, HNS3_TXD_FE_B, frag_end); - desc->tx.tp_fe_sc_vld_ra_ri = rte_cpu_to_le_16(rrcfv); - - if (frag_end) { - if (ol_flags & (PKT_TX_VLAN_PKT | PKT_TX_QINQ_PKT)) { - tmp = rte_le_to_cpu_32(desc->tx.type_cs_vlan_tso_len); - hns3_set_bit(tmp, HNS3_TXD_VLAN_B, 1); - desc->tx.type_cs_vlan_tso_len = rte_cpu_to_le_32(tmp); - desc->tx.vlan_tag = rte_cpu_to_le_16(rxm->vlan_tci); - } + paylen = rxm->pkt_len - hdr_len; + desc->tx.paylen = rte_cpu_to_le_32(paylen); + hns3_set_tso(desc, ol_flags, paylen, rxm); - if (ol_flags & PKT_TX_QINQ_PKT) { - tmp = rte_le_to_cpu_32(desc->tx.ol_type_vlan_len_msec); - hns3_set_bit(tmp, HNS3_TXD_OVLAN_B, 1); - desc->tx.ol_type_vlan_len_msec = rte_cpu_to_le_32(tmp); + /* +* Currently, hardware doesn't support more than two layers VLAN offload +* in Tx d
[dpdk-dev] [PATCH 1/4] net/hns3: check if registering mp action successfully
Currently, there is a coverity defect warning about hns3 PMD driver, the detail information as blow: CID 289969 (#1 of 1): Unchecked return value (CHECKED_RETURN) 1. check_return: Calling rte_mp_action_register without checking return value (as is done elsewhere 11 out of 13 times). The problem is that missing checking the return value of calling the API rte_mp_action_register during initialization. If regitering an action function for primary and secondary communication failed, the secondary process can't work properly. This patch fixes it by adding check return value of the API function named rte_mp_action_register in the '.dev_init' implementation function of hns3 PMD driver. Coverity issue: 289969 Fixes: 23d4b61fee5d ("net/hns3: support multiple process") Cc: sta...@dpdk.org Signed-off-by: Lijun Ou Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_ethdev.c| 22 -- drivers/net/hns3/hns3_ethdev_vf.c | 20 ++-- drivers/net/hns3/hns3_mp.c| 34 +- drivers/net/hns3/hns3_mp.h| 4 ++-- 4 files changed, 69 insertions(+), 11 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 00ed3e2..265d620 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -5451,12 +5451,25 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) hns3_set_rxtx_function(eth_dev); eth_dev->dev_ops = &hns3_eth_dev_ops; if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - hns3_mp_init_secondary(); + ret = hns3_mp_init_secondary(); + if (ret) { + PMD_INIT_LOG(ERR, "Failed to init for secondary " +"process, ret = %d", ret); + goto err_mp_init_secondary; + } + hw->secondary_cnt++; return 0; } - hns3_mp_init_primary(); + ret = hns3_mp_init_primary(); + if (ret) { + PMD_INIT_LOG(ERR, +"Failed to init for primary process, ret = %d", +ret); + goto err_mp_init_primary; + } + hw->adapter_state = HNS3_NIC_UNINITIALIZED; hns->is_vf = false; hw->data = eth_dev->data; @@ -5517,7 +5530,12 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) err_init_pf: rte_free(hw->reset.wait_data); + err_init_reset: + hns3_mp_uninit_primary(); + +err_mp_init_primary: +err_mp_init_secondary: eth_dev->dev_ops = NULL; eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 3c5998a..54e5dac 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -2524,12 +2524,24 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) hns3_set_rxtx_function(eth_dev); eth_dev->dev_ops = &hns3vf_eth_dev_ops; if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - hns3_mp_init_secondary(); + ret = hns3_mp_init_secondary(); + if (ret) { + PMD_INIT_LOG(ERR, "Failed to init for secondary " + "process, ret = %d", ret); + goto err_mp_init_secondary; + } + hw->secondary_cnt++; return 0; } - hns3_mp_init_primary(); + ret = hns3_mp_init_primary(); + if (ret) { + PMD_INIT_LOG(ERR, +"Failed to init for primary process, ret = %d", +ret); + goto err_mp_init_primary; + } hw->adapter_state = HNS3_NIC_UNINITIALIZED; hns->is_vf = true; @@ -2586,6 +2598,10 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) rte_free(hw->reset.wait_data); err_init_reset: + hns3_mp_uninit_primary(); + +err_mp_init_primary: +err_mp_init_secondary: eth_dev->dev_ops = NULL; eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c index 596c310..639f46c 100644 --- a/drivers/net/hns3/hns3_mp.c +++ b/drivers/net/hns3/hns3_mp.c @@ -14,6 +14,8 @@ #include "hns3_rxtx.h" #include "hns3_mp.h" +static bool hns3_inited; + /* * Initialize IPC message. * @@ -192,9 +194,20 @@ void hns3_mp_req_stop_rxtx(struct rte_eth_dev *dev) /* * Initialize by primary process. */ -void hns3_mp_init_primary(void) +int hns3_mp_init_primary(void) { - rte_mp_action_register(HNS3_MP_NAME, mp_primary_handle); + int ret; + + if (!hns3_inited) { + /* primary is allowed to not suppor
Re: [dpdk-dev] [PATCH v4 2/2] ethdev: fix VLAN offloads set if no relative capabilities
Hi, Jeff Guo On 2020/7/5 19:22, Jeff Guo wrote: hi, xavier On 7/3/2020 9:28 AM, Wei Hu (Xavier) wrote: Hi, Heinrich Kuhn & Jerin Jacob & Nithin Dabilpuram & Kiran Kumar K & Rasesh Mody & Shahed Shaikh & Qi Zhang & Xiao Wang & Beilei Xing & Jeff Guo. Could you please help to review this patch and give 'Acked-by' if there are no objects. Thanks, Xavier On 2020/6/29 9:34, Wei Hu (Xavier) wrote: Hi, Heinrich Kuhn & Harman Kalra & Jerin Jacob & Nithin Dabilpuram & Kiran Kumar K & Rasesh Mody & Shahed Shaikh & Qi Zhang & Xiao Wang & Beilei Xing & Jeff Guo. Could you please help to review this patch and give 'Acked-by' if there are no objects. Thanks, Xavier On 2020/6/22 16:09, Wei Hu (Xavier) wrote: Currently, there is a potential problem that calling the API function rte_eth_dev_set_vlan_offload to start VLAN hardware offloads which the driver does not support. If the PMD driver does not support certain VLAN hardware offloads and does not check for it, the hardware setting will not change, but the VLAN offloads in dev->data->dev_conf.rxmode.offloads will be turned on. It is supposed to check the hardware capabilities to decide whether the relative callback needs to be called just like the behavior in the API function named rte_eth_dev_configure. And it is also needed to cleanup duplicated checks which are done in some PMDs. Also, note that it is behaviour change for some PMDs which simply ignore (with error/warning log message) unsupported VLAN offloads, but now it will fail. Fixes: a4996bd89c42 ("ethdev: new Rx/Tx offloads API") Cc: sta...@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) Acked-by: Andrew Rybchenko Acked-by: Hyong Youb Kim --- v3 -> v4: Delete "next_mask" label and modify the function that when the offload is not supported the function fail. v2 -> v3: Add __rte_unused to avoid unused parameter 'dev' and 'mask' warning. v1 -> v2: Cleanup duplicated checks which are done in some PMDs. --- drivers/net/dpaa2/dpaa2_ethdev.c | 12 +++- drivers/net/enic/enic_ethdev.c | 12 drivers/net/fm10k/fm10k_ethdev.c | 23 ++- drivers/net/hinic/hinic_pmd_ethdev.c | 6 -- drivers/net/i40e/i40e_ethdev.c | 5 - drivers/net/nfp/nfp_net.c | 5 - drivers/net/octeontx/octeontx_ethdev_ops.c | 10 -- drivers/net/octeontx2/otx2_vlan.c | 5 - drivers/net/qede/qede_ethdev.c | 3 --- lib/librte_ethdev/rte_ethdev.c | 21 + 10 files changed, 26 insertions(+), 76 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 2f031ec..17a7a49 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -147,7 +147,7 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) { struct dpaa2_dev_priv *priv = dev->data->dev_private; struct fsl_mc_io *dpni = dev->process_private; -int ret; +int ret = 0; PMD_INIT_FUNC_TRACE(); @@ -155,7 +155,7 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) /* VLAN Filter not avaialble */ if (!priv->max_vlan_filters) { DPAA2_PMD_INFO("VLAN filter not available"); -goto next_mask; +return -ENOTSUP; } if (dev->data->dev_conf.rxmode.offloads & @@ -168,14 +168,8 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) if (ret < 0) DPAA2_PMD_INFO("Unable to set vlan filter = %d", ret); } -next_mask: -if (mask & ETH_VLAN_EXTEND_MASK) { -if (dev->data->dev_conf.rxmode.offloads & -DEV_RX_OFFLOAD_VLAN_EXTEND) -DPAA2_PMD_INFO("VLAN extend offload not supported"); -} -return 0; +return ret; } static int diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 32d5397..ef8900d 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -374,18 +374,6 @@ static int enicpmd_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask) enic->ig_vlan_strip_en = 0; } -if ((mask & ETH_VLAN_FILTER_MASK) && -(offloads & DEV_RX_OFFLOAD_VLAN_FILTER)) { -dev_warning(enic, -"Configuration of VLAN filter is not supported\n"); -} - -if ((mask & ETH_VLAN_EXTEND_MASK) && -(offloads & DEV_RX_OFFLOAD_VLAN_EXTEND)) { -dev_warning(enic, -"Configuration of extended VLAN is not supported\n"); -} - return enic_set_vlan_strip(enic); } diff --git
[dpdk-dev] [PATCH v5 2/2] ethdev: fix VLAN offloads set if no relative capabilities
Currently, there is a potential problem that calling the API function rte_eth_dev_set_vlan_offload to start VLAN hardware offloads which the driver does not support. If the PMD driver does not support certain VLAN hardware offloads and does not check for it, the hardware setting will not change, but the VLAN offloads in dev->data->dev_conf.rxmode.offloads will be turned on. It is supposed to check the hardware capabilities to decide whether the relative callback needs to be called just like the behavior in the API function named rte_eth_dev_configure. And it is also needed to cleanup duplicated checks which are done in some PMDs. Also, note that it is behaviour change for some PMDs which simply ignore (with error/warning log message) unsupported VLAN offloads, but now it will fail. Fixes: a4996bd89c42 ("ethdev: new Rx/Tx offloads API") Cc: sta...@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) Acked-by: Andrew Rybchenko Acked-by: Hyong Youb Kim Acked-by: Sachin Saxena Acked-by: Xiaoyun wang Acked-by: Harman Kalra --- v4 -> v5: add the related history patch into the Fixes commit log. v3 -> v4: Delete "next_mask" label and modify the function that when the offload is not supported the function fail. v2 -> v3: Add __rte_unused to avoid unused parameter 'dev' and 'mask' warning. v1 -> v2: Cleanup duplicated checks which are done in some PMDs. --- drivers/net/dpaa2/dpaa2_ethdev.c | 12 +++- drivers/net/enic/enic_ethdev.c | 12 drivers/net/fm10k/fm10k_ethdev.c | 23 ++- drivers/net/hinic/hinic_pmd_ethdev.c | 6 -- drivers/net/i40e/i40e_ethdev.c | 5 - drivers/net/nfp/nfp_net.c | 5 - drivers/net/octeontx/octeontx_ethdev_ops.c | 10 -- drivers/net/octeontx2/otx2_vlan.c | 5 - drivers/net/qede/qede_ethdev.c | 3 --- lib/librte_ethdev/rte_ethdev.c | 21 + 10 files changed, 26 insertions(+), 76 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index a1f1919..489d744 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -145,7 +145,7 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) { struct dpaa2_dev_priv *priv = dev->data->dev_private; struct fsl_mc_io *dpni = dev->process_private; - int ret; + int ret = 0; PMD_INIT_FUNC_TRACE(); @@ -153,7 +153,7 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) /* VLAN Filter not avaialble */ if (!priv->max_vlan_filters) { DPAA2_PMD_INFO("VLAN filter not available"); - goto next_mask; + return -ENOTSUP; } if (dev->data->dev_conf.rxmode.offloads & @@ -166,14 +166,8 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) if (ret < 0) DPAA2_PMD_INFO("Unable to set vlan filter = %d", ret); } -next_mask: - if (mask & ETH_VLAN_EXTEND_MASK) { - if (dev->data->dev_conf.rxmode.offloads & - DEV_RX_OFFLOAD_VLAN_EXTEND) - DPAA2_PMD_INFO("VLAN extend offload not supported"); - } - return 0; + return ret; } static int diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 6a3580f..30a599d 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -367,18 +367,6 @@ static int enicpmd_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask) enic->ig_vlan_strip_en = 0; } - if ((mask & ETH_VLAN_FILTER_MASK) && - (offloads & DEV_RX_OFFLOAD_VLAN_FILTER)) { - dev_warning(enic, - "Configuration of VLAN filter is not supported\n"); - } - - if ((mask & ETH_VLAN_EXTEND_MASK) && - (offloads & DEV_RX_OFFLOAD_VLAN_EXTEND)) { - dev_warning(enic, - "Configuration of extended VLAN is not supported\n"); - } - return enic_set_vlan_strip(enic); } diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index cb0dd3b..b574693 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -1562,28 +1562,9 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) } static int -fm10k_vlan_offload_set(struct rte_eth_dev *dev, int mask) +fm10k_vlan_offload_set(struct rte_eth_dev *dev __rte_unused, + int mask __rte_unused) { - if (mask & ETH_VLAN_
[dpdk-dev] [PATCH v5 0/2] ethdev: minor bugfixes
This series are minor bugfixes for rte_ethdev.c. Wei Hu (Xavier) (2): ethdev: fix data room size verification in Rx queue setup ethdev: fix VLAN offloads set if no relative capabilities drivers/net/dpaa2/dpaa2_ethdev.c | 12 +++- drivers/net/enic/enic_ethdev.c | 12 drivers/net/fm10k/fm10k_ethdev.c | 23 ++- drivers/net/hinic/hinic_pmd_ethdev.c | 6 -- drivers/net/i40e/i40e_ethdev.c | 5 - drivers/net/nfp/nfp_net.c | 5 - drivers/net/octeontx/octeontx_ethdev_ops.c | 10 -- drivers/net/octeontx2/otx2_vlan.c | 5 - drivers/net/qede/qede_ethdev.c | 3 --- lib/librte_ethdev/rte_ethdev.c | 23 ++- 10 files changed, 27 insertions(+), 77 deletions(-) -- 2.7.4
[dpdk-dev] [PATCH v5 1/2] ethdev: fix data room size verification in Rx queue setup
In the rte_eth_rx_queue_setup API function, the local variable named mbp_buf_size, which is the data room size of the input parameter mp, is checked to guarantee that each memory chunck used for net device in the mbuf is bigger than the min_rx_bufsize. But if mbp_buf_size is less than RTE_PKTMBUF_HEADROOM, the value of the following statement will be a large number since the mbp_buf_size is a unsigned value. mbp_buf_size - RTE_PKTMBUF_HEADROOM As a result, it will cause a segment fault in this situation. This patch fixes it by modify the check condition to guarantee that the local varibale named mbp_buf_size is bigger than RTE_PKTMBUF_HEADROOM. Fixes: af75078fece3 ("first public release") Cc: sta...@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) Reviewed-by: Andrew Rybchenko Acked-by: Sachin Saxena --- v2 -> v5: No change. v1 -> v2: Simplify the check condition of mbp_buf_size according to Andrew Rybchenko's comment. --- lib/librte_ethdev/rte_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index d06b7f9..50c3f18 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1820,7 +1820,7 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, } mbp_buf_size = rte_pktmbuf_data_room_size(mp); - if ((mbp_buf_size - RTE_PKTMBUF_HEADROOM) < dev_info.min_rx_bufsize) { + if (mbp_buf_size < dev_info.min_rx_bufsize + RTE_PKTMBUF_HEADROOM) { RTE_ETHDEV_LOG(ERR, "%s mbuf_data_room_size %d < %d (RTE_PKTMBUF_HEADROOM=%d + min_rx_bufsize(dev)=%d)\n", mp->name, (int)mbp_buf_size, -- 2.7.4
[dpdk-dev] [PATCH v6 2/2] ethdev: fix VLAN offloads set if no relative capabilities
Currently, there is a potential problem that calling the API function rte_eth_dev_set_vlan_offload to start VLAN hardware offloads which the driver does not support. If the PMD driver does not support certain VLAN hardware offloads and does not check for it, the hardware setting will not change, but the VLAN offloads in dev->data->dev_conf.rxmode.offloads will be turned on. It is supposed to check the hardware capabilities to decide whether the relative callback needs to be called just like the behavior in the API function named rte_eth_dev_configure. And it is also needed to cleanup duplicated checks which are done in some PMDs. Also, note that it is behaviour change for some PMDs which simply ignore (with error/warning log message) unsupported VLAN offloads, but now it will fail. Fixes: a4996bd89c42 ("ethdev: new Rx/Tx offloads API") Fixes: 0ebce6129bc6 ("net/dpaa2: support new ethdev offload APIs") Fixes: f9416bbafd98 ("net/enic: remove VLAN filter handler") Fixes: 4f7d9e383e5c ("fm10k: update vlan offload features") Fixes: fdba3bf15c7b ("net/hinic: add VLAN filter and offload") Fixes: b96fb2f0d22b ("net/i40e: handle QinQ strip") Fixes: d4a27a3b092a ("nfp: add basic features") Fixes: 56139e85abec ("net/octeontx: support VLAN filter offload") Fixes: ba1b3b081edf ("net/octeontx2: support VLAN offloads") Fixes: d87246a43759 ("net/qede: enable and disable VLAN filtering") Cc: sta...@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) Acked-by: Andrew Rybchenko Acked-by: Hyong Youb Kim Acked-by: Sachin Saxena Acked-by: Xiaoyun wang Acked-by: Harman Kalra --- v5 -> v6: add the related history patch into the Fixes commit log. v4 -> v5: no change. v3 -> v4: Delete "next_mask" label and modify the function that when the offload is not supported the function fail. v2 -> v3: Add __rte_unused to avoid unused parameter 'dev' and 'mask' warning. v1 -> v2: Cleanup duplicated checks which are done in some PMDs. --- drivers/net/dpaa2/dpaa2_ethdev.c | 12 +++- drivers/net/enic/enic_ethdev.c | 12 drivers/net/fm10k/fm10k_ethdev.c | 23 ++- drivers/net/hinic/hinic_pmd_ethdev.c | 6 -- drivers/net/i40e/i40e_ethdev.c | 5 - drivers/net/nfp/nfp_net.c | 5 - drivers/net/octeontx/octeontx_ethdev_ops.c | 10 -- drivers/net/octeontx2/otx2_vlan.c | 5 - drivers/net/qede/qede_ethdev.c | 3 --- lib/librte_ethdev/rte_ethdev.c | 21 + 10 files changed, 26 insertions(+), 76 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index a1f1919..489d744 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -145,7 +145,7 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) { struct dpaa2_dev_priv *priv = dev->data->dev_private; struct fsl_mc_io *dpni = dev->process_private; - int ret; + int ret = 0; PMD_INIT_FUNC_TRACE(); @@ -153,7 +153,7 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) /* VLAN Filter not avaialble */ if (!priv->max_vlan_filters) { DPAA2_PMD_INFO("VLAN filter not available"); - goto next_mask; + return -ENOTSUP; } if (dev->data->dev_conf.rxmode.offloads & @@ -166,14 +166,8 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask) if (ret < 0) DPAA2_PMD_INFO("Unable to set vlan filter = %d", ret); } -next_mask: - if (mask & ETH_VLAN_EXTEND_MASK) { - if (dev->data->dev_conf.rxmode.offloads & - DEV_RX_OFFLOAD_VLAN_EXTEND) - DPAA2_PMD_INFO("VLAN extend offload not supported"); - } - return 0; + return ret; } static int diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 6a3580f..30a599d 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -367,18 +367,6 @@ static int enicpmd_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask) enic->ig_vlan_strip_en = 0; } - if ((mask & ETH_VLAN_FILTER_MASK) && - (offloads & DEV_RX_OFFLOAD_VLAN_FILTER)) { - dev_warning(enic, - "Configuration of VLAN filter is not supported\n"); - } - - if ((mask & ETH_VLAN_EXTEND_MASK) && - (offloads & DEV_RX_OFFLOAD_VLAN_EXTEND)) { - dev_warning(enic, - &qu
[dpdk-dev] [PATCH v6 1/2] ethdev: fix data room size verification in Rx queue setup
In the rte_eth_rx_queue_setup API function, the local variable named mbp_buf_size, which is the data room size of the input parameter mp, is checked to guarantee that each memory chunck used for net device in the mbuf is bigger than the min_rx_bufsize. But if mbp_buf_size is less than RTE_PKTMBUF_HEADROOM, the value of the following statement will be a large number since the mbp_buf_size is a unsigned value. mbp_buf_size - RTE_PKTMBUF_HEADROOM As a result, it will cause a segment fault in this situation. This patch fixes it by modify the check condition to guarantee that the local varibale named mbp_buf_size is bigger than RTE_PKTMBUF_HEADROOM. Fixes: af75078fece3 ("first public release") Cc: sta...@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) Reviewed-by: Andrew Rybchenko Acked-by: Sachin Saxena --- v2 -> v6: No change. v1 -> v2: Simplify the check condition of mbp_buf_size according to Andrew Rybchenko's comment. --- lib/librte_ethdev/rte_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index d06b7f9..50c3f18 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1820,7 +1820,7 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, } mbp_buf_size = rte_pktmbuf_data_room_size(mp); - if ((mbp_buf_size - RTE_PKTMBUF_HEADROOM) < dev_info.min_rx_bufsize) { + if (mbp_buf_size < dev_info.min_rx_bufsize + RTE_PKTMBUF_HEADROOM) { RTE_ETHDEV_LOG(ERR, "%s mbuf_data_room_size %d < %d (RTE_PKTMBUF_HEADROOM=%d + min_rx_bufsize(dev)=%d)\n", mp->name, (int)mbp_buf_size, -- 2.7.4