IB/iser: Keep IB device attributes under iser_device
authorSagi Grimberg <sagig@mellanox.com>
Wed, 5 Mar 2014 17:43:42 +0000 (19:43 +0200)
committerRoland Dreier <roland@purestorage.com>
Tue, 18 Mar 2014 05:33:57 +0000 (22:33 -0700)
For T10-PI offload support, we will need to know the device signature
offload capability upon every connection establishment.

This patch does not change any functionality.

Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Alex Tabachnik <alext@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/ulp/iser/iscsi_iser.h
drivers/infiniband/ulp/iser/iser_verbs.c

index ca161dfeee48caa07ed67c063a1c22432f661b18..b4290f509a39eea425adc8121d792b8561396e73 100644 (file)
@@ -260,6 +260,7 @@ struct iscsi_iser_task;
 struct iser_device {
        struct ib_device             *ib_device;
        struct ib_pd                 *pd;
+       struct ib_device_attr        dev_attr;
        struct ib_cq                 *rx_cq[ISER_MAX_CQ];
        struct ib_cq                 *tx_cq[ISER_MAX_CQ];
        struct ib_mr                 *mr;
index 9569e402d3680dac69fd591be8eead0f003966f4..95fcfcac0100e8760719fbe75370bca8dc84f617 100644 (file)
@@ -71,17 +71,14 @@ static void iser_event_handler(struct ib_event_handler *handler,
  */
 static int iser_create_device_ib_res(struct iser_device *device)
 {
-       int i, j;
        struct iser_cq_desc *cq_desc;
-       struct ib_device_attr *dev_attr;
+       struct ib_device_attr *dev_attr = &device->dev_attr;
+       int ret, i, j;
 
-       dev_attr = kmalloc(sizeof(*dev_attr), GFP_KERNEL);
-       if (!dev_attr)
-               return -ENOMEM;
-
-       if (ib_query_device(device->ib_device, dev_attr)) {
+       ret = ib_query_device(device->ib_device, dev_attr);
+       if (ret) {
                pr_warn("Query device failed for %s\n", device->ib_device->name);
-               goto dev_attr_err;
+               return ret;
        }
 
        /* Assign function handles  - based on FMR support */
@@ -101,7 +98,7 @@ static int iser_create_device_ib_res(struct iser_device *device)
                device->iser_unreg_rdma_mem = iser_unreg_mem_fastreg;
        } else {
                iser_err("IB device does not support FMRs nor FastRegs, can't register memory\n");
-               goto dev_attr_err;
+               return -1;
        }
 
        device->cqs_used = min(ISER_MAX_CQ, device->ib_device->num_comp_vectors);
@@ -158,7 +155,6 @@ static int iser_create_device_ib_res(struct iser_device *device)
        if (ib_register_event_handler(&device->event_handler))
                goto handler_err;
 
-       kfree(dev_attr);
        return 0;
 
 handler_err:
@@ -178,8 +174,6 @@ pd_err:
        kfree(device->cq_desc);
 cq_desc_err:
        iser_err("failed to allocate an IB resource\n");
-dev_attr_err:
-       kfree(dev_attr);
        return -1;
 }