From: Xueming Li Date: Thu, 21 Oct 2021 10:41:36 +0000 (+0800) Subject: ethdev: introduce shared Rx queue X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=dd22740cc291568f354279f5c38eef4a1d1dd3a0;hp=17faaed85449b58b209150906d2ad2cbfd853150;p=dpdk.git ethdev: introduce shared Rx queue In current DPDK framework, each Rx queue is pre-loaded with mbufs to save incoming packets. For some PMDs, when number of representors scale out in a switch domain, the memory consumption became significant. Polling all ports also leads to high cache miss, high latency and low throughput. This patch introduces shared Rx queue. Ports in same Rx domain and switch domain could share Rx queue set by specifying non-zero sharing group in Rx queue configuration. Shared Rx queue is identified by share_rxq field of Rx queue configuration. Port A RxQ X can share RxQ with Port B RxQ Y by using same shared Rx queue ID. No special API is defined to receive packets from shared Rx queue. Polling any member port of a shared Rx queue receives packets of that queue for all member ports, port_id is identified by mbuf->port. PMD is responsible to resolve shared Rx queue from device and queue data. Shared Rx queue must be polled in same thread or core, polling a queue ID of any member port is essentially same. Multiple share groups are supported. PMD should support mixed configuration by allowing multiple share groups and non-shared Rx queue on one port. Example grouping and polling model to reflect service priority: Group1, 2 shared Rx queues per port: PF, rep0, rep1 Group2, 1 shared Rx queue per port: rep2, rep3, ... rep127 Core0: poll PF queue0 Core1: poll PF queue1 Core2: poll rep2 queue0 PMD advertise shared Rx queue capability via RTE_ETH_DEV_CAPA_RXQ_SHARE. PMD is responsible for shared Rx queue consistency checks to avoid member port's configuration contradict each other. Signed-off-by: Xueming Li Reviewed-by: Andrew Rybchenko Acked-by: Ajit Khaparde --- diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst index 8dd421ca01..d35751d5b5 100644 --- a/doc/guides/nics/features.rst +++ b/doc/guides/nics/features.rst @@ -614,6 +614,19 @@ Supports inner packet L4 checksum. ``tx_offload_capa,tx_queue_offload_capa:DEV_TX_OFFLOAD_OUTER_UDP_CKSUM``. +.. _nic_features_shared_rx_queue: + +Shared Rx queue +--------------- + +Supports shared Rx queue for ports in same Rx domain of a switch domain. + +* **[uses] rte_eth_dev_info**: ``dev_capa:RTE_ETH_DEV_CAPA_RXQ_SHARE``. +* **[uses] rte_eth_dev_info,rte_eth_switch_info**: ``rx_domain``, ``domain_id``. +* **[uses] rte_eth_rxconf**: ``share_group``, ``share_qid``. +* **[provides] mbuf**: ``mbuf.port``. + + .. _nic_features_packet_type_parsing: Packet type parsing diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini index 8e6a28c419..082c7e85db 100644 --- a/doc/guides/nics/features/default.ini +++ b/doc/guides/nics/features/default.ini @@ -19,6 +19,7 @@ Free Tx mbuf on demand = Queue start/stop = Runtime Rx queue setup = Runtime Tx queue setup = +Shared Rx queue = Burst mode info = Power mgmt address monitor = MTU update = diff --git a/doc/guides/prog_guide/switch_representation.rst b/doc/guides/prog_guide/switch_representation.rst index ff6aa91c80..4f2532a91e 100644 --- a/doc/guides/prog_guide/switch_representation.rst +++ b/doc/guides/prog_guide/switch_representation.rst @@ -123,6 +123,17 @@ thought as a software "patch panel" front-end for applications. .. [1] `Ethernet switch device driver model (switchdev) `_ +- For some PMDs, memory usage of representors is huge when number of + representor grows, mbufs are allocated for each descriptor of Rx queue. + Polling large number of ports brings more CPU load, cache miss and + latency. Shared Rx queue can be used to share Rx queue between PF and + representors among same Rx domain. ``RTE_ETH_DEV_CAPA_RXQ_SHARE`` in + device info is used to indicate the capability. Setting non-zero share + group in Rx queue configuration to enable share, share_qid is used to + identify the shared Rx queue in group. Polling any member port can + receive packets of all member ports in the group, port ID is saved in + ``mbuf.port``. + Basic SR-IOV ------------ diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index f77afc1400..26ecd6decc 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -120,6 +120,12 @@ New Features A new API, ``rte_flow_pick_transfer_proxy()``, was added. +* **Added ethdev shared Rx queue support.** + + * Added new device capability flag and Rx domain field to switch info. + * Added share group and share queue ID to Rx queue configuration. + * Added testpmd support and dedicate forwarding engine. + * **Updated af_packet ethdev driver.** * Default VLAN strip behavior was changed. VLAN tag won't be stripped diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index e04e574d43..3939c344e8 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -2175,6 +2175,14 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, return -EINVAL; } + if (local_conf.share_group > 0 && + (dev_info.dev_capa & RTE_ETH_DEV_CAPA_RXQ_SHARE) == 0) { + RTE_ETHDEV_LOG(ERR, + "Ethdev port_id=%d rx_queue_id=%d, enabled share_group=%hu while device doesn't support Rx queue share\n", + port_id, rx_queue_id, local_conf.share_group); + return -EINVAL; + } + /* * If LRO is enabled, check that the maximum aggregated packet * size is supported by the configured device. diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index f8fd302d6e..8c1b5e01d2 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -1046,6 +1046,14 @@ struct rte_eth_rxconf { uint8_t rx_drop_en; /**< Drop packets if no descriptors are available. */ uint8_t rx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */ uint16_t rx_nseg; /**< Number of descriptions in rx_seg array. */ + /** + * Share group index in Rx domain and switch domain. + * Non-zero value to enable Rx queue share, zero value disable share. + * PMD is responsible for Rx queue consistency checks to avoid member + * port's configuration contradict to each other. + */ + uint16_t share_group; + uint16_t share_qid; /**< Shared Rx queue ID in group */ /** * Per-queue Rx offloads to be set using DEV_RX_OFFLOAD_* flags. * Only offloads set on rx_queue_offload_capa or rx_offload_capa @@ -1448,6 +1456,16 @@ struct rte_eth_conf { #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP 0x00000001 /** Device supports Tx queue setup after device started. */ #define RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP 0x00000002 +/** + * Device supports shared Rx queue among ports within Rx domain and + * switch domain. Mbufs are consumed by shared Rx queue instead of + * each queue. Multiple groups are supported by share_group of Rx + * queue configuration. Shared Rx queue is identified by PMD using + * share_qid of Rx queue configuration. Polling any port in the group + * receive packets of all member ports, source port identified by + * mbuf->port field. + */ +#define RTE_ETH_DEV_CAPA_RXQ_SHARE RTE_BIT64(2) /**@}*/ /* @@ -1491,6 +1509,12 @@ struct rte_eth_switch_info { * port identifier to that physical interconnect/switch */ uint16_t port_id; + /** + * Shared Rx queue sub-domain boundary. Only ports in same Rx domain + * and switch domain can share Rx queue. Valid only if device advertised + * RTE_ETH_DEV_CAPA_RXQ_SHARE capability. + */ + uint16_t rx_domain; }; /**