From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730082.outbound.protection.outlook.com [40.107.73.82]) by dpdk.org (Postfix) with ESMTP id 8BB8E1B114 for ; Sat, 29 Sep 2018 12:31:17 +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=TcChu27za5IBG2B9IS6oh2ILQY1Pif0X5fUNd11InmA=; b=ZR3KS/Q/Ddx0rnJc+S2niA8LSONu5JeMSkiCuqHUnb8KNXz+qJTCl8t+NXA4wPOmRBLxyV6gg+rKnCsFN1KuZ9PGIdG3TjJ/q0lejGX81beoMveVCGbZppOuMT5xpbRTfN6QTY19otvapwgQK/fpSpE0Viyp96zYLkoiVAYnWYU= 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.1185.22; Sat, 29 Sep 2018 10:31:10 +0000 From: Igor Russkikh To: dev@dpdk.org Cc: pavel.belous@aquantia.com, igor.russkikh@aquantia.com, Pavel Belous Date: Sat, 29 Sep 2018 13:30:17 +0300 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [95.79.108.179] X-ClientProxiedBy: VI1P193CA0009.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::19) To BLUPR0701MB1650.namprd07.prod.outlook.com (2a01:111:e400:58c6::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c31c9dfd-e273-4e39-d367-08d625f6afd5 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BLUPR0701MB1650; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 3:uqlb1vNDjztdZqx2mBKm+V+1/Xc8xkBopQsUdrF7bUPyFsqPb058C9m179zO7pscvadTdx/wPV4r+LrmScquBDxk0KXuZ9/QONJiefXX4UnghtSW73UncibApyn1JUGuP/2TwgSas0HWDLT3JhlqXlV4Te95PWPE+m4/5dWO/P3Vh2om4iCYDGWB9Fqso1OrzprZS064MqWYMdyslGQ1IDJ0aloNqPF3NZK6x5umiYWM5kzzf/+Z5/9vc/j+NIr1; 25:0alj8UODSxG9+JTl00lTEjp/ZabL3CYNc2eHXcihStojNsB+wdeeWpeu5S5iB2QxHmVYBqMM8TW5KQRKkO1eJrzYCWcx8Fk5dqk8pl08QVj8vUWRWmWpYc0Y34nhepVFjbChQBfneH2+N0HIufxoQ95RVAOnVM+aHFzCTfPwIv2y4Mc7L/Go1TXSkX7QEBP61o2zxzkzJ+u4JO/TGfiQQj024wowI1PdSAn6Riy9+Xj+jEo4LGi96ZTnSXirdmVoo9W4uM3D0/v+hyleeOEkA6WP4N2rSUfVXk9sAArExuX7zviXS1i07QxX0wWZ2+3r0vt6dTTo1tHPyuDc0rqwvPeOVwgt5zZQ+kAXjhQ8j2w=; 31:LMf/Eja8B+VQw480fet4761jLvC7JFYf/60xNULoYpourLIY8Du9+0TRVGRySrBmlhXL2qsJJfKhrgPFidtOlkAzvlmg0XrQFWB2mX1LpBwWJtfLlslnX5Hil5wagDIYJz7pcgKQS7+I5Qk6zvv8x+PbQAwQIhJyWUtsu5k9QQwJQse42kNgWjgIdllkNwpygQ8qrsNwg3Tk0p/x+VNhkxWKqGbGThsGNcPoh150/nQ= X-MS-TrafficTypeDiagnostic: BLUPR0701MB1650: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 20:XLFSNJbWsmUeGr3a/JrrLa1zLPFCg5TezXhxqp2I1QjpYHdw8jE789gN7zoLLQlMGu8qbM9GzAL5u3MY4oJyGdOfzjrrZv4sPngVUoJgT+avs0jV4gms8uZs7xKLSUQHZtQMaalck/s9UwO0JkxGmhKJ+6ibd3pLKA1JdqNhjppNwVY2KM/Yz5U7QevsZHu3Wmr9B6MmJjdQJ0pLXoPbIqPRl1xIQjhdCm+Mt4dRPsRUGDRBDDPL6OBldko++o+F0Zn3HYyCzeMyE5cRMqZHL0qwKS39vILg4rMZgye3Jr5YqfVDru+fq4cekVSi8q5wAMcnSZMCEedV7dwHGVG2sVTUXMykKGZerC3ez+K/Qnd6gBPr/KpdnAzTYaOWirrMiRFczQfHzM5eN5p14mqNRhYKsBiJtQcfZdgBpr9fcEVfV6DM84SX5AAMJjv2icEE9IzSuOatDqwrlnLOTHiUphVAys2/0bF9xtajCd06okLUyYd9Vn45Mv0upYNoHSGm; 4:Y6xzUjWe66RvMIgLPBrYDmOnE+QGPM0MOFTHuVNxslnAQw4AVnbLxZ6SlOQNxASqw4r4DKq+WtonRjflNfEx2UiiSwVq3LepT6iAHwiSuhRHP5y2ViB6FiUJZo9BpPYPL78Qt9eIQIbE4HmyXO98GoaMS4qKLh73mJgNgxwaIF/A9WXz6W/t4OLQc8g4hq6kPTOLrWyWunUi73phBDmZrcXM/6sOJLEklwbVMov3d/9ohS5/tZLrYHclJTfBbJiaE6mLapLKxEXdQKhQ/jY76g== 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)(10201501046)(3002001)(93006095)(93001095)(3231355)(944501410)(52105095)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051); SRVR:BLUPR0701MB1650; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1650; X-Forefront-PRVS: 0810818DA0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(136003)(396003)(376002)(39850400004)(366004)(189003)(199004)(16526019)(446003)(76176011)(2906002)(6916009)(97736004)(8676002)(81166006)(81156014)(36756003)(4326008)(316002)(8936002)(50226002)(34290500001)(86362001)(5660300001)(68736007)(16586007)(118296001)(72206003)(3846002)(6116002)(53936002)(386003)(105586002)(6486002)(47776003)(66066001)(486006)(25786009)(305945005)(50466002)(44832011)(956004)(2616005)(26005)(107886003)(52116002)(51416003)(7696005)(186003)(476003)(478600001)(2361001)(7736002)(2351001)(48376002)(106356001)(11346002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1650; 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; BLUPR0701MB1650; 23:9yyX/s8fw5BI9YzuLFeswGWf+pIXz+tZOmzS7MU?= =?us-ascii?Q?88/a4HNAaIMlvqEWKt3Iy9O7wiLbSfTnuJCmI24QuIAqBWLAY4EMSa7Li+ME?= =?us-ascii?Q?4JTiv19iqSM0/CrGeLwDsNMltb4ki9u6fcsH9z2tz8bJogAHxG9gLWfWbvW+?= =?us-ascii?Q?QSKWj2w6thPfzQUWg2AgY88DTZC0rrCfV68sDjLqilNGQP9WD1ZjozeoLiZa?= =?us-ascii?Q?uH+EKDOn+P1Lw9f51L9HKxsljA7UJqy3kbks7EB0u1X8ToDW7E4b6nGeVTh3?= =?us-ascii?Q?TwV+H7OoQKWmMTqPMwX77ldyVVCGABAW8y7z3y09Q6AMhaqbP5YMGdDs6cyo?= =?us-ascii?Q?rP7R6GNyHOjNUqdwQ6+jlXgkYnsuTSntlE/2QT4bVrr/sCjuF8LraEHLwmIw?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XJc0/yZkEmJwy/qP10=; 7:4LAmkT2PawhpQaosG/7Qlf87JrgbjzcZOj1t/fQOCThTW3Fsczf4ykDcA0JRBdwWt/rGJ5DyJWzlOVVBx6h7bbtY9QyK8Wh65Eemf82tr2EAdDpKMfaG1qhBih01mclwquFDMaWqdm4Jb6XmNTsVZYU1TxNQpNtYsOUUObbYMC4p6VG3ELKCRCANY8Ni0EdIagckzs18FBrSb6Zs9PFXxzNTX2fsX63SSbK6PKfNKYXcEx1781nbUUnKsVHgj88Y SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2018 10:31:10.0928 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c31c9dfd-e273-4e39-d367-08d625f6afd5 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 v3 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: Sat, 29 Sep 2018 10:31:18 -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 += -lrte_bus_pci # all source are stored in SRCS-y # SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_hw_regs.c 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 = 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 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 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 */ diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_types.h index 5a14c2506477..83fb377add47 100644 --- a/drivers/net/atlantic/atl_types.h +++ b/drivers/net/atlantic/atl_types.h @@ -28,4 +28,8 @@ typedef int bool; #define min(a, b) RTE_MIN(a, b) #define max(a, b) RTE_MAX(a, b) +struct aq_hw_s { + void *mmio; +}; + #endif diff --git a/drivers/net/atlantic/meson.build b/drivers/net/atlantic/meson.build index 90ee5288206a..7fdde358ba21 100644 --- a/drivers/net/atlantic/meson.build +++ b/drivers/net/atlantic/meson.build @@ -3,6 +3,7 @@ sources = files( 'atl_ethdev.c', + 'atl_hw_regs.c', ) deps += ['eal'] -- 2.7.4