IB/mthca: Stop returning separate error and status from FW commands
Instead of having firmware command functions return an error and also a status, leading to code like: err = mthca_FW_COMMAND(..., &status); if (err) goto out; if (status) { err = -E...; goto out; } all over the place, just handle the FW status inside the FW command handling code (the way mlx4 does it), so we can simply write: err = mthca_FW_COMMAND(...); if (err) goto out; In addition to simplifying the source code, this also saves a healthy chunk of text: add/remove: 0/0 grow/shrink: 10/88 up/down: 510/-3357 (-2847) function old new delta static.trans_table 324 584 +260 mthca_cmd_poll 352 477 +125 mthca_cmd_wait 511 567 +56 mthca_table_put 213 240 +27 mthca_cleanup_db_tab 372 387 +15 __mthca_remove_one 314 323 +9 mthca_cleanup_user_db_tab 275 283 +8 __mthca_init_one 1738 1746 +8 mthca_cleanup 20 21 +1 mthca_MAD_IFC 1081 1082 +1 mthca_MGID_HASH 43 40 -3 mthca_MAP_ICM_AUX 23 20 -3 mthca_MAP_ICM 19 16 -3 mthca_MAP_FA 23 20 -3 mthca_READ_MGM 43 38 -5 mthca_QUERY_SRQ 43 38 -5 mthca_QUERY_QP 59 54 -5 mthca_HW2SW_SRQ 43 38 -5 mthca_HW2SW_MPT 60 55 -5 mthca_HW2SW_EQ 43 38 -5 mthca_HW2SW_CQ 43 38 -5 mthca_free_icm_table 120 114 -6 mthca_query_srq 214 206 -8 mthca_free_qp 662 654 -8 mthca_cmd 38 28 -10 mthca_alloc_db 1321 1311 -10 mthca_setup_hca 1067 1055 -12 mthca_WRITE_MTT 35 22 -13 mthca_WRITE_MGM 40 27 -13 mthca_UNMAP_ICM_AUX 36 23 -13 mthca_UNMAP_FA 36 23 -13 mthca_SYS_DIS 36 23 -13 mthca_SYNC_TPT 36 23 -13 mthca_SW2HW_SRQ 35 22 -13 mthca_SW2HW_MPT 35 22 -13 mthca_SW2HW_EQ 35 22 -13 mthca_SW2HW_CQ 35 22 -13 mthca_RUN_FW 36 23 -13 mthca_DISABLE_LAM 36 23 -13 mthca_CLOSE_IB 36 23 -13 mthca_CLOSE_HCA 38 25 -13 mthca_ARM_SRQ 39 26 -13 mthca_free_icms 178 164 -14 mthca_QUERY_DDR 389 375 -14 mthca_resize_cq 1063 1048 -15 mthca_unmap_eq_icm 123 107 -16 mthca_map_eq_icm 396 380 -16 mthca_cmd_box 90 74 -16 mthca_SET_IB 433 417 -16 mthca_RESIZE_CQ 369 353 -16 mthca_MAP_ICM_page 240 224 -16 mthca_MAP_EQ 183 167 -16 mthca_INIT_IB 473 457 -16 mthca_INIT_HCA 745 729 -16 mthca_map_user_db 816 798 -18 mthca_SYS_EN 157 139 -18 mthca_cleanup_qp_table 78 59 -19 mthca_cleanup_eq_table 168 149 -19 mthca_UNMAP_ICM 143 121 -22 mthca_modify_srq 172 149 -23 mthca_unmap_fmr 198 174 -24 mthca_query_qp 814 790 -24 mthca_query_pkey 343 319 -24 mthca_SET_ICM_SIZE 34 10 -24 mthca_QUERY_DEV_LIM 1870 1846 -24 mthca_map_cmd 1130 1105 -25 mthca_ENABLE_LAM 401 375 -26 mthca_modify_port 247 220 -27 mthca_query_device 884 850 -34 mthca_NOP 75 41 -34 mthca_table_get 287 249 -38 mthca_init_qp_table 333 293 -40 mthca_MODIFY_QP 348 308 -40 mthca_close_hca 131 89 -42 mthca_free_eq 435 390 -45 mthca_query_port 755 705 -50 mthca_free_cq 581 528 -53 mthca_alloc_icm_table 578 524 -54 mthca_multicast_attach 1041 986 -55 mthca_init_hca 326 271 -55 mthca_query_gid 487 431 -56 mthca_free_srq 524 468 -56 mthca_free_mr 168 111 -57 mthca_create_eq 1560 1501 -59 mthca_multicast_detach 790 728 -62 mthca_write_mtt 918 854 -64 mthca_register_device 1406 1342 -64 mthca_fmr_alloc 947 883 -64 mthca_mr_alloc 652 582 -70 mthca_process_mad 1242 1164 -78 mthca_dev_lim 910 830 -80 find_mgm 482 400 -82 mthca_modify_qp 3852 3753 -99 mthca_init_cq 1281 1181 -100 mthca_alloc_srq 1719 1610 -109 mthca_init_eq_table 1807 1679 -128 mthca_init_tavor 761 491 -270 mthca_init_arbel 2617 2098 -519 Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.de>
This commit is contained in:

committed by
Roland Dreier

parent
620917de59
commit
cdb73db0b6
@@ -63,8 +63,6 @@ static int mthca_query_device(struct ib_device *ibdev,
|
||||
int err = -ENOMEM;
|
||||
struct mthca_dev *mdev = to_mdev(ibdev);
|
||||
|
||||
u8 status;
|
||||
|
||||
in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
|
||||
out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
|
||||
if (!in_mad || !out_mad)
|
||||
@@ -78,14 +76,9 @@ static int mthca_query_device(struct ib_device *ibdev,
|
||||
in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
|
||||
|
||||
err = mthca_MAD_IFC(mdev, 1, 1,
|
||||
1, NULL, NULL, in_mad, out_mad,
|
||||
&status);
|
||||
1, NULL, NULL, in_mad, out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
if (status) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
props->device_cap_flags = mdev->device_cap_flags;
|
||||
props->vendor_id = be32_to_cpup((__be32 *) (out_mad->data + 36)) &
|
||||
@@ -141,7 +134,6 @@ static int mthca_query_port(struct ib_device *ibdev,
|
||||
struct ib_smp *in_mad = NULL;
|
||||
struct ib_smp *out_mad = NULL;
|
||||
int err = -ENOMEM;
|
||||
u8 status;
|
||||
|
||||
in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
|
||||
out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
|
||||
@@ -155,14 +147,9 @@ static int mthca_query_port(struct ib_device *ibdev,
|
||||
in_mad->attr_mod = cpu_to_be32(port);
|
||||
|
||||
err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
|
||||
port, NULL, NULL, in_mad, out_mad,
|
||||
&status);
|
||||
port, NULL, NULL, in_mad, out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
if (status) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
props->lid = be16_to_cpup((__be16 *) (out_mad->data + 16));
|
||||
props->lmc = out_mad->data[34] & 0x7;
|
||||
@@ -214,7 +201,6 @@ static int mthca_modify_port(struct ib_device *ibdev,
|
||||
struct mthca_set_ib_param set_ib;
|
||||
struct ib_port_attr attr;
|
||||
int err;
|
||||
u8 status;
|
||||
|
||||
if (mutex_lock_interruptible(&to_mdev(ibdev)->cap_mask_mutex))
|
||||
return -ERESTARTSYS;
|
||||
@@ -229,14 +215,9 @@ static int mthca_modify_port(struct ib_device *ibdev,
|
||||
set_ib.cap_mask = (attr.port_cap_flags | props->set_port_cap_mask) &
|
||||
~props->clr_port_cap_mask;
|
||||
|
||||
err = mthca_SET_IB(to_mdev(ibdev), &set_ib, port, &status);
|
||||
err = mthca_SET_IB(to_mdev(ibdev), &set_ib, port);
|
||||
if (err)
|
||||
goto out;
|
||||
if (status) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
mutex_unlock(&to_mdev(ibdev)->cap_mask_mutex);
|
||||
return err;
|
||||
@@ -248,7 +229,6 @@ static int mthca_query_pkey(struct ib_device *ibdev,
|
||||
struct ib_smp *in_mad = NULL;
|
||||
struct ib_smp *out_mad = NULL;
|
||||
int err = -ENOMEM;
|
||||
u8 status;
|
||||
|
||||
in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
|
||||
out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
|
||||
@@ -260,14 +240,9 @@ static int mthca_query_pkey(struct ib_device *ibdev,
|
||||
in_mad->attr_mod = cpu_to_be32(index / 32);
|
||||
|
||||
err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
|
||||
port, NULL, NULL, in_mad, out_mad,
|
||||
&status);
|
||||
port, NULL, NULL, in_mad, out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
if (status) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
*pkey = be16_to_cpu(((__be16 *) out_mad->data)[index % 32]);
|
||||
|
||||
@@ -283,7 +258,6 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port,
|
||||
struct ib_smp *in_mad = NULL;
|
||||
struct ib_smp *out_mad = NULL;
|
||||
int err = -ENOMEM;
|
||||
u8 status;
|
||||
|
||||
in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
|
||||
out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
|
||||
@@ -295,14 +269,9 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port,
|
||||
in_mad->attr_mod = cpu_to_be32(port);
|
||||
|
||||
err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
|
||||
port, NULL, NULL, in_mad, out_mad,
|
||||
&status);
|
||||
port, NULL, NULL, in_mad, out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
if (status) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(gid->raw, out_mad->data + 8, 8);
|
||||
|
||||
@@ -311,14 +280,9 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port,
|
||||
in_mad->attr_mod = cpu_to_be32(index / 8);
|
||||
|
||||
err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
|
||||
port, NULL, NULL, in_mad, out_mad,
|
||||
&status);
|
||||
port, NULL, NULL, in_mad, out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
if (status) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(gid->raw + 8, out_mad->data + (index % 8) * 8, 8);
|
||||
|
||||
@@ -800,7 +764,6 @@ static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *uda
|
||||
struct mthca_cq *cq = to_mcq(ibcq);
|
||||
struct mthca_resize_cq ucmd;
|
||||
u32 lkey;
|
||||
u8 status;
|
||||
int ret;
|
||||
|
||||
if (entries < 1 || entries > dev->limits.max_cqes)
|
||||
@@ -827,9 +790,7 @@ static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *uda
|
||||
lkey = ucmd.lkey;
|
||||
}
|
||||
|
||||
ret = mthca_RESIZE_CQ(dev, cq->cqn, lkey, ilog2(entries), &status);
|
||||
if (status)
|
||||
ret = -EINVAL;
|
||||
ret = mthca_RESIZE_CQ(dev, cq->cqn, lkey, ilog2(entries));
|
||||
|
||||
if (ret) {
|
||||
if (cq->resize_buf) {
|
||||
@@ -1161,7 +1122,6 @@ static int mthca_unmap_fmr(struct list_head *fmr_list)
|
||||
{
|
||||
struct ib_fmr *fmr;
|
||||
int err;
|
||||
u8 status;
|
||||
struct mthca_dev *mdev = NULL;
|
||||
|
||||
list_for_each_entry(fmr, fmr_list, list) {
|
||||
@@ -1182,12 +1142,8 @@ static int mthca_unmap_fmr(struct list_head *fmr_list)
|
||||
list_for_each_entry(fmr, fmr_list, list)
|
||||
mthca_tavor_fmr_unmap(mdev, to_mfmr(fmr));
|
||||
|
||||
err = mthca_SYNC_TPT(mdev, &status);
|
||||
if (err)
|
||||
return err;
|
||||
if (status)
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
err = mthca_SYNC_TPT(mdev);
|
||||
return err;
|
||||
}
|
||||
|
||||
static ssize_t show_rev(struct device *device, struct device_attribute *attr,
|
||||
@@ -1253,7 +1209,6 @@ static int mthca_init_node_data(struct mthca_dev *dev)
|
||||
struct ib_smp *in_mad = NULL;
|
||||
struct ib_smp *out_mad = NULL;
|
||||
int err = -ENOMEM;
|
||||
u8 status;
|
||||
|
||||
in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
|
||||
out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
|
||||
@@ -1264,28 +1219,18 @@ static int mthca_init_node_data(struct mthca_dev *dev)
|
||||
in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
|
||||
|
||||
err = mthca_MAD_IFC(dev, 1, 1,
|
||||
1, NULL, NULL, in_mad, out_mad,
|
||||
&status);
|
||||
1, NULL, NULL, in_mad, out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
if (status) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(dev->ib_dev.node_desc, out_mad->data, 64);
|
||||
|
||||
in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
|
||||
|
||||
err = mthca_MAD_IFC(dev, 1, 1,
|
||||
1, NULL, NULL, in_mad, out_mad,
|
||||
&status);
|
||||
1, NULL, NULL, in_mad, out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
if (status) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (mthca_is_memfree(dev))
|
||||
dev->rev_id = be32_to_cpup((__be32 *) (out_mad->data + 32));
|
||||
|
Reference in New Issue
Block a user