Skip to content

Commit b885d5b

Browse files
kwan-intcjgunthorpe
authored andcommitted
IB/hfi1: Unify the software PSN check for TID RDMA READ/WRITE
For expected packet receiving, the hfi1 hardware checks the KDETH PSN automatically. However, when sequence error occurs, the hfi1 driver can check the sequence instead until the hardware flow generation is reloaded. TID RDMA READ and WRITE protocols implement similar software checking mechanisms, but with different flags and different local variables to store next expected PSN. Unify the handling by using only one set of flag and local variable for both TID RDMA READ and WRITE protocols. Reviewed-by: Mike Marciniszyn <[email protected]> Reviewed-by: Dennis Dalessandro <[email protected]> Reviewed-by: Michael J. Ruhl <[email protected]> Signed-off-by: Kaike Wan <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 6a40693 commit b885d5b

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

drivers/infiniband/hw/hfi1/tid_rdma.c

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ static u32 mask_generation(u32 a)
6767
#define TID_RDMA_DESTQP_FLOW_SHIFT 11
6868
#define TID_RDMA_DESTQP_FLOW_MASK 0x1f
6969

70-
#define TID_FLOW_SW_PSN BIT(0)
71-
7270
#define TID_OPFN_QP_CTXT_MASK 0xff
7371
#define TID_OPFN_QP_CTXT_SHIFT 56
7472
#define TID_OPFN_QP_KDETH_MASK 0xff
@@ -777,7 +775,6 @@ int hfi1_kern_setup_hw_flow(struct hfi1_ctxtdata *rcd, struct rvt_qp *qp)
777775
rcd->flows[fs->index].generation = fs->generation;
778776
fs->generation = kern_setup_hw_flow(rcd, fs->index);
779777
fs->psn = 0;
780-
fs->flags = 0;
781778
dequeue_tid_waiter(rcd, &rcd->flow_queue, qp);
782779
/* get head before dropping lock */
783780
fqp = first_qp(rcd, &rcd->flow_queue);
@@ -1808,6 +1805,7 @@ u32 hfi1_build_tid_rdma_read_req(struct rvt_qp *qp, struct rvt_swqe *wqe,
18081805
goto done;
18091806

18101807
hfi1_kern_clear_hw_flow(req->rcd, qp);
1808+
qpriv->s_flags &= ~HFI1_R_TID_SW_PSN;
18111809
req->state = TID_REQUEST_ACTIVE;
18121810
}
18131811

@@ -2476,8 +2474,13 @@ void hfi1_rc_rcv_tid_rdma_read_resp(struct hfi1_packet *packet)
24762474

24772475
flow = &req->flows[req->clear_tail];
24782476
/* When header suppression is disabled */
2479-
if (cmp_psn(ipsn, flow->flow_state.ib_lpsn))
2477+
if (cmp_psn(ipsn, flow->flow_state.ib_lpsn)) {
2478+
if (cmp_psn(kpsn, flow->flow_state.r_next_psn))
2479+
goto ack_done;
2480+
flow->flow_state.r_next_psn = mask_psn(kpsn + 1);
24802481
goto ack_done;
2482+
}
2483+
flow->flow_state.r_next_psn = mask_psn(kpsn + 1);
24812484
req->ack_pending--;
24822485
priv->pending_tid_r_segs--;
24832486
qp->s_num_rd_atomic--;
@@ -2519,6 +2522,7 @@ void hfi1_rc_rcv_tid_rdma_read_resp(struct hfi1_packet *packet)
25192522
req->comp_seg == req->cur_seg) ||
25202523
priv->tid_r_comp == priv->tid_r_reqs) {
25212524
hfi1_kern_clear_hw_flow(priv->rcd, qp);
2525+
priv->s_flags &= ~HFI1_R_TID_SW_PSN;
25222526
if (req->state == TID_REQUEST_SYNC)
25232527
req->state = TID_REQUEST_ACTIVE;
25242528
}
@@ -2768,9 +2772,9 @@ static bool handle_read_kdeth_eflags(struct hfi1_ctxtdata *rcd,
27682772
rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
27692773
return ret;
27702774
}
2771-
if (priv->flow_state.flags & TID_FLOW_SW_PSN) {
2775+
if (priv->s_flags & HFI1_R_TID_SW_PSN) {
27722776
diff = cmp_psn(psn,
2773-
priv->flow_state.r_next_psn);
2777+
flow->flow_state.r_next_psn);
27742778
if (diff > 0) {
27752779
if (!(qp->r_flags & RVT_R_RDMAR_SEQ))
27762780
restart_tid_rdma_read_req(rcd,
@@ -2806,14 +2810,15 @@ static bool handle_read_kdeth_eflags(struct hfi1_ctxtdata *rcd,
28062810
qp->r_flags &=
28072811
~RVT_R_RDMAR_SEQ;
28082812
}
2809-
priv->flow_state.r_next_psn++;
2813+
flow->flow_state.r_next_psn =
2814+
mask_psn(psn + 1);
28102815
} else {
28112816
u32 last_psn;
28122817

28132818
last_psn = read_r_next_psn(dd, rcd->ctxt,
28142819
flow->idx);
2815-
priv->flow_state.r_next_psn = last_psn;
2816-
priv->flow_state.flags |= TID_FLOW_SW_PSN;
2820+
flow->flow_state.r_next_psn = last_psn;
2821+
priv->s_flags |= HFI1_R_TID_SW_PSN;
28172822
/*
28182823
* If no request has been restarted yet,
28192824
* restart the current one.
@@ -2878,6 +2883,7 @@ bool hfi1_handle_kdeth_eflags(struct hfi1_ctxtdata *rcd,
28782883
struct rvt_ack_entry *e;
28792884
struct tid_rdma_request *req;
28802885
struct tid_rdma_flow *flow;
2886+
int diff = 0;
28812887

28822888
trace_hfi1_msg_handle_kdeth_eflags(NULL, "Kdeth error: rhf ",
28832889
packet->rhf);
@@ -2977,10 +2983,12 @@ bool hfi1_handle_kdeth_eflags(struct hfi1_ctxtdata *rcd,
29772983
* mismatch could be due to packets that were
29782984
* already in flight.
29792985
*/
2980-
if (psn != flow->flow_state.r_next_psn) {
2981-
psn = flow->flow_state.r_next_psn;
2986+
diff = cmp_psn(psn,
2987+
flow->flow_state.r_next_psn);
2988+
if (diff > 0)
29822989
goto nak_psn;
2983-
}
2990+
else if (diff < 0)
2991+
break;
29842992

29852993
qpriv->s_nak_state = 0;
29862994
/*
@@ -2991,8 +2999,10 @@ bool hfi1_handle_kdeth_eflags(struct hfi1_ctxtdata *rcd,
29912999
if (psn == full_flow_psn(flow,
29923000
flow->flow_state.lpsn))
29933001
ret = false;
3002+
flow->flow_state.r_next_psn =
3003+
mask_psn(psn + 1);
29943004
qpriv->r_next_psn_kdeth =
2995-
++flow->flow_state.r_next_psn;
3005+
flow->flow_state.r_next_psn;
29963006
}
29973007
break;
29983008

@@ -3497,8 +3507,10 @@ static void hfi1_tid_write_alloc_resources(struct rvt_qp *qp, bool intr_ctx)
34973507
if (qpriv->r_tid_alloc == qpriv->r_tid_head) {
34983508
/* If all data has been received, clear the flow */
34993509
if (qpriv->flow_state.index < RXE_NUM_TID_FLOWS &&
3500-
!qpriv->alloc_w_segs)
3510+
!qpriv->alloc_w_segs) {
35013511
hfi1_kern_clear_hw_flow(rcd, qp);
3512+
qpriv->s_flags &= ~HFI1_R_TID_SW_PSN;
3513+
}
35023514
break;
35033515
}
35043516

@@ -3524,8 +3536,7 @@ static void hfi1_tid_write_alloc_resources(struct rvt_qp *qp, bool intr_ctx)
35243536
if (qpriv->sync_pt && !qpriv->alloc_w_segs) {
35253537
hfi1_kern_clear_hw_flow(rcd, qp);
35263538
qpriv->sync_pt = false;
3527-
if (qpriv->s_flags & HFI1_R_TID_SW_PSN)
3528-
qpriv->s_flags &= ~HFI1_R_TID_SW_PSN;
3539+
qpriv->s_flags &= ~HFI1_R_TID_SW_PSN;
35293540
}
35303541

35313542
/* Allocate flow if we don't have one */
@@ -4299,7 +4310,7 @@ void hfi1_rc_rcv_tid_rdma_write_data(struct hfi1_packet *packet)
42994310
if (cmp_psn(psn, full_flow_psn(flow, flow->flow_state.lpsn))) {
43004311
if (cmp_psn(psn, flow->flow_state.r_next_psn))
43014312
goto send_nak;
4302-
flow->flow_state.r_next_psn++;
4313+
flow->flow_state.r_next_psn = mask_psn(psn + 1);
43034314
goto exit;
43044315
}
43054316
flow->flow_state.r_next_psn = mask_psn(psn + 1);

drivers/infiniband/hw/hfi1/tid_rdma.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ struct tid_rdma_qp_params {
7676
struct tid_flow_state {
7777
u32 generation;
7878
u32 psn;
79-
u32 r_next_psn; /* next PSN to be received (in TID space) */
8079
u8 index;
8180
u8 last_index;
82-
u8 flags;
8381
};
8482

8583
enum tid_rdma_req_state {

drivers/infiniband/hw/hfi1/trace_tid.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ u16 hfi1_trace_get_tid_idx(u32 ent);
5353
"tid_r_comp %u pending_tid_r_segs %u " \
5454
"s_flags 0x%x ps_flags 0x%x iow_flags 0x%lx " \
5555
"s_state 0x%x hw_flow_index %u generation 0x%x " \
56-
"fpsn 0x%x flow_flags 0x%x"
56+
"fpsn 0x%x"
5757

5858
#define TID_REQ_PRN "[%s] qpn 0x%x newreq %u opcode 0x%x psn 0x%x lpsn 0x%x " \
5959
"cur_seg %u comp_seg %u ack_seg %u alloc_seg %u " \
@@ -71,7 +71,7 @@ u16 hfi1_trace_get_tid_idx(u32 ent);
7171
"pending_tid_w_segs %u sync_pt %s " \
7272
"ps_nak_psn 0x%x ps_nak_state 0x%x " \
7373
"prnr_nak_state 0x%x hw_flow_index %u generation "\
74-
"0x%x fpsn 0x%x flow_flags 0x%x resync %s" \
74+
"0x%x fpsn 0x%x resync %s" \
7575
"r_next_psn_kdeth 0x%x"
7676

7777
#define TID_WRITE_SENDER_PRN "[%s] qpn 0x%x newreq %u s_tid_cur %u " \
@@ -973,7 +973,6 @@ DECLARE_EVENT_CLASS(/* tid_read_sender */
973973
__field(u32, hw_flow_index)
974974
__field(u32, generation)
975975
__field(u32, fpsn)
976-
__field(u32, flow_flags)
977976
),
978977
TP_fast_assign(/* assign */
979978
struct hfi1_qp_priv *priv = qp->priv;
@@ -991,7 +990,6 @@ DECLARE_EVENT_CLASS(/* tid_read_sender */
991990
__entry->hw_flow_index = priv->flow_state.index;
992991
__entry->generation = priv->flow_state.generation;
993992
__entry->fpsn = priv->flow_state.psn;
994-
__entry->flow_flags = priv->flow_state.flags;
995993
),
996994
TP_printk(/* print */
997995
TID_READ_SENDER_PRN,
@@ -1007,8 +1005,7 @@ DECLARE_EVENT_CLASS(/* tid_read_sender */
10071005
__entry->s_state,
10081006
__entry->hw_flow_index,
10091007
__entry->generation,
1010-
__entry->fpsn,
1011-
__entry->flow_flags
1008+
__entry->fpsn
10121009
)
10131010
);
10141011

@@ -1338,7 +1335,6 @@ DECLARE_EVENT_CLASS(/* tid_write_sp */
13381335
__field(u32, hw_flow_index)
13391336
__field(u32, generation)
13401337
__field(u32, fpsn)
1341-
__field(u32, flow_flags)
13421338
__field(bool, resync)
13431339
__field(u32, r_next_psn_kdeth)
13441340
),
@@ -1360,7 +1356,6 @@ DECLARE_EVENT_CLASS(/* tid_write_sp */
13601356
__entry->hw_flow_index = priv->flow_state.index;
13611357
__entry->generation = priv->flow_state.generation;
13621358
__entry->fpsn = priv->flow_state.psn;
1363-
__entry->flow_flags = priv->flow_state.flags;
13641359
__entry->resync = priv->resync;
13651360
__entry->r_next_psn_kdeth = priv->r_next_psn_kdeth;
13661361
),
@@ -1381,7 +1376,6 @@ DECLARE_EVENT_CLASS(/* tid_write_sp */
13811376
__entry->hw_flow_index,
13821377
__entry->generation,
13831378
__entry->fpsn,
1384-
__entry->flow_flags,
13851379
__entry->resync ? "yes" : "no",
13861380
__entry->r_next_psn_kdeth
13871381
)

0 commit comments

Comments
 (0)