Skip to content

Commit f75b7a5

Browse files
Hal RosenstockLinus Torvalds
authored andcommitted
[PATCH] IB: Add automatic retries to MAD layer
Add automatic retries to MAD layer. Signed-off-by: Sean Hefty <[email protected]> Signed-off-by: Hal Rosenstock <[email protected]> Cc: Roland Dreier <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent df9f9ea commit f75b7a5

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

drivers/infiniband/core/mad.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ int ib_post_send_mad(struct ib_mad_agent *mad_agent,
954954
/* Timeout will be updated after send completes */
955955
mad_send_wr->timeout = msecs_to_jiffies(send_wr->wr.
956956
ud.timeout_ms);
957-
mad_send_wr->retry = 0;
957+
mad_send_wr->retries = mad_send_wr->send_wr.wr.ud.retries;
958958
/* One reference for each work request to QP + response */
959959
mad_send_wr->refcount = 1 + (mad_send_wr->timeout > 0);
960960
mad_send_wr->status = IB_WC_SUCCESS;
@@ -2174,6 +2174,27 @@ static void local_completions(void *data)
21742174
spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
21752175
}
21762176

2177+
static int retry_send(struct ib_mad_send_wr_private *mad_send_wr)
2178+
{
2179+
int ret;
2180+
2181+
if (!mad_send_wr->retries--)
2182+
return -ETIMEDOUT;
2183+
2184+
mad_send_wr->timeout = msecs_to_jiffies(mad_send_wr->send_wr.
2185+
wr.ud.timeout_ms);
2186+
2187+
ret = ib_send_mad(mad_send_wr);
2188+
2189+
if (!ret) {
2190+
mad_send_wr->refcount++;
2191+
list_del(&mad_send_wr->agent_list);
2192+
list_add_tail(&mad_send_wr->agent_list,
2193+
&mad_send_wr->mad_agent_priv->send_list);
2194+
}
2195+
return ret;
2196+
}
2197+
21772198
static void timeout_sends(void *data)
21782199
{
21792200
struct ib_mad_agent_private *mad_agent_priv;
@@ -2202,6 +2223,9 @@ static void timeout_sends(void *data)
22022223
break;
22032224
}
22042225

2226+
if (!retry_send(mad_send_wr))
2227+
continue;
2228+
22052229
list_del(&mad_send_wr->agent_list);
22062230
spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
22072231

drivers/infiniband/core/mad_priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ struct ib_mad_send_wr_private {
123123
u64 wr_id; /* client WR ID */
124124
u64 tid;
125125
unsigned long timeout;
126+
int retries;
126127
int retry;
127128
int refcount;
128129
enum ib_wc_status status;
@@ -136,6 +137,7 @@ struct ib_mad_local_private {
136137
struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
137138
u64 wr_id; /* client WR ID */
138139
u64 tid;
140+
int retries;
139141
};
140142

141143
struct ib_mad_mgmt_method_table {

drivers/infiniband/core/sa_query.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ static int send_mad(struct ib_sa_query *query, int timeout_ms)
462462
.mad_hdr = &query->mad->mad_hdr,
463463
.remote_qpn = 1,
464464
.remote_qkey = IB_QP1_QKEY,
465-
.timeout_ms = timeout_ms
465+
.timeout_ms = timeout_ms,
466+
.retries = 0
466467
}
467468
}
468469
};

drivers/infiniband/core/user_mad.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
322322
wr.wr.ud.remote_qpn = be32_to_cpu(packet->mad.qpn);
323323
wr.wr.ud.remote_qkey = be32_to_cpu(packet->mad.qkey);
324324
wr.wr.ud.timeout_ms = packet->mad.timeout_ms;
325+
wr.wr.ud.retries = 0;
325326

326327
wr.wr_id = (unsigned long) packet;
327328

drivers/infiniband/include/ib_verbs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ struct ib_send_wr {
566566
u32 remote_qpn;
567567
u32 remote_qkey;
568568
int timeout_ms; /* valid for MADs only */
569+
int retries; /* valid for MADs only */
569570
u16 pkey_index; /* valid for GSI only */
570571
u8 port_num; /* valid for DR SMPs on switch only */
571572
} ud;

0 commit comments

Comments
 (0)