From patchwork Tue Aug 15 11:10:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lihuisong (C)" X-Patchwork-Id: 130334 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7B6334306F; Tue, 15 Aug 2023 13:13:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA84743266; Tue, 15 Aug 2023 13:13:34 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id D2D3840E25 for ; Tue, 15 Aug 2023 13:13:29 +0200 (CEST) Received: from kwepemm600004.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RQ7p65fgsztS9m; Tue, 15 Aug 2023 19:09:50 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 15 Aug 2023 19:13:26 +0800 From: Huisong Li To: CC: , , , , Subject: [PATCH v1 1/3] ethdev: introduce maximum Rx buffer size Date: Tue, 15 Aug 2023 19:10:32 +0800 Message-ID: <20230815111034.22887-2-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230815111034.22887-1-lihuisong@huawei.com> References: <20230808040234.12947-1-lihuisong@huawei.com> <20230815111034.22887-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The Rx buffer size stands for the size hardware supported to receive packets in one mbuf. The "min_rx_bufsize" is the minimum buffer hardware supported in Rx. Actually, some engines also have the maximum buffer specification, like, hns3. For these engines, the available data size of one mbuf in Rx also depends on the maximum buffer hardware supported. So introduce maximum Rx buffer size in struct rte_eth_dev_info to report user to avoid memory waste. And driver should accept it and just pass maximum buffer hardware supported to hardware if application specifies the Rx buffer size is greater than the maximum buffer. Signed-off-by: Huisong Li --- lib/ethdev/rte_ethdev.c | 7 +++++++ lib/ethdev/rte_ethdev.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 0840d2b594..9985bd3049 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -2068,6 +2068,7 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; struct rte_eth_rxconf local_conf; + uint32_t vld_bufsize; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; @@ -2105,6 +2106,11 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, return ret; mbp_buf_size = rte_pktmbuf_data_room_size(mp); + vld_bufsize = mbp_buf_size - RTE_PKTMBUF_HEADROOM; + if (vld_bufsize > dev_info.max_rx_bufsize) + RTE_ETHDEV_LOG(WARNING, + "Ethdev port_id=%u Rx buffer size (%u) is greater than the maximum buffer size (%u) driver supported.\n", + port_id, vld_bufsize, dev_info.max_rx_bufsize); } else if (rx_conf != NULL && rx_conf->rx_nseg > 0) { const struct rte_eth_rxseg_split *rx_seg; uint16_t n_seg; @@ -3689,6 +3695,7 @@ rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info) dev_info->min_mtu = RTE_ETHER_MIN_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN; dev_info->max_mtu = UINT16_MAX; + dev_info->max_rx_bufsize = UINT32_MAX; if (*dev->dev_ops->dev_infos_get == NULL) return -ENOTSUP; diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 04a2564f22..9fdf2c75ee 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -1724,6 +1724,12 @@ struct rte_eth_dev_info { uint16_t max_mtu; /**< Maximum MTU allowed */ const uint32_t *dev_flags; /**< Device flags */ uint32_t min_rx_bufsize; /**< Minimum size of Rx buffer. */ + /** + * Maximum size of Rx buffer. Driver should accept it and just pass + * this value to HW if application specifies the Rx buffer size is + * greater than this value. + */ + uint32_t max_rx_bufsize; uint32_t max_rx_pktlen; /**< Maximum configurable length of Rx pkt. */ /** Maximum configurable size of LRO aggregated packet. */ uint32_t max_lro_pkt_size;