|
38 | 38 | #include "hns_roce_u.h"
|
39 | 39 | #include "hns_roce_u_db.h"
|
40 | 40 | #include "hns_roce_u_hw_v2.h"
|
| 41 | +#include "hns_roce_u_trace.h" |
41 | 42 |
|
42 | 43 | #define HR_IBV_OPC_MAP(ib_key, hr_key) \
|
43 | 44 | [IBV_WR_ ## ib_key] = HNS_ROCE_WQE_OP_ ## hr_key
|
@@ -680,6 +681,80 @@ static int parse_cqe_for_cq(struct hns_roce_context *ctx, struct hns_roce_cq *cq
|
680 | 681 | return 0;
|
681 | 682 | }
|
682 | 683 |
|
| 684 | +#ifdef LTTNG_ENABLED |
| 685 | +static uint8_t read_wc_sl(struct hns_roce_qp *hr_qp, |
| 686 | + struct hns_roce_v2_cqe *cqe, |
| 687 | + struct ibv_wc *wc) |
| 688 | +{ |
| 689 | + return hr_qp->verbs_qp.qp.qp_type == IBV_QPT_UD && |
| 690 | + hr_reg_read(cqe, CQE_S_R) == CQE_FOR_RQ ? |
| 691 | + wc->sl : UINT8_MAX; |
| 692 | +} |
| 693 | + |
| 694 | +static uint32_t read_wc_rqpn(struct hns_roce_qp *hr_qp, |
| 695 | + struct hns_roce_v2_cqe *cqe, |
| 696 | + struct ibv_wc *wc) |
| 697 | +{ |
| 698 | + return hr_qp->verbs_qp.qp.qp_type == IBV_QPT_UD && |
| 699 | + hr_reg_read(cqe, CQE_S_R) == CQE_FOR_RQ ? |
| 700 | + wc->src_qp : UINT32_MAX; |
| 701 | +} |
| 702 | + |
| 703 | +static uint32_t read_wc_byte_len(struct hns_roce_v2_cqe *cqe, |
| 704 | + struct ibv_wc *wc) |
| 705 | +{ |
| 706 | + if (hr_reg_read(cqe, CQE_S_R) == CQE_FOR_RQ) |
| 707 | + return wc->byte_len; |
| 708 | + |
| 709 | + switch (hr_reg_read(cqe, CQE_OPCODE)) { |
| 710 | + case HNS_ROCE_SQ_OP_RDMA_READ: |
| 711 | + case HNS_ROCE_SQ_OP_ATOMIC_COMP_AND_SWAP: |
| 712 | + case HNS_ROCE_SQ_OP_ATOMIC_FETCH_AND_ADD: |
| 713 | + case HNS_ROCE_SQ_OP_ATOMIC_MASK_COMP_AND_SWAP: |
| 714 | + case HNS_ROCE_SQ_OP_ATOMIC_MASK_FETCH_AND_ADD: |
| 715 | + return wc->byte_len; |
| 716 | + default: |
| 717 | + return UINT32_MAX; |
| 718 | + } |
| 719 | +} |
| 720 | + |
| 721 | +static uint8_t trace_wc_read_sl(struct ibv_cq_ex *cq_ex) |
| 722 | +{ |
| 723 | + return cq_ex->read_sl ? cq_ex->read_sl(cq_ex) : UINT8_MAX; |
| 724 | +} |
| 725 | + |
| 726 | +static uint32_t trace_wc_read_qp_num(struct ibv_cq_ex *cq_ex) |
| 727 | +{ |
| 728 | + return cq_ex->read_qp_num ? |
| 729 | + cq_ex->read_qp_num(cq_ex) : UINT32_MAX; |
| 730 | +} |
| 731 | + |
| 732 | +static uint32_t trace_wc_read_src_qp(struct ibv_cq_ex *cq_ex) |
| 733 | +{ |
| 734 | + return cq_ex->read_src_qp ? |
| 735 | + cq_ex->read_src_qp(cq_ex) : UINT32_MAX; |
| 736 | +} |
| 737 | + |
| 738 | +static uint32_t trace_wc_read_byte_len(struct ibv_cq_ex *cq_ex) |
| 739 | +{ |
| 740 | + return cq_ex->read_byte_len ? |
| 741 | + cq_ex->read_byte_len(cq_ex) : UINT32_MAX; |
| 742 | +} |
| 743 | + |
| 744 | +static uint32_t get_send_wr_rqpn(struct ibv_send_wr *wr, |
| 745 | + uint8_t qp_type) |
| 746 | +{ |
| 747 | + return qp_type == IBV_QPT_UD ? wr->wr.ud.remote_qpn : UINT32_MAX; |
| 748 | +} |
| 749 | + |
| 750 | +static uint8_t get_send_wr_tclass(struct ibv_send_wr *wr, |
| 751 | + uint8_t qp_type) |
| 752 | +{ |
| 753 | + return qp_type == IBV_QPT_UD ? |
| 754 | + to_hr_ah(wr->wr.ud.ah)->av.tclass : UINT8_MAX; |
| 755 | +} |
| 756 | +#endif |
| 757 | + |
683 | 758 | static int hns_roce_poll_one(struct hns_roce_context *ctx,
|
684 | 759 | struct hns_roce_qp **cur_qp, struct hns_roce_cq *cq,
|
685 | 760 | struct ibv_wc *wc)
|
@@ -716,8 +791,27 @@ static int hns_roce_poll_one(struct hns_roce_context *ctx,
|
716 | 791 | wc->status = wc_status;
|
717 | 792 | wc->vendor_err = hr_reg_read(cqe, CQE_SUB_STATUS);
|
718 | 793 | wc->qp_num = qpn;
|
| 794 | + |
| 795 | + rdma_tracepoint(rdma_core_hns, poll_cq, |
| 796 | + cq->verbs_cq.cq.context->device->name, |
| 797 | + wc->wr_id, wc_status, wc->opcode, |
| 798 | + wc->wc_flags, wc->vendor_err, |
| 799 | + read_wc_sl(*cur_qp, cqe, wc), |
| 800 | + wc->qp_num, read_wc_rqpn(*cur_qp, cqe, wc), |
| 801 | + read_wc_byte_len(cqe, wc)); |
719 | 802 | } else {
|
720 | 803 | cq->verbs_cq.cq_ex.status = wc_status;
|
| 804 | + |
| 805 | + rdma_tracepoint(rdma_core_hns, poll_cq, |
| 806 | + cq->verbs_cq.cq.context->device->name, |
| 807 | + cq->verbs_cq.cq_ex.wr_id, wc_status, |
| 808 | + ibv_wc_read_opcode(&cq->verbs_cq.cq_ex), |
| 809 | + ibv_wc_read_wc_flags(&cq->verbs_cq.cq_ex), |
| 810 | + ibv_wc_read_vendor_err(&cq->verbs_cq.cq_ex), |
| 811 | + trace_wc_read_sl(&cq->verbs_cq.cq_ex), |
| 812 | + trace_wc_read_qp_num(&cq->verbs_cq.cq_ex), |
| 813 | + trace_wc_read_src_qp(&cq->verbs_cq.cq_ex), |
| 814 | + trace_wc_read_byte_len(&cq->verbs_cq.cq_ex)); |
721 | 815 | }
|
722 | 816 |
|
723 | 817 | if (status == HNS_ROCE_V2_CQE_SUCCESS ||
|
@@ -1328,6 +1422,14 @@ int hns_roce_u_v2_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
|
1328 | 1422 | *bad_wr = wr;
|
1329 | 1423 | goto out;
|
1330 | 1424 | }
|
| 1425 | + |
| 1426 | + rdma_tracepoint(rdma_core_hns, post_send, |
| 1427 | + ibvqp->context->device->name, wr->wr_id, |
| 1428 | + sge_info.valid_num, ibvqp->qp_num, |
| 1429 | + get_send_wr_rqpn(wr, ibvqp->qp_type), |
| 1430 | + wr->send_flags, sge_info.total_len, |
| 1431 | + wr->opcode, qp->sl, |
| 1432 | + get_send_wr_tclass(wr, ibvqp->qp_type)); |
1331 | 1433 | }
|
1332 | 1434 |
|
1333 | 1435 | out:
|
@@ -1457,6 +1559,10 @@ static int hns_roce_u_v2_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr,
|
1457 | 1559 | wqe_idx = (qp->rq.head + nreq) & (qp->rq.wqe_cnt - 1);
|
1458 | 1560 | fill_rq_wqe(qp, wr, wqe_idx, max_sge);
|
1459 | 1561 | qp->rq.wrid[wqe_idx] = wr->wr_id;
|
| 1562 | + |
| 1563 | + rdma_tracepoint(rdma_core_hns, post_recv, |
| 1564 | + ibvqp->context->device->name, wr->wr_id, |
| 1565 | + wr->num_sge, ibvqp->qp_num, 0); |
1460 | 1566 | }
|
1461 | 1567 |
|
1462 | 1568 | out:
|
@@ -1794,6 +1900,10 @@ static int hns_roce_u_v2_post_srq_recv(struct ibv_srq *ib_srq,
|
1794 | 1900 | fill_wqe_idx(srq, wqe_idx);
|
1795 | 1901 |
|
1796 | 1902 | srq->wrid[wqe_idx] = wr->wr_id;
|
| 1903 | + |
| 1904 | + rdma_tracepoint(rdma_core_hns, post_recv, |
| 1905 | + ib_srq->context->device->name, wr->wr_id, |
| 1906 | + wr->num_sge, srq->srqn, 1); |
1797 | 1907 | }
|
1798 | 1908 |
|
1799 | 1909 | if (nreq) {
|
@@ -2062,6 +2172,12 @@ static void wr_set_sge_rc(struct ibv_qp_ex *ibv_qp, uint32_t lkey,
|
2062 | 2172 | wqe->msg_len = htole32(length);
|
2063 | 2173 | hr_reg_write(wqe, RCWQE_LEN0, length);
|
2064 | 2174 | hr_reg_write(wqe, RCWQE_SGE_NUM, !!length);
|
| 2175 | + |
| 2176 | + rdma_tracepoint(rdma_core_hns, post_send, |
| 2177 | + ibv_qp->qp_base.context->device->name, ibv_qp->wr_id, |
| 2178 | + !!length, ibv_qp->qp_base.qp_num, UINT32_MAX, |
| 2179 | + ibv_qp->wr_flags, length, |
| 2180 | + hr_reg_read(wqe, RCWQE_OPCODE), qp->sl, UINT8_MAX); |
2065 | 2181 | }
|
2066 | 2182 |
|
2067 | 2183 | static void set_sgl_rc(struct hns_roce_v2_wqe_data_seg *dseg,
|
@@ -2126,6 +2242,12 @@ static void wr_set_sge_list_rc(struct ibv_qp_ex *ibv_qp, size_t num_sge,
|
2126 | 2242 |
|
2127 | 2243 | wqe->msg_len = htole32(qp->sge_info.total_len);
|
2128 | 2244 | hr_reg_write(wqe, RCWQE_SGE_NUM, qp->sge_info.valid_num);
|
| 2245 | + |
| 2246 | + rdma_tracepoint(rdma_core_hns, post_send, |
| 2247 | + ibv_qp->qp_base.context->device->name, ibv_qp->wr_id, |
| 2248 | + qp->sge_info.valid_num, ibv_qp->qp_base.qp_num, |
| 2249 | + UINT32_MAX, ibv_qp->wr_flags, qp->sge_info.total_len, |
| 2250 | + opcode, qp->sl, UINT8_MAX); |
2129 | 2251 | }
|
2130 | 2252 |
|
2131 | 2253 | static void wr_send_rc(struct ibv_qp_ex *ibv_qp)
|
@@ -2300,6 +2422,14 @@ static void set_inline_data_list_rc(struct hns_roce_qp *qp,
|
2300 | 2422 |
|
2301 | 2423 | hr_reg_write(wqe, RCWQE_SGE_NUM, qp->sge_info.valid_num);
|
2302 | 2424 | }
|
| 2425 | + |
| 2426 | + rdma_tracepoint(rdma_core_hns, post_send, |
| 2427 | + qp->verbs_qp.qp.context->device->name, |
| 2428 | + qp->verbs_qp.qp_ex.wr_id, |
| 2429 | + hr_reg_read(wqe, RCWQE_SGE_NUM), |
| 2430 | + qp->verbs_qp.qp.qp_num, UINT32_MAX, |
| 2431 | + qp->verbs_qp.qp_ex.wr_flags, msg_len, |
| 2432 | + hr_reg_read(wqe, RCWQE_OPCODE), qp->sl, UINT8_MAX); |
2303 | 2433 | }
|
2304 | 2434 |
|
2305 | 2435 | static void wr_set_inline_data_rc(struct ibv_qp_ex *ibv_qp, void *addr,
|
@@ -2432,6 +2562,13 @@ static void wr_set_sge_ud(struct ibv_qp_ex *ibv_qp, uint32_t lkey,
|
2432 | 2562 | dseg->len = htole32(length);
|
2433 | 2563 |
|
2434 | 2564 | qp->sge_info.start_idx++;
|
| 2565 | + |
| 2566 | + rdma_tracepoint(rdma_core_hns, post_send, |
| 2567 | + ibv_qp->qp_base.context->device->name, ibv_qp->wr_id, |
| 2568 | + 1, ibv_qp->qp_base.qp_num, |
| 2569 | + hr_reg_read(wqe, UDWQE_DQPN), ibv_qp->wr_flags, |
| 2570 | + length, hr_reg_read(wqe, UDWQE_OPCODE), |
| 2571 | + qp->sl, hr_reg_read(wqe, UDWQE_TCLASS)); |
2435 | 2572 | }
|
2436 | 2573 |
|
2437 | 2574 | static void wr_set_sge_list_ud(struct ibv_qp_ex *ibv_qp, size_t num_sge,
|
@@ -2470,6 +2607,13 @@ static void wr_set_sge_list_ud(struct ibv_qp_ex *ibv_qp, size_t num_sge,
|
2470 | 2607 | hr_reg_write(wqe, UDWQE_SGE_NUM, cnt);
|
2471 | 2608 |
|
2472 | 2609 | qp->sge_info.start_idx += cnt;
|
| 2610 | + |
| 2611 | + rdma_tracepoint(rdma_core_hns, post_send, |
| 2612 | + ibv_qp->qp_base.context->device->name, ibv_qp->wr_id, |
| 2613 | + cnt, ibv_qp->qp_base.qp_num, |
| 2614 | + hr_reg_read(wqe, UDWQE_DQPN), ibv_qp->wr_flags, |
| 2615 | + msg_len, hr_reg_read(wqe, UDWQE_OPCODE), |
| 2616 | + qp->sl, hr_reg_read(wqe, UDWQE_TCLASS)); |
2473 | 2617 | }
|
2474 | 2618 |
|
2475 | 2619 | static void set_inline_data_list_ud(struct hns_roce_qp *qp,
|
@@ -2518,6 +2662,15 @@ static void set_inline_data_list_ud(struct hns_roce_qp *qp,
|
2518 | 2662 |
|
2519 | 2663 | hr_reg_write(wqe, UDWQE_SGE_NUM, qp->sge_info.valid_num);
|
2520 | 2664 | }
|
| 2665 | + |
| 2666 | + rdma_tracepoint(rdma_core_hns, post_send, |
| 2667 | + qp->verbs_qp.qp.context->device->name, |
| 2668 | + qp->verbs_qp.qp_ex.wr_id, |
| 2669 | + hr_reg_read(wqe, UDWQE_SGE_NUM), |
| 2670 | + qp->verbs_qp.qp.qp_num, hr_reg_read(wqe, UDWQE_DQPN), |
| 2671 | + qp->verbs_qp.qp_ex.wr_flags, msg_len, |
| 2672 | + hr_reg_read(wqe, UDWQE_OPCODE), qp->sl, |
| 2673 | + hr_reg_read(wqe, UDWQE_TCLASS)); |
2521 | 2674 | }
|
2522 | 2675 |
|
2523 | 2676 | static void wr_set_inline_data_ud(struct ibv_qp_ex *ibv_qp, void *addr,
|
|
0 commit comments