aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mthca/mthca_provider.c
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2006-01-09 18:29:53 -0500
committerRoland Dreier <rolandd@cisco.com>2006-01-09 18:29:53 -0500
commit87635b71b544563f29050a9cecaa12b5d2a3e34a (patch)
tree5be700dae4582d73fdd31b8db0480eaddd04881c /drivers/infiniband/hw/mthca/mthca_provider.c
parent105e50a5e8f184af31daffce4d7bfd7771fe213f (diff)
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: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_provider.c')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c52
1 files changed, 22 insertions, 30 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index 0ae27fa26c7a..488757766a5d 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -45,6 +45,14 @@
45#include "mthca_user.h" 45#include "mthca_user.h"
46#include "mthca_memfree.h" 46#include "mthca_memfree.h"
47 47
48static void init_query_mad(struct ib_smp *mad)
49{
50 mad->base_version = 1;
51 mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
52 mad->class_version = 1;
53 mad->method = IB_MGMT_METHOD_GET;
54}
55
48static int mthca_query_device(struct ib_device *ibdev, 56static int mthca_query_device(struct ib_device *ibdev,
49 struct ib_device_attr *props) 57 struct ib_device_attr *props)
50{ 58{
@@ -64,11 +72,8 @@ static int mthca_query_device(struct ib_device *ibdev,
64 72
65 props->fw_ver = mdev->fw_ver; 73 props->fw_ver = mdev->fw_ver;
66 74
67 in_mad->base_version = 1; 75 init_query_mad(in_mad);
68 in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED; 76 in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
69 in_mad->class_version = 1;
70 in_mad->method = IB_MGMT_METHOD_GET;
71 in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
72 77
73 err = mthca_MAD_IFC(mdev, 1, 1, 78 err = mthca_MAD_IFC(mdev, 1, 1,
74 1, NULL, NULL, in_mad, out_mad, 79 1, NULL, NULL, in_mad, out_mad,
@@ -134,12 +139,9 @@ static int mthca_query_port(struct ib_device *ibdev,
134 139
135 memset(props, 0, sizeof *props); 140 memset(props, 0, sizeof *props);
136 141
137 in_mad->base_version = 1; 142 init_query_mad(in_mad);
138 in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED; 143 in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
139 in_mad->class_version = 1; 144 in_mad->attr_mod = cpu_to_be32(port);
140 in_mad->method = IB_MGMT_METHOD_GET;
141 in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
142 in_mad->attr_mod = cpu_to_be32(port);
143 145
144 err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, 146 err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
145 port, NULL, NULL, in_mad, out_mad, 147 port, NULL, NULL, in_mad, out_mad,
@@ -223,12 +225,9 @@ static int mthca_query_pkey(struct ib_device *ibdev,
223 if (!in_mad || !out_mad) 225 if (!in_mad || !out_mad)
224 goto out; 226 goto out;
225 227
226 in_mad->base_version = 1; 228 init_query_mad(in_mad);
227 in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED; 229 in_mad->attr_id = IB_SMP_ATTR_PKEY_TABLE;
228 in_mad->class_version = 1; 230 in_mad->attr_mod = cpu_to_be32(index / 32);
229 in_mad->method = IB_MGMT_METHOD_GET;
230 in_mad->attr_id = IB_SMP_ATTR_PKEY_TABLE;
231 in_mad->attr_mod = cpu_to_be32(index / 32);
232 231
233 err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, 232 err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
234 port, NULL, NULL, in_mad, out_mad, 233 port, NULL, NULL, in_mad, out_mad,
@@ -261,12 +260,9 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port,
261 if (!in_mad || !out_mad) 260 if (!in_mad || !out_mad)
262 goto out; 261 goto out;
263 262
264 in_mad->base_version = 1; 263 init_query_mad(in_mad);
265 in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED; 264 in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
266 in_mad->class_version = 1; 265 in_mad->attr_mod = cpu_to_be32(port);
267 in_mad->method = IB_MGMT_METHOD_GET;
268 in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
269 in_mad->attr_mod = cpu_to_be32(port);
270 266
271 err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, 267 err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
272 port, NULL, NULL, in_mad, out_mad, 268 port, NULL, NULL, in_mad, out_mad,
@@ -280,13 +276,9 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port,
280 276
281 memcpy(gid->raw, out_mad->data + 8, 8); 277 memcpy(gid->raw, out_mad->data + 8, 8);
282 278
283 memset(in_mad, 0, sizeof *in_mad); 279 init_query_mad(in_mad);
284 in_mad->base_version = 1; 280 in_mad->attr_id = IB_SMP_ATTR_GUID_INFO;
285 in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED; 281 in_mad->attr_mod = cpu_to_be32(index / 8);
286 in_mad->class_version = 1;
287 in_mad->method = IB_MGMT_METHOD_GET;
288 in_mad->attr_id = IB_SMP_ATTR_GUID_INFO;
289 in_mad->attr_mod = cpu_to_be32(index / 8);
290 282
291 err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1, 283 err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
292 port, NULL, NULL, in_mad, out_mad, 284 port, NULL, NULL, in_mad, out_mad,