Skip to content

Commit

Permalink
IB/mad: Change ib_response_mad signature arguments
Browse files Browse the repository at this point in the history
ib_response_mad only needs read access to the MAD header, not write access
to the entire mad struct, so replace struct ib_mad with const struct
ib_mad_hdr

Reviewed-By: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
  • Loading branch information
Ira Weiny authored and Doug Ledford committed May 20, 2015
1 parent 77f6083 commit 9690930
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions drivers/infiniband/core/mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ static int is_vendor_method_in_use(
return 0;
}

int ib_response_mad(struct ib_mad *mad)
int ib_response_mad(const struct ib_mad_hdr *hdr)
{
return ((mad->mad_hdr.method & IB_MGMT_METHOD_RESP) ||
(mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS) ||
((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_BM) &&
(mad->mad_hdr.attr_mod & IB_BM_ATTR_MOD_RESP)));
return ((hdr->method & IB_MGMT_METHOD_RESP) ||
(hdr->method == IB_MGMT_METHOD_TRAP_REPRESS) ||
((hdr->mgmt_class == IB_MGMT_CLASS_BM) &&
(hdr->attr_mod & IB_BM_ATTR_MOD_RESP)));
}
EXPORT_SYMBOL(ib_response_mad);

Expand Down Expand Up @@ -791,7 +791,7 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
switch (ret)
{
case IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY:
if (ib_response_mad(&mad_priv->mad.mad) &&
if (ib_response_mad(&mad_priv->mad.mad.mad_hdr) &&
mad_agent_priv->agent.recv_handler) {
local->mad_priv = mad_priv;
local->recv_mad_agent = mad_agent_priv;
Expand Down Expand Up @@ -1628,7 +1628,7 @@ find_mad_agent(struct ib_mad_port_private *port_priv,
unsigned long flags;

spin_lock_irqsave(&port_priv->reg_lock, flags);
if (ib_response_mad(mad)) {
if (ib_response_mad(&mad->mad_hdr)) {
u32 hi_tid;
struct ib_mad_agent_private *entry;

Expand Down Expand Up @@ -1765,8 +1765,8 @@ static inline int rcv_has_same_gid(struct ib_mad_agent_private *mad_agent_priv,
u8 port_num = mad_agent_priv->agent.port_num;
u8 lmc;

send_resp = ib_response_mad((struct ib_mad *)wr->send_buf.mad);
rcv_resp = ib_response_mad(rwc->recv_buf.mad);
send_resp = ib_response_mad((struct ib_mad_hdr *)wr->send_buf.mad);
rcv_resp = ib_response_mad(&rwc->recv_buf.mad->mad_hdr);

if (send_resp == rcv_resp)
/* both requests, or both responses. GIDs different */
Expand Down Expand Up @@ -1879,7 +1879,7 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
}

/* Complete corresponding request */
if (ib_response_mad(mad_recv_wc->recv_buf.mad)) {
if (ib_response_mad(&mad_recv_wc->recv_buf.mad->mad_hdr)) {
spin_lock_irqsave(&mad_agent_priv->lock, flags);
mad_send_wr = ib_find_send_mad(mad_agent_priv, mad_recv_wc);
if (!mad_send_wr) {
Expand Down
6 changes: 3 additions & 3 deletions drivers/infiniband/core/user_mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,11 @@ static int is_duplicate(struct ib_umad_file *file,
* the same TID, reject the second as a duplicate. This is more
* restrictive than required by the spec.
*/
if (!ib_response_mad((struct ib_mad *) hdr)) {
if (!ib_response_mad((struct ib_mad *) sent_hdr))
if (!ib_response_mad(hdr)) {
if (!ib_response_mad(sent_hdr))
return 1;
continue;
} else if (!ib_response_mad((struct ib_mad *) sent_hdr))
} else if (!ib_response_mad(sent_hdr))
continue;

if (same_destination(&packet->mad.hdr, &sent_packet->mad.hdr))
Expand Down
2 changes: 1 addition & 1 deletion include/rdma/ib_mad.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ struct ib_mad_send_buf {
* ib_response_mad - Returns if the specified MAD has been generated in
* response to a sent request or trap.
*/
int ib_response_mad(struct ib_mad *mad);
int ib_response_mad(const struct ib_mad_hdr *hdr);

/**
* ib_get_rmpp_resptime - Returns the RMPP response time.
Expand Down

0 comments on commit 9690930

Please sign in to comment.