From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0087.outbound.protection.outlook.com [104.47.42.87]) by dpdk.org (Postfix) with ESMTP id D72731B1E9 for ; Tue, 9 Oct 2018 11:31:34 +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=NXSRAamjdsI36WqLgtQlRtrruIYBJVrkx9f9eQ5nSbY=; b=TK3e0DGYpKAqL4hoZ7LYkFr7sNQRKA7mga5XNeyBuqy1ANLmdZnUZKufZFvfFBbY15B6keEydCbYokcZlsucdBwFMRq9g1iHwMReZnT5LMM0b5KlqUYQh3Tcg7UIV+qfoc11gTdPJEkRjOz7b2ksFQUekyiAb/n/Ijp13XTY8Ec= Received: from BLUPR0701MB1651.namprd07.prod.outlook.com (10.163.84.21) by BLUPR0701MB2100.namprd07.prod.outlook.com (10.163.122.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.27; Tue, 9 Oct 2018 09:31:32 +0000 Received: from BLUPR0701MB1651.namprd07.prod.outlook.com ([fe80::7c97:1527:4c0:8b46]) by BLUPR0701MB1651.namprd07.prod.outlook.com ([fe80::7c97:1527:4c0:8b46%3]) with mapi id 15.20.1207.024; Tue, 9 Oct 2018 09:31:32 +0000 From: Igor Russkikh To: "dev@dpdk.org" CC: Pavel Belous , Igor Russkikh , "ferruh.yigit@intel.com" , Pavel Belous Thread-Topic: [PATCH v4 03/22] net/atlantic: hardware register access routines Thread-Index: AQHUX7Ldwn6EDFQJr02s3nkRKgHLiQ== Date: Tue, 9 Oct 2018 09:31:32 +0000 Message-ID: <7304c5885f984588016f0ab899c1f496951e3485.1539075891.git.igor.russkikh@aquantia.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM0PR01CA0028.eurprd01.prod.exchangelabs.com (2603:10a6:208:69::41) To BLUPR0701MB1651.namprd07.prod.outlook.com (2a01:111:e400:58c6::21) 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; BLUPR0701MB2100; 6:9Iwlpg50+AWU/63yH4zG3YhVuF2+3S1TvpfwljEq+EgajOzfPwho38Ke6vbsw45LjznYVJ4GCaJKWcxRdFzirkZ6qlF4a8SwlTVMNBb+eKpZmztKNKGpV9RKkJab9ShQFrxwPf/Rgyf+q4uDMVPOnmi8yz+UHkzmwXPJ/RVtqQCV0wVtcO9fBbe6g5XzLhCD6qwMPkNTWwpk1NSow0vaRAnIa48THlN7cd1TGjS8uUborQOrEPCBxUtT9a4j46002Vxz/0Z/tklzDeCLIB0RBteAKw22n45WyZ3KhJSmLNWk/D+nkoNHnMmYoJwKzRvEbNrRLFtElU+EvU3PobktSLxQnBJW/8AsiDofCa5YJPdPOeMUvyHggUaNNqKaF97JwOHKYm3bJkX9LzsXseIZOQn+Zbz2KJeGaUnzuK5f0xIVnwjUFi6CrM2DbGnkXI75WEK+FdadEdKmk1E2ozu77w==; 5:Wox6McJNlyIki9JuNlPUnperBgOYS2NwP4v1+ibmiBAu4KKn++pgdIMMN6Dd/tICYTEUZjCNj7grFolJFYdb7WnCMleOan1O6tFAefAkzRY6TYmj1eQgwWbwywGvy4GJ71+ufFxToFQkChbEJrOHPIeORLDfEFoPhLoRrl+EXVU=; 7:GFnoeRmkVyr2WP89Up+tM7uPqCTeGH+DdLKFI0vOQ204gUx3KE3bCa9l2Bdww/Ugh223p6wHVocZCP0+6paL6JyXnlLdx0x4iGEv1Dqx+q4Rh0u8evQj75j2w42QGTbwll3BFs/aKcmhbkCTpJCTcT7M987jY9pmbivhSumBLD6jXK6lvlL4gTvpubxErEDLsjOyY4sRi1HnNIny+BC+KqF7Jfvcy4lq+cMkFZ29nY7FGQrHh4ovPsV9QW1ZFUzT x-ms-office365-filtering-correlation-id: 567362f0-83f0-4f6a-5974-08d62dc9ff95 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BLUPR0701MB2100; x-ms-traffictypediagnostic: BLUPR0701MB2100: 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)(3231355)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699051); SRVR:BLUPR0701MB2100; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB2100; x-forefront-prvs: 08200063E9 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(376002)(346002)(39850400004)(396003)(189003)(199004)(305945005)(36756003)(25786009)(5250100002)(476003)(86362001)(72206003)(2351001)(5660300001)(6916009)(446003)(478600001)(44832011)(11346002)(2906002)(106356001)(7736002)(486006)(4326008)(3846002)(6116002)(105586002)(97736004)(2616005)(256004)(26005)(186003)(66066001)(2501003)(6512007)(316002)(53936002)(102836004)(76176011)(14454004)(5640700003)(575784001)(107886003)(118296001)(71190400001)(52116002)(68736007)(71200400001)(8936002)(2900100001)(8676002)(1730700003)(81156014)(81166006)(99286004)(54906003)(6436002)(6506007)(386003)(6486002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB2100; H:BLUPR0701MB1651.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: dB5lbDNESmPDOn0w7kLD8TOXJPo3rE99QFXs9w0xZ1cJXQiMlNT7bDV47/KJ2OLq+zu2BeaR41KmmA2OI6g7QPnLME+wTXRYMmm+z7yU/tbAZ0stjTMfSatK65nrQZpfkEkoznMqYB1e6prZV+wMDc7nfiPgN7RaRp2OrR2bvThcnqNICvXM2CztN8urK8BSptLOUtfKaEFd5NM0XCL5zB1Fhk3DVwIFAFwndKYZ7VZ01xenp4ClHZbyh0X7f4q1lKZm/cxHOlhburiRtnOv91qgnVMG/td0QH1hzgsVQGj4Y1cv/yjZs65viUUC+pgw6mvkbys6IUje4Td0Z9dR+OS2H3jQa8iwHq+J5Y8jSdo= 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: 567362f0-83f0-4f6a-5974-08d62dc9ff95 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Oct 2018 09:31:32.2921 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB2100 Subject: [dpdk-dev] [PATCH v4 03/22] net/atlantic: hardware register access routines 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: Tue, 09 Oct 2018 09:31:35 -0000 Signed-off-by: Igor Russkikh Signed-off-by: Pavel Belous --- drivers/net/atlantic/Makefile | 1 + drivers/net/atlantic/atl_hw_regs.c | 52 ++++++++++++++++++++++++++++++++++= +++ drivers/net/atlantic/atl_hw_regs.h | 53 ++++++++++++++++++++++++++++++++++= ++++ drivers/net/atlantic/atl_types.h | 4 +++ drivers/net/atlantic/meson.build | 1 + 5 files changed, 111 insertions(+) create mode 100644 drivers/net/atlantic/atl_hw_regs.c create mode 100644 drivers/net/atlantic/atl_hw_regs.h diff --git a/drivers/net/atlantic/Makefile b/drivers/net/atlantic/Makefile index e42ce5b178ab..8613ced71732 100644 --- a/drivers/net/atlantic/Makefile +++ b/drivers/net/atlantic/Makefile @@ -23,5 +23,6 @@ LDLIBS +=3D -lrte_bus_pci # all source are stored in SRCS-y # SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) +=3D atl_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) +=3D atl_hw_regs.c =20 include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/net/atlantic/atl_hw_regs.c b/drivers/net/atlantic/atl_= hw_regs.c new file mode 100644 index 000000000000..bd42c8341e2b --- /dev/null +++ b/drivers/net/atlantic/atl_hw_regs.c @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) +/* Copyright (C) 2014-2017 aQuantia Corporation. */ + +/* File aq_hw_utils.c: Definitions of helper functions used across + * hardware layer. + */ + +#include "atl_hw_regs.h" + +#include +#include + +void aq_hw_write_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, + u32 shift, u32 val) +{ + if (msk ^ ~0) { + u32 reg_old, reg_new; + + reg_old =3D aq_hw_read_reg(aq_hw, addr); + reg_new =3D (reg_old & (~msk)) | (val << shift); + + if (reg_old !=3D reg_new) + aq_hw_write_reg(aq_hw, addr, reg_new); + } else { + aq_hw_write_reg(aq_hw, addr, val); + } +} + +u32 aq_hw_read_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, u32 shift= ) +{ + return ((aq_hw_read_reg(aq_hw, addr) & msk) >> shift); +} + +u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg) +{ + return rte_le_to_cpu_32(rte_read32((u8 *)hw->mmio + reg)); +} + +void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value) +{ + rte_write32((rte_cpu_to_le_32(value)), (u8 *)hw->mmio + reg); +} + +int aq_hw_err_from_flags(struct aq_hw_s *hw) +{ + int err =3D 0; + + if (aq_hw_read_reg(hw, 0x10U) =3D=3D ~0U) + return -ENXIO; + + return err; +} diff --git a/drivers/net/atlantic/atl_hw_regs.h b/drivers/net/atlantic/atl_= hw_regs.h new file mode 100644 index 000000000000..a2d6ca804e5e --- /dev/null +++ b/drivers/net/atlantic/atl_hw_regs.h @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) */ +/* Copyright (C) 2014-2017 aQuantia Corporation. */ + +/* File aq_hw_utils.h: Declaration of helper functions used across hardwar= e + * layer. + */ + +#ifndef AQ_HW_UTILS_H +#define AQ_HW_UTILS_H + +#include +#include +#include +#include +#include +#include "atl_common.h" +#include "atl_types.h" + + +#ifndef HIDWORD +#define LODWORD(_qw) ((u32)(_qw)) +#define HIDWORD(_qw) ((u32)(((_qw) >> 32) & 0xffffffff)) +#endif + +#define AQ_HW_SLEEP(_US_) rte_delay_ms(_US_) + +#define mdelay rte_delay_ms +#define udelay rte_delay_us +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) +#define BIT(x) (1UL << (x)) + +#define AQ_HW_WAIT_FOR(_B_, _US_, _N_) \ +do { \ + unsigned int AQ_HW_WAIT_FOR_i; \ + for (AQ_HW_WAIT_FOR_i =3D _N_; (!(_B_)) && (AQ_HW_WAIT_FOR_i);\ + --AQ_HW_WAIT_FOR_i) {\ + udelay(_US_); \ + } \ + if (!AQ_HW_WAIT_FOR_i) {\ + err =3D -ETIMEDOUT; \ + } \ +} while (0) + +#define ATL_WRITE_FLUSH(aq_hw) { (void)aq_hw_read_reg(aq_hw, 0x10); } + +void aq_hw_write_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, + u32 shift, u32 val); +u32 aq_hw_read_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, u32 shift= ); +u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg); +void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value); +int aq_hw_err_from_flags(struct aq_hw_s *hw); + +#endif /* AQ_HW_UTILS_H */ diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_ty= pes.h index d8c2560807d3..725b0c4dc670 100644 --- a/drivers/net/atlantic/atl_types.h +++ b/drivers/net/atlantic/atl_types.h @@ -22,4 +22,8 @@ typedef uint64_t u64; #define min(a, b) RTE_MIN(a, b) #define max(a, b) RTE_MAX(a, b) =20 +struct aq_hw_s { + void *mmio; +}; + #endif diff --git a/drivers/net/atlantic/meson.build b/drivers/net/atlantic/meson.= build index c5a2546ef657..cd6a0f637a7d 100644 --- a/drivers/net/atlantic/meson.build +++ b/drivers/net/atlantic/meson.build @@ -3,4 +3,5 @@ =20 sources =3D files( 'atl_ethdev.c', + 'atl_hw_regs.c', ) --=20 2.7.4