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 3C80FA328D for ; Wed, 23 Oct 2019 05:16:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D92DB1BF0C; Wed, 23 Oct 2019 05:16:11 +0200 (CEST) Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30086.outbound.protection.outlook.com [40.107.3.86]) by dpdk.org (Postfix) with ESMTP id 0934F1BEED for ; Wed, 23 Oct 2019 05:16:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3G6X6Xj3nyW/H3bofwKLYkJateA8S/4vWKzWhGq5P1I=; b=tlZ9OgnN8ZD6k7BF2726Jjsg4toYO7uOG9/8f3Y8L+m75EZwlkElRiNJfwlM2b3utfLbxbzeUgRAkRvxMpBx3fUlinv7dzREmDuLlA1xqhmYxJba7dUYptCMhg7EvMSigygZd3xcUMFfRraHMmJXZbrlzPfXfrsWDFhXub3NrHc= Received: from VI1PR08CA0179.eurprd08.prod.outlook.com (2603:10a6:800:d1::33) by DB6PR0801MB2072.eurprd08.prod.outlook.com (2603:10a6:4:79::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Wed, 23 Oct 2019 03:16:10 +0000 Received: from VE1EUR03FT060.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::205) by VI1PR08CA0179.outlook.office365.com (2603:10a6:800:d1::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.21 via Frontend Transport; Wed, 23 Oct 2019 03:16:09 +0000 Authentication-Results: spf=fail (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dpdk.org; dmarc=none action=none header.from=arm.com; Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT060.mail.protection.outlook.com (10.152.19.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.23 via Frontend Transport; Wed, 23 Oct 2019 03:16:09 +0000 Received: ("Tessian outbound 6481c7fa5a3c:v33"); Wed, 23 Oct 2019 03:16:09 +0000 X-CR-MTA-TID: 64aa7808 Received: from cf93e647be76.3 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.5.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 49200DD5-D50D-456D-BE81-466B078174C5.1; Wed, 23 Oct 2019 03:16:04 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-he1eur02lp2056.outbound.protection.outlook.com [104.47.5.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cf93e647be76.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 23 Oct 2019 03:16:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nN7BgpJDWb7AUktdOOmtHf0D11/f6LSj7jCqKKtA4cR4Izm3BMKTpeUgkLDcggyFS1zyFbtb6gC6g+hZSC7EUG1HQKYJ1RSRh7qWZWKGqi/trDxZ+NaVkgHivuaWxwTqR9OmZKecOxkkbMbSox92rb6SqWEPgBLOQ5vgcQcTJxMMqV+TGjcoKJDzm5+UZSC20BLbQa/jPcBVgoID2+5MH7wxvEcTluxr+Q30v3WJlb1vYDAv4WXSTslfgksePEhGrLGMtGcKuik4grFDLXJu8rbE5D6hT6ruavG4KX7++GbRc4uRdLxddC5Bj8Kx+pp9/1gTCm4SvMJXfHYIw8kGoQ== 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=3G6X6Xj3nyW/H3bofwKLYkJateA8S/4vWKzWhGq5P1I=; b=CkJ3hid9YPgmf9UsVUlDLm1h5aY/lYfv9Ki5YM4am56vxBRxbNsvChGvoPwmUDspRuD+1TJzE7IyFj9G21YeO+8A4GcuP/9P4Pz0gDWA8+i9rYUoKd2YSn3ASl3IeaqY9hA+yJyxFfKjlVfwS/XRll3iTBH9ldZ/gwrUuu9gjvg7HsN1ZGJR8wHQrbTdXqC9o/OEWtZW13Oac9zUlnvYpgdpSLI8mcq0WTbXBZmeIynd9NBJZcW9S3GfYPPDVzUMiwH3M4Gi9HSnR/vK48PT4HOfgKL2fE6IB0sNkkYfQvbZYtq27IwcHudsWJmxTFiN/WTVCmAgZDfJCNTJiYhymg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3G6X6Xj3nyW/H3bofwKLYkJateA8S/4vWKzWhGq5P1I=; b=tlZ9OgnN8ZD6k7BF2726Jjsg4toYO7uOG9/8f3Y8L+m75EZwlkElRiNJfwlM2b3utfLbxbzeUgRAkRvxMpBx3fUlinv7dzREmDuLlA1xqhmYxJba7dUYptCMhg7EvMSigygZd3xcUMFfRraHMmJXZbrlzPfXfrsWDFhXub3NrHc= Received: from VE1PR08MB5149.eurprd08.prod.outlook.com (20.179.30.27) by VE1PR08MB5021.eurprd08.prod.outlook.com (20.179.30.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.24; Wed, 23 Oct 2019 03:16:01 +0000 Received: from VE1PR08MB5149.eurprd08.prod.outlook.com ([fe80::8c82:8d9c:c78d:22a6]) by VE1PR08MB5149.eurprd08.prod.outlook.com ([fe80::8c82:8d9c:c78d:22a6%7]) with mapi id 15.20.2367.022; Wed, 23 Oct 2019 03:16:01 +0000 From: Honnappa Nagarahalli To: "Joyce Kong (Arm Technology China)" , "dev@dpdk.org" CC: nd , "thomas@monjalon.net" , "jerinj@marvell.com" , "stephen@networkplumber.org" , "mb@smartsharesystems.com" , "Gavin Hu (Arm Technology China)" , "ravi1.kumar@amd.com" , "rmody@marvell.com" , "shshaikh@marvell.com" , "xuanziyang2@huawei.com" , "cloud.wangxiaoyun@huawei.com" , "zhouguoyang@huawei.com" , Honnappa Nagarahalli , nd Thread-Topic: [PATCH v2 3/6] net/axgbe: use common rte bit operation APIs instead Thread-Index: AQHViU1blOy8AKcVE06cPbADxxQdeqdnjK1A Date: Wed, 23 Oct 2019 03:16:01 +0000 Message-ID: References: <1571125801-45773-1-git-send-email-joyce.kong@arm.com> <1571799298-18873-4-git-send-email-joyce.kong@arm.com> In-Reply-To: <1571799298-18873-4-git-send-email-joyce.kong@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 560eee06-4604-4216-85c7-832a04bef4af.0 x-checkrecipientchecked: true Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; x-originating-ip: [217.140.111.135] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a21790c1-3015-48a9-d7d4-08d7576759f5 X-MS-TrafficTypeDiagnostic: VE1PR08MB5021:|VE1PR08MB5021:|DB6PR0801MB2072: x-ld-processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:1265;OLM:1265; x-forefront-prvs: 019919A9E4 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(979002)(4636009)(396003)(136003)(346002)(376002)(39860400002)(366004)(189003)(199004)(186003)(14454004)(64756008)(478600001)(11346002)(446003)(33656002)(81156014)(25786009)(81166006)(8936002)(8676002)(86362001)(2501003)(66476007)(66556008)(66946007)(486006)(66446008)(66066001)(52536014)(5660300002)(102836004)(26005)(256004)(76116006)(6506007)(476003)(305945005)(6246003)(76176011)(71190400001)(7736002)(6116002)(7416002)(4326008)(3846002)(74316002)(55016002)(229853002)(9686003)(6436002)(99286004)(71200400001)(110136005)(316002)(7696005)(54906003)(2906002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5021; H:VE1PR08MB5149.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: YbXXBNyR8dW5yPUnTHMGW9e1DSMxuPkGZq9oJYn08aD+iKPNS6JCtzYSMbtA40JbQ9JVHHIIyr3OdW96BFaIEQGgGsn1OTHtmaC4Xx/G5rg5CzowowX6DFI8jsBP7i9syry/jBvFOFLfXpQSRjA9PXWRh7yT/l+L4tYu4x/R0ASyl2MgawhK0wvnWVv4Skf2WjFjlKknZOh5e628FWn6bXgbGRGh6yJsqRS5tMgIyHMEj9ST5l5KzmIZX+nUYClH6cm3V8ha7sEZOZ8oh1DmapzuAOcLDWop1wlwugXwVikGkbfyGdG95F77o8UPZNBC6TR5Xd8ndz4ywfXO9ulcUarsADKHY2S6zh3EFBnpVJpsZbigCWoeoIySd8w4UfP8g+H+c1RLpQfo3OTB+Lus5/KD8bd0FS1ZNKxkpu8PxkBWQVOd+/0wSsHjmSJvTkr6 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5021 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT060.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(979002)(4636009)(376002)(39860400002)(136003)(396003)(346002)(1110001)(339900001)(199004)(189003)(74316002)(186003)(99286004)(2501003)(26005)(76130400001)(7696005)(105606002)(55016002)(46406003)(2906002)(229853002)(305945005)(7736002)(76176011)(22756006)(3846002)(4326008)(6116002)(70206006)(70586007)(102836004)(47776003)(23726003)(9686003)(52536014)(11346002)(33656002)(6246003)(316002)(26826003)(336012)(97756001)(478600001)(36906005)(66066001)(14454004)(356004)(86362001)(476003)(54906003)(486006)(126002)(25786009)(81156014)(81166006)(6506007)(8676002)(446003)(8746002)(110136005)(8936002)(50466002)(5660300002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0801MB2072; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Fail; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 51bb7a79-19d7-422f-06d9-08d7576754f5 NoDisclaimer: True X-Forefront-PRVS: 019919A9E4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hw0Ba/mMHYyueuiCrOqTzYLb+/dQrsYAKnM3qBHcYHRkb8lkY98pfGTNb7V8VgwZk+dUcBGUyoJQGp4tUbgIf96q7iKTvZOxvkM4Uu/HOuoA/Ex0lX9t1wPsvJGEsHYF4sxNPQycrv7V80SuH2CiAzME20zxdSCDhAr285iiVydivfchFjtsVhcBQgNjuEUW6ZW+QAGOpjywFe1K33zJ1tS3jYGUwMsMzRZPfYcbOJioUxGFfSc9rqbSQNgFA1+4XmJvzXgOnXI1is0ShWavzaM5cu2fc3eC3bv9bd7I0y0M4JuABN5Q4+M5Q+n0j6gfZYjUSFzYBiZqSGIWcceUZerIHUlX3WMLbIf8qFk/KAFc/ZePh/4zve6tyFO1okJ7i8/ZQpm7XupDcKzpWoxi4Zap85J4VhlAc7KTJ3lVB1F4hudq++G2764g/SgrRLIL X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2019 03:16:09.7658 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a21790c1-3015-48a9-d7d4-08d7576759f5 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2072 Subject: Re: [dpdk-dev] [PATCH v2 3/6] net/axgbe: use common rte bit operation APIs instead 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" >=20 > Remove its own bit operation APIs and use the common one, this can reduce > the code duplication largely. >=20 > Signed-off-by: Joyce Kong > Reviewed-by: Gavin Hu > --- > drivers/net/axgbe/axgbe_common.h | 29 +---------------------------- > drivers/net/axgbe/axgbe_ethdev.c | 14 +++++++------- > drivers/net/axgbe/axgbe_mdio.c | 14 +++++++------- > 3 files changed, 15 insertions(+), 42 deletions(-) >=20 > diff --git a/drivers/net/axgbe/axgbe_common.h > b/drivers/net/axgbe/axgbe_common.h > index 34f60f1..e44ec7d 100644 > --- a/drivers/net/axgbe/axgbe_common.h > +++ b/drivers/net/axgbe/axgbe_common.h > @@ -22,6 +22,7 @@ > #include >=20 > #include > +#include > #include > #include > #include > @@ -1674,34 +1675,6 @@ do { > \ > #define time_after_eq(a, b) ((long)((a) - (b)) >=3D 0) > #define time_before_eq(a, b) time_after_eq(b, a) >=20 > -/*---bitmap support apis---*/ > -static inline int axgbe_test_bit(int nr, volatile unsigned long *addr) -= { > - int res; > - > - rte_mb(); > - res =3D ((*addr) & (1UL << nr)) !=3D 0; > - rte_mb(); > - return res; > -} This function uses rte_mb before and after the load. Where as the new API u= ses just 'acquire', please ensure 'acquire' is enough. > - > -static inline void axgbe_set_bit(unsigned int nr, volatile unsigned long= *addr) > -{ > - __sync_fetch_and_or(addr, (1UL << nr)); > -} > - > -static inline void axgbe_clear_bit(int nr, volatile unsigned long *addr)= -{ > - __sync_fetch_and_and(addr, ~(1UL << nr)); > -} > - > -static inline int axgbe_test_and_clear_bit(int nr, volatile unsigned lon= g *addr) > -{ > - unsigned long mask =3D (1UL << nr); > - > - return __sync_fetch_and_and(addr, ~mask) & mask; > -} > - > static inline unsigned long msecs_to_timer_cycles(unsigned int m) { > return rte_get_timer_hz() * (m / 1000); diff --git > a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c > index d1f160e..8c8e5ff 100644 > --- a/drivers/net/axgbe/axgbe_ethdev.c > +++ b/drivers/net/axgbe/axgbe_ethdev.c > @@ -201,8 +201,8 @@ axgbe_dev_start(struct rte_eth_dev *dev) > axgbe_dev_enable_tx(dev); > axgbe_dev_enable_rx(dev); >=20 > - axgbe_clear_bit(AXGBE_STOPPED, &pdata->dev_state); > - axgbe_clear_bit(AXGBE_DOWN, &pdata->dev_state); > + rte_io_clear_bit(AXGBE_STOPPED, &pdata->dev_state); > + rte_io_clear_bit(AXGBE_DOWN, &pdata->dev_state); > return 0; > } >=20 > @@ -216,17 +216,17 @@ axgbe_dev_stop(struct rte_eth_dev *dev) >=20 > rte_intr_disable(&pdata->pci_dev->intr_handle); >=20 > - if (axgbe_test_bit(AXGBE_STOPPED, &pdata->dev_state)) > + if (rte_io_test_bit(AXGBE_STOPPED, &pdata->dev_state)) > return; >=20 > - axgbe_set_bit(AXGBE_STOPPED, &pdata->dev_state); > + rte_io_set_bit(AXGBE_STOPPED, &pdata->dev_state); > axgbe_dev_disable_tx(dev); > axgbe_dev_disable_rx(dev); >=20 > pdata->phy_if.phy_stop(pdata); > pdata->hw_if.exit(pdata); > memset(&dev->data->dev_link, 0, sizeof(struct rte_eth_link)); > - axgbe_set_bit(AXGBE_DOWN, &pdata->dev_state); > + rte_io_set_bit(AXGBE_DOWN, &pdata->dev_state); > } >=20 > /* Clear all resources like TX/RX queues. */ @@ -598,8 +598,8 @@ > eth_axgbe_dev_init(struct rte_eth_dev *eth_dev) >=20 > pdata =3D eth_dev->data->dev_private; > /* initial state */ > - axgbe_set_bit(AXGBE_DOWN, &pdata->dev_state); > - axgbe_set_bit(AXGBE_STOPPED, &pdata->dev_state); > + rte_io_set_bit(AXGBE_DOWN, &pdata->dev_state); > + rte_io_set_bit(AXGBE_STOPPED, &pdata->dev_state); > pdata->eth_dev =3D eth_dev; >=20 > pci_dev =3D RTE_DEV_TO_PCI(eth_dev->device); diff --git > a/drivers/net/axgbe/axgbe_mdio.c b/drivers/net/axgbe/axgbe_mdio.c index > 2721e5c..4164564 100644 > --- a/drivers/net/axgbe/axgbe_mdio.c > +++ b/drivers/net/axgbe/axgbe_mdio.c > @@ -743,7 +743,7 @@ static int __axgbe_phy_config_aneg(struct > axgbe_port *pdata) { > int ret; >=20 > - axgbe_set_bit(AXGBE_LINK_INIT, &pdata->dev_state); > + rte_io_set_bit(AXGBE_LINK_INIT, &pdata->dev_state); > pdata->link_check =3D rte_get_timer_cycles(); >=20 > ret =3D pdata->phy_if.phy_impl.an_config(pdata); > @@ -807,9 +807,9 @@ static int axgbe_phy_config_aneg(struct axgbe_port > *pdata) >=20 > ret =3D __axgbe_phy_config_aneg(pdata); > if (ret) > - axgbe_set_bit(AXGBE_LINK_ERR, &pdata->dev_state); > + rte_io_set_bit(AXGBE_LINK_ERR, &pdata->dev_state); > else > - axgbe_clear_bit(AXGBE_LINK_ERR, &pdata->dev_state); > + rte_io_clear_bit(AXGBE_LINK_ERR, &pdata->dev_state); >=20 > pthread_mutex_unlock(&pdata->an_mutex); >=20 > @@ -880,7 +880,7 @@ static void axgbe_phy_status(struct axgbe_port > *pdata) > unsigned int link_aneg; > int an_restart; >=20 > - if (axgbe_test_bit(AXGBE_LINK_ERR, &pdata->dev_state)) { > + if (rte_io_test_bit(AXGBE_LINK_ERR, &pdata->dev_state)) { > pdata->phy.link =3D 0; > goto adjust_link; > } > @@ -900,10 +900,10 @@ static void axgbe_phy_status(struct axgbe_port > *pdata) > return; > } > axgbe_phy_status_result(pdata); > - if (axgbe_test_bit(AXGBE_LINK_INIT, &pdata->dev_state)) > - axgbe_clear_bit(AXGBE_LINK_INIT, &pdata- > >dev_state); > + if (rte_io_test_bit(AXGBE_LINK_INIT, &pdata->dev_state)) > + rte_io_clear_bit(AXGBE_LINK_INIT, &pdata- > >dev_state); > } else { > - if (axgbe_test_bit(AXGBE_LINK_INIT, &pdata->dev_state)) { > + if (rte_io_test_bit(AXGBE_LINK_INIT, &pdata->dev_state)) { > axgbe_check_link_timeout(pdata); >=20 > if (link_aneg) > -- > 2.7.4