/*-1* SPDX-License-Identifier: BSD-2-Clause OR GPL-2.02*3* Copyright(c) 2016 Intel Corporation.4*5* This file is provided under a dual BSD/GPLv2 license. When using or6* redistributing this file, you may do so under either license.7*8* GPL LICENSE SUMMARY9*10* This program is free software; you can redistribute it and/or modify11* it under the terms of version 2 of the GNU General Public License as12* published by the Free Software Foundation.13*14* This program is distributed in the hope that it will be useful, but15* WITHOUT ANY WARRANTY; without even the implied warranty of16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU17* General Public License for more details.18*19* BSD LICENSE20*21* Redistribution and use in source and binary forms, with or without22* modification, are permitted provided that the following conditions23* are met:24*25* - Redistributions of source code must retain the above copyright26* notice, this list of conditions and the following disclaimer.27* - Redistributions in binary form must reproduce the above copyright28* notice, this list of conditions and the following disclaimer in29* the documentation and/or other materials provided with the30* distribution.31* - Neither the name of Intel Corporation nor the names of its32* contributors may be used to endorse or promote products derived33* from this software without specific prior written permission.34*35* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS36* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT37* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR38* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT39* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,40* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT41* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,42* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY43* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT44* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE45* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.46*/4748#ifndef IB_HDRS_H49#define IB_HDRS_H5051#include <linux/types.h>52#include <asm/unaligned.h>53#include <rdma/ib_verbs.h>5455#define IB_SEQ_NAK (3 << 29)5657/* AETH NAK opcode values */58#define IB_RNR_NAK 0x2059#define IB_NAK_PSN_ERROR 0x6060#define IB_NAK_INVALID_REQUEST 0x6161#define IB_NAK_REMOTE_ACCESS_ERROR 0x6262#define IB_NAK_REMOTE_OPERATIONAL_ERROR 0x6363#define IB_NAK_INVALID_RD_REQUEST 0x646465#define IB_BTH_REQ_ACK BIT(31)66#define IB_BTH_SOLICITED BIT(23)67#define IB_BTH_MIG_REQ BIT(22)6869#define IB_GRH_VERSION 670#define IB_GRH_VERSION_MASK 0xF71#define IB_GRH_VERSION_SHIFT 2872#define IB_GRH_TCLASS_MASK 0xFF73#define IB_GRH_TCLASS_SHIFT 2074#define IB_GRH_FLOW_MASK 0xFFFFF75#define IB_GRH_FLOW_SHIFT 076#define IB_GRH_NEXT_HDR 0x1B7778struct ib_reth {79__be64 vaddr; /* potentially unaligned */80__be32 rkey;81__be32 length;82} __packed;8384struct 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;9091union ib_ehdrs {92struct {93__be32 deth[2];94__be32 imm_data;95} ud;96struct {97struct ib_reth reth;98__be32 imm_data;99} rc;100struct {101__be32 aeth;102__be64 atomic_ack_eth; /* potentially unaligned */103} __packed at;104__be32 imm_data;105__be32 aeth;106__be32 ieth;107struct ib_atomic_eth atomic_eth;108} __packed;109110struct ib_other_headers {111__be32 bth[3];112union ib_ehdrs u;113} __packed;114115struct ib_header {116__be16 lrh[4];117union {118struct {119struct ib_grh grh;120struct ib_other_headers oth;121} l;122struct ib_other_headers oth;123} u;124} __packed;125126/* accessors for unaligned __be64 items */127128static inline u64 ib_u64_get(__be64 *p)129{130return get_unaligned_be64(p);131}132133static inline void ib_u64_put(u64 val, __be64 *p)134{135put_unaligned_be64(val, p);136}137138static inline u64 get_ib_reth_vaddr(struct ib_reth *reth)139{140return ib_u64_get(&reth->vaddr);141}142143static inline void put_ib_reth_vaddr(u64 val, struct ib_reth *reth)144{145ib_u64_put(val, &reth->vaddr);146}147148static inline u64 get_ib_ateth_vaddr(struct ib_atomic_eth *ateth)149{150return ib_u64_get(&ateth->vaddr);151}152153static inline void put_ib_ateth_vaddr(u64 val, struct ib_atomic_eth *ateth)154{155ib_u64_put(val, &ateth->vaddr);156}157158static inline u64 get_ib_ateth_swap(struct ib_atomic_eth *ateth)159{160return ib_u64_get(&ateth->swap_data);161}162163static inline void put_ib_ateth_swap(u64 val, struct ib_atomic_eth *ateth)164{165ib_u64_put(val, &ateth->swap_data);166}167168static inline u64 get_ib_ateth_compare(struct ib_atomic_eth *ateth)169{170return ib_u64_get(&ateth->compare_data);171}172173static inline void put_ib_ateth_compare(u64 val, struct ib_atomic_eth *ateth)174{175ib_u64_put(val, &ateth->compare_data);176}177178#endif /* IB_HDRS_H */179180181