hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/infiniband/hw/mlx4/mad.c
....@@ -202,13 +202,13 @@
202202 rdma_ah_set_port_num(&ah_attr, port_num);
203203
204204 new_ah = rdma_create_ah(dev->send_agent[port_num - 1][0]->qp->pd,
205
- &ah_attr);
205
+ &ah_attr, 0);
206206 if (IS_ERR(new_ah))
207207 return;
208208
209209 spin_lock_irqsave(&dev->sm_lock, flags);
210210 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);
212212 dev->sm_ah[port_num - 1] = new_ah;
213213 spin_unlock_irqrestore(&dev->sm_lock, flags);
214214 }
....@@ -500,6 +500,13 @@
500500 sgid, dgid);
501501 }
502502
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
+
503510 int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
504511 enum ib_qp_type dest_qpt, struct ib_wc *wc,
505512 struct ib_grh *grh, struct ib_mad *mad)
....@@ -520,8 +527,10 @@
520527 u16 cached_pkey;
521528 u8 is_eth = dev->dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH;
522529
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);
524532 return -EINVAL;
533
+ }
525534
526535 tun_ctx = dev->sriov.demux[port-1].tun[slave];
527536
....@@ -538,12 +547,20 @@
538547 if (dest_qpt) {
539548 u16 pkey_ix;
540549 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);
542554 return -EINVAL;
555
+ }
543556
544557 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);
546562 return -EINVAL;
563
+ }
547564 tun_pkey_ix = pkey_ix;
548565 } else
549566 tun_pkey_ix = dev->pkeys.virt2phys_pkey[slave][port - 1][0];
....@@ -567,7 +584,7 @@
567584 return -EINVAL;
568585 rdma_ah_set_grh(&attr, &dgid, 0, 0, 0, 0);
569586 }
570
- ah = rdma_create_ah(tun_ctx->pd, &attr);
587
+ ah = rdma_create_ah(tun_ctx->pd, &attr, 0);
571588 if (IS_ERR(ah))
572589 return -ENOMEM;
573590
....@@ -584,7 +601,7 @@
584601
585602 tun_mad = (struct mlx4_rcv_tunnel_mad *) (tun_qp->tx_ring[tun_tx_ix].buf.addr);
586603 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);
588605 tun_qp->tx_ring[tun_tx_ix].ah = ah;
589606 ib_dma_sync_single_for_cpu(&dev->ib_dev,
590607 tun_qp->tx_ring[tun_tx_ix].buf.map,
....@@ -657,7 +674,7 @@
657674 spin_unlock(&tun_qp->tx_lock);
658675 tun_qp->tx_ring[tun_tx_ix].ah = NULL;
659676 end:
660
- rdma_destroy_ah(ah);
677
+ rdma_destroy_ah(ah, 0);
661678 return ret;
662679 }
663680
....@@ -715,7 +732,8 @@
715732
716733 err = mlx4_ib_send_to_slave(dev, slave, port, wc->qp->qp_type, wc, grh, mad);
717734 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",
719737 slave, err);
720738 return 0;
721739 }
....@@ -794,7 +812,8 @@
794812
795813 err = mlx4_ib_send_to_slave(dev, slave, port, wc->qp->qp_type, wc, grh, mad);
796814 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",
798817 slave, err);
799818 return 0;
800819 }
....@@ -806,25 +825,6 @@
806825 u16 slid, prev_lid = 0;
807826 int err;
808827 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
- }
828828
829829 slid = in_wc ? ib_lid_cpu16(in_wc->slid) : be16_to_cpu(IB_LID_PERMISSIVE);
830830
....@@ -964,7 +964,6 @@
964964 }
965965 mutex_unlock(&dev->counters_table[port_num - 1].mutex);
966966 if (stats_avail) {
967
- memset(out_mad->data, 0, sizeof out_mad->data);
968967 switch (counter_stats.counter_mode & 0xf) {
969968 case 0:
970969 edit_counter(&counter_stats,
....@@ -982,38 +981,31 @@
982981
983982 int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
984983 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)
988986 {
989987 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;
992988 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;
997989
998990 /* iboe_process_mad() which uses the HCA flow-counters to implement IB PMA
999991 * queries, should be called only by VFs and for that specific purpose
1000992 */
1001993 if (link == IB_LINK_LAYER_INFINIBAND) {
1002994 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);
10091001
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);
10121004 }
10131005
10141006 if (link == IB_LINK_LAYER_ETHERNET)
10151007 return iboe_process_mad(ibdev, mad_flags, port_num, in_wc,
1016
- in_grh, in_mad, out_mad);
1008
+ in_grh, in, out);
10171009
10181010 return -EINVAL;
10191011 }
....@@ -1022,7 +1014,7 @@
10221014 struct ib_mad_send_wc *mad_send_wc)
10231015 {
10241016 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);
10261018 ib_free_send_mad(mad_send_wc->send_buf);
10271019 }
10281020
....@@ -1077,7 +1069,7 @@
10771069 }
10781070
10791071 if (dev->sm_ah[p])
1080
- rdma_destroy_ah(dev->sm_ah[p]);
1072
+ rdma_destroy_ah(dev->sm_ah[p], 0);
10811073 }
10821074 }
10831075
....@@ -1359,14 +1351,6 @@
13591351 return ret;
13601352 }
13611353
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
-
13701354 int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
13711355 enum ib_qp_type dest_qpt, u16 pkey_index,
13721356 u32 remote_qpn, u32 qkey, struct rdma_ah_attr *attr,
....@@ -1381,9 +1365,9 @@
13811365 struct ib_ah *ah;
13821366 struct ib_qp *send_qp = NULL;
13831367 unsigned wire_tx_ix = 0;
1384
- int ret = 0;
13851368 u16 wire_pkey_ix;
13861369 int src_qpnum;
1370
+ int ret;
13871371
13881372 sqp_ctx = dev->sriov.sqps[port-1];
13891373
....@@ -1403,25 +1387,32 @@
14031387
14041388 send_qp = sqp->qp;
14051389
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)
14111392 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
+
14121404 spin_lock(&sqp->tx_lock);
14131405 if (sqp->tx_ix_head - sqp->tx_ix_tail >=
1414
- (MLX4_NUM_TUNNEL_BUFS - 1))
1406
+ (MLX4_NUM_WIRE_BUFS - 1))
14151407 ret = -EAGAIN;
14161408 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);
14181410 spin_unlock(&sqp->tx_lock);
14191411 if (ret)
14201412 goto out;
14211413
14221414 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);
14251416 sqp->tx_ring[wire_tx_ix].ah = ah;
14261417 ib_dma_sync_single_for_cpu(&dev->ib_dev,
14271418 sqp->tx_ring[wire_tx_ix].buf.map,
....@@ -1460,7 +1451,7 @@
14601451 spin_unlock(&sqp->tx_lock);
14611452 sqp->tx_ring[wire_tx_ix].ah = NULL;
14621453 out:
1463
- mlx4_ib_destroy_ah(ah);
1454
+ kfree(ah);
14641455 return ret;
14651456 }
14661457
....@@ -1495,6 +1486,7 @@
14951486 u16 vlan_id;
14961487 u8 qos;
14971488 u8 *dmac;
1489
+ int sts;
14981490
14991491 /* Get slave that sent this packet */
15001492 if (wc->src_qp < dev->dev->phys_caps.base_proxy_sqpn ||
....@@ -1591,13 +1583,17 @@
15911583 &vlan_id, &qos))
15921584 rdma_ah_set_sl(&ah_attr, qos);
15931585
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);
16011597 }
16021598
16031599 static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
....@@ -1606,19 +1602,20 @@
16061602 int i;
16071603 struct mlx4_ib_demux_pv_qp *tun_qp;
16081604 int rx_buf_size, tx_buf_size;
1605
+ const int nmbr_bufs = is_tun ? MLX4_NUM_TUNNEL_BUFS : MLX4_NUM_WIRE_BUFS;
16091606
16101607 if (qp_type > IB_QPT_GSI)
16111608 return -EINVAL;
16121609
16131610 tun_qp = &ctx->qp[qp_type];
16141611
1615
- tun_qp->ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
1612
+ tun_qp->ring = kcalloc(nmbr_bufs,
16161613 sizeof(struct mlx4_ib_buf),
16171614 GFP_KERNEL);
16181615 if (!tun_qp->ring)
16191616 return -ENOMEM;
16201617
1621
- tun_qp->tx_ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
1618
+ tun_qp->tx_ring = kcalloc(nmbr_bufs,
16221619 sizeof (struct mlx4_ib_tun_tx_buf),
16231620 GFP_KERNEL);
16241621 if (!tun_qp->tx_ring) {
....@@ -1635,7 +1632,7 @@
16351632 tx_buf_size = sizeof (struct mlx4_mad_snd_buf);
16361633 }
16371634
1638
- for (i = 0; i < MLX4_NUM_TUNNEL_BUFS; i++) {
1635
+ for (i = 0; i < nmbr_bufs; i++) {
16391636 tun_qp->ring[i].addr = kmalloc(rx_buf_size, GFP_KERNEL);
16401637 if (!tun_qp->ring[i].addr)
16411638 goto err;
....@@ -1649,7 +1646,7 @@
16491646 }
16501647 }
16511648
1652
- for (i = 0; i < MLX4_NUM_TUNNEL_BUFS; i++) {
1649
+ for (i = 0; i < nmbr_bufs; i++) {
16531650 tun_qp->tx_ring[i].buf.addr =
16541651 kmalloc(tx_buf_size, GFP_KERNEL);
16551652 if (!tun_qp->tx_ring[i].buf.addr)
....@@ -1680,7 +1677,7 @@
16801677 tx_buf_size, DMA_TO_DEVICE);
16811678 kfree(tun_qp->tx_ring[i].buf.addr);
16821679 }
1683
- i = MLX4_NUM_TUNNEL_BUFS;
1680
+ i = nmbr_bufs;
16841681 err:
16851682 while (i > 0) {
16861683 --i;
....@@ -1701,6 +1698,7 @@
17011698 int i;
17021699 struct mlx4_ib_demux_pv_qp *tun_qp;
17031700 int rx_buf_size, tx_buf_size;
1701
+ const int nmbr_bufs = is_tun ? MLX4_NUM_TUNNEL_BUFS : MLX4_NUM_WIRE_BUFS;
17041702
17051703 if (qp_type > IB_QPT_GSI)
17061704 return;
....@@ -1715,18 +1713,18 @@
17151713 }
17161714
17171715
1718
- for (i = 0; i < MLX4_NUM_TUNNEL_BUFS; i++) {
1716
+ for (i = 0; i < nmbr_bufs; i++) {
17191717 ib_dma_unmap_single(ctx->ib_dev, tun_qp->ring[i].map,
17201718 rx_buf_size, DMA_FROM_DEVICE);
17211719 kfree(tun_qp->ring[i].addr);
17221720 }
17231721
1724
- for (i = 0; i < MLX4_NUM_TUNNEL_BUFS; i++) {
1722
+ for (i = 0; i < nmbr_bufs; i++) {
17251723 ib_dma_unmap_single(ctx->ib_dev, tun_qp->tx_ring[i].buf.map,
17261724 tx_buf_size, DMA_TO_DEVICE);
17271725 kfree(tun_qp->tx_ring[i].buf.addr);
17281726 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);
17301728 }
17311729 kfree(tun_qp->tx_ring);
17321730 kfree(tun_qp->ring);
....@@ -1755,11 +1753,8 @@
17551753 "buf:%lld\n", wc.wr_id);
17561754 break;
17571755 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);
17611756 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);
17631758 tun_qp->tx_ring[wc.wr_id & (MLX4_NUM_TUNNEL_BUFS - 1)].ah
17641759 = NULL;
17651760 spin_lock(&tun_qp->tx_lock);
....@@ -1776,7 +1771,7 @@
17761771 ctx->slave, wc.status, wc.wr_id);
17771772 if (!MLX4_TUN_IS_RECV(wc.wr_id)) {
17781773 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);
17801775 tun_qp->tx_ring[wc.wr_id & (MLX4_NUM_TUNNEL_BUFS - 1)].ah
17811776 = NULL;
17821777 spin_lock(&tun_qp->tx_lock);
....@@ -1804,6 +1799,7 @@
18041799 struct mlx4_ib_qp_tunnel_init_attr qp_init_attr;
18051800 struct ib_qp_attr attr;
18061801 int qp_attr_mask_INIT;
1802
+ const int nmbr_bufs = create_tun ? MLX4_NUM_TUNNEL_BUFS : MLX4_NUM_WIRE_BUFS;
18071803
18081804 if (qp_type > IB_QPT_GSI)
18091805 return -EINVAL;
....@@ -1814,8 +1810,8 @@
18141810 qp_init_attr.init_attr.send_cq = ctx->cq;
18151811 qp_init_attr.init_attr.recv_cq = ctx->cq;
18161812 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;
18191815 qp_init_attr.init_attr.cap.max_send_sge = 1;
18201816 qp_init_attr.init_attr.cap.max_recv_sge = 1;
18211817 if (create_tun) {
....@@ -1877,7 +1873,7 @@
18771873 goto err_qp;
18781874 }
18791875
1880
- for (i = 0; i < MLX4_NUM_TUNNEL_BUFS; i++) {
1876
+ for (i = 0; i < nmbr_bufs; i++) {
18811877 ret = mlx4_ib_post_pv_qp_buf(ctx, tun_qp, i);
18821878 if (ret) {
18831879 pr_err(" mlx4_ib_post_pv_buf error"
....@@ -1912,9 +1908,9 @@
19121908 if (wc.status == IB_WC_SUCCESS) {
19131909 switch (wc.opcode) {
19141910 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
19181914 = NULL;
19191915 spin_lock(&sqp->tx_lock);
19201916 sqp->tx_ix_tail++;
....@@ -1923,13 +1919,13 @@
19231919 case IB_WC_RECV:
19241920 mad = (struct ib_mad *) &(((struct mlx4_mad_rcv_buf *)
19251921 (sqp->ring[wc.wr_id &
1926
- (MLX4_NUM_TUNNEL_BUFS - 1)].addr))->payload);
1922
+ (MLX4_NUM_WIRE_BUFS - 1)].addr))->payload);
19271923 grh = &(((struct mlx4_mad_rcv_buf *)
19281924 (sqp->ring[wc.wr_id &
1929
- (MLX4_NUM_TUNNEL_BUFS - 1)].addr))->grh);
1925
+ (MLX4_NUM_WIRE_BUFS - 1)].addr))->grh);
19301926 mlx4_ib_demux_mad(ctx->ib_dev, ctx->port, &wc, grh, mad);
19311927 if (mlx4_ib_post_pv_qp_buf(ctx, sqp, wc.wr_id &
1932
- (MLX4_NUM_TUNNEL_BUFS - 1)))
1928
+ (MLX4_NUM_WIRE_BUFS - 1)))
19331929 pr_err("Failed reposting SQP "
19341930 "buf:%lld\n", wc.wr_id);
19351931 break;
....@@ -1941,9 +1937,9 @@
19411937 " status = %d, wrid = 0x%llx\n",
19421938 ctx->slave, wc.status, wc.wr_id);
19431939 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
19471943 = NULL;
19481944 spin_lock(&sqp->tx_lock);
19491945 sqp->tx_ix_tail++;
....@@ -1983,6 +1979,7 @@
19831979 {
19841980 int ret, cq_size;
19851981 struct ib_cq_init_attr cq_attr = {};
1982
+ const int nmbr_bufs = create_tun ? MLX4_NUM_TUNNEL_BUFS : MLX4_NUM_WIRE_BUFS;
19861983
19871984 if (ctx->state != DEMUX_PV_STATE_DOWN)
19881985 return -EEXIST;
....@@ -2007,7 +2004,7 @@
20072004 goto err_out_qp0;
20082005 }
20092006
2010
- cq_size = 2 * MLX4_NUM_TUNNEL_BUFS;
2007
+ cq_size = 2 * nmbr_bufs;
20112008 if (ctx->has_smi)
20122009 cq_size *= 2;
20132010