Introduce Microsoft Azure Network Adatper (MANA) PMD
Subsystems (2)
cover Introduce Microsoft Azure Network Adatper (MANA) PMD
From: Long Li <[email protected]>
MANA is a network interface card to be used in the Azure cloud environment. MANA provides safe access to user memory through memory registration. It has IOMMU built into the hardware.
MANA uses IB verbs and RDMA layer to configure hardware resources. It requires the corresponding RDMA kernel-mode and user-mode drivers.
The MANA RDMA kernel-mode driver is being reviewed at:
https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/
The MANA RDMA user-mode driver is being reviewed at:
https://github.com/linux-rdma/rdma-core/pull/1177
Long Li (17):
net/mana: add basic driver, build environment and doc net/mana: add device configuration and stop net/mana: add function to report support ptypes net/mana: add link update
net/mana: add function for device removal interrupts net/mana: add device info
net/mana: add function to configure RSS net/mana: add function to configure RX queues net/mana: add function to configure TX queues net/mana: implement memory registration net/mana: implement the hardware layer operations net/mana: add function to start/stop TX queues net/mana: add function to start/stop RX queues net/mana: add function to receive packets net/mana: add function to send packets net/mana: add function to start/stop device net/mana: add function to report queue stats
MAINTAINERS | 6 + doc/guides/nics/features/mana.ini | 18 + doc/guides/nics/index.rst | 1 + doc/guides/nics/mana.rst | 54 ++ drivers/net/mana/gdma.c | 309 +++++++ drivers/net/mana/mana.c | 1388 +++++++++++++++++++++++++++++ drivers/net/mana/mana.h | 543 +++++++++++ drivers/net/mana/meson.build | 38 + drivers/net/mana/mp.c | 345 +++++++ drivers/net/mana/mr.c | 339 +++++++ drivers/net/mana/rx.c | 473 ++++++++++ drivers/net/mana/tx.c | 420 +++++++++ drivers/net/mana/version.map | 3 + drivers/net/meson.build | 1 + 14 files changed, 3938 insertions(+) create mode 100644 doc/guides/nics/features/mana.ini create mode 100644 doc/guides/nics/mana.rst create mode 100644 drivers/net/mana/gdma.c create mode 100644 drivers/net/mana/mana.c create mode 100644 drivers/net/mana/mana.h create mode 100644 drivers/net/mana/meson.build create mode 100644 drivers/net/mana/mp.c create mode 100644 drivers/net/mana/mr.c create mode 100644 drivers/net/mana/rx.c create mode 100644 drivers/net/mana/tx.c create mode 100644 drivers/net/mana/version.map
Signature · 1 line
2.17.1
PATCH 1/17 net/mana: add basic driver, build environment and doc
From: Long Li <[email protected]>
MANA is a PCI device. It uses IB verbs to access hardware through the kernel RDMA layer. This patch introduces build environment and basic device probe functions.
--- MAINTAINERS | 6 + doc/guides/nics/features/mana.ini | 10 + doc/guides/nics/index.rst | 1 + doc/guides/nics/mana.rst | 54 +++ drivers/net/mana/mana.c | 729 ++++++++++++++++++++++++++++++ drivers/net/mana/mana.h | 214 +++++++++ drivers/net/mana/meson.build | 34 ++ drivers/net/mana/mp.c | 257 +++++++++++ drivers/net/mana/version.map | 3 + drivers/net/meson.build | 1 + 10 files changed, 1309 insertions(+) create mode 100644 doc/guides/nics/features/mana.ini create mode 100644 doc/guides/nics/mana.rst create mode 100644 drivers/net/mana/mana.c create mode 100644 drivers/net/mana/mana.h create mode 100644 drivers/net/mana/meson.build create mode 100644 drivers/net/mana/mp.c create mode 100644 drivers/net/mana/version.map
MAINTAINERS +6 -0
@@ -837,6 +837,12 @@ F: buildtools/options-ibverbs-static.sh F: doc/guides/nics/mlx5.rst F: doc/guides/nics/features/mlx5.ini +Microsoft mana +M: Long Li <[email protected]> +F: drivers/net/mana +F: doc/guides/nics/mana.rst +F: doc/guides/nics/features/mana.ini + Microsoft vdev_netvsc - EXPERIMENTAL M: Matan Azrad <[email protected]> F: drivers/net/vdev_netvsc/
doc/guides/nics/features/mana.ini new file +10 -0
@@ -0,0 +1,10 @@ +; +; Supported features of the 'cnxk' network poll mode driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +Linux = Y +Multiprocess aware = Y +Usage doc = Y +x86-64 = Y
doc/guides/nics/index.rst +1 -0
@@ -41,6 +41,7 @@ Network Interface Controller Drivers intel_vf kni liquidio + mana memif mlx4 mlx5
doc/guides/nics/mana.rst new file +54 -0
54 lines not on this page · raw message
drivers/net/mana/mana.c new file +729 -0
729 lines not on this page · raw message
drivers/net/mana/mana.h new file +214 -0
214 lines not on this page · raw message
drivers/net/mana/meson.build new file +34 -0
@@ -0,0 +1,34 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2022 Microsoft Corporation + +if is_windows + build = false + reason = 'not supported on Windows' + subdir_done() +endif + +deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs'] + +sources += files( + 'mana.c', + 'mp.c', +) + +lib = cc.find_library('ibverbs', required:false) +if lib.found() + ext_deps += lib +else + build = false + reason = 'missing dependency ibverbs' + subdir_done() +endif + + +lib = cc.find_library('mana', required:false) +if lib.found() + ext_deps += lib +else + build = false + reason = 'missing dependency mana' + subdir_done() +endif
drivers/net/mana/mp.c new file +257 -0
257 lines not on this page · raw message
drivers/net/mana/version.map new file +3 -0
@@ -0,0 +1,3 @@ +DPDK_22 { + local: *; +};
drivers/net/meson.build +1 -0
@@ -34,6 +34,7 @@ drivers = [ 'ixgbe', 'kni', 'liquidio', + 'mana', 'memif', 'mlx4', 'mlx5',
Signature · 1 line
2.17.1
PATCH 2/17 net/mana: add device configuration and stop
In reply to [email protected]From: Long Li <[email protected]>
MANA defines its memory allocation functions to override IB layer default functions to allocate device queues. This patch adds the code for device configuration and stop.
--- drivers/net/mana/mana.c | 87 ++++++++++++++++++++++++++++++++++++++++- drivers/net/mana/mana.h | 3 -- 2 files changed, 85 insertions(+), 5 deletions(-)
drivers/net/mana/mana.c +85 -2
@@ -57,7 +57,91 @@ static rte_spinlock_t mana_shared_data_lock = RTE_SPINLOCK_INITIALIZER;int mana_logtype_driver;int mana_logtype_init; +static void *mana_alloc_verbs_buf (size_t size,void *data) +{ +void *ret; +size_t alignment =rte_mem_page_size (); +int socket = (int )(uintptr_t )data; + +DRV_LOG (DEBUG ,"size=%lu socket=%d" , size, socket); + +if (alignment == (size_t )-1 ) { +DRV_LOG (ERR ,"Failed to get mem page size" ); + rte_errno =ENOMEM ; +return NULL ; + } + + ret =rte_zmalloc_socket ("mana_verb_buf" , size, alignment, socket); +if (!ret && size) + rte_errno =ENOMEM ; +return ret; +} + +static void mana_free_verbs_buf(void *ptr, void *data __rte_unused) +{ +rte_free (ptr); +} + +static int mana_dev_configure (struct rte_eth_dev *dev) +{ +struct mana_priv *priv = dev->data->dev_private; +struct rte_eth_conf *dev_conf = &dev->data->dev_conf; +const struct rte_eth_rxmode *rxmode = &dev_conf->rxmode; +const struct rte_eth_txmode *txmode = &dev_conf->txmode; + +if (dev_conf->rxmode.mq_mode Ð_MQ_RX_RSS_FLAG ) + dev_conf->rxmode.offloads |=DEV_RX_OFFLOAD_RSS_HASH ; + +if (txmode->offloads & ~BNIC_DEV_TX_OFFLOAD_SUPPORT ) { +DRV_LOG (ERR ,"Unsupported TX offload: %lx" , txmode->offloads); +return -EINVAL ; + } + +if (rxmode->offloads & ~BNIC_DEV_RX_OFFLOAD_SUPPORT ) { +DRV_LOG (ERR ,"Unsupported RX offload: %lx" , rxmode->offloads); +return -EINVAL ; + } + +if (dev->data->nb_rx_queues != dev->data->nb_tx_queues) { +DRV_LOG (ERR ,"Only support equal number of rx/tx queues" ); +return -EINVAL ; + } + +if (!rte_is_power_of_2 (dev->data->nb_rx_queues)) { +DRV_LOG (ERR ,"number of TX/RX queues must be power of 2" ); +return -EINVAL ; + } + + priv->num_queues = dev->data->nb_rx_queues; + +manadv_set_context_attr (priv->ib_ctx,MANADV_CTX_ATTR_BUF_ALLOCATORS , + (void *)((uintptr_t )&(struct manadv_ctx_allocators ){ + .alloc = &mana_alloc_verbs_buf, + .free = &mana_free_verbs_buf, + .data =0 , + })); + +return 0 ; +} + +static int +mana_dev_close (struct rte_eth_dev *dev) +{ +struct mana_priv *priv = dev->data->dev_private; +int ret; + + ret =ibv_close_device (priv->ib_ctx); +if (ret) { + ret = errno; +return ret; + } + +return 0 ; +} +const struct eth_dev_ops mana_dev_ops = { + .dev_configure = mana_dev_configure, + .dev_close = mana_dev_close, };const struct eth_dev_ops mana_dev_sec_ops = {
@@ -652,8 +736,7 @@ static int mana_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,static int mana_dev_uninit (struct rte_eth_dev *dev) { -RTE_SET_USED (dev); -return 0 ; +return mana_dev_close (dev); }static int mana_pci_remove (struct rte_pci_device *pci_dev)
drivers/net/mana/mana.h +0 -3
@@ -177,9 +177,6 @@ uint16_t mana_rx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,uint16_t mana_tx_burst_removed (void *dpdk_rxq,struct rte_mbuf **pkts,uint16_t pkts_n); -void *mana_alloc_verbs_buf (size_t size,void *data); -void mana_free_verbs_buf (void *ptr,void *data); -/** Request timeout for IPC. */ #define MANA_MP_REQ_TIMEOUT_SEC 5
Signature · 1 line
2.17.1
PATCH 3/17 net/mana: add function to report support ptypes
In reply to [email protected]From: Long Li <[email protected]>
Report supported protocol types.
--- drivers/net/mana/mana.c | 16 ++++++++++++++++ drivers/net/mana/mana.h | 2 -- 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/net/mana/mana.c +16 -0
@@ -139,9 +139,25 @@ mana_dev_close(struct rte_eth_dev *dev)return 0 ; } +static const uint32_t *mana_supported_ptypes(struct rte_eth_dev *dev __rte_unused) +{ +static const uint32_t ptypes[] = { +RTE_PTYPE_L2_ETHER , +RTE_PTYPE_L3_IPV4_EXT_UNKNOWN , +RTE_PTYPE_L3_IPV6_EXT_UNKNOWN , +RTE_PTYPE_L4_FRAG , +RTE_PTYPE_L4_TCP , +RTE_PTYPE_L4_UDP , +RTE_PTYPE_UNKNOWN + }; + +return ptypes; +} +const struct eth_dev_ops mana_dev_ops = { .dev_configure = mana_dev_configure, .dev_close = mana_dev_close, + .dev_supported_ptypes_get = mana_supported_ptypes, };const struct eth_dev_ops mana_dev_sec_ops = {
drivers/net/mana/mana.h +0 -2
@@ -169,8 +169,6 @@ extern int mana_logtype_init;#define PMD_INIT_FUNC_TRACE () PMD_INIT_LOG(DEBUG, " >>") -const uint32_t *mana_supported_ptypes (struct rte_eth_dev *dev); -uint16_t mana_rx_burst_removed (void *dpdk_rxq,struct rte_mbuf **pkts,uint16_t pkts_n);
Signature · 1 line
2.17.1
PATCH 4/17 net/mana: add link update
In reply to [email protected]From: Long Li <[email protected]>
The carrier state is managed by the Azure host. MANA runs as a VF and always reports UP.
--- doc/guides/nics/features/mana.ini | 1 + drivers/net/mana/mana.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
@@ -4,6 +4,7 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +Link status = P Linux = Y Multiprocess aware = Y Usage doc = Y
drivers/net/mana/mana.c +17 -0
@@ -154,10 +154,27 @@ static const uint32_t *mana_supported_ptypes(struct rte_eth_dev *dev __rte_unusereturn ptypes; } +static int mana_dev_link_update (struct rte_eth_dev *dev, + int wait_to_complete __rte_unused) +{ +struct rte_eth_link link; + +/* MANA has no concept of carrier state, always reporting UP */ + link = (struct rte_eth_link ) { + .link_duplex =RTE_ETH_LINK_FULL_DUPLEX , + .link_autoneg =RTE_ETH_LINK_SPEED_FIXED , + .link_speed =RTE_ETH_SPEED_NUM_200G , + .link_status =RTE_ETH_LINK_UP , + }; + +return rte_eth_linkstatus_set (dev, &link); +} +const struct eth_dev_ops mana_dev_ops = { .dev_configure = mana_dev_configure, .dev_close = mana_dev_close, .dev_supported_ptypes_get = mana_supported_ptypes, + .link_update = mana_dev_link_update, };const struct eth_dev_ops mana_dev_sec_ops = {
Signature · 1 line
2.17.1
PATCH 5/17 net/mana: add function for device removal interrupts
In reply to [email protected]From: Long Li <[email protected]>
MANA supports PCI hot plug events. Add this interrupt to DPDK core so its parent PMD can detect device removal during Azure servicing or live migration.
--- doc/guides/nics/features/mana.ini | 1 + drivers/net/mana/mana.c | 97 +++++++++++++++++++++++++++++++ drivers/net/mana/mana.h | 1 + 3 files changed, 99 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
@@ -7,5 +7,6 @@ Link status = P Linux = Y Multiprocess aware = Y +Removal event = Y Usage doc = Y x86-64 = Y
drivers/net/mana/mana.c +97 -0
121 lines not on this page · raw message
drivers/net/mana/mana.h +1 -0
@@ -72,6 +72,7 @@ struct mana_priv {uint8_t ind_table_key[40 ];struct ibv_qp *rwq_qp;void *db_page; +struct rte_intr_handle *intr_handle;int max_rx_queues;int max_tx_queues;int max_rx_desc;
Signature · 1 line
2.17.1
PATCH 6/17 net/mana: add device info
In reply to [email protected]From: Long Li <[email protected]>
Add the function to get device info.
--- doc/guides/nics/features/mana.ini | 1 + drivers/net/mana/mana.c | 82 +++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
@@ -8,5 +8,6 @@ Link status = P Linux = Y Multiprocess aware = Y Removal event = Y +Speed capabilities = P Usage doc = Y x86-64 = Y
drivers/net/mana/mana.c +82 -0
99 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 7/17 net/mana: add function to configure RSS
In reply to [email protected]From: Long Li <[email protected]>
Currently this PMD supports RSS configuration when the device is stopped. Configuring RSS in running state will be supported in the future.
--- doc/guides/nics/features/mana.ini | 1 + drivers/net/mana/mana.c | 61 +++++++++++++++++++++++++++++++ drivers/net/mana/mana.h | 1 + 3 files changed, 63 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
@@ -8,6 +8,7 @@ Link status = P Linux = Y Multiprocess aware = Y Removal event = Y +RSS hash = Y Speed capabilities = P Usage doc = Y x86-64 = Y
drivers/net/mana/mana.c +61 -0
73 lines not on this page · raw message
drivers/net/mana/mana.h +1 -0
@@ -72,6 +72,7 @@ struct mana_priv {uint8_t ind_table_key[40 ];struct ibv_qp *rwq_qp;void *db_page; +struct rte_eth_rss_conf rss_conf;struct rte_intr_handle *intr_handle;int max_rx_queues;int max_tx_queues;
Signature · 1 line
2.17.1
PATCH 8/17 net/mana: add function to configure RX queues
In reply to [email protected]From: Long Li <[email protected]>
RX hardware queue is allocated when starting the queue. This function is for queue configuration pre starting.
--- drivers/net/mana/mana.c | 68 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)
drivers/net/mana/mana.c +68 -0
@@ -225,6 +225,16 @@ static int mana_dev_info_get(struct rte_eth_dev *dev,return 0 ; } +static void mana_dev_rx_queue_info (struct rte_eth_dev *dev,uint16_t queue_id, +struct rte_eth_rxq_info *qinfo) +{ +struct mana_rxq *rxq = dev->data->rx_queues[queue_id]; + + qinfo->mp = rxq->mp; + qinfo->nb_desc = rxq->num_desc; + qinfo->conf.offloads = dev->data->dev_conf.rxmode.offloads; +} + static const uint32_t *mana_supported_ptypes(struct rte_eth_dev *dev __rte_unused) {static const uint32_t ptypes[] = {
@@ -299,6 +309,61 @@ static int mana_rss_hash_conf_get(struct rte_eth_dev *dev,return 0 ; } +static int mana_dev_rx_queue_setup (struct rte_eth_dev *dev, +uint16_t queue_idx,uint16_t nb_desc, +unsigned int socket_id, + const struct rte_eth_rxconf *rx_conf __rte_unused, +struct rte_mempool *mp) +{ +struct mana_priv *priv = dev->data->dev_private; +struct mana_rxq *rxq; +int ret; + + rxq =rte_zmalloc_socket ("mana_rxq" ,sizeof (*rxq),0 , socket_id); +if (!rxq) { +DRV_LOG (ERR ,"failed to allocate rxq" ); +return -ENOMEM ; + } + +DRV_LOG (DEBUG ,"idx %u nb_desc %u socket %u" , + queue_idx, nb_desc, socket_id); + + rxq->socket = socket_id; + + rxq->desc_ring =rte_zmalloc_socket ("mana_rx_mbuf_ring" , +sizeof (struct mana_rxq_desc ) * + nb_desc, +RTE_CACHE_LINE_SIZE , socket_id); + +if (!rxq->desc_ring) { +DRV_LOG (ERR ,"failed to allocate rxq desc_ring" ); + ret = -ENOMEM ; + goto fail; + } + + rxq->num_desc = nb_desc; + + rxq->priv = priv; + rxq->num_desc = nb_desc; + rxq->mp = mp; + dev->data->rx_queues[queue_idx] = rxq; + +return 0 ; + +fail: +rte_free (rxq->desc_ring); +rte_free (rxq); +return ret; +} + +static void mana_dev_rx_queue_release (struct rte_eth_dev *dev,uint16_t qid) +{ +struct mana_rxq *rxq = dev->data->rx_queues[qid]; + +rte_free (rxq->desc_ring); +rte_free (rxq); +} +static int mana_dev_link_update (struct rte_eth_dev *dev, int wait_to_complete __rte_unused) {
@@ -319,9 +384,12 @@ const struct eth_dev_ops mana_dev_ops = { .dev_configure = mana_dev_configure, .dev_close = mana_dev_close, .dev_infos_get = mana_dev_info_get, + .rxq_info_get = mana_dev_rx_queue_info, .dev_supported_ptypes_get = mana_supported_ptypes, .rss_hash_update = mana_rss_hash_update, .rss_hash_conf_get = mana_rss_hash_conf_get, + .rx_queue_setup = mana_dev_rx_queue_setup, + .rx_queue_release = mana_dev_rx_queue_release, .link_update = mana_dev_link_update, };
Signature · 1 line
2.17.1
PATCH 9/17 net/mana: add function to configure TX queues
In reply to [email protected]From: Long Li <[email protected]>
TX hardware queue is allocated when starting the queue, this is for pre configuration.
--- drivers/net/mana/mana.c | 65 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
drivers/net/mana/mana.c +65 -0
@@ -225,6 +225,15 @@ static int mana_dev_info_get(struct rte_eth_dev *dev,return 0 ; } +static void mana_dev_tx_queue_info (struct rte_eth_dev *dev,uint16_t queue_id, +struct rte_eth_txq_info *qinfo) +{ +struct mana_txq *txq = dev->data->tx_queues[queue_id]; + + qinfo->conf.offloads = dev->data->dev_conf.txmode.offloads; + qinfo->nb_desc = txq->num_desc; +} +static void mana_dev_rx_queue_info (struct rte_eth_dev *dev,uint16_t queue_id,struct rte_eth_rxq_info *qinfo) {
@@ -309,6 +318,59 @@ static int mana_rss_hash_conf_get(struct rte_eth_dev *dev,return 0 ; } +static int mana_dev_tx_queue_setup (struct rte_eth_dev *dev, +uint16_t queue_idx,uint16_t nb_desc, +unsigned int socket_id, + const struct rte_eth_txconf *tx_conf __rte_unused) + +{ +struct mana_priv *priv = dev->data->dev_private; +struct mana_txq *txq; +int ret; + + txq =rte_zmalloc_socket ("mana_txq" ,sizeof (*txq),0 , socket_id); +if (!txq) { +DRV_LOG (ERR ,"failed to allocate txq" ); +return -ENOMEM ; + } + + txq->socket = socket_id; + + txq->desc_ring =rte_malloc_socket ("mana_tx_desc_ring" , +sizeof (struct mana_txq_desc ) * + nb_desc, +RTE_CACHE_LINE_SIZE , socket_id); +if (!txq->desc_ring) { +DRV_LOG (ERR ,"failed to allocate txq desc_ring" ); + ret = -ENOMEM ; + goto fail; + } + +DRV_LOG (DEBUG ,"idx %u nb_desc %u socket %u txq->desc_ring %p" , + queue_idx, nb_desc, socket_id, txq->desc_ring); + + txq->desc_ring_head =0 ; + txq->desc_ring_tail =0 ; + txq->priv = priv; + txq->num_desc = nb_desc; + dev->data->tx_queues[queue_idx] = txq; + +return 0 ; + +fail: +rte_free (txq->desc_ring); +rte_free (txq); +return ret; +} + +static void mana_dev_tx_queue_release (struct rte_eth_dev *dev,uint16_t qid) +{ +struct mana_txq *txq = dev->data->tx_queues[qid]; + +rte_free (txq->desc_ring); +rte_free (txq); +} + static int mana_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, unsigned int socket_id,
@@ -384,10 +446,13 @@ const struct eth_dev_ops mana_dev_ops = { .dev_configure = mana_dev_configure, .dev_close = mana_dev_close, .dev_infos_get = mana_dev_info_get, + .txq_info_get = mana_dev_tx_queue_info, .rxq_info_get = mana_dev_rx_queue_info, .dev_supported_ptypes_get = mana_supported_ptypes, .rss_hash_update = mana_rss_hash_update, .rss_hash_conf_get = mana_rss_hash_conf_get, + .tx_queue_setup = mana_dev_tx_queue_setup, + .tx_queue_release = mana_dev_tx_queue_release, .rx_queue_setup = mana_dev_rx_queue_setup, .rx_queue_release = mana_dev_rx_queue_release, .link_update = mana_dev_link_update,
Signature · 1 line
2.17.1
PATCH 10/17 net/mana: implement memory registration
In reply to [email protected]From: Long Li <[email protected]>
MANA hardware has iommu built-in, that provides hardware safe access to user memory through memory registration. Since memory registration is an expensive operation, this patch implements a two level memory registartion cache mechanisum for each queue and for each port.
--- drivers/net/mana/mana.c | 20 +++ drivers/net/mana/mana.h | 38 ++++ drivers/net/mana/meson.build | 1 + drivers/net/mana/mp.c | 85 +++++++++ drivers/net/mana/mr.c | 339 +++++++++++++++++++++++++++++++++++ 5 files changed, 483 insertions(+) create mode 100644 drivers/net/mana/mr.c
drivers/net/mana/mana.c +20 -0
@@ -132,6 +132,8 @@ mana_dev_close(struct rte_eth_dev *dev)struct mana_priv *priv = dev->data->dev_private;int ret; +remove_all_mr (priv); + ret =mana_intr_uninstall (priv);if (ret)return ret;
@@ -346,6 +348,13 @@ static int mana_dev_tx_queue_setup(struct rte_eth_dev *dev, goto fail; } + ret =mana_mr_btree_init (&txq->mr_btree, +MANA_MR_BTREE_PER_QUEUE_N ,0 ); +if (ret) { +DRV_LOG (ERR ,"Failed to init TXQ MR btree" ); + goto fail; + } +DRV_LOG (DEBUG ,"idx %u nb_desc %u socket %u txq->desc_ring %p" , queue_idx, nb_desc, socket_id, txq->desc_ring);
@@ -367,6 +376,8 @@ static void mana_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid) {struct mana_txq *txq = dev->data->tx_queues[qid]; +mana_mr_btree_free (&txq->mr_btree); +rte_free (txq->desc_ring);rte_free (txq); }
@@ -403,6 +414,13 @@ static int mana_dev_rx_queue_setup(struct rte_eth_dev *dev, goto fail; } + ret =mana_mr_btree_init (&rxq->mr_btree, +MANA_MR_BTREE_PER_QUEUE_N , socket_id); +if (ret) { +DRV_LOG (ERR ,"Failed to init RXQ MR btree" ); + goto fail; + } + rxq->num_desc = nb_desc; rxq->priv = priv;
@@ -422,6 +440,8 @@ static void mana_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid) {struct mana_rxq *rxq = dev->data->rx_queues[qid]; +mana_mr_btree_free (&rxq->mr_btree); +rte_free (rxq->desc_ring);rte_free (rxq); }
drivers/net/mana/mana.h +38 -0
@@ -50,6 +50,22 @@ struct mana_shared_data {#define MAX_RECEIVE_BUFFERS_PER_QUEUE 256#define MAX_SEND_BUFFERS_PER_QUEUE 256 +struct mana_mr_cache { +uint32_t lkey; +uintptr_t addr; +size_t len; +void *verb_obj; +}; + +#define MANA_MR_BTREE_CACHE_N 512 +struct mana_mr_btree { +uint16_t len;/* Used entries */ +uint16_t size;/* Total entries */ +int overflow; +int socket; +struct mana_mr_cache *table; +}; +struct mana_process_priv {void *db_page; };
@@ -82,6 +98,7 @@ struct mana_priv {int max_recv_sge;int max_mr;uint64_t max_mr_size; +struct mana_mr_btree mr_btree;rte_rwlock_t mr_list_lock; };
@@ -132,6 +149,7 @@ struct mana_txq {uint32_t desc_ring_head, desc_ring_tail;struct mana_stats stats; +struct mana_mr_btree mr_btree;unsigned int socket; };
@@ -154,6 +172,7 @@ struct mana_rxq {struct mana_gdma_queue gdma_cq;struct mana_stats stats; +struct mana_mr_btree mr_btree;unsigned int socket; };
@@ -177,6 +196,24 @@ uint16_t mana_rx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,uint16_t mana_tx_burst_removed (void *dpdk_rxq,struct rte_mbuf **pkts,uint16_t pkts_n); +struct mana_mr_cache *find_pmd_mr (struct mana_mr_btree *local_tree, +struct mana_priv *priv, +struct rte_mbuf *mbuf); +int new_pmd_mr (struct mana_mr_btree *local_tree,struct mana_priv *priv, +struct rte_mempool *pool); +void remove_all_mr (struct mana_priv *priv); +void del_pmd_mr (struct mana_mr_cache *mr); + +void mana_mempool_chunk_cb (struct rte_mempool *mp,void *opaque, +struct rte_mempool_memhdr *memhdr,unsigned int idx); + +struct mana_mr_cache *mana_mr_btree_lookup (struct mana_mr_btree *bt, +uint16_t *idx, +uintptr_t addr,size_t len); +int mana_mr_btree_insert (struct mana_mr_btree *bt,struct mana_mr_cache *entry); +int mana_mr_btree_init (struct mana_mr_btree *bt,int n,int socket); +void mana_mr_btree_free (struct mana_mr_btree *bt); +/** Request timeout for IPC. */ #define MANA_MP_REQ_TIMEOUT_SEC 5
@@ -205,6 +242,7 @@ int mana_mp_init_secondary(void);void mana_mp_uninit_primary (void );void mana_mp_uninit_secondary (void );int mana_mp_req_verbs_cmd_fd (struct rte_eth_dev *dev); +int mana_mp_req_mr_create (struct mana_priv *priv,uintptr_t addr,uint32_t len);void mana_mp_req_on_rxtx (struct rte_eth_dev *dev,enum mana_mp_req_type type);
drivers/net/mana/meson.build +1 -0
@@ -11,6 +11,7 @@ deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs'] sources += files( 'mana.c', + 'mr.c', 'mp.c', )
drivers/net/mana/mp.c +85 -0
103 lines not on this page · raw message
drivers/net/mana/mr.c new file +339 -0
339 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 11/17 net/mana: implement the hardware layer operations
In reply to [email protected]From: Long Li <[email protected]>
The hardware layer of MANA understands the device queue and doorbell formats. Those functions are implemented for use by packet RX/TX code.
--- drivers/net/mana/gdma.c | 309 +++++++++++++++++++++++++++++++++++ drivers/net/mana/mana.h | 183 +++++++++++++++++++++ drivers/net/mana/meson.build | 1 + 3 files changed, 493 insertions(+) create mode 100644 drivers/net/mana/gdma.c
drivers/net/mana/gdma.c new file +309 -0
@@ -0,0 +1,309 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2022 Microsoft Corporation +*/ + +#include <stddef.h> +#include <unistd.h> +#include <string.h> +#include <stdint.h> +#include <stdlib.h> +#include <errno.h> +#include <stdio.h> +#include <sys/types.h> +#include <dirent.h> + +#include <rte_malloc.h> +#include <ethdev_driver.h> +#include <ethdev_pci.h> +#include <rte_pci.h> +#include <rte_bus_pci.h> +#include <rte_common.h> +#include <rte_kvargs.h> +#include <rte_rwlock.h> +#include <rte_spinlock.h> +#include <rte_string_fns.h> +#include <rte_alarm.h> +#include <rte_log.h> +#include <rte_eal_paging.h> +#include <rte_io.h> + +#include <infiniband/verbs.h> +#include <infiniband/manadv.h> + +#include "mana.h" + +uint8_t *gdma_get_wqe_pointer (struct mana_gdma_queue *queue) +{ +uint32_t offset_in_bytes = + (queue->head *GDMA_WQE_ALIGNMENT_UNIT_SIZE ) & + (queue->size -1 ); + +DRV_LOG (DEBUG ,"txq sq_head %u sq_size %u offset_in_bytes %u" , + queue->head, queue->size, offset_in_bytes); + +if (offset_in_bytes +GDMA_WQE_ALIGNMENT_UNIT_SIZE > queue->size) +DRV_LOG (ERR ,"fatal error: offset_in_bytes %u too big" , + offset_in_bytes); + +return ((uint8_t *)queue->buffer) + offset_in_bytes; +} + +static uint32_t +write_dma_client_oob (uint8_t *work_queue_buffer_pointer, +const struct gdma_work_request *work_request, +uint32_t client_oob_size) +{ +uint8_t *p = work_queue_buffer_pointer; + +struct gdma_wqe_dma_oob *header = (struct gdma_wqe_dma_oob *)p; + +memset (header,0 ,sizeof (struct gdma_wqe_dma_oob )); + header->num_sgl_entries = work_request->num_sgl_elements; + header->inline_client_oob_size_in_dwords = + client_oob_size /sizeof (uint32_t ); + header->client_data_unit = work_request->client_data_unit; + +DRV_LOG (DEBUG ,"queue buf %p sgl %u oob_h %u du %u oob_buf %p oob_b %u" , + work_queue_buffer_pointer, header->num_sgl_entries, + header->inline_client_oob_size_in_dwords, + header->client_data_unit, work_request->inline_oob_data, + work_request->inline_oob_size_in_bytes); + + p +=sizeof (struct gdma_wqe_dma_oob ); +if (work_request->inline_oob_data && + work_request->inline_oob_size_in_bytes >0 ) { +memcpy (p, work_request->inline_oob_data, + work_request->inline_oob_size_in_bytes); +if (client_oob_size > work_request->inline_oob_size_in_bytes) +memset (p + work_request->inline_oob_size_in_bytes,0 , + client_oob_size - + work_request->inline_oob_size_in_bytes); + } + +return sizeof (struct gdma_wqe_dma_oob ) + client_oob_size; +} + +static uint32_t +write_scatter_gather_list (uint8_t *work_queue_head_pointer, +uint8_t *work_queue_end_pointer, +uint8_t *work_queue_cur_pointer, +struct gdma_work_request *work_request) +{ +struct gdma_sgl_element *sge_list; +struct gdma_sgl_element dummy_sgl[1 ]; +uint8_t *address; +uint32_t size; +uint32_t num_sge; +uint32_t size_to_queue_end; +uint32_t sge_list_size; + +DRV_LOG (DEBUG ,"work_queue_cur_pointer %p work_request->flags %x" , + work_queue_cur_pointer, work_request->flags); + + num_sge = work_request->num_sgl_elements; + sge_list = work_request->sgl; + size_to_queue_end = (uint32_t )(work_queue_end_pointer - + work_queue_cur_pointer); + +if (num_sge ==0 ) { +/* Per spec, the case of an empty SGL should be handled as +* follows to avoid corrupted WQE errors: +* Write one dummy SGL entry +* Set the address to 1, leave the rest as 0 +*/ + dummy_sgl[num_sge].address =1 ; + dummy_sgl[num_sge].size =0 ; + dummy_sgl[num_sge].memory_key =0 ; + num_sge++; + sge_list = dummy_sgl; + } + + sge_list_size =0 ; + { + address = (uint8_t *)sge_list; + size =sizeof (struct gdma_sgl_element ) * num_sge; +if (size_to_queue_end < size) { +memcpy (work_queue_cur_pointer, address, + size_to_queue_end); + work_queue_cur_pointer = work_queue_head_pointer; + address += size_to_queue_end; + size -= size_to_queue_end; + } + +memcpy (work_queue_cur_pointer, address, size); + sge_list_size = size; + } + +DRV_LOG (DEBUG ,"sge %u address 0x%lx size %u key %u sge_list_size %u" , + num_sge, sge_list->address, sge_list->size, + sge_list->memory_key, sge_list_size); + +return sge_list_size; +} + +int gdma_post_work_request (struct mana_gdma_queue *queue, +struct gdma_work_request *work_req, +struct gdma_posted_wqe_info *wqe_info) +{ +uint32_t client_oob_size = + work_req->inline_oob_size_in_bytes > +INLINE_OOB_SMALL_SIZE_IN_BYTES ? +INLINE_OOB_LARGE_SIZE_IN_BYTES : +INLINE_OOB_SMALL_SIZE_IN_BYTES ; + +uint32_t sgl_data_size =sizeof (struct gdma_sgl_element ) * +RTE_MAX ((uint32_t )1 , work_req->num_sgl_elements); +uint32_t wqe_size = +RTE_ALIGN (sizeof (struct gdma_wqe_dma_oob ) + + client_oob_size + sgl_data_size, +GDMA_WQE_ALIGNMENT_UNIT_SIZE ); +uint8_t *wq_buffer_pointer; +uint32_t queue_free_units = queue->count - (queue->head - queue->tail); + +if (wqe_size /GDMA_WQE_ALIGNMENT_UNIT_SIZE > queue_free_units) { +DRV_LOG (DEBUG ,"WQE size %u queue count %u head %u tail %u" , + wqe_size, queue->count, queue->head, queue->tail); +return -EBUSY ; + } + +DRV_LOG (DEBUG ,"client_oob_size %u sgl_data_size %u wqe_size %u" , + client_oob_size, sgl_data_size, wqe_size); + +if (wqe_info) { + wqe_info->wqe_index = + ((queue->head *GDMA_WQE_ALIGNMENT_UNIT_SIZE ) & + (queue->size -1 )) /GDMA_WQE_ALIGNMENT_UNIT_SIZE ; + wqe_info->unmasked_queue_offset = queue->head; + wqe_info->wqe_size_in_bu = + wqe_size /GDMA_WQE_ALIGNMENT_UNIT_SIZE ; + } + + wq_buffer_pointer =gdma_get_wqe_pointer (queue); + wq_buffer_pointer +=write_dma_client_oob (wq_buffer_pointer, work_req, + client_oob_size); +if (wq_buffer_pointer >= ((uint8_t *)queue->buffer) + queue->size) + wq_buffer_pointer -= queue->size; + +write_scatter_gather_list ((uint8_t *)queue->buffer, + (uint8_t *)queue->buffer + queue->size, + wq_buffer_pointer, work_req); + + queue->head += wqe_size /GDMA_WQE_ALIGNMENT_UNIT_SIZE ; + +return 0 ; +} + +union gdma_doorbell_entry { +uint64_t as_uint64; + +struct { +uint64_t id :24 ; +uint64_t reserved :8 ; +uint64_t tail_ptr :31 ; +uint64_t arm :1 ; + } cq; + +struct { +uint64_t id :24 ; +uint64_t wqe_cnt :8 ; +uint64_t tail_ptr :32 ; + } rq; + +struct { +uint64_t id :24 ; +uint64_t reserved :8 ; +uint64_t tail_ptr :32 ; + } sq; + +struct { +uint64_t id :16 ; +uint64_t reserved :16 ; +uint64_t tail_ptr :31 ; +uint64_t arm :1 ; + } eq; +};/* HW DATA */ + +#define DOORBELL_OFFSET_SQ 0x0 +#define DOORBELL_OFFSET_RQ 0x400 +#define DOORBELL_OFFSET_CQ 0x800 +#define DOORBELL_OFFSET_EQ 0xFF8 + +int mana_ring_doorbell (void *db_page,enum gdma_queue_types queue_type, +uint32_t queue_id,uint32_t tail) +{ +uint8_t *addr = db_page; +union gdma_doorbell_entry e = {}; + +switch (queue_type) { +case gdma_queue_send: + e.sq.id = queue_id; + e.sq.tail_ptr = tail; + addr +=DOORBELL_OFFSET_SQ ; +break ; + +case gdma_queue_receive: + e.rq.id = queue_id; + e.rq.tail_ptr = tail; + e.rq.wqe_cnt =1 ; + addr +=DOORBELL_OFFSET_RQ ; +break ; + +case gdma_queue_completion: + e.cq.id = queue_id; + e.cq.tail_ptr = tail; + e.cq.arm =1 ; + addr +=DOORBELL_OFFSET_CQ ; +break ; + +default : +DRV_LOG (ERR ,"Unsupported queue type %d" , queue_type); +return -1 ; + } + +rte_wmb (); +DRV_LOG (DEBUG ,"db_page %p addr %p queue_id %u type %u tail %u" , + db_page, addr, queue_id, queue_type, tail); + +rte_write64 (e.as_uint64, addr); +return 0 ; +} + +int gdma_poll_completion_queue (struct mana_gdma_queue *cq, +struct gdma_comp *comp) +{ +struct gdma_hardware_completion_entry *cqe; +uint32_t head = cq->head % cq->count; +uint32_t new_owner_bits, old_owner_bits; +uint32_t cqe_owner_bits; +struct gdma_hardware_completion_entry *buffer = cq->buffer; + + cqe = &buffer[head]; + new_owner_bits = (cq->head / cq->count) &COMPLETION_QUEUE_OWNER_MASK ; + old_owner_bits = (cq->head / cq->count -1 ) & +COMPLETION_QUEUE_OWNER_MASK ; + cqe_owner_bits = cqe->owner_bits; + +DRV_LOG (DEBUG ,"comp cqe bits 0x%x owner bits 0x%x" , + cqe_owner_bits, old_owner_bits); + +if (cqe_owner_bits == old_owner_bits) +return 0 ;/* No new entry */ + +if (cqe_owner_bits != new_owner_bits) { +DRV_LOG (ERR ,"CQ overflowed, ID %u cqe 0x%x new 0x%x" , + cq->id, cqe_owner_bits, new_owner_bits); +return -1 ; + } + + comp->work_queue_number = cqe->wq_num; + comp->send_work_queue = cqe->is_sq; + +memcpy (comp->completion_data, cqe->dma_client_data,GDMA_COMP_DATA_SIZE ); + + cq->head++; + +DRV_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, + comp->work_queue_number, comp->send_work_queue, cq->head); +return 1 ; +}
drivers/net/mana/mana.h +183 -0
201 lines not on this page · raw message
drivers/net/mana/meson.build +1 -0
@@ -12,6 +12,7 @@ deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs'] sources += files( 'mana.c', 'mr.c', + 'gdma.c', 'mp.c', )
Signature · 1 line
2.17.1
PATCH 12/17 net/mana: add function to start/stop TX queues
In reply to [email protected]From: Long Li <[email protected]>
MANA allocate device queues through the IB layer when starting TX queues. When device is stopped all the queues are unmapped and freed.
--- doc/guides/nics/features/mana.ini | 1 + drivers/net/mana/mana.h | 4 + drivers/net/mana/meson.build | 1 + drivers/net/mana/tx.c | 180 ++++++++++++++++++++++++++++++ 4 files changed, 186 insertions(+) create mode 100644 drivers/net/mana/tx.c
doc/guides/nics/features/mana.ini +1 -0
@@ -7,6 +7,7 @@ Link status = P Linux = Y Multiprocess aware = Y +Queue start/stop = Y Removal event = Y RSS hash = Y Speed capabilities = P
drivers/net/mana/mana.h +4 -0
@@ -379,6 +379,10 @@ uint16_t mana_tx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,int gdma_poll_completion_queue (struct mana_gdma_queue *cq,struct gdma_comp *comp); +int start_tx_queues (struct rte_eth_dev *dev); + +int stop_tx_queues (struct rte_eth_dev *dev); +struct mana_mr_cache *find_pmd_mr (struct mana_mr_btree *local_tree,struct mana_priv *priv,struct rte_mbuf *mbuf);
drivers/net/mana/meson.build +1 -0
@@ -11,6 +11,7 @@ deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs'] sources += files( 'mana.c', + 'tx.c', 'mr.c', 'gdma.c', 'mp.c',
drivers/net/mana/tx.c new file +180 -0
180 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 13/17 net/mana: add function to start/stop RX queues
In reply to [email protected]From: Long Li <[email protected]>
MANA allocates device queues through the IB layer when starting RX queues. When device is stopped all the queues are unmapped and freed.
--- drivers/net/mana/mana.h | 5 + drivers/net/mana/meson.build | 1 + drivers/net/mana/rx.c | 369 +++++++++++++++++++++++++++++++++++ 3 files changed, 375 insertions(+) create mode 100644 drivers/net/mana/rx.c
drivers/net/mana/mana.h +5 -0
@@ -364,6 +364,7 @@ extern int mana_logtype_init;int mana_ring_doorbell (void *db_page,enum gdma_queue_types queue_type,uint32_t queue_id,uint32_t tail); +int rq_ring_doorbell (struct mana_rxq *rxq); int gdma_post_work_request(struct mana_gdma_queue *queue, struct gdma_work_request *work_req,
@@ -379,10 +380,14 @@ uint16_t mana_tx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts,int gdma_poll_completion_queue (struct mana_gdma_queue *cq,struct gdma_comp *comp); +int start_rx_queues (struct rte_eth_dev *dev);int start_tx_queues (struct rte_eth_dev *dev); +int stop_rx_queues (struct rte_eth_dev *dev);int stop_tx_queues (struct rte_eth_dev *dev); +int alloc_and_post_rx_wqe (struct mana_rxq *rxq); +struct mana_mr_cache *find_pmd_mr (struct mana_mr_btree *local_tree,struct mana_priv *priv,struct rte_mbuf *mbuf);
drivers/net/mana/meson.build +1 -0
@@ -11,6 +11,7 @@ deps += ['pci', 'bus_pci', 'net', 'eal', 'kvargs'] sources += files( 'mana.c', + 'rx.c', 'tx.c', 'mr.c', 'gdma.c',
drivers/net/mana/rx.c new file +369 -0
369 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 14/17 net/mana: add function to receive packets
In reply to [email protected]From: Long Li <[email protected]>
With all the RX queues created, MANA can use those queues to receive packets.
--- doc/guides/nics/features/mana.ini | 2 + drivers/net/mana/mana.c | 2 + drivers/net/mana/mana.h | 37 +++++++++++ drivers/net/mana/mp.c | 2 + drivers/net/mana/rx.c | 104 ++++++++++++++++++++++++++++++ 5 files changed, 147 insertions(+)
doc/guides/nics/features/mana.ini +2 -0
@@ -6,6 +6,8 @@ [Features] Link status = P Linux = Y +L3 checksum offload = Y +L4 checksum offload = Y Multiprocess aware = Y Queue start/stop = Y Removal event = Y
drivers/net/mana/mana.c +2 -0
@@ -987,6 +987,8 @@ static int mana_pci_probe_mac(struct rte_pci_driver *pci_drv __rte_unused,/* fd is no not used after mapping doorbell */ close (fd); + eth_dev->rx_pkt_burst = mana_rx_burst; +rte_spinlock_lock (&mana_shared_data->lock); mana_shared_data->secondary_cnt++; mana_local_data.secondary_cnt++;
drivers/net/mana/mana.h +37 -0
@@ -178,6 +178,11 @@ struct gdma_work_request {enum mana_cqe_type {CQE_INVALID =0 , + +CQE_RX_OKAY =1 , +CQE_RX_COALESCED_4 =2 , +CQE_RX_OBJECT_FENCE =3 , +CQE_RX_TRUNCATED =4 , };struct mana_cqe_header {
@@ -203,6 +208,35 @@ struct mana_cqe_header { (NDIS_HASH_TCP_IPV4 |NDIS_HASH_UDP_IPV4 |NDIS_HASH_TCP_IPV6 | \ NDIS_HASH_UDP_IPV6 | NDIS_HASH_TCP_IPV6_EX | NDIS_HASH_UDP_IPV6_EX) +struct mana_rx_comp_per_packet_info { +uint32_t packet_length :16 ; +uint32_t reserved0 :16 ; +uint32_t reserved1; +uint32_t packet_hash; +};/* HW DATA */ +#define RX_COM_OOB_NUM_PACKETINFO_SEGMENTS 4 + +struct mana_rx_comp_oob { +struct mana_cqe_header cqe_hdr; + +uint32_t rx_vlan_id :12 ; +uint32_t rx_vlan_tag_present :1 ; +uint32_t rx_outer_ip_header_checksum_succeeded :1 ; +uint32_t rx_outer_ip_header_checksum_failed :1 ; +uint32_t reserved :1 ; +uint32_t rx_hash_type :9 ; +uint32_t rx_ip_header_checksum_succeeded :1 ; +uint32_t rx_ip_header_checksum_failed :1 ; +uint32_t rx_tcp_checksum_succeeded :1 ; +uint32_t rx_tcp_checksum_failed :1 ; +uint32_t rx_udp_checksum_succeeded :1 ; +uint32_t rx_udp_checksum_failed :1 ; +uint32_t reserved1 :1 ; +struct mana_rx_comp_per_packet_info + packet_info[RX_COM_OOB_NUM_PACKETINFO_SEGMENTS ]; +uint32_t received_wqe_offset; +};/* HW DATA */ +struct gdma_wqe_dma_oob {uint32_t reserved:24 ;uint32_t last_Vbytes:8 ;
@@ -371,6 +405,9 @@ int gdma_post_work_request(struct mana_gdma_queue *queue, struct gdma_posted_wqe_info *wqe_info);uint8_t *gdma_get_wqe_pointer (struct mana_gdma_queue *queue); +uint16_t mana_rx_burst (void *dpdk_rxq,struct rte_mbuf **rx_pkts, +uint16_t pkts_n); +uint16_t mana_rx_burst_removed (void *dpdk_rxq,struct rte_mbuf **pkts,uint16_t pkts_n);
drivers/net/mana/mp.c +2 -0
@@ -160,6 +160,8 @@ static int mana_mp_secondary_handle(const struct rte_mp_msg *mp_msg,case MANA_MP_REQ_START_RXTX :DRV_LOG (INFO ,"Port %u starting datapath" , dev->data->port_id); + dev->rx_pkt_burst = mana_rx_burst; +rte_mb (); res->result =0 ;
drivers/net/mana/rx.c +104 -0
107 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 15/17 net/mana: add function to send packets
In reply to [email protected]From: Long Li <[email protected]>
With all the TX queues created, MANA can send packets over those queues.
--- doc/guides/nics/features/mana.ini | 1 + drivers/net/mana/mana.c | 1 + drivers/net/mana/mana.h | 65 ++++++++ drivers/net/mana/mp.c | 1 + drivers/net/mana/tx.c | 240 ++++++++++++++++++++++++++++++ 5 files changed, 308 insertions(+)
doc/guides/nics/features/mana.ini +1 -0
@@ -4,6 +4,7 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +Free Tx mbuf on demand = Y Link status = P Linux = Y L3 checksum offload = Y
drivers/net/mana/mana.c +1 -0
@@ -987,6 +987,7 @@ static int mana_pci_probe_mac(struct rte_pci_driver *pci_drv __rte_unused,/* fd is no not used after mapping doorbell */ close (fd); + eth_dev->tx_pkt_burst = mana_tx_burst; eth_dev->rx_pkt_burst = mana_rx_burst;rte_spinlock_lock (&mana_shared_data->lock);
drivers/net/mana/mana.h +65 -0
89 lines not on this page · raw message
drivers/net/mana/mp.c +1 -0
@@ -160,6 +160,7 @@ static int mana_mp_secondary_handle(const struct rte_mp_msg *mp_msg,case MANA_MP_REQ_START_RXTX :DRV_LOG (INFO ,"Port %u starting datapath" , dev->data->port_id); + dev->tx_pkt_burst = mana_tx_burst; dev->rx_pkt_burst = mana_rx_burst;rte_mb ();
drivers/net/mana/tx.c +240 -0
243 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 16/17 net/mana: add function to start/stop device
In reply to [email protected]From: Long Li <[email protected]>
Add support for starting/stopping the device.
--- drivers/net/mana/mana.c | 70 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
drivers/net/mana/mana.c +70 -0
@@ -126,6 +126,74 @@ static int mana_dev_configure(struct rte_eth_dev *dev)static int mana_intr_uninstall (struct mana_priv *priv); +static int +mana_dev_start (struct rte_eth_dev *dev) +{ +int ret; +struct mana_priv *priv = dev->data->dev_private; + +rte_rwlock_init (&priv->mr_list_lock); + ret =mana_mr_btree_init (&priv->mr_btree,MANA_MR_BTREE_CACHE_N , + dev->device->numa_node); +if (ret) { +DRV_LOG (ERR ,"Failed to init device MR btree %d" , ret); +return ret; + } + + ret =start_tx_queues (dev); +if (ret) { +DRV_LOG (ERR ,"failed to start tx queues %d" , ret); +return ret; + } + + ret =start_rx_queues (dev); +if (ret) { +DRV_LOG (ERR ,"failed to start rx queues %d" , ret); +stop_tx_queues (dev); +return ret; + } + +rte_wmb (); + + dev->tx_pkt_burst = mana_tx_burst; + dev->rx_pkt_burst = mana_rx_burst; + +DRV_LOG (INFO ,"TX/RX queues have started" ); + +/* Enable datapath for secondary processes */ +mana_mp_req_on_rxtx (dev,MANA_MP_REQ_START_RXTX ); + +return 0 ; +} + +static int +mana_dev_stop(struct rte_eth_dev *dev __rte_unused) +{ +int ret; + + dev->tx_pkt_burst = mana_tx_burst_removed; + dev->rx_pkt_burst = mana_rx_burst_removed; + +/* Stop datapath on secondary processes */ +mana_mp_req_on_rxtx (dev,MANA_MP_REQ_STOP_RXTX ); + +rte_wmb (); + + ret =stop_tx_queues (dev); +if (ret) { +DRV_LOG (ERR ,"failed to stop tx queues" ); +return ret; + } + + ret =stop_rx_queues (dev); +if (ret) { +DRV_LOG (ERR ,"failed to stop tx queues" ); +return ret; + } + +return 0 ; +} +static int mana_dev_close (struct rte_eth_dev *dev) {
@@ -464,6 +532,8 @@ static int mana_dev_link_update(struct rte_eth_dev *dev,const struct eth_dev_ops mana_dev_ops = { .dev_configure = mana_dev_configure, + .dev_start = mana_dev_start, + .dev_stop = mana_dev_stop, .dev_close = mana_dev_close, .dev_infos_get = mana_dev_info_get, .txq_info_get = mana_dev_tx_queue_info,
Signature · 1 line
2.17.1
PATCH 17/17 net/mana: add function to report queue stats
In reply to [email protected]From: Long Li <[email protected]>
Report packet statistics.
--- doc/guides/nics/features/mana.ini | 2 + drivers/net/mana/mana.c | 77 +++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+)
doc/guides/nics/features/mana.ini +2 -0
@@ -4,6 +4,7 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +Basic stats = Y Free Tx mbuf on demand = Y Link status = P Linux = Y
@@ -14,5 +15,6 @@ Queue start/stop = Y Removal event = Y RSS hash = Y Speed capabilities = P +Stats per queue = Y Usage doc = Y x86-64 = Y
drivers/net/mana/mana.c +77 -0
92 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH 01/17] net/mana: add basic driver, build environment and doc
In reply to [email protected]doc/guides/nics/features/mana.ini line 2
Quoted 8 lines · On Fri, 1 Jul 2022 02:02:31 -0700 [email protected] wrote:
doc/guides/nics/features/mana.ini new file +2
-0@@ -0,0 +1,10 @@ +; +; Supported features of the 'cnxk' network poll mode driver.
Looks like cut/paste error!
Quoted 8 lines
doc/guides/nics/features/mana.ini new file +8
-0+; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +Linux = Y +Multiprocess aware = Y +Usage doc = Y +x86-64 = Y
Re: [PATCH 02/17] net/mana: add device configuration and stop
In reply to [email protected]drivers/net/mana/mana.c static rte_spinlock_t mana_shared_data_lock = RTE_SPINLOCK_INITIALIZER; · line 104
Quoted 11 lines · On Fri, 1 Jul 2022 02:02:32 -0700 [email protected] wrote:
drivers/net/mana/mana.c +11
-0+ +if (txmode->offloads & ~BNIC_DEV_TX_OFFLOAD_SUPPORT ) { +DRV_LOG (ERR ,"Unsupported TX offload: %lx" , txmode->offloads); +return -EINVAL ; + } + +if (rxmode->offloads & ~BNIC_DEV_RX_OFFLOAD_SUPPORT ) { +DRV_LOG (ERR ,"Unsupported RX offload: %lx" , rxmode->offloads); +return -EINVAL ; + } +
If the device reports the correct capabilities in dev_info.tx_offload_capa and dev_info.rx_offload_capa then these checks are unnecessary since the flags are already checked in ethdev_configure.
Re: [PATCH 10/17] net/mana: implement memory registration
In reply to [email protected]drivers/net/mana/mana.h uint16_t mana_rx_burst_removed(void *dpdk_rxq, struct rte_mbuf **pkts, · line 205
Quoted 4 lines · On Fri, 1 Jul 2022 02:02:40 -0700 [email protected] wrote:
drivers/net/mana/mana.h +4
-0+int new_pmd_mr (struct mana_mr_btree *local_tree,struct mana_priv *priv, +struct rte_mempool *pool); +void remove_all_mr (struct mana_priv *priv); +void del_pmd_mr (struct mana_mr_cache *mr);
Please use one prefix across all of the driver for functions. mana_new_pmd_mr etc
Re: [PATCH 11/17] net/mana: implement the hardware layer operations
In reply to [email protected]Quoted 4 lines · On Fri, 1 Jul 2022 02:02:41 -0700 [email protected] wrote:
drivers/net/mana/gdma.c new file +4
-0+#include <rte_malloc.h> +#include <ethdev_driver.h> +#include <ethdev_pci.h> +#include <rte_pci.h>
drivers/net/mana/gdma.c line 28
Quoted 10 lines
drivers/net/mana/gdma.c new file +10
-0+#include <rte_bus_pci.h> +#include <rte_common.h> +#include <rte_kvargs.h> +#include <rte_rwlock.h> +#include <rte_spinlock.h> +#include <rte_string_fns.h> +#include <rte_alarm.h> +#include <rte_log.h> +#include <rte_eal_paging.h> +#include <rte_io.h>
This is including everything and much of this not used here. I see no rwlock, alarm or rte_malloc here.
Re: [PATCH 12/17] net/mana: add function to start/stop TX queues
In reply to [email protected]Quoted 20 lines · On Fri, 1 Jul 2022 02:02:42 -0700 [email protected] wrote:
drivers/net/mana/tx.c new file +20
-0+#include <stddef.h> +#include <unistd.h> +#include <string.h> +#include <stdint.h> +#include <stdlib.h> +#include <errno.h> +#include <stdio.h> +#include <sys/types.h> +#include <dirent.h> + +#include <rte_malloc.h> +#include <ethdev_driver.h> +#include <ethdev_pci.h> +#include <rte_pci.h> +#include <rte_bus_pci.h> +#include <rte_common.h> +#include <rte_kvargs.h> +#include <rte_rwlock.h> +#include <rte_spinlock.h> +#include <rte_string_fns.h>
drivers/net/mana/tx.c line 34
Quoted 10 lines
drivers/net/mana/tx.c new file +10
-0+#include <rte_alarm.h> +#include <rte_log.h> +#include <rte_eal_paging.h> +#include <rte_io.h> + +#include <infiniband/verbs.h> +#include <infiniband/manadv.h> + +#include "mana.h" +
Lots extra include here as well.
Try IWYU tool to find what is needed?
Re: [PATCH 13/17] net/mana: add function to start/stop RX queues
In reply to [email protected]Quoted 4 lines · On Fri, 1 Jul 2022 02:02:43 -0700 [email protected] wrote:
drivers/net/mana/rx.c new file +4
-0+ +static uint8_t mana_rss_hash_key_default[TOEPLITZ_HASH_KEY_SIZE_IN_BYTES ] = { +0x2c ,0xc6 ,0x81 ,0xd1 , +0x5b ,0xdb ,0xf4 ,0xf7 ,
drivers/net/mana/rx.c line 47
Quoted 10 lines
drivers/net/mana/rx.c new file +10
-0+0xfc ,0xa2 ,0x83 ,0x19 , +0xdb ,0x1a ,0x3e ,0x94 , +0x6b ,0x9e ,0x38 ,0xd9 , +0x2c ,0x9c ,0x03 ,0xd1 , +0xad ,0x99 ,0x44 ,0xa7 , +0xd9 ,0x56 ,0x3d ,0x59 , +0x06 ,0x3c ,0x25 ,0xf3 , + 0xfc, 0x1f, 0xdc, 0x2a, +}; +
Is this constant?
Re: [PATCH 01/17] net/mana: add basic driver, build environment and doc
In reply to [email protected]drivers/net/mana/mana.c line 233
Quoted 11 lines · On Fri, 1 Jul 2022 02:02:31 -0700 [email protected] wrote:
drivers/net/mana/mana.c new file +11
-0+while (fgets (line,sizeof (line), file) == line) { +size_t len =strlen (line); +int ret; + +/* Truncate long lines. */ +if (len == (sizeof (line) -1 )) +while (line[(len -1 )] !='\n' ) { + ret =fgetc (file); +if (ret ==EOF ) +break ; + line[(len -1 )] = ret;
An alternative, would be to use getline() which handles arbitrary length input.
Re: [PATCH 01/17] net/mana: add basic driver, build environment and doc
In reply to [email protected]drivers/net/mana/mana.h line 66
Quoted 11 lines · On Fri, 1 Jul 2022 02:02:31 -0700 [email protected] wrote:
drivers/net/mana/mana.h new file +11
-0+ +struct mana_priv { +struct rte_eth_dev_data *dev_data; +struct mana_process_priv *process_priv; +int num_queues; + +/* DPDK port */ +int port_id; + +/* IB device port */ +int dev_port;
Are the port values and number of queues really signed? Best to use unsigned value of specific size.
Re: [PATCH 01/17] net/mana: add basic driver, build environment and doc
In reply to [email protected]drivers/net/mana/mana.h line 84
Quoted 3 lines · On Fri, 1 Jul 2022 02:02:31 -0700 [email protected] wrote:
drivers/net/mana/mana.h new file +3
-0+uint64_t max_mr_size; +rte_rwlock_t mr_list_lock; +};
Reader/Writer locks are slower for the usual uncontended case. Unless you have a reader holding onto the lock for a long time, better to use spin lock.
This is Linux wisdom (thank you paulmck), Windows seems to love reader/writer locks.
Re: [PATCH 01/17] net/mana: add basic driver, build environment and doc
In reply to [email protected]Quoted 6 lines · On Fri, 1 Jul 2022 02:02:31 -0700 [email protected] wrote:
drivers/net/mana/meson.build new file +0
-0
drivers/net/mana/meson.build line 8
Quoted 8 lines
drivers/net/mana/meson.build new file +8
-0@@ -0,0 +1,34 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2022 Microsoft Corporation + +if is_windows + build = false + reason = 'not supported on Windows' + subdir_done() +endif
Since the driver is listed as only supported on x86, probably best to enforce that in meson build as well.
RE: [PATCH 01/17] net/mana: add basic driver, build environment and doc
Quoted 15 lines
Subject: Re: [PATCH 01/17] net/mana: add basic driver, build environment and doc
Quoted 9 lines · On Fri, 1 Jul 2022 02:02:31 -0700 [email protected] wrote:
(quoted diff) +0
-0b/drivers/net/mana/meson.build new file mode 100644 index 0000000000..7ab34c253c
drivers/net/mana/meson.build new file +3
-0@@ -0,0 +1,34 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2022 Microsoft +Corporation +
Quoted 8 lines
drivers/net/mana/meson.build line 8
Quoted 5 lines
drivers/net/mana/meson.build new file +5
-0+if is_windows + build = false + reason = 'not supported on Windows' + subdir_done() +endifSince the driver is listed as only supported on x86, probably best to enforce that in meson build as well.
Thank you, I'm sending v2 to address all the comments.
Long
RE: [PATCH 13/17] net/mana: add function to start/stop RX queues
In reply to Stephen HemmingerQuoted 8 lines
Subject: Re: [PATCH 13/17] net/mana: add function to start/stop RX queues
Review
Quoted 2 lines · On Fri, 1 Jul 2022 02:02:43 -0700 [email protected] wrote:
(quoted diff) +2
-0+ +static uint8_tmana_rss_hash_key_default[TOEPLITZ_HASH_KEY_SIZE_IN_BYTES] = {
Quoted 14 lines
drivers/net/mana/rx.c line 47
Quoted 12 lines
drivers/net/mana/rx.c new file +12
-0+0x2c ,0xc6 ,0x81 ,0xd1 , +0x5b ,0xdb ,0xf4 ,0xf7 , +0xfc ,0xa2 ,0x83 ,0x19 , +0xdb ,0x1a ,0x3e ,0x94 , +0x6b ,0x9e ,0x38 ,0xd9 , +0x2c ,0x9c ,0x03 ,0xd1 , +0xad ,0x99 ,0x44 ,0xa7 , +0xd9 ,0x56 ,0x3d ,0x59 , +0x06 ,0x3c ,0x25 ,0xf3 , + 0xfc, 0x1f, 0xdc, 0x2a, +}; +Is this constant?
I found it awkward defining it as const.
Later, the code uses ".rx_hash_key = mana_rss_hash_key_default" to assign this to the IB verb interface. rx_hash_key is of type uint8_t * (non const).
I'm yet to find a way to do this assignment without the compiler complaining about convert const pointer to pointer.
RE: [PATCH 01/17] net/mana: add basic driver, build environment and doc
In reply to Stephen HemmingerQuoted 14 lines
Subject: Re: [PATCH 01/17] net/mana: add basic driver, build environment and doc
drivers/net/mana/mana.h line 84
Quoted 3 lines · On Fri, 1 Jul 2022 02:02:31 -0700 [email protected] wrote:
drivers/net/mana/mana.h new file +3
-0+uint64_t max_mr_size; +rte_rwlock_t mr_list_lock; +};Reader/Writer locks are slower for the usual uncontended case. Unless you have a reader holding onto the lock for a long time, better to use spin lock.
Quoted 2 lines
This is Linux wisdom (thank you paulmck), Windows seems to love reader/writer locks.
This lock is used mostly uncontended for readers and allow them concurrently to access the list. It's rare that a writer might want to access it.
But changing it to spinlock will prevent multiple readers from accessing the list at the same time. In this use case, is it beneficial to use spinlocks?
Re: [PATCH 01/17] net/mana: add basic driver, build environment and doc
Quoted 14 lines · On Sun, 3 Jul 2022 07:56:18 +0000 Long Li <[email protected]> wrote:
Quoted 14 lines
Subject: Re: [PATCH 01/17] net/mana: add basic driver, build environment and doc
drivers/net/mana/mana.h line 84
Quoted 3 lines · On Fri, 1 Jul 2022 02:02:31 -0700 [email protected] wrote:
drivers/net/mana/mana.h new file +3
-0+uint64_t max_mr_size; +rte_rwlock_t mr_list_lock; +};Reader/Writer locks are slower for the usual uncontended case. Unless you have a reader holding onto the lock for a long time, better to use spin lock.
Quoted 6 lines
Quoted 2 lines
This is Linux wisdom (thank you paulmck), Windows seems to love reader/writer locks.
This lock is used mostly uncontended for readers and allow them concurrently to access the list. It's rare that a writer might want to access it.
But changing it to spinlock will prevent multiple readers from accessing the list at the same time. In this use case, is it beneficial to use spinlocks?
It all depends on how long the readers and writers hold the lock. If the window is short a spin lock is faster.
Re: [PATCH 01/17] net/mana: add basic driver, build environment and doc
In reply to Long LiQuoted 14 lines · On Sun, 3 Jul 2022 07:56:18 +0000 Long Li <[email protected]> wrote:
Quoted 14 lines
Subject: Re: [PATCH 01/17] net/mana: add basic driver, build environment and doc
drivers/net/mana/mana.h line 84
Quoted 3 lines · On Fri, 1 Jul 2022 02:02:31 -0700 [email protected] wrote:
drivers/net/mana/mana.h new file +3
-0+uint64_t max_mr_size; +rte_rwlock_t mr_list_lock; +};Reader/Writer locks are slower for the usual uncontended case. Unless you have a reader holding onto the lock for a long time, better to use spin lock.
Quoted 6 lines
Quoted 2 lines
This is Linux wisdom (thank you paulmck), Windows seems to love reader/writer locks.
This lock is used mostly uncontended for readers and allow them concurrently to access the list. It's rare that a writer might want to access it.
But changing it to spinlock will prevent multiple readers from accessing the list at the same time. In this use case, is it beneficial to use spinlocks?
Conclusion
Breakeven curves for the locking primitives were computed, and the breakeven between simple spinlock and distributed reader-writer spinlock supports the rule of thumb that states that simple spinlock should be used in cases where the update ratio f is greater than the reciprocal of the number of CPUs, 1/nm.
RE: [PATCH 01/17] net/mana: add basic driver, build environment and doc
Quoted 39 lines
Subject: Re: [PATCH 01/17] net/mana: add basic driver, build environment and doc
Quoted 14 lines · On Sun, 3 Jul 2022 07:56:18 +0000 Long Li <[email protected]> wrote:
Quoted 14 lines
Subject: Re: [PATCH 01/17] net/mana: add basic driver, build environment and doc
drivers/net/mana/mana.h line 84
Quoted 3 lines · On Fri, 1 Jul 2022 02:02:31 -0700 [email protected] wrote:
drivers/net/mana/mana.h new file +3
-0+uint64_t max_mr_size; +rte_rwlock_t mr_list_lock; +};Reader/Writer locks are slower for the usual uncontended case. Unless you have a reader holding onto the lock for a long time, better to use spin lock.
Quoted 4 lines
Quoted 2 lines
This is Linux wisdom (thank you paulmck), Windows seems to love reader/writer locks.
This lock is used mostly uncontended for readers and allow them concurrently
to access the list. It's rare that a writer might want to access it.
Quoted 2 lines
But changing it to spinlock will prevent multiple readers from accessing the list
at the same time. In this use case, is it beneficial to use spinlocks?
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.re
searchgate.net%2Ffigure%2FCosts-of-Simple-Spinlock-and-Distributed-Reader- Writer-Spinlock-To-write-acquire- the_fig1_244490342&data=05%7C01%7Clongli%40microsoft.com%7C51cc 3d29340347b87b8508da5ddc06c0%7C72f988bf86f141af91ab2d7cd011db47%7 C1%7C0%7C637925496841806674%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC 4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C %7C%7C&sdata=bWePngCuLBWN%2FFasdYpTuuCJW6Y8kX6WVTInLYvd1E c%3D&reserved=0
Quoted 8 lines
Conclusion
Breakeven curves for the locking primitives were computed, and the breakeven between simple spinlock and distributed reader-writer spinlock supports the rule of thumb that states that simple spinlock should be used in cases where the update ratio f is greater than the reciprocal of the number of CPUs, 1/nm.
Thank you for the pointer!
I think this driver should use spinlocks. I'm sending v2 with this change.
Long