Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright(c) 2016 - 2018 Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #ifndef IB_HDRS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define IB_HDRS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <rdma/ib_verbs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #define IB_SEQ_NAK	(3 << 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) /* AETH NAK opcode values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #define IB_RNR_NAK                      0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define IB_NAK_PSN_ERROR                0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define IB_NAK_INVALID_REQUEST          0x61
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #define IB_NAK_REMOTE_ACCESS_ERROR      0x62
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define IB_NAK_REMOTE_OPERATIONAL_ERROR 0x63
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define IB_NAK_INVALID_RD_REQUEST       0x64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define IB_BTH_REQ_ACK		BIT(31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define IB_BTH_SOLICITED	BIT(23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define IB_BTH_MIG_REQ		BIT(22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define IB_GRH_VERSION		6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define IB_GRH_VERSION_MASK	0xF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define IB_GRH_VERSION_SHIFT	28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define IB_GRH_TCLASS_MASK	0xFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define IB_GRH_TCLASS_SHIFT	20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define IB_GRH_FLOW_MASK	0xFFFFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define IB_GRH_FLOW_SHIFT	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define IB_GRH_NEXT_HDR		0x1B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define IB_FECN_SHIFT 31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define IB_FECN_MASK 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define IB_FECN_SMASK BIT(IB_FECN_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define IB_BECN_SHIFT 30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define IB_BECN_MASK 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define IB_BECN_SMASK BIT(IB_BECN_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define IB_AETH_CREDIT_SHIFT	24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define IB_AETH_CREDIT_MASK	0x1F
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define IB_AETH_CREDIT_INVAL	0x1F
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define IB_AETH_NAK_SHIFT	29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define IB_MSN_MASK		0xFFFFFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) struct ib_reth {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	__be64 vaddr;        /* potentially unaligned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	__be32 rkey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	__be32 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) struct ib_atomic_eth {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	__be64 vaddr;        /* potentially unaligned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	__be32 rkey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	__be64 swap_data;    /* potentially unaligned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	__be64 compare_data; /* potentially unaligned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #include <rdma/tid_rdma_defs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) union ib_ehdrs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		__be32 deth[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		__be32 imm_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	} ud;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		struct ib_reth reth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		__be32 imm_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	} rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		__be32 aeth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		__be64 atomic_ack_eth; /* potentially unaligned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	} __packed at;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	__be32 imm_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	__be32 aeth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	__be32 ieth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	struct ib_atomic_eth atomic_eth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	/* TID RDMA headers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		struct tid_rdma_read_req r_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		struct tid_rdma_read_resp r_rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		struct tid_rdma_write_req w_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		struct tid_rdma_write_resp w_rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		struct tid_rdma_write_data w_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		struct tid_rdma_resync resync;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		struct tid_rdma_ack ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	} tid_rdma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) }  __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) struct ib_other_headers {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	__be32 bth[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	union ib_ehdrs u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) struct ib_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	__be16 lrh[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			struct ib_grh grh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			struct ib_other_headers oth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		} l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		struct ib_other_headers oth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	} u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /* accessors for unaligned __be64 items */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static inline u64 ib_u64_get(__be64 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	return get_unaligned_be64(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static inline void ib_u64_put(u64 val, __be64 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	put_unaligned_be64(val, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static inline u64 get_ib_reth_vaddr(struct ib_reth *reth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	return ib_u64_get(&reth->vaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static inline void put_ib_reth_vaddr(u64 val, struct ib_reth *reth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	ib_u64_put(val, &reth->vaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static inline u64 get_ib_ateth_vaddr(struct ib_atomic_eth *ateth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	return ib_u64_get(&ateth->vaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static inline void put_ib_ateth_vaddr(u64 val, struct ib_atomic_eth *ateth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	ib_u64_put(val, &ateth->vaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static inline u64 get_ib_ateth_swap(struct ib_atomic_eth *ateth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	return ib_u64_get(&ateth->swap_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static inline void put_ib_ateth_swap(u64 val, struct ib_atomic_eth *ateth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	ib_u64_put(val, &ateth->swap_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) static inline u64 get_ib_ateth_compare(struct ib_atomic_eth *ateth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	return ib_u64_get(&ateth->compare_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) static inline void put_ib_ateth_compare(u64 val, struct ib_atomic_eth *ateth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	ib_u64_put(val, &ateth->compare_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * 9B/IB Packet Format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #define IB_LNH_MASK		3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) #define IB_SC_MASK		0xf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #define IB_SC_SHIFT		12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) #define IB_SC5_MASK		0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) #define IB_SL_MASK		0xf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) #define IB_SL_SHIFT		4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) #define IB_SL_SHIFT		4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) #define IB_LVER_MASK	0xf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) #define IB_LVER_SHIFT	8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) static inline u8 ib_get_lnh(struct ib_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	return (be16_to_cpu(hdr->lrh[0]) & IB_LNH_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static inline u8 ib_get_sc(struct ib_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	return ((be16_to_cpu(hdr->lrh[0]) >> IB_SC_SHIFT) & IB_SC_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) static inline bool ib_is_sc5(u16 sc5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	return !!(sc5 & IB_SC5_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) static inline u8 ib_get_sl(struct ib_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	return ((be16_to_cpu(hdr->lrh[0]) >> IB_SL_SHIFT) & IB_SL_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static inline u16 ib_get_dlid(struct ib_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	return (be16_to_cpu(hdr->lrh[1]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) static inline u16 ib_get_slid(struct ib_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	return (be16_to_cpu(hdr->lrh[3]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) static inline u8 ib_get_lver(struct ib_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	return (u8)((be16_to_cpu(hdr->lrh[0]) >> IB_LVER_SHIFT) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		   IB_LVER_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) static inline u16 ib_get_len(struct ib_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	return (u16)(be16_to_cpu(hdr->lrh[2]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) static inline u32 ib_get_qkey(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	return be32_to_cpu(ohdr->u.ud.deth[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static inline u32 ib_get_sqpn(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	return ((be32_to_cpu(ohdr->u.ud.deth[1])) & IB_QPN_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  * BTH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) #define IB_BTH_OPCODE_MASK	0xff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) #define IB_BTH_OPCODE_SHIFT	24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) #define IB_BTH_PAD_MASK	3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) #define IB_BTH_PKEY_MASK	0xffff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) #define IB_BTH_PAD_SHIFT	20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) #define IB_BTH_A_MASK		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) #define IB_BTH_A_SHIFT		31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) #define IB_BTH_M_MASK		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) #define IB_BTH_M_SHIFT		22
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) #define IB_BTH_SE_MASK		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) #define IB_BTH_SE_SHIFT	23
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) #define IB_BTH_TVER_MASK	0xf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) #define IB_BTH_TVER_SHIFT	16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) static inline u8 ib_bth_get_pad(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	return ((be32_to_cpu(ohdr->bth[0]) >> IB_BTH_PAD_SHIFT) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		   IB_BTH_PAD_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) static inline u16 ib_bth_get_pkey(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	return (be32_to_cpu(ohdr->bth[0]) & IB_BTH_PKEY_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) static inline u8 ib_bth_get_opcode(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	return ((be32_to_cpu(ohdr->bth[0]) >> IB_BTH_OPCODE_SHIFT) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		   IB_BTH_OPCODE_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) static inline u8 ib_bth_get_ackreq(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	return (u8)((be32_to_cpu(ohdr->bth[2]) >> IB_BTH_A_SHIFT) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		   IB_BTH_A_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) static inline u8 ib_bth_get_migreq(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	return (u8)((be32_to_cpu(ohdr->bth[0]) >> IB_BTH_M_SHIFT) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		    IB_BTH_M_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) static inline u8 ib_bth_get_se(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	return (u8)((be32_to_cpu(ohdr->bth[0]) >> IB_BTH_SE_SHIFT) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		    IB_BTH_SE_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) static inline u32 ib_bth_get_psn(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	return (u32)(be32_to_cpu(ohdr->bth[2]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) static inline u32 ib_bth_get_qpn(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	return (u32)((be32_to_cpu(ohdr->bth[1])) & IB_QPN_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) static inline bool ib_bth_get_becn(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	return (ohdr->bth[1]) & cpu_to_be32(IB_BECN_SMASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) static inline bool ib_bth_get_fecn(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	return (ohdr->bth[1]) & cpu_to_be32(IB_FECN_SMASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) static inline u8 ib_bth_get_tver(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	return (u8)((be32_to_cpu(ohdr->bth[0]) >> IB_BTH_TVER_SHIFT)  &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		    IB_BTH_TVER_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) static inline bool ib_bth_is_solicited(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	return ohdr->bth[0] & cpu_to_be32(IB_BTH_SOLICITED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) static inline bool ib_bth_is_migration(struct ib_other_headers *ohdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	return ohdr->bth[0] & cpu_to_be32(IB_BTH_MIG_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) #endif                          /* IB_HDRS_H */