]> git.openfabrics.org - ~shefty/libibverbs.git/commitdiff
Add generic userspace part of query GID and query P_Key verbs
authorRoland Dreier <roland@topspin.com>
Tue, 31 May 2005 15:56:49 +0000 (15:56 +0000)
committerRoland Dreier <rolandd@cisco.com>
Thu, 9 Nov 2006 19:35:56 +0000 (11:35 -0800)
Signed-off-by: Roland Dreier <roland@topspin.com>
include/infiniband/driver.h
include/infiniband/kern-abi.h
include/infiniband/verbs.h
src/cmd.c
src/libibverbs.map
src/verbs.c

index 7d89af4bfadbfe0bc4c8e73619b9c950dc6f9740..45279e33748271ac366d058645ce956b31c11736 100644 (file)
@@ -68,6 +68,10 @@ extern int ibv_cmd_get_context(int num_comp, struct ibv_context *context,
 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);
index 25137c2db3719abadfe708d4b425af764eb59b60..8166c83c0aa3b5ccec50f4e6f9cdbb73a9fae9b6 100644 (file)
@@ -196,6 +196,7 @@ struct ibv_query_pkey {
 
 struct ibv_query_pkey_resp {
        __u16 pkey;
+       __u16 reserved;
 };
 
 struct ibv_alloc_pd {
index 57d4016ca0b178eebda68492c09a37b2514bdee0..602d6971c0d97967dad8b44579d8e6e6be2a1124 100644 (file)
@@ -414,6 +414,10 @@ struct ibv_device {
 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,
@@ -486,6 +490,18 @@ extern int ibv_get_async_event(struct ibv_context *context,
 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
  */
index 2a4ffefb435fadeb720a5c00ed54b8fe17cb7817..4e74495ca1e976569ab5a8d6fd42d6a13160e84c 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -97,6 +97,42 @@ int ibv_cmd_query_port(struct ibv_context *context, uint8_t port_num,
        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)
 {
index 0a812ddc331bef6b0b16e6599bce5dfe8dc675be..64a4f6a5c80fa44c852b3f22c5298885146a7fd2 100644 (file)
@@ -7,6 +7,8 @@ IBVERBS_1.0 {
                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;
@@ -23,6 +25,8 @@ IBVERBS_1.0 {
                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;
index c732d4b28b409ba31f9b034bb6f61f3f3dd1d190..94830b4b4a885d07cdc4cb18b33308dfd9da19c1 100644 (file)
@@ -48,6 +48,18 @@ int ibv_query_port(struct ibv_context *context, uint8_t port_num,
        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;