From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0061.outbound.protection.outlook.com [104.47.38.61]) by dpdk.org (Postfix) with ESMTP id 850941B446 for ; Thu, 11 Oct 2018 12:35:00 +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=M67Ae2jQX59iRHihVErnTHBmM6cCjuFcgpBbDMOGnlQ=; b=kzC3wYoO72r6R5d6G6c+GwBc5KJAr5576s6r6hpFuSDIahgwkMIc9OMoQsnmPEq8OiClVyPjtYvkCt8rQR/MiTCrAl2sgYvJuhqlzvLUl56SC+74l7VqKdF20fpFuoXSIoo4TOnPJseW3MNv7gm59XR3mcMrXRomVAI5HVGLVXs= 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:34:58 +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:34:58 +0000 From: Igor Russkikh To: "dev@dpdk.org" CC: Pavel Belous , Igor Russkikh , "ferruh.yigit@intel.com" Thread-Topic: [PATCH v5 04/23] net/atlantic: hardware registers access routines Thread-Index: AQHUYU4OzQU150JbRkePzGHG9dkHDg== Date: Thu, 11 Oct 2018 10:34:58 +0000 Message-ID: <35272078378cfe0282178ba48e3a83095a3f9718.1539249721.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: 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:ibKT0Y2cXwi7709oVs8OJxJXIpv6j4V4/R+vz+z6wZQkP0qwPEJZyZBmYzxLuM1WtNDupiqrJVMQBHvERGl9TMM6l7zg282VynUCQWeyW/C9FTRWpquUaRVEWcy69zoORR8HdWlFTxFOaHWUqozZuQLq/UnL5ApboMrfahucFQ1YgAA/jeBecXbE6dJc7E4RY60OdhcfcaUaArDUwHzoX+65VIaYv/6ZtLMqHHBehz44LpWn+o62T0Ji3pOZP7UceO5sYH4BCbUM9yHsdyipikm8FGjEoM6Sf0pZwihkz5ziAr4Q/XI1QehEk3++SsC0qApiJCV2oMJjZf8qRjG41SaHgUKEftrHtBBI1BoeWbaxApMrU7APTghlUR96q6dVHVVURZf6HEf1KKeeHDy9WdCUtiTXBLAdtUaZ1XF2BIVx23SQ8kgrmX8D8wMirzbYBStMboMVrZluLWPpkCUVQ9m30BOgQuCW/Wuxxg1/ZUc=; 5:0r0GR2nrw480BQIRD5INCGvhYe3Y4W+jY8jm+eQiJVFfVcxN3IVPBq0PYIo3ScVgTwkvVtOEw4CGi+2kEdBaRxAX3LG1VKMaTRWWQt9eOVfvl5Zo0VNcQZwvDVoq/Tt2ffTms9cv/FrzRQ9bS5Nc9l6XWMBBxriLNhzJ9IM0Vbw=; 7:wDGi7YoXynYwwf9ZnJ3otJ8UTTZW9OvsvHhPeiGWsryHJgD1jhcoDZEPxx+fgNAcFd12lcCfTZhqMZkhz7TRWsqFQ9lT6mwsfXmjIr7HQKjr4Cc9gP8ppO39cJyEav1r8MJVhb1yUhr/HYRNQCwklq/P2/kvEmcpYAiYM77gpcnshxTDER3W0OMOa+rdi1HpCuKYtoaYgNsslMuBNFGX8OubS2HLKs0I8mA/nSXmc0/Oq/UNs0yqBd36XRDVRx9o x-ms-office365-filtering-correlation-id: 095815a9-8daf-432a-bee5-08d62f65312b 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)(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: uUpKNlikTliTqCc7qCRYkJX2N9mxKGGYmGgT1W9sdIT0BMzDxpM8aDP4T2KscKaoBww7Szm+L8PVMH9uOAP49rnDJYOtrIchbrIaRAHQkb1Z2KVWiCPQGbOeG757K9Y97YJwtl2i2aBVmEZE4siP5diH4qeFE3Ais4/oAuIWaoBUI5jhE3W17lKLHXnDWo4/F5FiyW6ZfXlgYoyjDgaNSGEqkXPLcGQucRRzPlhE4DA48zeOnKTFE/m6/4KuEk4OkpC/zAstajx+Bvgt+AKOnElctpBrOCQ3geDdDTgGWtkh2cB5pScSomkgT+pbkLcnyfpP0a4PEGbJ4xrWGYN3bXiFRTpffNrhl8qrCQNUPGg= 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: 095815a9-8daf-432a-bee5-08d62f65312b X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Oct 2018 10:34:58.8041 (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 04/23] net/atlantic: hardware registers 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: Thu, 11 Oct 2018 10:35:01 -0000 Add implementation for hardware registers access routines. 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