From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016ce01.pphosted.com (mx0b-0016ce01.pphosted.com [67.231.156.153]) by dpdk.org (Postfix) with ESMTP id 10E744AC7 for ; Fri, 8 Jul 2016 00:50:55 +0200 (CEST) Received: from pps.filterd (m0085408.ppops.net [127.0.0.1]) by mx0b-0016ce01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u67MfkXH014581; Thu, 7 Jul 2016 15:50:54 -0700 Received: from avcashub1.qlogic.com ([198.186.0.116]) by mx0b-0016ce01.pphosted.com with ESMTP id 23xckpcreg-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 07 Jul 2016 15:50:54 -0700 Received: from avluser05.qlc.com (10.1.113.115) by qlc.com (10.1.4.191) with Microsoft SMTP Server id 14.3.235.1; Thu, 7 Jul 2016 15:50:53 -0700 Received: (from rmody@localhost) by avluser05.qlc.com (8.14.4/8.14.4/Submit) id u67MorNJ028199; Thu, 7 Jul 2016 15:50:53 -0700 X-Authentication-Warning: avluser05.qlc.com: rmody set sender to rasesh.mody@qlogic.com using -f From: Rasesh Mody To: , CC: , , Rasesh Mody Date: Thu, 7 Jul 2016 15:50:39 -0700 Message-ID: <1467931839-28153-2-git-send-email-rasesh.mody@qlogic.com> X-Mailer: git-send-email 1.7.10.3 In-Reply-To: <1467931839-28153-1-git-send-email-rasesh.mody@qlogic.com> References: <1467931839-28153-1-git-send-email-rasesh.mody@qlogic.com> MIME-Version: 1.0 Content-Type: text/plain disclaimer: bypass X-Proofpoint-Virus-Version: vendor=nai engine=5800 definitions=8219 signatures=670665 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1607070216 Subject: [dpdk-dev] [PATCH 2/2] bnx2x: add support for xstats X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2016 22:50:56 -0000 This patch adds support for extended statistics for BNX2X PMD. Signed-off-by: Rasesh Mody --- doc/guides/nics/overview.rst | 2 +- drivers/net/bnx2x/bnx2x_ethdev.c | 86 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/overview.rst b/doc/guides/nics/overview.rst index 91fb18d..572ced4 100644 --- a/doc/guides/nics/overview.rst +++ b/doc/guides/nics/overview.rst @@ -128,7 +128,7 @@ Most of these differences are summarized below. Packet type parsing Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Timesync Y Y Y Y Y Basic stats Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y - Extended stats Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y + Extended stats Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Stats per queue Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y EEPROM dump Y Y Y Y Registers dump Y Y Y Y Y Y Y Y diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c index 3ff57c4..a57299f 100644 --- a/drivers/net/bnx2x/bnx2x_ethdev.c +++ b/drivers/net/bnx2x/bnx2x_ethdev.c @@ -28,6 +28,42 @@ static struct rte_pci_id pci_id_bnx2xvf_map[] = { { .vendor_id = 0, } }; +struct rte_bnx2x_xstats_name_off { + char name[RTE_ETH_XSTATS_NAME_SIZE]; + uint32_t offset_hi; + uint32_t offset_lo; +}; + +static const struct rte_bnx2x_xstats_name_off bnx2x_xstats_strings[] = { + {"rx_buffer_drops", + offsetof(struct bnx2x_eth_stats, brb_drop_hi), + offsetof(struct bnx2x_eth_stats, brb_drop_lo)}, + {"rx_buffer_truncates", + offsetof(struct bnx2x_eth_stats, brb_truncate_hi), + offsetof(struct bnx2x_eth_stats, brb_truncate_lo)}, + {"rx_buffer_truncate_discard", + offsetof(struct bnx2x_eth_stats, brb_truncate_discard), + offsetof(struct bnx2x_eth_stats, brb_truncate_discard)}, + {"mac_filter_discard", + offsetof(struct bnx2x_eth_stats, mac_filter_discard), + offsetof(struct bnx2x_eth_stats, mac_filter_discard)}, + {"no_match_vlan_tag_discard", + offsetof(struct bnx2x_eth_stats, mf_tag_discard), + offsetof(struct bnx2x_eth_stats, mf_tag_discard)}, + {"tx_pause", + offsetof(struct bnx2x_eth_stats, pause_frames_sent_hi), + offsetof(struct bnx2x_eth_stats, pause_frames_sent_lo)}, + {"rx_pause", + offsetof(struct bnx2x_eth_stats, pause_frames_received_hi), + offsetof(struct bnx2x_eth_stats, pause_frames_received_lo)}, + {"tx_priority_flow_control", + offsetof(struct bnx2x_eth_stats, pfc_frames_sent_hi), + offsetof(struct bnx2x_eth_stats, pfc_frames_sent_lo)}, + {"rx_priority_flow_control", + offsetof(struct bnx2x_eth_stats, pfc_frames_received_hi), + offsetof(struct bnx2x_eth_stats, pfc_frames_received_lo)} +}; + static void bnx2x_link_update(struct rte_eth_dev *dev) { @@ -334,6 +370,52 @@ bnx2x_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) brb_truncate_discard + stats->rx_nombuf; } +static int +bnx2x_get_xstats_names(__rte_unused struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, + __rte_unused unsigned limit) +{ + unsigned int i, stat_cnt = RTE_DIM(bnx2x_xstats_strings); + + if (xstats_names != NULL) + for (i = 0; i < stat_cnt; i++) + snprintf(xstats_names[i].name, + sizeof(xstats_names[i].name), + "%s", + bnx2x_xstats_strings[i].name); + + return stat_cnt; +} + +static int +bnx2x_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, + unsigned int n) +{ + struct bnx2x_softc *sc = dev->data->dev_private; + unsigned int num = RTE_DIM(bnx2x_xstats_strings); + + if (n < num) + return num; + + bnx2x_stats_handle(sc, STATS_EVENT_UPDATE); + + for (num = 0; num < n; num++) { + if (bnx2x_xstats_strings[num].offset_hi != + bnx2x_xstats_strings[num].offset_lo) + xstats[num].value = HILO_U64( + *(uint32_t *)((char *)&sc->eth_stats + + bnx2x_xstats_strings[num].offset_hi), + *(uint32_t *)((char *)&sc->eth_stats + + bnx2x_xstats_strings[num].offset_lo)); + else + xstats[num].value = + *(uint64_t *)((char *)&sc->eth_stats + + bnx2x_xstats_strings[num].offset_lo); + } + + return num; +} + static void bnx2x_dev_infos_get(struct rte_eth_dev *dev, __rte_unused struct rte_eth_dev_info *dev_info) { @@ -376,6 +458,8 @@ static const struct eth_dev_ops bnx2x_eth_dev_ops = { .allmulticast_disable = bnx2x_dev_allmulticast_disable, .link_update = bnx2x_dev_link_update, .stats_get = bnx2x_dev_stats_get, + .xstats_get = bnx2x_dev_xstats_get, + .xstats_get_names = bnx2x_get_xstats_names, .dev_infos_get = bnx2x_dev_infos_get, .rx_queue_setup = bnx2x_dev_rx_queue_setup, .rx_queue_release = bnx2x_dev_rx_queue_release, @@ -399,6 +483,8 @@ static const struct eth_dev_ops bnx2xvf_eth_dev_ops = { .allmulticast_disable = bnx2x_dev_allmulticast_disable, .link_update = bnx2xvf_dev_link_update, .stats_get = bnx2x_dev_stats_get, + .xstats_get = bnx2x_dev_xstats_get, + .xstats_get_names = bnx2x_get_xstats_names, .dev_infos_get = bnx2x_dev_infos_get, .rx_queue_setup = bnx2x_dev_rx_queue_setup, .rx_queue_release = bnx2x_dev_rx_queue_release, -- 1.7.10.3