From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0086.outbound.protection.outlook.com [104.47.38.86]) by dpdk.org (Postfix) with ESMTP id AAAC71B4C6 for ; Thu, 11 Oct 2018 12:35:25 +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=lrWrHmxtswERoYBsBmkOs7X59unKk9Qn9SHJ82I/lT0=; b=XvZowg/rc29sTFSMQYCpYjIknbEgMDdgMUrVYCc0YcLINtWx4DArzh3sbrHDdeaQUwnixLwvzk2GNiN2zx1KGSjbB1bQRn8Z8n3EfcvTy7lw9fuux91AzfL5UcD3pWCQ7o0M7IippHxpX9OlZSbbYWVzRIEDljxnmI5UxxegTGM= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1206.namprd07.prod.outlook.com (10.160.105.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.24; Thu, 11 Oct 2018 10:35:24 +0000 Received: from BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::346d:e756:e70e:17]) by BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::346d:e756:e70e:17%3]) with mapi id 15.20.1228.020; Thu, 11 Oct 2018 10:35:24 +0000 From: Igor Russkikh To: "dev@dpdk.org" CC: Pavel Belous , Igor Russkikh , "ferruh.yigit@intel.com" Thread-Topic: [PATCH v5 13/23] net/atlantic: device statistics support Thread-Index: AQHUYU4d6hRZh50UEUKv7trPxl6xsA== Date: Thu, 11 Oct 2018 10:35:23 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR04CA0088.eurprd04.prod.outlook.com (2603:10a6:803:64::23) To BY1PR0701MB1660.namprd07.prod.outlook.com (2a01:111:e400:522a::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [95.79.108.179] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BY1PR0701MB1206; 6:apD6WiSGsO3gSExik18QBLU8ZeM1vDzWKMaxke1gc4nrY5RKK/3Fn9LdNmTRnuMJSUpLyGh1p3q7dLidDpW7KwEnWPnDMJDvA9qdIXBlBjH//M2KxgwhKsSZKGj9WWyKvlCgFwFQT8FrQ75oNYWTRGdi2O3KwQrJa17kWgjxIqR9p1dn6rS24HEhC4XzBPd18oCBAc4vV2Muxk0ULRWLR4B7ka52MPiY89CU4bCFSKPXgypnwF7hl32Ws/ta4ff4fIITBZXAvRcXyLzRh9C878RYLdUFZU5/ykprxHCtLbteyhdnMMz3G+EYqFTZ8ICbzVmKDNiQJvdb28FL6nwODyl8F3Ey61OsfCoy8Ccgv5yfhao2rSV2zvfWOV1URj76Xzv0E46BwlNP0GBGH8i25FMaNLkyfpgOS4hPdy1p2g5Sx+rMgIZeGDRXg7NZLd7OrbvcO3QKv2wZ5ovqSuOk/GcN85+nHAKuHxYHtPErtbY=; 5:ws5skJDaRt6E9bJYVCyW7UvIaqL/g19QM82QWACWhQWDFCqS80sZm8P0+rji/4tcXeN7CWjPiFC6XzzttawanBvPc3OlbNHeeXbj3CJhZ0nVTWdCGpbEJWwO2pumTlW3w8Z0znw9BBAWT3DIsKM/UsQC1nSKdcneE2hPOxcf5mQ=; 7:bxAAfjR1XTFQT+IYLxX1HUCDzbbT9m6PPxp0FmDpkL6jzzbnIo7IilUvq+ClaK2HUKdAiugAF/fiG/ob3qnmi0R7l4bTTA66I0sPMgnCSL5ndUm5tC8MfhGol56CK7tndD0+alLVjRz3PgZLiMHZO37HZ0vXJo50ine/Xaywt0fAUelmZwzFBopKNpFAcAS5K2i8O7XQYHtv0uSsljVfOTjkbMGwZepEDASBnbDxLypvOHiqZGS6PU8eRW7+E6Tg x-ms-office365-filtering-correlation-id: 81a6bce8-9620-4891-8d00-08d62f654011 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BY1PR0701MB1206; x-ms-traffictypediagnostic: BY1PR0701MB1206: 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)(8121501046)(5005006)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(93001095)(149066)(150057)(6041310)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051); SRVR:BY1PR0701MB1206; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1206; x-forefront-prvs: 08220FA8D6 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(346002)(136003)(396003)(39850400004)(376002)(366004)(189003)(199004)(486006)(14444005)(256004)(2351001)(25786009)(186003)(44832011)(2501003)(26005)(6436002)(6512007)(118296001)(478600001)(5640700003)(305945005)(71190400001)(71200400001)(72206003)(4326008)(53936002)(66066001)(7736002)(8676002)(6486002)(102836004)(36756003)(14454004)(81166006)(81156014)(1730700003)(386003)(6506007)(6116002)(3846002)(446003)(54906003)(68736007)(11346002)(476003)(99286004)(76176011)(52116002)(8936002)(316002)(2616005)(86362001)(106356001)(575784001)(5660300001)(97736004)(2900100001)(105586002)(6916009)(5250100002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1206; H:BY1PR0701MB1660.namprd07.prod.outlook.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-antispam-message-info: oRdV/VKZn197txYd3dS26roFQrWDX0k7FPqaF+jGkodDRgG3dGifaCa5k9mdk7+YcOOfNliCyrEEdan1eUzucmib0h7n1oAflHYM3oHjdJH2meSiLRLghD+iY/pRkzMSa2ksw8stxnthtG+gEyfP0aRE5K1ctTdOo3v1eGUup9az361O+0u5OKZnrh7MxCrA5xFP0kBRJFbImDYcv9e1cBzhSOtr6rwCk5GuAw/lb1Zs5/se7GOFMpvGVmkkpKO39omuHEnQEirq2JrvRnoGqDSKZY+A+SQg+8nx6p3fSeaVk1HI0ccTVXyStlkYbMRxr//54sHmfoL29HIRtPbDj2koreQB2x+U/WWJPxiNDjE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81a6bce8-9620-4891-8d00-08d62f654011 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Oct 2018 10:35:23.9033 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1206 Subject: [dpdk-dev] [PATCH v5 13/23] net/atlantic: device statistics support 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: Thu, 11 Oct 2018 10:35:26 -0000 From: Pavel Belous Add support for device statistics. Signed-off-by: Igor Russkikh Signed-off-by: Pavel Belous --- doc/guides/nics/atlantic.rst | 1 + doc/guides/nics/features/atlantic.ini | 3 + drivers/net/atlantic/atl_ethdev.c | 133 ++++++++++++++++++++++++++++++= ++++ drivers/net/atlantic/atl_ethdev.h | 1 + drivers/net/atlantic/atl_rxtx.c | 11 ++- drivers/net/atlantic/atl_types.h | 41 +++++++++++ 6 files changed, 189 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/atlantic.rst b/doc/guides/nics/atlantic.rst index a003ef5110c9..1108d458f836 100644 --- a/doc/guides/nics/atlantic.rst +++ b/doc/guides/nics/atlantic.rst @@ -13,6 +13,7 @@ Supported features ^^^^^^^^^^^^^^^^^^ =20 - Base L2 features +- Port statistics - Checksum offload - Jumbo Frame upto 16K =20 diff --git a/doc/guides/nics/features/atlantic.ini b/doc/guides/nics/featur= es/atlantic.ini index 1648fffae192..c630496f0ba5 100644 --- a/doc/guides/nics/features/atlantic.ini +++ b/doc/guides/nics/features/atlantic.ini @@ -13,6 +13,9 @@ CRC offload =3D Y L3 checksum offload =3D Y L4 checksum offload =3D Y Packet type parsing =3D Y +Basic stats =3D Y +Extended stats =3D Y +Stats per queue =3D Y FW version =3D Y Linux UIO =3D Y x86-32 =3D Y diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_e= thdev.c index 30ef0ffbfca8..3c27a5037e03 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -24,6 +24,18 @@ static void atl_dev_close(struct rte_eth_dev *dev); static int atl_dev_reset(struct rte_eth_dev *dev); static int atl_dev_link_update(struct rte_eth_dev *dev, int wait); =20 +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 int atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); =20 @@ -116,6 +128,33 @@ static const struct rte_eth_desc_lim tx_desc_lim =3D { .nb_mtu_seg_max =3D ATL_TX_MAX_SEG, }; =20 +#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[] =3D { + 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 =3D { .dev_configure =3D atl_dev_configure, .dev_start =3D atl_dev_start, @@ -128,6 +167,13 @@ static const struct eth_dev_ops atl_eth_dev_ops =3D { /* Link */ .link_update =3D atl_dev_link_update, =20 + /* Stats */ + .stats_get =3D atl_dev_stats_get, + .xstats_get =3D atl_dev_xstats_get, + .xstats_get_names =3D atl_dev_xstats_get_names, + .stats_reset =3D atl_dev_stats_reset, + .xstats_reset =3D atl_dev_stats_reset, + .fw_version_get =3D atl_fw_version_get, .dev_infos_get =3D atl_dev_info_get, .dev_supported_ptypes_get =3D atl_dev_supported_ptypes_get, @@ -224,6 +270,9 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) eth_dev->data->mac_addrs->addr_bytes) !=3D 0) return -EINVAL; =20 + /* Reset the hw statistics */ + atl_dev_stats_reset(eth_dev); + rte_intr_callback_register(intr_handle, atl_dev_interrupt_handler, eth_dev); =20 @@ -542,6 +591,90 @@ atl_dev_reset(struct rte_eth_dev *dev) return ret; } =20 + +static int +atl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) +{ + struct atl_adapter *adapter =3D ATL_DEV_TO_ADAPTER(dev); + struct aq_hw_s *hw =3D &adapter->hw; + struct atl_sw_stats *swstats =3D &adapter->sw_stats; + unsigned int i; + + hw->aq_fw_ops->update_stats(hw); + + /* Fill out the rte_eth_stats statistics structure */ + stats->ipackets =3D hw->curr_stats.dma_pkt_rc; + stats->ibytes =3D hw->curr_stats.dma_oct_rc; + stats->imissed =3D hw->curr_stats.dpc; + stats->ierrors =3D hw->curr_stats.erpt; + + stats->opackets =3D hw->curr_stats.dma_pkt_tc; + stats->obytes =3D hw->curr_stats.dma_oct_tc; + stats->oerrors =3D 0; + + stats->rx_nombuf =3D swstats->rx_nombuf; + + for (i =3D 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) { + stats->q_ipackets[i] =3D swstats->q_ipackets[i]; + stats->q_opackets[i] =3D swstats->q_opackets[i]; + stats->q_ibytes[i] =3D swstats->q_ibytes[i]; + stats->q_obytes[i] =3D swstats->q_obytes[i]; + stats->q_errors[i] =3D swstats->q_errors[i]; + } + return 0; +} + +static void +atl_dev_stats_reset(struct rte_eth_dev *dev) +{ + struct atl_adapter *adapter =3D ATL_DEV_TO_ADAPTER(dev); + struct aq_hw_s *hw =3D &adapter->hw; + + hw->aq_fw_ops->update_stats(hw); + + /* Reset software totals */ + memset(&hw->curr_stats, 0, sizeof(hw->curr_stats)); + + memset(&adapter->sw_stats, 0, sizeof(adapter->sw_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 =3D 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 =3D ATL_DEV_TO_ADAPTER(dev); + struct aq_hw_s *hw =3D &adapter->hw; + unsigned int i; + + if (!stats) + return 0; + + for (i =3D 0; i < n && i < RTE_DIM(atl_xstats_tbl); i++) { + stats[i].id =3D i; + stats[i].value =3D *(u64 *)((uint8_t *)&hw->curr_stats + + atl_xstats_tbl[i].offset); + } + + return n; +} + static int atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_si= ze) { diff --git a/drivers/net/atlantic/atl_ethdev.h b/drivers/net/atlantic/atl_e= thdev.h index 55a7e0d6188c..dc48c134b7b8 100644 --- a/drivers/net/atlantic/atl_ethdev.h +++ b/drivers/net/atlantic/atl_ethdev.h @@ -33,6 +33,7 @@ struct atl_interrupt { struct atl_adapter { struct aq_hw_s hw; struct aq_hw_cfg_s hw_cfg; + struct atl_sw_stats sw_stats; struct atl_interrupt intr; }; =20 diff --git a/drivers/net/atlantic/atl_rxtx.c b/drivers/net/atlantic/atl_rxt= x.c index e1ace0a342e5..4e0ca59943e5 100644 --- a/drivers/net/atlantic/atl_rxtx.c +++ b/drivers/net/atlantic/atl_rxtx.c @@ -874,7 +874,8 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts= , uint16_t nb_pkts) "queue_id=3D%u", (unsigned int)rxq->port_id, (unsigned int)rxq->queue_id); dev->data->rx_mbuf_alloc_failed++; - goto err_stop; + adapter->sw_stats.rx_nombuf++; + goto err_stop; } =20 nb_hold++; @@ -957,6 +958,9 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts= , uint16_t nb_pkts) * of returned packets. */ rx_pkts[nb_rx++] =3D rx_mbuf_first; + adapter->sw_stats.q_ipackets[rxq->queue_id]++; + adapter->sw_stats.q_ibytes[rxq->queue_id] +=3D + rx_mbuf_first->pkt_len; =20 PMD_RX_LOG(ERR, "add mbuf segs=3D%d pkt_len=3D%d", rx_mbuf_first->nb_segs, @@ -1102,6 +1106,8 @@ static inline void atl_xmit_pkt(struct aq_hw_s *hw, struct atl_tx_queue *txq, struct rte_mbuf *tx_pkt) { + struct atl_adapter *adapter =3D + ATL_DEV_TO_ADAPTER(&rte_eth_devices[txq->port_id]); uint32_t pay_len =3D 0; int tail =3D 0; struct atl_tx_entry *tx_entry; @@ -1182,6 +1188,9 @@ atl_xmit_pkt(struct aq_hw_s *hw, struct atl_tx_queue = *txq, txq->tx_tail =3D tail; =20 txq->tx_free -=3D desc_count; + + adapter->sw_stats.q_opackets[txq->queue_id]++; + adapter->sw_stats.q_obytes[txq->queue_id] +=3D pay_len; } =20 uint16_t diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_ty= pes.h index e636464955e3..56887b14d6f8 100644 --- a/drivers/net/atlantic/atl_types.h +++ b/drivers/net/atlantic/atl_types.h @@ -140,4 +140,45 @@ struct aq_fw_ops { int (*set_eeprom)(struct aq_hw_s *self, u32 *data, u32 len); }; =20 +struct atl_sw_stats { + u64 crcerrs; + u64 errbc; + u64 mspdc; + u64 mpctotal; + u64 mpc[8]; + u64 mlfc; + u64 mrfc; + u64 rlec; + u64 lxontxc; + u64 lxonrxc; + u64 lxofftxc; + u64 lxoffrxc; + u64 pxontxc[8]; + u64 pxonrxc[8]; + u64 pxofftxc[8]; + u64 pxoffrxc[8]; + u64 gprc; + u64 bprc; + u64 mprc; + u64 gptc; + u64 gorc; + u64 gotc; + u64 tor; + u64 tpr; + u64 tpt; + u64 mptc; + u64 bptc; + u64 xec; + u64 fccrc; + u64 ldpcec; + u64 pcrc8ec; + + u64 rx_nombuf; + u64 q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS]; + u64 q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS]; + u64 q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS]; + u64 q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS]; + u64 q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS]; +}; + #endif --=20 2.7.4