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 2C38CA00C4; Mon, 25 Jul 2022 06:15:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4CEF842826; Mon, 25 Jul 2022 06:15:45 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id 31D724021E for ; Mon, 25 Jul 2022 06:15:41 +0200 (CEST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Lrms32LbVzGpBN; Mon, 25 Jul 2022 12:14:31 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 25 Jul 2022 12:15:39 +0800 From: Chengwen Feng To: , CC: , , , , Subject: [PATCH v2 2/3] net/bonding: support Tx prepare fail stats Date: Mon, 25 Jul 2022 12:08:41 +0800 Message-ID: <20220725040842.35027-3-fengchengwen@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220725040842.35027-1-fengchengwen@huawei.com> References: <1619171202-28486-2-git-send-email-tangchengchang@huawei.com> <20220725040842.35027-1-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500024.china.huawei.com (7.185.36.10) 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 If the Tx prepare fails, the bonding driver will free the corresponding packets internally, and only the packets of the Tx prepare OK are xmit. In this patch, the number of Tx prepare fails will be counted, the result is added in the 'struct rte_eth_stats' oerrors field. Signed-off-by: Chengwen Feng --- drivers/net/bonding/eth_bond_private.h | 7 +++++++ drivers/net/bonding/rte_eth_bond_pmd.c | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/net/bonding/eth_bond_private.h b/drivers/net/bonding/eth_bond_private.h index 9996f6673c..aa33fa0043 100644 --- a/drivers/net/bonding/eth_bond_private.h +++ b/drivers/net/bonding/eth_bond_private.h @@ -72,6 +72,13 @@ struct bond_tx_queue { /**< Number of TX descriptors available for the queue */ struct rte_eth_txconf tx_conf; /**< Copy of TX configuration structure for queue */ + + /* + * The following fields are statistical value, and maybe update + * at runtime, so start with one new cache line. + */ + uint64_t prepare_fails __rte_cache_aligned; + /**< Tx prepare fail cnt */ }; /** Bonded slave devices structure */ diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index c32c7e6c6c..84fd0e5a73 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -602,6 +602,7 @@ bond_ethdev_tx_wrap(struct bond_tx_queue *bd_tx_q, uint16_t slave_port_id, rte_pktmbuf_free(fail_pkts[i]); } + bd_tx_q->prepare_fails += fail_cnt; if (fail_cnt == nb_pkts) return nb_pkts; tx_burst: @@ -2399,6 +2400,8 @@ bond_ethdev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, bd_tx_q->nb_tx_desc = nb_tx_desc; memcpy(&(bd_tx_q->tx_conf), tx_conf, sizeof(bd_tx_q->tx_conf)); + bd_tx_q->prepare_fails = 0; + dev->data->tx_queues[tx_queue_id] = bd_tx_q; return 0; @@ -2609,6 +2612,7 @@ bond_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct bond_dev_private *internals = dev->data->dev_private; struct rte_eth_stats slave_stats; + struct bond_tx_queue *bd_tx_q; int i, j; for (i = 0; i < internals->slave_count; i++) { @@ -2630,7 +2634,12 @@ bond_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) stats->q_obytes[j] += slave_stats.q_obytes[j]; stats->q_errors[j] += slave_stats.q_errors[j]; } + } + for (i = 0; i < dev->data->nb_tx_queues; i++) { + bd_tx_q = (struct bond_tx_queue *)dev->data->tx_queues[i]; + if (bd_tx_q) + stats->oerrors += bd_tx_q->prepare_fails; } return 0; @@ -2640,6 +2649,7 @@ static int bond_ethdev_stats_reset(struct rte_eth_dev *dev) { struct bond_dev_private *internals = dev->data->dev_private; + struct bond_tx_queue *bd_tx_q; int i; int err; int ret; @@ -2650,6 +2660,12 @@ bond_ethdev_stats_reset(struct rte_eth_dev *dev) err = ret; } + for (i = 0; i < dev->data->nb_tx_queues; i++) { + bd_tx_q = (struct bond_tx_queue *)dev->data->tx_queues[i]; + if (bd_tx_q) + bd_tx_q->prepare_fails = 0; + } + return err; } -- 2.33.0