[openib-general] [PATCH] ib_smi: Add PMA support

Hal Rosenstock
Fri Oct 8 07:16:49 PDT 2004


ib_smi: Add PMA support

Index: ib_smi_priv.h
===================================================================
--- ib_smi_priv.h       (revision 960)
+++ ib_smi_priv.h       (working copy)
@@ -41,6 +41,7 @@
        int port_num;
        struct ib_mad_agent *mad_agent; /* DR SM class */
        struct ib_mad_agent *mad_agent2; /* LR SM class */
+       struct ib_mad_agent *pma_mad_agent; /* PerfMgt class */
        struct ib_mr *mr;
        u64 wr_id;
 };
Index: ib_smi.c
===================================================================
--- ib_smi.c    (revision 960)
+++ ib_smi.c    (working copy)
@@ -124,7 +124,7 @@
        {
        case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
                return smi_handle_dr_smp_send(mad_agent, smp);
-       default:
+       default:        /* LR SM or PerfMgt classes */
                return 1;
        }
 }
@@ -137,7 +137,7 @@
 {
        /* C14-9:3 -- We're at the end of the DR segment of path */
        /* C14-9:4 -- Hop Pointer = Hop Count + 1 -> give to SMA/SM. */
-       return ((smp->mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED) ||
+       return ((smp->mgmt_class != IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) ||
                (mad_agent->device->process_mad &&
                !ib_get_smp_direction(smp) &&
                (smp->hop_ptr == smp->hop_cnt + 1)));
@@ -230,7 +230,7 @@
        {
        case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
                return smi_handle_dr_smp_recv(mad_agent, smp);
-       default:
+       default:        /* LR SM or PerfMgt classes */
                return 1;
        }
 }
@@ -282,7 +282,7 @@
        {
        case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
                return smi_check_forward_dr_smp(mad_agent, smp);
-       default:
+       default:        /* LR SM or PerfMgt classes */
                return 1;
        }
 }
@@ -314,7 +314,8 @@
        spin_lock_irqsave(&ib_smi_port_list_lock, flags);
        list_for_each_entry(entry, &ib_smi_port_list, port_list) {
                if ((entry->mad_agent == mad_agent) ||
-                   (entry->mad_agent2 == mad_agent)) { 
+                   (entry->mad_agent2 == mad_agent) ||
+                   (entry->pma_mad_agent == mad_agent)) { 
                        port_priv = entry;
                        break;
                }
@@ -363,7 +364,13 @@
        }
                                                                                 
        send_wr.wr.ud.ah = ah;
-       send_wr.wr.ud.remote_qkey = 0; /* for SMPs */
+       if (smp->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT) {
+               send_wr.wr.ud.pkey_index = mad_recv_wc->wc->pkey_index;
+               send_wr.wr.ud.remote_qkey = IB_QP1_QKEY;
+       } else {
+               send_wr.wr.ud.pkey_index = 0; /* Should only matter for GMPs */
+               send_wr.wr.ud.remote_qkey = 0; /* for SMPs */
+       }
        send_wr.wr.ud.mad_hdr = (struct ib_mad_hdr *)smp;
        send_wr.wr_id = ++port_priv->wr_id;
 
@@ -451,7 +458,8 @@
        spin_lock_irqsave(&ib_smi_port_list_lock, flags);
        list_for_each_entry(entry, &ib_smi_port_list, port_list) {
                if ((entry->mad_agent == mad_agent) ||
-                   (entry->mad_agent2 == mad_agent)) {
+                   (entry->mad_agent2 == mad_agent) ||
+                   (entry->pma_mad_agent == mad_agent)) {
                        port_priv = entry;
                        break;
                }
@@ -581,13 +589,26 @@
                goto error3;
        }
 
+        /* Obtain MAD agent for PerfMgt class */
+        reg_req.mgmt_class = IB_MGMT_CLASS_PERF_MGMT;
+        port_priv->pma_mad_agent = ib_register_mad_agent(device,
port_num,
+                                                        IB_QPT_GSI,
+                                                       &reg_req, 0,
+                                                       &smi_send_handler,
+                                                       &smi_recv_handler,
+                                                        NULL);
+       if (IS_ERR(port_priv->pma_mad_agent)) {
+               ret = PTR_ERR(port_priv->pma_mad_agent);
+               goto error4;
+       }
+
        port_priv->mr = ib_reg_phys_mr(port_priv->mad_agent->qp->pd,
                                      &buf_list, 1,
                                       IB_ACCESS_LOCAL_WRITE, &iova);
        if (IS_ERR(port_priv->mr)) {
                printk(KERN_ERR "Couldn't register MR\n");
                ret = PTR_ERR(port_priv->mr);
-               goto error4;
+               goto error5;
        } 
 
        spin_lock_irqsave(&ib_smi_port_list_lock, flags);
@@ -596,6 +617,8 @@
 
        return 0;
 
+error5:
+       ib_unregister_mad_agent(port_priv->pma_mad_agent);
 error4:
        ib_unregister_mad_agent(port_priv->mad_agent2);
 error3:
@@ -630,6 +653,7 @@
        spin_unlock_irqrestore(&ib_smi_port_list_lock, flags);
 
        ib_dereg_mr(port_priv->mr);
+       ib_unregister_mad_agent(port_priv->pma_mad_agent);
        ib_unregister_mad_agent(port_priv->mad_agent2);
        ib_unregister_mad_agent(port_priv->mad_agent);
         kfree(port_priv);





More information about the openib-general mailing list