IB/core: Add subnet prefix to port info
authorEli Cohen <eli@mellanox.com>
Fri, 11 Mar 2016 20:58:36 +0000 (22:58 +0200)
committerDoug Ledford <dledford@redhat.com>
Mon, 21 Mar 2016 20:34:06 +0000 (16:34 -0400)
The subnet prefix is a part of the port_info MAD returned and should be
available at the ib_port_attr struct. We define it here and provide a
default implementation in case the hardware driver does not provide one.
The subnet prefix is required when creating the address vector to access
the SA in networks where GRH must be used.

Signed-off-by: Eli Cohen <eli@mellanox.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/device.c
include/rdma/ib_verbs.h

index 270c7ff6cba7870d86a7c5d81eeced269011e2df..10979844026a01bda540a6f99d2cef0ef56b525f 100644 (file)
@@ -650,10 +650,23 @@ int ib_query_port(struct ib_device *device,
                  u8 port_num,
                  struct ib_port_attr *port_attr)
 {
+       union ib_gid gid;
+       int err;
+
        if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
                return -EINVAL;
 
-       return device->query_port(device, port_num, port_attr);
+       memset(port_attr, 0, sizeof(*port_attr));
+       err = device->query_port(device, port_num, port_attr);
+       if (err || port_attr->subnet_prefix)
+               return err;
+
+       err = ib_query_gid(device, port_num, 0, &gid, NULL);
+       if (err)
+               return err;
+
+       port_attr->subnet_prefix = be64_to_cpu(gid.global.subnet_prefix);
+       return 0;
 }
 EXPORT_SYMBOL(ib_query_port);
 
index c9b62344d22ebaa37af9a36bbe24fbc10adb6ea2..7239b9a4499e857d251158b4616527ea23ddc985 100644 (file)
@@ -490,6 +490,7 @@ union rdma_protocol_stats {
                                        | RDMA_CORE_CAP_OPA_MAD)
 
 struct ib_port_attr {
+       u64                     subnet_prefix;
        enum ib_port_state      state;
        enum ib_mtu             max_mtu;
        enum ib_mtu             active_mtu;
This page took 0.027953 seconds and 5 git commands to generate.