diff options
| author | Mike Marciniszyn <mike.marciniszyn@intel.com> | 2016-09-06 07:34:49 -0400 |
|---|---|---|
| committer | Doug Ledford <dledford@redhat.com> | 2016-10-02 08:40:35 -0400 |
| commit | 7368ef023515ce5affb44fa3fd4935c70e6a573f (patch) | |
| tree | d052bce89ea979b6429b15dec9cf6758fec247d6 /include/rdma | |
| parent | 4d6f85c3fa55e00ebde75a74b070f2ed4b93e869 (diff) | |
IB/core: Add ib headers for general use
Add IB headers, defines, and accessors that are identical
in both qib and hfi1 into the core includes.
The accessors for be maintenance of __be64 fields since
alignment is potentially invalid and can differ based on
the presense of the GRH.
{hfi1,qib}_ib_headers will be ib_headers.
{hfi1,qib|_other_headers will be ib_other_headers.
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: Don Hiatt <don.hiatt@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'include/rdma')
| -rw-r--r-- | include/rdma/ib_hdrs.h | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/include/rdma/ib_hdrs.h b/include/rdma/ib_hdrs.h new file mode 100644 index 000000000000..408439fe911e --- /dev/null +++ b/include/rdma/ib_hdrs.h | |||
| @@ -0,0 +1,178 @@ | |||
| 1 | /* | ||
| 2 | * Copyright(c) 2016 Intel Corporation. | ||
| 3 | * | ||
| 4 | * This file is provided under a dual BSD/GPLv2 license. When using or | ||
| 5 | * redistributing this file, you may do so under either license. | ||
| 6 | * | ||
| 7 | * GPL LICENSE SUMMARY | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of version 2 of the GNU General Public License as | ||
| 11 | * published by the Free Software Foundation. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, but | ||
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 16 | * General Public License for more details. | ||
| 17 | * | ||
| 18 | * BSD LICENSE | ||
| 19 | * | ||
| 20 | * Redistribution and use in source and binary forms, with or without | ||
| 21 | * modification, are permitted provided that the following conditions | ||
| 22 | * are met: | ||
| 23 | * | ||
| 24 | * - Redistributions of source code must retain the above copyright | ||
| 25 | * notice, this list of conditions and the following disclaimer. | ||
| 26 | * - Redistributions in binary form must reproduce the above copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer in | ||
| 28 | * the documentation and/or other materials provided with the | ||
| 29 | * distribution. | ||
| 30 | * - Neither the name of Intel Corporation nor the names of its | ||
| 31 | * contributors may be used to endorse or promote products derived | ||
| 32 | * from this software without specific prior written permission. | ||
| 33 | * | ||
| 34 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 35 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| 37 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| 38 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 39 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| 40 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| 41 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| 42 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 43 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| 44 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 45 | * | ||
| 46 | */ | ||
| 47 | |||
| 48 | #ifndef IB_HDRS_H | ||
| 49 | #define IB_HDRS_H | ||
| 50 | |||
| 51 | #include <linux/types.h> | ||
| 52 | #include <asm/unaligned.h> | ||
| 53 | #include <rdma/ib_verbs.h> | ||
| 54 | |||
| 55 | #define IB_SEQ_NAK (3 << 29) | ||
| 56 | |||
| 57 | /* AETH NAK opcode values */ | ||
| 58 | #define IB_RNR_NAK 0x20 | ||
| 59 | #define IB_NAK_PSN_ERROR 0x60 | ||
| 60 | #define IB_NAK_INVALID_REQUEST 0x61 | ||
| 61 | #define IB_NAK_REMOTE_ACCESS_ERROR 0x62 | ||
| 62 | #define IB_NAK_REMOTE_OPERATIONAL_ERROR 0x63 | ||
| 63 | #define IB_NAK_INVALID_RD_REQUEST 0x64 | ||
| 64 | |||
| 65 | #define IB_BTH_REQ_ACK BIT(31) | ||
| 66 | #define IB_BTH_SOLICITED BIT(23) | ||
| 67 | #define IB_BTH_MIG_REQ BIT(22) | ||
| 68 | |||
| 69 | #define IB_GRH_VERSION 6 | ||
| 70 | #define IB_GRH_VERSION_MASK 0xF | ||
| 71 | #define IB_GRH_VERSION_SHIFT 28 | ||
| 72 | #define IB_GRH_TCLASS_MASK 0xFF | ||
| 73 | #define IB_GRH_TCLASS_SHIFT 20 | ||
| 74 | #define IB_GRH_FLOW_MASK 0xFFFFF | ||
| 75 | #define IB_GRH_FLOW_SHIFT 0 | ||
| 76 | #define IB_GRH_NEXT_HDR 0x1B | ||
| 77 | |||
| 78 | struct ib_reth { | ||
| 79 | __be64 vaddr; /* potentially unaligned */ | ||
| 80 | __be32 rkey; | ||
| 81 | __be32 length; | ||
| 82 | } __packed; | ||
| 83 | |||
| 84 | struct ib_atomic_eth { | ||
| 85 | __be64 vaddr; /* potentially unaligned */ | ||
| 86 | __be32 rkey; | ||
| 87 | __be64 swap_data; /* potentially unaligned */ | ||
| 88 | __be64 compare_data; /* potentially unaligned */ | ||
| 89 | } __packed; | ||
| 90 | |||
| 91 | union ib_ehdrs { | ||
| 92 | struct { | ||
| 93 | __be32 deth[2]; | ||
| 94 | __be32 imm_data; | ||
| 95 | } ud; | ||
| 96 | struct { | ||
| 97 | struct ib_reth reth; | ||
| 98 | __be32 imm_data; | ||
| 99 | } rc; | ||
| 100 | struct { | ||
| 101 | __be32 aeth; | ||
| 102 | __be64 atomic_ack_eth; /* potentially unaligned */ | ||
| 103 | } __packed at; | ||
| 104 | __be32 imm_data; | ||
| 105 | __be32 aeth; | ||
| 106 | __be32 ieth; | ||
| 107 | struct ib_atomic_eth atomic_eth; | ||
| 108 | } __packed; | ||
| 109 | |||
| 110 | struct ib_other_headers { | ||
| 111 | __be32 bth[3]; | ||
| 112 | union ib_ehdrs u; | ||
| 113 | } __packed; | ||
| 114 | |||
| 115 | struct ib_header { | ||
| 116 | __be16 lrh[4]; | ||
| 117 | union { | ||
| 118 | struct { | ||
| 119 | struct ib_grh grh; | ||
| 120 | struct ib_other_headers oth; | ||
| 121 | } l; | ||
| 122 | struct ib_other_headers oth; | ||
| 123 | } u; | ||
| 124 | } __packed; | ||
| 125 | |||
| 126 | /* accessors for unaligned __be64 items */ | ||
| 127 | |||
| 128 | static inline u64 ib_u64_get(__be64 *p) | ||
| 129 | { | ||
| 130 | return get_unaligned_be64(p); | ||
| 131 | } | ||
| 132 | |||
| 133 | static inline void ib_u64_put(u64 val, __be64 *p) | ||
| 134 | { | ||
| 135 | put_unaligned_be64(val, p); | ||
| 136 | } | ||
| 137 | |||
| 138 | static inline u64 get_ib_reth_vaddr(struct ib_reth *reth) | ||
| 139 | { | ||
| 140 | return ib_u64_get(&reth->vaddr); | ||
| 141 | } | ||
| 142 | |||
| 143 | static inline void put_ib_reth_vaddr(u64 val, struct ib_reth *reth) | ||
| 144 | { | ||
| 145 | ib_u64_put(val, &reth->vaddr); | ||
| 146 | } | ||
| 147 | |||
| 148 | static inline u64 get_ib_ateth_vaddr(struct ib_atomic_eth *ateth) | ||
| 149 | { | ||
| 150 | return ib_u64_get(&ateth->vaddr); | ||
| 151 | } | ||
| 152 | |||
| 153 | static inline void put_ib_ateth_vaddr(u64 val, struct ib_atomic_eth *ateth) | ||
| 154 | { | ||
| 155 | ib_u64_put(val, &ateth->vaddr); | ||
| 156 | } | ||
| 157 | |||
| 158 | static inline u64 get_ib_ateth_swap(struct ib_atomic_eth *ateth) | ||
| 159 | { | ||
| 160 | return ib_u64_get(&ateth->swap_data); | ||
| 161 | } | ||
| 162 | |||
| 163 | static inline void put_ib_ateth_swap(u64 val, struct ib_atomic_eth *ateth) | ||
| 164 | { | ||
| 165 | ib_u64_put(val, &ateth->swap_data); | ||
| 166 | } | ||
| 167 | |||
| 168 | static inline u64 get_ib_ateth_compare(struct ib_atomic_eth *ateth) | ||
| 169 | { | ||
| 170 | return ib_u64_get(&ateth->compare_data); | ||
| 171 | } | ||
| 172 | |||
| 173 | static inline void put_ib_ateth_compare(u64 val, struct ib_atomic_eth *ateth) | ||
| 174 | { | ||
| 175 | ib_u64_put(val, &ateth->compare_data); | ||
| 176 | } | ||
| 177 | |||
| 178 | #endif /* IB_HDRS_H */ | ||
