From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3AB0AA04EF for ; Tue, 2 Jun 2020 03:33:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2F1091BFCA; Tue, 2 Jun 2020 03:33:46 +0200 (CEST) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id 632811BF44 for ; Tue, 2 Jun 2020 03:33:44 +0200 (CEST) Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 2EDD8B3892105084046E for ; Tue, 2 Jun 2020 09:29:46 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Tue, 2 Jun 2020 09:29:38 +0800 From: "Wei Hu (Xavier)" To: CC: , Date: Tue, 2 Jun 2020 09:28:05 +0800 Message-ID: <1591061288-39518-4-git-send-email-xavier.huwei@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1591061288-39518-1-git-send-email-xavier.huwei@huawei.com> References: <1591061288-39518-1-git-send-email-xavier.huwei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-stable] [PATCH 19.11 v2 3/5] net/hns3: remove one IO barrier in Rx X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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 Sender: "stable" [ upstream commit 5cf7a75b2c3b33c4c3579eba6716a4c7ca02ec5b ] When receiving a packet, hns3 hardware network engine firstly writes the packet content to the memory pointed by the 'addr' field of the Rx Buffer Descriptor, secondly fills the result of parsing the packet include the valid field into the Rx Buffer Descriptor in one write operation, and thirdly writes the number of the Buffer Descriptor not processed by the driver to the HNS3_RING_RX_FBDNUM_REG register. This patch optimizes the Rx performance by removing one rte_io_rmb call in the '.rx_pkt_burst' ops implementation function named hns3_recv_pkts. The change as follows: 1. Driver no longer read HNS3_RING_RX_FBDNUM_REG register, so remove one rte_io_rmb call, and directly read the valid flag of Rx Buffer Descriptor to check whether the BD is ready. 2. Delete the non_vld_descs field from the statistic information of the hns3 driver because now it has become a common case that the valid flag of Rx Buffer Descriptor read by the driver is invalid. Signed-off-by: Chengwen Feng Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_rxtx.c | 12 +++--------- drivers/net/hns3/hns3_rxtx.h | 1 - drivers/net/hns3/hns3_stats.c | 3 --- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index af7972f..23bb115 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -1225,7 +1225,6 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, rxq->io_base = (void *)((char *)hw->io_base + HNS3_TQP_REG_OFFSET + idx * HNS3_TQP_REG_SIZE); rxq->rx_buf_len = hw->rx_buf_len; - rxq->non_vld_descs = 0; rxq->l2_errors = 0; rxq->pkt_len_errors = 0; rxq->l3_csum_erros = 0; @@ -1472,7 +1471,6 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) uint16_t pkt_len; uint16_t nb_rx; uint16_t rx_id; - int num; /* num of desc in ring */ int ret; nb_rx = 0; @@ -1486,15 +1484,11 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) last_seg = rxq->pkt_last_seg; sw_ring = rxq->sw_ring; - /* Get num of packets in descriptor ring */ - num = hns3_read_dev(rxq, HNS3_RING_RX_FBDNUM_REG); - while (nb_rx_bd < num && nb_rx < nb_pkts) { + while (nb_rx < nb_pkts) { rxdp = &rx_ring[rx_id]; bd_base_info = rte_le_to_cpu_32(rxdp->rx.bd_base_info); - if (unlikely(!hns3_get_bit(bd_base_info, HNS3_RXD_VLD_B))) { - rxq->non_vld_descs++; + if (unlikely(!hns3_get_bit(bd_base_info, HNS3_RXD_VLD_B))) break; - } nmb = rte_mbuf_raw_alloc(rxq->mb_pool); if (unlikely(nmb == NULL)) { @@ -1505,7 +1499,7 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) nb_rx_bd++; rxe = &sw_ring[rx_id]; rx_id++; - if (rx_id == rxq->nb_rx_desc) + if (unlikely(rx_id == rxq->nb_rx_desc)) rx_id = 0; rte_prefetch0(sw_ring[rx_id].mbuf); diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h index b751472..00b92cf 100644 --- a/drivers/net/hns3/hns3_rxtx.h +++ b/drivers/net/hns3/hns3_rxtx.h @@ -245,7 +245,6 @@ struct hns3_rx_queue { bool rx_deferred_start; /* don't start this queue in dev start */ bool configured; /* indicate if rx queue has been configured */ - uint64_t non_vld_descs; /* num of non valid rx descriptors */ uint64_t l2_errors; uint64_t pkt_len_errors; uint64_t l3_csum_erros; diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c index 6e13948..10cc757 100644 --- a/drivers/net/hns3/hns3_stats.c +++ b/drivers/net/hns3/hns3_stats.c @@ -219,8 +219,6 @@ static const struct hns3_xstats_name_offset hns3_reset_stats_strings[] = { /* The statistic of errors in Rx BD */ static const struct hns3_xstats_name_offset hns3_rx_bd_error_strings[] = { - {"NONE_VALIDATED_DESCRIPTORS", - HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(non_vld_descs)}, {"RX_PKT_LEN_ERRORS", HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(pkt_len_errors)}, {"L2_RX_ERRORS", @@ -512,7 +510,6 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) rxq = eth_dev->data->rx_queues[i]; if (rxq) { rxq->pkt_len_errors = 0; - rxq->non_vld_descs = 0; rxq->l2_errors = 0; rxq->l3_csum_erros = 0; rxq->l4_csum_erros = 0; -- 2.7.4