extern int ibv_cmd_query_port(struct ibv_context *context, uint8_t port_num,
struct ibv_port_attr *port_attr,
struct ibv_query_port *cmd, size_t cmd_size);
+extern int ibv_cmd_query_gid(struct ibv_context *context, uint8_t port_num,
+ int index, union ibv_gid *gid);
+extern int ibv_cmd_query_pkey(struct ibv_context *context, uint8_t port_num,
+ int index, uint16_t *pkey);
extern int ibv_cmd_alloc_pd(struct ibv_context *context, struct ibv_pd *pd,
struct ibv_alloc_pd *cmd, size_t cmd_size);
extern int ibv_cmd_dealloc_pd(struct ibv_pd *pd);
struct ibv_query_pkey_resp {
__u16 pkey;
+ __u16 reserved;
};
struct ibv_alloc_pd {
struct ibv_context_ops {
int (*query_port)(struct ibv_context *context, uint8_t port_num,
struct ibv_port_attr *port_attr);
+ int (*query_gid)(struct ibv_context *context, uint8_t port_num,
+ int index, union ibv_gid *gid);
+ int (*query_pkey)(struct ibv_context *context, uint8_t port_num,
+ int index, uint16_t *pkey);
struct ibv_pd * (*alloc_pd)(struct ibv_context *context);
int (*dealloc_pd)(struct ibv_pd *pd);
struct ibv_mr * (*reg_mr)(struct ibv_pd *pd, void *addr, size_t length,
extern int ibv_query_port(struct ibv_context *context, uint8_t port_num,
struct ibv_port_attr *port_attr);
+/**
+ * ibv_query_gid - Get a GID table entry
+ */
+extern int ibv_query_gid(struct ibv_context *context, uint8_t port_num,
+ int index, union ibv_gid *gid);
+
+/**
+ * ibv_query_pkey - Get a P_Key table entry
+ */
+extern int ibv_query_pkey(struct ibv_context *context, uint8_t port_num,
+ int index, uint16_t *pkey);
+
/**
* ibv_alloc_pd - Allocate a protection domain
*/
return 0;
}
+int ibv_cmd_query_gid(struct ibv_context *context, uint8_t port_num,
+ int index, union ibv_gid *gid)
+{
+ struct ibv_query_gid cmd;
+ struct ibv_query_gid_resp resp;
+
+ IBV_INIT_CMD_RESP(&cmd, sizeof cmd, QUERY_GID, &resp);
+ cmd.port_num = port_num;
+ cmd.index = index;
+
+ if (write(context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
+ return errno;
+
+ memcpy(gid->raw, resp.gid, 16);
+
+ return 0;
+}
+
+int ibv_cmd_query_pkey(struct ibv_context *context, uint8_t port_num,
+ int index, uint16_t *pkey)
+{
+ struct ibv_query_pkey cmd;
+ struct ibv_query_pkey_resp resp;
+
+ IBV_INIT_CMD_RESP(&cmd, sizeof cmd, QUERY_PKEY, &resp);
+ cmd.port_num = port_num;
+ cmd.index = index;
+
+ if (write(context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
+ return errno;
+
+ *pkey = resp.pkey;
+
+ return 0;
+}
+
int ibv_cmd_alloc_pd(struct ibv_context *context, struct ibv_pd *pd,
struct ibv_alloc_pd *cmd, size_t cmd_size)
{
ibv_close_device;
ibv_get_async_event;
ibv_query_port;
+ ibv_query_gid;
+ ibv_query_pkey;
ibv_alloc_pd;
ibv_dealloc_pd;
ibv_reg_mr;
ibv_detach_mcast;
ibv_cmd_get_context;
ibv_cmd_query_port;
+ ibv_cmd_query_gid;
+ ibv_cmd_query_pkey;
ibv_cmd_alloc_pd;
ibv_cmd_dealloc_pd;
ibv_cmd_reg_mr;
return context->ops.query_port(context, port_num, port_attr);
}
+int ibv_query_gid(struct ibv_context *context, uint8_t port_num,
+ int index, union ibv_gid *gid)
+{
+ return context->ops.query_gid(context, port_num, index, gid);
+}
+
+int ibv_query_pkey(struct ibv_context *context, uint8_t port_num,
+ int index, uint16_t *pkey)
+{
+ return context->ops.query_pkey(context, port_num, index, pkey);
+}
+
struct ibv_pd *ibv_alloc_pd(struct ibv_context *context)
{
struct ibv_pd *pd;