From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0056.outbound.protection.outlook.com [104.47.42.56]) by dpdk.org (Postfix) with ESMTP id B27B95B38 for ; Fri, 7 Sep 2018 17:23:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=AQUANTIA1COM.onmicrosoft.com; s=selector1-aquantia-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fFsc9iucHgd/dGVDSipx1RyFyU8gis6JEuvMbS1ZRLc=; b=qlGUqNJj8OZr3Ts3R3HE7Vbq8XtHf/ETVSBeEBIZrOGY+K9ECkwXNGkbJaPPEFmLZvYGhXgE9NkUqQbhHmMK4G/wq/jMEsUZyZHBWWvGq1OG+DW1b+NzAScTdavanCJIvqrayGOg6KFf0YqWuXAsos3Ur91q+wt/Ni0LPMRVvNM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; Received: from ubuntubox.rdc.aquantia.com (95.79.108.179) by BLUPR0701MB1652.namprd07.prod.outlook.com (2a01:111:e400:58c6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Fri, 7 Sep 2018 15:23:33 +0000 From: Igor Russkikh To: dev@dpdk.org Cc: pavel.belous@aquantia.com, Nadezhda.Krupnina@aquantia.com, igor.russkikh@aquantia.com, Simon.Edelhaus@aquantia.com, Corey Melton , Ashish Kumar Date: Fri, 7 Sep 2018 18:21:55 +0300 Message-Id: <1536333719-32155-18-git-send-email-igor.russkikh@aquantia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536333719-32155-1-git-send-email-igor.russkikh@aquantia.com> References: <1536333719-32155-1-git-send-email-igor.russkikh@aquantia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [95.79.108.179] X-ClientProxiedBy: BN6PR20CA0060.namprd20.prod.outlook.com (2603:10b6:404:151::22) To BLUPR0701MB1652.namprd07.prod.outlook.com (2a01:111:e400:58c6::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a0312514-a25f-42fa-7d74-08d614d5e053 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BLUPR0701MB1652; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1652; 3:e50KKz3Y2ATfIfoZ2Q7vcfpw/dxm2pBVEi8+81TVKikM4aD1EpyFXq1AimMgqcvJrZ/l4hRZThncCMG3jnkas8BEFQEh59RjL8RenHupGDZQV96qGoW9IwKPe1p93/l/JnZ72ntnAxY2j9gjgp9sojzhM4JPLkfBa8gegnCU9oaaq+RdH0cqIPLTtA8G6Bc7OFi3KNKfNR7qgAfqagdv3P7LpKInP4tt2qJ4NXxpuySAAG51sa1LkyFhhabkcSBn; 25:WkgVxoxLJWlrtJ3mP3JkwbX4ip63cw/DkC68xtkI5M5cuUxiS+QY0f+3h8JEg5IG6aMykrO2JxQVcb97xVVRGpohQvew4UlA9ymVRgRuR+AmFhgdYoAitEw/X/LhE5GmsrS2G8gEfkipjTZVarXWKRNyFiNdWAs2dWLT7ij+Lsd9fvT3V6TNP4zJmd15SlqDynOeE4DudiY3g2vnet6pzDLxxecIzN3/mMftT6r51Fl6MnJd/atP4PmoDB4AscqA3jOd3IDr/ivYj8qh+fJt0jslh8W+WXcrmE4ycgd/lwqOlicREmSWA2Es42qLniEwcM5ojJLMxgsS44QGnk8WKQ==; 31:h35yPl14gRY/HkAHY6PEYu1BeG+RKOkTuuhahp5GGZsWXnsK6JMd4mWpGhC/hIq10ownFdKyIxUqCmY8khQR2vEtV/BB7AMz7ejB076qLf1AmmSIcQzMG/ENn43tWV5OTvKS6AYZfGEedIMYVWeuxXqHsMTP2vzIb2BbH6H8DtdaahziZr6iWpqFAQJob3zLhkDaRsQgn42df9CrsPHlrpgpNQUWnkGGzeCJyOnZ3Ds= X-MS-TrafficTypeDiagnostic: BLUPR0701MB1652: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1652; 20:MuIvfRDgByd3TFOo/KUj4q0j8IR/DWSLtVzWdyvKb0T3t91leZsVK777fhX7FDto+N7w/tKyH8nXLw9UOClcsQ/Mq2XX461BcWMTeZUBkhNGtZSuuILvMJqCBNJIBuGn6oRqunvPAKWbvIAHUNN2AEEzdUkZhawAhbMZmCvFa4WJwTyEyXrAzx5+V2wCTBePg9Z+WAiaamh9HPyNQunMvpY478eno4uDGRCiJbnSkwPVanLDcsmopgX9ClYyQLw2caMzCay6b+23bszhiqmOUSYzfzP8bH0GojKLxVAFkkA1pQAqA0rfKimXJMKLL1TfT5Z5Yem6TfOV21HWCVoUYho59qEic5TndSZVqq8FQhWTUJxNraeN8YVKKo9THzl00zcVydTJLaBoMa+dHgxbdXe/EvBVyEzB2GRJMB+BXkul06BiRcELPAzOYWu2cN5faRM7J0g4MNhsnyAWz7x2nqZSdhlFFwY4icK9eyUjBhhJ3tbaxxE91dZvo8NNqPs4; 4:M8fUVEvD2w7mxiL4yd7v7Ec+KMGsGTZoaL9IZiBNHAnF4zCgCKGOi5ZlTeQafcb7AlJZJqaYeVQQ4AveXjWs4UHz3Rp2dEHF07QlWV0GPmCP+LqHBksLujE6S99X5ppH2H3EkbENLUtgZcXzlLSRbR8siMP+/BqIzVHNEnC6KBmsNNZDNwj3aWrrhBZ63bpfmu7usuViIK8NhJIS9Y0z/TPv8JTc9YHgJTJVs0bjyjwFI9ui1WXYQBLwQpOc4vybWdnoMfF/7kr5i5455gBN8A== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231311)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699050); SRVR:BLUPR0701MB1652; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1652; X-Forefront-PRVS: 07880C4932 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39850400004)(396003)(376002)(366004)(346002)(136003)(189003)(199004)(81156014)(81166006)(44832011)(8936002)(2351001)(486006)(106356001)(2361001)(105586002)(446003)(2906002)(50226002)(476003)(11346002)(956004)(2616005)(305945005)(7736002)(16586007)(316002)(54906003)(14444005)(16526019)(66066001)(26005)(7696005)(52116002)(8676002)(51416003)(76176011)(186003)(386003)(68736007)(478600001)(6666003)(6916009)(6486002)(5660300001)(53936002)(47776003)(4326008)(25786009)(86362001)(48376002)(50466002)(72206003)(6116002)(97736004)(36756003)(3846002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1652; H:ubuntubox.rdc.aquantia.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0701MB1652; 23:Rv4xCl28EIYitsWd7R0sw5Ebbn8v7/qWud0vhEP?= =?us-ascii?Q?FJRibV8KyjBj45xBUpTYypZP6eVRTrcKwVTDiwo95NOc6IdMfLIl0Rb1+/Tc?= =?us-ascii?Q?/aKZdlgKrOa0lXyFRKaeXHhNuXGNaI4yCj4tCIZpNkYMhlq/Wkngs1F3ln+9?= =?us-ascii?Q?NXP1ph2ySTH0HGVh5nJhkclwkkZolFfhbaiS/v1to53ZNs5tQ4jgfC1wcm4b?= =?us-ascii?Q?YHsnFz7I3iGOLlTwVUhhJps/DA6teVc+K5eXOH6wLwRf64fLKjM3mROz8Y60?= =?us-ascii?Q?N3sfzBXslYHF41KENlW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SG7ZawQQ3f0oTrrcZeoCn4/FSpSZgN+7EoToJCJRZ7+5vwWEkv2/+U5ddVzKKegXtnMmyxVE32cfEl6blQiworYPczIydjoh+M=; 7:o06wAbBxHO9QF7S4t3JXQ9feZ1rlPp/qw1240iEjZUBKob62qiQRqcb9Nv4UxO7/iquCHRb5Ob/hwudivSHaYPMJ7k86sfx+lzCY+aXDW/8MOcvflvLnnKf3eyTRJOzQgzXy/OwhsHCaQ1583TG1QaTB42OnKZ0RNjChKFP+RVMsSt1lfua/ZlWG+HjyEHsbPF/gsDIdlkkolnO3RXhZdl78REsDtzgmRaLGB3/KwR4pqEhs1X87wANEaH3nQNnD SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2018 15:23:33.0230 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0312514-a25f-42fa-7d74-08d614d5e053 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1652 Subject: [dpdk-dev] [PATCH 17/21] net/atlantic: device statistics, xstats 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: Fri, 07 Sep 2018 15:23:37 -0000 Signed-off-by: Igor Russkikh --- drivers/net/atlantic/atl_ethdev.c | 131 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index b3ec7c492..c99d321c9 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -59,6 +59,19 @@ static void atl_dev_allmulticast_enable(struct rte_eth_dev *dev); static void atl_dev_allmulticast_disable(struct rte_eth_dev *dev); static int atl_dev_link_update(struct rte_eth_dev *dev, int wait); +static int atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused, + struct rte_eth_xstat_name *xstats_names, + unsigned int size); + +static int atl_dev_stats_get(struct rte_eth_dev *dev, + struct rte_eth_stats *stats); + +static int atl_dev_xstats_get(struct rte_eth_dev *dev, + struct rte_eth_xstat *stats, unsigned int n); + +static void atl_dev_stats_reset(struct rte_eth_dev *dev); +static void atl_dev_xstats_reset(struct rte_eth_dev *dev); + static int atl_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id, uint8_t stat_idx, @@ -180,6 +193,34 @@ static const struct rte_eth_desc_lim tx_desc_lim = { .nb_mtu_seg_max = ATL_TX_MAX_SEG, }; +#define ATL_XSTATS_FIELD(name) { \ + #name, \ + offsetof(struct aq_stats_s, name) \ +} + +struct atl_xstats_tbl_s { + const char *name; + unsigned int offset; +}; + +static struct atl_xstats_tbl_s atl_xstats_tbl[] = { + ATL_XSTATS_FIELD(uprc), + ATL_XSTATS_FIELD(mprc), + ATL_XSTATS_FIELD(bprc), + ATL_XSTATS_FIELD(erpt), + ATL_XSTATS_FIELD(uptc), + ATL_XSTATS_FIELD(mptc), + ATL_XSTATS_FIELD(bptc), + ATL_XSTATS_FIELD(erpr), + ATL_XSTATS_FIELD(ubrc), + ATL_XSTATS_FIELD(ubtc), + ATL_XSTATS_FIELD(mbrc), + ATL_XSTATS_FIELD(mbtc), + ATL_XSTATS_FIELD(bbrc), + ATL_XSTATS_FIELD(bbtc), +}; + + static const struct eth_dev_ops atl_eth_dev_ops = { .dev_configure = atl_dev_configure, .dev_start = atl_dev_start, @@ -200,6 +241,12 @@ static const struct eth_dev_ops atl_eth_dev_ops = { .get_reg = atl_dev_get_regs, + /* Stats */ + .stats_get = atl_dev_stats_get, + .xstats_get = atl_dev_xstats_get, + .xstats_get_names = atl_dev_xstats_get_names, + .stats_reset = atl_dev_stats_reset, + .xstats_reset = atl_dev_xstats_reset, /* LEDs */ .dev_led_on = atl_dev_led_on, @@ -384,6 +431,9 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) if (hw->aq_fw_ops->get_mac_permanent(hw, (u8*)ð_dev->data->mac_addrs[0]) != 0) return -EINVAL; + /* Reset the hw statistics */ + atl_dev_stats_reset(eth_dev); + rte_intr_callback_register(intr_handle, atl_dev_interrupt_handler, eth_dev); @@ -693,6 +743,87 @@ atl_dev_reset(struct rte_eth_dev *dev) } +static int +atl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) +{ + struct atl_adapter *adapter = (struct atl_adapter *)dev->data->dev_private; + struct aq_hw_s *hw = &adapter->hw; + struct atl_sw_stats *swstats = &adapter->sw_stats; + unsigned i; + + hw->aq_fw_ops->update_stats(hw); + + /* Fill out the rte_eth_stats statistics structure */ + stats->ipackets = hw->curr_stats.dma_pkt_rc; + stats->ibytes = hw->curr_stats.dma_oct_rc; + stats->imissed = hw->curr_stats.dpc; + stats->ierrors = hw->curr_stats.erpt; + + stats->opackets = hw->curr_stats.dma_pkt_tc; + stats->obytes = hw->curr_stats.dma_oct_tc; + stats->oerrors = 0; + + stats->rx_nombuf = swstats->rx_nombuf; + + for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) { + stats->q_ipackets[i] = swstats->q_ipackets[i]; + stats->q_opackets[i] = swstats->q_opackets[i]; + stats->q_ibytes[i] = swstats->q_ibytes[i]; + stats->q_obytes[i] = swstats->q_obytes[i]; + stats->q_errors[i] = swstats->q_errors[i]; + } + return 0; +} + +static void +atl_dev_stats_reset(struct rte_eth_dev *dev) +{ + struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + hw->aq_fw_ops->update_stats(hw); + + /* Reset software totals */ + memset(&hw->curr_stats, 0, sizeof(hw->curr_stats)); +} + +static int +atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused, struct rte_eth_xstat_name *xstats_names, unsigned int size) +{ + unsigned int i; + + if (!xstats_names) + return RTE_DIM(atl_xstats_tbl); + + for (i = 0; i < size && i < RTE_DIM(atl_xstats_tbl); i++) + snprintf(xstats_names[i].name, RTE_ETH_XSTATS_NAME_SIZE, "%s", + atl_xstats_tbl[i].name); + + return size; +} + +static int +atl_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, unsigned int n) +{ + struct atl_adapter *adapter = (struct atl_adapter *)dev->data->dev_private; + struct aq_hw_s *hw = &adapter->hw; + unsigned i; + + if (!stats) + return 0; + + for (i = 0; i < n && i < RTE_DIM(atl_xstats_tbl); i++) { + stats[i].id = i; + stats[i].value = *(u64 *)((uint8_t *)&hw->curr_stats + atl_xstats_tbl[i].offset); + } + + return n; +} + +static void +atl_dev_xstats_reset(struct rte_eth_dev *dev __rte_unused) +{ + return; +} /* return 0 means link status changed, -1 means not changed */ static int atl_dev_link_update(struct rte_eth_dev *dev, int wait __rte_unused) -- 2.13.3.windows.1