From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0076.outbound.protection.outlook.com [104.47.36.76]) by dpdk.org (Postfix) with ESMTP id 16CC11B18C for ; Sun, 8 Oct 2017 14:45:26 +0200 (CEST) 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=hiWoQ9983B572dJ4JxeMlwZDxU3270p1s5CkA0T6onQ=; b=Rgnv3ps0zw5cF7puytzbmClLjffOZQcXeXgThQFoRs/fOPeSU3DRt6m/QGZechO6+Isj0wGbZR/KAXGjz41C1wiJYktKcLcV+qOO9OplCtYboKpkyeTe5T6JiGtfeiCadz/cbgM2605DfHJ7fuA+HMeDDp5Uu3YbueITZ1p7jlc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Santosh.Shukla@cavium.com; Received: from localhost.localdomain (14.140.2.178) by BN6PR07MB3089.namprd07.prod.outlook.com (10.172.105.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Sun, 8 Oct 2017 12:45:23 +0000 From: Santosh Shukla To: dev@dpdk.org Cc: ferruh.yigit@intel.com, jerin.jacob@caviumnetworks.com, Santosh Shukla Date: Sun, 8 Oct 2017 18:14:06 +0530 Message-Id: <20171008124430.1866-3-santosh.shukla@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171008124430.1866-1-santosh.shukla@caviumnetworks.com> References: <20170831145436.5397-1-jerin.jacob@caviumnetworks.com> <20171008124430.1866-1-santosh.shukla@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: MA1PR01CA0113.INDPRD01.PROD.OUTLOOK.COM (10.174.56.157) To BN6PR07MB3089.namprd07.prod.outlook.com (10.172.105.7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d96e0d3f-0812-485e-0db3-08d50e4a7281 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:BN6PR07MB3089; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3089; 3:skRt/raE9WMpHiHt7Gr15BcR4zwQnKzdnkGYNlzQBvj2KI2yrRM3HhoKkQVEEpVhLdXkZaqAvtyITDYZK08bR65A4GYPgAgXw96yp/52ZlU9fKv3EJLpec72zMyNzuQNgl5z4GppkEKgnx6rnuYhaEdKnrCxmWCw5z0VVZXisj9xgugCD0QcWZvjGofWuq07EfYl0y5/kEQs5WkxcwYxixGpIVSOS1pfJVihdS6HPmJpFMgp7icJzPsMGwgyoqhk; 25:3BuwaPjch6mQat7zQYlWF0FE7+J8LGc44eqWC30Z8oYOiMmG7k33EGvLy+RtcV/Fi2PITbj940/mvmzL3X+qEonCuRNoLl0BmyDKn/Ov9lXur/PFZa65oxO1fTFHDZ5+EmB/u1ssXBswPZpaSPHpLuc4AitRaTez4MA4McPD1ffk4wq8FZGiB0ZzcwssIuORbTp6aj/1d7+1/Y012RuQX9yxUE7es32iGykx255/2afPK4LUKtVhYbYFnN2DmhwWAQn9hJiyVGlPcjicqbSB5ZhY29mefjWReifb6045iXsv82OmGp5Ukru3MehyWSjexRUInKV7nqa6/BdHV5NHYA==; 31:XU6ZAIyHohoME6HOsc11t/DvIvR1CnS/dKId68z7zBGFVjnG8I2cKxAp5KaaoMKSeI1raiE+6K1PJy3c2813LLgIHLVGZF1dr58x1MEACTmdGj2EdiAt73ykRpLLEasjRlowQNuuXJNV/TW+a0mY7Nn1aIvPTzXrIGZPsNrkW1YtFfTj+cLuJY7bHyo3uK80KcZ2hsSTZRpfrJ8ZfKZAGAnbjCHaCuk5RYQQa1JJWs4= X-MS-TrafficTypeDiagnostic: BN6PR07MB3089: X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3089; 20:WL5rgjM6/kSu7SI+11gaCoRjmGGtPfmqfgcN9yTN4xgU96VLh3QmDrPjstnunUwA6AY5y3II7bcCaVdwkRliL/AiJcStm5b4jehV3hyVA1d/B/FV6ieJWmvn3tvN0xeWJFO378jNLxoRkycon8rY7mzzNIqNAAvXxPgPVgE7T5Pgo7ewfQ2eYDzh09XZdeueq3rN3dfmkCFbA14TjlhvhNhARJCCV7fUHqbKsDfXgg97HBtyZ8IAe754I9CBl0/iyZL+ZVj/+/VrNFSSWekBBmefFDMDoor+qYcQ48O7Dzs7Q3r6lV1CGLoZs1spWqLueZeLcczVzdDLuaTGDnGjaJuQ7pTN2hLl/i+ligQ6hfhYt/uSR7i0jTWR87QQf/f/Z4ta33L/NROoekG0uKr8ZXC2cuuu24qmJuNWjuJ5ixtanKx7zqtLDnlvHfj7IKpCXymx3PpRDKBMZIwjbOrQka+tVL8CBPg3qDVUBavD1iYFdkBqBIOr0aJCg8ohcAUf7hA/e8h3cR/lXpPqLpmtkcsyRp0axM5Q+m02uBwoFvLSura9xXEASKij1J+mAm45TFfGQqGPK2JsqAfz15i7dRtG0dPGxFLtBhqzWLNsDDY=; 4:y2Jfyj7V+ZaiZFyzoAEh42JbTo4jJV+8tmfgKjLZI0Dc0lEMWiu4cBMx2vknaKeMW/NnUamN4i5EtyRNALxVEaDCmufPbWquEGpRY9w+q6ZvbxCdZhq9dQDxeKrfrnzcwPkqtjthsBE/fSKUPkmhicRXOctD8bh1DgoTDHLCtT/e8imces6ZnFerN0+8Khi/sEOuyF+Xfo2OrWRJkkQjvhGXE9H58qaHZmAKCdxdI9a0vkB8NiLneyGle3D5O+Xs X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(100000703101)(100105400095)(6041248)(20161123562025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR07MB3089; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR07MB3089; X-Forefront-PRVS: 0454444834 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(376002)(346002)(199003)(189002)(6916009)(42882006)(81166006)(2950100002)(81156014)(8936002)(50226002)(6486002)(16526018)(6666003)(189998001)(16586007)(316002)(6116002)(1076002)(6506006)(3846002)(7736002)(305945005)(8676002)(106356001)(105586002)(5009440100003)(53936002)(4326008)(66066001)(107886003)(47776003)(2906002)(5660300001)(6512007)(76176999)(5003940100001)(50986999)(97736004)(25786009)(101416001)(68736007)(48376002)(50466002)(478600001)(72206003)(2351001)(2361001)(33646002)(36756003)(110426004)(473944003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR07MB3089; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; BN6PR07MB3089; 23:HrGvfu8XWwmiVemg13htd0qoMk0Ql7aN+126wpee5?= =?us-ascii?Q?Iw0Vqk8PfjzVUwv3lIEEY7CQ/eA7CTUXVbiZolFrIfpm2bWS91RXJKAnhNk6?= =?us-ascii?Q?tIaHnD/N9+o3hgNTovjM1PcppAnc7MVtJMg6rkkJYzH3gBYrgCP/f5WDfHep?= =?us-ascii?Q?JJ3jpsKbL3f7FwfIddtcMlpiKR0kvEOcYpWNi97VFe1yAR3yfWsEyQvvndnD?= =?us-ascii?Q?t9nXOmHdGhmJ2yWfmuRlNGyofL+b+u4VxaIW7C1gLlLGz0vT/zWfbCce/zTK?= =?us-ascii?Q?6+82RrQYxqjcht8SLuOrB48eTYdtT8v5JgiUNmbUcuz5vfsUB5xxyz23KE4g?= =?us-ascii?Q?RczZU14rkEOT1g578pJyouBvw6ch3uPzwSa3uN7DQ1jCXB8N98j2VsBCbt+Y?= =?us-ascii?Q?MMXETf6neckK/aXCfG59H1lDqd13fSFofdWR+/9cIARZzmM9XWpnI68lmHpW?= =?us-ascii?Q?vrcN6dbCyW3bpaFidFidfA26QcC7cpQcMFn4sICzkzfCgUCHmKduSXAKYRNN?= =?us-ascii?Q?12lVM+3TP9F6IjmMGBRP4J2HK6k1IXXmyfQ/IGSF+3reOBd58EB74eZSHbiA?= =?us-ascii?Q?4q+4vlDIbLEzVwLM87/Q/7eH5amjnXML3Ql8cMVgU4WhZl727n6IqFbqEzZS?= =?us-ascii?Q?OaAEzv0QrCVSiHmbJfhQSeJEvyMoIOkyym81nRoGV83Fa5Z0mrpBbL9gPqOg?= =?us-ascii?Q?pYxkCcNBMnDptCocFcmOUb7Z1EaHAwYQB5Y5cdUhib4dyWB75zpfbopLZyez?= =?us-ascii?Q?Ye14isN9pl3EGkiHO8S6bJHwG99X2/oSGQxzuOir6Y+8YW0o10H8xGSkc73V?= =?us-ascii?Q?OuiNoKDWS1W2g4bee6rEYp57WN7/ILbBXPt81FtPO3+ObM4/DzgHkXhul52V?= =?us-ascii?Q?FNKur3LBiC6DVgQEKegRgnprRM6gZEgD2bUMu1PX97nWPS6Hgz+VeelrLB3u?= =?us-ascii?Q?E+cGqUyPtA3NI1er97kZHkewg0boXro5LFRCWUr6vHVk9mObF8OOsp4g4g6y?= =?us-ascii?Q?A1c5VF3LrrApbYdMt0/NfoHS7mhQFoj6Gfj54kA5svfA2/dgHc68nmR6fVOB?= =?us-ascii?Q?IoGCFL6RQaIWGr8/TacAQSe8QEgzonlNVZISA9YGg54maeQyqX9n2aWu8YJ6?= =?us-ascii?Q?HySkNnVXhjtUPkW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amDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2017 12:45:23.5601 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3089 Subject: [dpdk-dev] [PATCH v2 02/26] net/octeontx/base: add octeontx io operations 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: Sun, 08 Oct 2017 12:45:27 -0000 From: Jerin Jacob Adding octeontx specific io operations. Added a stub for building against non octeontx targets. Signed-off-by: Jerin Jacob Co-authored-by: Santosh Shukla Signed-off-by: Santosh Shukla --- drivers/net/octeontx/base/octeontx_io.h | 156 ++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 drivers/net/octeontx/base/octeontx_io.h diff --git a/drivers/net/octeontx/base/octeontx_io.h b/drivers/net/octeontx/base/octeontx_io.h new file mode 100644 index 000000000..ec4ce1dcd --- /dev/null +++ b/drivers/net/octeontx/base/octeontx_io.h @@ -0,0 +1,156 @@ +/* + * BSD LICENSE + * + * Copyright (C) Cavium Inc. 2017. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Cavium networks nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __OCTEONTX_IO_H__ +#define __OCTEONTX_IO_H__ + +#include +#include + +#include + +/* In Cavium OcteonTX SoC, all accesses to the device registers are + * implicitly strongly ordered. So, The relaxed version of IO operation is + * safe to use with out any IO memory barriers. + */ +#define octeontx_read64 rte_read64_relaxed +#define octeontx_write64 rte_write64_relaxed + +/* ARM64 specific functions */ +#if defined(RTE_ARCH_ARM64) +#define octeontx_prefetch_store_keep(_ptr) ({\ + asm volatile("prfm pstl1keep, %a0\n" : : "p" (_ptr)); }) + +#define octeontx_load_pair(val0, val1, addr) ({ \ + asm volatile( \ + "ldp %x[x0], %x[x1], [%x[p1]]" \ + :[x0]"=r"(val0), [x1]"=r"(val1) \ + :[p1]"r"(addr) \ + ); }) + +#define octeontx_store_pair(val0, val1, addr) ({ \ + asm volatile( \ + "stp %x[x0], %x[x1], [%x[p1]]" \ + ::[x0]"r"(val0), [x1]"r"(val1), [p1]"r"(addr) \ + ); }) +#else /* Un optimized functions for building on non arm64 arch */ + +#define octeontx_prefetch_store_keep(_ptr) do {} while (0) + +#define octeontx_load_pair(val0, val1, addr) \ +do { \ + val0 = rte_read64(addr); \ + val1 = rte_read64(((uint8_t *)addr) + 8); \ +} while (0) + +#define octeontx_store_pair(val0, val1, addr) \ +do { \ + rte_write64(val0, addr); \ + rte_write64(val1, (((uint8_t *)addr) + 8)); \ +} while (0) +#endif + +#if defined(RTE_ARCH_ARM64) +/** + * Perform an atomic fetch-and-add operation. + */ +static inline uint64_t +octeontx_reg_ldadd_u64(void *addr, int64_t off) +{ + uint64_t old_val; + + __asm__ volatile( + " .cpu generic+lse\n" + " ldadd %1, %0, [%2]\n" + : "=r" (old_val) : "r" (off), "r" (addr) : "memory"); + + return old_val; +} + +/** + * Perform a LMTST operation - an atomic write of up to 128 byte to + * an I/O block that supports this operation type. + * + * @param lmtline_va is the address where LMTLINE is mapped + * @param ioreg_va is the virtual address of the device register + * @param cmdbuf is the array of peripheral commands to execute + * @param cmdsize is the number of 64-bit words in 'cmdbuf' + * + * @return N/A + */ +static inline void +octeontx_reg_lmtst(void *lmtline_va, void *ioreg_va, const uint64_t cmdbuf[], + uint64_t cmdsize) +{ + uint64_t result; + uint64_t word_count; + uint64_t *lmtline = lmtline_va; + + word_count = cmdsize; + + do { + /* Copy commands to LMTLINE */ + for (result = 0; result < word_count; result += 2) { + lmtline[result + 0] = cmdbuf[result + 0]; + lmtline[result + 1] = cmdbuf[result + 1]; + } + + /* LDEOR initiates atomic transfer to I/O device */ + __asm__ volatile( + " .cpu generic+lse\n" + " ldeor xzr, %0, [%1]\n" + : "=r" (result) : "r" (ioreg_va) : "memory"); + } while (!result); +} + +#else + +static inline uint64_t +octeontx_reg_ldadd_u64(void *addr, int64_t off) +{ + RTE_SET_USED(addr); + RTE_SET_USED(off); + return 0; +} + +static inline void +octeontx_reg_lmtst(void *lmtline_va, void *ioreg_va, const uint64_t cmdbuf[], + uint64_t cmdsize) +{ + RTE_SET_USED(lmtline_va); + RTE_SET_USED(ioreg_va); + RTE_SET_USED(cmdbuf); + RTE_SET_USED(cmdsize); +} + +#endif +#endif /* __OCTEONTX_IO_H__ */ -- 2.14.1