.. | .. |
---|
202 | 202 | rdma_ah_set_port_num(&ah_attr, port_num); |
---|
203 | 203 | |
---|
204 | 204 | new_ah = rdma_create_ah(dev->send_agent[port_num - 1][0]->qp->pd, |
---|
205 | | - &ah_attr); |
---|
| 205 | + &ah_attr, 0); |
---|
206 | 206 | if (IS_ERR(new_ah)) |
---|
207 | 207 | return; |
---|
208 | 208 | |
---|
209 | 209 | spin_lock_irqsave(&dev->sm_lock, flags); |
---|
210 | 210 | if (dev->sm_ah[port_num - 1]) |
---|
211 | | - rdma_destroy_ah(dev->sm_ah[port_num - 1]); |
---|
| 211 | + rdma_destroy_ah(dev->sm_ah[port_num - 1], 0); |
---|
212 | 212 | dev->sm_ah[port_num - 1] = new_ah; |
---|
213 | 213 | spin_unlock_irqrestore(&dev->sm_lock, flags); |
---|
214 | 214 | } |
---|
.. | .. |
---|
500 | 500 | sgid, dgid); |
---|
501 | 501 | } |
---|
502 | 502 | |
---|
| 503 | +static int is_proxy_qp0(struct mlx4_ib_dev *dev, int qpn, int slave) |
---|
| 504 | +{ |
---|
| 505 | + int proxy_start = dev->dev->phys_caps.base_proxy_sqpn + 8 * slave; |
---|
| 506 | + |
---|
| 507 | + return (qpn >= proxy_start && qpn <= proxy_start + 1); |
---|
| 508 | +} |
---|
| 509 | + |
---|
503 | 510 | int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port, |
---|
504 | 511 | enum ib_qp_type dest_qpt, struct ib_wc *wc, |
---|
505 | 512 | struct ib_grh *grh, struct ib_mad *mad) |
---|
.. | .. |
---|
520 | 527 | u16 cached_pkey; |
---|
521 | 528 | u8 is_eth = dev->dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH; |
---|
522 | 529 | |
---|
523 | | - if (dest_qpt > IB_QPT_GSI) |
---|
| 530 | + if (dest_qpt > IB_QPT_GSI) { |
---|
| 531 | + pr_debug("dest_qpt (%d) > IB_QPT_GSI\n", dest_qpt); |
---|
524 | 532 | return -EINVAL; |
---|
| 533 | + } |
---|
525 | 534 | |
---|
526 | 535 | tun_ctx = dev->sriov.demux[port-1].tun[slave]; |
---|
527 | 536 | |
---|
.. | .. |
---|
538 | 547 | if (dest_qpt) { |
---|
539 | 548 | u16 pkey_ix; |
---|
540 | 549 | ret = ib_get_cached_pkey(&dev->ib_dev, port, wc->pkey_index, &cached_pkey); |
---|
541 | | - if (ret) |
---|
| 550 | + if (ret) { |
---|
| 551 | + pr_debug("unable to get %s cached pkey for index %d, ret %d\n", |
---|
| 552 | + is_proxy_qp0(dev, wc->src_qp, slave) ? "SMI" : "GSI", |
---|
| 553 | + wc->pkey_index, ret); |
---|
542 | 554 | return -EINVAL; |
---|
| 555 | + } |
---|
543 | 556 | |
---|
544 | 557 | ret = find_slave_port_pkey_ix(dev, slave, port, cached_pkey, &pkey_ix); |
---|
545 | | - if (ret) |
---|
| 558 | + if (ret) { |
---|
| 559 | + pr_debug("unable to get %s pkey ix for pkey 0x%x, ret %d\n", |
---|
| 560 | + is_proxy_qp0(dev, wc->src_qp, slave) ? "SMI" : "GSI", |
---|
| 561 | + cached_pkey, ret); |
---|
546 | 562 | return -EINVAL; |
---|
| 563 | + } |
---|
547 | 564 | tun_pkey_ix = pkey_ix; |
---|
548 | 565 | } else |
---|
549 | 566 | tun_pkey_ix = dev->pkeys.virt2phys_pkey[slave][port - 1][0]; |
---|
.. | .. |
---|
567 | 584 | return -EINVAL; |
---|
568 | 585 | rdma_ah_set_grh(&attr, &dgid, 0, 0, 0, 0); |
---|
569 | 586 | } |
---|
570 | | - ah = rdma_create_ah(tun_ctx->pd, &attr); |
---|
| 587 | + ah = rdma_create_ah(tun_ctx->pd, &attr, 0); |
---|
571 | 588 | if (IS_ERR(ah)) |
---|
572 | 589 | return -ENOMEM; |
---|
573 | 590 | |
---|
.. | .. |
---|
584 | 601 | |
---|
585 | 602 | tun_mad = (struct mlx4_rcv_tunnel_mad *) (tun_qp->tx_ring[tun_tx_ix].buf.addr); |
---|
586 | 603 | if (tun_qp->tx_ring[tun_tx_ix].ah) |
---|
587 | | - rdma_destroy_ah(tun_qp->tx_ring[tun_tx_ix].ah); |
---|
| 604 | + rdma_destroy_ah(tun_qp->tx_ring[tun_tx_ix].ah, 0); |
---|
588 | 605 | tun_qp->tx_ring[tun_tx_ix].ah = ah; |
---|
589 | 606 | ib_dma_sync_single_for_cpu(&dev->ib_dev, |
---|
590 | 607 | tun_qp->tx_ring[tun_tx_ix].buf.map, |
---|
.. | .. |
---|
657 | 674 | spin_unlock(&tun_qp->tx_lock); |
---|
658 | 675 | tun_qp->tx_ring[tun_tx_ix].ah = NULL; |
---|
659 | 676 | end: |
---|
660 | | - rdma_destroy_ah(ah); |
---|
| 677 | + rdma_destroy_ah(ah, 0); |
---|
661 | 678 | return ret; |
---|
662 | 679 | } |
---|
663 | 680 | |
---|
.. | .. |
---|
715 | 732 | |
---|
716 | 733 | err = mlx4_ib_send_to_slave(dev, slave, port, wc->qp->qp_type, wc, grh, mad); |
---|
717 | 734 | if (err) |
---|
718 | | - pr_debug("failed sending to slave %d via tunnel qp (%d)\n", |
---|
| 735 | + pr_debug("failed sending %s to slave %d via tunnel qp (%d)\n", |
---|
| 736 | + is_proxy_qp0(dev, wc->src_qp, slave) ? "SMI" : "GSI", |
---|
719 | 737 | slave, err); |
---|
720 | 738 | return 0; |
---|
721 | 739 | } |
---|
.. | .. |
---|
794 | 812 | |
---|
795 | 813 | err = mlx4_ib_send_to_slave(dev, slave, port, wc->qp->qp_type, wc, grh, mad); |
---|
796 | 814 | if (err) |
---|
797 | | - pr_debug("failed sending to slave %d via tunnel qp (%d)\n", |
---|
| 815 | + pr_debug("failed sending %s to slave %d via tunnel qp (%d)\n", |
---|
| 816 | + is_proxy_qp0(dev, wc->src_qp, slave) ? "SMI" : "GSI", |
---|
798 | 817 | slave, err); |
---|
799 | 818 | return 0; |
---|
800 | 819 | } |
---|
.. | .. |
---|
806 | 825 | u16 slid, prev_lid = 0; |
---|
807 | 826 | int err; |
---|
808 | 827 | struct ib_port_attr pattr; |
---|
809 | | - |
---|
810 | | - if (in_wc && in_wc->qp->qp_num) { |
---|
811 | | - pr_debug("received MAD: slid:%d sqpn:%d " |
---|
812 | | - "dlid_bits:%d dqpn:%d wc_flags:0x%x, cls %x, mtd %x, atr %x\n", |
---|
813 | | - in_wc->slid, in_wc->src_qp, |
---|
814 | | - in_wc->dlid_path_bits, |
---|
815 | | - in_wc->qp->qp_num, |
---|
816 | | - in_wc->wc_flags, |
---|
817 | | - in_mad->mad_hdr.mgmt_class, in_mad->mad_hdr.method, |
---|
818 | | - be16_to_cpu(in_mad->mad_hdr.attr_id)); |
---|
819 | | - if (in_wc->wc_flags & IB_WC_GRH) { |
---|
820 | | - pr_debug("sgid_hi:0x%016llx sgid_lo:0x%016llx\n", |
---|
821 | | - be64_to_cpu(in_grh->sgid.global.subnet_prefix), |
---|
822 | | - be64_to_cpu(in_grh->sgid.global.interface_id)); |
---|
823 | | - pr_debug("dgid_hi:0x%016llx dgid_lo:0x%016llx\n", |
---|
824 | | - be64_to_cpu(in_grh->dgid.global.subnet_prefix), |
---|
825 | | - be64_to_cpu(in_grh->dgid.global.interface_id)); |
---|
826 | | - } |
---|
827 | | - } |
---|
828 | 828 | |
---|
829 | 829 | slid = in_wc ? ib_lid_cpu16(in_wc->slid) : be16_to_cpu(IB_LID_PERMISSIVE); |
---|
830 | 830 | |
---|
.. | .. |
---|
964 | 964 | } |
---|
965 | 965 | mutex_unlock(&dev->counters_table[port_num - 1].mutex); |
---|
966 | 966 | if (stats_avail) { |
---|
967 | | - memset(out_mad->data, 0, sizeof out_mad->data); |
---|
968 | 967 | switch (counter_stats.counter_mode & 0xf) { |
---|
969 | 968 | case 0: |
---|
970 | 969 | edit_counter(&counter_stats, |
---|
.. | .. |
---|
982 | 981 | |
---|
983 | 982 | int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, |
---|
984 | 983 | const struct ib_wc *in_wc, const struct ib_grh *in_grh, |
---|
985 | | - const struct ib_mad_hdr *in, size_t in_mad_size, |
---|
986 | | - struct ib_mad_hdr *out, size_t *out_mad_size, |
---|
987 | | - u16 *out_mad_pkey_index) |
---|
| 984 | + const struct ib_mad *in, struct ib_mad *out, |
---|
| 985 | + size_t *out_mad_size, u16 *out_mad_pkey_index) |
---|
988 | 986 | { |
---|
989 | 987 | struct mlx4_ib_dev *dev = to_mdev(ibdev); |
---|
990 | | - const struct ib_mad *in_mad = (const struct ib_mad *)in; |
---|
991 | | - struct ib_mad *out_mad = (struct ib_mad *)out; |
---|
992 | 988 | enum rdma_link_layer link = rdma_port_get_link_layer(ibdev, port_num); |
---|
993 | | - |
---|
994 | | - if (WARN_ON_ONCE(in_mad_size != sizeof(*in_mad) || |
---|
995 | | - *out_mad_size != sizeof(*out_mad))) |
---|
996 | | - return IB_MAD_RESULT_FAILURE; |
---|
997 | 989 | |
---|
998 | 990 | /* iboe_process_mad() which uses the HCA flow-counters to implement IB PMA |
---|
999 | 991 | * queries, should be called only by VFs and for that specific purpose |
---|
1000 | 992 | */ |
---|
1001 | 993 | if (link == IB_LINK_LAYER_INFINIBAND) { |
---|
1002 | 994 | if (mlx4_is_slave(dev->dev) && |
---|
1003 | | - (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT && |
---|
1004 | | - (in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS || |
---|
1005 | | - in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS_EXT || |
---|
1006 | | - in_mad->mad_hdr.attr_id == IB_PMA_CLASS_PORT_INFO))) |
---|
1007 | | - return iboe_process_mad(ibdev, mad_flags, port_num, in_wc, |
---|
1008 | | - in_grh, in_mad, out_mad); |
---|
| 995 | + (in->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT && |
---|
| 996 | + (in->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS || |
---|
| 997 | + in->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS_EXT || |
---|
| 998 | + in->mad_hdr.attr_id == IB_PMA_CLASS_PORT_INFO))) |
---|
| 999 | + return iboe_process_mad(ibdev, mad_flags, port_num, |
---|
| 1000 | + in_wc, in_grh, in, out); |
---|
1009 | 1001 | |
---|
1010 | | - return ib_process_mad(ibdev, mad_flags, port_num, in_wc, |
---|
1011 | | - in_grh, in_mad, out_mad); |
---|
| 1002 | + return ib_process_mad(ibdev, mad_flags, port_num, in_wc, in_grh, |
---|
| 1003 | + in, out); |
---|
1012 | 1004 | } |
---|
1013 | 1005 | |
---|
1014 | 1006 | if (link == IB_LINK_LAYER_ETHERNET) |
---|
1015 | 1007 | return iboe_process_mad(ibdev, mad_flags, port_num, in_wc, |
---|
1016 | | - in_grh, in_mad, out_mad); |
---|
| 1008 | + in_grh, in, out); |
---|
1017 | 1009 | |
---|
1018 | 1010 | return -EINVAL; |
---|
1019 | 1011 | } |
---|
.. | .. |
---|
1022 | 1014 | struct ib_mad_send_wc *mad_send_wc) |
---|
1023 | 1015 | { |
---|
1024 | 1016 | if (mad_send_wc->send_buf->context[0]) |
---|
1025 | | - rdma_destroy_ah(mad_send_wc->send_buf->context[0]); |
---|
| 1017 | + rdma_destroy_ah(mad_send_wc->send_buf->context[0], 0); |
---|
1026 | 1018 | ib_free_send_mad(mad_send_wc->send_buf); |
---|
1027 | 1019 | } |
---|
1028 | 1020 | |
---|
.. | .. |
---|
1077 | 1069 | } |
---|
1078 | 1070 | |
---|
1079 | 1071 | if (dev->sm_ah[p]) |
---|
1080 | | - rdma_destroy_ah(dev->sm_ah[p]); |
---|
| 1072 | + rdma_destroy_ah(dev->sm_ah[p], 0); |
---|
1081 | 1073 | } |
---|
1082 | 1074 | } |
---|
1083 | 1075 | |
---|
.. | .. |
---|
1359 | 1351 | return ret; |
---|
1360 | 1352 | } |
---|
1361 | 1353 | |
---|
1362 | | -static int is_proxy_qp0(struct mlx4_ib_dev *dev, int qpn, int slave) |
---|
1363 | | -{ |
---|
1364 | | - int proxy_start = dev->dev->phys_caps.base_proxy_sqpn + 8 * slave; |
---|
1365 | | - |
---|
1366 | | - return (qpn >= proxy_start && qpn <= proxy_start + 1); |
---|
1367 | | -} |
---|
1368 | | - |
---|
1369 | | - |
---|
1370 | 1354 | int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port, |
---|
1371 | 1355 | enum ib_qp_type dest_qpt, u16 pkey_index, |
---|
1372 | 1356 | u32 remote_qpn, u32 qkey, struct rdma_ah_attr *attr, |
---|
.. | .. |
---|
1381 | 1365 | struct ib_ah *ah; |
---|
1382 | 1366 | struct ib_qp *send_qp = NULL; |
---|
1383 | 1367 | unsigned wire_tx_ix = 0; |
---|
1384 | | - int ret = 0; |
---|
1385 | 1368 | u16 wire_pkey_ix; |
---|
1386 | 1369 | int src_qpnum; |
---|
| 1370 | + int ret; |
---|
1387 | 1371 | |
---|
1388 | 1372 | sqp_ctx = dev->sriov.sqps[port-1]; |
---|
1389 | 1373 | |
---|
.. | .. |
---|
1403 | 1387 | |
---|
1404 | 1388 | send_qp = sqp->qp; |
---|
1405 | 1389 | |
---|
1406 | | - /* create ah */ |
---|
1407 | | - ah = mlx4_ib_create_ah_slave(sqp_ctx->pd, attr, |
---|
1408 | | - rdma_ah_retrieve_grh(attr)->sgid_index, |
---|
1409 | | - s_mac, vlan_id); |
---|
1410 | | - if (IS_ERR(ah)) |
---|
| 1390 | + ah = rdma_zalloc_drv_obj(sqp_ctx->pd->device, ib_ah); |
---|
| 1391 | + if (!ah) |
---|
1411 | 1392 | return -ENOMEM; |
---|
| 1393 | + |
---|
| 1394 | + ah->device = sqp_ctx->pd->device; |
---|
| 1395 | + ah->pd = sqp_ctx->pd; |
---|
| 1396 | + |
---|
| 1397 | + /* create ah */ |
---|
| 1398 | + ret = mlx4_ib_create_ah_slave(ah, attr, |
---|
| 1399 | + rdma_ah_retrieve_grh(attr)->sgid_index, |
---|
| 1400 | + s_mac, vlan_id); |
---|
| 1401 | + if (ret) |
---|
| 1402 | + goto out; |
---|
| 1403 | + |
---|
1412 | 1404 | spin_lock(&sqp->tx_lock); |
---|
1413 | 1405 | if (sqp->tx_ix_head - sqp->tx_ix_tail >= |
---|
1414 | | - (MLX4_NUM_TUNNEL_BUFS - 1)) |
---|
| 1406 | + (MLX4_NUM_WIRE_BUFS - 1)) |
---|
1415 | 1407 | ret = -EAGAIN; |
---|
1416 | 1408 | else |
---|
1417 | | - wire_tx_ix = (++sqp->tx_ix_head) & (MLX4_NUM_TUNNEL_BUFS - 1); |
---|
| 1409 | + wire_tx_ix = (++sqp->tx_ix_head) & (MLX4_NUM_WIRE_BUFS - 1); |
---|
1418 | 1410 | spin_unlock(&sqp->tx_lock); |
---|
1419 | 1411 | if (ret) |
---|
1420 | 1412 | goto out; |
---|
1421 | 1413 | |
---|
1422 | 1414 | sqp_mad = (struct mlx4_mad_snd_buf *) (sqp->tx_ring[wire_tx_ix].buf.addr); |
---|
1423 | | - if (sqp->tx_ring[wire_tx_ix].ah) |
---|
1424 | | - rdma_destroy_ah(sqp->tx_ring[wire_tx_ix].ah); |
---|
| 1415 | + kfree(sqp->tx_ring[wire_tx_ix].ah); |
---|
1425 | 1416 | sqp->tx_ring[wire_tx_ix].ah = ah; |
---|
1426 | 1417 | ib_dma_sync_single_for_cpu(&dev->ib_dev, |
---|
1427 | 1418 | sqp->tx_ring[wire_tx_ix].buf.map, |
---|
.. | .. |
---|
1460 | 1451 | spin_unlock(&sqp->tx_lock); |
---|
1461 | 1452 | sqp->tx_ring[wire_tx_ix].ah = NULL; |
---|
1462 | 1453 | out: |
---|
1463 | | - mlx4_ib_destroy_ah(ah); |
---|
| 1454 | + kfree(ah); |
---|
1464 | 1455 | return ret; |
---|
1465 | 1456 | } |
---|
1466 | 1457 | |
---|
.. | .. |
---|
1495 | 1486 | u16 vlan_id; |
---|
1496 | 1487 | u8 qos; |
---|
1497 | 1488 | u8 *dmac; |
---|
| 1489 | + int sts; |
---|
1498 | 1490 | |
---|
1499 | 1491 | /* Get slave that sent this packet */ |
---|
1500 | 1492 | if (wc->src_qp < dev->dev->phys_caps.base_proxy_sqpn || |
---|
.. | .. |
---|
1591 | 1583 | &vlan_id, &qos)) |
---|
1592 | 1584 | rdma_ah_set_sl(&ah_attr, qos); |
---|
1593 | 1585 | |
---|
1594 | | - mlx4_ib_send_to_wire(dev, slave, ctx->port, |
---|
1595 | | - is_proxy_qp0(dev, wc->src_qp, slave) ? |
---|
1596 | | - IB_QPT_SMI : IB_QPT_GSI, |
---|
1597 | | - be16_to_cpu(tunnel->hdr.pkey_index), |
---|
1598 | | - be32_to_cpu(tunnel->hdr.remote_qpn), |
---|
1599 | | - be32_to_cpu(tunnel->hdr.qkey), |
---|
1600 | | - &ah_attr, wc->smac, vlan_id, &tunnel->mad); |
---|
| 1586 | + sts = mlx4_ib_send_to_wire(dev, slave, ctx->port, |
---|
| 1587 | + is_proxy_qp0(dev, wc->src_qp, slave) ? |
---|
| 1588 | + IB_QPT_SMI : IB_QPT_GSI, |
---|
| 1589 | + be16_to_cpu(tunnel->hdr.pkey_index), |
---|
| 1590 | + be32_to_cpu(tunnel->hdr.remote_qpn), |
---|
| 1591 | + be32_to_cpu(tunnel->hdr.qkey), |
---|
| 1592 | + &ah_attr, wc->smac, vlan_id, &tunnel->mad); |
---|
| 1593 | + if (sts) |
---|
| 1594 | + pr_debug("failed sending %s to wire on behalf of slave %d (%d)\n", |
---|
| 1595 | + is_proxy_qp0(dev, wc->src_qp, slave) ? "SMI" : "GSI", |
---|
| 1596 | + slave, sts); |
---|
1601 | 1597 | } |
---|
1602 | 1598 | |
---|
1603 | 1599 | static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx, |
---|
.. | .. |
---|
1606 | 1602 | int i; |
---|
1607 | 1603 | struct mlx4_ib_demux_pv_qp *tun_qp; |
---|
1608 | 1604 | int rx_buf_size, tx_buf_size; |
---|
| 1605 | + const int nmbr_bufs = is_tun ? MLX4_NUM_TUNNEL_BUFS : MLX4_NUM_WIRE_BUFS; |
---|
1609 | 1606 | |
---|
1610 | 1607 | if (qp_type > IB_QPT_GSI) |
---|
1611 | 1608 | return -EINVAL; |
---|
1612 | 1609 | |
---|
1613 | 1610 | tun_qp = &ctx->qp[qp_type]; |
---|
1614 | 1611 | |
---|
1615 | | - tun_qp->ring = kcalloc(MLX4_NUM_TUNNEL_BUFS, |
---|
| 1612 | + tun_qp->ring = kcalloc(nmbr_bufs, |
---|
1616 | 1613 | sizeof(struct mlx4_ib_buf), |
---|
1617 | 1614 | GFP_KERNEL); |
---|
1618 | 1615 | if (!tun_qp->ring) |
---|
1619 | 1616 | return -ENOMEM; |
---|
1620 | 1617 | |
---|
1621 | | - tun_qp->tx_ring = kcalloc(MLX4_NUM_TUNNEL_BUFS, |
---|
| 1618 | + tun_qp->tx_ring = kcalloc(nmbr_bufs, |
---|
1622 | 1619 | sizeof (struct mlx4_ib_tun_tx_buf), |
---|
1623 | 1620 | GFP_KERNEL); |
---|
1624 | 1621 | if (!tun_qp->tx_ring) { |
---|
.. | .. |
---|
1635 | 1632 | tx_buf_size = sizeof (struct mlx4_mad_snd_buf); |
---|
1636 | 1633 | } |
---|
1637 | 1634 | |
---|
1638 | | - for (i = 0; i < MLX4_NUM_TUNNEL_BUFS; i++) { |
---|
| 1635 | + for (i = 0; i < nmbr_bufs; i++) { |
---|
1639 | 1636 | tun_qp->ring[i].addr = kmalloc(rx_buf_size, GFP_KERNEL); |
---|
1640 | 1637 | if (!tun_qp->ring[i].addr) |
---|
1641 | 1638 | goto err; |
---|
.. | .. |
---|
1649 | 1646 | } |
---|
1650 | 1647 | } |
---|
1651 | 1648 | |
---|
1652 | | - for (i = 0; i < MLX4_NUM_TUNNEL_BUFS; i++) { |
---|
| 1649 | + for (i = 0; i < nmbr_bufs; i++) { |
---|
1653 | 1650 | tun_qp->tx_ring[i].buf.addr = |
---|
1654 | 1651 | kmalloc(tx_buf_size, GFP_KERNEL); |
---|
1655 | 1652 | if (!tun_qp->tx_ring[i].buf.addr) |
---|
.. | .. |
---|
1680 | 1677 | tx_buf_size, DMA_TO_DEVICE); |
---|
1681 | 1678 | kfree(tun_qp->tx_ring[i].buf.addr); |
---|
1682 | 1679 | } |
---|
1683 | | - i = MLX4_NUM_TUNNEL_BUFS; |
---|
| 1680 | + i = nmbr_bufs; |
---|
1684 | 1681 | err: |
---|
1685 | 1682 | while (i > 0) { |
---|
1686 | 1683 | --i; |
---|
.. | .. |
---|
1701 | 1698 | int i; |
---|
1702 | 1699 | struct mlx4_ib_demux_pv_qp *tun_qp; |
---|
1703 | 1700 | int rx_buf_size, tx_buf_size; |
---|
| 1701 | + const int nmbr_bufs = is_tun ? MLX4_NUM_TUNNEL_BUFS : MLX4_NUM_WIRE_BUFS; |
---|
1704 | 1702 | |
---|
1705 | 1703 | if (qp_type > IB_QPT_GSI) |
---|
1706 | 1704 | return; |
---|
.. | .. |
---|
1715 | 1713 | } |
---|
1716 | 1714 | |
---|
1717 | 1715 | |
---|
1718 | | - for (i = 0; i < MLX4_NUM_TUNNEL_BUFS; i++) { |
---|
| 1716 | + for (i = 0; i < nmbr_bufs; i++) { |
---|
1719 | 1717 | ib_dma_unmap_single(ctx->ib_dev, tun_qp->ring[i].map, |
---|
1720 | 1718 | rx_buf_size, DMA_FROM_DEVICE); |
---|
1721 | 1719 | kfree(tun_qp->ring[i].addr); |
---|
1722 | 1720 | } |
---|
1723 | 1721 | |
---|
1724 | | - for (i = 0; i < MLX4_NUM_TUNNEL_BUFS; i++) { |
---|
| 1722 | + for (i = 0; i < nmbr_bufs; i++) { |
---|
1725 | 1723 | ib_dma_unmap_single(ctx->ib_dev, tun_qp->tx_ring[i].buf.map, |
---|
1726 | 1724 | tx_buf_size, DMA_TO_DEVICE); |
---|
1727 | 1725 | kfree(tun_qp->tx_ring[i].buf.addr); |
---|
1728 | 1726 | if (tun_qp->tx_ring[i].ah) |
---|
1729 | | - rdma_destroy_ah(tun_qp->tx_ring[i].ah); |
---|
| 1727 | + rdma_destroy_ah(tun_qp->tx_ring[i].ah, 0); |
---|
1730 | 1728 | } |
---|
1731 | 1729 | kfree(tun_qp->tx_ring); |
---|
1732 | 1730 | kfree(tun_qp->ring); |
---|
.. | .. |
---|
1755 | 1753 | "buf:%lld\n", wc.wr_id); |
---|
1756 | 1754 | break; |
---|
1757 | 1755 | case IB_WC_SEND: |
---|
1758 | | - pr_debug("received tunnel send completion:" |
---|
1759 | | - "wrid=0x%llx, status=0x%x\n", |
---|
1760 | | - wc.wr_id, wc.status); |
---|
1761 | 1756 | rdma_destroy_ah(tun_qp->tx_ring[wc.wr_id & |
---|
1762 | | - (MLX4_NUM_TUNNEL_BUFS - 1)].ah); |
---|
| 1757 | + (MLX4_NUM_TUNNEL_BUFS - 1)].ah, 0); |
---|
1763 | 1758 | tun_qp->tx_ring[wc.wr_id & (MLX4_NUM_TUNNEL_BUFS - 1)].ah |
---|
1764 | 1759 | = NULL; |
---|
1765 | 1760 | spin_lock(&tun_qp->tx_lock); |
---|
.. | .. |
---|
1776 | 1771 | ctx->slave, wc.status, wc.wr_id); |
---|
1777 | 1772 | if (!MLX4_TUN_IS_RECV(wc.wr_id)) { |
---|
1778 | 1773 | rdma_destroy_ah(tun_qp->tx_ring[wc.wr_id & |
---|
1779 | | - (MLX4_NUM_TUNNEL_BUFS - 1)].ah); |
---|
| 1774 | + (MLX4_NUM_TUNNEL_BUFS - 1)].ah, 0); |
---|
1780 | 1775 | tun_qp->tx_ring[wc.wr_id & (MLX4_NUM_TUNNEL_BUFS - 1)].ah |
---|
1781 | 1776 | = NULL; |
---|
1782 | 1777 | spin_lock(&tun_qp->tx_lock); |
---|
.. | .. |
---|
1804 | 1799 | struct mlx4_ib_qp_tunnel_init_attr qp_init_attr; |
---|
1805 | 1800 | struct ib_qp_attr attr; |
---|
1806 | 1801 | int qp_attr_mask_INIT; |
---|
| 1802 | + const int nmbr_bufs = create_tun ? MLX4_NUM_TUNNEL_BUFS : MLX4_NUM_WIRE_BUFS; |
---|
1807 | 1803 | |
---|
1808 | 1804 | if (qp_type > IB_QPT_GSI) |
---|
1809 | 1805 | return -EINVAL; |
---|
.. | .. |
---|
1814 | 1810 | qp_init_attr.init_attr.send_cq = ctx->cq; |
---|
1815 | 1811 | qp_init_attr.init_attr.recv_cq = ctx->cq; |
---|
1816 | 1812 | qp_init_attr.init_attr.sq_sig_type = IB_SIGNAL_ALL_WR; |
---|
1817 | | - qp_init_attr.init_attr.cap.max_send_wr = MLX4_NUM_TUNNEL_BUFS; |
---|
1818 | | - qp_init_attr.init_attr.cap.max_recv_wr = MLX4_NUM_TUNNEL_BUFS; |
---|
| 1813 | + qp_init_attr.init_attr.cap.max_send_wr = nmbr_bufs; |
---|
| 1814 | + qp_init_attr.init_attr.cap.max_recv_wr = nmbr_bufs; |
---|
1819 | 1815 | qp_init_attr.init_attr.cap.max_send_sge = 1; |
---|
1820 | 1816 | qp_init_attr.init_attr.cap.max_recv_sge = 1; |
---|
1821 | 1817 | if (create_tun) { |
---|
.. | .. |
---|
1877 | 1873 | goto err_qp; |
---|
1878 | 1874 | } |
---|
1879 | 1875 | |
---|
1880 | | - for (i = 0; i < MLX4_NUM_TUNNEL_BUFS; i++) { |
---|
| 1876 | + for (i = 0; i < nmbr_bufs; i++) { |
---|
1881 | 1877 | ret = mlx4_ib_post_pv_qp_buf(ctx, tun_qp, i); |
---|
1882 | 1878 | if (ret) { |
---|
1883 | 1879 | pr_err(" mlx4_ib_post_pv_buf error" |
---|
.. | .. |
---|
1912 | 1908 | if (wc.status == IB_WC_SUCCESS) { |
---|
1913 | 1909 | switch (wc.opcode) { |
---|
1914 | 1910 | case IB_WC_SEND: |
---|
1915 | | - rdma_destroy_ah(sqp->tx_ring[wc.wr_id & |
---|
1916 | | - (MLX4_NUM_TUNNEL_BUFS - 1)].ah); |
---|
1917 | | - sqp->tx_ring[wc.wr_id & (MLX4_NUM_TUNNEL_BUFS - 1)].ah |
---|
| 1911 | + kfree(sqp->tx_ring[wc.wr_id & |
---|
| 1912 | + (MLX4_NUM_WIRE_BUFS - 1)].ah); |
---|
| 1913 | + sqp->tx_ring[wc.wr_id & (MLX4_NUM_WIRE_BUFS - 1)].ah |
---|
1918 | 1914 | = NULL; |
---|
1919 | 1915 | spin_lock(&sqp->tx_lock); |
---|
1920 | 1916 | sqp->tx_ix_tail++; |
---|
.. | .. |
---|
1923 | 1919 | case IB_WC_RECV: |
---|
1924 | 1920 | mad = (struct ib_mad *) &(((struct mlx4_mad_rcv_buf *) |
---|
1925 | 1921 | (sqp->ring[wc.wr_id & |
---|
1926 | | - (MLX4_NUM_TUNNEL_BUFS - 1)].addr))->payload); |
---|
| 1922 | + (MLX4_NUM_WIRE_BUFS - 1)].addr))->payload); |
---|
1927 | 1923 | grh = &(((struct mlx4_mad_rcv_buf *) |
---|
1928 | 1924 | (sqp->ring[wc.wr_id & |
---|
1929 | | - (MLX4_NUM_TUNNEL_BUFS - 1)].addr))->grh); |
---|
| 1925 | + (MLX4_NUM_WIRE_BUFS - 1)].addr))->grh); |
---|
1930 | 1926 | mlx4_ib_demux_mad(ctx->ib_dev, ctx->port, &wc, grh, mad); |
---|
1931 | 1927 | if (mlx4_ib_post_pv_qp_buf(ctx, sqp, wc.wr_id & |
---|
1932 | | - (MLX4_NUM_TUNNEL_BUFS - 1))) |
---|
| 1928 | + (MLX4_NUM_WIRE_BUFS - 1))) |
---|
1933 | 1929 | pr_err("Failed reposting SQP " |
---|
1934 | 1930 | "buf:%lld\n", wc.wr_id); |
---|
1935 | 1931 | break; |
---|
.. | .. |
---|
1941 | 1937 | " status = %d, wrid = 0x%llx\n", |
---|
1942 | 1938 | ctx->slave, wc.status, wc.wr_id); |
---|
1943 | 1939 | if (!MLX4_TUN_IS_RECV(wc.wr_id)) { |
---|
1944 | | - rdma_destroy_ah(sqp->tx_ring[wc.wr_id & |
---|
1945 | | - (MLX4_NUM_TUNNEL_BUFS - 1)].ah); |
---|
1946 | | - sqp->tx_ring[wc.wr_id & (MLX4_NUM_TUNNEL_BUFS - 1)].ah |
---|
| 1940 | + kfree(sqp->tx_ring[wc.wr_id & |
---|
| 1941 | + (MLX4_NUM_WIRE_BUFS - 1)].ah); |
---|
| 1942 | + sqp->tx_ring[wc.wr_id & (MLX4_NUM_WIRE_BUFS - 1)].ah |
---|
1947 | 1943 | = NULL; |
---|
1948 | 1944 | spin_lock(&sqp->tx_lock); |
---|
1949 | 1945 | sqp->tx_ix_tail++; |
---|
.. | .. |
---|
1983 | 1979 | { |
---|
1984 | 1980 | int ret, cq_size; |
---|
1985 | 1981 | struct ib_cq_init_attr cq_attr = {}; |
---|
| 1982 | + const int nmbr_bufs = create_tun ? MLX4_NUM_TUNNEL_BUFS : MLX4_NUM_WIRE_BUFS; |
---|
1986 | 1983 | |
---|
1987 | 1984 | if (ctx->state != DEMUX_PV_STATE_DOWN) |
---|
1988 | 1985 | return -EEXIST; |
---|
.. | .. |
---|
2007 | 2004 | goto err_out_qp0; |
---|
2008 | 2005 | } |
---|
2009 | 2006 | |
---|
2010 | | - cq_size = 2 * MLX4_NUM_TUNNEL_BUFS; |
---|
| 2007 | + cq_size = 2 * nmbr_bufs; |
---|
2011 | 2008 | if (ctx->has_smi) |
---|
2012 | 2009 | cq_size *= 2; |
---|
2013 | 2010 | |
---|