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 C3AF4A00C3; Tue, 19 Apr 2022 09:49:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EAAEF4281E; Tue, 19 Apr 2022 09:48:40 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 458B84281B for ; Tue, 19 Apr 2022 09:48:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650354519; x=1681890519; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0+5q1CcVdwWRcMvgBmLEHo3hrJBSnjcR0D9gDk2Z7AQ=; b=UMkmkhIwfuv5YIR8wg8GE+C5GoyfvbUqFTy1UKI9DnilMv2lNOOmrudB 8Z9qdW6owYM9Cg6UJsx+9c4+l29TQUnDkQMKmURiFD+LkYjUUvJdl5G+q TzIpseTmoglzrwOC6FeNMaHDB8o9VohXC5biHq1VgObhd90JvVZ0TP5Mu +a0088lMJbuNoEGjNxOfyt7O5rFFjO5Tn5PItCRWLLAPCSn+nvImJbaG4 nINxOYHgedWxWr4yk/cISrOfi4EroXxuJaIluxKHr0OPqHYIw1r2pO8cS sVIIj0ALSCDrLF6t0REcAY31K3e7wWXTaLpBOclsbD+E9u6r2o+30B+Un Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10321"; a="244288798" X-IronPort-AV: E=Sophos;i="5.90,272,1643702400"; d="scan'208";a="244288798" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2022 00:48:38 -0700 X-IronPort-AV: E=Sophos;i="5.90,272,1643702400"; d="scan'208";a="575972044" Received: from intel-cd-odc-kevin.cd.intel.com ([10.240.178.195]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2022 00:48:35 -0700 From: Kevin Liu To: dev@dpdk.org Cc: qiming.yang@intel.com, qi.z.zhang@intel.com, stevex.yang@intel.com, Kevin Liu Subject: [PATCH v4 20/23] net/ice: add extended stats Date: Tue, 19 Apr 2022 15:46:11 +0000 Message-Id: <20220419154614.476154-21-kevinx.liu@intel.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220419154614.476154-1-kevinx.liu@intel.com> References: <20220413171030.2231163-1-kevinx.liu@intel.com> <20220419154614.476154-1-kevinx.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Add implementation of xstats() functions in DCF PMD. Signed-off-by: Kevin Liu --- drivers/net/ice/ice_dcf.h | 23 +++++++++- drivers/net/ice/ice_dcf_ethdev.c | 75 ++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/drivers/net/ice/ice_dcf.h b/drivers/net/ice/ice_dcf.h index 78ab23aaa6..8bdad679b1 100644 --- a/drivers/net/ice/ice_dcf.h +++ b/drivers/net/ice/ice_dcf.h @@ -16,7 +16,11 @@ #include "ice_logs.h" #define ICE_DCF_RXTX_QUEUE_CHUNKS_NUM 2 - +/* ICE_DCF_DEV_PRIVATE_TO */ +#define ICE_DCF_DEV_PRIVATE_TO_ADAPTER(adapter) \ + ((struct ice_dcf_adapter *)adapter) +#define ICE_DCF_DEV_PRIVATE_TO_VF(adapter) \ + (&((struct ice_dcf_adapter *)adapter)->vf) struct dcf_virtchnl_cmd { TAILQ_ENTRY(dcf_virtchnl_cmd) next; @@ -81,6 +85,23 @@ struct ice_dcf_qv_map { uint16_t vector_id; }; +struct ice_dcf_eth_stats { + u64 rx_bytes; /* gorc */ + u64 rx_unicast; /* uprc */ + u64 rx_multicast; /* mprc */ + u64 rx_broadcast; /* bprc */ + u64 rx_discards; /* rdpc */ + u64 rx_unknown_protocol; /* rupp */ + u64 tx_bytes; /* gotc */ + u64 tx_unicast; /* uptc */ + u64 tx_multicast; /* mptc */ + u64 tx_broadcast; /* bptc */ + u64 tx_discards; /* tdpc */ + u64 tx_errors; /* tepc */ + u64 rx_no_desc; /* repc */ + u64 rx_errors; /* repc */ +}; + struct ice_dcf_hw { struct iavf_hw avf; diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index e46c8405aa..a4f0ec36a1 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -47,6 +47,30 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev); static int ice_dcf_dev_uninit(struct rte_eth_dev *eth_dev); +struct rte_ice_dcf_xstats_name_off { + char name[RTE_ETH_XSTATS_NAME_SIZE]; + unsigned int offset; +}; + +static const struct rte_ice_dcf_xstats_name_off rte_ice_dcf_stats_strings[] = { + {"rx_bytes", offsetof(struct ice_dcf_eth_stats, rx_bytes)}, + {"rx_unicast_packets", offsetof(struct ice_dcf_eth_stats, rx_unicast)}, + {"rx_multicast_packets", offsetof(struct ice_dcf_eth_stats, rx_multicast)}, + {"rx_broadcast_packets", offsetof(struct ice_dcf_eth_stats, rx_broadcast)}, + {"rx_dropped_packets", offsetof(struct ice_dcf_eth_stats, rx_discards)}, + {"rx_unknown_protocol_packets", offsetof(struct ice_dcf_eth_stats, + rx_unknown_protocol)}, + {"tx_bytes", offsetof(struct ice_dcf_eth_stats, tx_bytes)}, + {"tx_unicast_packets", offsetof(struct ice_dcf_eth_stats, tx_unicast)}, + {"tx_multicast_packets", offsetof(struct ice_dcf_eth_stats, tx_multicast)}, + {"tx_broadcast_packets", offsetof(struct ice_dcf_eth_stats, tx_broadcast)}, + {"tx_dropped_packets", offsetof(struct ice_dcf_eth_stats, tx_discards)}, + {"tx_error_packets", offsetof(struct ice_dcf_eth_stats, tx_errors)}, +}; + +#define ICE_DCF_NB_XSTATS (sizeof(rte_ice_dcf_stats_strings) / \ + sizeof(rte_ice_dcf_stats_strings[0])) + static uint16_t ice_dcf_recv_pkts(__rte_unused void *rx_queue, __rte_unused struct rte_mbuf **bufs, @@ -1610,6 +1634,54 @@ ice_dcf_stats_reset(struct rte_eth_dev *dev) return 0; } +static int ice_dcf_xstats_get_names(__rte_unused struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, + __rte_unused unsigned int limit) +{ + unsigned int i; + + if (xstats_names != NULL) + for (i = 0; i < ICE_DCF_NB_XSTATS; i++) { + snprintf(xstats_names[i].name, + sizeof(xstats_names[i].name), + "%s", rte_ice_dcf_stats_strings[i].name); + } + return ICE_DCF_NB_XSTATS; +} + +static int ice_dcf_xstats_get(struct rte_eth_dev *dev, + struct rte_eth_xstat *xstats, unsigned int n) +{ + int ret; + unsigned int i; + struct ice_dcf_adapter *adapter = + ICE_DCF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); + struct ice_dcf_hw *hw = &adapter->real_hw; + struct virtchnl_eth_stats *postats = &hw->eth_stats_offset; + struct virtchnl_eth_stats pnstats; + + if (n < ICE_DCF_NB_XSTATS) + return ICE_DCF_NB_XSTATS; + + ret = ice_dcf_query_stats(hw, &pnstats); + if (ret != 0) + return 0; + + if (!xstats) + return 0; + + ice_dcf_update_stats(postats, &pnstats); + + /* loop over xstats array and values from pstats */ + for (i = 0; i < ICE_DCF_NB_XSTATS; i++) { + xstats[i].id = i; + xstats[i].value = *(uint64_t *)(((char *)&pnstats) + + rte_ice_dcf_stats_strings[i].offset); + } + + return ICE_DCF_NB_XSTATS; +} + static void ice_dcf_free_repr_info(struct ice_dcf_adapter *dcf_adapter) { @@ -1881,6 +1953,9 @@ static const struct eth_dev_ops ice_dcf_eth_dev_ops = { .link_update = ice_dcf_link_update, .stats_get = ice_dcf_stats_get, .stats_reset = ice_dcf_stats_reset, + .xstats_get = ice_dcf_xstats_get, + .xstats_get_names = ice_dcf_xstats_get_names, + .xstats_reset = ice_dcf_stats_reset, .promiscuous_enable = ice_dcf_dev_promiscuous_enable, .promiscuous_disable = ice_dcf_dev_promiscuous_disable, .allmulticast_enable = ice_dcf_dev_allmulticast_enable, -- 2.33.1