Skip to content

Commit 6a40693

Browse files
kwan-intcjgunthorpe
authored andcommitted
IB/hfi1: Add a function to read next expected psn from hardware flow
This patch adds a function to read next expected KDETH PSN from hardware flow to simplify the code. 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 f6f3f53 commit 6a40693

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

drivers/infiniband/hw/hfi1/tid_rdma.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ static int make_tid_rdma_ack(struct rvt_qp *qp,
128128
struct ib_other_headers *ohdr,
129129
struct hfi1_pkt_state *ps);
130130
static void hfi1_do_tid_send(struct rvt_qp *qp);
131+
static u32 read_r_next_psn(struct hfi1_devdata *dd, u8 ctxt, u8 fidx);
131132

132133
static u64 tid_rdma_opfn_encode(struct tid_rdma_params *p)
133134
{
@@ -2807,18 +2808,10 @@ static bool handle_read_kdeth_eflags(struct hfi1_ctxtdata *rcd,
28072808
}
28082809
priv->flow_state.r_next_psn++;
28092810
} else {
2810-
u64 reg;
28112811
u32 last_psn;
28122812

2813-
/*
2814-
* The only sane way to get the amount of
2815-
* progress is to read the HW flow state.
2816-
*/
2817-
reg = read_uctxt_csr(dd, rcd->ctxt,
2818-
RCV_TID_FLOW_TABLE +
2819-
(8 * flow->idx));
2820-
last_psn = mask_psn(reg);
2821-
2813+
last_psn = read_r_next_psn(dd, rcd->ctxt,
2814+
flow->idx);
28222815
priv->flow_state.r_next_psn = last_psn;
28232816
priv->flow_state.flags |= TID_FLOW_SW_PSN;
28242817
/*
@@ -2968,17 +2961,10 @@ bool hfi1_handle_kdeth_eflags(struct hfi1_ctxtdata *rcd,
29682961
switch (rte) {
29692962
case RHF_RTE_EXPECTED_FLOW_SEQ_ERR:
29702963
if (!(qpriv->s_flags & HFI1_R_TID_SW_PSN)) {
2971-
u64 reg;
2972-
29732964
qpriv->s_flags |= HFI1_R_TID_SW_PSN;
2974-
/*
2975-
* The only sane way to get the amount of
2976-
* progress is to read the HW flow state.
2977-
*/
2978-
reg = read_uctxt_csr(dd, rcd->ctxt,
2979-
RCV_TID_FLOW_TABLE +
2980-
(8 * flow->idx));
2981-
flow->flow_state.r_next_psn = mask_psn(reg);
2965+
flow->flow_state.r_next_psn =
2966+
read_r_next_psn(dd, rcd->ctxt,
2967+
flow->idx);
29822968
qpriv->r_next_psn_kdeth =
29832969
flow->flow_state.r_next_psn;
29842970
goto nak_psn;
@@ -5456,3 +5442,15 @@ bool hfi1_tid_rdma_ack_interlock(struct rvt_qp *qp, struct rvt_ack_entry *e)
54565442
}
54575443
return false;
54585444
}
5445+
5446+
static u32 read_r_next_psn(struct hfi1_devdata *dd, u8 ctxt, u8 fidx)
5447+
{
5448+
u64 reg;
5449+
5450+
/*
5451+
* The only sane way to get the amount of
5452+
* progress is to read the HW flow state.
5453+
*/
5454+
reg = read_uctxt_csr(dd, ctxt, RCV_TID_FLOW_TABLE + (8 * fidx));
5455+
return mask_psn(reg);
5456+
}

0 commit comments

Comments
 (0)