diff options
author | David S. Miller <davem@davemloft.net> | 2014-10-03 18:42:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-03 18:42:37 -0400 |
commit | 48fea861c9fbee5aae17897fb9acc4d348a9abac (patch) | |
tree | 84f297a4df4c18b5ec6e589528c8f2d978d8abae /drivers/infiniband/hw/mlx5/main.c | |
parent | 55a93b3ea780908b7d1b3a8cf1976223a9268d78 (diff) | |
parent | f832dc820fe8fca561933e8fa734adca75bba5a0 (diff) |
Merge branch 'mlx5-next'
Eli Cohen says:
====================
mlx5 update for 3.18
This series integrates a new mechanism for populating and extracting field values
used in the driver/firmware interaction around command mailboxes.
Changes from V1:
- Remove unused definition of memcpy_cpu_to_be32()
- Remove definitions of non_existent_*() and use BUILD_BUG_ON() instead.
- Added a patch one line patch to add support for ConnectX-4 devices.
Changes from V0:
- trimmed the auto-generated file to a minimum, as required by the reviewers.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/infiniband/hw/mlx5/main.c')
-rw-r--r-- | drivers/infiniband/hw/mlx5/main.c | 83 |
1 files changed, 47 insertions, 36 deletions
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index d8907b20522a..f3114d1132fb 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c | |||
@@ -157,11 +157,13 @@ static int mlx5_ib_query_device(struct ib_device *ibdev, | |||
157 | struct mlx5_ib_dev *dev = to_mdev(ibdev); | 157 | struct mlx5_ib_dev *dev = to_mdev(ibdev); |
158 | struct ib_smp *in_mad = NULL; | 158 | struct ib_smp *in_mad = NULL; |
159 | struct ib_smp *out_mad = NULL; | 159 | struct ib_smp *out_mad = NULL; |
160 | struct mlx5_general_caps *gen; | ||
160 | int err = -ENOMEM; | 161 | int err = -ENOMEM; |
161 | int max_rq_sg; | 162 | int max_rq_sg; |
162 | int max_sq_sg; | 163 | int max_sq_sg; |
163 | u64 flags; | 164 | u64 flags; |
164 | 165 | ||
166 | gen = &dev->mdev->caps.gen; | ||
165 | in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); | 167 | in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); |
166 | out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); | 168 | out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); |
167 | if (!in_mad || !out_mad) | 169 | if (!in_mad || !out_mad) |
@@ -183,7 +185,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev, | |||
183 | IB_DEVICE_PORT_ACTIVE_EVENT | | 185 | IB_DEVICE_PORT_ACTIVE_EVENT | |
184 | IB_DEVICE_SYS_IMAGE_GUID | | 186 | IB_DEVICE_SYS_IMAGE_GUID | |
185 | IB_DEVICE_RC_RNR_NAK_GEN; | 187 | IB_DEVICE_RC_RNR_NAK_GEN; |
186 | flags = dev->mdev->caps.flags; | 188 | flags = gen->flags; |
187 | if (flags & MLX5_DEV_CAP_FLAG_BAD_PKEY_CNTR) | 189 | if (flags & MLX5_DEV_CAP_FLAG_BAD_PKEY_CNTR) |
188 | props->device_cap_flags |= IB_DEVICE_BAD_PKEY_CNTR; | 190 | props->device_cap_flags |= IB_DEVICE_BAD_PKEY_CNTR; |
189 | if (flags & MLX5_DEV_CAP_FLAG_BAD_QKEY_CNTR) | 191 | if (flags & MLX5_DEV_CAP_FLAG_BAD_QKEY_CNTR) |
@@ -213,30 +215,31 @@ static int mlx5_ib_query_device(struct ib_device *ibdev, | |||
213 | memcpy(&props->sys_image_guid, out_mad->data + 4, 8); | 215 | memcpy(&props->sys_image_guid, out_mad->data + 4, 8); |
214 | 216 | ||
215 | props->max_mr_size = ~0ull; | 217 | props->max_mr_size = ~0ull; |
216 | props->page_size_cap = dev->mdev->caps.min_page_sz; | 218 | props->page_size_cap = gen->min_page_sz; |
217 | props->max_qp = 1 << dev->mdev->caps.log_max_qp; | 219 | props->max_qp = 1 << gen->log_max_qp; |
218 | props->max_qp_wr = dev->mdev->caps.max_wqes; | 220 | props->max_qp_wr = gen->max_wqes; |
219 | max_rq_sg = dev->mdev->caps.max_rq_desc_sz / sizeof(struct mlx5_wqe_data_seg); | 221 | max_rq_sg = gen->max_rq_desc_sz / sizeof(struct mlx5_wqe_data_seg); |
220 | max_sq_sg = (dev->mdev->caps.max_sq_desc_sz - sizeof(struct mlx5_wqe_ctrl_seg)) / | 222 | max_sq_sg = (gen->max_sq_desc_sz - sizeof(struct mlx5_wqe_ctrl_seg)) / |
221 | sizeof(struct mlx5_wqe_data_seg); | 223 | sizeof(struct mlx5_wqe_data_seg); |
222 | props->max_sge = min(max_rq_sg, max_sq_sg); | 224 | props->max_sge = min(max_rq_sg, max_sq_sg); |
223 | props->max_cq = 1 << dev->mdev->caps.log_max_cq; | 225 | props->max_cq = 1 << gen->log_max_cq; |
224 | props->max_cqe = dev->mdev->caps.max_cqes - 1; | 226 | props->max_cqe = gen->max_cqes - 1; |
225 | props->max_mr = 1 << dev->mdev->caps.log_max_mkey; | 227 | props->max_mr = 1 << gen->log_max_mkey; |
226 | props->max_pd = 1 << dev->mdev->caps.log_max_pd; | 228 | props->max_pd = 1 << gen->log_max_pd; |
227 | props->max_qp_rd_atom = dev->mdev->caps.max_ra_req_qp; | 229 | props->max_qp_rd_atom = 1 << gen->log_max_ra_req_qp; |
228 | props->max_qp_init_rd_atom = dev->mdev->caps.max_ra_res_qp; | 230 | props->max_qp_init_rd_atom = 1 << gen->log_max_ra_res_qp; |
231 | props->max_srq = 1 << gen->log_max_srq; | ||
232 | props->max_srq_wr = gen->max_srq_wqes - 1; | ||
233 | props->local_ca_ack_delay = gen->local_ca_ack_delay; | ||
229 | props->max_res_rd_atom = props->max_qp_rd_atom * props->max_qp; | 234 | props->max_res_rd_atom = props->max_qp_rd_atom * props->max_qp; |
230 | props->max_srq = 1 << dev->mdev->caps.log_max_srq; | ||
231 | props->max_srq_wr = dev->mdev->caps.max_srq_wqes - 1; | ||
232 | props->max_srq_sge = max_rq_sg - 1; | 235 | props->max_srq_sge = max_rq_sg - 1; |
233 | props->max_fast_reg_page_list_len = (unsigned int)-1; | 236 | props->max_fast_reg_page_list_len = (unsigned int)-1; |
234 | props->local_ca_ack_delay = dev->mdev->caps.local_ca_ack_delay; | 237 | props->local_ca_ack_delay = gen->local_ca_ack_delay; |
235 | props->atomic_cap = IB_ATOMIC_NONE; | 238 | props->atomic_cap = IB_ATOMIC_NONE; |
236 | props->masked_atomic_cap = IB_ATOMIC_NONE; | 239 | props->masked_atomic_cap = IB_ATOMIC_NONE; |
237 | props->max_pkeys = be16_to_cpup((__be16 *)(out_mad->data + 28)); | 240 | props->max_pkeys = be16_to_cpup((__be16 *)(out_mad->data + 28)); |
238 | props->max_mcast_grp = 1 << dev->mdev->caps.log_max_mcg; | 241 | props->max_mcast_grp = 1 << gen->log_max_mcg; |
239 | props->max_mcast_qp_attach = dev->mdev->caps.max_qp_mcg; | 242 | props->max_mcast_qp_attach = gen->max_qp_mcg; |
240 | props->max_total_mcast_qp_attach = props->max_mcast_qp_attach * | 243 | props->max_total_mcast_qp_attach = props->max_mcast_qp_attach * |
241 | props->max_mcast_grp; | 244 | props->max_mcast_grp; |
242 | props->max_map_per_fmr = INT_MAX; /* no limit in ConnectIB */ | 245 | props->max_map_per_fmr = INT_MAX; /* no limit in ConnectIB */ |
@@ -254,10 +257,12 @@ int mlx5_ib_query_port(struct ib_device *ibdev, u8 port, | |||
254 | struct mlx5_ib_dev *dev = to_mdev(ibdev); | 257 | struct mlx5_ib_dev *dev = to_mdev(ibdev); |
255 | struct ib_smp *in_mad = NULL; | 258 | struct ib_smp *in_mad = NULL; |
256 | struct ib_smp *out_mad = NULL; | 259 | struct ib_smp *out_mad = NULL; |
260 | struct mlx5_general_caps *gen; | ||
257 | int ext_active_speed; | 261 | int ext_active_speed; |
258 | int err = -ENOMEM; | 262 | int err = -ENOMEM; |
259 | 263 | ||
260 | if (port < 1 || port > dev->mdev->caps.num_ports) { | 264 | gen = &dev->mdev->caps.gen; |
265 | if (port < 1 || port > gen->num_ports) { | ||
261 | mlx5_ib_warn(dev, "invalid port number %d\n", port); | 266 | mlx5_ib_warn(dev, "invalid port number %d\n", port); |
262 | return -EINVAL; | 267 | return -EINVAL; |
263 | } | 268 | } |
@@ -288,8 +293,8 @@ int mlx5_ib_query_port(struct ib_device *ibdev, u8 port, | |||
288 | props->phys_state = out_mad->data[33] >> 4; | 293 | props->phys_state = out_mad->data[33] >> 4; |
289 | props->port_cap_flags = be32_to_cpup((__be32 *)(out_mad->data + 20)); | 294 | props->port_cap_flags = be32_to_cpup((__be32 *)(out_mad->data + 20)); |
290 | props->gid_tbl_len = out_mad->data[50]; | 295 | props->gid_tbl_len = out_mad->data[50]; |
291 | props->max_msg_sz = 1 << to_mdev(ibdev)->mdev->caps.log_max_msg; | 296 | props->max_msg_sz = 1 << gen->log_max_msg; |
292 | props->pkey_tbl_len = to_mdev(ibdev)->mdev->caps.port[port - 1].pkey_table_len; | 297 | props->pkey_tbl_len = gen->port[port - 1].pkey_table_len; |
293 | props->bad_pkey_cntr = be16_to_cpup((__be16 *)(out_mad->data + 46)); | 298 | props->bad_pkey_cntr = be16_to_cpup((__be16 *)(out_mad->data + 46)); |
294 | props->qkey_viol_cntr = be16_to_cpup((__be16 *)(out_mad->data + 48)); | 299 | props->qkey_viol_cntr = be16_to_cpup((__be16 *)(out_mad->data + 48)); |
295 | props->active_width = out_mad->data[31] & 0xf; | 300 | props->active_width = out_mad->data[31] & 0xf; |
@@ -316,7 +321,7 @@ int mlx5_ib_query_port(struct ib_device *ibdev, u8 port, | |||
316 | 321 | ||
317 | /* If reported active speed is QDR, check if is FDR-10 */ | 322 | /* If reported active speed is QDR, check if is FDR-10 */ |
318 | if (props->active_speed == 4) { | 323 | if (props->active_speed == 4) { |
319 | if (dev->mdev->caps.ext_port_cap[port - 1] & | 324 | if (gen->ext_port_cap[port - 1] & |
320 | MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO) { | 325 | MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO) { |
321 | init_query_mad(in_mad); | 326 | init_query_mad(in_mad); |
322 | in_mad->attr_id = MLX5_ATTR_EXTENDED_PORT_INFO; | 327 | in_mad->attr_id = MLX5_ATTR_EXTENDED_PORT_INFO; |
@@ -470,6 +475,7 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, | |||
470 | struct mlx5_ib_alloc_ucontext_req_v2 req; | 475 | struct mlx5_ib_alloc_ucontext_req_v2 req; |
471 | struct mlx5_ib_alloc_ucontext_resp resp; | 476 | struct mlx5_ib_alloc_ucontext_resp resp; |
472 | struct mlx5_ib_ucontext *context; | 477 | struct mlx5_ib_ucontext *context; |
478 | struct mlx5_general_caps *gen; | ||
473 | struct mlx5_uuar_info *uuari; | 479 | struct mlx5_uuar_info *uuari; |
474 | struct mlx5_uar *uars; | 480 | struct mlx5_uar *uars; |
475 | int gross_uuars; | 481 | int gross_uuars; |
@@ -480,6 +486,7 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, | |||
480 | int i; | 486 | int i; |
481 | size_t reqlen; | 487 | size_t reqlen; |
482 | 488 | ||
489 | gen = &dev->mdev->caps.gen; | ||
483 | if (!dev->ib_active) | 490 | if (!dev->ib_active) |
484 | return ERR_PTR(-EAGAIN); | 491 | return ERR_PTR(-EAGAIN); |
485 | 492 | ||
@@ -512,14 +519,14 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, | |||
512 | 519 | ||
513 | num_uars = req.total_num_uuars / MLX5_NON_FP_BF_REGS_PER_PAGE; | 520 | num_uars = req.total_num_uuars / MLX5_NON_FP_BF_REGS_PER_PAGE; |
514 | gross_uuars = num_uars * MLX5_BF_REGS_PER_PAGE; | 521 | gross_uuars = num_uars * MLX5_BF_REGS_PER_PAGE; |
515 | resp.qp_tab_size = 1 << dev->mdev->caps.log_max_qp; | 522 | resp.qp_tab_size = 1 << gen->log_max_qp; |
516 | resp.bf_reg_size = dev->mdev->caps.bf_reg_size; | 523 | resp.bf_reg_size = gen->bf_reg_size; |
517 | resp.cache_line_size = L1_CACHE_BYTES; | 524 | resp.cache_line_size = L1_CACHE_BYTES; |
518 | resp.max_sq_desc_sz = dev->mdev->caps.max_sq_desc_sz; | 525 | resp.max_sq_desc_sz = gen->max_sq_desc_sz; |
519 | resp.max_rq_desc_sz = dev->mdev->caps.max_rq_desc_sz; | 526 | resp.max_rq_desc_sz = gen->max_rq_desc_sz; |
520 | resp.max_send_wqebb = dev->mdev->caps.max_wqes; | 527 | resp.max_send_wqebb = gen->max_wqes; |
521 | resp.max_recv_wr = dev->mdev->caps.max_wqes; | 528 | resp.max_recv_wr = gen->max_wqes; |
522 | resp.max_srq_recv_wr = dev->mdev->caps.max_srq_wqes; | 529 | resp.max_srq_recv_wr = gen->max_srq_wqes; |
523 | 530 | ||
524 | context = kzalloc(sizeof(*context), GFP_KERNEL); | 531 | context = kzalloc(sizeof(*context), GFP_KERNEL); |
525 | if (!context) | 532 | if (!context) |
@@ -565,7 +572,7 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, | |||
565 | mutex_init(&context->db_page_mutex); | 572 | mutex_init(&context->db_page_mutex); |
566 | 573 | ||
567 | resp.tot_uuars = req.total_num_uuars; | 574 | resp.tot_uuars = req.total_num_uuars; |
568 | resp.num_ports = dev->mdev->caps.num_ports; | 575 | resp.num_ports = gen->num_ports; |
569 | err = ib_copy_to_udata(udata, &resp, | 576 | err = ib_copy_to_udata(udata, &resp, |
570 | sizeof(resp) - sizeof(resp.reserved)); | 577 | sizeof(resp) - sizeof(resp.reserved)); |
571 | if (err) | 578 | if (err) |
@@ -967,9 +974,11 @@ static void mlx5_ib_event(struct mlx5_core_dev *dev, void *context, | |||
967 | 974 | ||
968 | static void get_ext_port_caps(struct mlx5_ib_dev *dev) | 975 | static void get_ext_port_caps(struct mlx5_ib_dev *dev) |
969 | { | 976 | { |
977 | struct mlx5_general_caps *gen; | ||
970 | int port; | 978 | int port; |
971 | 979 | ||
972 | for (port = 1; port <= dev->mdev->caps.num_ports; port++) | 980 | gen = &dev->mdev->caps.gen; |
981 | for (port = 1; port <= gen->num_ports; port++) | ||
973 | mlx5_query_ext_port_caps(dev, port); | 982 | mlx5_query_ext_port_caps(dev, port); |
974 | } | 983 | } |
975 | 984 | ||
@@ -977,9 +986,11 @@ static int get_port_caps(struct mlx5_ib_dev *dev) | |||
977 | { | 986 | { |
978 | struct ib_device_attr *dprops = NULL; | 987 | struct ib_device_attr *dprops = NULL; |
979 | struct ib_port_attr *pprops = NULL; | 988 | struct ib_port_attr *pprops = NULL; |
989 | struct mlx5_general_caps *gen; | ||
980 | int err = 0; | 990 | int err = 0; |
981 | int port; | 991 | int port; |
982 | 992 | ||
993 | gen = &dev->mdev->caps.gen; | ||
983 | pprops = kmalloc(sizeof(*pprops), GFP_KERNEL); | 994 | pprops = kmalloc(sizeof(*pprops), GFP_KERNEL); |
984 | if (!pprops) | 995 | if (!pprops) |
985 | goto out; | 996 | goto out; |
@@ -994,14 +1005,14 @@ static int get_port_caps(struct mlx5_ib_dev *dev) | |||
994 | goto out; | 1005 | goto out; |
995 | } | 1006 | } |
996 | 1007 | ||
997 | for (port = 1; port <= dev->mdev->caps.num_ports; port++) { | 1008 | for (port = 1; port <= gen->num_ports; port++) { |
998 | err = mlx5_ib_query_port(&dev->ib_dev, port, pprops); | 1009 | err = mlx5_ib_query_port(&dev->ib_dev, port, pprops); |
999 | if (err) { | 1010 | if (err) { |
1000 | mlx5_ib_warn(dev, "query_port %d failed %d\n", port, err); | 1011 | mlx5_ib_warn(dev, "query_port %d failed %d\n", port, err); |
1001 | break; | 1012 | break; |
1002 | } | 1013 | } |
1003 | dev->mdev->caps.port[port - 1].pkey_table_len = dprops->max_pkeys; | 1014 | gen->port[port - 1].pkey_table_len = dprops->max_pkeys; |
1004 | dev->mdev->caps.port[port - 1].gid_table_len = pprops->gid_tbl_len; | 1015 | gen->port[port - 1].gid_table_len = pprops->gid_tbl_len; |
1005 | mlx5_ib_dbg(dev, "pkey_table_len %d, gid_table_len %d\n", | 1016 | mlx5_ib_dbg(dev, "pkey_table_len %d, gid_table_len %d\n", |
1006 | dprops->max_pkeys, pprops->gid_tbl_len); | 1017 | dprops->max_pkeys, pprops->gid_tbl_len); |
1007 | } | 1018 | } |
@@ -1279,8 +1290,8 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) | |||
1279 | strlcpy(dev->ib_dev.name, "mlx5_%d", IB_DEVICE_NAME_MAX); | 1290 | strlcpy(dev->ib_dev.name, "mlx5_%d", IB_DEVICE_NAME_MAX); |
1280 | dev->ib_dev.owner = THIS_MODULE; | 1291 | dev->ib_dev.owner = THIS_MODULE; |
1281 | dev->ib_dev.node_type = RDMA_NODE_IB_CA; | 1292 | dev->ib_dev.node_type = RDMA_NODE_IB_CA; |
1282 | dev->ib_dev.local_dma_lkey = mdev->caps.reserved_lkey; | 1293 | dev->ib_dev.local_dma_lkey = mdev->caps.gen.reserved_lkey; |
1283 | dev->num_ports = mdev->caps.num_ports; | 1294 | dev->num_ports = mdev->caps.gen.num_ports; |
1284 | dev->ib_dev.phys_port_cnt = dev->num_ports; | 1295 | dev->ib_dev.phys_port_cnt = dev->num_ports; |
1285 | dev->ib_dev.num_comp_vectors = dev->num_comp_vectors; | 1296 | dev->ib_dev.num_comp_vectors = dev->num_comp_vectors; |
1286 | dev->ib_dev.dma_device = &mdev->pdev->dev; | 1297 | dev->ib_dev.dma_device = &mdev->pdev->dev; |
@@ -1355,7 +1366,7 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) | |||
1355 | dev->ib_dev.free_fast_reg_page_list = mlx5_ib_free_fast_reg_page_list; | 1366 | dev->ib_dev.free_fast_reg_page_list = mlx5_ib_free_fast_reg_page_list; |
1356 | dev->ib_dev.check_mr_status = mlx5_ib_check_mr_status; | 1367 | dev->ib_dev.check_mr_status = mlx5_ib_check_mr_status; |
1357 | 1368 | ||
1358 | if (mdev->caps.flags & MLX5_DEV_CAP_FLAG_XRC) { | 1369 | if (mdev->caps.gen.flags & MLX5_DEV_CAP_FLAG_XRC) { |
1359 | dev->ib_dev.alloc_xrcd = mlx5_ib_alloc_xrcd; | 1370 | dev->ib_dev.alloc_xrcd = mlx5_ib_alloc_xrcd; |
1360 | dev->ib_dev.dealloc_xrcd = mlx5_ib_dealloc_xrcd; | 1371 | dev->ib_dev.dealloc_xrcd = mlx5_ib_dealloc_xrcd; |
1361 | dev->ib_dev.uverbs_cmd_mask |= | 1372 | dev->ib_dev.uverbs_cmd_mask |= |