From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0044.outbound.protection.outlook.com [104.47.42.44]) by dpdk.org (Postfix) with ESMTP id 93C8D4CC3 for ; Fri, 7 Sep 2018 17:23:21 +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=R+wR5RYKz6EFNlgaRa0EgZvgE/YI7DyD/1o/9rkLrAM=; b=TU4f9B5TDiVlvckMnTu0Xhm1frgEH+7Gz/PdVVFP7EhgP3JvQQvlkwPBCUhJkJhZrBqYlDaB8MmalJEWCdbhVVLRWqrhWby5XaeQ1Ch0VWo3gFNHb/uVfMfeDHb6FrCmdLsTNUUGoO19RzB63cH54zszurlrVNhSQE7oFiKeMd0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; Received: from ubuntubox.rdc.aquantia.com (95.79.108.179) by BLUPR0701MB1652.namprd07.prod.outlook.com (2a01:111:e400:58c6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Fri, 7 Sep 2018 15:23:14 +0000 From: Igor Russkikh To: dev@dpdk.org Cc: pavel.belous@aquantia.com, Nadezhda.Krupnina@aquantia.com, igor.russkikh@aquantia.com, Simon.Edelhaus@aquantia.com, Corey Melton , Ashish Kumar Date: Fri, 7 Sep 2018 18:21:45 +0300 Message-Id: <1536333719-32155-8-git-send-email-igor.russkikh@aquantia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536333719-32155-1-git-send-email-igor.russkikh@aquantia.com> References: <1536333719-32155-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: BN6PR20CA0060.namprd20.prod.outlook.com (2603:10b6:404:151::22) To BLUPR0701MB1652.namprd07.prod.outlook.com (2a01:111:e400:58c6::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 35f31961-f9fd-45fe-5495-08d614d5d51a X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BLUPR0701MB1652; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1652; 3:if5aWVxK7pm0YlZnbcR7Kk+F/tAyy5k/dmyCTSH2jx9L0D6Sn3sTEj+lebyu9+PXS5wEExzAU3u4eQqxc/OCKJVEfl1q8FtRzpNNYcEKxkuGLavw+EWanVSQPyiMGqqyO+AhP3C1XX19bzZlTrfg8FDeyTyOMIxjKJmyWQ66ha05gmURvwN12LjCnPLHoPanToYMHHRXNEC8V3JQE4m6RoBQ/RiXMJtRsckdqfu4GWOHN9W7xD5fa0SEkQVYv/Ie; 25:59XD/Xg6mcclbXfxWOkis1yvr3eJPOXsMc5k+VUL61aPVXSexhqEQod9JAQovObW4JMSeJIBMwqRY/oV/+ufjgZoazAmfKR1u2VN82z3sg4BrTPJgvrG1GtJE7YkQDUTUBiRY8YlVcSPCeZLfU7smYmGVphpttC0OFpWmzxZTBNZMJweDKA9FyNgeSuhTIqaeGX4lSZ/S2qUkYmjQFqOwN96CnIwVHzlNR96Ah1QbYleTs16hPcIfLq+ElyEiebWid8F5KgBOkrWeCJpkDLYJx5W6qiimnHU+Gr5IU/v8YLNBIjKZ7WbAuGs377+XgZxibMosd+sUDq0iH9HPH138Q==; 31:M2MwN70L8X6YiICUhtWNr+QAdiAUqI2KboUMBffXZ95g8h+R/TNIeSgXFFG/+uWQ+TXQ5JMe46WQwyS+nOWk0LxaLYy+noX1DbLK5uA2B4rSapApE2RVsCRmo1qYjLQfGHqd0Ec+T3cz0NFbXWILZyYzzzBYJ6S+WfSKxe4e2f37wnqWFRObnZ1w3ynbf6tqV9lU2fBs4HrlbyBKEQnAuFmCw6G7ciHaHWOxAV2+m8o= X-MS-TrafficTypeDiagnostic: BLUPR0701MB1652: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1652; 20:x9YHfcX6D2vCBn74YmyfNpFnvnWDlGkzj7Fw7+bdQGG9pCSxswB/52gWLm8I53kMmMG/dUNtIfMgsh6fr7CH6TDcngg969oR8Wjd4w7XIbrnxXFKhyA1xPpZylIAr0hgYDlqgZc5JFwRcSxifTVkBnk9zOPJTFrCCBZzaNqDcvTmozRWYCzU6Ru8jj3D3usEcrXBanVP+04ET0gZo7ij+rgf7OBKKc7CT+cMMJ4qZd7DCQTLyylw6mQKRLxu09+4t0FF9bCCBSFFiiKANVxv4B7nGzOAYFWE0clqLBNEM5d2lX89OJQ1Lmkcv6qHUdhX2h0C9ZbqgVkmHLcLQIrcxOcYNkb19N9dcUk5Xh1yE8TkgdunNezfPF9wtGrXz97m9U4mPy3BN+M9cnfJZ7nohfjeZHpGbfHNpNsMHjWUajFnCPVGXDN3WT9opj6zV84t5BERr/3juF9pOgPdEsJ6SayG4T9Y7k/mM476NCGvjIuHna1J1T5bE92jZQt7C8bv; 4:GrDeVFDuZ9uXRsrZiWWZAOeVJoUKLJ8GsDuDzqGdIiIBD+pcn7BUYdLn+wYEvpcZ8MPAEhIvPaY+vvM9vCcp+ki2fc/typYaYpjMQMk2CWQnfrNmXNMNPzxO+5E/dGgUfVw6hQ0lo5iZSSnjhzxYs62Qa1zmuG1ZyHeVM2AjRxvGhLsRw/zNit3WUBYDw/WPjzWsuRaK3etc9M+0ZhhVoGK+gtw6GJspsSMcQkhG/+SSGr6rqsdpuA6BFWYcb9yY5iH9mY6msQqh32DuZwznAw== 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)(5005006)(8121501046)(93006095)(93001095)(3231311)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699050); SRVR:BLUPR0701MB1652; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1652; X-Forefront-PRVS: 07880C4932 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39850400004)(396003)(376002)(366004)(346002)(136003)(189003)(199004)(81156014)(81166006)(44832011)(8936002)(2351001)(486006)(106356001)(2361001)(105586002)(446003)(2906002)(50226002)(476003)(11346002)(956004)(2616005)(305945005)(7736002)(16586007)(316002)(54906003)(16526019)(66066001)(26005)(7696005)(52116002)(8676002)(51416003)(76176011)(186003)(386003)(68736007)(478600001)(6666003)(6916009)(6486002)(5660300001)(53936002)(47776003)(4326008)(25786009)(86362001)(48376002)(50466002)(72206003)(6116002)(97736004)(36756003)(3846002)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1652; H:ubuntubox.rdc.aquantia.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-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0701MB1652; 23:9NSvmWGouyiRSewVrMVVQUdgsNwTcwtW0YUzHO1?= =?us-ascii?Q?JHKP4RDpn6LiTH2vrHfCF/S3nk+5vip60lqfb3Q8Ouno05wj5BHtm8lfpOYA?= =?us-ascii?Q?+39ldJcVlR5bKsxk3VZ1jQg5CIGVSgwwhjW65X1yNNrk/PKfsnJVSWafDSP+?= =?us-ascii?Q?P7PdjYa4XJnxFSbOj0f+o179G4ZK8pOZIAaSS1KyCnCecDDZyVn8Mjv12mwy?= =?us-ascii?Q?ZI/StrrSCXdTQJfJybysREOA5SOewb+1F1WGJ9gSiRAvu0Dg6XzAN+j8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Uj7T7+KHbKX11vWtatOVBGuTykfJM1g6hrHu+qjEwZ0vGzcUcUOQF4aX1lAJgOMNn21nsdRXX3hgwiCBpOrBCW1lIg2ti5PTyLCj8EjJccwUjE0PavTj6UUCCXGNb3vM4Lv6ZM2ro3RfcSuNo=; 7:PE1Cn+Vzjb4A5RRlR4jekAkK0Mn7Fyeqj/+gGRsnaiNN7ajjHJ2l2VVsIT4ItWxb8olk2NZGe9Zs179U76kI5D/d2JA9SZxFYnkk76IeFShK16//E9NeksBEh8siQjnfzAiOFkN1SysMGc4f2FNq7LyUw3wJJnhncKUIPQGdiO2HXYt2v+vqskEwADYyLizNLsUi863vAx05Dweb6S3yyCTM9RQg8jQOrbXec4yKJKHMbFye2QuQTEsMccMCBVDm SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2018 15:23:14.1934 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35f31961-f9fd-45fe-5495-08d614d5d51a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1652 Subject: [dpdk-dev] [PATCH 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: Fri, 07 Sep 2018 15:23:22 -0000 Signed-off-by: Igor Russkikh --- drivers/net/atlantic/atl_hw_regs.c | 58 +++++++++++++++++++++++++++++++++++++ drivers/net/atlantic/atl_hw_regs.h | 59 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 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..7301d08e7 --- /dev/null +++ b/drivers/net/atlantic/atl_hw_regs.c @@ -0,0 +1,58 @@ +/* + * aQuantia Corporation Network Driver + * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + */ + +/* 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..ca5a80ed2 --- /dev/null +++ b/drivers/net/atlantic/atl_hw_regs.h @@ -0,0 +1,59 @@ +/* + * aQuantia Corporation Network Driver + * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + */ + +/* 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 = -ETIME; \ + } \ +} 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