}
        spin_unlock_irq(&port_priv->reg_lock);
 
+       trace_ib_mad_create_agent(mad_agent_priv);
        return &mad_agent_priv->agent;
 error6:
        spin_unlock_irq(&port_priv->reg_lock);
        struct ib_mad_port_private *port_priv;
 
        /* Note that we could still be handling received MADs */
+       trace_ib_mad_unregister_agent(mad_agent_priv);
 
        /*
         * Canceling all sends results in dropping received response
 
        mad_agent = find_mad_agent(port_priv, (const struct ib_mad_hdr *)recv->mad);
        if (mad_agent) {
+               trace_ib_mad_recv_done_agent(mad_agent);
                ib_mad_complete_recv(mad_agent, &recv->header.recv_wc);
                /*
                 * recv is freed up in error cases in ib_mad_complete_recv
        send_queue = mad_list->mad_queue;
        qp_info = send_queue->qp_info;
 
+       trace_ib_mad_send_done_agent(mad_send_wr->mad_agent_priv);
        trace_ib_mad_send_done_handler(mad_send_wr, wc);
 
 retry:
 
        )
 );
 
+DECLARE_EVENT_CLASS(ib_mad_agent_template,
+       TP_PROTO(struct ib_mad_agent_private *agent),
+       TP_ARGS(agent),
+
+       TP_STRUCT__entry(
+               __field(u32,            dev_index)
+               __field(u32,            hi_tid)
+               __field(u8,             port_num)
+               __field(u8,             mgmt_class)
+               __field(u8,             mgmt_class_version)
+       ),
+
+       TP_fast_assign(
+               __entry->dev_index = agent->agent.device->index;
+               __entry->port_num = agent->agent.port_num;
+               __entry->hi_tid = agent->agent.hi_tid;
+
+               if (agent->reg_req) {
+                       __entry->mgmt_class = agent->reg_req->mgmt_class;
+                       __entry->mgmt_class_version =
+                               agent->reg_req->mgmt_class_version;
+               } else {
+                       __entry->mgmt_class = 0;
+                       __entry->mgmt_class_version = 0;
+               }
+       ),
+
+       TP_printk("%d:%d mad agent : hi_tid 0x%08x class 0x%02x class_ver 0x%02x",
+               __entry->dev_index, __entry->port_num,
+               __entry->hi_tid, __entry->mgmt_class,
+               __entry->mgmt_class_version
+       )
+);
+DEFINE_EVENT(ib_mad_agent_template, ib_mad_recv_done_agent,
+       TP_PROTO(struct ib_mad_agent_private *agent),
+       TP_ARGS(agent));
+DEFINE_EVENT(ib_mad_agent_template, ib_mad_send_done_agent,
+       TP_PROTO(struct ib_mad_agent_private *agent),
+       TP_ARGS(agent));
+DEFINE_EVENT(ib_mad_agent_template, ib_mad_create_agent,
+       TP_PROTO(struct ib_mad_agent_private *agent),
+       TP_ARGS(agent));
+DEFINE_EVENT(ib_mad_agent_template, ib_mad_unregister_agent,
+       TP_PROTO(struct ib_mad_agent_private *agent),
+       TP_ARGS(agent));
+
 
 #endif /* _TRACE_IB_MAD_H */