1219820Sjeff/* 2219820Sjeff * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 3219820Sjeff * Copyright (c) 2005, 2006 Cisco Systems, Inc. All rights reserved. 4219820Sjeff * Copyright (c) 2005 PathScale, Inc. All rights reserved. 5219820Sjeff * 6219820Sjeff * This software is available to you under a choice of one of two 7219820Sjeff * licenses. You may choose to be licensed under the terms of the GNU 8219820Sjeff * General Public License (GPL) Version 2, available from the file 9219820Sjeff * COPYING in the main directory of this source tree, or the 10219820Sjeff * OpenIB.org BSD license below: 11219820Sjeff * 12219820Sjeff * Redistribution and use in source and binary forms, with or 13219820Sjeff * without modification, are permitted provided that the following 14219820Sjeff * conditions are met: 15219820Sjeff * 16219820Sjeff * - Redistributions of source code must retain the above 17219820Sjeff * copyright notice, this list of conditions and the following 18219820Sjeff * disclaimer. 19219820Sjeff * 20219820Sjeff * - Redistributions in binary form must reproduce the above 21219820Sjeff * copyright notice, this list of conditions and the following 22219820Sjeff * disclaimer in the documentation and/or other materials 23219820Sjeff * provided with the distribution. 24219820Sjeff * 25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32219820Sjeff * SOFTWARE. 33219820Sjeff */ 34219820Sjeff 35219820Sjeff#ifndef INFINIBAND_DRIVER_H 36219820Sjeff#define INFINIBAND_DRIVER_H 37219820Sjeff 38219820Sjeff#include <infiniband/verbs.h> 39219820Sjeff#include <infiniband/kern-abi.h> 40219820Sjeff 41219820Sjeff#ifdef __cplusplus 42219820Sjeff# define BEGIN_C_DECLS extern "C" { 43219820Sjeff# define END_C_DECLS } 44219820Sjeff#else /* !__cplusplus */ 45219820Sjeff# define BEGIN_C_DECLS 46219820Sjeff# define END_C_DECLS 47219820Sjeff#endif /* __cplusplus */ 48219820Sjeff 49219820Sjeff/* 50219820Sjeff * Extension that low-level drivers should add to their .so filename 51219820Sjeff * (probably via libtool "-release" option). For example a low-level 52219820Sjeff * driver named "libfoo" should build a plug-in named "libfoo-rdmav2.so". 53219820Sjeff */ 54219820Sjeff#define IBV_DEVICE_LIBRARY_EXTENSION rdmav2 55219820Sjeff 56219820Sjefftypedef struct ibv_device *(*ibv_driver_init_func)(const char *uverbs_sys_path, 57219820Sjeff int abi_version); 58219820Sjeff 59219820Sjeffvoid ibv_register_driver(const char *name, ibv_driver_init_func init_func); 60219820Sjeffint ibv_cmd_get_context(struct ibv_context *context, struct ibv_get_context *cmd, 61219820Sjeff size_t cmd_size, struct ibv_get_context_resp *resp, 62219820Sjeff size_t resp_size); 63219820Sjeffint ibv_cmd_query_device(struct ibv_context *context, 64219820Sjeff struct ibv_device_attr *device_attr, 65219820Sjeff uint64_t *raw_fw_ver, 66219820Sjeff struct ibv_query_device *cmd, size_t cmd_size); 67219820Sjeffint ibv_cmd_query_port(struct ibv_context *context, uint8_t port_num, 68219820Sjeff struct ibv_port_attr *port_attr, 69219820Sjeff struct ibv_query_port *cmd, size_t cmd_size); 70219820Sjeffint ibv_cmd_query_gid(struct ibv_context *context, uint8_t port_num, 71219820Sjeff int index, union ibv_gid *gid); 72219820Sjeffint ibv_cmd_query_pkey(struct ibv_context *context, uint8_t port_num, 73219820Sjeff int index, uint16_t *pkey); 74219820Sjeffint ibv_cmd_alloc_pd(struct ibv_context *context, struct ibv_pd *pd, 75219820Sjeff struct ibv_alloc_pd *cmd, size_t cmd_size, 76219820Sjeff struct ibv_alloc_pd_resp *resp, size_t resp_size); 77219820Sjeffint ibv_cmd_dealloc_pd(struct ibv_pd *pd); 78219820Sjeff#define IBV_CMD_REG_MR_HAS_RESP_PARAMS 79219820Sjeffint ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length, 80219820Sjeff uint64_t hca_va, int access, 81219820Sjeff struct ibv_mr *mr, struct ibv_reg_mr *cmd, 82219820Sjeff size_t cmd_size, 83219820Sjeff struct ibv_reg_mr_resp *resp, size_t resp_size); 84219820Sjeffint ibv_cmd_dereg_mr(struct ibv_mr *mr); 85219820Sjeffint ibv_cmd_create_cq(struct ibv_context *context, int cqe, 86219820Sjeff struct ibv_comp_channel *channel, 87219820Sjeff int comp_vector, struct ibv_cq *cq, 88219820Sjeff struct ibv_create_cq *cmd, size_t cmd_size, 89219820Sjeff struct ibv_create_cq_resp *resp, size_t resp_size); 90219820Sjeffint ibv_cmd_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc); 91219820Sjeffint ibv_cmd_req_notify_cq(struct ibv_cq *cq, int solicited_only); 92219820Sjeff#define IBV_CMD_RESIZE_CQ_HAS_RESP_PARAMS 93219820Sjeffint ibv_cmd_resize_cq(struct ibv_cq *cq, int cqe, 94219820Sjeff struct ibv_resize_cq *cmd, size_t cmd_size, 95219820Sjeff struct ibv_resize_cq_resp *resp, size_t resp_size); 96219820Sjeffint ibv_cmd_destroy_cq(struct ibv_cq *cq); 97219820Sjeff 98219820Sjeffint ibv_cmd_create_srq(struct ibv_pd *pd, 99219820Sjeff struct ibv_srq *srq, struct ibv_srq_init_attr *attr, 100219820Sjeff struct ibv_create_srq *cmd, size_t cmd_size, 101219820Sjeff struct ibv_create_srq_resp *resp, size_t resp_size); 102219820Sjeffint ibv_cmd_create_xrc_srq(struct ibv_pd *pd, 103219820Sjeff struct ibv_srq *srq, struct ibv_srq_init_attr *attr, 104219820Sjeff uint32_t xrc_domain, uint32_t xrc_cq, 105219820Sjeff struct ibv_create_xrc_srq *cmd, size_t cmd_size, 106219820Sjeff struct ibv_create_srq_resp *resp, size_t resp_size); 107219820Sjeffint ibv_cmd_modify_srq(struct ibv_srq *srq, 108219820Sjeff struct ibv_srq_attr *srq_attr, 109219820Sjeff int srq_attr_mask, 110219820Sjeff struct ibv_modify_srq *cmd, size_t cmd_size); 111219820Sjeffint ibv_cmd_query_srq(struct ibv_srq *srq, 112219820Sjeff struct ibv_srq_attr *srq_attr, 113219820Sjeff struct ibv_query_srq *cmd, size_t cmd_size); 114219820Sjeffint ibv_cmd_destroy_srq(struct ibv_srq *srq); 115219820Sjeff 116219820Sjeffint ibv_cmd_create_qp(struct ibv_pd *pd, 117219820Sjeff struct ibv_qp *qp, struct ibv_qp_init_attr *attr, 118219820Sjeff struct ibv_create_qp *cmd, size_t cmd_size, 119219820Sjeff struct ibv_create_qp_resp *resp, size_t resp_size); 120219820Sjeffint ibv_cmd_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *qp_attr, 121219820Sjeff int attr_mask, 122219820Sjeff struct ibv_qp_init_attr *qp_init_attr, 123219820Sjeff struct ibv_query_qp *cmd, size_t cmd_size); 124219820Sjeffint ibv_cmd_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, 125219820Sjeff int attr_mask, 126219820Sjeff struct ibv_modify_qp *cmd, size_t cmd_size); 127219820Sjeffint ibv_cmd_destroy_qp(struct ibv_qp *qp); 128219820Sjeffint ibv_cmd_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, 129219820Sjeff struct ibv_send_wr **bad_wr); 130219820Sjeffint ibv_cmd_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, 131219820Sjeff struct ibv_recv_wr **bad_wr); 132219820Sjeffint ibv_cmd_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr, 133219820Sjeff struct ibv_recv_wr **bad_wr); 134219820Sjeffint ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah, 135219820Sjeff struct ibv_ah_attr *attr); 136219820Sjeffint ibv_cmd_destroy_ah(struct ibv_ah *ah); 137219820Sjeffint ibv_cmd_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid); 138219820Sjeffint ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid); 139219820Sjeff 140219820Sjeffint ibv_dontfork_range(void *base, size_t size); 141219820Sjeffint ibv_dofork_range(void *base, size_t size); 142219820Sjeffint ibv_cmd_open_xrc_domain(struct ibv_context *context, int fd, int oflag, 143219820Sjeff struct ibv_xrc_domain *d, 144219820Sjeff struct ibv_open_xrc_domain_resp *resp, 145219820Sjeff size_t resp_size); 146219820Sjeffint ibv_cmd_close_xrc_domain(struct ibv_xrc_domain *d); 147219820Sjeffint ibv_cmd_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr, 148219820Sjeff uint32_t *xrc_rcv_qpn); 149219820Sjeffint ibv_cmd_modify_xrc_rcv_qp(struct ibv_xrc_domain *d, uint32_t xrc_rcv_qpn, 150219820Sjeff struct ibv_qp_attr *attr, int attr_mask); 151219820Sjeffint ibv_cmd_query_xrc_rcv_qp(struct ibv_xrc_domain *d, uint32_t xrc_rcv_qpn, 152219820Sjeff struct ibv_qp_attr *attr, int attr_mask, 153219820Sjeff struct ibv_qp_init_attr *init_attr); 154219820Sjeffint ibv_cmd_reg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, 155219820Sjeff uint32_t xrc_qp_num); 156219820Sjeffint ibv_cmd_unreg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, 157219820Sjeff uint32_t xrc_qp_num); 158219820Sjeff 159219820Sjeff/* 160219820Sjeff * sysfs helper functions 161219820Sjeff */ 162219820Sjeffconst char *ibv_get_sysfs_path(void); 163219820Sjeff 164219820Sjeffint ibv_read_sysfs_file(const char *dir, const char *file, 165219820Sjeff char *buf, size_t size); 166219820Sjeff 167219820Sjeffint ibv_resolve_eth_gid(const struct ibv_pd *pd, uint8_t port_num, 168219820Sjeff union ibv_gid *dgid, uint8_t sgid_index, 169219820Sjeff uint8_t mac[], uint16_t *vlan, uint8_t *tagged, 170219820Sjeff uint8_t *is_mcast); 171219820Sjeff 172219820Sjeff#endif /* INFINIBAND_DRIVER_H */ 173