From patchwork Wed Jul 27 10:36:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 114270 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru 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 A0595A00C4; Wed, 27 Jul 2022 12:37:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F15694114A; Wed, 27 Jul 2022 12:37:12 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id D1445400D7; Wed, 27 Jul 2022 12:37:11 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Lt9Bj4h3TzkXW4; Wed, 27 Jul 2022 18:34:37 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Jul 2022 18:37:10 +0800 From: Dongdong Liu To: , , , CC: , Chengwen Feng , Dongdong Liu , Yisen Zhuang , Lijun Ou , "Min Hu (Connor)" Subject: [PATCH 1/8] net/hns3: fix segment fault when using SVE xmit Date: Wed, 27 Jul 2022 18:36:09 +0800 Message-ID: <20220727103616.18596-2-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220727103616.18596-1-liudongdong3@huawei.com> References: <20220727103616.18596-1-liudongdong3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500017.china.huawei.com (7.221.188.110) 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 From: Chengwen Feng Currently, the number of Tx send bytes is obtained by accumulating the length of the batch 'mbuf' packets of the current loop cycle. Unfortunately, it uses svcntd (which means all lane, regardless of whether the corresponding lane is valid) which may lead to overflow, and thus refers to an invalid mbuf. Because the SVE xmit algorithm applies only to a single mbuf, the mbuf's data_len is equal pkt_len, so this patch fixes it by using svaddv_u64(svbool_t pg, svuint64_t data_len) which only adds valid lanes. Fixes: fdcd6a3e0246 ("net/hns3: add bytes stats") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_rxtx_vec_sve.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c index be1fdbcdf0..b0dfb052bb 100644 --- a/drivers/net/hns3/hns3_rxtx_vec_sve.c +++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c @@ -435,9 +435,8 @@ hns3_tx_fill_hw_ring_sve(struct hns3_tx_queue *txq, offsets, svdup_n_u64(valid_bit)); /* Increment bytes counter */ - uint32_t idx; - for (idx = 0; idx < svcntd(); idx++) - txq->basic_stats.bytes += pkts[idx]->pkt_len; + txq->basic_stats.bytes += + (svaddv_u64(pg, data_len) >> HNS3_UINT16_BIT); /* update index for next loop */ i += svcntd();