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 15666460C2; Mon, 20 Jan 2025 12:16:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3BEFA40E44; Mon, 20 Jan 2025 12:15:11 +0100 (CET) Received: from lf-2-45.ptr.blmpb.com (lf-2-45.ptr.blmpb.com [101.36.218.45]) by mails.dpdk.org (Postfix) with ESMTP id 0E4D440E34 for ; Mon, 20 Jan 2025 12:15:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2403070942; d=yunsilicon.com; t=1737371703; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=RdG/AYX1bzy4SOT4pFS/RQtV7XT19KO33KyHMqhiB/4=; b=SshI/9f9zRoQ5gN9inRvr3DRKs/8m/G5mO4hmh0gGdMFd/MMrd6UG7a7rq1bzQIXj2dhQK sOWqXvd3478ueE7GT+zhszOnjC+jAWDX32tj/5OW8FJRv+mUZHsvvlFtoeC8HbuE12R/jy /uiqAKjuOCIjxaimsyYLmoewewX2pqnk2EZrScN/3bpft5MYxqr8z2tFrcT4uzWk9XMGrD Z5Shg/wgIj/7hIsveOjzkZeY8ltdvqlwdR/EMLtygEabGiy+IyVpwC9di82+UCf2LfKDur M7ReC/qYSvs7ha+GCnuaZelV5m4ygOK4GMhGOLzKdLpMpqQJPOW4CD1+OcYavw== Date: Mon, 20 Jan 2025 19:15:00 +0800 References: <20250120111431.1048479-1-wanry@yunsilicon.com> Cc: , , , , , , , , , Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [PATCH v6 13/15] net/xsc: add basic stats ops Mime-Version: 1.0 X-Mailer: git-send-email 2.25.1 X-Lms-Return-Path: To: From: "WanRenyong" Message-Id: <20250120111459.1048479-14-wanry@yunsilicon.com> Received: from ubuntu-liun.yunsilicon.com ([58.34.192.114]) by smtp.feishu.cn with ESMTPS; Mon, 20 Jan 2025 19:15:00 +0800 X-Original-From: WanRenyong In-Reply-To: <20250120111431.1048479-1-wanry@yunsilicon.com> 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 Implement xsc ethdev basic statatics ops. Signed-off-by: WanRenyong --- v6: * Remove unnecessary paren. * Add the feature of stats per queue in xsc.ini. --- doc/guides/nics/features/xsc.ini | 2 + drivers/net/xsc/xsc_ethdev.c | 75 ++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/doc/guides/nics/features/xsc.ini b/doc/guides/nics/features/xsc.ini index 772c6418c4..56e38a27d8 100644 --- a/doc/guides/nics/features/xsc.ini +++ b/doc/guides/nics/features/xsc.ini @@ -11,6 +11,8 @@ L3 checksum offload = Y L4 checksum offload = Y Inner L3 checksum = Y Inner L4 checksum = Y +Basic stats = Y +Stats per queue = Y Linux = Y ARMv8 = Y x86-64 = Y diff --git a/drivers/net/xsc/xsc_ethdev.c b/drivers/net/xsc/xsc_ethdev.c index d344714d79..63c64ce547 100644 --- a/drivers/net/xsc/xsc_ethdev.c +++ b/drivers/net/xsc/xsc_ethdev.c @@ -443,6 +443,79 @@ xsc_ethdev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, return 0; } +static int +xsc_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) +{ + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev); + uint32_t rxqs_n = priv->num_rq; + uint32_t txqs_n = priv->num_sq; + uint32_t i, idx; + struct xsc_rxq_data *rxq; + struct xsc_txq_data *txq; + + for (i = 0; i < rxqs_n; ++i) { + rxq = xsc_rxq_get(priv, i); + if (unlikely(rxq == NULL)) + continue; + + idx = rxq->idx; + if (idx < RTE_ETHDEV_QUEUE_STAT_CNTRS) { + stats->q_ipackets[idx] += rxq->stats.rx_pkts; + stats->q_ibytes[idx] += rxq->stats.rx_bytes; + stats->q_errors[idx] += rxq->stats.rx_errors + + rxq->stats.rx_nombuf; + } + stats->ipackets += rxq->stats.rx_pkts; + stats->ibytes += rxq->stats.rx_bytes; + stats->ierrors += rxq->stats.rx_errors; + stats->rx_nombuf += rxq->stats.rx_nombuf; + } + + for (i = 0; i < txqs_n; ++i) { + txq = xsc_txq_get(priv, i); + if (unlikely(txq == NULL)) + continue; + + idx = txq->idx; + if (idx < RTE_ETHDEV_QUEUE_STAT_CNTRS) { + stats->q_opackets[idx] += txq->stats.tx_pkts; + stats->q_obytes[idx] += txq->stats.tx_bytes; + stats->q_errors[idx] += txq->stats.tx_errors; + } + stats->opackets += txq->stats.tx_pkts; + stats->obytes += txq->stats.tx_bytes; + stats->oerrors += txq->stats.tx_errors; + } + + return 0; +} + +static int +xsc_ethdev_stats_reset(struct rte_eth_dev *dev) +{ + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev); + uint32_t rxqs_n = priv->num_rq; + uint32_t txqs_n = priv->num_sq; + uint32_t i; + struct xsc_rxq_data *rxq; + struct xsc_txq_data *txq; + + for (i = 0; i < rxqs_n; ++i) { + rxq = xsc_rxq_get(priv, i); + if (unlikely(rxq == NULL)) + continue; + memset(&rxq->stats, 0, sizeof(struct xsc_rxq_stats)); + } + for (i = 0; i < txqs_n; ++i) { + txq = xsc_txq_get(priv, i); + if (unlikely(txq == NULL)) + continue; + memset(&txq->stats, 0, sizeof(struct xsc_txq_stats)); + } + + return 0; +} + static int xsc_ethdev_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, uint32_t index) { @@ -474,6 +547,8 @@ const struct eth_dev_ops xsc_eth_dev_ops = { .dev_start = xsc_ethdev_start, .dev_stop = xsc_ethdev_stop, .dev_close = xsc_ethdev_close, + .stats_get = xsc_ethdev_stats_get, + .stats_reset = xsc_ethdev_stats_reset, .rx_queue_setup = xsc_ethdev_rx_queue_setup, .tx_queue_setup = xsc_ethdev_tx_queue_setup, .rx_queue_release = xsc_ethdev_rxq_release, -- 2.25.1