staging/rdma/hfi1: Remove create and free mad agents
authorDennis Dalessandro <dennis.dalessandro@intel.com>
Tue, 19 Jan 2016 22:44:11 +0000 (14:44 -0800)
committerDoug Ledford <dledford@redhat.com>
Fri, 11 Mar 2016 01:37:44 +0000 (20:37 -0500)
Get rid of create and free mad agent from the driver and use rdmavt
version.

Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/staging/rdma/hfi1/mad.c
drivers/staging/rdma/hfi1/verbs.c
drivers/staging/rdma/hfi1/verbs.h

index 6daf2770cc5662c3d8d54d23f5e21c4542de33bb..9cadf77427a2163b0a2ee30a6566b5b69342d1e6 100644 (file)
@@ -129,7 +129,7 @@ static void send_trap(struct hfi1_ibport *ibp, void *data, unsigned len)
        memcpy(smp->route.lid.data, data, len);
 
        spin_lock_irqsave(&ibp->rvp.lock, flags);
-       if (!ibp->sm_ah) {
+       if (!ibp->rvp.sm_ah) {
                if (ibp->rvp.sm_lid != be16_to_cpu(IB_LID_PERMISSIVE)) {
                        struct ib_ah *ah;
 
@@ -138,13 +138,13 @@ static void send_trap(struct hfi1_ibport *ibp, void *data, unsigned len)
                                ret = PTR_ERR(ah);
                        else {
                                send_buf->ah = ah;
-                               ibp->sm_ah = ibah_to_rvtah(ah);
+                               ibp->rvp.sm_ah = ibah_to_rvtah(ah);
                                ret = 0;
                        }
                } else
                        ret = -EINVAL;
        } else {
-               send_buf->ah = &ibp->sm_ah->ibah;
+               send_buf->ah = &ibp->rvp.sm_ah->ibah;
                ret = 0;
        }
        spin_unlock_irqrestore(&ibp->rvp.lock, flags);
@@ -1138,11 +1138,11 @@ static int __subn_set_opa_portinfo(struct opa_smp *smp, u32 am, u8 *data,
        } else if (smlid != ibp->rvp.sm_lid || msl != ibp->rvp.sm_sl) {
                pr_warn("SubnSet(OPA_PortInfo) smlid 0x%x\n", smlid);
                spin_lock_irqsave(&ibp->rvp.lock, flags);
-               if (ibp->sm_ah) {
+               if (ibp->rvp.sm_ah) {
                        if (smlid != ibp->rvp.sm_lid)
-                               ibp->sm_ah->attr.dlid = smlid;
+                               ibp->rvp.sm_ah->attr.dlid = smlid;
                        if (msl != ibp->rvp.sm_sl)
-                               ibp->sm_ah->attr.sl = msl;
+                               ibp->rvp.sm_ah->attr.sl = msl;
                }
                spin_unlock_irqrestore(&ibp->rvp.lock, flags);
                if (smlid != ibp->rvp.sm_lid)
@@ -4157,67 +4157,3 @@ int hfi1_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
 
        return IB_MAD_RESULT_FAILURE;
 }
-
-static void send_handler(struct ib_mad_agent *agent,
-                        struct ib_mad_send_wc *mad_send_wc)
-{
-       ib_free_send_mad(mad_send_wc->send_buf);
-}
-
-int hfi1_create_agents(struct hfi1_ibdev *dev)
-{
-       struct hfi1_devdata *dd = dd_from_dev(dev);
-       struct ib_mad_agent *agent;
-       struct hfi1_ibport *ibp;
-       int p;
-       int ret;
-
-       for (p = 0; p < dd->num_pports; p++) {
-               ibp = &dd->pport[p].ibport_data;
-               agent = ib_register_mad_agent(&dev->rdi.ibdev, p + 1,
-                                             IB_QPT_SMI,
-                                             NULL, 0, send_handler,
-                                             NULL, NULL, 0);
-               if (IS_ERR(agent)) {
-                       ret = PTR_ERR(agent);
-                       goto err;
-               }
-
-               ibp->rvp.send_agent = agent;
-       }
-
-       return 0;
-
-err:
-       for (p = 0; p < dd->num_pports; p++) {
-               ibp = &dd->pport[p].ibport_data;
-               if (ibp->rvp.send_agent) {
-                       agent = ibp->rvp.send_agent;
-                       ibp->rvp.send_agent = NULL;
-                       ib_unregister_mad_agent(agent);
-               }
-       }
-
-       return ret;
-}
-
-void hfi1_free_agents(struct hfi1_ibdev *dev)
-{
-       struct hfi1_devdata *dd = dd_from_dev(dev);
-       struct ib_mad_agent *agent;
-       struct hfi1_ibport *ibp;
-       int p;
-
-       for (p = 0; p < dd->num_pports; p++) {
-               ibp = &dd->pport[p].ibport_data;
-               if (ibp->rvp.send_agent) {
-                       agent = ibp->rvp.send_agent;
-                       ibp->rvp.send_agent = NULL;
-                       ib_unregister_mad_agent(agent);
-               }
-               if (ibp->sm_ah) {
-                       ib_destroy_ah(&ibp->sm_ah->ibah);
-                       ibp->sm_ah = NULL;
-               }
-       }
-}
index 67999150921c68e56de1027687adfd2c075b5147..68f4045dfa99aa494a08a81f117525b8a32c0eb1 100644 (file)
@@ -1590,27 +1590,19 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
 
        ret = rvt_register_device(&dd->verbs_dev.rdi);
        if (ret)
-               goto err_reg;
-
-       ret = hfi1_create_agents(dev);
-       if (ret)
-               goto err_agents;
+               goto err_verbs_txreq;
 
        ret = hfi1_verbs_register_sysfs(dd);
        if (ret)
                goto err_class;
 
-       goto bail;
+       return ret;
 
 err_class:
-       hfi1_free_agents(dev);
-err_agents:
        rvt_unregister_device(&dd->verbs_dev.rdi);
-err_reg:
 err_verbs_txreq:
        kmem_cache_destroy(dev->verbs_txreq_cache);
        dd_dev_err(dd, "cannot register verbs: %d!\n", -ret);
-bail:
        return ret;
 }
 
@@ -1620,8 +1612,6 @@ void hfi1_unregister_ib_device(struct hfi1_devdata *dd)
 
        hfi1_verbs_unregister_sysfs(dd);
 
-       hfi1_free_agents(dev);
-
        rvt_unregister_device(&dd->verbs_dev.rdi);
 
        if (!list_empty(&dev->txwait))
index f2c8a212104cdc8494e44a9c14d1b2a54ff15f8e..c845514d3abf860f41dcff92bd0830fa9cc0cc34 100644 (file)
@@ -247,8 +247,6 @@ static inline void inc_opstats(
 struct hfi1_ibport {
        struct rvt_qp __rcu *qp[2];
        struct rvt_ibport rvp;
-       struct rvt_ah *sm_ah;
-       struct rvt_ah *smi_ah;
 
        __be64 guids[HFI1_GUIDS_PER_PORT        - 1];   /* writable GUIDs */
 
@@ -340,8 +338,6 @@ int hfi1_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,
                     const struct ib_mad_hdr *in_mad, size_t in_mad_size,
                     struct ib_mad_hdr *out_mad, size_t *out_mad_size,
                     u16 *out_mad_pkey_index);
-int hfi1_create_agents(struct hfi1_ibdev *dev);
-void hfi1_free_agents(struct hfi1_ibdev *dev);
 
 /*
  * The PSN_MASK and PSN_SHIFT allow for