From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0047.outbound.protection.outlook.com [104.47.32.47]) by dpdk.org (Postfix) with ESMTP id 518DD5F34 for ; Thu, 13 Sep 2018 13:35:57 +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=VIKU7VF8X9rWsYWoy5FUs0jXjhrs3KrbwtxjRKY+b/s=; b=EZ42aUrRXZjvqseeG9hu2P8/LaPoL0la6s3mabkrvAeNrKkX0KtL6RNcXTyZiU+2cLTjFIVzweKsaFE63meGNPbJZtC24soiFazcv0lM+TCU/g0frBKWT1LjUAIdlPem3BAWW7kFhI6x73JLcl5vPbDhrMCmwd6FsVfkhqiWKec= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; Received: from ubuntubox.rdc.aquantia.com (95.79.108.179) by BLUPR0701MB1650.namprd07.prod.outlook.com (2a01:111:e400:58c6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.15; Thu, 13 Sep 2018 11:35:54 +0000 From: Igor Russkikh To: dev@dpdk.org Cc: pavel.belous@aquantia.com, igor.russkikh@aquantia.com Date: Thu, 13 Sep 2018 14:35:14 +0300 Message-Id: <1536838528-11800-7-git-send-email-igor.russkikh@aquantia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536838528-11800-1-git-send-email-igor.russkikh@aquantia.com> References: <1536838528-11800-1-git-send-email-igor.russkikh@aquantia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [95.79.108.179] X-ClientProxiedBy: VI1PR0202CA0026.eurprd02.prod.outlook.com (2603:10a6:803:14::39) To BLUPR0701MB1650.namprd07.prod.outlook.com (2a01:111:e400:58c6::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0cc0bb23-1576-41a3-4999-08d6196d1167 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BLUPR0701MB1650; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 3:DJB35/sf256+M89O5kzBAGZ09ELWaSsDMkr0UKhkYAJCN3DxwuMUoHAriqyMGPRns7LLw40JME7thrRllL56za6Jb0VivvPshZh3BQ+PnLABClvjaTEoSnjmuMPXD0bXPCcSE6XAWc39UFYEagGTruhIbCB8nC0iMNshGV510s/1FZXg1LAwxPR1Yo8iLuaFlu8KYrIEP7MjiU4r43ybWfU47qIBPALnFKAtsLM04dcxVAyweZ3DDSSPmn0cZaw5; 25:kwKNN3g78f+DkGHk9wT+hZwRoopkIwtNAZqkPtDMq+WawqMiA1xu7xn+Xel3HEejGQmRToU1qxjWHPFmKnPBE2jhWz3aTuJZ7GnkTpg2/KHpKVzVe5GeVKD6DyPCvanRgaRfMSjr1FrHEgx7AsoT7gKXuUtNVnbUdijR+jxYbS0pSu//Lx9HL5tu6oAVl2EkFjd+Kna5FSSHyloPNdAgmajrdak4PUJMDbEhtNpkRVjjpoHIrDIribgAQKPvfddFcSw3whHO/aeLHpXGwi4GyjsffphsiN2N1rQy37ApNzqwUYuonXmqCAR8wUGIJ9p5QzBjbq8oIUBxgLF+iw9tiH3EvSw0Gg7iG6lElH6B2Nw=; 31:6+1sCMdr4PHSWXQCxINTdRt7CBtsMrIOx7fh1qo3mB5t23nGOVxaiyjTq7m92Kcx3k0MLeb1+8K6W0Lw3YWRSD37xYNgXzjTJV/NarN5xZGaPqmKBHtYTgCyviS7aDoyJGdKyeWVbg6XZC2P8aLCBjNGCyS2bHAL4JnbU54rHoNYGA12kaN3zUwpH/vZCIK6hhozfU4QeS6+aJCX8w8rCqxKRys4VlYVVaTxgAOuxsY= X-MS-TrafficTypeDiagnostic: BLUPR0701MB1650: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 20:hPF04O59dn8RGqlDsbd7X2Yznl3aj5Dm34uXb63g/UGZdvgGYuEGc0fheKLARqzneEyuxtIoOqf5BTE6NQhnkEQPBOPBVCZTfzNjL66Du2M6fgKD/ffnqn1RT5PEUtIO651anE1AKMQctkd9reO9zDt7PlMD2kkMNHd40DltiXF4WLcKRmYJEYioMcQjz/ugvYA9iy9FfVSqiE3i2OysZkiB9gpV0MnOcQpO0w0sJ+5aE2szjU2vPule3FkCpr/one0rZdzOJrOFasRKVlCQ4VVYFeuCziO3YDQpCaDCkVu3NGIQzBEB2ppdpPyVL2XwKefoKi/JT48qW+26LtnGKFwzfAU++wsBXBa9Xw/NrUiTEQFR9RQiqR8RxDY5wLkyKIL1Le+l26rFh0jGhZAuVDq0hQmSA894fWo7fp4oBKncOb4L92U9x19sNfN3/fiiT6xbLomk0bPlB8SAZDjDze9XLTbqFzdRRZGicVV3q4JM6ko8rQLyvhJ/J7C6by8C; 4:ggHF6Z9F35O1ocU3URp1VcmDw8OGyYv7mRVKHpkSobp27Y5lyRopbxpBldHLq2Vaxk34VgfbULpThpoYjz0pBkvLAe1K4o2+NE/cjoTJ/cu/4ltdrAgpiY/5xkgoYbvHmS9rW/cIrg0LgEb65Lwe6HMUZx1zqTYtAJF0vjCezWhntW2FMx0YI9oCTzpddJrPAUjG//GRz42Em0MeYd2wrrm23i0lqzoiwkQpqiuCmNOutQXZf4cfpID50MfISD6x/tyIE4tqtPGHPevL80Pxrg== 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)(93006095)(93001095)(3231311)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699050); SRVR:BLUPR0701MB1650; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1650; X-Forefront-PRVS: 07943272E1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39840400004)(366004)(396003)(376002)(136003)(346002)(199004)(189003)(6666003)(6916009)(97736004)(8936002)(68736007)(25786009)(50226002)(81166006)(81156014)(4326008)(107886003)(6486002)(51416003)(2906002)(53936002)(5660300001)(36756003)(86362001)(316002)(52116002)(8676002)(16586007)(7736002)(305945005)(11346002)(446003)(476003)(956004)(47776003)(72206003)(66066001)(44832011)(478600001)(486006)(186003)(26005)(16526019)(386003)(48376002)(2351001)(106356001)(2361001)(2616005)(3846002)(105586002)(50466002)(7696005)(6116002)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1650; H:ubuntubox.rdc.aquantia.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-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0701MB1650; 23:172lhciuiJz9SrZ8rZACrxvrEdZ10jazmPAtKrJ?= =?us-ascii?Q?CdduXb7KvumXS05XQykyBSM0TEKitSl7vruzfN2tbZC5IO5MyXMGHyT3vZFQ?= =?us-ascii?Q?sWEeyXiXOAT6RaPvbcr7m7cbavG1PQq5QVX/9zg9dr1JPjJ7VviEFWRARp9g?= =?us-ascii?Q?YrYeDtBLPWMMDVpGsW3vWAay2Qh0nVuytzpAFlOCwIUIforP790gA8uDjTGi?= =?us-ascii?Q?Za3QZdOLj3ezGHAHjt9KsmUi//Q8ajU5Jwh/c/tTlhnWRanE8SFJWeZJaCm5?= =?us-ascii?Q?1Nf+exmmDrpJxTqaef/4FkUuqjIeJu4qFh4BAJDocEQim7dWFG0BlZln6ge/?= =?us-ascii?Q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o4SFvxs8iSyXxfws0d0XlYXhQIvw4uqNBR6TaDRvHeZ5CPA3I0=; 7:UkKpsHhes0LDfw+XHOYkM5RyGBZuxWSrtm0ls55ZE+Og+RyNkYuJBK4T+nd3hU3I+YfdQbjfpWa7rs+W1tmghUqPikaDYv0gU/1DlML4yRbpswa6PFgHLs7xKlrjUsyS3UpHaca0RA2GdIVR/mVTQA9LSEhv4HiC4zWhMzWKaWnXPuUE6DUCrx8e0AABOmEphQX0tfag7ga6FI4sNZrY/pdwVwR/71cpa+377OMx4ugYibf4AYYNOOMxRLJFQipu SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2018 11:35:54.4107 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0cc0bb23-1576-41a3-4999-08d6196d1167 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1650 Subject: [dpdk-dev] [PATCH v2 07/21] 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: Thu, 13 Sep 2018 11:35:57 -0000 Signed-off-by: Igor Russkikh --- drivers/net/atlantic/atl_hw_regs.c | 52 +++++++++++++++++++++++++++++++++++++ drivers/net/atlantic/atl_hw_regs.h | 53 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 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/atl_hw_regs.c b/drivers/net/atlantic/atl_hw_regs.c new file mode 100644 index 000000000..231dc712f --- /dev/null +++ b/drivers/net/atlantic/atl_hw_regs.c @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: 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 = aq_hw_read_reg(aq_hw, addr); + reg_new = (reg_old & (~msk)) | (val << shift); + + if (reg_old != 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 = 0; + + if (aq_hw_read_reg(hw, 0x10U) == ~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 000000000..fc109f5d8 --- /dev/null +++ b/drivers/net/atlantic/atl_hw_regs.h @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2014-2017 aQuantia Corporation. */ + +/* File aq_hw_utils.h: Declaration of helper functions used across hardware + * 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 = _N_; (!(_B_)) && (AQ_HW_WAIT_FOR_i);\ + --AQ_HW_WAIT_FOR_i) {\ + udelay(_US_); \ + } \ + if (!AQ_HW_WAIT_FOR_i) {\ + err = -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 */ -- 2.13.3.windows.1