18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright(c) 2015 - 2020 Intel Corporation. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license. When using or 58c2ecf20Sopenharmony_ci * redistributing this file, you may do so under either license. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * GPL LICENSE SUMMARY 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 108c2ecf20Sopenharmony_ci * it under the terms of version 2 of the GNU General Public License as 118c2ecf20Sopenharmony_ci * published by the Free Software Foundation. 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, but 148c2ecf20Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of 158c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 168c2ecf20Sopenharmony_ci * General Public License for more details. 178c2ecf20Sopenharmony_ci * 188c2ecf20Sopenharmony_ci * BSD LICENSE 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 218c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions 228c2ecf20Sopenharmony_ci * are met: 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * - Redistributions of source code must retain the above copyright 258c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 268c2ecf20Sopenharmony_ci * - Redistributions in binary form must reproduce the above copyright 278c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer in 288c2ecf20Sopenharmony_ci * the documentation and/or other materials provided with the 298c2ecf20Sopenharmony_ci * distribution. 308c2ecf20Sopenharmony_ci * - Neither the name of Intel Corporation nor the names of its 318c2ecf20Sopenharmony_ci * contributors may be used to endorse or promote products derived 328c2ecf20Sopenharmony_ci * from this software without specific prior written permission. 338c2ecf20Sopenharmony_ci * 348c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 358c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 368c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 378c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 388c2ecf20Sopenharmony_ci * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 398c2ecf20Sopenharmony_ci * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 408c2ecf20Sopenharmony_ci * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 418c2ecf20Sopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 428c2ecf20Sopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 438c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 448c2ecf20Sopenharmony_ci * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 458c2ecf20Sopenharmony_ci * 468c2ecf20Sopenharmony_ci */ 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#ifndef _COMMON_H 498c2ecf20Sopenharmony_ci#define _COMMON_H 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#include <rdma/hfi/hfi1_user.h> 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci/* 548c2ecf20Sopenharmony_ci * This file contains defines, structures, etc. that are used 558c2ecf20Sopenharmony_ci * to communicate between kernel and user code. 568c2ecf20Sopenharmony_ci */ 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* version of protocol header (known to chip also). In the long run, 598c2ecf20Sopenharmony_ci * we should be able to generate and accept a range of version numbers; 608c2ecf20Sopenharmony_ci * for now we only accept one, and it's compiled in. 618c2ecf20Sopenharmony_ci */ 628c2ecf20Sopenharmony_ci#define IPS_PROTO_VERSION 2 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* 658c2ecf20Sopenharmony_ci * These are compile time constants that you may want to enable or disable 668c2ecf20Sopenharmony_ci * if you are trying to debug problems with code or performance. 678c2ecf20Sopenharmony_ci * HFI1_VERBOSE_TRACING define as 1 if you want additional tracing in 688c2ecf20Sopenharmony_ci * fast path code 698c2ecf20Sopenharmony_ci * HFI1_TRACE_REGWRITES define as 1 if you want register writes to be 708c2ecf20Sopenharmony_ci * traced in fast path code 718c2ecf20Sopenharmony_ci * _HFI1_TRACING define as 0 if you want to remove all tracing in a 728c2ecf20Sopenharmony_ci * compilation unit 738c2ecf20Sopenharmony_ci */ 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* driver/hw feature set bitmask */ 768c2ecf20Sopenharmony_ci#define HFI1_CAP_USER_SHIFT 24 778c2ecf20Sopenharmony_ci#define HFI1_CAP_MASK ((1UL << HFI1_CAP_USER_SHIFT) - 1) 788c2ecf20Sopenharmony_ci/* locked flag - if set, only HFI1_CAP_WRITABLE_MASK bits can be set */ 798c2ecf20Sopenharmony_ci#define HFI1_CAP_LOCKED_SHIFT 63 808c2ecf20Sopenharmony_ci#define HFI1_CAP_LOCKED_MASK 0x1ULL 818c2ecf20Sopenharmony_ci#define HFI1_CAP_LOCKED_SMASK (HFI1_CAP_LOCKED_MASK << HFI1_CAP_LOCKED_SHIFT) 828c2ecf20Sopenharmony_ci/* extra bits used between kernel and user processes */ 838c2ecf20Sopenharmony_ci#define HFI1_CAP_MISC_SHIFT (HFI1_CAP_USER_SHIFT * 2) 848c2ecf20Sopenharmony_ci#define HFI1_CAP_MISC_MASK ((1ULL << (HFI1_CAP_LOCKED_SHIFT - \ 858c2ecf20Sopenharmony_ci HFI1_CAP_MISC_SHIFT)) - 1) 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#define HFI1_CAP_KSET(cap) ({ hfi1_cap_mask |= HFI1_CAP_##cap; hfi1_cap_mask; }) 888c2ecf20Sopenharmony_ci#define HFI1_CAP_KCLEAR(cap) \ 898c2ecf20Sopenharmony_ci ({ \ 908c2ecf20Sopenharmony_ci hfi1_cap_mask &= ~HFI1_CAP_##cap; \ 918c2ecf20Sopenharmony_ci hfi1_cap_mask; \ 928c2ecf20Sopenharmony_ci }) 938c2ecf20Sopenharmony_ci#define HFI1_CAP_USET(cap) \ 948c2ecf20Sopenharmony_ci ({ \ 958c2ecf20Sopenharmony_ci hfi1_cap_mask |= (HFI1_CAP_##cap << HFI1_CAP_USER_SHIFT); \ 968c2ecf20Sopenharmony_ci hfi1_cap_mask; \ 978c2ecf20Sopenharmony_ci }) 988c2ecf20Sopenharmony_ci#define HFI1_CAP_UCLEAR(cap) \ 998c2ecf20Sopenharmony_ci ({ \ 1008c2ecf20Sopenharmony_ci hfi1_cap_mask &= ~(HFI1_CAP_##cap << HFI1_CAP_USER_SHIFT); \ 1018c2ecf20Sopenharmony_ci hfi1_cap_mask; \ 1028c2ecf20Sopenharmony_ci }) 1038c2ecf20Sopenharmony_ci#define HFI1_CAP_SET(cap) \ 1048c2ecf20Sopenharmony_ci ({ \ 1058c2ecf20Sopenharmony_ci hfi1_cap_mask |= (HFI1_CAP_##cap | (HFI1_CAP_##cap << \ 1068c2ecf20Sopenharmony_ci HFI1_CAP_USER_SHIFT)); \ 1078c2ecf20Sopenharmony_ci hfi1_cap_mask; \ 1088c2ecf20Sopenharmony_ci }) 1098c2ecf20Sopenharmony_ci#define HFI1_CAP_CLEAR(cap) \ 1108c2ecf20Sopenharmony_ci ({ \ 1118c2ecf20Sopenharmony_ci hfi1_cap_mask &= ~(HFI1_CAP_##cap | \ 1128c2ecf20Sopenharmony_ci (HFI1_CAP_##cap << HFI1_CAP_USER_SHIFT)); \ 1138c2ecf20Sopenharmony_ci hfi1_cap_mask; \ 1148c2ecf20Sopenharmony_ci }) 1158c2ecf20Sopenharmony_ci#define HFI1_CAP_LOCK() \ 1168c2ecf20Sopenharmony_ci ({ hfi1_cap_mask |= HFI1_CAP_LOCKED_SMASK; hfi1_cap_mask; }) 1178c2ecf20Sopenharmony_ci#define HFI1_CAP_LOCKED() (!!(hfi1_cap_mask & HFI1_CAP_LOCKED_SMASK)) 1188c2ecf20Sopenharmony_ci/* 1198c2ecf20Sopenharmony_ci * The set of capability bits that can be changed after initial load 1208c2ecf20Sopenharmony_ci * This set is the same for kernel and user contexts. However, for 1218c2ecf20Sopenharmony_ci * user contexts, the set can be further filtered by using the 1228c2ecf20Sopenharmony_ci * HFI1_CAP_RESERVED_MASK bits. 1238c2ecf20Sopenharmony_ci */ 1248c2ecf20Sopenharmony_ci#define HFI1_CAP_WRITABLE_MASK (HFI1_CAP_SDMA_AHG | \ 1258c2ecf20Sopenharmony_ci HFI1_CAP_HDRSUPP | \ 1268c2ecf20Sopenharmony_ci HFI1_CAP_MULTI_PKT_EGR | \ 1278c2ecf20Sopenharmony_ci HFI1_CAP_NODROP_RHQ_FULL | \ 1288c2ecf20Sopenharmony_ci HFI1_CAP_NODROP_EGR_FULL | \ 1298c2ecf20Sopenharmony_ci HFI1_CAP_ALLOW_PERM_JKEY | \ 1308c2ecf20Sopenharmony_ci HFI1_CAP_STATIC_RATE_CTRL | \ 1318c2ecf20Sopenharmony_ci HFI1_CAP_PRINT_UNIMPL | \ 1328c2ecf20Sopenharmony_ci HFI1_CAP_TID_UNMAP | \ 1338c2ecf20Sopenharmony_ci HFI1_CAP_OPFN) 1348c2ecf20Sopenharmony_ci/* 1358c2ecf20Sopenharmony_ci * A set of capability bits that are "global" and are not allowed to be 1368c2ecf20Sopenharmony_ci * set in the user bitmask. 1378c2ecf20Sopenharmony_ci */ 1388c2ecf20Sopenharmony_ci#define HFI1_CAP_RESERVED_MASK ((HFI1_CAP_SDMA | \ 1398c2ecf20Sopenharmony_ci HFI1_CAP_USE_SDMA_HEAD | \ 1408c2ecf20Sopenharmony_ci HFI1_CAP_EXTENDED_PSN | \ 1418c2ecf20Sopenharmony_ci HFI1_CAP_PRINT_UNIMPL | \ 1428c2ecf20Sopenharmony_ci HFI1_CAP_NO_INTEGRITY | \ 1438c2ecf20Sopenharmony_ci HFI1_CAP_PKEY_CHECK | \ 1448c2ecf20Sopenharmony_ci HFI1_CAP_TID_RDMA | \ 1458c2ecf20Sopenharmony_ci HFI1_CAP_OPFN | \ 1468c2ecf20Sopenharmony_ci HFI1_CAP_AIP) << \ 1478c2ecf20Sopenharmony_ci HFI1_CAP_USER_SHIFT) 1488c2ecf20Sopenharmony_ci/* 1498c2ecf20Sopenharmony_ci * Set of capabilities that need to be enabled for kernel context in 1508c2ecf20Sopenharmony_ci * order to be allowed for user contexts, as well. 1518c2ecf20Sopenharmony_ci */ 1528c2ecf20Sopenharmony_ci#define HFI1_CAP_MUST_HAVE_KERN (HFI1_CAP_STATIC_RATE_CTRL) 1538c2ecf20Sopenharmony_ci/* Default enabled capabilities (both kernel and user) */ 1548c2ecf20Sopenharmony_ci#define HFI1_CAP_MASK_DEFAULT (HFI1_CAP_HDRSUPP | \ 1558c2ecf20Sopenharmony_ci HFI1_CAP_NODROP_RHQ_FULL | \ 1568c2ecf20Sopenharmony_ci HFI1_CAP_NODROP_EGR_FULL | \ 1578c2ecf20Sopenharmony_ci HFI1_CAP_SDMA | \ 1588c2ecf20Sopenharmony_ci HFI1_CAP_PRINT_UNIMPL | \ 1598c2ecf20Sopenharmony_ci HFI1_CAP_STATIC_RATE_CTRL | \ 1608c2ecf20Sopenharmony_ci HFI1_CAP_PKEY_CHECK | \ 1618c2ecf20Sopenharmony_ci HFI1_CAP_MULTI_PKT_EGR | \ 1628c2ecf20Sopenharmony_ci HFI1_CAP_EXTENDED_PSN | \ 1638c2ecf20Sopenharmony_ci HFI1_CAP_AIP | \ 1648c2ecf20Sopenharmony_ci ((HFI1_CAP_HDRSUPP | \ 1658c2ecf20Sopenharmony_ci HFI1_CAP_MULTI_PKT_EGR | \ 1668c2ecf20Sopenharmony_ci HFI1_CAP_STATIC_RATE_CTRL | \ 1678c2ecf20Sopenharmony_ci HFI1_CAP_PKEY_CHECK | \ 1688c2ecf20Sopenharmony_ci HFI1_CAP_EARLY_CREDIT_RETURN) << \ 1698c2ecf20Sopenharmony_ci HFI1_CAP_USER_SHIFT)) 1708c2ecf20Sopenharmony_ci/* 1718c2ecf20Sopenharmony_ci * A bitmask of kernel/global capabilities that should be communicated 1728c2ecf20Sopenharmony_ci * to user level processes. 1738c2ecf20Sopenharmony_ci */ 1748c2ecf20Sopenharmony_ci#define HFI1_CAP_K2U (HFI1_CAP_SDMA | \ 1758c2ecf20Sopenharmony_ci HFI1_CAP_EXTENDED_PSN | \ 1768c2ecf20Sopenharmony_ci HFI1_CAP_PKEY_CHECK | \ 1778c2ecf20Sopenharmony_ci HFI1_CAP_NO_INTEGRITY) 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci#define HFI1_USER_SWVERSION ((HFI1_USER_SWMAJOR << HFI1_SWMAJOR_SHIFT) | \ 1808c2ecf20Sopenharmony_ci HFI1_USER_SWMINOR) 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci#ifndef HFI1_KERN_TYPE 1838c2ecf20Sopenharmony_ci#define HFI1_KERN_TYPE 0 1848c2ecf20Sopenharmony_ci#endif 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci/* 1878c2ecf20Sopenharmony_ci * Similarly, this is the kernel version going back to the user. It's 1888c2ecf20Sopenharmony_ci * slightly different, in that we want to tell if the driver was built as 1898c2ecf20Sopenharmony_ci * part of a Intel release, or from the driver from openfabrics.org, 1908c2ecf20Sopenharmony_ci * kernel.org, or a standard distribution, for support reasons. 1918c2ecf20Sopenharmony_ci * The high bit is 0 for non-Intel and 1 for Intel-built/supplied. 1928c2ecf20Sopenharmony_ci * 1938c2ecf20Sopenharmony_ci * It's returned by the driver to the user code during initialization in the 1948c2ecf20Sopenharmony_ci * spi_sw_version field of hfi1_base_info, so the user code can in turn 1958c2ecf20Sopenharmony_ci * check for compatibility with the kernel. 1968c2ecf20Sopenharmony_ci*/ 1978c2ecf20Sopenharmony_ci#define HFI1_KERN_SWVERSION ((HFI1_KERN_TYPE << 31) | HFI1_USER_SWVERSION) 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci/* 2008c2ecf20Sopenharmony_ci * Define the driver version number. This is something that refers only 2018c2ecf20Sopenharmony_ci * to the driver itself, not the software interfaces it supports. 2028c2ecf20Sopenharmony_ci */ 2038c2ecf20Sopenharmony_ci#ifndef HFI1_DRIVER_VERSION_BASE 2048c2ecf20Sopenharmony_ci#define HFI1_DRIVER_VERSION_BASE "0.9-294" 2058c2ecf20Sopenharmony_ci#endif 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci/* create the final driver version string */ 2088c2ecf20Sopenharmony_ci#ifdef HFI1_IDSTR 2098c2ecf20Sopenharmony_ci#define HFI1_DRIVER_VERSION HFI1_DRIVER_VERSION_BASE " " HFI1_IDSTR 2108c2ecf20Sopenharmony_ci#else 2118c2ecf20Sopenharmony_ci#define HFI1_DRIVER_VERSION HFI1_DRIVER_VERSION_BASE 2128c2ecf20Sopenharmony_ci#endif 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci/* 2158c2ecf20Sopenharmony_ci * Diagnostics can send a packet by writing the following 2168c2ecf20Sopenharmony_ci * struct to the diag packet special file. 2178c2ecf20Sopenharmony_ci * 2188c2ecf20Sopenharmony_ci * This allows a custom PBC qword, so that special modes and deliberate 2198c2ecf20Sopenharmony_ci * changes to CRCs can be used. 2208c2ecf20Sopenharmony_ci */ 2218c2ecf20Sopenharmony_ci#define _DIAG_PKT_VERS 1 2228c2ecf20Sopenharmony_cistruct diag_pkt { 2238c2ecf20Sopenharmony_ci __u16 version; /* structure version */ 2248c2ecf20Sopenharmony_ci __u16 unit; /* which device */ 2258c2ecf20Sopenharmony_ci __u16 sw_index; /* send sw index to use */ 2268c2ecf20Sopenharmony_ci __u16 len; /* data length, in bytes */ 2278c2ecf20Sopenharmony_ci __u16 port; /* port number */ 2288c2ecf20Sopenharmony_ci __u16 unused; 2298c2ecf20Sopenharmony_ci __u32 flags; /* call flags */ 2308c2ecf20Sopenharmony_ci __u64 data; /* user data pointer */ 2318c2ecf20Sopenharmony_ci __u64 pbc; /* PBC for the packet */ 2328c2ecf20Sopenharmony_ci}; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci/* diag_pkt flags */ 2358c2ecf20Sopenharmony_ci#define F_DIAGPKT_WAIT 0x1 /* wait until packet is sent */ 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci/* 2388c2ecf20Sopenharmony_ci * The next set of defines are for packet headers, and chip register 2398c2ecf20Sopenharmony_ci * and memory bits that are visible to and/or used by user-mode software. 2408c2ecf20Sopenharmony_ci */ 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci/* 2438c2ecf20Sopenharmony_ci * Receive Header Flags 2448c2ecf20Sopenharmony_ci */ 2458c2ecf20Sopenharmony_ci#define RHF_PKT_LEN_SHIFT 0 2468c2ecf20Sopenharmony_ci#define RHF_PKT_LEN_MASK 0xfffull 2478c2ecf20Sopenharmony_ci#define RHF_PKT_LEN_SMASK (RHF_PKT_LEN_MASK << RHF_PKT_LEN_SHIFT) 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci#define RHF_RCV_TYPE_SHIFT 12 2508c2ecf20Sopenharmony_ci#define RHF_RCV_TYPE_MASK 0x7ull 2518c2ecf20Sopenharmony_ci#define RHF_RCV_TYPE_SMASK (RHF_RCV_TYPE_MASK << RHF_RCV_TYPE_SHIFT) 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ci#define RHF_USE_EGR_BFR_SHIFT 15 2548c2ecf20Sopenharmony_ci#define RHF_USE_EGR_BFR_MASK 0x1ull 2558c2ecf20Sopenharmony_ci#define RHF_USE_EGR_BFR_SMASK (RHF_USE_EGR_BFR_MASK << RHF_USE_EGR_BFR_SHIFT) 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci#define RHF_EGR_INDEX_SHIFT 16 2588c2ecf20Sopenharmony_ci#define RHF_EGR_INDEX_MASK 0x7ffull 2598c2ecf20Sopenharmony_ci#define RHF_EGR_INDEX_SMASK (RHF_EGR_INDEX_MASK << RHF_EGR_INDEX_SHIFT) 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci#define RHF_DC_INFO_SHIFT 27 2628c2ecf20Sopenharmony_ci#define RHF_DC_INFO_MASK 0x1ull 2638c2ecf20Sopenharmony_ci#define RHF_DC_INFO_SMASK (RHF_DC_INFO_MASK << RHF_DC_INFO_SHIFT) 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci#define RHF_RCV_SEQ_SHIFT 28 2668c2ecf20Sopenharmony_ci#define RHF_RCV_SEQ_MASK 0xfull 2678c2ecf20Sopenharmony_ci#define RHF_RCV_SEQ_SMASK (RHF_RCV_SEQ_MASK << RHF_RCV_SEQ_SHIFT) 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci#define RHF_EGR_OFFSET_SHIFT 32 2708c2ecf20Sopenharmony_ci#define RHF_EGR_OFFSET_MASK 0xfffull 2718c2ecf20Sopenharmony_ci#define RHF_EGR_OFFSET_SMASK (RHF_EGR_OFFSET_MASK << RHF_EGR_OFFSET_SHIFT) 2728c2ecf20Sopenharmony_ci#define RHF_HDRQ_OFFSET_SHIFT 44 2738c2ecf20Sopenharmony_ci#define RHF_HDRQ_OFFSET_MASK 0x1ffull 2748c2ecf20Sopenharmony_ci#define RHF_HDRQ_OFFSET_SMASK (RHF_HDRQ_OFFSET_MASK << RHF_HDRQ_OFFSET_SHIFT) 2758c2ecf20Sopenharmony_ci#define RHF_K_HDR_LEN_ERR (0x1ull << 53) 2768c2ecf20Sopenharmony_ci#define RHF_DC_UNC_ERR (0x1ull << 54) 2778c2ecf20Sopenharmony_ci#define RHF_DC_ERR (0x1ull << 55) 2788c2ecf20Sopenharmony_ci#define RHF_RCV_TYPE_ERR_SHIFT 56 2798c2ecf20Sopenharmony_ci#define RHF_RCV_TYPE_ERR_MASK 0x7ul 2808c2ecf20Sopenharmony_ci#define RHF_RCV_TYPE_ERR_SMASK (RHF_RCV_TYPE_ERR_MASK << RHF_RCV_TYPE_ERR_SHIFT) 2818c2ecf20Sopenharmony_ci#define RHF_TID_ERR (0x1ull << 59) 2828c2ecf20Sopenharmony_ci#define RHF_LEN_ERR (0x1ull << 60) 2838c2ecf20Sopenharmony_ci#define RHF_ECC_ERR (0x1ull << 61) 2848c2ecf20Sopenharmony_ci#define RHF_RESERVED (0x1ull << 62) 2858c2ecf20Sopenharmony_ci#define RHF_ICRC_ERR (0x1ull << 63) 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ci#define RHF_ERROR_SMASK 0xffe0000000000000ull /* bits 63:53 */ 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci/* RHF receive types */ 2908c2ecf20Sopenharmony_ci#define RHF_RCV_TYPE_EXPECTED 0 2918c2ecf20Sopenharmony_ci#define RHF_RCV_TYPE_EAGER 1 2928c2ecf20Sopenharmony_ci#define RHF_RCV_TYPE_IB 2 /* normal IB, IB Raw, or IPv6 */ 2938c2ecf20Sopenharmony_ci#define RHF_RCV_TYPE_ERROR 3 2948c2ecf20Sopenharmony_ci#define RHF_RCV_TYPE_BYPASS 4 2958c2ecf20Sopenharmony_ci#define RHF_RCV_TYPE_INVALID5 5 2968c2ecf20Sopenharmony_ci#define RHF_RCV_TYPE_INVALID6 6 2978c2ecf20Sopenharmony_ci#define RHF_RCV_TYPE_INVALID7 7 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci/* RHF receive type error - expected packet errors */ 3008c2ecf20Sopenharmony_ci#define RHF_RTE_EXPECTED_FLOW_SEQ_ERR 0x2 3018c2ecf20Sopenharmony_ci#define RHF_RTE_EXPECTED_FLOW_GEN_ERR 0x4 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ci/* RHF receive type error - eager packet errors */ 3048c2ecf20Sopenharmony_ci#define RHF_RTE_EAGER_NO_ERR 0x0 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci/* RHF receive type error - IB packet errors */ 3078c2ecf20Sopenharmony_ci#define RHF_RTE_IB_NO_ERR 0x0 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci/* RHF receive type error - error packet errors */ 3108c2ecf20Sopenharmony_ci#define RHF_RTE_ERROR_NO_ERR 0x0 3118c2ecf20Sopenharmony_ci#define RHF_RTE_ERROR_OP_CODE_ERR 0x1 3128c2ecf20Sopenharmony_ci#define RHF_RTE_ERROR_KHDR_MIN_LEN_ERR 0x2 3138c2ecf20Sopenharmony_ci#define RHF_RTE_ERROR_KHDR_HCRC_ERR 0x3 3148c2ecf20Sopenharmony_ci#define RHF_RTE_ERROR_KHDR_KVER_ERR 0x4 3158c2ecf20Sopenharmony_ci#define RHF_RTE_ERROR_CONTEXT_ERR 0x5 3168c2ecf20Sopenharmony_ci#define RHF_RTE_ERROR_KHDR_TID_ERR 0x6 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ci/* RHF receive type error - bypass packet errors */ 3198c2ecf20Sopenharmony_ci#define RHF_RTE_BYPASS_NO_ERR 0x0 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ci/* MAX RcvSEQ */ 3228c2ecf20Sopenharmony_ci#define RHF_MAX_SEQ 13 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_ci/* IB - LRH header constants */ 3258c2ecf20Sopenharmony_ci#define HFI1_LRH_GRH 0x0003 /* 1. word of IB LRH - next header: GRH */ 3268c2ecf20Sopenharmony_ci#define HFI1_LRH_BTH 0x0002 /* 1. word of IB LRH - next header: BTH */ 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci/* misc. */ 3298c2ecf20Sopenharmony_ci#define SC15_PACKET 0xF 3308c2ecf20Sopenharmony_ci#define SIZE_OF_CRC 1 3318c2ecf20Sopenharmony_ci#define SIZE_OF_LT 1 3328c2ecf20Sopenharmony_ci#define MAX_16B_PADDING 12 /* CRC = 4, LT = 1, Pad = 0 to 7 bytes */ 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ci#define LIM_MGMT_P_KEY 0x7FFF 3358c2ecf20Sopenharmony_ci#define FULL_MGMT_P_KEY 0xFFFF 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci#define DEFAULT_P_KEY LIM_MGMT_P_KEY 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ci#define HFI1_PSM_IOC_BASE_SEQ 0x0 3408c2ecf20Sopenharmony_ci 3418c2ecf20Sopenharmony_ci/* Number of BTH.PSN bits used for sequence number in expected rcvs */ 3428c2ecf20Sopenharmony_ci#define HFI1_KDETH_BTH_SEQ_SHIFT 11 3438c2ecf20Sopenharmony_ci#define HFI1_KDETH_BTH_SEQ_MASK (BIT(HFI1_KDETH_BTH_SEQ_SHIFT) - 1) 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_cistatic inline __u64 rhf_to_cpu(const __le32 *rbuf) 3468c2ecf20Sopenharmony_ci{ 3478c2ecf20Sopenharmony_ci return __le64_to_cpu(*((__le64 *)rbuf)); 3488c2ecf20Sopenharmony_ci} 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_cistatic inline u64 rhf_err_flags(u64 rhf) 3518c2ecf20Sopenharmony_ci{ 3528c2ecf20Sopenharmony_ci return rhf & RHF_ERROR_SMASK; 3538c2ecf20Sopenharmony_ci} 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_cistatic inline u32 rhf_rcv_type(u64 rhf) 3568c2ecf20Sopenharmony_ci{ 3578c2ecf20Sopenharmony_ci return (rhf >> RHF_RCV_TYPE_SHIFT) & RHF_RCV_TYPE_MASK; 3588c2ecf20Sopenharmony_ci} 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_cistatic inline u32 rhf_rcv_type_err(u64 rhf) 3618c2ecf20Sopenharmony_ci{ 3628c2ecf20Sopenharmony_ci return (rhf >> RHF_RCV_TYPE_ERR_SHIFT) & RHF_RCV_TYPE_ERR_MASK; 3638c2ecf20Sopenharmony_ci} 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_ci/* return size is in bytes, not DWORDs */ 3668c2ecf20Sopenharmony_cistatic inline u32 rhf_pkt_len(u64 rhf) 3678c2ecf20Sopenharmony_ci{ 3688c2ecf20Sopenharmony_ci return ((rhf & RHF_PKT_LEN_SMASK) >> RHF_PKT_LEN_SHIFT) << 2; 3698c2ecf20Sopenharmony_ci} 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_cistatic inline u32 rhf_egr_index(u64 rhf) 3728c2ecf20Sopenharmony_ci{ 3738c2ecf20Sopenharmony_ci return (rhf >> RHF_EGR_INDEX_SHIFT) & RHF_EGR_INDEX_MASK; 3748c2ecf20Sopenharmony_ci} 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_cistatic inline u32 rhf_rcv_seq(u64 rhf) 3778c2ecf20Sopenharmony_ci{ 3788c2ecf20Sopenharmony_ci return (rhf >> RHF_RCV_SEQ_SHIFT) & RHF_RCV_SEQ_MASK; 3798c2ecf20Sopenharmony_ci} 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ci/* returned offset is in DWORDS */ 3828c2ecf20Sopenharmony_cistatic inline u32 rhf_hdrq_offset(u64 rhf) 3838c2ecf20Sopenharmony_ci{ 3848c2ecf20Sopenharmony_ci return (rhf >> RHF_HDRQ_OFFSET_SHIFT) & RHF_HDRQ_OFFSET_MASK; 3858c2ecf20Sopenharmony_ci} 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_cistatic inline u64 rhf_use_egr_bfr(u64 rhf) 3888c2ecf20Sopenharmony_ci{ 3898c2ecf20Sopenharmony_ci return rhf & RHF_USE_EGR_BFR_SMASK; 3908c2ecf20Sopenharmony_ci} 3918c2ecf20Sopenharmony_ci 3928c2ecf20Sopenharmony_cistatic inline u64 rhf_dc_info(u64 rhf) 3938c2ecf20Sopenharmony_ci{ 3948c2ecf20Sopenharmony_ci return rhf & RHF_DC_INFO_SMASK; 3958c2ecf20Sopenharmony_ci} 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_cistatic inline u32 rhf_egr_buf_offset(u64 rhf) 3988c2ecf20Sopenharmony_ci{ 3998c2ecf20Sopenharmony_ci return (rhf >> RHF_EGR_OFFSET_SHIFT) & RHF_EGR_OFFSET_MASK; 4008c2ecf20Sopenharmony_ci} 4018c2ecf20Sopenharmony_ci#endif /* _COMMON_H */ 402