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