aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIra Weiny <ira.weiny@intel.com>2015-06-06 14:38:22 -0400
committerDoug Ledford <dledford@redhat.com>2015-06-12 14:49:16 -0400
commitd94bd2667a78ecbc64296588a8272e97a61dbafd (patch)
tree26ebacd959f57aeba1b63650e12cab4f84595b1b
parent4b664c4355b251a142d9d57d0ca0298b497f8428 (diff)
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>
-rw-r--r--drivers/infiniband/core/mad.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 533c0b2e7a63..309eaa191c3e 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -73,7 +73,7 @@ static int method_in_use(struct ib_mad_mgmt_method_table **method,
73static void remove_mad_reg_req(struct ib_mad_agent_private *priv); 73static void remove_mad_reg_req(struct ib_mad_agent_private *priv);
74static struct ib_mad_agent_private *find_mad_agent( 74static struct ib_mad_agent_private *find_mad_agent(
75 struct ib_mad_port_private *port_priv, 75 struct ib_mad_port_private *port_priv,
76 struct ib_mad *mad); 76 const struct ib_mad_hdr *mad);
77static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info, 77static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
78 struct ib_mad_private *mad); 78 struct ib_mad_private *mad);
79static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv); 79static 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,
813 if (port_priv) { 813 if (port_priv) {
814 memcpy(&mad_priv->mad.mad, smp, sizeof(struct ib_mad)); 814 memcpy(&mad_priv->mad.mad, smp, sizeof(struct ib_mad));
815 recv_mad_agent = find_mad_agent(port_priv, 815 recv_mad_agent = find_mad_agent(port_priv,
816 &mad_priv->mad.mad); 816 &mad_priv->mad.mad.mad_hdr);
817 } 817 }
818 if (!port_priv || !recv_mad_agent) { 818 if (!port_priv || !recv_mad_agent) {
819 /* 819 /*
@@ -1324,7 +1324,7 @@ static int check_vendor_class(struct ib_mad_mgmt_vendor_class *vendor_class)
1324} 1324}
1325 1325
1326static int find_vendor_oui(struct ib_mad_mgmt_vendor_class *vendor_class, 1326static int find_vendor_oui(struct ib_mad_mgmt_vendor_class *vendor_class,
1327 char *oui) 1327 const char *oui)
1328{ 1328{
1329 int i; 1329 int i;
1330 1330
@@ -1622,13 +1622,13 @@ out:
1622 1622
1623static struct ib_mad_agent_private * 1623static struct ib_mad_agent_private *
1624find_mad_agent(struct ib_mad_port_private *port_priv, 1624find_mad_agent(struct ib_mad_port_private *port_priv,
1625 struct ib_mad *mad) 1625 const struct ib_mad_hdr *mad_hdr)
1626{ 1626{
1627 struct ib_mad_agent_private *mad_agent = NULL; 1627 struct ib_mad_agent_private *mad_agent = NULL;
1628 unsigned long flags; 1628 unsigned long flags;
1629 1629
1630 spin_lock_irqsave(&port_priv->reg_lock, flags); 1630 spin_lock_irqsave(&port_priv->reg_lock, flags);
1631 if (ib_response_mad(&mad->mad_hdr)) { 1631 if (ib_response_mad(mad_hdr)) {
1632 u32 hi_tid; 1632 u32 hi_tid;
1633 struct ib_mad_agent_private *entry; 1633 struct ib_mad_agent_private *entry;
1634 1634
@@ -1636,7 +1636,7 @@ find_mad_agent(struct ib_mad_port_private *port_priv,
1636 * Routing is based on high 32 bits of transaction ID 1636 * Routing is based on high 32 bits of transaction ID
1637 * of MAD. 1637 * of MAD.
1638 */ 1638 */
1639 hi_tid = be64_to_cpu(mad->mad_hdr.tid) >> 32; 1639 hi_tid = be64_to_cpu(mad_hdr->tid) >> 32;
1640 list_for_each_entry(entry, &port_priv->agent_list, agent_list) { 1640 list_for_each_entry(entry, &port_priv->agent_list, agent_list) {
1641 if (entry->agent.hi_tid == hi_tid) { 1641 if (entry->agent.hi_tid == hi_tid) {
1642 mad_agent = entry; 1642 mad_agent = entry;
@@ -1648,45 +1648,45 @@ find_mad_agent(struct ib_mad_port_private *port_priv,
1648 struct ib_mad_mgmt_method_table *method; 1648 struct ib_mad_mgmt_method_table *method;
1649 struct ib_mad_mgmt_vendor_class_table *vendor; 1649 struct ib_mad_mgmt_vendor_class_table *vendor;
1650 struct ib_mad_mgmt_vendor_class *vendor_class; 1650 struct ib_mad_mgmt_vendor_class *vendor_class;
1651 struct ib_vendor_mad *vendor_mad; 1651 const struct ib_vendor_mad *vendor_mad;
1652 int index; 1652 int index;
1653 1653
1654 /* 1654 /*
1655 * Routing is based on version, class, and method 1655 * Routing is based on version, class, and method
1656 * For "newer" vendor MADs, also based on OUI 1656 * For "newer" vendor MADs, also based on OUI
1657 */ 1657 */
1658 if (mad->mad_hdr.class_version >= MAX_MGMT_VERSION) 1658 if (mad_hdr->class_version >= MAX_MGMT_VERSION)
1659 goto out; 1659 goto out;
1660 if (!is_vendor_class(mad->mad_hdr.mgmt_class)) { 1660 if (!is_vendor_class(mad_hdr->mgmt_class)) {
1661 class = port_priv->version[ 1661 class = port_priv->version[
1662 mad->mad_hdr.class_version].class; 1662 mad_hdr->class_version].class;
1663 if (!class) 1663 if (!class)
1664 goto out; 1664 goto out;
1665 if (convert_mgmt_class(mad->mad_hdr.mgmt_class) >= 1665 if (convert_mgmt_class(mad_hdr->mgmt_class) >=
1666 IB_MGMT_MAX_METHODS) 1666 IB_MGMT_MAX_METHODS)
1667 goto out; 1667 goto out;
1668 method = class->method_table[convert_mgmt_class( 1668 method = class->method_table[convert_mgmt_class(
1669 mad->mad_hdr.mgmt_class)]; 1669 mad_hdr->mgmt_class)];
1670 if (method) 1670 if (method)
1671 mad_agent = method->agent[mad->mad_hdr.method & 1671 mad_agent = method->agent[mad_hdr->method &
1672 ~IB_MGMT_METHOD_RESP]; 1672 ~IB_MGMT_METHOD_RESP];
1673 } else { 1673 } else {
1674 vendor = port_priv->version[ 1674 vendor = port_priv->version[
1675 mad->mad_hdr.class_version].vendor; 1675 mad_hdr->class_version].vendor;
1676 if (!vendor) 1676 if (!vendor)
1677 goto out; 1677 goto out;
1678 vendor_class = vendor->vendor_class[vendor_class_index( 1678 vendor_class = vendor->vendor_class[vendor_class_index(
1679 mad->mad_hdr.mgmt_class)]; 1679 mad_hdr->mgmt_class)];
1680 if (!vendor_class) 1680 if (!vendor_class)
1681 goto out; 1681 goto out;
1682 /* Find matching OUI */ 1682 /* Find matching OUI */
1683 vendor_mad = (struct ib_vendor_mad *)mad; 1683 vendor_mad = (const struct ib_vendor_mad *)mad_hdr;
1684 index = find_vendor_oui(vendor_class, vendor_mad->oui); 1684 index = find_vendor_oui(vendor_class, vendor_mad->oui);
1685 if (index == -1) 1685 if (index == -1)
1686 goto out; 1686 goto out;
1687 method = vendor_class->method_table[index]; 1687 method = vendor_class->method_table[index];
1688 if (method) { 1688 if (method) {
1689 mad_agent = method->agent[mad->mad_hdr.method & 1689 mad_agent = method->agent[mad_hdr->method &
1690 ~IB_MGMT_METHOD_RESP]; 1690 ~IB_MGMT_METHOD_RESP];
1691 } 1691 }
1692 } 1692 }
@@ -2056,7 +2056,7 @@ local:
2056 } 2056 }
2057 } 2057 }
2058 2058
2059 mad_agent = find_mad_agent(port_priv, &recv->mad.mad); 2059 mad_agent = find_mad_agent(port_priv, &recv->mad.mad.mad_hdr);
2060 if (mad_agent) { 2060 if (mad_agent) {
2061 ib_mad_complete_recv(mad_agent, &recv->header.recv_wc); 2061 ib_mad_complete_recv(mad_agent, &recv->header.recv_wc);
2062 /* 2062 /*