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 0118BA0524; Mon, 31 May 2021 14:09:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8654640040; Mon, 31 May 2021 14:09:38 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 280D44003F for ; Mon, 31 May 2021 14:09:36 +0200 (CEST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Ftv9d1ZPRz1BGlD for ; Mon, 31 May 2021 20:04:53 +0800 (CST) Received: from dggpemm500008.china.huawei.com (7.185.36.136) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 20:09:28 +0800 Received: from localhost (10.174.243.60) by dggpemm500008.china.huawei.com (7.185.36.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 20:09:27 +0800 From: wangyunjian To: CC: , , , Yunjian Wang Date: Mon, 31 May 2021 20:09:10 +0800 Message-ID: <4ebfe0d38b335a437edc9c58368153d005f562ce.1622460655.git.wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.243.60] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500008.china.huawei.com (7.185.36.136) X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] kni: fix wrong mbuf alloc count in kni_allocate_mbufs 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 Sender: "dev" From: Yunjian Wang In kni_allocate_mbufs(), we alloc mbuf for alloc_q as this code. allocq_free = (kni->alloc_q->read - kni->alloc_q->write - 1) \ & (MAX_MBUF_BURST_NUM - 1); The value of allocq_free maybe zero (e.g 32 & (32 - 1) = 0), and it will not fill the alloc_q. When the alloc_q's free count is zero, it will drop the packet in kernel kni. In this patch, we set the allocq_free as the min between MAX_MBUF_BURST_NUM and the free count of the alloc_q. Signed-off-by: Cheng Liu Signed-off-by: Yunjian Wang --- lib/kni/rte_kni.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c index 9dae6a8d7c..20d8f20cef 100644 --- a/lib/kni/rte_kni.c +++ b/lib/kni/rte_kni.c @@ -677,8 +677,9 @@ kni_allocate_mbufs(struct rte_kni *kni) return; } - allocq_free = (kni->alloc_q->read - kni->alloc_q->write - 1) - & (MAX_MBUF_BURST_NUM - 1); + allocq_free = kni_fifo_free_count(kni->alloc_q); + allocq_free = (allocq_free > MAX_MBUF_BURST_NUM) ? + MAX_MBUF_BURST_NUM : allocq_free; for (i = 0; i < allocq_free; i++) { pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool); if (unlikely(pkts[i] == NULL)) { -- 2.23.0