net/mana: 32 bit support
Subsystems (2)
cover 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
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(-)
Signature · 1 line
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.
--- 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(-)
drivers/net/mana/mana.c +1 -1
@@ -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);
drivers/net/mana/meson.build +2 -2
@@ -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
drivers/net/mana/mr.c +9 -9
@@ -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,return &table[base];DP_LOG (DEBUG , -"addr 0x%" PRIx64" len %zu idx %u sum 0x%" PRIx64" not found" , +"addr 0x%" PRIxPTR" len %zu idx %u sum 0x%" PRIxPTR" not found" , addr, len, *idx, addr + len);return NULL ;
@@ -316,7 +316,7 @@ mana_mr_btree_insert(struct mana_mr_btree *bt, struct mana_mr_cache *entry)uint16_t shift;if (mana_mr_btree_lookup (bt, &idx, entry->addr, entry->len)) { -DP_LOG (DEBUG ,"Addr 0x%" PRIx64" len %zu exists in btree" , +DP_LOG (DEBUG ,"Addr 0x%" PRIxPTR" len %zu exists in btree" , entry->addr, entry->len);return 0 ; }
@@ -340,7 +340,7 @@ mana_mr_btree_insert(struct mana_mr_btree *bt, struct mana_mr_cache *entry) bt->len++;DP_LOG (DEBUG , -"Inserted MR b-tree table %p idx %d addr 0x%" PRIx64" len %zu" , +"Inserted MR b-tree table %p idx %d addr 0x%" PRIxPTR" len %zu" , table, idx, entry->addr, entry->len);return 0 ;
Signature · 1 line
2.34.1
Re: [PATCH 1/2] net/mana: enable 32 bit build for mana driver
Quoted 7 lines · Wei Hu
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.
s/applicatons/applications/
can fix while merging
RE: [PATCH 1/2] net/mana: enable 32 bit build for mana driver
In reply to Wei HuQuoted 5 lines
Subject: [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.
Quoted 7 lines
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.
Signed-off-by Wei Hu <[email protected]>
Quoted 136 lines
--- 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(-)drivers/net/mana/mana.c index renamed from drivers/net/mana/mana.c +0
-0
7630118d4f..896b53ed35100644drivers/net/mana/mana.c +1
-1@@ -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) {drivers/net/mana/mana.c +0
-0DRV_LOG (ERR ,"ibv_alloc_parent_domain failed port %d" , port);drivers/net/mana/meson.build index renamed from drivers/net/mana/meson.build +0
-0
493f0d26d4..2d72eca5a8100644drivers/net/mana/meson.build +0
-0@@ -1,9 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2022 MicrosoftCorporation
drivers/net/mana/meson.build +2
-2-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() endifdrivers/net/mana/mr.c index renamed from drivers/net/mana/mr.c +0
-0
fec0dc961c..b8e6ea0bbf100644drivers/net/mana/mr.c +1
-1@@ -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(structmana_mr_btree*local_tree, structmana_priv*priv,drivers/net/mana/mr.c +2
-2ranges[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(structmana_mr_btree*local_tree, structmana_priv*priv,drivers/net/mana/mr.c +2
-2return 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",drivers/net/mana/mr.c +1
-1mr->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;drivers/net/mana/mr.c +3
-2}@@ -266,7 +266,7 @@ mana_mr_btree_lookup(struct mana_mr_btree *bt,uint16_t *idx, return &table[base];DP_LOG (DEBUG , -"addr 0x%" PRIx64" len %zu idx %u sum 0x%" PRIx64" not found" , +"addr 0x%" PRIxPTR" len %zu idx %u sum 0x%" PRIxPTR" not +found", addr, len, *idx, addr + len);return NULL ;@@ -316,7 +316,7 @@ mana_mr_btree_insert(struct mana_mr_btree *bt, struct mana_mr_cache *entry)uint16_t shift;if (mana_mr_btree_lookup (bt, &idx, entry->addr, entry->len)) { -DP_LOG (DEBUG ,"Addr 0x%" PRIx64" len %zu exists in btree" , +DP_LOG (DEBUG ,"Addr 0x%" PRIxPTR" len %zu exists in btree" , entry->addr, entry->len);return 0 ;drivers/net/mana/mr.c +2
-2}@@ -340,7 +340,7 @@ mana_mr_btree_insert(struct mana_mr_btree *bt, struct mana_mr_cache *entry) bt->len++;DP_LOG (DEBUG , -"Inserted MR b-tree table %p idx %d addr 0x%" PRIx64" len %zu" , + "Inserted MR b-tree table %p idx %d addr 0x%" PRIxPTR " len +%zu", table, idx, entry->addr, entry->len);return 0 ; --2.34.1
Re: [PATCH 1/2] net/mana: enable 32 bit build for mana driver
Quoted 9 lines · Long Li
Quoted 9 lines
Subject: [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.
Quoted 6 lines
Quoted 3 lines
Signed-off-by Wei Hu <[email protected]>Acked-by Long Li <[email protected]>
Series applied to dpdk-next-net/main, thanks.
PATCH 2/2 net/mana: add 32 bit short doorbell
In reply to Wei HuAdd 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.
--- 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(+)
drivers/net/mana/gdma.c +92 -0
@@ -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.
drivers/net/mana/mana.h +26 -0
@@ -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 +#define GDMA_SHORT_DB_INC_MASK 0xffff +#define GDMA_SHORT_DB_QID_MASK 0xfff + +#define GDMA_SHORT_DB_MAX_WQE (0x10000 / 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 */ #define INLINE_OOB_SMALL_SIZE_IN_BYTES 8#define INLINE_OOB_LARGE_SIZE_IN_BYTES 24
@@ -425,6 +440,11 @@ struct mana_rxq {*/ uint32_t desc_ring_head, desc_ring_tail; +#ifdef RTE_ARCH_32 +/* For storing wqe increment count btw each short doorbell ring */ +uint32_t wqe_cnt_to_short_db; +#endif +struct mana_gdma_queue gdma_rq;struct mana_gdma_queue gdma_cq;struct gdma_comp *gdma_comp_buf;
@@ -455,8 +475,14 @@ extern int mana_logtype_init;#define PMD_INIT_FUNC_TRACE () PMD_INIT_LOG(DEBUG, " >>") +#ifdef RTE_ARCH_32 +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); +#else int mana_ring_doorbell (void *db_page,enum gdma_queue_types queue_type,uint32_t queue_id,uint32_t tail,uint8_t arm); +#endif int mana_rq_ring_doorbell (struct mana_rxq *rxq); int gdma_post_work_request(struct mana_gdma_queue *queue,
drivers/net/mana/rx.c +45 -0
97 lines not on this page · raw message
drivers/net/mana/tx.c +25 -0
@@ -176,6 +176,9 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)void *db_page;uint16_t pkt_sent =0 ;uint32_t num_comp, i; +#ifdef RTE_ARCH_32 +uint32_t wqe_count =0 ; +#endif /* Process send completions from GDMA */ num_comp = gdma_poll_completion_queue(&txq->gdma_cq,
@@ -418,6 +421,20 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)DP_LOG (DEBUG ,"nb_pkts %u pkt[%d] sent" , nb_pkts, pkt_idx); +#ifdef RTE_ARCH_32 + wqe_count += wqe_size_in_bu; +if (wqe_count >TX_WQE_SHORT_DB_THRESHOLD ) { +/* wqe_count approaching to short doorbell +* increment limit. Stop processing further +* more packets and just ring short +* doorbell. +*/ +DP_LOG (DEBUG ,"wqe_count %u reaching limit, " +"pkt_sent %d" , + wqe_count, pkt_sent); +break ; + } +#endif }else {DP_LOG (DEBUG ,"pkt[%d] failed to post send ret %d" , pkt_idx, ret);
@@ -436,11 +453,19 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) }if (pkt_sent) { +#ifdef RTE_ARCH_32 + ret =mana_ring_short_doorbell (db_page,GDMA_QUEUE_SEND , + txq->gdma_sq.id, + wqe_count * +GDMA_WQE_ALIGNMENT_UNIT_SIZE , +0 ); +#else ret =mana_ring_doorbell (db_page,GDMA_QUEUE_SEND , txq->gdma_sq.id, txq->gdma_sq.head *GDMA_WQE_ALIGNMENT_UNIT_SIZE ,0 ); +#endif if (ret)DP_LOG (ERR ,"mana_ring_doorbell failed ret %d" , ret); }
Signature · 1 line
2.34.1
Re: [PATCH 2/2] net/mana: add 32 bit short doorbell
Quoted 3 lines · Wei Hu
Add 32 bit short doorbell support. Ring short doorbell when running in 32 bit applicactions.
s/applicactions/applications/
can fix while merging
RE: [PATCH 2/2] net/mana: add 32 bit short doorbell
In reply to Wei HuQuoted 5 lines
Subject: [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.
Quoted 8 lines
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.Signed-off-by Wei Hu <[email protected]>
Quoted 10 lines · Wei Hu
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 fromsize_ttouintptr_t
- remove short doorbell for CQ as it is not supported
- add a couple missing ifdefs
- fix the short doorbell threshold counting in wqes
Quoted 4 lines
Need to backport these to 22.11.x
Will keep the tag and leave the decision to LTS maintainers.
Quoted 4 lines
Wei Hu (2):
net/mana: enable 32 bit build for mana driver
net/mana: add 32 bit short doorbell
Looks good to me, will wait Long's ack to proceed.