From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0080.outbound.protection.outlook.com [104.47.42.80]) by dpdk.org (Postfix) with ESMTP id AF8437CB8 for ; Thu, 31 Aug 2017 16:55:25 +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=0eSUIchnWkjX9L7PJJl2xv92Wt8XYXlbCEa3IMWjw/Q=; b=Ypup7XTduu4FMu8mIysykm3U2bwhCJrmlBOuXtitV6NKU8oJF08Bqi2XkYKYd7vOBD7Z0BpZWXL+Fzjq8Ynei4J/MVaKS+aH2FKLK8eR5tTNrxnykQK6FYuD0Fptwjzdzi4UydMnTnFwAXVf6RXzbKyIeaSInT8J9736XqVQJ/w= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.JacobKollanukkaran@cavium.com; Received: from jerin.domain.name (171.76.126.71) by SN2PR07MB2526.namprd07.prod.outlook.com (2603:10b6:804:6::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Thu, 31 Aug 2017 14:55:22 +0000 From: Jerin Jacob To: dev@dpdk.org Cc: ferruh.yigit@intel.com, santosh.shukla@caviumnetworks.com, Jerin Jacob Date: Thu, 31 Aug 2017 20:24:12 +0530 Message-Id: <20170831145436.5397-3-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170831145436.5397-1-jerin.jacob@caviumnetworks.com> References: <20170831145436.5397-1-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [171.76.126.71] X-ClientProxiedBy: MA1PR01CA0109.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::25) To SN2PR07MB2526.namprd07.prod.outlook.com (2603:10b6:804:6::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5a17df19-5737-4e40-7d78-08d4f0804f3c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:SN2PR07MB2526; X-Microsoft-Exchange-Diagnostics: 1; SN2PR07MB2526; 3:xsF+4xnnTF6Jsx69UBr/Ryk9GrBdzBuGeieyuHd9hksoNGGb9xczGbf6Bnue7TaVblRA83hJlCA+L2/LaaGZfUIRwtPZdzXkfQF60+YIiscW92lgPSrE1KMoLb07OPXqG87YRUiQaLSc7AAZastlTrVQ1JSeSxA6xYvOAHzeTCLxLXFqzobgP3gm0cAte7ttDcFPdd8GYaRu7cXfifaxN97ZQrKqqKYqMsMnJEBUgjRyPESgUfYvWe0TMLLufyUg; 25:MmpCJR7vvTrXzrWXyg+LlTlMjrBZopbmLuUAcGv7g8kD2lxdnuCjy7gNReHqf2N5jwFQgd91Vc9p+kbD/1GT+jJoTU0sz6XlhdZqdt7lMxG8edrWVRO7PH9ORVVQR7NEjSCjw2gald9xv53Tl+/c1jvSbfoyPoMRXyvCQudg4HWRVRCEXbl/2SfRPO+8mXJ/ORvMUfweY+DZ6CNUBgZn1z4lCfjyIu9yIAH+JFo5/20wHQAODd+aO99+4NpmijSI7gsQsp8vhec7XVIsU73bZksZDEGg5GOJ0q39IxLGR27t4v8R5HZJz8DdzF3L0zMX0lRgzfdqM6pFXN3m+95kyA==; 31:fTJ8xd9dEvkIfdAmhmfmIAXzGOV0eFoQOGU2rssNvg6LTVayeMIGPd3IzD5z7E0h1HaLkfUt7ElijYATDJKPEAcPrqq4HoFq7n+KRq53nhASUd2V6lZ8HB2Sz6t4ZQZ2uLa6FhpTYGkfdtWpMHRL23JJM3fjtx1TtKTgst44y9QnGULxUqdFOlCiAeyELq4+ad5eBCFcibH1SSB+X4K5dhcHnZUtTmCR8Pw/wWMDOv8= X-MS-TrafficTypeDiagnostic: SN2PR07MB2526: X-Microsoft-Exchange-Diagnostics: 1; SN2PR07MB2526; 20:UgqzCP9KhB/pN68JmO9B5iTfhc3xEJfgyFDJvJMAMszn/SQfPCmOKImur5wpOOXxxa1n1ydVEdUAX7fFHF1rcbDm511O0zmustZRzGgRGj2/MOzlb5F7gULC6eU3N5xAyGWUl+/GmOVocZKZTZsTfohjX5Xs/MamHxq98zms7EERkY5KwJGBpLn3IsxbvCh5DwiUobnOhi+PW6JC464jUpA4W1U276rV/F3JHgfAOSzAN9Jcg7ynq+E1JOf735/qDKk99fbfLgctO3uy+G8P0zOrUDLGT8t9HMwRSK/TX+Gn36+e1meN4gIFdtJG6gRgxPphDiMGpbKZ0NBFnoUFXnsoldxky03/ccIeGS5ojSEkWudO1zlrLOjUfgAuTXPHcSqYftJz6GeqoZQUQnWqM/NO/cZsjBJCvfUVejFCDy0zOzcXxCuCjnMoAPPzfJ4Ah00r/T0/62KuKyvs4CwjHOgza1g1bu+ZdwxLMQIy0+XjjVNGTpmlk+9/jXtxAKcviFB8kFDH3PHwKz/aBgnLy4MFEXd1EZ+d7vp3dAOLP7LAqMgtC/IPFpGV7ovgcvvERiA5xOzwWSqub1s0q6g5GGZ1wBHruRmjqIDljhVdIn4=; 4:f1/Ko7/ishorR45PdfLnCsHXbP7HHzgjR2htZZQaASLeKVTxCL8g1mRJ+h1UjX4cE1B8TpKM5YhdF5Q9O/6/0aj+vqfi44uKk/A0DPyIvPgMTXTnWPFbtZYL/QD4dsEtYGPb6nSKzrnvRGA/wKmZln414v82bz1tzzXGxvu8sEd64/ndBEt0iVagpfCljMun6PwmEBNGzTA61T59qu4exG+A34ZnDOQsd8Z+qpcecCprgMhP6F3ZELqiu2Tn/m6d 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)(601004)(2401047)(5005006)(8121501046)(93006095)(100000703101)(100105400095)(10201501046)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123562025)(20161123560025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN2PR07MB2526; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN2PR07MB2526; X-Forefront-PRVS: 04163EF38A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(25786009)(1076002)(53936002)(3846002)(6116002)(478600001)(110136004)(72206003)(7736002)(6666003)(107886003)(6512007)(305945005)(6506006)(36756003)(6486002)(68736007)(5003940100001)(189998001)(50986999)(42882006)(106356001)(101416001)(76176999)(2950100002)(6916009)(5660300001)(2361001)(33646002)(2351001)(2906002)(4326008)(97736004)(105586002)(48376002)(50466002)(81166006)(66066001)(69596002)(8936002)(47776003)(53416004)(8676002)(50226002)(81156014)(42186005)(473944003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR07MB2526; H:jerin.domain.name; 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; SN2PR07MB2526; 23:wB5cjN64iNvzZc8Tu2ymE+4tr4wxqHONORFdK4mCX?= =?us-ascii?Q?Y/w2vdeoCuKLOz3OvFSPeY+RJRrCVT/epaSnHvh0UFu5AS+JR1YRb5kJcUli?= =?us-ascii?Q?FlDg88d1sHLHxUZg2yMrUEHIE2RYLhw/DJD7C7Zt/Gm6aVf67VYX0JTw38zK?= =?us-ascii?Q?1tDqwG0yz3O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utput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2017 14:55:22.7083 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR07MB2526 Subject: [dpdk-dev] [PATCH 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: Thu, 31 Aug 2017 14:55:26 -0000 Adding octeontx specific io operations. Added a stub for building against non octeontx targets. Signed-off-by: Jerin Jacob Co-authored-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