IB/mad cleanup: Clean up function params -- find_mad_agent
find_mad_agent only needs read only access to the MAD header. Update the ib_mad pointer to be const ib_mad_hdr. Adjust call tree. Signed-off-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
@@ -73,7 +73,7 @@ static int method_in_use(struct ib_mad_mgmt_method_table **method,
|
|||||||
static void remove_mad_reg_req(struct ib_mad_agent_private *priv);
|
static void remove_mad_reg_req(struct ib_mad_agent_private *priv);
|
||||||
static struct ib_mad_agent_private *find_mad_agent(
|
static struct ib_mad_agent_private *find_mad_agent(
|
||||||
struct ib_mad_port_private *port_priv,
|
struct ib_mad_port_private *port_priv,
|
||||||
struct ib_mad *mad);
|
const struct ib_mad_hdr *mad);
|
||||||
static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
|
static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
|
||||||
struct ib_mad_private *mad);
|
struct ib_mad_private *mad);
|
||||||
static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv);
|
static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv);
|
||||||
@@ -813,7 +813,7 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
|
|||||||
if (port_priv) {
|
if (port_priv) {
|
||||||
memcpy(&mad_priv->mad.mad, smp, sizeof(struct ib_mad));
|
memcpy(&mad_priv->mad.mad, smp, sizeof(struct ib_mad));
|
||||||
recv_mad_agent = find_mad_agent(port_priv,
|
recv_mad_agent = find_mad_agent(port_priv,
|
||||||
&mad_priv->mad.mad);
|
&mad_priv->mad.mad.mad_hdr);
|
||||||
}
|
}
|
||||||
if (!port_priv || !recv_mad_agent) {
|
if (!port_priv || !recv_mad_agent) {
|
||||||
/*
|
/*
|
||||||
@@ -1324,7 +1324,7 @@ static int check_vendor_class(struct ib_mad_mgmt_vendor_class *vendor_class)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int find_vendor_oui(struct ib_mad_mgmt_vendor_class *vendor_class,
|
static int find_vendor_oui(struct ib_mad_mgmt_vendor_class *vendor_class,
|
||||||
char *oui)
|
const char *oui)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -1622,13 +1622,13 @@ out:
|
|||||||
|
|
||||||
static struct ib_mad_agent_private *
|
static struct ib_mad_agent_private *
|
||||||
find_mad_agent(struct ib_mad_port_private *port_priv,
|
find_mad_agent(struct ib_mad_port_private *port_priv,
|
||||||
struct ib_mad *mad)
|
const struct ib_mad_hdr *mad_hdr)
|
||||||
{
|
{
|
||||||
struct ib_mad_agent_private *mad_agent = NULL;
|
struct ib_mad_agent_private *mad_agent = NULL;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&port_priv->reg_lock, flags);
|
spin_lock_irqsave(&port_priv->reg_lock, flags);
|
||||||
if (ib_response_mad(&mad->mad_hdr)) {
|
if (ib_response_mad(mad_hdr)) {
|
||||||
u32 hi_tid;
|
u32 hi_tid;
|
||||||
struct ib_mad_agent_private *entry;
|
struct ib_mad_agent_private *entry;
|
||||||
|
|
||||||
@@ -1636,7 +1636,7 @@ find_mad_agent(struct ib_mad_port_private *port_priv,
|
|||||||
* Routing is based on high 32 bits of transaction ID
|
* Routing is based on high 32 bits of transaction ID
|
||||||
* of MAD.
|
* of MAD.
|
||||||
*/
|
*/
|
||||||
hi_tid = be64_to_cpu(mad->mad_hdr.tid) >> 32;
|
hi_tid = be64_to_cpu(mad_hdr->tid) >> 32;
|
||||||
list_for_each_entry(entry, &port_priv->agent_list, agent_list) {
|
list_for_each_entry(entry, &port_priv->agent_list, agent_list) {
|
||||||
if (entry->agent.hi_tid == hi_tid) {
|
if (entry->agent.hi_tid == hi_tid) {
|
||||||
mad_agent = entry;
|
mad_agent = entry;
|
||||||
@@ -1648,45 +1648,45 @@ find_mad_agent(struct ib_mad_port_private *port_priv,
|
|||||||
struct ib_mad_mgmt_method_table *method;
|
struct ib_mad_mgmt_method_table *method;
|
||||||
struct ib_mad_mgmt_vendor_class_table *vendor;
|
struct ib_mad_mgmt_vendor_class_table *vendor;
|
||||||
struct ib_mad_mgmt_vendor_class *vendor_class;
|
struct ib_mad_mgmt_vendor_class *vendor_class;
|
||||||
struct ib_vendor_mad *vendor_mad;
|
const struct ib_vendor_mad *vendor_mad;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Routing is based on version, class, and method
|
* Routing is based on version, class, and method
|
||||||
* For "newer" vendor MADs, also based on OUI
|
* For "newer" vendor MADs, also based on OUI
|
||||||
*/
|
*/
|
||||||
if (mad->mad_hdr.class_version >= MAX_MGMT_VERSION)
|
if (mad_hdr->class_version >= MAX_MGMT_VERSION)
|
||||||
goto out;
|
goto out;
|
||||||
if (!is_vendor_class(mad->mad_hdr.mgmt_class)) {
|
if (!is_vendor_class(mad_hdr->mgmt_class)) {
|
||||||
class = port_priv->version[
|
class = port_priv->version[
|
||||||
mad->mad_hdr.class_version].class;
|
mad_hdr->class_version].class;
|
||||||
if (!class)
|
if (!class)
|
||||||
goto out;
|
goto out;
|
||||||
if (convert_mgmt_class(mad->mad_hdr.mgmt_class) >=
|
if (convert_mgmt_class(mad_hdr->mgmt_class) >=
|
||||||
IB_MGMT_MAX_METHODS)
|
IB_MGMT_MAX_METHODS)
|
||||||
goto out;
|
goto out;
|
||||||
method = class->method_table[convert_mgmt_class(
|
method = class->method_table[convert_mgmt_class(
|
||||||
mad->mad_hdr.mgmt_class)];
|
mad_hdr->mgmt_class)];
|
||||||
if (method)
|
if (method)
|
||||||
mad_agent = method->agent[mad->mad_hdr.method &
|
mad_agent = method->agent[mad_hdr->method &
|
||||||
~IB_MGMT_METHOD_RESP];
|
~IB_MGMT_METHOD_RESP];
|
||||||
} else {
|
} else {
|
||||||
vendor = port_priv->version[
|
vendor = port_priv->version[
|
||||||
mad->mad_hdr.class_version].vendor;
|
mad_hdr->class_version].vendor;
|
||||||
if (!vendor)
|
if (!vendor)
|
||||||
goto out;
|
goto out;
|
||||||
vendor_class = vendor->vendor_class[vendor_class_index(
|
vendor_class = vendor->vendor_class[vendor_class_index(
|
||||||
mad->mad_hdr.mgmt_class)];
|
mad_hdr->mgmt_class)];
|
||||||
if (!vendor_class)
|
if (!vendor_class)
|
||||||
goto out;
|
goto out;
|
||||||
/* Find matching OUI */
|
/* Find matching OUI */
|
||||||
vendor_mad = (struct ib_vendor_mad *)mad;
|
vendor_mad = (const struct ib_vendor_mad *)mad_hdr;
|
||||||
index = find_vendor_oui(vendor_class, vendor_mad->oui);
|
index = find_vendor_oui(vendor_class, vendor_mad->oui);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
goto out;
|
goto out;
|
||||||
method = vendor_class->method_table[index];
|
method = vendor_class->method_table[index];
|
||||||
if (method) {
|
if (method) {
|
||||||
mad_agent = method->agent[mad->mad_hdr.method &
|
mad_agent = method->agent[mad_hdr->method &
|
||||||
~IB_MGMT_METHOD_RESP];
|
~IB_MGMT_METHOD_RESP];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2056,7 +2056,7 @@ local:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mad_agent = find_mad_agent(port_priv, &recv->mad.mad);
|
mad_agent = find_mad_agent(port_priv, &recv->mad.mad.mad_hdr);
|
||||||
if (mad_agent) {
|
if (mad_agent) {
|
||||||
ib_mad_complete_recv(mad_agent, &recv->header.recv_wc);
|
ib_mad_complete_recv(mad_agent, &recv->header.recv_wc);
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user