aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSean Hefty <sean.hefty@intel.com>2007-08-01 16:49:53 -0400
committerRoland Dreier <rolandd@cisco.com>2007-10-09 22:59:17 -0400
commitde98b693e9857e183679cd2f49b3c30d2bc57629 (patch)
treebfb31d9109f5057926b8849671e2937df22b37fd /drivers
parent1a1eb6a646f52dc62e3f9ceac4aab9c27e781186 (diff)
IB/cm: Modify interface to send MRAs in response to duplicate messages
The IB CM provides a message received acknowledged (MRA) message that can be sent to indicate that a REQ or REP message has been received, but will require more time to process than the timeout specified by those messages. In many cases, the application may not know how long it will take to respond to a CM message, but the majority of the time, it will usually respond before a retry has been sent. Rather than sending an MRA in response to all messages just to handle the case where a longer timeout is needed, it is more efficient to queue the MRA for sending in case a duplicate message is received. This avoids sending an MRA when it is not needed, but limits the number of times that a REQ or REP will be resent. It also provides for a simpler implementation than generating the MRA based on a timer event. (That is, trying to send the MRA after receiving the first REQ or REP if a response has not been generated, so that it is received at the remote side before a duplicate REQ or REP has been received) Signed-off-by: Sean Hefty <sean.hefty@intel.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/core/cm.c51
1 files changed, 23 insertions, 28 deletions
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 4df269f5d9ac..2e39236d189f 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -2219,6 +2219,9 @@ int ib_send_cm_mra(struct ib_cm_id *cm_id,
2219{ 2219{
2220 struct cm_id_private *cm_id_priv; 2220 struct cm_id_private *cm_id_priv;
2221 struct ib_mad_send_buf *msg; 2221 struct ib_mad_send_buf *msg;
2222 enum ib_cm_state cm_state;
2223 enum ib_cm_lap_state lap_state;
2224 enum cm_msg_response msg_response;
2222 void *data; 2225 void *data;
2223 unsigned long flags; 2226 unsigned long flags;
2224 int ret; 2227 int ret;
@@ -2235,48 +2238,40 @@ int ib_send_cm_mra(struct ib_cm_id *cm_id,
2235 spin_lock_irqsave(&cm_id_priv->lock, flags); 2238 spin_lock_irqsave(&cm_id_priv->lock, flags);
2236 switch(cm_id_priv->id.state) { 2239 switch(cm_id_priv->id.state) {
2237 case IB_CM_REQ_RCVD: 2240 case IB_CM_REQ_RCVD:
2238 ret = cm_alloc_msg(cm_id_priv, &msg); 2241 cm_state = IB_CM_MRA_REQ_SENT;
2239 if (ret) 2242 lap_state = cm_id->lap_state;
2240 goto error1; 2243 msg_response = CM_MSG_RESPONSE_REQ;
2241
2242 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv,
2243 CM_MSG_RESPONSE_REQ, service_timeout,
2244 private_data, private_data_len);
2245 ret = ib_post_send_mad(msg, NULL);
2246 if (ret)
2247 goto error2;
2248 cm_id->state = IB_CM_MRA_REQ_SENT;
2249 break; 2244 break;
2250 case IB_CM_REP_RCVD: 2245 case IB_CM_REP_RCVD:
2251 ret = cm_alloc_msg(cm_id_priv, &msg); 2246 cm_state = IB_CM_MRA_REP_SENT;
2252 if (ret) 2247 lap_state = cm_id->lap_state;
2253 goto error1; 2248 msg_response = CM_MSG_RESPONSE_REP;
2254
2255 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv,
2256 CM_MSG_RESPONSE_REP, service_timeout,
2257 private_data, private_data_len);
2258 ret = ib_post_send_mad(msg, NULL);
2259 if (ret)
2260 goto error2;
2261 cm_id->state = IB_CM_MRA_REP_SENT;
2262 break; 2249 break;
2263 case IB_CM_ESTABLISHED: 2250 case IB_CM_ESTABLISHED:
2251 cm_state = cm_id->state;
2252 lap_state = IB_CM_MRA_LAP_SENT;
2253 msg_response = CM_MSG_RESPONSE_OTHER;
2254 break;
2255 default:
2256 ret = -EINVAL;
2257 goto error1;
2258 }
2259
2260 if (!(service_timeout & IB_CM_MRA_FLAG_DELAY)) {
2264 ret = cm_alloc_msg(cm_id_priv, &msg); 2261 ret = cm_alloc_msg(cm_id_priv, &msg);
2265 if (ret) 2262 if (ret)
2266 goto error1; 2263 goto error1;
2267 2264
2268 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv, 2265 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv,
2269 CM_MSG_RESPONSE_OTHER, service_timeout, 2266 msg_response, service_timeout,
2270 private_data, private_data_len); 2267 private_data, private_data_len);
2271 ret = ib_post_send_mad(msg, NULL); 2268 ret = ib_post_send_mad(msg, NULL);
2272 if (ret) 2269 if (ret)
2273 goto error2; 2270 goto error2;
2274 cm_id->lap_state = IB_CM_MRA_LAP_SENT;
2275 break;
2276 default:
2277 ret = -EINVAL;
2278 goto error1;
2279 } 2271 }
2272
2273 cm_id->state = cm_state;
2274 cm_id->lap_state = lap_state;
2280 cm_id_priv->service_timeout = service_timeout; 2275 cm_id_priv->service_timeout = service_timeout;
2281 cm_set_private_data(cm_id_priv, data, private_data_len); 2276 cm_set_private_data(cm_id_priv, data, private_data_len);
2282 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2277 spin_unlock_irqrestore(&cm_id_priv->lock, flags);