From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 20B991B168 for ; Wed, 10 Jan 2018 07:14:12 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2018 22:14:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,338,1511856000"; d="scan'208";a="8624573" Received: from dpdk26.sh.intel.com ([10.67.110.152]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2018 22:14:11 -0800 From: Wenzhuo Lu To: dev@dpdk.org Cc: Jingjing Wu Date: Wed, 10 Jan 2018 14:15:53 +0800 Message-Id: <1515564961-79227-7-git-send-email-wenzhuo.lu@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1515564961-79227-1-git-send-email-wenzhuo.lu@intel.com> References: <1515388414-16214-1-git-send-email-wenzhuo.lu@intel.com> <1515564961-79227-1-git-send-email-wenzhuo.lu@intel.com> Subject: [dpdk-dev] [PATCH v6 06/14] net/avf: support stats X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jan 2018 06:14:13 -0000 From: Jingjing Wu Signed-off-by: Jingjing Wu --- doc/guides/nics/features/avf.ini | 1 + drivers/net/avf/avf.h | 2 ++ drivers/net/avf/avf_ethdev.c | 27 +++++++++++++++++++++++++++ drivers/net/avf/avf_vchnl.c | 27 +++++++++++++++++++++++++++ 4 files changed, 57 insertions(+) diff --git a/doc/guides/nics/features/avf.ini b/doc/guides/nics/features/avf.ini index 77e4f53..af84599 100644 --- a/doc/guides/nics/features/avf.ini +++ b/doc/guides/nics/features/avf.ini @@ -17,6 +17,7 @@ VLAN offload = Y L3 checksum offload = Y L4 checksum offload = Y Packet type parsing = Y +Basic stats = Y Multiprocess aware = Y BSD nic_uio = Y Linux UIO = Y diff --git a/drivers/net/avf/avf.h b/drivers/net/avf/avf.h index c97b2ee..680b117 100644 --- a/drivers/net/avf/avf.h +++ b/drivers/net/avf/avf.h @@ -204,4 +204,6 @@ int avf_switch_queue(struct avf_adapter *adapter, uint16_t qid, void avf_add_del_all_mac_addr(struct avf_adapter *adapter, bool add); int avf_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete); +int avf_query_stats(struct avf_adapter *adapter, + struct virtchnl_eth_stats **pstats); #endif /* _AVF_ETHDEV_H_ */ diff --git a/drivers/net/avf/avf_ethdev.c b/drivers/net/avf/avf_ethdev.c index 7f7ddf9..bf6251b 100644 --- a/drivers/net/avf/avf_ethdev.c +++ b/drivers/net/avf/avf_ethdev.c @@ -40,6 +40,8 @@ static void avf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); static const uint32_t *avf_dev_supported_ptypes_get(struct rte_eth_dev *dev); +static int avf_dev_stats_get(struct rte_eth_dev *dev, + struct rte_eth_stats *stats); int avf_logtype_init; int avf_logtype_driver; @@ -56,6 +58,7 @@ static void avf_dev_info_get(struct rte_eth_dev *dev, .dev_infos_get = avf_dev_info_get, .dev_supported_ptypes_get = avf_dev_supported_ptypes_get, .link_update = avf_dev_link_update, + .stats_get = avf_dev_stats_get, .rx_queue_start = avf_dev_rx_queue_start, .rx_queue_stop = avf_dev_rx_queue_stop, .tx_queue_start = avf_dev_tx_queue_start, @@ -478,6 +481,30 @@ static void avf_dev_info_get(struct rte_eth_dev *dev, } static int +avf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) +{ + struct avf_adapter *adapter = + AVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); + struct virtchnl_eth_stats *pstats = NULL; + int ret; + + ret = avf_query_stats(adapter, &pstats); + if (ret == 0) { + stats->ipackets = pstats->rx_unicast + pstats->rx_multicast + + pstats->rx_broadcast; + stats->opackets = pstats->tx_broadcast + pstats->tx_multicast + + pstats->tx_unicast; + stats->imissed = pstats->rx_discards; + stats->oerrors = pstats->tx_errors + pstats->tx_discards; + stats->ibytes = pstats->rx_bytes; + stats->obytes = pstats->tx_bytes; + } else { + PMD_DRV_LOG(ERR, "Get statistics failed"); + } + return -EIO; +} + +static int avf_check_vf_reset_done(struct avf_hw *hw) { int i, reset; diff --git a/drivers/net/avf/avf_vchnl.c b/drivers/net/avf/avf_vchnl.c index f5da601..e26527f 100644 --- a/drivers/net/avf/avf_vchnl.c +++ b/drivers/net/avf/avf_vchnl.c @@ -693,3 +693,30 @@ begin = next_begin; } while (begin < AVF_NUM_MACADDR_MAX); } + +int +avf_query_stats(struct avf_adapter *adapter, + struct virtchnl_eth_stats **pstats) +{ + struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter); + struct virtchnl_queue_select q_stats; + struct avf_cmd_info args; + int err; + + memset(&q_stats, 0, sizeof(q_stats)); + q_stats.vsi_id = vf->vsi_res->vsi_id; + args.ops = VIRTCHNL_OP_GET_STATS; + args.in_args = (uint8_t *)&q_stats; + args.in_args_size = sizeof(q_stats); + args.out_buffer = vf->aq_resp; + args.out_size = AVF_AQ_BUF_SZ; + + err = avf_execute_vf_cmd(adapter, &args); + if (err) { + PMD_DRV_LOG(ERR, "fail to execute command OP_GET_STATS"); + *pstats = NULL; + return err; + } + *pstats = (struct virtchnl_eth_stats *)args.out_buffer; + return 0; +} -- 1.9.3