From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7C7F4A2EFC for ; Fri, 20 Sep 2019 18:22:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 88A401F525; Fri, 20 Sep 2019 18:22:09 +0200 (CEST) Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-eopbgr820088.outbound.protection.outlook.com [40.107.82.88]) by dpdk.org (Postfix) with ESMTP id B3A8A1F503; Fri, 20 Sep 2019 18:22:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fa6eaSVcjM5HRB7p+W4saWka7ps0vO/wA/pxq4HgxaaFr7fbKefdMm9QJWMxpDVVkCSb9H6AqKx8dqOV4wdaegluC8XdSWvK+4TtdTDlQ70l/qaNDJNTgogocdAHkn44QJm2xn4ybTQk5gxFUu+SdJBL7+mgZ4wmqgjEKEKUZ9VYMB2HRcUI7Ox8gd5Kln6fXoauBdm4O8bssgl/fPpzV5Ypz7alPkcEY9TgOR7nGrDb8mitrEUjXGN0TKVjkDATzmZVgBt/Vw00ouruSUH+PqqWzr13HZ7MWvyOuheeaQZu+3LgfK5C/7xhIASjDLAjqsVkuhfz9FGiwm9qAw9dqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ry6RHIEJ1wRo25HcCKoBqcDGv5GZbd4X5Wccr7Fz9as=; b=QMwVwwHLQ+0ogCM8I7eg2SiqVfkQgvuD3XbLRbCjEJT7KgXMFvUyk3D7n6T1I+9aQ4E16s7YdUjt27LZzt+5WnbfQpvuzLSdnXbH8J0NHcRd9jswV1HyD95FGY0FnW9n2QE6zjrJAzS/A+dAeDVlheGPDImMeawQp3DB7qTNNKAJR5cMsyvoFhVTjGqJ8X1Aydq5Jc+47wSacEucjtWnUUa6AnCWH/zWQC6bgGHPYei1NAmezECpEPzXoqCFqLwIMQbk+SPRDgm0dK1BFuI41oD8tdTp1zKMbLk8/RZC3Y4jh8RxSpRDvz2SAJA3H94Gyz3Oi/Kw4S9cBvcgeXLQYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=aquantia.com; dmarc=pass action=none header.from=aquantia.com; dkim=pass header.d=aquantia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=AQUANTIA1COM.onmicrosoft.com; s=selector2-AQUANTIA1COM-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ry6RHIEJ1wRo25HcCKoBqcDGv5GZbd4X5Wccr7Fz9as=; b=dtdJl0AF//kTgk0kVHvmbkCUErHCx/55nC4mxkf+KeUpiTHaJ4KK+ACSMZGgXDXL1sYR0uXkc2+fjmyj2ioLcr6aHfEZRvd9QiANXkjObhc/BHAqJ72evGEBoldKuB9fDZpZptJ+l+0dKqXGiIKNubtniR2Xi8MIbIBr+vnj3JU= Received: from CY4PR1101MB2183.namprd11.prod.outlook.com (10.172.76.20) by CY4PR1101MB2165.namprd11.prod.outlook.com (10.174.54.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.19; Fri, 20 Sep 2019 16:22:02 +0000 Received: from CY4PR1101MB2183.namprd11.prod.outlook.com ([fe80::894e:7352:6cbd:bb25]) by CY4PR1101MB2183.namprd11.prod.outlook.com ([fe80::894e:7352:6cbd:bb25%11]) with mapi id 15.20.2284.009; Fri, 20 Sep 2019 16:22:02 +0000 From: Pavel Belous To: Ferruh Yigit CC: "dev@dpdk.org" , Igor Russkikh , Corey Melton , Pavel Belous , "stable@dpdk.org" Thread-Topic: [PATCH v2 1/3] net/atlantic: exclude MACSEC counters from xstats Thread-Index: AQHVb8+JjG3TvbEfKUK2vxB8IMPeWA== Date: Fri, 20 Sep 2019 16:22:02 +0000 Message-ID: <85744ec877be5433cc028e25c7d00f7231fa927c.1568994395.git.Pavel.Belous@aquantia.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0401CA0063.eurprd04.prod.outlook.com (2603:10a6:3:19::31) To CY4PR1101MB2183.namprd11.prod.outlook.com (2603:10b6:910:18::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Pavel.Belous@aquantia.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-originating-ip: [95.79.108.179] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 260708a0-d9e0-4a59-b0a3-08d73de6ab2e x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:CY4PR1101MB2165; x-ms-traffictypediagnostic: CY4PR1101MB2165: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:331; x-forefront-prvs: 0166B75B74 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(396003)(136003)(346002)(366004)(39850400004)(199004)(189003)(6506007)(386003)(76176011)(66446008)(66476007)(2616005)(102836004)(64756008)(2906002)(118296001)(316002)(50226002)(36756003)(186003)(8936002)(99286004)(26005)(6116002)(3846002)(8676002)(446003)(11346002)(256004)(52116002)(486006)(54906003)(44832011)(6916009)(476003)(81156014)(81166006)(66066001)(6486002)(25786009)(14454004)(66946007)(7736002)(5660300002)(6512007)(66556008)(86362001)(478600001)(6436002)(4326008)(71190400001)(305945005)(71200400001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR1101MB2165; H:CY4PR1101MB2183.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 4OahqAxBH1EzmNPgo2f2Xyrd2ziv5VGdJWDPS/y0gxzlqt/2z5wgS5SZh4jEHYds9Mi2B4McjRCpZz7+sCkwA2yx/HpNKupqwHgyz7sXEkSZKk4VXTp/27cRIQLMfUhhEmiQHRDuNx41w4YzBUa/aWuGwcTI1JBDNR4a4sG0DgTnSw2A522L633at06H7sL73QIu6qfeXEEJy4DcV8tCkCAloy99yhOfzuqsghO7/qFcBXjJBKV8XrHOjLXMHPxK9OsxXiTQygxpEDS/Gv/H1nm9BRAf1CylG4034CD9k6+7IrbcBY2KFrjmWGlFREA0aMBMuuTjoD35ZaeVc8C0vC90vhy8bzbW/71ob1uP9R4DYuEibw8dLfSZRyd2/Cw+vXix014/tCvjTHypM6zFnDWoJyCs41qbXChNe69xDzM= 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: 260708a0-d9e0-4a59-b0a3-08d73de6ab2e X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Sep 2019 16:22:02.6158 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: sjMI0wFhEK9GRbvRZFXolYeskRFBNPDjvnQk5qrk84SZnp/iFHktW5qgBPvHLeM6qw9aisSwYXAorcxRKK5PFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1101MB2165 Subject: [dpdk-dev] [PATCH v2 1/3] net/atlantic: exclude MACSEC counters from 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Pavel Belous Currently, driver always return full set of xstats counters, including MACSEC counters. But this driver also supports AQC100 chips, which does not have MACSEC feature. This fix adds checking for MACSEC availability (based on FW capability bits) and returns xstats without MACSEC counters if MACSEC feature is not available. Fixes: 09d4dfa85359 ("net/atlantic: implement MACsec statistics") Cc: stable@dpdk.org Signed-off-by: Pavel Belous Signed-off-by: Igor Russkikh --- drivers/net/atlantic/atl_ethdev.c | 52 ++++++++++++++++++++++++++++-------= ---- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_e= thdev.c index 3c1b349..178f7db 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -993,20 +993,42 @@ atl_dev_stats_reset(struct rte_eth_dev *dev) } =20 static int +atl_dev_xstats_get_count(struct rte_eth_dev *dev) +{ + struct atl_adapter *adapter =3D + (struct atl_adapter *)dev->data->dev_private; + + struct aq_hw_s *hw =3D &adapter->hw; + unsigned int i, count =3D 0; + + for (i =3D 0; i < RTE_DIM(atl_xstats_tbl); i++) { + if (atl_xstats_tbl[i].type =3D=3D XSTATS_TYPE_MACSEC && + ((hw->caps_lo & BIT(CAPS_LO_MACSEC)) =3D=3D 0)) + continue; + + count++; + } + + return count; +} + +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; + unsigned int count =3D atl_dev_xstats_get_count(dev); =20 - if (!xstats_names) - return RTE_DIM(atl_xstats_tbl); - - for (i =3D 0; i < size && i < RTE_DIM(atl_xstats_tbl); i++) - strlcpy(xstats_names[i].name, atl_xstats_tbl[i].name, - RTE_ETH_XSTATS_NAME_SIZE); + if (xstats_names) { + for (i =3D 0; i < size && i < count; i++) { + snprintf(xstats_names[i].name, + RTE_ETH_XSTATS_NAME_SIZE, "%s", + atl_xstats_tbl[i].name); + } + } =20 - return i; + return count; } =20 static int @@ -1020,9 +1042,10 @@ atl_dev_xstats_get(struct rte_eth_dev *dev, struct r= te_eth_xstat *stats, struct macsec_msg_fw_response resp =3D { 0 }; int err =3D -1; unsigned int i; + unsigned int count =3D atl_dev_xstats_get_count(dev); =20 if (!stats) - return 0; + return count; =20 if (hw->aq_fw_ops->send_macsec_req !=3D NULL) { req.ingress_sa_index =3D 0xff; @@ -1035,7 +1058,7 @@ atl_dev_xstats_get(struct rte_eth_dev *dev, struct rt= e_eth_xstat *stats, err =3D hw->aq_fw_ops->send_macsec_req(hw, &msg, &resp); } =20 - for (i =3D 0; i < n && i < RTE_DIM(atl_xstats_tbl); i++) { + for (i =3D 0; i < n && i < count; i++) { stats[i].id =3D i; =20 switch (atl_xstats_tbl[i].type) { @@ -1044,14 +1067,15 @@ atl_dev_xstats_get(struct rte_eth_dev *dev, struct = rte_eth_xstat *stats, atl_xstats_tbl[i].offset); break; case XSTATS_TYPE_MACSEC: - if (err) - goto done; - stats[i].value =3D *(u64 *)((uint8_t *)&resp.stats + - atl_xstats_tbl[i].offset); + if (!err) { + stats[i].value =3D + *(u64 *)((uint8_t *)&resp.stats + + atl_xstats_tbl[i].offset); + } break; } } -done: + return i; } =20 --=20 2.7.4