Commit 87635b71 authored by Roland Dreier's avatar Roland Dreier

IB/mthca: Factor common MAD initialization code

Factor out common code for initializing MAD packets, which is shared
by many query routines in mthca_provider.c, into init_query_mad().

add/remove: 1/0 grow/shrink: 0/4 up/down: 16/-44 (-28)
function                                     old     new   delta
init_query_mad                                 -      16     +16
mthca_query_port                             521     518      -3
mthca_query_pkey                             301     294      -7
mthca_query_device                           648     641      -7
mthca_query_gid                              453     426     -27
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 105e50a5
...@@ -45,6 +45,14 @@ ...@@ -45,6 +45,14 @@
#include "mthca_user.h" #include "mthca_user.h"
#include "mthca_memfree.h" #include "mthca_memfree.h"
static void init_query_mad(struct ib_smp *mad)
{
mad->base_version = 1;
mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
mad->class_version = 1;
mad->method = IB_MGMT_METHOD_GET;
}
static int mthca_query_device(struct ib_device *ibdev, static int mthca_query_device(struct ib_device *ibdev,
struct ib_device_attr *props) struct ib_device_attr *props)
{ {
...@@ -64,10 +72,7 @@ static int mthca_query_device(struct ib_device *ibdev, ...@@ -64,10 +72,7 @@ static int mthca_query_device(struct ib_device *ibdev,
props->fw_ver = mdev->fw_ver; props->fw_ver = mdev->fw_ver;
in_mad->base_version = 1; init_query_mad(in_mad);
in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
in_mad->class_version = 1;
in_mad->method = IB_MGMT_METHOD_GET;
in_mad->attr_id = IB_SMP_ATTR_NODE_INFO; in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
err = mthca_MAD_IFC(mdev, 1, 1, err = mthca_MAD_IFC(mdev, 1, 1,
...@@ -134,10 +139,7 @@ static int mthca_query_port(struct ib_device *ibdev, ...@@ -134,10 +139,7 @@ static int mthca_query_port(struct ib_device *ibdev,
memset(props, 0, sizeof *props); memset(props, 0, sizeof *props);
in_mad->base_version = 1; init_query_mad(in_mad);
in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
in_mad->class_version = 1;
in_mad->method = IB_MGMT_METHOD_GET;
in_mad->attr_id = IB_SMP_ATTR_PORT_INFO; in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
in_mad->attr_mod = cpu_to_be32(port); in_mad->attr_mod = cpu_to_be32(port);
...@@ -223,10 +225,7 @@ static int mthca_query_pkey(struct ib_device *ibdev, ...@@ -223,10 +225,7 @@ static int mthca_query_pkey(struct ib_device *ibdev,
if (!in_mad || !out_mad) if (!in_mad || !out_mad)
goto out; goto out;
in_mad->base_version = 1; init_query_mad(in_mad);
in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
in_mad->class_version = 1;
in_mad->method = IB_MGMT_METHOD_GET;
in_mad->attr_id = IB_SMP_ATTR_PKEY_TABLE; in_mad->attr_id = IB_SMP_ATTR_PKEY_TABLE;
in_mad->attr_mod = cpu_to_be32(index / 32); in_mad->attr_mod = cpu_to_be32(index / 32);
...@@ -261,10 +260,7 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port, ...@@ -261,10 +260,7 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port,
if (!in_mad || !out_mad) if (!in_mad || !out_mad)
goto out; goto out;
in_mad->base_version = 1; init_query_mad(in_mad);
in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
in_mad->class_version = 1;
in_mad->method = IB_MGMT_METHOD_GET;
in_mad->attr_id = IB_SMP_ATTR_PORT_INFO; in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
in_mad->attr_mod = cpu_to_be32(port); in_mad->attr_mod = cpu_to_be32(port);
...@@ -280,11 +276,7 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port, ...@@ -280,11 +276,7 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port,
memcpy(gid->raw, out_mad->data + 8, 8); memcpy(gid->raw, out_mad->data + 8, 8);
memset(in_mad, 0, sizeof *in_mad); init_query_mad(in_mad);
in_mad->base_version = 1;
in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
in_mad->class_version = 1;
in_mad->method = IB_MGMT_METHOD_GET;
in_mad->attr_id = IB_SMP_ATTR_GUID_INFO; in_mad->attr_id = IB_SMP_ATTR_GUID_INFO;
in_mad->attr_mod = cpu_to_be32(index / 8); in_mad->attr_mod = cpu_to_be32(index / 8);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment