From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id A5227A0096 for ; Mon, 8 Apr 2019 13:23:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 39A795911; Mon, 8 Apr 2019 13:22:58 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00041.outbound.protection.outlook.com [40.107.0.41]) by dpdk.org (Postfix) with ESMTP id 0C1FA2C55 for ; Mon, 8 Apr 2019 13:22:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ii0/foC+3T3iQrMHL4Gv609zxTZSdpqJE3RQsREq5Jo=; b=ShEDBfzRzh5Icno4/BGoEXUBwxVd7mGzRTCoef+1EK/Qz2mxuZDCMFfM81JCpFeKzvLfotLlnyxvc6lraSbc/vZUVCotbCQKzb6CgSSsuTeSLKR7tibuklL8jzg8ITj/LjLSqxjZNvWd/7TTKz+5dTeBr8zYZTR84TpwXVA0Fd0= Received: from VE1PR04MB6365.eurprd04.prod.outlook.com (10.255.118.78) by VE1PR04MB6606.eurprd04.prod.outlook.com (20.179.235.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.13; Mon, 8 Apr 2019 11:22:38 +0000 Received: from VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0]) by VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0%3]) with mapi id 15.20.1771.016; Mon, 8 Apr 2019 11:22:38 +0000 From: Gagandeep Singh To: "dev@dpdk.org" , "ferruh.yigit@intel.com" CC: Gagandeep Singh Thread-Topic: [PATCH 06/13] net/enetc: replace register read/write macros with functions Thread-Index: AQHU7f1fT7yI27M310CFEbCFWBWchQ== Date: Mon, 8 Apr 2019 11:22:37 +0000 Message-ID: <1554745507-15089-7-git-send-email-g.singh@nxp.com> References: <1554745507-15089-1-git-send-email-g.singh@nxp.com> In-Reply-To: <1554745507-15089-1-git-send-email-g.singh@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0003.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::13) To VE1PR04MB6365.eurprd04.prod.outlook.com (2603:10a6:803:12a::14) x-mailer: git-send-email 1.9.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=G.Singh@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [92.120.1.67] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3e3078cd-a20c-4b50-c132-08d6bc148161 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:VE1PR04MB6606; x-ms-traffictypediagnostic: VE1PR04MB6606: x-microsoft-antispam-prvs: x-forefront-prvs: 0001227049 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(376002)(346002)(39860400002)(396003)(136003)(199004)(189003)(76176011)(97736004)(81156014)(71200400001)(71190400001)(72206003)(3846002)(25786009)(81166006)(53936002)(2616005)(5660300002)(6116002)(8676002)(7736002)(446003)(478600001)(8936002)(11346002)(305945005)(2906002)(256004)(66066001)(6512007)(476003)(6436002)(486006)(50226002)(2501003)(99286004)(106356001)(86362001)(110136005)(4326008)(6486002)(68736007)(105586002)(6506007)(52116002)(316002)(26005)(386003)(14454004)(186003)(36756003)(102836004); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6606; H:VE1PR04MB6365.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: LdBGnj9wwcQWZRX1vKnsWmJ9i2LD63YREBH0qPUMz0j08Sogho+f+vfzl0wtYwHreJ/HUysShAIoywNoBOIVSuM4D+nvAJXKo19Q/R/+gWPyp96hSxgXKpeYAMD9lcrgkt7Ie9S7tCxd0qBw7SFgCcVDm/UaAZgZgLR2G7hKt/47gWPUAIoIVfSrBL38x5wM0LtaZ7ypwWbToutdLFkAXAPePi7BSjfje3mViIj30vzF23NE293sKT1Elst0vkD0HnZLm157n/A8LVHSDmHDjSSqDsxZmV67gxdre2aSqoDfJd2PvOkd5373MQpMlZRKtL4OnBx2ICzstIhtFWz4gfsaGVKlxykGF9inu85LUKcj6Vk98fpQwlZZ+GylcqmMh8nxxgVEWfGHUJV4HkbLoQ9m7/5009r8gzYix4If7js= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e3078cd-a20c-4b50-c132-08d6bc148161 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2019 11:22:37.9741 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6606 Subject: [dpdk-dev] [PATCH 06/13] net/enetc: replace register read/write macros with functions 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" Message-ID: <20190408112237.0sYU9fjDfllMt5xkIxyr1QaU1a05YEgfkdblcbI7SEw@z> Replacing read-write macros with already available read-write functions. Signed-off-by: Gagandeep Singh --- drivers/net/enetc/enetc.h | 7 +---- drivers/net/enetc/enetc_ethdev.c | 61 ++++++++++++++++++++----------------= ---- 2 files changed, 31 insertions(+), 37 deletions(-) diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h index 0e80d1c..56454dc 100644 --- a/drivers/net/enetc/enetc.h +++ b/drivers/net/enetc/enetc.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2018 NXP + * Copyright 2018-2019 NXP */ =20 #ifndef _ENETC_H_ @@ -86,11 +86,6 @@ struct enetc_eth_adapter { #define ENETC_DEV_PRIVATE_TO_INTR(adapter) \ (&((struct enetc_eth_adapter *)adapter)->intr) =20 -#define ENETC_GET_HW_ADDR(reg, addr) ((void *)(((size_t)reg) + (addr))) -#define ENETC_REG_READ(addr) (*(uint32_t *)addr) -#define ENETC_REG_WRITE(addr, val) (*(uint32_t *)addr =3D val) -#define ENETC_REG_WRITE_RELAXED(addr, val) (*(uint32_t *)addr =3D val) - /* * RX/TX ENETC function prototypes */ diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_eth= dev.c index 99c2ce7..d403d7a 100644 --- a/drivers/net/enetc/enetc_ethdev.c +++ b/drivers/net/enetc/enetc_ethdev.c @@ -131,28 +131,31 @@ static int enetc_stats_get(struct rte_eth_dev *dev, { struct enetc_eth_hw *hw =3D ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw =3D &hw->hw; uint32_t val; =20 PMD_INIT_FUNC_TRACE(); - val =3D ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, - ENETC_PM0_CMD_CFG)); - ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG), - val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN); + val =3D enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG); + enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG, + val | ENETC_PM0_TX_EN | ENETC_PM0_RX_EN); =20 /* Enable port */ - val =3D ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR)); - ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR), - val | ENETC_PMR_EN); + val =3D enetc_port_rd(enetc_hw, ENETC_PMR); + enetc_port_wr(enetc_hw, ENETC_PMR, val | ENETC_PMR_EN); =20 /* set auto-speed for RGMII */ - if (enetc_port_rd(&hw->hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG) { - enetc_port_wr(&hw->hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_RGAUTO); - enetc_port_wr(&hw->hw, ENETC_PM1_IF_MODE, ENETC_PM0_IFM_RGAUTO); + if (enetc_port_rd(enetc_hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG) { + enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE, + ENETC_PM0_IFM_RGAUTO); + enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE, + ENETC_PM0_IFM_RGAUTO); } - if (enetc_global_rd(&hw->hw, + if (enetc_global_rd(enetc_hw, ENETC_G_EPFBLPR(1)) =3D=3D ENETC_G_EPFBLPR1_XGMII) { - enetc_port_wr(&hw->hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_XGMII); - enetc_port_wr(&hw->hw, ENETC_PM1_IF_MODE, ENETC_PM0_IFM_XGMII); + enetc_port_wr(enetc_hw, ENETC_PM0_IF_MODE, + ENETC_PM0_IFM_XGMII); + enetc_port_wr(enetc_hw, ENETC_PM1_IF_MODE, + ENETC_PM0_IFM_XGMII); } =20 return 0; @@ -163,18 +166,17 @@ static int enetc_stats_get(struct rte_eth_dev *dev, { struct enetc_eth_hw *hw =3D ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw =3D &hw->hw; uint32_t val; =20 PMD_INIT_FUNC_TRACE(); /* Disable port */ - val =3D ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR)); - ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PMR), - val & (~ENETC_PMR_EN)); - - val =3D ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, - ENETC_PM0_CMD_CFG)); - ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PM0_CMD_CFG), - val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN))); + val =3D enetc_port_rd(enetc_hw, ENETC_PMR); + enetc_port_wr(enetc_hw, ENETC_PMR, val & (~ENETC_PMR_EN)); + + val =3D enetc_port_rd(enetc_hw, ENETC_PM0_CMD_CFG); + enetc_port_wr(enetc_hw, ENETC_PM0_CMD_CFG, + val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN))); } =20 static void @@ -221,6 +223,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev, { struct enetc_eth_hw *hw =3D ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw =3D &hw->hw; struct rte_eth_link link; uint32_t status; =20 @@ -228,8 +231,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev, =20 memset(&link, 0, sizeof(link)); =20 - status =3D ENETC_REG_READ(ENETC_GET_HW_ADDR(hw->hw.port, - ENETC_PM0_STATUS)); + status =3D enetc_port_rd(enetc_hw, ENETC_PM0_STATUS); =20 if (status & ENETC_LINK_MODE) link.link_duplex =3D ETH_LINK_FULL_DUPLEX; @@ -262,6 +264,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev, enetc_hardware_init(struct enetc_eth_hw *hw) { uint32_t psipmr =3D 0; + struct enetc_hw *enetc_hw =3D &hw->hw; =20 PMD_INIT_FUNC_TRACE(); /* Calculating and storing the base HW addresses */ @@ -269,8 +272,7 @@ static int enetc_stats_get(struct rte_eth_dev *dev, hw->hw.global =3D (void *)((size_t)hw->hw.reg + ENETC_GLOBAL_BASE); =20 /* Enabling Station Interface */ - ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.reg, ENETC_SIMR), - ENETC_SIMR_EN); + enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN); =20 /* Setting to accept broadcast packets for each inetrface */ psipmr |=3D ENETC_PSIPMR_SET_UP(0) | ENETC_PSIPMR_SET_MP(0) | @@ -280,14 +282,11 @@ static int enetc_stats_get(struct rte_eth_dev *dev, psipmr |=3D ENETC_PSIPMR_SET_UP(2) | ENETC_PSIPMR_SET_MP(2) | ENETC_PSIPMR_SET_VLAN_MP(2); =20 - ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMR), - psipmr); + enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr); =20 /* Enabling broadcast address */ - ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR0(0)), - 0xFFFFFFFF); - ENETC_REG_WRITE(ENETC_GET_HW_ADDR(hw->hw.port, ENETC_PSIPMAR1(0)), - 0xFFFF << 16); + enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), 0xFFFFFFFF); + enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), 0xFFFF << 16); =20 return 0; } --=20 1.9.1