Skip to content

Commit 9171bfd

Browse files
mmarcinidledford
authored andcommitted
staging/rdma/hfi1: centralize timer routines into rc
Centralize disparate timer maintenance. This allow for central control and changes to the RC timer handling including future optimizations. Reviewed-by: Jubin John <[email protected]> Signed-off-by: Mike Marciniszyn <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent cd93a9e commit 9171bfd

File tree

1 file changed

+107
-0
lines changed
  • drivers/staging/rdma/hfi1

1 file changed

+107
-0
lines changed

drivers/staging/rdma/hfi1/rc.c

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,113 @@
6262

6363
static void rc_timeout(unsigned long arg);
6464

65+
/**
66+
* hfi1_add_retry_timer - add/start a retry timer
67+
* @qp - the QP
68+
*
69+
* add a retry timer on the QP
70+
*/
71+
static inline void hfi1_add_retry_timer(struct rvt_qp *qp)
72+
{
73+
qp->s_flags |= RVT_S_TIMER;
74+
qp->s_timer.function = rc_timeout;
75+
/* 4.096 usec. * (1 << qp->timeout) */
76+
qp->s_timer.expires = jiffies + qp->timeout_jiffies;
77+
add_timer(&qp->s_timer);
78+
}
79+
80+
/**
81+
* hfi1_add_rnr_timer - add/start an rnr timer
82+
* @qp - the QP
83+
* @to - timeout in usecs
84+
*
85+
* add an rnr timer on the QP
86+
*/
87+
static inline void hfi1_add_rnr_timer(struct rvt_qp *qp, u32 to)
88+
{
89+
qp->s_flags |= RVT_S_WAIT_RNR;
90+
qp->s_timer.function = hfi1_rc_rnr_retry;
91+
qp->s_timer.expires = jiffies + usecs_to_jiffies(to);
92+
add_timer(&qp->s_timer);
93+
}
94+
95+
/**
96+
* hfi1_mod_retry_timer - mod a retry timer
97+
* @qp - the QP
98+
*
99+
* Modify a potentially already running retry
100+
* timer
101+
*/
102+
static inline void hfi1_mod_retry_timer(struct rvt_qp *qp)
103+
{
104+
qp->s_flags |= RVT_S_TIMER;
105+
qp->s_timer.function = rc_timeout;
106+
/* 4.096 usec. * (1 << qp->timeout) */
107+
mod_timer(&qp->s_timer, jiffies + qp->timeout_jiffies);
108+
}
109+
110+
/**
111+
* hfi1_stop_retry_timer - stop a retry timer
112+
* @qp - the QP
113+
*
114+
* stop a retry timer and return if the timer
115+
* had been pending.
116+
*/
117+
static inline int hfi1_stop_retry_timer(struct rvt_qp *qp)
118+
{
119+
int rval = 0;
120+
121+
/* Remove QP from retry */
122+
if (qp->s_flags & RVT_S_TIMER) {
123+
qp->s_flags &= ~RVT_S_TIMER;
124+
rval = del_timer(&qp->s_timer);
125+
}
126+
return rval;
127+
}
128+
129+
/**
130+
* hfi1_stop_rc_timers - stop all timers
131+
* @qp - the QP
132+
*
133+
* stop any pending timers
134+
*/
135+
static inline void hfi1_stop_rc_timers(struct rvt_qp *qp)
136+
{
137+
/* Remove QP from all timers */
138+
if (qp->s_flags & (RVT_S_TIMER | RVT_S_WAIT_RNR)) {
139+
qp->s_flags &= ~(RVT_S_TIMER | RVT_S_WAIT_RNR);
140+
del_timer(&qp->s_timer);
141+
}
142+
}
143+
144+
/**
145+
* hfi1_stop_rnr_timer - stop an rnr timer
146+
* @qp - the QP
147+
*
148+
* stop an rnr timer and return if the timer
149+
* had been pending.
150+
*/
151+
static inline int hfi1_stop_rnr_timer(struct rvt_qp *qp)
152+
{
153+
int rval = 0;
154+
155+
/* Remove QP from rnr timer */
156+
if (qp->s_flags & RVT_S_WAIT_RNR) {
157+
qp->s_flags &= ~RVT_S_WAIT_RNR;
158+
rval = del_timer(&qp->s_timer);
159+
}
160+
return rval;
161+
}
162+
163+
/**
164+
* hfi1_del_timers_sync - wait for any timeout routines to exit
165+
* @qp - the QP
166+
*/
167+
static inline void hfi1_del_timers_sync(struct rvt_qp *qp)
168+
{
169+
del_timer_sync(&qp->s_timer);
170+
}
171+
65172
static u32 restart_sge(struct rvt_sge_state *ss, struct rvt_swqe *wqe,
66173
u32 psn, u32 pmtu)
67174
{

0 commit comments

Comments
 (0)