From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1871A41B96 for ; Wed, 1 Feb 2023 03:34:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0DDF9427F5; Wed, 1 Feb 2023 03:34:45 +0100 (CET) Received: from smtpbguseast1.qq.com (smtpbguseast1.qq.com [54.204.34.129]) by mails.dpdk.org (Postfix) with ESMTP id BA0C54021F; Wed, 1 Feb 2023 03:34:41 +0100 (CET) X-QQ-mid: Yeas52t1675218874t477t29807 Received: from 7082A6556EBF4E69829842272A565F7C (jiawenwu@trustnetic.com [183.129.236.74]) X-QQ-SSF: 00400000000000F0FK9000000000000 From: =?utf-8?b?Smlhd2VuIFd1?= To: "'Ferruh Yigit'" , Cc: References: <20230118060039.3074016-1-jiawenwu@trustnetic.com> <20230118060039.3074016-2-jiawenwu@trustnetic.com> In-Reply-To: Subject: RE: [PATCH 1/8] net/txgbe: fix Rx buffer size in configure register Date: Wed, 1 Feb 2023 10:34:27 +0800 Message-ID: <026901d935e5$b4d52230$1e7f6690$@trustnetic.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Content-Language: zh-cn Thread-Index: AQIBtVZXYxbb1ShePjndn/GGR7Jz2QEZpFqDAThJI6muVc/TgA== X-QQ-SENDSIZE: 520 Feedback-ID: Yeas:trustnetic.com:qybglogicsvr:qybglogicsvr5 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On Friday, January 27, 2023 11:36 PM, Ferruh Yigit wrote: > On 1/18/2023 6:00 AM, Jiawen Wu wrote: > > When round up buffer size to 1K, to configure the register, hardware > > will receive packets exceeding the buffer size in LRO mode. It will > > cause a segment fault in the receive function. > > > > Fixes: be797cbf4582 ("net/txgbe: add Rx and Tx init") > > Cc: stable@dpdk.org > > > > Signed-off-by: Jiawen Wu > > --- > > drivers/net/txgbe/txgbe_rxtx.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/net/txgbe/txgbe_rxtx.c > > b/drivers/net/txgbe/txgbe_rxtx.c index ac1bba08a3..ae70ca3beb 100644 > > --- a/drivers/net/txgbe/txgbe_rxtx.c > > +++ b/drivers/net/txgbe/txgbe_rxtx.c > > @@ -4382,7 +4382,7 @@ txgbe_dev_rx_init(struct rte_eth_dev *dev) > > */ > > buf_size =3D (uint16_t)(rte_pktmbuf_data_room_size(rxq->mb_pool) = - > > RTE_PKTMBUF_HEADROOM); > > - buf_size =3D ROUND_UP(buf_size, 0x1 << 10); > > + buf_size =3D ROUND_DOWN(buf_size, 0x1 << 10); > > srrctl |=3D TXGBE_RXCFG_PKTLEN(buf_size); > > >=20 > What if 'buf_size' is less than 1K, won't 'ROUND_DOWN' make it 0, and = I assume > setting 0 to register may cause problem. >=20 It is indeed a problem, I will fix it. > And according to the code comment for 'buf_size' [1], buffer size = can't be more than > 16K, but technically 'buf_size' can be more than 16K. > Does the HW constrain values larger than 16K? If not the 'buf_size' > value needs to be checked against the 16K limit. >=20 There is a macro that defines the conversion to limit 16K. #define PKTLEN(v) ROUND_OVER(v, 14, 10) #define ROUND_OVER(x, maxbits, unitbits) \ ((x) >=3D 1 << (maxbits) ? 0 : (x) >> (unitbits)) >=20 >=20 >=20 > [1] > /* > * Configure the RX buffer size in the PKTLEN field of > * the RXCFG register of the queue. > * The value is in 1 KB resolution. Valid values can be from > * 1 KB to 16 KB. > */ >=20