39 #define T4_MAX_NUM_QP (1<<16)
40 #define T4_MAX_NUM_CQ (1<<15)
41 #define T4_MAX_NUM_PD (1<<15)
42 #define T4_EQ_STATUS_ENTRIES (L1_CACHE_BYTES > 64 ? 2 : 1)
43 #define T4_MAX_EQ_SIZE (65520 - T4_EQ_STATUS_ENTRIES)
44 #define T4_MAX_IQ_SIZE (65520 - 1)
45 #define T4_MAX_RQ_SIZE (8192 - T4_EQ_STATUS_ENTRIES)
46 #define T4_MAX_SQ_SIZE (T4_MAX_EQ_SIZE - 1)
47 #define T4_MAX_QP_DEPTH (T4_MAX_RQ_SIZE - 1)
48 #define T4_MAX_CQ_DEPTH (T4_MAX_IQ_SIZE - 1)
49 #define T4_MAX_NUM_STAG (1<<15)
50 #define T4_MAX_MR_SIZE (~0ULL - 1)
51 #define T4_PAGESIZE_MASK 0xffff000
52 #define T4_STAG_UNSET 0xffffffff
54 #define T4_EQ_STATUS_ENTRIES (L1_CACHE_BYTES > 64 ? 2 : 1)
55 #define A_PCIE_MA_SYNC 0x30b4
71 #define T4_EQ_ENTRY_SIZE 64
73 #define T4_SQ_NUM_SLOTS 5
74 #define T4_SQ_NUM_BYTES (T4_EQ_ENTRY_SIZE * T4_SQ_NUM_SLOTS)
75 #define T4_MAX_SEND_SGE ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_send_wr) - \
76 sizeof(struct fw_ri_isgl)) / sizeof(struct fw_ri_sge))
77 #define T4_MAX_SEND_INLINE ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_send_wr) - \
78 sizeof(struct fw_ri_immd)))
79 #define T4_MAX_WRITE_INLINE ((T4_SQ_NUM_BYTES - \
80 sizeof(struct fw_ri_rdma_write_wr) - \
81 sizeof(struct fw_ri_immd)))
82 #define T4_MAX_WRITE_SGE ((T4_SQ_NUM_BYTES - \
83 sizeof(struct fw_ri_rdma_write_wr) - \
84 sizeof(struct fw_ri_isgl)) / sizeof(struct fw_ri_sge))
85 #define T4_MAX_FR_IMMD ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_fr_nsmr_wr) - \
86 sizeof(struct fw_ri_immd)) & ~31UL)
87 #define T4_MAX_FR_DEPTH (T4_MAX_FR_IMMD / sizeof(u64))
89 #define T4_RQ_NUM_SLOTS 2
90 #define T4_RQ_NUM_BYTES (T4_EQ_ENTRY_SIZE * T4_RQ_NUM_SLOTS)
91 #define T4_MAX_RECV_SGE 4
112 static inline void init_wr_hdr(
union t4_wr *wqe,
u16 wrid,
115 wqe->
send.opcode = (
u8)opcode;
117 wqe->
send.wrid = wrid;
121 wqe->
send.len16 = len16;
125 #define T4_ERR_SUCCESS 0x0
126 #define T4_ERR_STAG 0x1
129 #define T4_ERR_PDID 0x2
130 #define T4_ERR_QPID 0x3
131 #define T4_ERR_ACCESS 0x4
132 #define T4_ERR_WRAP 0x5
133 #define T4_ERR_BOUND 0x6
134 #define T4_ERR_INVALIDATE_SHARED_MR 0x7
136 #define T4_ERR_INVALIDATE_MR_WITH_MW_BOUND 0x8
138 #define T4_ERR_ECC 0x9
139 #define T4_ERR_ECC_PSTAG 0xA
142 #define T4_ERR_PBL_ADDR_BOUND 0xB
144 #define T4_ERR_SWFLUSH 0xC
145 #define T4_ERR_CRC 0x10
146 #define T4_ERR_MARKER 0x11
147 #define T4_ERR_PDU_LEN_ERR 0x12
148 #define T4_ERR_OUT_OF_RQE 0x13
149 #define T4_ERR_DDP_VERSION 0x14
150 #define T4_ERR_RDMA_VERSION 0x15
151 #define T4_ERR_OPCODE 0x16
152 #define T4_ERR_DDP_QUEUE_NUM 0x17
153 #define T4_ERR_MSN 0x18
154 #define T4_ERR_TBIT 0x19
155 #define T4_ERR_MO 0x1A
157 #define T4_ERR_MSN_GAP 0x1B
158 #define T4_ERR_MSN_RANGE 0x1C
159 #define T4_ERR_IRD_OVERFLOW 0x1D
160 #define T4_ERR_RQE_ADDR_BOUND 0x1E
162 #define T4_ERR_INTERNAL_ERR 0x1F
191 #define S_CQE_QPID 12
192 #define M_CQE_QPID 0xFFFFF
193 #define G_CQE_QPID(x) ((((x) >> S_CQE_QPID)) & M_CQE_QPID)
194 #define V_CQE_QPID(x) ((x)<<S_CQE_QPID)
196 #define S_CQE_SWCQE 11
197 #define M_CQE_SWCQE 0x1
198 #define G_CQE_SWCQE(x) ((((x) >> S_CQE_SWCQE)) & M_CQE_SWCQE)
199 #define V_CQE_SWCQE(x) ((x)<<S_CQE_SWCQE)
201 #define S_CQE_STATUS 5
202 #define M_CQE_STATUS 0x1F
203 #define G_CQE_STATUS(x) ((((x) >> S_CQE_STATUS)) & M_CQE_STATUS)
204 #define V_CQE_STATUS(x) ((x)<<S_CQE_STATUS)
207 #define M_CQE_TYPE 0x1
208 #define G_CQE_TYPE(x) ((((x) >> S_CQE_TYPE)) & M_CQE_TYPE)
209 #define V_CQE_TYPE(x) ((x)<<S_CQE_TYPE)
211 #define S_CQE_OPCODE 0
212 #define M_CQE_OPCODE 0xF
213 #define G_CQE_OPCODE(x) ((((x) >> S_CQE_OPCODE)) & M_CQE_OPCODE)
214 #define V_CQE_OPCODE(x) ((x)<<S_CQE_OPCODE)
216 #define SW_CQE(x) (G_CQE_SWCQE(be32_to_cpu((x)->header)))
217 #define CQE_QPID(x) (G_CQE_QPID(be32_to_cpu((x)->header)))
218 #define CQE_TYPE(x) (G_CQE_TYPE(be32_to_cpu((x)->header)))
219 #define SQ_TYPE(x) (CQE_TYPE((x)))
220 #define RQ_TYPE(x) (!CQE_TYPE((x)))
221 #define CQE_STATUS(x) (G_CQE_STATUS(be32_to_cpu((x)->header)))
222 #define CQE_OPCODE(x) (G_CQE_OPCODE(be32_to_cpu((x)->header)))
224 #define CQE_SEND_OPCODE(x)( \
225 (G_CQE_OPCODE(be32_to_cpu((x)->header)) == FW_RI_SEND) || \
226 (G_CQE_OPCODE(be32_to_cpu((x)->header)) == FW_RI_SEND_WITH_SE) || \
227 (G_CQE_OPCODE(be32_to_cpu((x)->header)) == FW_RI_SEND_WITH_INV) || \
228 (G_CQE_OPCODE(be32_to_cpu((x)->header)) == FW_RI_SEND_WITH_SE_INV))
230 #define CQE_LEN(x) (be32_to_cpu((x)->len))
233 #define CQE_WRID_STAG(x) (be32_to_cpu((x)->u.rcqe.stag))
234 #define CQE_WRID_MSN(x) (be32_to_cpu((x)->u.rcqe.msn))
237 #define CQE_WRID_SQ_IDX(x) ((x)->u.scqe.cidx)
240 #define CQE_WRID_HI(x) ((x)->u.gen.wrid_hi)
241 #define CQE_WRID_LOW(x) ((x)->u.gen.wrid_low)
244 #define S_CQE_GENBIT 63
245 #define M_CQE_GENBIT 0x1
246 #define G_CQE_GENBIT(x) (((x) >> S_CQE_GENBIT) & M_CQE_GENBIT)
247 #define V_CQE_GENBIT(x) ((x)<<S_CQE_GENBIT)
249 #define S_CQE_OVFBIT 62
250 #define M_CQE_OVFBIT 0x1
251 #define G_CQE_OVFBIT(x) ((((x) >> S_CQE_OVFBIT)) & M_CQE_OVFBIT)
253 #define S_CQE_IQTYPE 60
254 #define M_CQE_IQTYPE 0x3
255 #define G_CQE_IQTYPE(x) ((((x) >> S_CQE_IQTYPE)) & M_CQE_IQTYPE)
257 #define M_CQE_TS 0x0fffffffffffffffULL
258 #define G_CQE_TS(x) ((x) & M_CQE_TS)
260 #define CQE_OVFBIT(x) ((unsigned)G_CQE_OVFBIT(be64_to_cpu((x)->bits_type_ts)))
261 #define CQE_GENBIT(x) ((unsigned)G_CQE_GENBIT(be64_to_cpu((x)->bits_type_ts)))
262 #define CQE_TS(x) (G_CQE_TS(be64_to_cpu((x)->bits_type_ts)))
276 #if defined(__i386__) || defined(__x86_64__) || defined(CONFIG_PPC64)
283 static inline int t4_ocqp_supported(
void)
285 #if defined(__i386__) || defined(__x86_64__) || defined(CONFIG_PPC64)
344 static inline int t4_rqes_posted(
struct t4_wq *wq)
346 return wq->
rq.in_use;
349 static inline int t4_rq_empty(
struct t4_wq *wq)
351 return wq->
rq.in_use == 0;
354 static inline int t4_rq_full(
struct t4_wq *wq)
356 return wq->
rq.in_use == (wq->
rq.size - 1);
359 static inline u32 t4_rq_avail(
struct t4_wq *wq)
361 return wq->
rq.size - 1 - wq->
rq.in_use;
364 static inline void t4_rq_produce(
struct t4_wq *wq,
u8 len16)
367 if (++wq->
rq.pidx == wq->
rq.size)
374 static inline void t4_rq_consume(
struct t4_wq *wq)
378 if (++wq->
rq.cidx == wq->
rq.size)
382 static inline u16 t4_rq_host_wq_pidx(
struct t4_wq *wq)
384 return wq->
rq.queue[wq->
rq.size].status.host_wq_pidx;
387 static inline u16 t4_rq_wq_size(
struct t4_wq *wq)
392 static inline int t4_sq_onchip(
struct t4_sq *sq)
397 static inline int t4_sq_empty(
struct t4_wq *wq)
399 return wq->
sq.in_use == 0;
402 static inline int t4_sq_full(
struct t4_wq *wq)
404 return wq->
sq.in_use == (wq->
sq.size - 1);
407 static inline u32 t4_sq_avail(
struct t4_wq *wq)
409 return wq->
sq.size - 1 - wq->
sq.in_use;
412 static inline void t4_sq_produce(
struct t4_wq *wq,
u8 len16)
415 if (++wq->
sq.pidx == wq->
sq.size)
422 static inline void t4_sq_consume(
struct t4_wq *wq)
425 if (++wq->
sq.cidx == wq->
sq.size)
429 static inline u16 t4_sq_host_wq_pidx(
struct t4_wq *wq)
431 return wq->
sq.queue[wq->
sq.size].status.host_wq_pidx;
434 static inline u16 t4_sq_wq_size(
struct t4_wq *wq)
439 static inline void t4_ring_sq_db(
struct t4_wq *wq,
u16 inc)
445 static inline void t4_ring_rq_db(
struct t4_wq *wq,
u16 inc)
451 static inline int t4_wq_in_error(
struct t4_wq *wq)
453 return wq->
rq.queue[wq->
rq.size].status.qp_err;
456 static inline void t4_set_wq_in_error(
struct t4_wq *wq)
458 wq->
rq.queue[wq->
rq.size].status.qp_err = 1;
461 static inline void t4_disable_wq_db(
struct t4_wq *wq)
463 wq->
rq.queue[wq->
rq.size].status.db_off = 1;
466 static inline void t4_enable_wq_db(
struct t4_wq *wq)
468 wq->
rq.queue[wq->
rq.size].status.db_off = 0;
471 static inline int t4_wq_db_enabled(
struct t4_wq *wq)
473 return !wq->
rq.queue[wq->
rq.size].status.db_off;
497 static inline int t4_arm_cq(
struct t4_cq *cq,
int se)
514 static inline void t4_swcq_produce(
struct t4_cq *cq)
521 static inline void t4_swcq_consume(
struct t4_cq *cq)
528 static inline void t4_hwcq_consume(
struct t4_cq *cq)
545 static inline int t4_valid_cqe(
struct t4_cq *cq,
struct t4_cqe *
cqe)
550 static inline int t4_next_hw_cqe(
struct t4_cq *cq,
struct t4_cqe **cqe)
556 prev_cidx = cq->
size - 1;
558 prev_cidx = cq->
cidx - 1;
564 }
else if (t4_valid_cqe(cq, &cq->
queue[cq->
cidx])) {
572 static inline struct t4_cqe *t4_next_sw_cqe(
struct t4_cq *cq)
579 static inline int t4_next_cqe(
struct t4_cq *cq,
struct t4_cqe **cqe)
588 ret = t4_next_hw_cqe(cq, cqe);
592 static inline int t4_cq_in_error(
struct t4_cq *cq)
597 static inline void t4_set_cq_in_error(
struct t4_cq *cq)