1/* 2 3 * Copyright (c) 2006, 2007 Cisco Systems. All rights reserved. 4 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved. 5 * 6 * This software is available to you under a choice of one of two 7 * licenses. You may choose to be licensed under the terms of the GNU 8 * General Public License (GPL) Version 2, available from the file 9 * COPYING in the main directory of this source tree, or the 10 * OpenIB.org BSD license below: 11 * 12 * Redistribution and use in source and binary forms, with or 13 * without modification, are permitted provided that the following 14 * conditions are met: 15 * 16 * - Redistributions of source code must retain the above 17 * copyright notice, this list of conditions and the following 18 * disclaimer. 19 * 20 * - Redistributions in binary form must reproduce the above 21 * copyright notice, this list of conditions and the following 22 * disclaimer in the documentation and/or other materials 23 * provided with the distribution. 24 * 25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * SOFTWARE. 33 34 */ 35#ifndef MLX4_IB_H 36#define MLX4_IB_H 37/* 38 #include <linux/compiler.h> 39 #include <linux/list.h> 40 #include <linux/mutex.h> 41 */ 42#include <linux/idr.h> 43/* 44 #include <linux/notifier.h> 45 */ 46#include <rdma/ib_verbs.h> 47/* 48 #include <rdma/ib_umem.h> 49 */ 50#include <rdma/ib_mad.h> 51#include <rdma/ib_sa.h> 52 53#include <linux/mlx4/device.h> 54#include <linux/mlx4/doorbell.h> 55#include <linux/rbtree.h> 56 57#include <asm/byteorder.h> 58 59#define MLX4_IB_DRV_NAME "mlx4_ib" 60 61#ifdef pr_fmt 62#undef pr_fmt 63#endif 64#define pr_fmt(fmt) "<" MLX4_IB_DRV_NAME "> %s: " fmt, __func__ 65 66#define mlx4_ib_warn(ibdev, format, arg...) \ 67 dev_warn((ibdev)->dma_device, MLX4_IB_DRV_NAME ": " format, ## arg) 68 69#define mlx4_ib_info(ibdev, format, arg...) \ 70 dev_info((ibdev)->dma_device, MLX4_IB_DRV_NAME ": " format, ## arg) 71 72enum { 73 MLX4_IB_SQ_MIN_WQE_SHIFT = 6, MLX4_IB_MAX_HEADROOM = 2048 74}; 75 76#define MLX4_IB_SQ_HEADROOM(shift) ((MLX4_IB_MAX_HEADROOM >> (shift)) + 1) 77#define MLX4_IB_SQ_MAX_SPARE (MLX4_IB_SQ_HEADROOM(MLX4_IB_SQ_MIN_WQE_SHIFT)) 78 79/*module param to indicate if SM assigns the alias_GUID*/ 80extern int mlx4_ib_sm_guid_assign; 81#ifdef __linux__ 82extern struct proc_dir_entry *mlx4_mrs_dir_entry; 83#endif 84 85#define MLX4_IB_UC_STEER_QPN_ALIGN 1 86#define MLX4_IB_UC_MAX_NUM_QPS (256 * 1024) 87 88#define MLX4_IB_MMAP_CMD_MASK 0xFF 89#define MLX4_IB_MMAP_CMD_BITS 8 90 91struct mlx4_ib_ucontext { 92 struct ib_ucontext ibucontext; 93 struct mlx4_uar uar; 94 struct list_head db_page_list; 95/*struct mutex db_page_mutex;*/ 96}; 97 98struct mlx4_ib_pd { 99 struct ib_pd ibpd; 100 u32 pdn; 101}; 102 103struct mlx4_ib_xrcd { 104 struct ib_xrcd ibxrcd; 105 u32 xrcdn; 106 struct ib_pd *pd; 107 struct ib_cq *cq; 108}; 109 110struct mlx4_ib_cq_buf { 111 struct mlx4_buf buf; 112 struct mlx4_mtt mtt; 113 int entry_size; 114}; 115 116struct mlx4_ib_cq_resize { 117 struct mlx4_ib_cq_buf buf; 118 int cqe; 119}; 120 121struct mlx4_shared_mr_info { 122 int mr_id; 123 struct ib_umem *umem; 124}; 125 126struct mlx4_ib_cq { 127 struct ib_cq ibcq; 128 struct mlx4_cq mcq; 129 struct mlx4_ib_cq_buf buf; 130 struct mlx4_ib_cq_resize *resize_buf; 131 struct mlx4_db db; 132 /*spinlock_t lock; 133 struct mutex resize_mutex;*/ 134 struct ib_umem *umem; 135 struct ib_umem *resize_umem; 136}; 137 138struct mlx4_ib_mr { 139 struct ib_mr ibmr; 140 struct mlx4_mr mmr; 141 struct ib_umem *umem; 142 struct mlx4_shared_mr_info *smr_info; 143}; 144/* 145 struct mlx4_ib_fast_reg_page_list { 146 struct ib_fast_reg_page_list ibfrpl; 147 __be64 *mapped_page_list; 148 dma_addr_t map; 149 }; 150 151 struct mlx4_ib_fmr { 152 struct ib_fmr ibfmr; 153 struct mlx4_fmr mfmr; 154 }; 155 */ 156struct mlx4_ib_wq { 157 u64 *wrid; 158 spinlock_t lock; 159 int wqe_cnt; 160 int max_post; 161 int max_gs; 162 int offset; 163 int wqe_shift; 164 unsigned head; 165 unsigned tail; 166}; 167 168enum mlx4_ib_qp_flags { 169 MLX4_IB_QP_LSO = IB_QP_CREATE_IPOIB_UD_LSO, 170 MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK = IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK, 171 MLX4_IB_QP_NETIF = IB_QP_CREATE_NETIF_QP, 172 MLX4_IB_SRIOV_TUNNEL_QP = 1 << 30, 173 MLX4_IB_SRIOV_SQP = 1 << 31, 174}; 175 176struct mlx4_ib_gid_entry { 177 struct list_head list; 178 union ib_gid gid; 179 int added; 180 u8 port; 181}; 182 183enum mlx4_ib_mmap_cmd { 184 MLX4_IB_MMAP_UAR_PAGE = 0, 185 MLX4_IB_MMAP_BLUE_FLAME_PAGE = 1, 186 MLX4_IB_MMAP_GET_CONTIGUOUS_PAGES = 2, 187}; 188 189enum mlx4_ib_qp_type { 190 191 /** IB_QPT_SMI and IB_QPT_GSI have to be the first two entries 192 * here (and in that order) since the MAD layer uses them as 193 * indices into a 2-entry table.*/ 194 195 MLX4_IB_QPT_SMI = IB_QPT_SMI, 196 MLX4_IB_QPT_GSI = IB_QPT_GSI, 197 198 MLX4_IB_QPT_RC = IB_QPT_RC, 199 MLX4_IB_QPT_UC = IB_QPT_UC, 200 MLX4_IB_QPT_UD = IB_QPT_UD, 201 MLX4_IB_QPT_RAW_IPV6 = IB_QPT_RAW_IPV6, 202 MLX4_IB_QPT_RAW_ETHERTYPE = IB_QPT_RAW_ETHERTYPE, 203 MLX4_IB_QPT_RAW_PACKET = IB_QPT_RAW_PACKET, 204 MLX4_IB_QPT_XRC_INI = IB_QPT_XRC_INI, 205 MLX4_IB_QPT_XRC_TGT = IB_QPT_XRC_TGT, 206 207 MLX4_IB_QPT_PROXY_SMI_OWNER = 1 << 16, 208 MLX4_IB_QPT_PROXY_SMI = 1 << 17, 209 MLX4_IB_QPT_PROXY_GSI = 1 << 18, 210 MLX4_IB_QPT_TUN_SMI_OWNER = 1 << 19, 211 MLX4_IB_QPT_TUN_SMI = 1 << 20, 212 MLX4_IB_QPT_TUN_GSI = 1 << 21, 213}; 214 215#define MLX4_IB_QPT_ANY_SRIOV (MLX4_IB_QPT_PROXY_SMI_OWNER | \ 216 MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER | \ 217 MLX4_IB_QPT_TUN_SMI | MLX4_IB_QPT_TUN_GSI) 218 219enum mlx4_ib_mad_ifc_flags { 220 MLX4_MAD_IFC_IGNORE_MKEY = 1, 221 MLX4_MAD_IFC_IGNORE_BKEY = 2, 222 MLX4_MAD_IFC_IGNORE_KEYS = (MLX4_MAD_IFC_IGNORE_MKEY 223 | MLX4_MAD_IFC_IGNORE_BKEY), 224 MLX4_MAD_IFC_NET_VIEW = 4, 225}; 226 227enum { 228 MLX4_NUM_TUNNEL_BUFS = 256, 229}; 230 231struct mlx4_ib_tunnel_header { 232 struct mlx4_av av; 233 __be32 remote_qpn; 234 __be32 qkey; 235 __be16 vlan; 236 u8 mac[6]; 237 __be16 pkey_index; 238 u8 reserved[6]; 239}; 240 241struct mlx4_ib_buf { 242 void *addr; 243 genpaddr_t map; 244}; 245 246struct mlx4_rcv_tunnel_hdr { 247 __be32 flags_src_qp; /*flags[6:5] is defined for VLANs: 248 * 0x0 - no vlan was in the packet 249 * 0x01 - C-VLAN was in the packet*/ 250 u8 g_ml_path; /*gid bit stands for ipv6/4 header in RoCE*/ 251 u8 reserved; 252 __be16 pkey_index; 253 __be16 sl_vid; 254 __be16 slid_mac_47_32; 255 __be32 mac_31_0; 256}; 257 258struct mlx4_ib_proxy_sqp_hdr { 259 struct ib_grh grh; 260 struct mlx4_rcv_tunnel_hdr tun; 261} __packed; 262 263struct mlx4_roce_smac_vlan_info { 264 u64 smac; 265 int smac_index; 266 int smac_port; 267 u64 candidate_smac; 268 int candidate_smac_index; 269 int candidate_smac_port; 270 u16 vid; 271 int vlan_index; 272 int vlan_port; 273 u16 candidate_vid; 274 int candidate_vlan_index; 275 int candidate_vlan_port; 276 int update_vid; 277}; 278 279struct mlx4_ib_qpg_data { 280 unsigned long *tss_bitmap; 281 unsigned long *rss_bitmap; 282 struct mlx4_ib_qp *qpg_parent; 283 int tss_qpn_base; 284 int rss_qpn_base; 285 u32 tss_child_count; 286 u32 rss_child_count; 287 u32 qpg_tss_mask_sz; 288}; 289 290struct mlx4_ib_qp { 291 struct ib_qp ibqp; 292 struct mlx4_qp mqp; 293 struct mlx4_buf buf; 294 295 struct mlx4_db db; 296 struct mlx4_ib_wq rq; 297 298 u32 doorbell_qpn; 299 __be32 sq_signal_bits; 300 unsigned sq_next_wqe; 301 int sq_max_wqes_per_wr; 302 int sq_spare_wqes; 303 struct mlx4_ib_wq sq; 304 305 enum mlx4_ib_qp_type mlx4_ib_qp_type; 306 struct ib_umem *umem; 307 struct mlx4_mtt mtt; 308 int buf_size; 309 /*struct mutex mutex;*/ 310 u16 xrcdn; 311 u32 flags; 312 u8 port; 313 u8 alt_port; 314 u8 atomic_rd_en; 315 u8 resp_depth; 316 u8 sq_no_prefetch; 317 u8 state; 318 int mlx_type; 319 enum ib_qpg_type qpg_type; 320 struct mlx4_ib_qpg_data *qpg_data; 321 struct list_head gid_list; 322 struct list_head steering_rules; 323 struct mlx4_ib_buf *sqp_proxy_rcv; 324 struct mlx4_roce_smac_vlan_info pri; 325 struct mlx4_roce_smac_vlan_info alt; 326 struct list_head rules_list; 327 int max_inline_data; 328 struct mlx4_bf bf; 329}; 330 331struct mlx4_ib_srq { 332 struct ib_srq ibsrq; 333 struct mlx4_srq msrq; 334 struct mlx4_buf buf; 335 struct mlx4_db db; 336 u64 *wrid; 337 spinlock_t lock; 338 int head; 339 int tail; 340 u16 wqe_ctr; 341 struct ib_umem *umem; 342 struct mlx4_mtt mtt; 343/*struct mutex mutex;*/ 344}; 345 346struct mlx4_ib_ah { 347 struct ib_ah ibah; 348 union mlx4_ext_av av; 349}; 350/* 351 ************************************** 352 alias guid support 353 ************************************** 354 */ 355#define NUM_PORT_ALIAS_GUID 2 356#define NUM_ALIAS_GUID_IN_REC 8 357#define NUM_ALIAS_GUID_REC_IN_PORT 16 358#define GUID_REC_SIZE 8 359#define NUM_ALIAS_GUID_PER_PORT 128 360#define MLX4_NOT_SET_GUID (0x00LL) 361#define MLX4_GUID_FOR_DELETE_VAL (~(0x00LL)) 362 363enum mlx4_guid_alias_rec_status { 364 MLX4_GUID_INFO_STATUS_IDLE, 365 MLX4_GUID_INFO_STATUS_SET, 366 MLX4_GUID_INFO_STATUS_PENDING, 367}; 368 369enum mlx4_guid_alias_rec_ownership { 370 MLX4_GUID_DRIVER_ASSIGN, MLX4_GUID_SYSADMIN_ASSIGN, MLX4_GUID_NONE_ASSIGN, /*init state of each record*/ 371}; 372 373enum mlx4_guid_alias_rec_method { 374 MLX4_GUID_INFO_RECORD_SET = IB_MGMT_METHOD_SET, 375 MLX4_GUID_INFO_RECORD_DELETE = IB_SA_METHOD_DELETE, 376}; 377 378struct mlx4_sriov_alias_guid_info_rec_det { 379 u8 all_recs[GUID_REC_SIZE * NUM_ALIAS_GUID_IN_REC]; 380 ib_sa_comp_mask guid_indexes; /*indicates what from the 8 records are valid*/ 381 enum mlx4_guid_alias_rec_status status; /*indicates the administraively status of the record.*/ 382 u8 method; /*set or delete*/ 383 enum mlx4_guid_alias_rec_ownership ownership; /*indicates who assign that alias_guid record*/ 384}; 385 386struct mlx4_sriov_alias_guid_port_rec_det { 387 struct mlx4_sriov_alias_guid_info_rec_det all_rec_per_port[NUM_ALIAS_GUID_REC_IN_PORT]; 388 struct workqueue_struct *wq; 389 /*struct delayed_work alias_guid_work;*/ 390 u8 port; 391 struct mlx4_sriov_alias_guid *parent; 392 struct list_head cb_list; 393}; 394 395struct mlx4_sriov_alias_guid { 396 struct mlx4_sriov_alias_guid_port_rec_det ports_guid[MLX4_MAX_PORTS]; 397 spinlock_t ag_work_lock; 398 struct ib_sa_client *sa_client; 399}; 400/* 401 struct mlx4_ib_demux_work { 402 struct work_struct work; 403 struct mlx4_ib_dev *dev; 404 int slave; 405 int do_init; 406 u8 port; 407 408 }; 409 410 struct mlx4_ib_tun_tx_buf { 411 struct mlx4_ib_buf buf; 412 struct ib_ah *ah; 413 }; 414 */ 415struct mlx4_ib_demux_pv_qp { 416 struct ib_qp *qp; 417 enum ib_qp_type proxy_qpt; 418 struct mlx4_ib_buf *ring; 419 struct mlx4_ib_tun_tx_buf *tx_ring; 420 spinlock_t tx_lock; 421 unsigned tx_ix_head; 422 unsigned tx_ix_tail; 423}; 424 425enum mlx4_ib_demux_pv_state { 426 DEMUX_PV_STATE_DOWN, 427 DEMUX_PV_STATE_STARTING, 428 DEMUX_PV_STATE_ACTIVE, 429 DEMUX_PV_STATE_DOWNING, 430}; 431 432struct mlx4_ib_demux_pv_ctx { 433 int port; 434 int slave; 435 enum mlx4_ib_demux_pv_state state; 436 int has_smi; 437 struct ib_device *ib_dev; 438 struct ib_cq *cq; 439 struct ib_pd *pd; 440 struct ib_mr *mr; 441 /*struct work_struct work; 442 struct workqueue_struct *wq;*/ 443 struct mlx4_ib_demux_pv_qp qp[2]; 444}; 445 446struct mlx4_ib_demux_ctx { 447 struct ib_device *ib_dev; 448 int port; 449 /*struct workqueue_struct *wq; 450 struct workqueue_struct *ud_wq; 451 spinlock_t ud_lock;*/ 452 __be64 subnet_prefix; 453 __be64 guid_cache[128]; 454 struct mlx4_ib_dev *dev; 455 /*the following lock protects both mcg_table and mcg_mgid0_list*/ 456 /*struct mutex mcg_table_lock;*/ 457 struct rb_root mcg_table; 458 struct list_head mcg_mgid0_list; 459 /*struct workqueue_struct *mcg_wq;*/ 460 struct mlx4_ib_demux_pv_ctx **tun; 461 atomic_t tid; 462 int flushing; /*flushing the work queue*/ 463}; 464 465struct mlx4_ib_sriov { 466 struct mlx4_ib_demux_ctx demux[MLX4_MAX_PORTS]; 467 struct mlx4_ib_demux_pv_ctx *sqps[MLX4_MAX_PORTS]; 468 /*when using this spinlock you should use "irq" because 469 * it may be called from interrupt context.*/ 470 /*spinlock_t going_down_lock;*/ 471 int is_going_down; 472 473 struct mlx4_sriov_alias_guid alias_guid; 474 475 /*CM paravirtualization fields*/ 476 struct list_head cm_list; 477 /*spinlock_t id_map_lock;*/ 478 struct rb_root sl_id_map; 479 struct idr pv_id_table; 480}; 481 482struct mlx4_ib_iboe { 483 /*spinlock_t lock;*/ 484 struct net_device *netdevs[MLX4_MAX_PORTS]; 485 /*struct notifier_block nb;*/ 486 union ib_gid gid_table[MLX4_MAX_PORTS][128]; 487}; 488 489struct pkey_mgt { 490 u8 virt2phys_pkey[MLX4_MFUNC_MAX][MLX4_MAX_PORTS][MLX4_MAX_PORT_PKEYS]; 491 u16 phys_pkey_cache[MLX4_MAX_PORTS][MLX4_MAX_PORT_PKEYS]; 492 struct list_head pkey_port_list[MLX4_MFUNC_MAX]; 493 struct kobject *device_parent[MLX4_MFUNC_MAX]; 494}; 495 496struct mlx4_ib_iov_sysfs_attr { 497 void *ctx; 498 struct kobject *kobj; 499 unsigned long data; 500 u32 entry_num; 501 char name[15]; 502 /*struct device_attribute dentry;*/ 503 struct device *dev; 504}; 505 506struct mlx4_ib_iov_sysfs_attr_ar { 507 struct mlx4_ib_iov_sysfs_attr dentries[3 * NUM_ALIAS_GUID_PER_PORT + 1]; 508}; 509 510struct mlx4_ib_iov_port { 511 char name[100]; 512 u8 num; 513 struct mlx4_ib_dev *dev; 514 struct list_head list; 515 struct mlx4_ib_iov_sysfs_attr_ar *dentr_ar; 516 struct ib_port_attr attr; 517 struct kobject *cur_port; 518 struct kobject *admin_alias_parent; 519 struct kobject *gids_parent; 520 struct kobject *pkeys_parent; 521 struct kobject *mcgs_parent; 522 struct mlx4_ib_iov_sysfs_attr mcg_dentry; 523}; 524 525struct mlx4_ib_dev { 526 struct ib_device ib_dev; 527 struct mlx4_dev *dev; 528 int num_ports; 529 struct mlx4_uar priv_uar; 530 u32 priv_pdn; 531 MLX4_DECLARE_DOORBELL_LOCK (uar_lock) 532 ; 533 534 struct ib_mad_agent *send_agent[MLX4_MAX_PORTS][2]; 535 struct ib_ah *sm_ah[MLX4_MAX_PORTS]; 536 spinlock_t sm_lock; 537 struct mlx4_ib_sriov sriov; 538 539 /*struct mutex cap_mask_mutex;*/ 540 bool ib_active; 541 struct mlx4_ib_iboe iboe; 542 int counters[MLX4_MAX_PORTS]; 543 int *eq_table; 544 int eq_added; 545 struct kobject *iov_parent; 546 struct kobject *ports_parent; 547 struct kobject *dev_ports_parent[MLX4_MFUNC_MAX]; 548 struct mlx4_ib_iov_port iov_ports[MLX4_MAX_PORTS]; 549 struct pkey_mgt pkeys; 550 unsigned long *ib_uc_qpns_bitmap; 551 int steer_qpn_count; 552 int steer_qpn_base; 553}; 554/* 555 struct ib_event_work { 556 struct work_struct work; 557 struct mlx4_ib_dev *ib_dev; 558 struct mlx4_eqe ib_eqe; 559 }; 560 */ 561struct mlx4_ib_qp_tunnel_init_attr { 562 struct ib_qp_init_attr init_attr; 563 int slave; 564 enum ib_qp_type proxy_qp_type; 565 u8 port; 566}; 567 568static inline struct mlx4_ib_dev *to_mdev(struct ib_device *ibdev) { 569 return container_of(ibdev, struct mlx4_ib_dev, ib_dev); 570} 571 572static inline struct mlx4_ib_ucontext *to_mucontext( 573 struct ib_ucontext *ibucontext) { 574 return container_of(ibucontext, struct mlx4_ib_ucontext, ibucontext); 575} 576 577static inline struct mlx4_ib_pd *to_mpd(struct ib_pd *ibpd) { 578 return container_of(ibpd, struct mlx4_ib_pd, ibpd); 579} 580 581static inline struct mlx4_ib_xrcd *to_mxrcd(struct ib_xrcd *ibxrcd) { 582 return container_of(ibxrcd, struct mlx4_ib_xrcd, ibxrcd); 583} 584 585static inline struct mlx4_ib_cq *to_mcq(struct ib_cq *ibcq) { 586 return container_of(ibcq, struct mlx4_ib_cq, ibcq); 587} 588 589static inline struct mlx4_ib_cq *to_mibcq(struct mlx4_cq *mcq) { 590 return container_of(mcq, struct mlx4_ib_cq, mcq); 591} 592/* 593 static inline struct mlx4_ib_mr *to_mmr(struct ib_mr *ibmr) { 594 return container_of(ibmr, struct mlx4_ib_mr, ibmr); 595 } 596 597 static inline struct mlx4_ib_fast_reg_page_list *to_mfrpl( 598 struct ib_fast_reg_page_list *ibfrpl) { 599 return container_of(ibfrpl, struct mlx4_ib_fast_reg_page_list, ibfrpl); 600 } 601 602 static inline struct mlx4_ib_fmr *to_mfmr(struct ib_fmr *ibfmr) { 603 return container_of(ibfmr, struct mlx4_ib_fmr, ibfmr); 604 } 605 */ 606static inline struct mlx4_ib_qp *to_mqp(struct ib_qp *ibqp) { 607 return container_of(ibqp, struct mlx4_ib_qp, ibqp); 608} 609static inline struct mlx4_ib_qp *to_mibqp(struct mlx4_qp *mqp) { 610 return container_of(mqp, struct mlx4_ib_qp, mqp); 611} 612static inline struct mlx4_ib_srq *to_msrq(struct ib_srq *ibsrq) { 613 return container_of(ibsrq, struct mlx4_ib_srq, ibsrq); 614} 615/* 616 static inline struct mlx4_ib_srq *to_mibsrq(struct mlx4_srq *msrq) { 617 return container_of(msrq, struct mlx4_ib_srq, msrq); 618 } 619 */ 620static inline struct mlx4_ib_ah *to_mah(struct ib_ah *ibah) { 621 return container_of(ibah, struct mlx4_ib_ah, ibah); 622} 623/* 624 int mlx4_ib_init_sriov(struct mlx4_ib_dev *dev); 625 void mlx4_ib_close_sriov(struct mlx4_ib_dev *dev); 626 627 int mlx4_ib_db_map_user(struct mlx4_ib_ucontext *context, unsigned long virt, 628 struct mlx4_db *db); 629 void mlx4_ib_db_unmap_user(struct mlx4_ib_ucontext *context, struct mlx4_db *db); 630 */ 631struct ib_mr *mlx4_ib_get_dma_mr(struct ib_pd *pd, int acc); 632/* 633 int mlx4_ib_umem_write_mtt(struct mlx4_ib_dev *dev, struct mlx4_mtt *mtt, 634 struct ib_umem *umem); 635 int mlx4_ib_umem_calc_optimal_mtt_size(struct ib_umem *umem, u64 start_va, 636 int *num_of_mtts); 637 struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, 638 u64 virt_addr, int access_flags, struct ib_udata *udata, int mr_id); 639 int mlx4_ib_dereg_mr(struct ib_mr *mr); 640 struct ib_mr *mlx4_ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len); 641 struct ib_fast_reg_page_list *mlx4_ib_alloc_fast_reg_page_list( 642 struct ib_device *ibdev, int page_list_len); 643 void mlx4_ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list); 644 645 int mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period); 646 int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata); 647 */ 648int mlx4_ib_ignore_overrun_cq(struct ib_cq *ibcq); 649struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, 650 int vector, struct ib_ucontext *context, struct ib_udata *udata); 651/* 652 int mlx4_ib_destroy_cq(struct ib_cq *cq); 653 */ 654int mlx4_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc); 655int mlx4_ib_arm_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags); 656/* 657 void __mlx4_ib_cq_clean(struct mlx4_ib_cq *cq, u32 qpn, struct mlx4_ib_srq *srq); 658 void mlx4_ib_cq_clean(struct mlx4_ib_cq *cq, u32 qpn, struct mlx4_ib_srq *srq); 659 */ 660struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr); 661/* 662 int mlx4_ib_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr); 663 */ 664int mlx4_ib_destroy_ah(struct ib_ah *ah); 665/* 666 struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, 667 struct ib_srq_init_attr *init_attr, struct ib_udata *udata); 668 int mlx4_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, 669 enum ib_srq_attr_mask attr_mask, struct ib_udata *udata); 670 int mlx4_ib_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr); 671 int mlx4_ib_destroy_srq(struct ib_srq *srq); 672 void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index); 673 int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr, 674 struct ib_recv_wr **bad_wr); 675 */ 676struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd, 677 struct ib_qp_init_attr *init_attr, struct ib_udata *udata); 678/* 679 int mlx4_ib_destroy_qp(struct ib_qp *qp); 680 */ 681int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 682 int attr_mask, struct ib_udata *udata); 683/* 684 int mlx4_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, 685 int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr); 686 */ 687int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, 688 struct ib_send_wr **bad_wr); 689int mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, 690 struct ib_recv_wr **bad_wr); 691int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int mad_ifc_flags, int port, 692 struct ib_wc *in_wc, struct ib_grh *in_grh, void *in_mad, 693 void *response_mad); 694int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, 695 struct ib_wc *in_wc, struct ib_grh *in_grh, struct ib_mad *in_mad, 696 struct ib_mad *out_mad); 697/* 698 int mlx4_ib_mad_init(struct mlx4_ib_dev *dev); 699 void mlx4_ib_mad_cleanup(struct mlx4_ib_dev *dev); 700 701 struct ib_fmr *mlx4_ib_fmr_alloc(struct ib_pd *pd, int mr_access_flags, 702 struct ib_fmr_attr *fmr_attr); 703 int mlx4_ib_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, int npages, 704 u64 iova); 705 int mlx4_ib_unmap_fmr(struct list_head *fmr_list); 706 int mlx4_ib_fmr_dealloc(struct ib_fmr *fmr); 707 */ 708int __mlx4_ib_query_port(struct ib_device *ibdev, u8 port, 709 struct ib_port_attr *props, int netw_view); 710int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey, 711 int netw_view); 712int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index, 713 union ib_gid *gid, int netw_view); 714 715int mlx4_ib_resolve_grh(struct mlx4_ib_dev *dev, 716 const struct ib_ah_attr *ah_attr, u8 *mac, int *is_mcast, u8 port); 717/* 718 int mlx4_ib_query_if_stat(struct mlx4_ib_dev *dev, u32 counter_index, 719 union mlx4_counter *counter, u8 clear); 720 */ 721static inline int mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah) { 722 u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3; 723 724 if (rdma_port_get_link_layer(ah->ibah.device, port) 725 == IB_LINK_LAYER_ETHERNET) 726 return 1; 727 728 return !!(ah->av.ib.g_slid & 0x80); 729} 730/* 731 int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx); 732 void mlx4_ib_mcg_port_cleanup(struct mlx4_ib_demux_ctx *ctx, int destroy_wq); 733 void clean_vf_mcast(struct mlx4_ib_demux_ctx *ctx, int slave); 734 int mlx4_ib_mcg_init(void); 735 void mlx4_ib_mcg_destroy(void); 736 737 int mlx4_ib_find_real_gid(struct ib_device *ibdev, u8 port, __be64 guid); 738 739 int mlx4_ib_mcg_multiplex_handler(struct ib_device *ibdev, int port, int slave, 740 struct ib_sa_mad *sa_mad); 741 int mlx4_ib_mcg_demux_handler(struct ib_device *ibdev, int port, int slave, 742 struct ib_sa_mad *mad); 743 */ 744int mlx4_ib_add_mc(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp, 745 union ib_gid *gid); 746/* 747 void mlx4_ib_dispatch_event(struct mlx4_ib_dev *dev, u8 port_num, 748 enum ib_event_type type); 749 750 void mlx4_ib_tunnels_update_work(struct work_struct *work); 751 752 int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port, 753 enum ib_qp_type qpt, struct ib_wc *wc, struct ib_grh *grh, 754 struct ib_mad *mad); 755 int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port, 756 enum ib_qp_type dest_qpt, u16 pkey_index, u32 remote_qpn, u32 qkey, 757 struct ib_ah_attr *attr, struct ib_mad *mad); 758 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx); 759 760 int mlx4_ib_demux_cm_handler(struct ib_device *ibdev, int port, int *slave, 761 struct ib_mad *mad, int is_eth); 762 763 int mlx4_ib_multiplex_cm_handler(struct ib_device *ibdev, int port, 764 int slave_id, struct ib_mad *mad); 765 766 void mlx4_ib_cm_paravirt_init(struct mlx4_ib_dev *dev); 767 void mlx4_ib_cm_paravirt_clean(struct mlx4_ib_dev *dev, int slave_id); 768 769 alias guid support 770 void mlx4_ib_init_alias_guid_work(struct mlx4_ib_dev *dev, int port); 771 int mlx4_ib_init_alias_guid_service(struct mlx4_ib_dev *dev); 772 void mlx4_ib_destroy_alias_guid_service(struct mlx4_ib_dev *dev); 773 void mlx4_ib_invalidate_all_guid_record(struct mlx4_ib_dev *dev, int port); 774 775 void mlx4_ib_notify_slaves_on_guid_change(struct mlx4_ib_dev *dev, 776 int block_num, u8 port_num, u8 *p_data); 777 778 void mlx4_ib_update_cache_on_guid_change(struct mlx4_ib_dev *dev, int block_num, 779 u8 port_num, u8 *p_data); 780 781 int add_sysfs_port_mcg_attr(struct mlx4_ib_dev *device, int port_num, 782 struct attribute *attr); 783 void del_sysfs_port_mcg_attr(struct mlx4_ib_dev *device, int port_num, 784 struct attribute *attr); 785 ib_sa_comp_mask mlx4_ib_get_aguid_comp_mask_from_ix(int index); 786 787 int mlx4_ib_device_register_sysfs(struct mlx4_ib_dev *device); 788 789 void mlx4_ib_device_unregister_sysfs(struct mlx4_ib_dev *device); 790 791 __be64 mlx4_ib_gen_node_guid(void); 792 */ 793int mlx4_ib_steer_qp_alloc(struct mlx4_ib_dev *dev, int count, int *qpn); 794/* 795 void mlx4_ib_steer_qp_free(struct mlx4_ib_dev *dev, u32 qpn, int count); 796 */ 797int mlx4_ib_steer_qp_reg(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp, 798 int is_attach); 799 800#endif /*MLX4_IB_H*/ 801