From patchwork Mon Oct 12 20:09:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 80401 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 19D96A04B6; Mon, 12 Oct 2020 22:10:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CF3021D9CC; Mon, 12 Oct 2020 22:10:22 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 78D3F1D9CB for ; Mon, 12 Oct 2020 22:10:20 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@nvidia.com) with SMTP; 12 Oct 2020 23:10:15 +0300 Received: from nvidia.com (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09CKADf9013670; Mon, 12 Oct 2020 23:10:15 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: thomasm@monjalon.net, stephen@networkplumber.org, ferruh.yigit@intel.com, olivier.matz@6wind.com, jerinjacobk@gmail.com, maxime.coquelin@redhat.com, david.marchand@redhat.com, arybchenko@solarflare.com Date: Mon, 12 Oct 2020 20:09:54 +0000 Message-Id: <1602533402-14795-2-git-send-email-viacheslavo@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> References: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> Subject: [dpdk-dev] [PATCH v4 1/9] ethdev: introduce Rx buffer split X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc. In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received. The following structure is introduced to specify the Rx packet segment: struct rte_eth_rxseg { struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length, configures "split point" */ uint16_t offset; /* data offset from beginning of mbuf data buffer */ uint32_t reserved; /* reserved field */ }; The new routine rte_eth_rxseg_queue_setup_ex() is introduced to setup the given Rx queue using the new extended Rx packet segment description: int rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id, uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, const struct rte_eth_rxseg *rx_seg, uint16_t n_seg) This routine presents the two new parameters: rx_seg - pointer the array of segment descriptions, each element describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf. This array allows to specify the different settings for each segment in individual fashion. n_seg - number of elements in the array The new offload flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup_ex() routine application should check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag. If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will split the received packets into multiple segments according to the specification in the description array: - the first network buffer will be allocated from the memory pool, specified in the first segment description element, the second network buffer - from the pool in the second segment description element and so on. If there is no enough elements to describe the buffer for entire packet of maximal length the pool from the last valid element will be used to allocate the buffers from for the rest of segments - the offsets from the segment description elements will provide the data offset from the buffer beginning except the first mbuf - for this one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual offset from the buffer beginning. If there is no enough elements to describe the buffer for entire packet of maximal length the offsets for the rest of segment will be supposed to be zero. - the data length being received to each segment is limited by the length specified in the segment description element. The data receiving starts with filling up the first mbuf data buffer, if the specified maximal segment length is reached and there are data remaining (packet is longer than buffer in the first mbuf) the following data will be pushed to the next segment up to its own maximal length. If the first two segments is not enough to store all the packet remaining data the next (third) segment will be engaged and so on. If the length in the segment description element is zero the actual buffer size will be deduced from the appropriate memory pool properties. If there is no enough elements to describe the buffer for entire packet of maximal length the buffer size will be deduced from the pool of the last valid element for the remaining segments. For example, let's suppose we configured the Rx queue with the following segments: seg0 - pool0, len0=14B, off0=2 seg1 - pool1, len1=20B, off1=128B seg2 - pool2, len2=20B, off2=0B seg3 - pool3, len3=512B, off3=0B The packet 46 bytes long will look like the following: seg0 - 14B long @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B long @ 128 in mbuf from pool1 seg2 - 12B long @ 0 in mbuf from pool2 The packet 1500 bytes long will look like the following: seg0 - 14B @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B @ 128 in mbuf from pool1 seg2 - 20B @ 0 in mbuf from pool2 seg3 - 512B @ 0 in mbuf from pool3 seg4 - 512B @ 0 in mbuf from pool3 seg5 - 422B @ 0 in mbuf from pool3 The offload RTE_ETH_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one). The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API. Signed-off-by: Viacheslav Ovsiienko --- doc/guides/nics/features.rst | 15 ++++ doc/guides/rel_notes/release_20_11.rst | 6 ++ lib/librte_ethdev/ethdev_trace_points.c | 3 + lib/librte_ethdev/rte_ethdev.c | 133 ++++++++++++++++++++++++------- lib/librte_ethdev/rte_ethdev.h | 107 +++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 10 +++ lib/librte_ethdev/rte_ethdev_trace.h | 19 +++++ lib/librte_ethdev/rte_ethdev_version.map | 3 + 8 files changed, 268 insertions(+), 28 deletions(-) diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst index dd8c955..21b91db 100644 --- a/doc/guides/nics/features.rst +++ b/doc/guides/nics/features.rst @@ -185,6 +185,21 @@ Supports receiving segmented mbufs. * **[related] eth_dev_ops**: ``rx_pkt_burst``. +.. _nic_features_buffer_split: + +Buffer Split on Rx +------------ + +Scatters the packets being received on specified boundaries to segmented mbufs. + +* **[uses] rte_eth_rxconf,rte_eth_rxmode**: ``offloads:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``. +* **[implements] datapath**: ``Buffer Split functionality``. +* **[implements] rte_eth_dev_data**: ``buffer_split``. +* **[provides] rte_eth_dev_info**: ``rx_offload_capa:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``. +* **[provides] eth_dev_ops**: ``rxq_info_get:buffer_split``. +* **[related] API**: ``rte_eth_rxseg_queue_setup()``. + + .. _nic_features_lro: LRO diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst index bcc0fc2..06a35c1 100644 --- a/doc/guides/rel_notes/release_20_11.rst +++ b/doc/guides/rel_notes/release_20_11.rst @@ -60,6 +60,12 @@ New Features Added the FEC API which provides functions for query FEC capabilities and current FEC mode from device. Also, API for configuring FEC mode is also provided. +* **Introduced extended buffer description for receiving.** + + Added the extended Rx queue setup routine providing the individual + descriptions for each Rx segment with maximal size, buffer offset and memory + pool to allocate data buffers from. + * **Updated Broadcom bnxt driver.** Updated the Broadcom bnxt driver with new features and improvements, including: diff --git a/lib/librte_ethdev/ethdev_trace_points.c b/lib/librte_ethdev/ethdev_trace_points.c index 2919409..0ec8fc4 100644 --- a/lib/librte_ethdev/ethdev_trace_points.c +++ b/lib/librte_ethdev/ethdev_trace_points.c @@ -12,6 +12,9 @@ RTE_TRACE_POINT_REGISTER(rte_ethdev_trace_rxq_setup, lib.ethdev.rxq.setup) +RTE_TRACE_POINT_REGISTER(rte_ethdev_trace_rxq_seg_setup, + lib.ethdev.rxq.setup) + RTE_TRACE_POINT_REGISTER(rte_ethdev_trace_txq_setup, lib.ethdev.txq.setup) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 892c246..579acf9 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -105,6 +105,9 @@ struct rte_eth_xstats_name_off { #define RTE_RX_OFFLOAD_BIT2STR(_name) \ { DEV_RX_OFFLOAD_##_name, #_name } +#define RTE_ETH_RX_OFFLOAD_BIT2STR(_name) \ + { RTE_ETH_RX_OFFLOAD_##_name, #_name } + static const struct { uint64_t offload; const char *name; @@ -128,9 +131,11 @@ struct rte_eth_xstats_name_off { RTE_RX_OFFLOAD_BIT2STR(SCTP_CKSUM), RTE_RX_OFFLOAD_BIT2STR(OUTER_UDP_CKSUM), RTE_RX_OFFLOAD_BIT2STR(RSS_HASH), + RTE_ETH_RX_OFFLOAD_BIT2STR(BUFFER_SPLIT), }; #undef RTE_RX_OFFLOAD_BIT2STR +#undef RTE_ETH_RX_OFFLOAD_BIT2STR #define RTE_TX_OFFLOAD_BIT2STR(_name) \ { DEV_TX_OFFLOAD_##_name, #_name } @@ -1763,13 +1768,14 @@ struct rte_eth_dev * return ret; } -int -rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, - uint16_t nb_rx_desc, unsigned int socket_id, - const struct rte_eth_rxconf *rx_conf, - struct rte_mempool *mp) +static int +__rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, + uint16_t nb_rx_desc, unsigned int socket_id, + const struct rte_eth_rxconf *rx_conf, + const struct rte_eth_rxseg *rx_seg, uint16_t n_seg) { - int ret; + int ret, ext; + uint16_t seg_idx; uint32_t mbp_buf_size; struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; @@ -1784,12 +1790,23 @@ struct rte_eth_dev * return -EINVAL; } - if (mp == NULL) { - RTE_ETHDEV_LOG(ERR, "Invalid null mempool pointer\n"); + if (rx_seg == NULL) { + RTE_ETHDEV_LOG(ERR, "Invalid null description pointer\n"); + return -EINVAL; + } + + if (n_seg == 0) { + RTE_ETHDEV_LOG(ERR, "Invalid zero description number\n"); return -EINVAL; } - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP); + ext = rx_seg[0].length || rx_seg[0].offset || n_seg > 1; + if (ext) + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rxseg_queue_setup, + -ENOTSUP); + else + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, + -ENOTSUP); /* * Check the size of the mbuf data buffer. @@ -1800,22 +1817,48 @@ struct rte_eth_dev * if (ret != 0) return ret; - if (mp->private_data_size < sizeof(struct rte_pktmbuf_pool_private)) { - RTE_ETHDEV_LOG(ERR, "%s private_data_size %d < %d\n", - mp->name, (int)mp->private_data_size, - (int)sizeof(struct rte_pktmbuf_pool_private)); - return -ENOSPC; - } - mbp_buf_size = rte_pktmbuf_data_room_size(mp); + for (seg_idx = 0; seg_idx < n_seg; seg_idx++) { + struct rte_mempool *mp = rx_seg[seg_idx].mp; + uint32_t length = rx_seg[seg_idx].length; + uint32_t offset = rx_seg[seg_idx].offset; + uint32_t head_room = seg_idx ? 0 : RTE_PKTMBUF_HEADROOM; - 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, - (int)(RTE_PKTMBUF_HEADROOM + dev_info.min_rx_bufsize), - (int)RTE_PKTMBUF_HEADROOM, - (int)dev_info.min_rx_bufsize); - return -EINVAL; + if (mp == NULL) { + RTE_ETHDEV_LOG(ERR, "Invalid null mempool pointer\n"); + return -EINVAL; + } + + if (mp->private_data_size < + sizeof(struct rte_pktmbuf_pool_private)) { + RTE_ETHDEV_LOG(ERR, "%s private_data_size %d < %d\n", + mp->name, (int)mp->private_data_size, + (int)sizeof(struct rte_pktmbuf_pool_private)); + return -ENOSPC; + } + + mbp_buf_size = rte_pktmbuf_data_room_size(mp); + length = length ? length : (mbp_buf_size - head_room); + if (mbp_buf_size < length + offset + head_room) { + RTE_ETHDEV_LOG(ERR, + "%s mbuf_data_room_size %u < %u" + " (segment length=%u + segment offset=%u)\n", + mp->name, mbp_buf_size, + length + offset, length, offset); + return -EINVAL; + } + if (!ext && (mbp_buf_size < dev_info.min_rx_bufsize + + RTE_PKTMBUF_HEADROOM)) { + RTE_ETHDEV_LOG(ERR, + "%s mbuf_data_room_size %u < %u " + "(RTE_PKTMBUF_HEADROOM=%u + " + "min_rx_bufsize(dev)=%u)\n", + mp->name, mbp_buf_size, + (RTE_PKTMBUF_HEADROOM + + dev_info.min_rx_bufsize), + RTE_PKTMBUF_HEADROOM, + dev_info.min_rx_bufsize); + return -EINVAL; + } } /* Use default specified by driver, if nb_rx_desc is zero */ @@ -1906,20 +1949,54 @@ struct rte_eth_dev * return ret; } - ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc, - socket_id, &local_conf, mp); + ret = ext ? + (*dev->dev_ops->rxseg_queue_setup)(dev, rx_queue_id, nb_rx_desc, + socket_id, &local_conf, + rx_seg, n_seg) : + (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc, + socket_id, &local_conf, + rx_seg[0].mp); if (!ret) { if (!dev->data->min_rx_buf_size || dev->data->min_rx_buf_size > mbp_buf_size) dev->data->min_rx_buf_size = mbp_buf_size; } - rte_ethdev_trace_rxq_setup(port_id, rx_queue_id, nb_rx_desc, mp, - rx_conf, ret); return eth_err(port_id, ret); } int +rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, + uint16_t nb_rx_desc, unsigned int socket_id, + const struct rte_eth_rxconf *rx_conf, + struct rte_mempool *mp) +{ + struct rte_eth_rxseg rx_seg = {.mp = mp}; + int ret; + + ret = __rte_eth_rx_queue_setup(port_id, rx_queue_id, nb_rx_desc, + socket_id, rx_conf, &rx_seg, 1); + rte_ethdev_trace_rxq_setup(port_id, rx_queue_id, nb_rx_desc, + mp, rx_conf, ret); + return ret; +} + +int +rte_eth_rxseg_queue_setup(uint16_t port_id, uint16_t rx_queue_id, + uint16_t nb_rx_desc, unsigned int socket_id, + const struct rte_eth_rxconf *rx_conf, + const struct rte_eth_rxseg *rx_seg, uint16_t n_seg) +{ + int ret; + + ret = __rte_eth_rx_queue_setup(port_id, rx_queue_id, nb_rx_desc, + socket_id, rx_conf, rx_seg, n_seg); + rte_ethdev_trace_rxq_seg_setup(port_id, rx_queue_id, nb_rx_desc, + rx_conf, rx_seg, n_seg, ret); + return ret; +} + +int rte_eth_rx_hairpin_queue_setup(uint16_t port_id, uint16_t rx_queue_id, uint16_t nb_rx_desc, const struct rte_eth_hairpin_conf *conf) diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 5bcfbb8..2596f6e 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -970,6 +970,16 @@ struct rte_eth_txmode { }; /** + * A structure used to configure an RX packet segment to split. + */ +struct rte_eth_rxseg { + struct rte_mempool *mp; /**< Memory pools to allocate segment from */ + uint16_t length; /**< Segment data length, configures split point. */ + uint16_t offset; /**< Data offset from beginning of mbuf data buffer */ + uint32_t reserved; /**< Reserved field */ +}; + +/** * A structure used to configure an RX ring of an Ethernet port. */ struct rte_eth_rxconf { @@ -1260,6 +1270,7 @@ struct rte_eth_conf { #define DEV_RX_OFFLOAD_SCTP_CKSUM 0x00020000 #define DEV_RX_OFFLOAD_OUTER_UDP_CKSUM 0x00040000 #define DEV_RX_OFFLOAD_RSS_HASH 0x00080000 +#define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT 0x00100000 #define DEV_RX_OFFLOAD_CHECKSUM (DEV_RX_OFFLOAD_IPV4_CKSUM | \ DEV_RX_OFFLOAD_UDP_CKSUM | \ @@ -2044,6 +2055,102 @@ int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, struct rte_mempool *mb_pool); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Allocate and set up a receive queue for an Ethernet device + * with specifying receiving segments parameters. + * + * The function allocates a contiguous block of memory for *nb_rx_desc* + * receive descriptors from a memory zone associated with *socket_id*. + * The descriptors might be divided into groups by PMD to receive the data + * into multi-segment packet presented by the chain of mbufs. + * + * Each descriptor within the group is initialized accordingly with + * the network buffers allocated from the specified memory pool and with + * specified buffer offset and maximal segment length. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param rx_queue_id + * The index of the receive queue to set up. + * The value must be in the range [0, nb_rx_queue - 1] previously supplied + * to rte_eth_dev_configure(). + * @param nb_rx_desc + * The number of receive descriptors to allocate for the receive ring. + * @param socket_id + * The *socket_id* argument is the socket identifier in case of NUMA. + * The value can be *SOCKET_ID_ANY* if there is no NUMA constraint for + * the DMA memory allocated for the receive descriptors of the ring. + * @param rx_conf + * The pointer to the configuration data to be used for the receive queue. + * NULL value is allowed, in which case default RX configuration + * will be used. + * The *rx_conf* structure contains an *rx_thresh* structure with the values + * of the Prefetch, Host, and Write-Back threshold registers of the receive + * ring. + * In addition it contains the hardware offloads features to activate using + * the DEV_RX_OFFLOAD_* flags. + * If an offloading set in rx_conf->offloads + * hasn't been set in the input argument eth_conf->rxmode.offloads + * to rte_eth_dev_configure(), it is a new added offloading, it must be + * per-queue type and it is enabled for the queue. + * No need to repeat any bit in rx_conf->offloads which has already been + * enabled in rte_eth_dev_configure() at port level. An offloading enabled + * at port level can't be disabled at queue level. + * @param rx_seg + * The pointer to the array of segment descriptions, each element describes + * the memory pool, maximal segment data length, initial data offset from + * the beginning of data buffer in mbuf. This allow to specify the dedicated + * properties for each segment in the receiving buffer - pool, buffer + * offset, maximal segment size. If RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload + * flag is configured the PMD will split the received packets into multiple + * segments according to the specification in the description array: + * - the first network buffer will be allocated from the memory pool, + * specified in the first segment description element, the second + * network buffer - from the pool in the second segment description + * element and so on. If there is no enough elements to describe + * the buffer for entire packet of maximal length the pool from the last + * valid element will be used to allocate the buffers from for the rest + * of segments. + * - the offsets from the segment description elements will provide the + * data offset from the buffer beginning except the first mbuf - for this + * one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual + * offset from the buffer beginning. If there is no enough elements + * to describe the buffer for entire packet of maximal length the offsets + * for the rest of segment will be supposed to be zero. + * - the data length being received to each segment is limited by the + * length specified in the segment description element. The data receiving + * starts with filling up the first mbuf data buffer, if the specified + * maximal segment length is reached and there are data remaining + * (packet is longer than buffer in the first mbuf) the following data + * will be pushed to the next segment up to its own length. If the first + * two segments is not enough to store all the packet data the next + * (third) segment will be engaged and so on. If the length in the segment + * description element is zero the actual buffer size will be deduced + * from the appropriate memory pool properties. If there is no enough + * elements to describe the buffer for entire packet of maximal length + * the buffer size will be deduced from the pool of the last valid + * element for the all remaining segments. + * @param n_seg + * The number of elements in the segment description array. + * @return + * - 0: Success, receive queue correctly set up. + * - -EIO: if device is removed. + * - -EINVAL: The segment descriptors array is empty (pointer to is null or + * zero number of elements) or the size of network buffers which can be + * allocated from this memory pool does not fit the various buffer sizes + * allowed by the device controller. + * - -ENOMEM: Unable to allocate the receive ring descriptors or to + * allocate network memory buffers from the memory pool when + * initializing receive descriptors. + */ +__rte_experimental +int rte_eth_rxseg_queue_setup(uint16_t port_id, uint16_t rx_queue_id, + uint16_t nb_rx_desc, unsigned int socket_id, + const struct rte_eth_rxconf *rx_conf, + const struct rte_eth_rxseg *rx_seg, uint16_t n_seg); /** * @warning diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h index 35cc4fb..5dee210 100644 --- a/lib/librte_ethdev/rte_ethdev_driver.h +++ b/lib/librte_ethdev/rte_ethdev_driver.h @@ -264,6 +264,15 @@ typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev, struct rte_mempool *mb_pool); /**< @internal Set up a receive queue of an Ethernet device. */ +typedef int (*eth_rxseg_queue_setup_t)(struct rte_eth_dev *dev, + uint16_t rx_queue_id, + uint16_t nb_rx_desc, + unsigned int socket_id, + const struct rte_eth_rxconf *rx_conf, + const struct rte_eth_rxseg *rx_seg, + uint16_t n_seg); +/**< @internal extended Set up a receive queue of an Ethernet device. */ + typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev, uint16_t tx_queue_id, uint16_t nb_tx_desc, @@ -711,6 +720,7 @@ struct eth_dev_ops { eth_queue_start_t tx_queue_start;/**< Start TX for a queue. */ eth_queue_stop_t tx_queue_stop; /**< Stop TX for a queue. */ eth_rx_queue_setup_t rx_queue_setup;/**< Set up device RX queue. */ + eth_rxseg_queue_setup_t rxseg_queue_setup;/**< Extended RX setup. */ eth_queue_release_t rx_queue_release; /**< Release RX queue. */ eth_rx_enable_intr_t rx_queue_intr_enable; /**< Enable Rx queue interrupt. */ diff --git a/lib/librte_ethdev/rte_ethdev_trace.h b/lib/librte_ethdev/rte_ethdev_trace.h index 16f5bf2..7341ae9 100644 --- a/lib/librte_ethdev/rte_ethdev_trace.h +++ b/lib/librte_ethdev/rte_ethdev_trace.h @@ -55,6 +55,25 @@ ) RTE_TRACE_POINT( + rte_ethdev_trace_rxq_seg_setup, + RTE_TRACE_POINT_ARGS(uint16_t port_id, uint16_t rx_queue_id, + uint16_t nb_rx_desc, const struct rte_eth_rxconf *rx_conf, + const struct rte_eth_rxseg *rx_seg, uint16_t n_seg, int rc), + rte_trace_point_emit_u16(port_id); + rte_trace_point_emit_u16(rx_queue_id); + rte_trace_point_emit_u16(nb_rx_desc); + rte_trace_point_emit_u8(rx_conf->rx_thresh.pthresh); + rte_trace_point_emit_u8(rx_conf->rx_thresh.hthresh); + rte_trace_point_emit_u8(rx_conf->rx_thresh.wthresh); + rte_trace_point_emit_u8(rx_conf->rx_drop_en); + rte_trace_point_emit_u8(rx_conf->rx_deferred_start); + rte_trace_point_emit_u64(rx_conf->offloads); + rte_trace_point_emit_ptr(rx_seg); + rte_trace_point_emit_u16(n_seg); + rte_trace_point_emit_int(rc); +) + +RTE_TRACE_POINT( rte_ethdev_trace_txq_setup, RTE_TRACE_POINT_ARGS(uint16_t port_id, uint16_t tx_queue_id, uint16_t nb_tx_desc, const struct rte_eth_txconf *tx_conf), diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index f8a0945..848438b 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -195,6 +195,7 @@ EXPERIMENTAL { rte_flow_get_aged_flows; # Marked as experimental in 20.11 + rte_eth_rxseg_queue_setup; rte_tm_capabilities_get; rte_tm_get_number_of_leaf_nodes; rte_tm_hierarchy_commit; @@ -232,6 +233,8 @@ EXPERIMENTAL { rte_eth_fec_get_capability; rte_eth_fec_get; rte_eth_fec_set; + __rte_ethdev_trace_rxq_seg_setup; + }; INTERNAL { From patchwork Mon Oct 12 20:09:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 80402 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 079FAA04B6; Mon, 12 Oct 2020 22:11:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8557D1D9D3; Mon, 12 Oct 2020 22:10:24 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 9B1231D9CC for ; Mon, 12 Oct 2020 22:10:21 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@nvidia.com) with SMTP; 12 Oct 2020 23:10:17 +0300 Received: from nvidia.com (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09CKADfA013670; Mon, 12 Oct 2020 23:10:17 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: thomasm@monjalon.net, stephen@networkplumber.org, ferruh.yigit@intel.com, olivier.matz@6wind.com, jerinjacobk@gmail.com, maxime.coquelin@redhat.com, david.marchand@redhat.com, arybchenko@solarflare.com Date: Mon, 12 Oct 2020 20:09:55 +0000 Message-Id: <1602533402-14795-3-git-send-email-viacheslavo@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> References: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> Subject: [dpdk-dev] [PATCH v4 2/9] app/testpmd: add multiple pools per core creation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The command line parameter --mbuf-size is updated, it can handle the multiple values like the following: --mbuf-size=2176,512,768,4096 specifying the creation the extra memory pools with the requested mbuf data buffer sizes. If some buffer split feature is engaged the extra memory pools can be used to configure the Rx queues with rte_the_dev_rx_queue_setup_ex(). The extra pools are created with requested sizes, and pool names are assigned with appended index: mbuf_pool_socket_%socket_%index. Index zero is used to specify the first mandatory pool to maintain compatibility with existing code. Signed-off-by: Viacheslav Ovsiienko --- app/test-pmd/bpf_cmd.c | 4 +-- app/test-pmd/cmdline.c | 2 +- app/test-pmd/config.c | 6 ++-- app/test-pmd/parameters.c | 24 +++++++++---- app/test-pmd/testpmd.c | 63 +++++++++++++++++++---------------- app/test-pmd/testpmd.h | 24 ++++++++++--- doc/guides/testpmd_app_ug/run_app.rst | 7 ++-- 7 files changed, 83 insertions(+), 47 deletions(-) diff --git a/app/test-pmd/bpf_cmd.c b/app/test-pmd/bpf_cmd.c index 16e3c3b..0a1a178 100644 --- a/app/test-pmd/bpf_cmd.c +++ b/app/test-pmd/bpf_cmd.c @@ -69,7 +69,7 @@ struct cmd_bpf_ld_result { *flags = RTE_BPF_ETH_F_NONE; arg->type = RTE_BPF_ARG_PTR; - arg->size = mbuf_data_size; + arg->size = mbuf_data_size[0]; for (i = 0; str[i] != 0; i++) { v = toupper(str[i]); @@ -78,7 +78,7 @@ struct cmd_bpf_ld_result { else if (v == 'M') { arg->type = RTE_BPF_ARG_PTR_MBUF; arg->size = sizeof(struct rte_mbuf); - arg->buf_size = mbuf_data_size; + arg->buf_size = mbuf_data_size[0]; } else if (v == '-') continue; else diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 273fb1a..a585cf0 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2907,7 +2907,7 @@ struct cmd_setup_rxtx_queue { if (!numa_support || socket_id == NUMA_NO_CONFIG) socket_id = port->socket_id; - mp = mbuf_pool_find(socket_id); + mp = mbuf_pool_find(socket_id, 0); if (mp == NULL) { printf("Failed to setup RX queue: " "No mempool allocation" diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index d4be694..5f501f6 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -690,7 +690,7 @@ static int bus_match_all(const struct rte_bus *bus, const void *data) printf("\nConnect to socket: %u", port->socket_id); if (port_numa[port_id] != NUMA_NO_CONFIG) { - mp = mbuf_pool_find(port_numa[port_id]); + mp = mbuf_pool_find(port_numa[port_id], 0); if (mp) printf("\nmemory allocation on the socket: %d", port_numa[port_id]); @@ -3352,9 +3352,9 @@ struct igb_ring_desc_16_bytes { */ tx_pkt_len = 0; for (i = 0; i < nb_segs; i++) { - if (seg_lengths[i] > (unsigned) mbuf_data_size) { + if (seg_lengths[i] > mbuf_data_size[0]) { printf("length[%u]=%u > mbuf_data_size=%u - give up\n", - i, seg_lengths[i], (unsigned) mbuf_data_size); + i, seg_lengths[i], mbuf_data_size[0]); return; } tx_pkt_len = (uint16_t)(tx_pkt_len + seg_lengths[i]); diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 15ce8c1..4db4987 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -106,7 +106,9 @@ "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n"); printf(" --socket-num=N: set socket from which all memory is allocated " "in NUMA mode.\n"); - printf(" --mbuf-size=N: set the data size of mbuf to N bytes.\n"); + printf(" --mbuf-size=N,[N1[,..Nn]: set the data size of mbuf to " + "N bytes. If multiple numbers are specified the extra pools " + "will be created to receive with packet split features\n"); printf(" --total-num-mbufs=N: set the number of mbufs to be allocated " "in mbuf pools.\n"); printf(" --max-pkt-len=N: set the maximum size of packet to N bytes.\n"); @@ -892,12 +894,22 @@ } } if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) { - n = atoi(optarg); - if (n > 0 && n <= 0xFFFF) - mbuf_data_size = (uint16_t) n; - else + unsigned int mb_sz[MAX_SEGS_BUFFER_SPLIT]; + unsigned int nb_segs, i; + + nb_segs = parse_item_list(optarg, "mbuf-size", + MAX_SEGS_BUFFER_SPLIT, mb_sz, 0); + if (nb_segs <= 0) rte_exit(EXIT_FAILURE, - "mbuf-size should be > 0 and < 65536\n"); + "bad mbuf-size\n"); + for (i = 0; i < nb_segs; i++) { + if (mb_sz[i] <= 0 || mb_sz[i] > 0xFFFF) + rte_exit(EXIT_FAILURE, + "mbuf-size should be " + "> 0 and < 65536\n"); + mbuf_data_size[i] = (uint16_t) mb_sz[i]; + } + mbuf_data_size_n = nb_segs; } if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) { n = atoi(optarg); diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index ccba71c..7e6ef80 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -186,7 +186,7 @@ struct fwd_engine * fwd_engines[] = { NULL, }; -struct rte_mempool *mempools[RTE_MAX_NUMA_NODES]; +struct rte_mempool *mempools[RTE_MAX_NUMA_NODES * MAX_SEGS_BUFFER_SPLIT]; uint16_t mempool_flags; struct fwd_config cur_fwd_config; @@ -195,7 +195,10 @@ struct fwd_engine * fwd_engines[] = { uint32_t burst_tx_delay_time = BURST_TX_WAIT_US; uint32_t burst_tx_retry_num = BURST_TX_RETRIES; -uint16_t mbuf_data_size = DEFAULT_MBUF_DATA_SIZE; /**< Mbuf data space size. */ +uint32_t mbuf_data_size_n = 1; /* Number of specified mbuf sizes. */ +uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT] = { + DEFAULT_MBUF_DATA_SIZE +}; /**< Mbuf data space size. */ uint32_t param_total_num_mbufs = 0; /**< number of mbufs in all pools - if * specified on command-line. */ uint16_t stats_period; /**< Period to show statistics (disabled by default) */ @@ -955,14 +958,14 @@ struct extmem_param { */ static struct rte_mempool * mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, - unsigned int socket_id) + unsigned int socket_id, unsigned int size_idx) { char pool_name[RTE_MEMPOOL_NAMESIZE]; struct rte_mempool *rte_mp = NULL; uint32_t mb_size; mb_size = sizeof(struct rte_mbuf) + mbuf_seg_size; - mbuf_poolname_build(socket_id, pool_name, sizeof(pool_name)); + mbuf_poolname_build(socket_id, pool_name, sizeof(pool_name), size_idx); TESTPMD_LOG(INFO, "create a new mbuf pool <%s>: n=%u, size=%u, socket=%u\n", @@ -1485,8 +1488,8 @@ struct extmem_param { port->dev_info.rx_desc_lim.nb_mtu_seg_max; if ((data_size + RTE_PKTMBUF_HEADROOM) > - mbuf_data_size) { - mbuf_data_size = data_size + + mbuf_data_size[0]) { + mbuf_data_size[0] = data_size + RTE_PKTMBUF_HEADROOM; warning = 1; } @@ -1494,9 +1497,9 @@ struct extmem_param { } if (warning) - TESTPMD_LOG(WARNING, "Configured mbuf size %hu\n", - mbuf_data_size); - + TESTPMD_LOG(WARNING, + "Configured mbuf size of the first segment %hu\n", + mbuf_data_size[0]); /* * Create pools of mbuf. * If NUMA support is disabled, create a single pool of mbuf in @@ -1516,21 +1519,23 @@ struct extmem_param { } if (numa_support) { - uint8_t i; + uint8_t i, j; for (i = 0; i < num_sockets; i++) - mempools[i] = mbuf_pool_create(mbuf_data_size, - nb_mbuf_per_pool, - socket_ids[i]); + for (j = 0; j < mbuf_data_size_n; j++) + mempools[i * MAX_SEGS_BUFFER_SPLIT + j] = + mbuf_pool_create(mbuf_data_size[j], + nb_mbuf_per_pool, + socket_ids[i], j); } else { - if (socket_num == UMA_NO_CONFIG) - mempools[0] = mbuf_pool_create(mbuf_data_size, - nb_mbuf_per_pool, 0); - else - mempools[socket_num] = mbuf_pool_create - (mbuf_data_size, - nb_mbuf_per_pool, - socket_num); + uint8_t i; + + for (i = 0; i < mbuf_data_size_n; i++) + mempools[i] = mbuf_pool_create + (mbuf_data_size[i], + nb_mbuf_per_pool, + socket_num == UMA_NO_CONFIG ? + 0 : socket_num, i); } init_port_config(); @@ -1542,10 +1547,10 @@ struct extmem_param { */ for (lc_id = 0; lc_id < nb_lcores; lc_id++) { mbp = mbuf_pool_find( - rte_lcore_to_socket_id(fwd_lcores_cpuids[lc_id])); + rte_lcore_to_socket_id(fwd_lcores_cpuids[lc_id]), 0); if (mbp == NULL) - mbp = mbuf_pool_find(0); + mbp = mbuf_pool_find(0, 0); fwd_lcores[lc_id]->mbp = mbp; /* initialize GSO context */ fwd_lcores[lc_id]->gso_ctx.direct_pool = mbp; @@ -2498,7 +2503,8 @@ struct extmem_param { if ((numa_support) && (rxring_numa[pi] != NUMA_NO_CONFIG)) { struct rte_mempool * mp = - mbuf_pool_find(rxring_numa[pi]); + mbuf_pool_find + (rxring_numa[pi], 0); if (mp == NULL) { printf("Failed to setup RX queue:" "No mempool allocation" @@ -2514,7 +2520,8 @@ struct extmem_param { mp); } else { struct rte_mempool *mp = - mbuf_pool_find(port->socket_id); + mbuf_pool_find + (port->socket_id, 0); if (mp == NULL) { printf("Failed to setup RX queue:" "No mempool allocation" @@ -2909,13 +2916,13 @@ struct extmem_param { pmd_test_exit(void) { portid_t pt_id; + unsigned int i; int ret; - int i; if (test_done == 0) stop_packet_forwarding(); - for (i = 0 ; i < RTE_MAX_NUMA_NODES ; i++) { + for (i = 0 ; i < RTE_DIM(mempools) ; i++) { if (mempools[i]) { if (mp_alloc_type == MP_ALLOC_ANON) rte_mempool_mem_iter(mempools[i], dma_unmap_cb, @@ -2959,7 +2966,7 @@ struct extmem_param { return; } } - for (i = 0 ; i < RTE_MAX_NUMA_NODES ; i++) { + for (i = 0 ; i < RTE_DIM(mempools) ; i++) { if (mempools[i]) rte_mempool_free(mempools[i]); } diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 9a29d7a..b42d710 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -42,6 +42,13 @@ */ #define RTE_MAX_SEGS_PER_PKT 255 /**< nb_segs is a 8-bit unsigned char. */ +/* + * The maximum number of segments per packet is used to configure + * buffer split feature, also specifies the maximum amount of + * optional Rx pools to allocate mbufs to split. + */ +#define MAX_SEGS_BUFFER_SPLIT 8 /**< nb_segs is a 8-bit unsigned char. */ + #define MAX_PKT_BURST 512 #define DEF_PKT_BURST 32 @@ -393,7 +400,9 @@ struct queue_stats_mappings { extern uint8_t dcb_config; extern uint8_t dcb_test; -extern uint16_t mbuf_data_size; /**< Mbuf data space size. */ +extern uint32_t mbuf_data_size_n; +extern uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT]; +/**< Mbuf data space size. */ extern uint32_t param_total_num_mbufs; extern uint16_t stats_period; @@ -605,17 +614,22 @@ struct mplsoudp_decap_conf { /* Mbuf Pools */ static inline void -mbuf_poolname_build(unsigned int sock_id, char* mp_name, int name_size) +mbuf_poolname_build(unsigned int sock_id, char *mp_name, + int name_size, unsigned int idx) { - snprintf(mp_name, name_size, "mbuf_pool_socket_%u", sock_id); + if (!idx) + snprintf(mp_name, name_size, "mbuf_pool_socket_%u", sock_id); + else + snprintf(mp_name, name_size, "mbuf_pool_socket_%u_%u", + sock_id, idx); } static inline struct rte_mempool * -mbuf_pool_find(unsigned int sock_id) +mbuf_pool_find(unsigned int sock_id, unsigned int idx) { char pool_name[RTE_MEMPOOL_NAMESIZE]; - mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name)); + mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name), idx); return rte_mempool_lookup((const char *)pool_name); } diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index ec085c2..1eb0a10 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -107,9 +107,12 @@ The command line options are: Set the socket from which all memory is allocated in NUMA mode, where 0 <= N < number of sockets on the board. -* ``--mbuf-size=N`` +* ``--mbuf-size=N[,N1[,...Nn]`` - Set the data size of the mbufs used to N bytes, where N < 65536. The default value is 2048. + Set the data size of the mbufs used to N bytes, where N < 65536. + The default value is 2048. If multiple mbuf-size values are specified the + extra memory pools will be created for allocating mbufs to receive packets + with buffer splittling features. * ``--total-num-mbufs=N`` From patchwork Mon Oct 12 20:09:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 80404 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7DC21A04B6; Mon, 12 Oct 2020 22:11:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 42DC51D9E3; Mon, 12 Oct 2020 22:10:29 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 807AF1D9D7 for ; Mon, 12 Oct 2020 22:10:24 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@nvidia.com) with SMTP; 12 Oct 2020 23:10:20 +0300 Received: from nvidia.com (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09CKADfB013670; Mon, 12 Oct 2020 23:10:20 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: thomasm@monjalon.net, stephen@networkplumber.org, ferruh.yigit@intel.com, olivier.matz@6wind.com, jerinjacobk@gmail.com, maxime.coquelin@redhat.com, david.marchand@redhat.com, arybchenko@solarflare.com Date: Mon, 12 Oct 2020 20:09:56 +0000 Message-Id: <1602533402-14795-4-git-send-email-viacheslavo@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> References: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> Subject: [dpdk-dev] [PATCH v4 3/9] app/testpmd: add buffer split offload configuration X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch add support for RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT providing per queue configuration for this offload. Signed-off-by: Viacheslav Ovsiienko --- app/test-pmd/cmdline.c | 21 +++++++++++---------- app/test-pmd/config.c | 9 +++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index a585cf0..fa71039 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -883,16 +883,16 @@ static void cmd_help_long_parsed(void *parsed_result, "port config rx_offload vlan_strip|" "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" "outer_ipv4_cksum|macsec_strip|header_split|" - "vlan_filter|vlan_extend|jumbo_frame|" - "scatter|timestamp|security|keep_crc on|off\n" + "vlan_filter|vlan_extend|jumbo_frame|scatter|" + "buffer_split|timestamp|security|keep_crc on|off\n" " Enable or disable a per port Rx offloading" " on all Rx queues of a port\n\n" "port (port_id) rxq (queue_id) rx_offload vlan_strip|" "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|" "outer_ipv4_cksum|macsec_strip|header_split|" - "vlan_filter|vlan_extend|jumbo_frame|" - "scatter|timestamp|security|keep_crc on|off\n" + "vlan_filter|vlan_extend|jumbo_frame|scatter|" + "buffer_split|timestamp|security|keep_crc on|off\n" " Enable or disable a per queue Rx offloading" " only on a specific Rx queue\n\n" @@ -18417,7 +18417,8 @@ struct cmd_config_per_port_rx_offload_result { offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" "qinq_strip#outer_ipv4_cksum#macsec_strip#" "header_split#vlan_filter#vlan_extend#jumbo_frame#" - "scatter#timestamp#security#keep_crc#rss_hash"); + "scatter#buffer_split#timestamp#security#" + "keep_crc#rss_hash"); cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = TOKEN_STRING_INITIALIZER (struct cmd_config_per_port_rx_offload_result, @@ -18497,8 +18498,8 @@ struct cmd_config_per_port_rx_offload_result { .help_str = "port config rx_offload vlan_strip|ipv4_cksum|" "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" "macsec_strip|header_split|vlan_filter|vlan_extend|" - "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash " - "on|off", + "jumbo_frame|scatter|buffer_split|timestamp|security|" + "keep_crc|rss_hash on|off", .tokens = { (void *)&cmd_config_per_port_rx_offload_result_port, (void *)&cmd_config_per_port_rx_offload_result_config, @@ -18547,7 +18548,7 @@ struct cmd_config_per_queue_rx_offload_result { offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" "qinq_strip#outer_ipv4_cksum#macsec_strip#" "header_split#vlan_filter#vlan_extend#jumbo_frame#" - "scatter#timestamp#security#keep_crc"); + "scatter#buffer_split#timestamp#security#keep_crc"); cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = TOKEN_STRING_INITIALIZER (struct cmd_config_per_queue_rx_offload_result, @@ -18603,8 +18604,8 @@ struct cmd_config_per_queue_rx_offload_result { "vlan_strip|ipv4_cksum|" "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" "macsec_strip|header_split|vlan_filter|vlan_extend|" - "jumbo_frame|scatter|timestamp|security|keep_crc " - "on|off", + "jumbo_frame|scatter|buffer_split|timestamp|security|" + "keep_crc on|off", .tokens = { (void *)&cmd_config_per_queue_rx_offload_result_port, (void *)&cmd_config_per_queue_rx_offload_result_port_id, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 5f501f6..7126d91 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1092,6 +1092,15 @@ static int bus_match_all(const struct rte_bus *bus, const void *data) printf("off\n"); } + if (dev_info.rx_offload_capa & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) { + printf("RX offload buffer split: "); + if (ports[port_id].dev_conf.rxmode.offloads & + RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) + printf("on\n"); + else + printf("off\n"); + } + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VLAN_INSERT) { printf("VLAN insert: "); if (ports[port_id].dev_conf.txmode.offloads & From patchwork Mon Oct 12 20:09:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 80403 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9EE43A04B6; Mon, 12 Oct 2020 22:11:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B1FCC1D9DE; Mon, 12 Oct 2020 22:10:27 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 8771B1D9D8 for ; Mon, 12 Oct 2020 22:10:25 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@nvidia.com) with SMTP; 12 Oct 2020 23:10:22 +0300 Received: from nvidia.com (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09CKADfC013670; Mon, 12 Oct 2020 23:10:22 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: thomasm@monjalon.net, stephen@networkplumber.org, ferruh.yigit@intel.com, olivier.matz@6wind.com, jerinjacobk@gmail.com, maxime.coquelin@redhat.com, david.marchand@redhat.com, arybchenko@solarflare.com Date: Mon, 12 Oct 2020 20:09:57 +0000 Message-Id: <1602533402-14795-5-git-send-email-viacheslavo@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> References: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> Subject: [dpdk-dev] [PATCH v4 4/9] app/testpmd: add rxpkts commands and parameters X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add command line parameter: --rxpkts=X[,Y] Sets the length of segments to scatter packets on receiving if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only). Add interactive mode command: testpmd> set txpkts (x[,y]*) Where x[,y]* represents a CSV list of values, without white space. Sets the length of segments to scatter packets on receiving if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only). Optionally the multiple memory pools can be specified with --mbuf-size command line parameter and the mbufs to receive will be allocated sequentially from these extra memory pools. Signed-off-by: Viacheslav Ovsiienko --- app/test-pmd/cmdline.c | 61 +++++++++++++++++++++++++++-- app/test-pmd/config.c | 48 ++++++++++++++++++++++- app/test-pmd/parameters.c | 15 +++++++ app/test-pmd/testpmd.c | 7 ++++ app/test-pmd/testpmd.h | 11 +++++- doc/guides/testpmd_app_ug/run_app.rst | 9 +++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 21 +++++++++- 7 files changed, 165 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index fa71039..d8dba54 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -183,7 +183,7 @@ static void cmd_help_long_parsed(void *parsed_result, "show (rxq|txq) info (port_id) (queue_id)\n" " Display information for configured RX/TX queue.\n\n" - "show config (rxtx|cores|fwd|txpkts)\n" + "show config (rxtx|cores|fwd|rxpkts|txpkts)\n" " Display the given configuration.\n\n" "read rxd (port_id) (queue_id) (rxd_id)\n" @@ -294,6 +294,12 @@ static void cmd_help_long_parsed(void *parsed_result, " Set the transmit delay time and number of retries," " effective when retry is enabled.\n\n" + "set rxpkts (x[,y]*)\n" + " Set the length of each segment to scatter" + " packets on receiving if split feature is engaged." + " Affects only the queues configured with split" + " offloads.\n\n" + "set txpkts (x[,y]*)\n" " Set the length of each segment of TXONLY" " and optionally CSUM packets.\n\n" @@ -3889,6 +3895,52 @@ struct cmd_set_log_result { }, }; +/* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */ + +struct cmd_set_rxpkts_result { + cmdline_fixed_string_t cmd_keyword; + cmdline_fixed_string_t rxpkts; + cmdline_fixed_string_t seg_lengths; +}; + +static void +cmd_set_rxpkts_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_set_rxpkts_result *res; + unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT]; + unsigned int nb_segs; + + res = parsed_result; + nb_segs = parse_item_list(res->seg_lengths, "segment lengths", + MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0); + if (nb_segs > 0) + set_rx_pkt_segments(seg_lengths, nb_segs); +} + +cmdline_parse_token_string_t cmd_set_rxpkts_keyword = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, + cmd_keyword, "set"); +cmdline_parse_token_string_t cmd_set_rxpkts_name = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, + rxpkts, "rxpkts"); +cmdline_parse_token_string_t cmd_set_rxpkts_lengths = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, + seg_lengths, NULL); + +cmdline_parse_inst_t cmd_set_rxpkts = { + .f = cmd_set_rxpkts_parsed, + .data = NULL, + .help_str = "set rxpkts ", + .tokens = { + (void *)&cmd_set_rxpkts_keyword, + (void *)&cmd_set_rxpkts_name, + (void *)&cmd_set_rxpkts_lengths, + NULL, + }, +}; + /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ struct cmd_set_txpkts_result { @@ -7517,6 +7569,8 @@ static void cmd_showcfg_parsed(void *parsed_result, fwd_lcores_config_display(); else if (!strcmp(res->what, "fwd")) pkt_fwd_config_display(&cur_fwd_config); + else if (!strcmp(res->what, "rxpkts")) + show_rx_pkt_segments(); else if (!strcmp(res->what, "txpkts")) show_tx_pkt_segments(); else if (!strcmp(res->what, "txtimes")) @@ -7529,12 +7583,12 @@ static void cmd_showcfg_parsed(void *parsed_result, TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); cmdline_parse_token_string_t cmd_showcfg_what = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, - "rxtx#cores#fwd#txpkts#txtimes"); + "rxtx#cores#fwd#rxpkts#txpkts#txtimes"); cmdline_parse_inst_t cmd_showcfg = { .f = cmd_showcfg_parsed, .data = NULL, - .help_str = "show config rxtx|cores|fwd|txpkts|txtimes", + .help_str = "show config rxtx|cores|fwd|rxpkts|txpkts|txtimes", .tokens = { (void *)&cmd_showcfg_show, (void *)&cmd_showcfg_port, @@ -19807,6 +19861,7 @@ struct cmd_showport_macs_result { (cmdline_parse_inst_t *)&cmd_reset, (cmdline_parse_inst_t *)&cmd_set_numbers, (cmdline_parse_inst_t *)&cmd_set_log, + (cmdline_parse_inst_t *)&cmd_set_rxpkts, (cmdline_parse_inst_t *)&cmd_set_txpkts, (cmdline_parse_inst_t *)&cmd_set_txsplit, (cmdline_parse_inst_t *)&cmd_set_txtimes, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 7126d91..24e9a7e 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3300,6 +3300,50 @@ struct igb_ring_desc_16_bytes { } void +show_rx_pkt_segments(void) +{ + uint32_t i, n; + + n = rx_pkt_nb_segs; + printf("Number of segments: %u\n", n); + if (n) { + printf("Segment sizes: "); + for (i = 0; i != n - 1; i++) + printf("%hu,", rx_pkt_seg_lengths[i]); + printf("%hu\n", rx_pkt_seg_lengths[i]); + } +} + +void +set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs) +{ + unsigned int i; + + if (nb_segs >= MAX_SEGS_BUFFER_SPLIT) { + printf("nb segments per RX packets=%u >= " + "MAX_SEGS_BUFFER_SPLIT - ignored\n", nb_segs); + return; + } + + /* + * No extra check here, the segment length will be checked by PMD + * in the extended queue setup. + */ + for (i = 0; i < nb_segs; i++) { + if (seg_lengths[i] >= UINT16_MAX) { + printf("length[%u]=%u > UINT16_MAX - give up\n", + i, seg_lengths[i]); + return; + } + } + + for (i = 0; i < nb_segs; i++) + rx_pkt_seg_lengths[i] = (uint16_t) seg_lengths[i]; + + rx_pkt_nb_segs = (uint8_t) nb_segs; +} + +void show_tx_pkt_segments(void) { uint32_t i, n; @@ -3344,10 +3388,10 @@ struct igb_ring_desc_16_bytes { } void -set_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs) +set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs) { uint16_t tx_pkt_len; - unsigned i; + unsigned int i; if (nb_segs_is_invalid(nb_segs)) return; diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 4db4987..e4e3635 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -184,6 +184,7 @@ "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); printf(" --no-flush-rx: Don't flush RX streams before forwarding." " Used mainly with PCAP drivers.\n"); + printf(" --rxpkts=X[,Y]*: set RX segment sizes to split.\n"); printf(" --txpkts=X[,Y]*: set TX segment sizes" " or total packet length.\n"); printf(" --txonly-multi-flow: generate multiple flows in txonly mode\n"); @@ -662,6 +663,7 @@ { "rx-queue-stats-mapping", 1, 0, 0 }, { "no-flush-rx", 0, 0, 0 }, { "flow-isolate-all", 0, 0, 0 }, + { "rxpkts", 1, 0, 0 }, { "txpkts", 1, 0, 0 }, { "txonly-multi-flow", 0, 0, 0 }, { "disable-link-check", 0, 0, 0 }, @@ -1272,6 +1274,19 @@ "invalid RX queue statistics mapping config entered\n"); } } + if (!strcmp(lgopts[opt_idx].name, "rxpkts")) { + unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT]; + unsigned int nb_segs; + + nb_segs = parse_item_list + (optarg, "rxpkt segments", + MAX_SEGS_BUFFER_SPLIT, + seg_len, 0); + if (nb_segs > 0) + set_rx_pkt_segments(seg_len, nb_segs); + else + rte_exit(EXIT_FAILURE, "bad rxpkts\n"); + } if (!strcmp(lgopts[opt_idx].name, "txpkts")) { unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; unsigned int nb_segs; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 7e6ef80..f88c1e2 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -210,6 +210,13 @@ struct fwd_engine * fwd_engines[] = { uint8_t f_quit; /* + * Configuration of packet segments used to scatter received packets + * if some of split features is configured. + */ +uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT]; +uint8_t rx_pkt_nb_segs; /**< Number of segments to split */ + +/* * Configuration of packet segments used by the "txonly" processing engine. */ uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN; /**< TXONLY packet length. */ diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index b42d710..8e5ba6a 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -420,6 +420,13 @@ struct queue_stats_mappings { extern struct rte_fdir_conf fdir_conf; /* + * Configuration of packet segments used to scatter received packets + * if some of split features is configured. + */ +extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT]; +extern uint8_t rx_pkt_nb_segs; /**< Number of segments to split */ + +/* * Configuration of packet segments used by the "txonly" processing engine. */ #define TXONLY_DEF_PACKET_LEN 64 @@ -816,7 +823,9 @@ void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type, void set_record_core_cycles(uint8_t on_off); void set_record_burst_stats(uint8_t on_off); void set_verbose_level(uint16_t vb_level); -void set_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs); +void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs); +void show_rx_pkt_segments(void); +void set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs); void show_tx_pkt_segments(void); void set_tx_pkt_times(unsigned int *tx_times); void show_tx_pkt_times(void); diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index 1eb0a10..463b76c 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -361,6 +361,15 @@ The command line options are: Don't flush the RX streams before starting forwarding. Used mainly with the PCAP PMD. +* ``--rxpkts=X[,Y]`` + + Set the length of segments to scatter packets on receiving if split + feature is engaged. Affects only the queues configured + with split offloads (currently BUFFER_SPLIT is supported only). + Optionally the multiple memory pools can be specified with --mbuf-size + command line parameter and the mbufs to receive will be allocated + sequentially from these extra memory pools. + * ``--txpkts=X[,Y]`` Set TX segment sizes or total packet length. Valid for ``tx-only`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 795c739..ff88762 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -273,7 +273,7 @@ show config Displays the configuration of the application. The configuration comes from the command-line, the runtime or the application defaults:: - testpmd> show config (rxtx|cores|fwd|txpkts|txtimes) + testpmd> show config (rxtx|cores|fwd|rxpkts|txpkts|txtimes) The available information categories are: @@ -283,6 +283,8 @@ The available information categories are: * ``fwd``: Packet forwarding configuration. +* ``rxpkts``: Packets to RX split configuration. + * ``txpkts``: Packets to TX configuration. * ``txtimes``: Burst time pattern for Tx only mode. @@ -774,6 +776,23 @@ When retry is enabled, the transmit delay time and number of retries can also be testpmd> set burst tx delay (microseconds) retry (num) +set rxpkts +~~~~~~~~~~ + +Set the length of segments to scatter packets on receiving if split +feature is engaged. Affects only the queues configured with split offloads +(currently BUFFER_SPLIT is supported only). Optionally the multiple memory +pools can be specified with --mbuf-size command line parameter and the mbufs +to receive will be allocated sequentially from these extra memory pools (the +mbuf for the first segment is allocated from the first pool, the second one +from the second pool, and so on, if segment number is greater then pool's the +mbuf for remaining segments will be allocated from the last valid pool). + + testpmd> set rxpkts (x[,y]*) + +Where x[,y]* represents a CSV list of values, without white space. Zero value +means to use the corresponding memory pool data buffer size. + set txpkts ~~~~~~~~~~ From patchwork Mon Oct 12 20:09:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 80405 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6CFF0A04B6; Mon, 12 Oct 2020 22:12:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B0A1C1D9E8; Mon, 12 Oct 2020 22:10:30 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id AC3591D9D9 for ; Mon, 12 Oct 2020 22:10:25 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@nvidia.com) with SMTP; 12 Oct 2020 23:10:23 +0300 Received: from nvidia.com (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09CKADfD013670; Mon, 12 Oct 2020 23:10:23 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: thomasm@monjalon.net, stephen@networkplumber.org, ferruh.yigit@intel.com, olivier.matz@6wind.com, jerinjacobk@gmail.com, maxime.coquelin@redhat.com, david.marchand@redhat.com, arybchenko@solarflare.com Date: Mon, 12 Oct 2020 20:09:58 +0000 Message-Id: <1602533402-14795-6-git-send-email-viacheslavo@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> References: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> Subject: [dpdk-dev] [PATCH v4 5/9] app/testpmd: add extended Rx queue setup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" If Rx queue is configured with split feature the extended setup with specified segment sizes and pool will be performed. Signed-off-by: Viacheslav Ovsiienko --- app/test-pmd/cmdline.c | 12 ++++++------ app/test-pmd/testpmd.c | 38 ++++++++++++++++++++++++++++++++++++-- app/test-pmd/testpmd.h | 6 ++++++ 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index d8dba54..cf99f66 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2921,12 +2921,12 @@ struct cmd_setup_rxtx_queue { rxring_numa[res->portid]); return; } - ret = rte_eth_rx_queue_setup(res->portid, - res->qid, - port->nb_rx_desc[res->qid], - socket_id, - &port->rx_conf[res->qid], - mp); + ret = rx_queue_setup(res->portid, + res->qid, + port->nb_rx_desc[res->qid], + socket_id, + &port->rx_conf[res->qid], + mp); if (ret) printf("Failed to setup RX queue\n"); } else { diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index f88c1e2..8cc265e 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2412,6 +2412,40 @@ struct extmem_param { return 0; } +/* Configure the Rx with optional split. */ +int +rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, + uint16_t nb_rx_desc, unsigned int socket_id, + const struct rte_eth_rxconf *rx_conf, + struct rte_mempool *mp) +{ + struct rte_eth_rxseg rx_seg[MAX_SEGS_BUFFER_SPLIT] = {}; + unsigned int i, mp_n; + + if (rx_pkt_nb_segs <= 1 || + (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) == 0) + return rte_eth_rx_queue_setup(port_id, rx_queue_id, + nb_rx_desc, socket_id, + rx_conf, mp); + for (i = 0; i < rx_pkt_nb_segs; i++) { + struct rte_mempool *mpx; + /* + * Use last valid pool for the segments with number + * exceeding the pool index. + */ + mp_n = (i > mbuf_data_size_n) ? mbuf_data_size_n - 1 : i; + mpx = mbuf_pool_find(socket_id, mp_n); + /* Handle zero as mbuf data buffer size. */ + rx_seg[i].length = rx_pkt_seg_lengths[i] ? + rx_pkt_seg_lengths[i] : + mbuf_data_size[mp_n]; + rx_seg[i].mp = mpx ? mpx : mp; + } + return rte_eth_rxseg_queue_setup(port_id, rx_queue_id, + nb_rx_desc, socket_id, rx_conf, + rx_seg, rx_pkt_nb_segs); +} + int start_port(portid_t pid) { @@ -2520,7 +2554,7 @@ struct extmem_param { return -1; } - diag = rte_eth_rx_queue_setup(pi, qi, + diag = rx_queue_setup(pi, qi, port->nb_rx_desc[qi], rxring_numa[pi], &(port->rx_conf[qi]), @@ -2536,7 +2570,7 @@ struct extmem_param { port->socket_id); return -1; } - diag = rte_eth_rx_queue_setup(pi, qi, + diag = rx_queue_setup(pi, qi, port->nb_rx_desc[qi], port->socket_id, &(port->rx_conf[qi]), diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 8e5ba6a..5cef419 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -872,6 +872,12 @@ void port_rss_reta_info(portid_t port_id, void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on); +int +rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, + uint16_t nb_rx_desc, unsigned int socket_id, + const struct rte_eth_rxconf *rx_conf, + struct rte_mempool *mp); + int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate); int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate, uint64_t q_msk); From patchwork Mon Oct 12 20:09:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 80406 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E9131A04B6; Mon, 12 Oct 2020 22:12:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4045C1D9EE; Mon, 12 Oct 2020 22:10:32 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id AAD4E1D9E6 for ; Mon, 12 Oct 2020 22:10:30 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@nvidia.com) with SMTP; 12 Oct 2020 23:10:24 +0300 Received: from nvidia.com (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09CKADfE013670; Mon, 12 Oct 2020 23:10:24 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: thomasm@monjalon.net, stephen@networkplumber.org, ferruh.yigit@intel.com, olivier.matz@6wind.com, jerinjacobk@gmail.com, maxime.coquelin@redhat.com, david.marchand@redhat.com, arybchenko@solarflare.com Date: Mon, 12 Oct 2020 20:09:59 +0000 Message-Id: <1602533402-14795-7-git-send-email-viacheslavo@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> References: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> Subject: [dpdk-dev] [PATCH v4 6/9] net/mlx5: add extended Rx queue setup routine X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The routine to provide Rx queue setup with specifying extended receiving buffer description is added. It allows application to specify desired segment lengths, data position offsets in the buffer and dedicated memory pool for each segment. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/linux/mlx5_os.c | 2 + drivers/net/mlx5/mlx5.h | 3 ++ drivers/net/mlx5/mlx5_rxq.c | 91 +++++++++++++++++++++++++++++++++++----- drivers/net/mlx5/mlx5_rxtx.h | 10 ++++- 4 files changed, 95 insertions(+), 11 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 487714f..0e85489 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -2495,6 +2495,7 @@ .dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get, .vlan_filter_set = mlx5_vlan_filter_set, .rx_queue_setup = mlx5_rx_queue_setup, + .rxseg_queue_setup = mlx5_rxseg_queue_setup, .rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup, .tx_queue_setup = mlx5_tx_queue_setup, .tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup, @@ -2578,6 +2579,7 @@ .dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get, .vlan_filter_set = mlx5_vlan_filter_set, .rx_queue_setup = mlx5_rx_queue_setup, + .rxseg_queue_setup = mlx5_rxseg_queue_setup, .rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup, .tx_queue_setup = mlx5_tx_queue_setup, .tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup, diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 87d3c15..bfc0812 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -162,6 +162,9 @@ struct mlx5_stats_ctrl { /* Maximal size of aggregated LRO packet. */ #define MLX5_MAX_LRO_SIZE (UINT8_MAX * MLX5_LRO_SEG_CHUNK_SIZE) +/* Maximal number of segments to split. */ +#define MLX5_MAX_RXQ_NSEG (1u << MLX5_MAX_LOG_RQ_SEGS) + /* LRO configurations structure. */ struct mlx5_lro_config { uint32_t supported:1; /* Whether LRO is supported. */ diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index f1d8373..42818d8 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -390,6 +390,7 @@ struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_dev_config *config = &priv->config; uint64_t offloads = (DEV_RX_OFFLOAD_SCATTER | + RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT | DEV_RX_OFFLOAD_TIMESTAMP | DEV_RX_OFFLOAD_JUMBO_FRAME | DEV_RX_OFFLOAD_RSS_HASH); @@ -715,16 +716,20 @@ * NUMA socket on which memory must be allocated. * @param[in] conf * Thresholds parameters. - * @param mp - * Memory pool for buffer allocations. + * @param rx_seg + * Pointer the array of segment descriptions, each element + * describes the memory pool, maximal data length, initial + * data offset from the beginning of data buffer in mbuf + * @param n_seg + * Number of elements in the segment descriptions array * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ int -mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, - unsigned int socket, const struct rte_eth_rxconf *conf, - struct rte_mempool *mp) +mlx5_rxseg_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, + unsigned int socket, const struct rte_eth_rxconf *conf, + const struct rte_eth_rxseg *rx_seg, uint16_t n_seg) { struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_rxq_data *rxq = (*priv->rxqs)[idx]; @@ -732,10 +737,43 @@ container_of(rxq, struct mlx5_rxq_ctrl, rxq); int res; + if (!n_seg || !rx_seg) { + DRV_LOG(ERR, "port %u queue index %u invalid " + "split description", + dev->data->port_id, idx); + rte_errno = EINVAL; + return -rte_errno; + } + if (n_seg > 1) { + uint64_t offloads = conf->offloads | + dev->data->dev_conf.rxmode.offloads; + + if (!(offloads & DEV_RX_OFFLOAD_SCATTER)) { + DRV_LOG(ERR, "port %u queue index %u split " + "configuration requires scattering", + dev->data->port_id, idx); + rte_errno = ENOSPC; + return -rte_errno; + } + if (!(offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) { + DRV_LOG(ERR, "port %u queue index %u split " + "offload not configured", + dev->data->port_id, idx); + rte_errno = ENOSPC; + return -rte_errno; + } + if (n_seg > MLX5_MAX_RXQ_NSEG) { + DRV_LOG(ERR, "port %u queue index %u too many " + "segments %u to split", + dev->data->port_id, idx, n_seg); + rte_errno = EOVERFLOW; + return -rte_errno; + } + } res = mlx5_rx_queue_pre_setup(dev, idx, &desc); if (res) return res; - rxq_ctrl = mlx5_rxq_new(dev, idx, desc, socket, conf, mp); + rxq_ctrl = mlx5_rxq_new(dev, idx, desc, socket, conf, rx_seg, n_seg); if (!rxq_ctrl) { DRV_LOG(ERR, "port %u unable to allocate queue index %u", dev->data->port_id, idx); @@ -756,6 +794,39 @@ * RX queue index. * @param desc * Number of descriptors to configure in queue. + * @param socket + * NUMA socket on which memory must be allocated. + * @param[in] conf + * Thresholds parameters. + * @param mp + * Memory pool for buffer allocations. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, + unsigned int socket, const struct rte_eth_rxconf *conf, + struct rte_mempool *mp) +{ + struct rte_eth_rxseg rx_seg = { + .mp = mp, + /* + * All other fields are zeroed, zero segment length + * means the pool buffer size should be used by PMD. + */ + }; + return mlx5_rxseg_queue_setup(dev, idx, desc, socket, conf, &rx_seg, 1); +} + +/** + * + * @param dev + * Pointer to Ethernet device structure. + * @param idx + * RX queue index. + * @param desc + * Number of descriptors to configure in queue. * @param hairpin_conf * Hairpin configuration parameters. * @@ -1328,11 +1399,11 @@ struct mlx5_rxq_ctrl * mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, unsigned int socket, const struct rte_eth_rxconf *conf, - struct rte_mempool *mp) + const struct rte_eth_rxseg *rx_seg, uint16_t n_seg) { struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_rxq_ctrl *tmpl; - unsigned int mb_len = rte_pktmbuf_data_room_size(mp); + unsigned int mb_len = rte_pktmbuf_data_room_size(rx_seg[0].mp); unsigned int mprq_stride_nums; unsigned int mprq_stride_size; unsigned int mprq_stride_cap; @@ -1346,7 +1417,7 @@ struct mlx5_rxq_ctrl * uint64_t offloads = conf->offloads | dev->data->dev_conf.rxmode.offloads; unsigned int lro_on_queue = !!(offloads & DEV_RX_OFFLOAD_TCP_LRO); - const int mprq_en = mlx5_check_mprq_support(dev) > 0; + const int mprq_en = mlx5_check_mprq_support(dev) > 0 && n_seg == 1; unsigned int max_rx_pkt_len = lro_on_queue ? dev->data->dev_conf.rxmode.max_lro_pkt_size : dev->data->dev_conf.rxmode.max_rx_pkt_len; @@ -1531,7 +1602,7 @@ struct mlx5_rxq_ctrl * (!!(dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS)); tmpl->rxq.port_id = dev->data->port_id; tmpl->priv = priv; - tmpl->rxq.mp = mp; + tmpl->rxq.mp = rx_seg[0].mp; tmpl->rxq.elts_n = log2above(desc); tmpl->rxq.rq_repl_thresh = MLX5_VPMD_RXQ_RPLNSH_THRESH(1 << tmpl->rxq.elts_n); diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 674296e..f103a30 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -150,6 +150,9 @@ struct mlx5_rxq_data { rte_spinlock_t *uar_lock_cq; /* CQ (UAR) access lock required for 32bit implementations */ #endif + struct rte_eth_rxseg rxseg[MLX5_MAX_RXQ_NSEG]; + /* Buffer split segment descriptions - sizes, offsets, pools. */ + uint32_t rxseg_n; /* Number of split segment descriptions. */ uint32_t tunnel; /* Tunnel information. */ uint64_t flow_meta_mask; int32_t flow_meta_offset; @@ -304,6 +307,10 @@ struct mlx5_txq_ctrl { int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, unsigned int socket, const struct rte_eth_rxconf *conf, struct rte_mempool *mp); +int mlx5_rxseg_queue_setup + (struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, + unsigned int socket, const struct rte_eth_rxconf *conf, + const struct rte_eth_rxseg *rx_seg, uint16_t n_seg); int mlx5_rx_hairpin_queue_setup (struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, const struct rte_eth_hairpin_conf *hairpin_conf); @@ -316,7 +323,8 @@ int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, unsigned int socket, const struct rte_eth_rxconf *conf, - struct rte_mempool *mp); + const struct rte_eth_rxseg *rx_seg, + uint16_t n_seg); struct mlx5_rxq_ctrl *mlx5_rxq_hairpin_new (struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, const struct rte_eth_hairpin_conf *hairpin_conf); From patchwork Mon Oct 12 20:10:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 80407 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A3FBAA04B6; Mon, 12 Oct 2020 22:12:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CA8EF1D9F4; Mon, 12 Oct 2020 22:10:33 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id B0CAC1D9E9 for ; Mon, 12 Oct 2020 22:10:29 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@nvidia.com) with SMTP; 12 Oct 2020 23:10:25 +0300 Received: from nvidia.com (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09CKADfF013670; Mon, 12 Oct 2020 23:10:25 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: thomasm@monjalon.net, stephen@networkplumber.org, ferruh.yigit@intel.com, olivier.matz@6wind.com, jerinjacobk@gmail.com, maxime.coquelin@redhat.com, david.marchand@redhat.com, arybchenko@solarflare.com Date: Mon, 12 Oct 2020 20:10:00 +0000 Message-Id: <1602533402-14795-8-git-send-email-viacheslavo@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> References: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> Subject: [dpdk-dev] [PATCH v4 7/9] net/mlx5: configure Rx queue to support split X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The scatter-gather elements should be configured accordingly to support the buffer split feature. The application provides the desired settings for the segments at the beginning of the packets and PMD pads the buffer chain (if needed) with attributes of last specified segment to accommodate the packet of maximal length. There are some limitations are implied. The MPRQ feature should be disengaged if split is requested, due to MPRQ neither supports pushing data to the dedicated pools nor follows the flexible buffer sizes. The vectorized rx_burst routines does not support the scattering (these ones are extremely simplified and work over the single segment only) and can't handle split as well. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_rxq.c | 94 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 80 insertions(+), 14 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 42818d8..4ec4677 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -1417,7 +1417,8 @@ struct mlx5_rxq_ctrl * uint64_t offloads = conf->offloads | dev->data->dev_conf.rxmode.offloads; unsigned int lro_on_queue = !!(offloads & DEV_RX_OFFLOAD_TCP_LRO); - const int mprq_en = mlx5_check_mprq_support(dev) > 0 && n_seg == 1; + const int mprq_en = mlx5_check_mprq_support(dev) > 0 && n_seg == 1 && + !rx_seg[0].offset && !rx_seg[0].length; unsigned int max_rx_pkt_len = lro_on_queue ? dev->data->dev_conf.rxmode.max_lro_pkt_size : dev->data->dev_conf.rxmode.max_rx_pkt_len; @@ -1425,22 +1426,87 @@ struct mlx5_rxq_ctrl * RTE_PKTMBUF_HEADROOM; unsigned int max_lro_size = 0; unsigned int first_mb_free_size = mb_len - RTE_PKTMBUF_HEADROOM; + const struct rte_eth_rxseg *qs_seg = rx_seg; + unsigned int tail_len; - if (non_scatter_min_mbuf_size > mb_len && !(offloads & - DEV_RX_OFFLOAD_SCATTER)) { + tmpl = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, sizeof(*tmpl) + + desc_n * sizeof(struct rte_mbuf *), 0, socket); + if (!tmpl) { + rte_errno = ENOMEM; + return NULL; + } + MLX5_ASSERT(n_seg && n_seg <= MLX5_MAX_RXQ_NSEG); + /* + * Build the array of actual buffer offsets and lengths. + * Pad with the buffers from the last memory pool if + * needed to handle max size packets, replace zero length + * with the buffer length from the pool. + */ + tail_len = max_rx_pkt_len; + do { + struct rte_eth_rxseg *hw_seg = + &tmpl->rxq.rxseg[tmpl->rxq.rxseg_n]; + uint32_t buf_len = rte_pktmbuf_data_room_size(qs_seg->mp); + uint32_t offset, seg_len; + + /* + * For the buffers beyond descriptions offset is zero, + * the first buffer contains head room. + */ + offset = (tmpl->rxq.rxseg_n >= n_seg ? 0 : qs_seg->offset) + + (tmpl->rxq.rxseg_n ? 0 : RTE_PKTMBUF_HEADROOM); + /* + * For the buffers beyond descriptions the length is + * pool buffer length, zero lengths are replaced with + * pool buffer length either. + */ + seg_len = tmpl->rxq.rxseg_n >= n_seg ? buf_len : + qs_seg->length ? qs_seg->length : (buf_len - offset); + /* Check is done in long int, now overflows. */ + if (buf_len < seg_len + offset) { + DRV_LOG(ERR, "port %u Rx queue %u: Split offset/length " + "%u/%u can't be satisfied", + dev->data->port_id, idx, + qs_seg->length, qs_seg->offset); + rte_errno = EINVAL; + goto error; + } + if (seg_len > tail_len) + seg_len = buf_len - offset; + if (++tmpl->rxq.rxseg_n > MLX5_MAX_RXQ_NSEG) { + DRV_LOG(ERR, + "port %u too many SGEs (%u) needed to handle" + " requested maximum packet size %u, the maximum" + " supported are %u", dev->data->port_id, + tmpl->rxq.rxseg_n, max_rx_pkt_len, + MLX5_MAX_RXQ_NSEG); + rte_errno = ENOTSUP; + goto error; + } + /* Build the actual scattering element in the queue object. */ + hw_seg->mp = qs_seg->mp; + MLX5_ASSERT(offset <= UINT16_MAX); + MLX5_ASSERT(seg_len <= UINT16_MAX); + hw_seg->offset = (uint16_t)offset; + hw_seg->length = (uint16_t)seg_len; + /* + * Advance the segment descriptor, the padding is the based + * on the attributes of the last descriptor. + */ + if (tmpl->rxq.rxseg_n < n_seg) + qs_seg++; + tail_len -= RTE_MIN(tail_len, seg_len); + } while (tail_len || !rte_is_power_of_2(tmpl->rxq.rxseg_n)); + MLX5_ASSERT(tmpl->rxq.rxseg_n && + tmpl->rxq.rxseg_n <= MLX5_MAX_RXQ_NSEG); + if (tmpl->rxq.rxseg_n > 1 && !(offloads & DEV_RX_OFFLOAD_SCATTER)) { DRV_LOG(ERR, "port %u Rx queue %u: Scatter offload is not" " configured and no enough mbuf space(%u) to contain " "the maximum RX packet length(%u) with head-room(%u)", dev->data->port_id, idx, mb_len, max_rx_pkt_len, RTE_PKTMBUF_HEADROOM); rte_errno = ENOSPC; - return NULL; - } - tmpl = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, sizeof(*tmpl) + - desc_n * sizeof(struct rte_mbuf *), 0, socket); - if (!tmpl) { - rte_errno = ENOMEM; - return NULL; + goto error; } tmpl->type = MLX5_RXQ_TYPE_STANDARD; if (mlx5_mr_btree_init(&tmpl->rxq.mr_ctrl.cache_bh, @@ -1467,7 +1533,7 @@ struct mlx5_rxq_ctrl * * - The number of descs is more than the number of strides. * - max_rx_pkt_len plus overhead is less than the max size * of a stride or mprq_stride_size is specified by a user. - * Need to nake sure that there are enough stides to encap + * Need to make sure that there are enough stides to encap * the maximum packet size in case mprq_stride_size is set. * Otherwise, enable Rx scatter if necessary. */ @@ -1497,11 +1563,11 @@ struct mlx5_rxq_ctrl * " strd_num_n = %u, strd_sz_n = %u", dev->data->port_id, idx, tmpl->rxq.strd_num_n, tmpl->rxq.strd_sz_n); - } else if (max_rx_pkt_len <= first_mb_free_size) { + } else if (tmpl->rxq.rxseg_n == 1) { + MLX5_ASSERT(max_rx_pkt_len <= first_mb_free_size); tmpl->rxq.sges_n = 0; max_lro_size = max_rx_pkt_len; } else if (offloads & DEV_RX_OFFLOAD_SCATTER) { - unsigned int size = non_scatter_min_mbuf_size; unsigned int sges_n; if (lro_on_queue && first_mb_free_size < @@ -1516,7 +1582,7 @@ struct mlx5_rxq_ctrl * * Determine the number of SGEs needed for a full packet * and round it to the next power of two. */ - sges_n = log2above((size / mb_len) + !!(size % mb_len)); + sges_n = log2above(tmpl->rxq.rxseg_n); if (sges_n > MLX5_MAX_LOG_RQ_SEGS) { DRV_LOG(ERR, "port %u too many SGEs (%u) needed to handle" From patchwork Mon Oct 12 20:10:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 80408 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2E64FA04B6; Mon, 12 Oct 2020 22:13:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 90A5F1D9FA; Mon, 12 Oct 2020 22:10:35 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id D2C8F1D9ED for ; Mon, 12 Oct 2020 22:10:30 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@nvidia.com) with SMTP; 12 Oct 2020 23:10:26 +0300 Received: from nvidia.com (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09CKADfG013670; Mon, 12 Oct 2020 23:10:26 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: thomasm@monjalon.net, stephen@networkplumber.org, ferruh.yigit@intel.com, olivier.matz@6wind.com, jerinjacobk@gmail.com, maxime.coquelin@redhat.com, david.marchand@redhat.com, arybchenko@solarflare.com Date: Mon, 12 Oct 2020 20:10:01 +0000 Message-Id: <1602533402-14795-9-git-send-email-viacheslavo@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> References: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> Subject: [dpdk-dev] [PATCH v4 8/9] net/mlx5: register multiple pool for Rx queue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The split feature for receiving packets was added to the mlx5 PMD, now Rx queue can receive the data to the buffers belonging to the different pools and the memory of all the involved pool must be registered for DMA operations in order to allow hardware to store the data. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_mr.c | 3 +++ drivers/net/mlx5/mlx5_trigger.c | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c index dbcf0aa..c308ecc 100644 --- a/drivers/net/mlx5/mlx5_mr.c +++ b/drivers/net/mlx5/mlx5_mr.c @@ -536,6 +536,9 @@ struct mr_update_mp_data { .ret = 0, }; + DRV_LOG(DEBUG, "Port %u Rx queue registering mp %s " + "having %u chunks.", dev->data->port_id, + mp->name, mp->nb_mem_chunks); rte_mempool_mem_iter(mp, mlx5_mr_update_mp_cb, &data); if (data.ret < 0 && rte_errno == ENXIO) { /* Mempool may have externally allocated memory. */ diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c index e72e5fb..643e10f 100644 --- a/drivers/net/mlx5/mlx5_trigger.c +++ b/drivers/net/mlx5/mlx5_trigger.c @@ -145,18 +145,22 @@ dev->data->port_id, priv->sh->device_attr.max_sge); for (i = 0; i != priv->rxqs_n; ++i) { struct mlx5_rxq_ctrl *rxq_ctrl = mlx5_rxq_get(dev, i); - struct rte_mempool *mp; if (!rxq_ctrl) continue; if (rxq_ctrl->type == MLX5_RXQ_TYPE_STANDARD) { - /* Pre-register Rx mempool. */ - mp = mlx5_rxq_mprq_enabled(&rxq_ctrl->rxq) ? - rxq_ctrl->rxq.mprq_mp : rxq_ctrl->rxq.mp; - DRV_LOG(DEBUG, "Port %u Rx queue %u registering mp %s" - " having %u chunks.", dev->data->port_id, - rxq_ctrl->rxq.idx, mp->name, mp->nb_mem_chunks); - mlx5_mr_update_mp(dev, &rxq_ctrl->rxq.mr_ctrl, mp); + /* Pre-register Rx mempools. */ + if (mlx5_rxq_mprq_enabled(&rxq_ctrl->rxq)) { + mlx5_mr_update_mp(dev, &rxq_ctrl->rxq.mr_ctrl, + rxq_ctrl->rxq.mprq_mp); + } else { + uint32_t s; + + for (s = 0; s < rxq_ctrl->rxq.rxseg_n; s++) + mlx5_mr_update_mp + (dev, &rxq_ctrl->rxq.mr_ctrl, + rxq_ctrl->rxq.rxseg[s].mp); + } ret = rxq_alloc_elts(rxq_ctrl); if (ret) goto error; From patchwork Mon Oct 12 20:10:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 80409 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0D89CA04B6; Mon, 12 Oct 2020 22:13:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5046F1DA08; Mon, 12 Oct 2020 22:10:37 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id D356A1D9E6 for ; Mon, 12 Oct 2020 22:10:30 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@nvidia.com) with SMTP; 12 Oct 2020 23:10:26 +0300 Received: from nvidia.com (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09CKADfH013670; Mon, 12 Oct 2020 23:10:26 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: thomasm@monjalon.net, stephen@networkplumber.org, ferruh.yigit@intel.com, olivier.matz@6wind.com, jerinjacobk@gmail.com, maxime.coquelin@redhat.com, david.marchand@redhat.com, arybchenko@solarflare.com Date: Mon, 12 Oct 2020 20:10:02 +0000 Message-Id: <1602533402-14795-10-git-send-email-viacheslavo@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> References: <1602533402-14795-1-git-send-email-viacheslavo@nvidia.com> Subject: [dpdk-dev] [PATCH v4 9/9] net/mlx5: update Rx datapath to support split X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Only the regular rx_burst routine is updated to support split, because the vectorized ones does not support scatter and MPRQ does not support split at all. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_rxq.c | 11 +++++------ drivers/net/mlx5/mlx5_rxtx.c | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 4ec4677..2ebb265 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -210,9 +210,10 @@ /* Iterate on segments. */ for (i = 0; (i != elts_n); ++i) { + struct rte_eth_rxseg *seg = &rxq_ctrl->rxq.rxseg[i % sges_n]; struct rte_mbuf *buf; - buf = rte_pktmbuf_alloc(rxq_ctrl->rxq.mp); + buf = rte_pktmbuf_alloc(seg->mp); if (buf == NULL) { DRV_LOG(ERR, "port %u empty mbuf pool", PORT_ID(rxq_ctrl->priv)); @@ -225,12 +226,10 @@ MLX5_ASSERT(rte_pktmbuf_data_len(buf) == 0); MLX5_ASSERT(rte_pktmbuf_pkt_len(buf) == 0); MLX5_ASSERT(!buf->next); - /* Only the first segment keeps headroom. */ - if (i % sges_n) - SET_DATA_OFF(buf, 0); + SET_DATA_OFF(buf, seg->offset); PORT(buf) = rxq_ctrl->rxq.port_id; - DATA_LEN(buf) = rte_pktmbuf_tailroom(buf); - PKT_LEN(buf) = DATA_LEN(buf); + DATA_LEN(buf) = seg->length; + PKT_LEN(buf) = seg->length; NB_SEGS(buf) = 1; (*rxq_ctrl->rxq.elts)[i] = buf; } diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index b530ff4..dd84249 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -1334,7 +1334,8 @@ enum mlx5_txcmp_code { rte_prefetch0(seg); rte_prefetch0(cqe); rte_prefetch0(wqe); - rep = rte_mbuf_raw_alloc(rxq->mp); + /* Allocate the buf from the same pool. */ + rep = rte_mbuf_raw_alloc(seg->pool); if (unlikely(rep == NULL)) { ++rxq->stats.rx_nombuf; if (!pkt) {