0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #ifndef QIB_VERBS_H
0036 #define QIB_VERBS_H
0037
0038 #include <linux/types.h>
0039 #include <linux/spinlock.h>
0040 #include <linux/kernel.h>
0041 #include <linux/interrupt.h>
0042 #include <linux/kref.h>
0043 #include <linux/workqueue.h>
0044 #include <linux/kthread.h>
0045 #include <linux/completion.h>
0046 #include <rdma/ib_pack.h>
0047 #include <rdma/ib_user_verbs.h>
0048 #include <rdma/ib_hdrs.h>
0049 #include <rdma/rdmavt_qp.h>
0050 #include <rdma/rdmavt_cq.h>
0051
0052 struct qib_ctxtdata;
0053 struct qib_pportdata;
0054 struct qib_devdata;
0055 struct qib_verbs_txreq;
0056
0057 #define QIB_MAX_RDMA_ATOMIC 16
0058 #define QIB_GUIDS_PER_PORT 5
0059 #define QIB_PSN_SHIFT 8
0060
0061
0062
0063
0064
0065 #define QIB_UVERBS_ABI_VERSION 2
0066
0067
0068 #define IB_PMA_SAMPLE_STATUS_DONE 0x00
0069 #define IB_PMA_SAMPLE_STATUS_STARTED 0x01
0070 #define IB_PMA_SAMPLE_STATUS_RUNNING 0x02
0071
0072
0073 #define IB_PMA_PORT_XMIT_DATA cpu_to_be16(0x0001)
0074 #define IB_PMA_PORT_RCV_DATA cpu_to_be16(0x0002)
0075 #define IB_PMA_PORT_XMIT_PKTS cpu_to_be16(0x0003)
0076 #define IB_PMA_PORT_RCV_PKTS cpu_to_be16(0x0004)
0077 #define IB_PMA_PORT_XMIT_WAIT cpu_to_be16(0x0005)
0078
0079 #define QIB_VENDOR_IPG cpu_to_be16(0xFFA0)
0080
0081 #define IB_DEFAULT_GID_PREFIX cpu_to_be64(0xfe80000000000000ULL)
0082
0083
0084 #define IB_VL_VL0 1
0085 #define IB_VL_VL0_1 2
0086 #define IB_VL_VL0_3 3
0087 #define IB_VL_VL0_7 4
0088 #define IB_VL_VL0_14 5
0089
0090 static inline int qib_num_vls(int vls)
0091 {
0092 switch (vls) {
0093 default:
0094 case IB_VL_VL0:
0095 return 1;
0096 case IB_VL_VL0_1:
0097 return 2;
0098 case IB_VL_VL0_3:
0099 return 4;
0100 case IB_VL_VL0_7:
0101 return 8;
0102 case IB_VL_VL0_14:
0103 return 15;
0104 }
0105 }
0106
0107 struct qib_pio_header {
0108 __le32 pbc[2];
0109 struct ib_header hdr;
0110 } __packed;
0111
0112
0113
0114
0115
0116 struct qib_qp_priv {
0117 struct ib_header *s_hdr;
0118 struct list_head iowait;
0119 atomic_t s_dma_busy;
0120 struct qib_verbs_txreq *s_tx;
0121 struct work_struct s_work;
0122 wait_queue_head_t wait_dma;
0123 struct rvt_qp *owner;
0124 };
0125
0126 #define QIB_PSN_CREDIT 16
0127
0128 struct qib_opcode_stats {
0129 u64 n_packets;
0130 u64 n_bytes;
0131 };
0132
0133 struct qib_opcode_stats_perctx {
0134 struct qib_opcode_stats stats[128];
0135 };
0136
0137 struct qib_pma_counters {
0138 u64 n_unicast_xmit;
0139 u64 n_unicast_rcv;
0140 u64 n_multicast_xmit;
0141 u64 n_multicast_rcv;
0142 };
0143
0144 struct qib_ibport {
0145 struct rvt_ibport rvp;
0146 struct rvt_ah *smi_ah;
0147 __be64 guids[QIB_GUIDS_PER_PORT - 1];
0148 struct qib_pma_counters __percpu *pmastats;
0149 u64 z_unicast_xmit;
0150 u64 z_unicast_rcv;
0151 u64 z_multicast_xmit;
0152 u64 z_multicast_rcv;
0153 u64 z_symbol_error_counter;
0154 u64 z_link_error_recovery_counter;
0155 u64 z_link_downed_counter;
0156 u64 z_port_rcv_errors;
0157 u64 z_port_rcv_remphys_errors;
0158 u64 z_port_xmit_discards;
0159 u64 z_port_xmit_data;
0160 u64 z_port_rcv_data;
0161 u64 z_port_xmit_packets;
0162 u64 z_port_rcv_packets;
0163 u32 z_local_link_integrity_errors;
0164 u32 z_excessive_buffer_overrun_errors;
0165 u32 z_vl15_dropped;
0166 u8 sl_to_vl[16];
0167 };
0168
0169 struct qib_ibdev {
0170 struct rvt_dev_info rdi;
0171
0172 struct list_head piowait;
0173 struct list_head dmawait;
0174 struct list_head txwait;
0175 struct list_head memwait;
0176 struct list_head txreq_free;
0177 struct timer_list mem_timer;
0178 struct qib_pio_header *pio_hdrs;
0179 dma_addr_t pio_hdrs_phys;
0180
0181 u32 n_piowait;
0182 u32 n_txwait;
0183
0184 #ifdef CONFIG_DEBUG_FS
0185
0186 struct dentry *qib_ibdev_dbg;
0187 #endif
0188 };
0189
0190 struct qib_verbs_counters {
0191 u64 symbol_error_counter;
0192 u64 link_error_recovery_counter;
0193 u64 link_downed_counter;
0194 u64 port_rcv_errors;
0195 u64 port_rcv_remphys_errors;
0196 u64 port_xmit_discards;
0197 u64 port_xmit_data;
0198 u64 port_rcv_data;
0199 u64 port_xmit_packets;
0200 u64 port_rcv_packets;
0201 u32 local_link_integrity_errors;
0202 u32 excessive_buffer_overrun_errors;
0203 u32 vl15_dropped;
0204 };
0205
0206 static inline struct qib_ibdev *to_idev(struct ib_device *ibdev)
0207 {
0208 struct rvt_dev_info *rdi;
0209
0210 rdi = container_of(ibdev, struct rvt_dev_info, ibdev);
0211 return container_of(rdi, struct qib_ibdev, rdi);
0212 }
0213
0214
0215
0216
0217
0218 static inline int qib_send_ok(struct rvt_qp *qp)
0219 {
0220 return !(qp->s_flags & (RVT_S_BUSY | RVT_S_ANY_WAIT_IO)) &&
0221 (qp->s_hdrwords || (qp->s_flags & RVT_S_RESP_PENDING) ||
0222 !(qp->s_flags & RVT_S_ANY_WAIT_SEND));
0223 }
0224
0225 bool _qib_schedule_send(struct rvt_qp *qp);
0226 bool qib_schedule_send(struct rvt_qp *qp);
0227
0228 static inline int qib_pkey_ok(u16 pkey1, u16 pkey2)
0229 {
0230 u16 p1 = pkey1 & 0x7FFF;
0231 u16 p2 = pkey2 & 0x7FFF;
0232
0233
0234
0235
0236
0237 return p1 && p1 == p2 && ((__s16)pkey1 < 0 || (__s16)pkey2 < 0);
0238 }
0239
0240 void qib_bad_pkey(struct qib_ibport *ibp, u32 key, u32 sl,
0241 u32 qp1, u32 qp2, __be16 lid1, __be16 lid2);
0242 void qib_cap_mask_chg(struct rvt_dev_info *rdi, u32 port_num);
0243 void qib_sys_guid_chg(struct qib_ibport *ibp);
0244 void qib_node_desc_chg(struct qib_ibport *ibp);
0245 int qib_process_mad(struct ib_device *ibdev, int mad_flags, u32 port_num,
0246 const struct ib_wc *in_wc, const struct ib_grh *in_grh,
0247 const struct ib_mad *in, struct ib_mad *out,
0248 size_t *out_mad_size, u16 *out_mad_pkey_index);
0249 void qib_notify_create_mad_agent(struct rvt_dev_info *rdi, int port_idx);
0250 void qib_notify_free_mad_agent(struct rvt_dev_info *rdi, int port_idx);
0251
0252
0253
0254
0255
0256 static inline int qib_cmp24(u32 a, u32 b)
0257 {
0258 return (((int) a) - ((int) b)) << 8;
0259 }
0260
0261 int qib_snapshot_counters(struct qib_pportdata *ppd, u64 *swords,
0262 u64 *rwords, u64 *spkts, u64 *rpkts,
0263 u64 *xmit_wait);
0264
0265 int qib_get_counters(struct qib_pportdata *ppd,
0266 struct qib_verbs_counters *cntrs);
0267
0268
0269
0270
0271 unsigned qib_free_all_qps(struct rvt_dev_info *rdi);
0272 void *qib_qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp);
0273 void qib_qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp);
0274 void qib_notify_qp_reset(struct rvt_qp *qp);
0275 int qib_alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
0276 enum ib_qp_type type, u32 port);
0277 void qib_restart_rc(struct rvt_qp *qp, u32 psn, int wait);
0278 #ifdef CONFIG_DEBUG_FS
0279
0280 void qib_qp_iter_print(struct seq_file *s, struct rvt_qp_iter *iter);
0281
0282 #endif
0283
0284 unsigned qib_pkt_delay(u32 plen, u8 snd_mult, u8 rcv_mult);
0285
0286 void qib_verbs_sdma_desc_avail(struct qib_pportdata *ppd, unsigned avail);
0287
0288 void qib_put_txreq(struct qib_verbs_txreq *tx);
0289
0290 int qib_verbs_send(struct rvt_qp *qp, struct ib_header *hdr,
0291 u32 hdrwords, struct rvt_sge_state *ss, u32 len);
0292
0293 void qib_uc_rcv(struct qib_ibport *ibp, struct ib_header *hdr,
0294 int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
0295
0296 void qib_rc_rcv(struct qib_ctxtdata *rcd, struct ib_header *hdr,
0297 int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
0298
0299 int qib_check_ah(struct ib_device *ibdev, struct rdma_ah_attr *ah_attr);
0300
0301 int qib_check_send_wqe(struct rvt_qp *qp, struct rvt_swqe *wqe,
0302 bool *call_send);
0303
0304 struct ib_ah *qib_create_qp0_ah(struct qib_ibport *ibp, u16 dlid);
0305
0306 void qib_rc_rnr_retry(unsigned long arg);
0307
0308 void qib_rc_send_complete(struct rvt_qp *qp, struct ib_header *hdr);
0309
0310 int qib_post_ud_send(struct rvt_qp *qp, const struct ib_send_wr *wr);
0311
0312 void qib_ud_rcv(struct qib_ibport *ibp, struct ib_header *hdr,
0313 int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
0314
0315 void mr_rcu_callback(struct rcu_head *list);
0316
0317 void qib_migrate_qp(struct rvt_qp *qp);
0318
0319 int qib_ruc_check_hdr(struct qib_ibport *ibp, struct ib_header *hdr,
0320 int has_grh, struct rvt_qp *qp, u32 bth0);
0321
0322 u32 qib_make_grh(struct qib_ibport *ibp, struct ib_grh *hdr,
0323 const struct ib_global_route *grh, u32 hwords, u32 nwords);
0324
0325 void qib_make_ruc_header(struct rvt_qp *qp, struct ib_other_headers *ohdr,
0326 u32 bth0, u32 bth2);
0327
0328 void _qib_do_send(struct work_struct *work);
0329
0330 void qib_do_send(struct rvt_qp *qp);
0331
0332 void qib_send_rc_ack(struct rvt_qp *qp);
0333
0334 int qib_make_rc_req(struct rvt_qp *qp, unsigned long *flags);
0335
0336 int qib_make_uc_req(struct rvt_qp *qp, unsigned long *flags);
0337
0338 int qib_make_ud_req(struct rvt_qp *qp, unsigned long *flags);
0339
0340 int qib_register_ib_device(struct qib_devdata *);
0341
0342 void qib_unregister_ib_device(struct qib_devdata *);
0343
0344 void qib_ib_rcv(struct qib_ctxtdata *, void *, void *, u32);
0345
0346 void qib_ib_piobufavail(struct qib_devdata *);
0347
0348 unsigned qib_get_npkeys(struct qib_devdata *);
0349
0350 unsigned qib_get_pkey(struct qib_ibport *, unsigned);
0351
0352 extern const enum ib_wc_opcode ib_qib_wc_opcode[];
0353
0354
0355
0356
0357
0358 #define IB_PHYSPORTSTATE_SLEEP 1
0359 #define IB_PHYSPORTSTATE_POLL 2
0360 #define IB_PHYSPORTSTATE_DISABLED 3
0361 #define IB_PHYSPORTSTATE_CFG_TRAIN 4
0362 #define IB_PHYSPORTSTATE_LINKUP 5
0363 #define IB_PHYSPORTSTATE_LINK_ERR_RECOVER 6
0364 #define IB_PHYSPORTSTATE_CFG_DEBOUNCE 8
0365 #define IB_PHYSPORTSTATE_CFG_IDLE 0xB
0366 #define IB_PHYSPORTSTATE_RECOVERY_RETRAIN 0xC
0367 #define IB_PHYSPORTSTATE_RECOVERY_WAITRMT 0xE
0368 #define IB_PHYSPORTSTATE_RECOVERY_IDLE 0xF
0369 #define IB_PHYSPORTSTATE_CFG_ENH 0x10
0370 #define IB_PHYSPORTSTATE_CFG_WAIT_ENH 0x13
0371
0372 extern const int ib_rvt_state_ops[];
0373
0374 extern __be64 ib_qib_sys_image_guid;
0375
0376 extern unsigned int ib_rvt_lkey_table_size;
0377
0378 extern unsigned int ib_qib_max_cqes;
0379
0380 extern unsigned int ib_qib_max_cqs;
0381
0382 extern unsigned int ib_qib_max_qp_wrs;
0383
0384 extern unsigned int ib_qib_max_qps;
0385
0386 extern unsigned int ib_qib_max_sges;
0387
0388 extern unsigned int ib_qib_max_mcast_grps;
0389
0390 extern unsigned int ib_qib_max_mcast_qp_attached;
0391
0392 extern unsigned int ib_qib_max_srqs;
0393
0394 extern unsigned int ib_qib_max_srq_sges;
0395
0396 extern unsigned int ib_qib_max_srq_wrs;
0397
0398 extern const u32 ib_qib_rnr_table[];
0399
0400 extern const struct rvt_operation_params qib_post_parms[];
0401
0402 #endif