From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0058.outbound.protection.outlook.com [104.47.42.58]) by dpdk.org (Postfix) with ESMTP id 7482AF93F for ; Thu, 12 Jan 2017 10:19:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=PqcA+jgAp3Mq6O4J4uBejKOw3RP2vj+pJJec17Rc7nM=; b=Nf9b+egTimljptsXpgbi7bDMUiqpdViv788BPGFcRv9tRCYhfPjHE78ifRMXet3lxHw3/LX01kcUZAU8GdSwQxwzK9MZ2JenDP0gQAVNPo3MfGeuGbDqZuKMXG+vUEjMyBx2yfBAbvdhhRtQXQjvUkt8GXwNgK43TUVxmYyXVNI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.caveonetworks.com (111.93.218.67) by BLUPR0701MB1714.namprd07.prod.outlook.com (10.163.85.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12; Thu, 12 Jan 2017 09:19:48 +0000 From: Jerin Jacob To: CC: , , , , , , Rahul Lakkireddy , Jerin Jacob Date: Thu, 12 Jan 2017 14:47:15 +0530 Message-ID: <1484212646-10338-19-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1484212646-10338-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1482832175-27199-1-git-send-email-jerin.jacob@caviumnetworks.com> <1484212646-10338-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BY2PR06CA0007.namprd06.prod.outlook.com (10.166.106.145) To BLUPR0701MB1714.namprd07.prod.outlook.com (10.163.85.140) X-MS-Office365-Filtering-Correlation-Id: 9045509e-e037-492b-711c-08d43acc2aaf X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BLUPR0701MB1714; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1714; 3:UqXcVR8gkRDH0B3XoQM2Ox/sl49cQT/Wz02Ts3LnlfhcQYyyLA6dxnFIMnntkayhqQoYDwErwhOwLGYKm3MF+YI3FOaeoOrPDXAAMsS/XJGyqHTnNeR6j0A+QrPo1WB3g1BS5LyuP+80kYAt7M18RnqlfltqpmSTrpaEfcjgIgH1s20QVXJzeTls1mI6Hta1fcTPS45zwhSmfVoPOGqXnnmpW48oxg7UhgI1R03o+neKu7vROxw3RsjBJLi1HcOXCvtPJIUb3bWZYc+9zaIOzw== X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1714; 25:A1+wZ2zkEWaFXS/vO/SvhIJEGOaUwbRGIghxy/JjlUwErysluPfThNuWkyK/MZyTOFWwFZMz0iITXk2u+gKIy9ODna0OqIvvk0cUVZ4M4DPlnp9emrk4lHnRMs26GWMWc3np+fu5573cDLSamobCPT6vHgZzJp9PCg9cvGA3f9iKcDG/yEeoMPyM3HJaMHCDEr02vQUgRZLjA/sXum+g+EcnjaOjRVsx034bC6m+if+VOy52aZODs7ft/6vBplCavsBcU5yPjBMmOrusH90BXe32bOyDaTiiEiWWdy1b1WN+MYZCgKqr4VbtI3rugAs+bIJJzvQrKamOrRX4QXKix4rOueQbiRJWAAQPEYQjSZW9YEOIx2sfIG6VJW1dugnEV1anPv7TEuNokmc+pAaVlc6CoqvyLRRWeXuAGvb+JM8ttnhgTp8MbJOpcLW0icEXX0m2Z70p6x1V96Ywq9UXeQl7A1t/bDk8EnvyEmTQq3dpRDWH4eDS9zXW+ImJeRmI0rtL4sdeE6rtvwpBQgO9sVpeSniAx6guCLgKnRF1o1H9N5U31MgfN1pmESqQnkYB6KeImavO2HoMZvKwAplM4A7DjjMFsWhiJ4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WcsyH9Hho1BESnfs5tyPGapAvTRBxbtRE1rBQvlP7CsQiMGzXI7UG7/rBQcNA3v1FC66T+uCJiozJB2gmoRo0GglhERBkDveSo= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041248)(20161123555025)(20161123562025)(20161123560025)(20161123564025)(6072148); SRVR:BLUPR0701MB1714; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1714; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1714; 4:1ESJnk7ap6tfEQgpIX13CnQPm0K+fA0xkcrsCNC6Z2HeNe41Hz4OuWfJM2JMXkaO3AU++jqm6Xi32mHuyoAQrVl71ubPcp3+zcON/TlQBYSBNzb5eUl8R/idx2qiQgwcEnOKuS1difHJqV6xqiN2DagxpHnPuMu3EAGZnMB+V942w5JANu/jh6TRU2TeJpxDe3tZuJyehx56e0JIqk20ONd2jnI2K/NHEo577F6gL22Q1/RofNLCUHYjB+0NgGdPjtuUI1XDkVuxRBmX/BgaVEm8HCGDCSw2RcyXVTKxczZ+BxDtxStzQeB59prpIKGaY5m+vaw4nH3nURigEir0GqBNdaFY8PrHk6wvwQTOLr9TyI1ssqLyuM7WWN9WXaCJdriMu8fG84TBGNVKoH5/zjIlVbfy3QADxzI1lPdcJ0zw0xuXbcCZvIArg+QCT3MMLK3bABrDohzvXdcCib7OjXkqIgz8RT/RPF3aUjxZYY0z1q4eqBHo4rsndgQoPgVqfT0tjX169t6kcusNiQUegC48D7dUTCDFQUSJl8VigvJtYaSqY6TInMxi0+gqe3PLQZkr7thYTt7Q3i2oX8Cw6Cv3/AMV6nLGdQcmzn0zRMc= X-Forefront-PRVS: 018577E36E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(39450400003)(189002)(199003)(2950100002)(53416004)(76506005)(92566002)(105586002)(69596002)(2351001)(42186005)(68736007)(106356001)(42882006)(6916009)(305945005)(2906002)(7736002)(50466002)(48376002)(36756003)(5660300001)(110136003)(575784001)(4326007)(97736004)(107886002)(189998001)(50226002)(6666003)(6506006)(38730400001)(101416001)(54906002)(33646002)(5009440100003)(4001430100002)(6486002)(66066001)(5003940100001)(6116002)(3846002)(47776003)(25786008)(81166006)(6512007)(81156014)(76176999)(50986999)(8676002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1714; H:localhost.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0701MB1714; 23:5rKLyB8brCdMKKFSlD78dUmj7I9tjFjSD8e06MY?= =?us-ascii?Q?9ctP1cvvKaUUl9x41R3Kwsj8EaIhtuj5f6eQAavaTOdCMdIo3XmCNVV3DLrk?= =?us-ascii?Q?JuwUzSuibqFjbNU1VvbCKgEwb7POSeqzg9vyLTyndFYGL4sP5GArVCizsHCI?= =?us-ascii?Q?eOhxjDAT6vAsQmnQTl99CyrF8bPDIfftWLuGo/DNGiB5I29d+GmJrBu9TDiR?= =?us-ascii?Q?CJMZXUfes9FH45p7FIHHT1/Oqy+P5lQ2JROCcfQYISMKTFnW6sAeqdZIVjl7?= =?us-ascii?Q?6/M+yGFBt8rEa37FfVndPs+kQiNMOiGhvULE44qEqoPMJkziAa6LrpdAwtH8?= =?us-ascii?Q?AEZ/PbmepLU8ynufrUfXUA/QQ4uNhxK2Twwx7/eHO5+XvTo6uRSaIKU55PVY?= =?us-ascii?Q?pxKJMPCh3W4XaY3i3TIaoFrhzimwvh0OC0FM5sGXU8TUbTKrScKsSReDCbtu?= =?us-ascii?Q?GMrvairJ/MvSMZe1dZVp82/PyWGOjDkcs1HxGt1dtUYlhZeNQLi0sml5dXUW?= =?us-ascii?Q?zHN6bkXoSGhzdRGPyjabPJ/a9PjtSjSvTCXUGBCkdMuKy12anywziCCLgXjr?= =?us-ascii?Q?UVpBxb40iEReAXkG2qdTbtOGBT2rr2ube2BRxnXcDDTKVIMule3Xp5TpUIqH?= =?us-ascii?Q?wYZnWzkY56oU/wVoYsg0WT+13nG6xsnX56R5Zy3Mjj+2c7A6GUVk/nkUrHTG?= =?us-ascii?Q?lPRX5lAYEmtTV0Bk4rM2KhwrwEt066zbHX9as/lwlYsgDix+spteAGMYRKvd?= =?us-ascii?Q?8T44yHaGqMJhY6bw+5D9WZb+t+WMI6YuYVYwVJtLD/PW4J7jKHOBNGPH37bD?= =?us-ascii?Q?Zgw7LL4O/KBg7cQ4O83EhnBMwTfXFkzfFlzIb2kic9EWVF8gw5f8+gswErxv?= =?us-ascii?Q?ax4uzFgXeDyJjGr19E1J5NmZeUZ5N6i3WDDWGaM6hvCgFVpe7D8UIcENJfYo?= =?us-ascii?Q?0FeKcQN0YW3BScYqubPL0MXQ8C10UST1gROgyGnVQJBwjtY1jw2AeNxh8Ufb?= =?us-ascii?Q?6PLbFFlb5B1T3Ah3yxd29FAnqhVdgNIEcoQbqMutIpvpohHO6Otrzij3mw6x?= =?us-ascii?Q?/OfK8IByMslwR5QBId7/Jfy8AEq9Q5X4u6fP+PzMK1YQWw8lCPf3C5ae9ok3?= =?us-ascii?Q?T/2+bMNVopUQqObafzhHnMT1QtL2g3zYlHnyWMBvRSTmAROBvVb9ADfpzUp7?= =?us-ascii?Q?uCqKOe2bcI65uSCW25g4wGQmASnDv1TZGHXtPwQUYEfCXzx42PJOHb2J+sPa?= =?us-ascii?Q?B6KL6kDnQwpquKGxovUWf0IbbVmbn+hD3sADD82Y9zExWTYs0dzIDMhCwQ26?= =?us-ascii?Q?ylIjCTBE862QBZbtqAhfJZ7aHaRQBi2E8qOIiyKnCAyew?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1714; 6:u59Ies0WxKe8eL60LoLqCb3F041ktChy4v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y5hW/URtvhTm3KKM4vLwg8o0uzFnsKUziEaYAlTfbki8VvJ/XIgam2gXafNkL2plii5LDUeCMY02vAXhG0aSrmVtfJNVap60SWlm8PLGC/XHxIpZRMRgSgO04Mrqy2KlA== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2017 09:19:48.5008 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1714 Subject: [dpdk-dev] [PATCH v3 18/29] net/cxgbe: use eal I/O device memory read/write API 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, 12 Jan 2017 09:19:55 -0000 From: Santosh Shukla Replace the raw I/O device memory read/write access with eal abstraction for I/O device memory read/write access to fix portability issues across different architectures. CC: Rahul Lakkireddy Signed-off-by: Santosh Shukla Signed-off-by: Jerin Jacob --- drivers/net/cxgbe/base/adapter.h | 34 ++++++++++++++++++++++++++++------ drivers/net/cxgbe/cxgbe_compat.h | 8 +++++++- drivers/net/cxgbe/sge.c | 10 +++++----- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/drivers/net/cxgbe/base/adapter.h b/drivers/net/cxgbe/base/adapter.h index 5e3bd50..beb1e3e 100644 --- a/drivers/net/cxgbe/base/adapter.h +++ b/drivers/net/cxgbe/base/adapter.h @@ -37,6 +37,7 @@ #define __T4_ADAPTER_H__ #include +#include #include "cxgbe_compat.h" #include "t4_regs_values.h" @@ -324,7 +325,7 @@ struct adapter { int use_unpacked_mode; /* unpacked rx mode state */ }; -#define CXGBE_PCI_REG(reg) (*((volatile uint32_t *)(reg))) +#define CXGBE_PCI_REG(reg) rte_read32(reg) static inline uint64_t cxgbe_read_addr64(volatile void *addr) { @@ -350,16 +351,21 @@ static inline uint32_t cxgbe_read_addr(volatile void *addr) #define CXGBE_READ_REG64(adap, reg) \ cxgbe_read_addr64(CXGBE_PCI_REG_ADDR((adap), (reg))) -#define CXGBE_PCI_REG_WRITE(reg, value) ({ \ - CXGBE_PCI_REG((reg)) = (value); }) +#define CXGBE_PCI_REG_WRITE(reg, value) rte_write32((value), (reg)) + +#define CXGBE_PCI_REG_WRITE_RELAXED(reg, value) \ + rte_write32_relaxed((value), (reg)) #define CXGBE_WRITE_REG(adap, reg, value) \ CXGBE_PCI_REG_WRITE(CXGBE_PCI_REG_ADDR((adap), (reg)), (value)) +#define CXGBE_WRITE_REG_RELAXED(adap, reg, value) \ + CXGBE_PCI_REG_WRITE_RELAXED(CXGBE_PCI_REG_ADDR((adap), (reg)), (value)) + static inline uint64_t cxgbe_write_addr64(volatile void *addr, uint64_t val) { - CXGBE_PCI_REG(addr) = val; - CXGBE_PCI_REG(((volatile uint8_t *)(addr) + 4)) = (val >> 32); + CXGBE_PCI_REG_WRITE(addr, val); + CXGBE_PCI_REG_WRITE(((volatile uint8_t *)(addr) + 4), (val >> 32)); return val; } @@ -383,7 +389,7 @@ static inline u32 t4_read_reg(struct adapter *adapter, u32 reg_addr) } /** - * t4_write_reg - write a HW register + * t4_write_reg - write a HW register with barrier * @adapter: the adapter * @reg_addr: the register address * @val: the value to write @@ -398,6 +404,22 @@ static inline void t4_write_reg(struct adapter *adapter, u32 reg_addr, u32 val) } /** + * t4_write_reg_relaxed - write a HW register with no barrier + * @adapter: the adapter + * @reg_addr: the register address + * @val: the value to write + * + * Write a 32-bit value into the given HW register. + */ +static inline void t4_write_reg_relaxed(struct adapter *adapter, u32 reg_addr, + u32 val) +{ + CXGBE_DEBUG_REG(adapter, "setting register 0x%x to 0x%x\n", reg_addr, + val); + CXGBE_WRITE_REG_RELAXED(adapter, reg_addr, val); +} + +/** * t4_read_reg64 - read a 64-bit HW register * @adapter: the adapter * @reg_addr: the register address diff --git a/drivers/net/cxgbe/cxgbe_compat.h b/drivers/net/cxgbe/cxgbe_compat.h index e68f8f5..1551cbf 100644 --- a/drivers/net/cxgbe/cxgbe_compat.h +++ b/drivers/net/cxgbe/cxgbe_compat.h @@ -45,6 +45,7 @@ #include #include #include +#include #define dev_printf(level, fmt, args...) \ RTE_LOG(level, PMD, "rte_cxgbe_pmd: " fmt, ## args) @@ -254,7 +255,7 @@ static inline unsigned long ilog2(unsigned long n) static inline void writel(unsigned int val, volatile void __iomem *addr) { - *(volatile unsigned int *)addr = val; + rte_write32(val, addr); } static inline void writeq(u64 val, volatile void __iomem *addr) @@ -263,4 +264,9 @@ static inline void writeq(u64 val, volatile void __iomem *addr) writel(val >> 32, (void *)((uintptr_t)addr + 4)); } +static inline void writel_relaxed(unsigned int val, volatile void __iomem *addr) +{ + rte_write32_relaxed(val, addr); +} + #endif /* _CXGBE_COMPAT_H_ */ diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c index 736f08c..fc03a0c 100644 --- a/drivers/net/cxgbe/sge.c +++ b/drivers/net/cxgbe/sge.c @@ -338,12 +338,12 @@ static inline void ring_fl_db(struct adapter *adap, struct sge_fl *q) * mechanism. */ if (unlikely(!q->bar2_addr)) { - t4_write_reg(adap, MYPF_REG(A_SGE_PF_KDOORBELL), - val | V_QID(q->cntxt_id)); + t4_write_reg_relaxed(adap, MYPF_REG(A_SGE_PF_KDOORBELL), + val | V_QID(q->cntxt_id)); } else { - writel(val | V_QID(q->bar2_qid), - (void *)((uintptr_t)q->bar2_addr + - SGE_UDB_KDOORBELL)); + writel_relaxed(val | V_QID(q->bar2_qid), + (void *)((uintptr_t)q->bar2_addr + + SGE_UDB_KDOORBELL)); /* * This Write memory Barrier will force the write to -- 2.5.5