Lines Matching refs:dev

52 void mlx4_qp_event(struct mlx4_dev *dev, u32 qpn, int event_type)  in mlx4_qp_event()  argument
54 struct mlx4_qp_table *qp_table = &mlx4_priv(dev)->qp_table; in mlx4_qp_event()
59 qp = __mlx4_qp_lookup(dev, qpn); in mlx4_qp_event()
66 mlx4_dbg(dev, "Async event for none existent QP %08x\n", qpn); in mlx4_qp_event()
77 static int is_master_qp0(struct mlx4_dev *dev, struct mlx4_qp *qp, int *real_qp0, int *proxy_qp0) in is_master_qp0() argument
81 u32 pf_proxy_offset = dev->phys_caps.base_proxy_sqpn + 8 * mlx4_master_func_num(dev); in is_master_qp0()
84 *real_qp0 = qp->qpn >= dev->phys_caps.base_sqpn && in is_master_qp0()
85 qp->qpn <= dev->phys_caps.base_sqpn + 1; in is_master_qp0()
90 static int __mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt, in __mlx4_qp_modify() argument
136 struct mlx4_priv *priv = mlx4_priv(dev); in __mlx4_qp_modify()
148 ret = mlx4_cmd(dev, 0, qp->qpn, 2, in __mlx4_qp_modify()
150 if (mlx4_is_master(dev) && cur_state != MLX4_QP_STATE_ERR && in __mlx4_qp_modify()
152 is_master_qp0(dev, qp, &real_qp0, &proxy_qp0)) { in __mlx4_qp_modify()
162 mailbox = mlx4_alloc_cmd_mailbox(dev); in __mlx4_qp_modify()
167 u64 mtt_addr = mlx4_mtt_addr(dev, mtt); in __mlx4_qp_modify()
179 ret = mlx4_cmd(dev, mailbox->dma, in __mlx4_qp_modify()
184 if (mlx4_is_master(dev) && is_master_qp0(dev, qp, &real_qp0, &proxy_qp0)) { in __mlx4_qp_modify()
201 mlx4_free_cmd_mailbox(dev, mailbox); in __mlx4_qp_modify()
205 int mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt, in mlx4_qp_modify() argument
211 return __mlx4_qp_modify(dev, mtt, cur_state, new_state, context, in mlx4_qp_modify()
216 int __mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, in __mlx4_qp_reserve_range() argument
221 struct mlx4_priv *priv = mlx4_priv(dev); in __mlx4_qp_reserve_range()
238 int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, in mlx4_qp_reserve_range() argument
245 if (mlx4_is_mfunc(dev)) { in mlx4_qp_reserve_range()
248 err = mlx4_cmd_imm(dev, in_param, &out_param, in mlx4_qp_reserve_range()
258 return __mlx4_qp_reserve_range(dev, cnt, align, base, flags); in mlx4_qp_reserve_range()
262 void __mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt) in __mlx4_qp_release_range() argument
264 struct mlx4_priv *priv = mlx4_priv(dev); in __mlx4_qp_release_range()
267 if (mlx4_is_qp_reserved(dev, (u32) base_qpn)) in __mlx4_qp_release_range()
272 void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt) in mlx4_qp_release_range() argument
277 if (mlx4_is_mfunc(dev)) { in mlx4_qp_release_range()
280 err = mlx4_cmd(dev, in_param, RES_QP, RES_OP_RESERVE, in mlx4_qp_release_range()
284 mlx4_warn(dev, "Failed to release qp range" in mlx4_qp_release_range()
288 __mlx4_qp_release_range(dev, base_qpn, cnt); in mlx4_qp_release_range()
292 int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn) in __mlx4_qp_alloc_icm() argument
294 struct mlx4_priv *priv = mlx4_priv(dev); in __mlx4_qp_alloc_icm()
298 err = mlx4_table_get(dev, &qp_table->qp_table, qpn); in __mlx4_qp_alloc_icm()
302 err = mlx4_table_get(dev, &qp_table->auxc_table, qpn); in __mlx4_qp_alloc_icm()
306 err = mlx4_table_get(dev, &qp_table->altc_table, qpn); in __mlx4_qp_alloc_icm()
310 err = mlx4_table_get(dev, &qp_table->rdmarc_table, qpn); in __mlx4_qp_alloc_icm()
314 err = mlx4_table_get(dev, &qp_table->cmpt_table, qpn); in __mlx4_qp_alloc_icm()
321 mlx4_table_put(dev, &qp_table->rdmarc_table, qpn); in __mlx4_qp_alloc_icm()
324 mlx4_table_put(dev, &qp_table->altc_table, qpn); in __mlx4_qp_alloc_icm()
327 mlx4_table_put(dev, &qp_table->auxc_table, qpn); in __mlx4_qp_alloc_icm()
330 mlx4_table_put(dev, &qp_table->qp_table, qpn); in __mlx4_qp_alloc_icm()
336 static int mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn) in mlx4_qp_alloc_icm() argument
340 if (mlx4_is_mfunc(dev)) { in mlx4_qp_alloc_icm()
342 return mlx4_cmd_imm(dev, param, &param, RES_QP, RES_OP_MAP_ICM, in mlx4_qp_alloc_icm()
346 return __mlx4_qp_alloc_icm(dev, qpn); in mlx4_qp_alloc_icm()
349 void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn) in __mlx4_qp_free_icm() argument
351 struct mlx4_priv *priv = mlx4_priv(dev); in __mlx4_qp_free_icm()
354 mlx4_table_put(dev, &qp_table->cmpt_table, qpn); in __mlx4_qp_free_icm()
355 mlx4_table_put(dev, &qp_table->rdmarc_table, qpn); in __mlx4_qp_free_icm()
356 mlx4_table_put(dev, &qp_table->altc_table, qpn); in __mlx4_qp_free_icm()
357 mlx4_table_put(dev, &qp_table->auxc_table, qpn); in __mlx4_qp_free_icm()
358 mlx4_table_put(dev, &qp_table->qp_table, qpn); in __mlx4_qp_free_icm()
361 static void mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn) in mlx4_qp_free_icm() argument
365 if (mlx4_is_mfunc(dev)) { in mlx4_qp_free_icm()
367 if (mlx4_cmd(dev, in_param, RES_QP, RES_OP_MAP_ICM, in mlx4_qp_free_icm()
370 mlx4_warn(dev, "Failed to free icm of qp:%d\n", qpn); in mlx4_qp_free_icm()
372 __mlx4_qp_free_icm(dev, qpn); in mlx4_qp_free_icm()
375 int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp) in mlx4_qp_alloc() argument
377 struct mlx4_priv *priv = mlx4_priv(dev); in mlx4_qp_alloc()
386 err = mlx4_qp_alloc_icm(dev, qpn); in mlx4_qp_alloc()
391 err = radix_tree_insert(&dev->qp_table_tree, qp->qpn & in mlx4_qp_alloc()
392 (dev->caps.num_qps - 1), qp); in mlx4_qp_alloc()
403 mlx4_qp_free_icm(dev, qpn); in mlx4_qp_alloc()
409 void mlx4_qp_remove(struct mlx4_dev *dev, struct mlx4_qp *qp) in mlx4_qp_remove() argument
411 struct mlx4_qp_table *qp_table = &mlx4_priv(dev)->qp_table; in mlx4_qp_remove()
415 radix_tree_delete(&dev->qp_table_tree, qp->qpn & (dev->caps.num_qps - 1)); in mlx4_qp_remove()
420 void mlx4_qp_free(struct mlx4_dev *dev, struct mlx4_qp *qp) in mlx4_qp_free() argument
426 mlx4_qp_free_icm(dev, qp->qpn); in mlx4_qp_free()
430 static int mlx4_CONF_SPECIAL_QP(struct mlx4_dev *dev, u32 base_qpn) in mlx4_CONF_SPECIAL_QP() argument
432 return mlx4_cmd(dev, 0, base_qpn, 0, MLX4_CMD_CONF_SPECIAL_QP, in mlx4_CONF_SPECIAL_QP()
436 int mlx4_init_qp_table(struct mlx4_dev *dev) in mlx4_init_qp_table() argument
438 struct mlx4_qp_table *qp_table = &mlx4_priv(dev)->qp_table; in mlx4_init_qp_table()
445 INIT_RADIX_TREE(&dev->qp_table_tree, GFP_ATOMIC); in mlx4_init_qp_table()
446 if (mlx4_is_slave(dev)) in mlx4_init_qp_table()
457 dev->phys_caps.base_sqpn = in mlx4_init_qp_table()
458 ALIGN(dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW], 8); in mlx4_init_qp_table()
463 int last_base = dev->caps.num_qps; in mlx4_init_qp_table()
470 if (dev->caps.reserved_qps_cnt[sort[j]] > in mlx4_init_qp_table()
471 dev->caps.reserved_qps_cnt[sort[j - 1]]) { in mlx4_init_qp_table()
480 last_base -= dev->caps.reserved_qps_cnt[sort[i]]; in mlx4_init_qp_table()
481 dev->caps.reserved_qps_base[sort[i]] = last_base; in mlx4_init_qp_table()
483 dev->caps.reserved_qps_cnt[sort[i]]; in mlx4_init_qp_table()
498 reserved_from_bot = mlx4_num_reserved_sqps(dev); in mlx4_init_qp_table()
499 if (reserved_from_bot + reserved_from_top > dev->caps.num_qps) { in mlx4_init_qp_table()
500 mlx4_err(dev, "Number of reserved QPs is higher than number " in mlx4_init_qp_table()
505 err = mlx4_bitmap_init(&qp_table->bitmap, dev->caps.num_qps, in mlx4_init_qp_table()
511 if (mlx4_is_mfunc(dev)) { in mlx4_init_qp_table()
513 dev->phys_caps.base_proxy_sqpn = dev->phys_caps.base_sqpn + 8; in mlx4_init_qp_table()
514 dev->phys_caps.base_tunnel_sqpn = dev->phys_caps.base_sqpn + 8 + 8 * MLX4_MFUNC_MAX; in mlx4_init_qp_table()
518 dev->caps.qp0_tunnel = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL); in mlx4_init_qp_table()
519 dev->caps.qp0_proxy = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL); in mlx4_init_qp_table()
520 dev->caps.qp1_tunnel = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL); in mlx4_init_qp_table()
521 dev->caps.qp1_proxy = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL); in mlx4_init_qp_table()
523 if (!dev->caps.qp0_tunnel || !dev->caps.qp0_proxy || in mlx4_init_qp_table()
524 !dev->caps.qp1_tunnel || !dev->caps.qp1_proxy) { in mlx4_init_qp_table()
529 for (k = 0; k < dev->caps.num_ports; k++) { in mlx4_init_qp_table()
530 dev->caps.qp0_proxy[k] = dev->phys_caps.base_proxy_sqpn + in mlx4_init_qp_table()
531 8 * mlx4_master_func_num(dev) + k; in mlx4_init_qp_table()
532 dev->caps.qp0_tunnel[k] = dev->caps.qp0_proxy[k] + 8 * MLX4_MFUNC_MAX; in mlx4_init_qp_table()
533 dev->caps.qp1_proxy[k] = dev->phys_caps.base_proxy_sqpn + in mlx4_init_qp_table()
534 8 * mlx4_master_func_num(dev) + MLX4_MAX_PORTS + k; in mlx4_init_qp_table()
535 dev->caps.qp1_tunnel[k] = dev->caps.qp1_proxy[k] + 8 * MLX4_MFUNC_MAX; in mlx4_init_qp_table()
540 err = mlx4_CONF_SPECIAL_QP(dev, dev->phys_caps.base_sqpn); in mlx4_init_qp_table()
546 kfree(dev->caps.qp0_tunnel); in mlx4_init_qp_table()
547 kfree(dev->caps.qp0_proxy); in mlx4_init_qp_table()
548 kfree(dev->caps.qp1_tunnel); in mlx4_init_qp_table()
549 kfree(dev->caps.qp1_proxy); in mlx4_init_qp_table()
550 dev->caps.qp0_tunnel = dev->caps.qp0_proxy = in mlx4_init_qp_table()
551 dev->caps.qp1_tunnel = dev->caps.qp1_proxy = NULL; in mlx4_init_qp_table()
555 void mlx4_cleanup_qp_table(struct mlx4_dev *dev) in mlx4_cleanup_qp_table() argument
557 if (mlx4_is_slave(dev)) in mlx4_cleanup_qp_table()
560 mlx4_CONF_SPECIAL_QP(dev, 0); in mlx4_cleanup_qp_table()
561 mlx4_bitmap_cleanup(&mlx4_priv(dev)->qp_table.bitmap); in mlx4_cleanup_qp_table()
564 int mlx4_qp_query(struct mlx4_dev *dev, struct mlx4_qp *qp, in mlx4_qp_query() argument
570 mailbox = mlx4_alloc_cmd_mailbox(dev); in mlx4_qp_query()
574 err = mlx4_cmd_box(dev, 0, mailbox->dma, qp->qpn, 0, in mlx4_qp_query()
580 mlx4_free_cmd_mailbox(dev, mailbox); in mlx4_qp_query()
585 int mlx4_qp_to_ready(struct mlx4_dev *dev, struct mlx4_mtt *mtt, in mlx4_qp_to_ready() argument
601 err = mlx4_qp_modify(dev, mtt, states[i], states[i + 1], in mlx4_qp_to_ready()
604 mlx4_err(dev, "Failed to bring QP to state: " in mlx4_qp_to_ready()