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 52967A054A; Mon, 5 Sep 2022 11:01:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3F41B42B71; Mon, 5 Sep 2022 11:01:12 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 3E0B0427FF; Mon, 5 Sep 2022 11:01:09 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MLj9R5zHczbnd1; Mon, 5 Sep 2022 16:58:35 +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; Mon, 5 Sep 2022 17:01:07 +0800 From: Dongdong Liu To: , , , , , , CC: , , , Subject: [PATCH RESEND 06/13] net/hns3: fix segment fault when using SVE xmit Date: Mon, 5 Sep 2022 16:59:32 +0800 Message-ID: <20220905085939.22236-7-liudongdong3@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20220905085939.22236-1-liudongdong3@huawei.com> References: <20220905085939.22236-1-liudongdong3@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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(); -- 2.22.0