]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sdp: fix keepalive functionality
authorshamir rabinovitch <shamir.rabinovitch@oracle.com>
Mon, 12 May 2014 15:34:02 +0000 (08:34 -0700)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Tue, 6 Oct 2015 12:45:41 +0000 (05:45 -0700)
sdp keepalive functionality differ a bit from tcp socket functionality.
in sdp only accepted or connected socket can trigger this functionality
as the keepalive is implemented as rdma write with zero length and this
require ib connection. due to this sdp behaviour you cannot set keepalive
on listening server socket or on non connected client socket. apps can
use sdp in 2 ways. binary apps that use tcp sockets can use the libsdp
to direct all the socket calls to sdp and new apps can open and use sdp
sockets directly w/o the need for libsdp. when using sdp socket directly
please follow the below rules:

- define: AF_INET_SDP = SOL_SDP = 27
- create the socket as follow:
socket(AF_INET_SDP, SOCK_STREAM, 0)
- get the sdp socket keepalive as follow:
getsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &optval, &optlen)
- set the sdp socket keepalive as follow:
setsockopt(fd, SOL_SDP, SO_KEEPALIVE, &optval, optlen)

when you load the sdp module;
- set the keepalive time. this is the max period in sec of no data before
sdp start to send the probes. you should take to account that more
then one probe is needed till sdp detect that the remote hca is gone.
echo <time sec> > /sys/module/ib_sdp/parameters/sdp_keepalive_time
- zero the probes counter. this counter is incremented any time sdp send probe.
probes are sent only if there is no tx/rx on this queue pair for the
keepalive time period.
echo 0 > /sys/module/ib_sdp/parameters/sdp_keepalive_probes_sent

on server socket:
- set keepalive only on accepted socket

on client socket:
- set keepalive only on socket after connect

Orabug: 18728784

Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
Signed-off-by: Vadim Makhervaks <vadim.makhervaks@oracle.com>
Signed-off-by: Guangyu Sun <guangyu.sun@oracle.com>
drivers/infiniband/ulp/sdp/sdp_main.c
drivers/infiniband/ulp/sdp/sdp_tx.c

index 70cf9ed3956562c2a903072fa77781fec503e4d4..b7ea88c5bd598acee4584d4655bbdb6d9b556996 100644 (file)
@@ -244,8 +244,6 @@ static void sdp_reset_keepalive_timer(struct sock *sk, unsigned long len)
 {
        struct sdp_sock *ssk = sdp_sk(sk);
 
-       sdp_dbg(sk, "%s\n", __func__);
-
        ssk->keepalive_tx_head = ring_head(ssk->tx_ring);
        ssk->keepalive_rx_head = ring_head(ssk->rx_ring);
 
@@ -269,7 +267,6 @@ static void sdp_keepalive_timer(unsigned long data)
        struct sock *sk = (struct sock *)data;
        struct sdp_sock *ssk = sdp_sk(sk);
 
-       sdp_dbg(sk, "%s\n", __func__);
        SDPSTATS_COUNTER_INC(keepalive_timer);
 
        /* Only process if the socket is not in use */
@@ -296,8 +293,6 @@ out:
 
 static void sdp_set_keepalive(struct sock *sk, int val)
 {
-       sdp_dbg(sk, "%s %d\n", __func__, val);
-
        if ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))
                return;
 
index a7b68de2a468cededf65f4c50f5e823fefa0d280..c91231d0121cfebfdaed4c85213e5828498cdab7 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/ratelimit.h>
 #include <rdma/ib_verbs.h>
 #include <rdma/rdma_cm.h>
 #include "sdp.h"
@@ -430,8 +431,9 @@ void sdp_post_keepalive(struct sdp_sock *ssk)
 {
        int rc;
        struct ib_send_wr wr, *bad_wr;
-
-       sdp_dbg(sk_ssk(ssk), "%s\n", __func__);
+       static DEFINE_RATELIMIT_STATE(_rs,
+               DEFAULT_RATELIMIT_INTERVAL,
+               DEFAULT_RATELIMIT_BURST);
 
        memset(&wr, 0, sizeof(wr));
 
@@ -440,15 +442,19 @@ void sdp_post_keepalive(struct sdp_sock *ssk)
        wr.sg_list = NULL;
        wr.num_sge = 0;
        wr.opcode  = IB_WR_RDMA_WRITE;
+       wr.send_flags = IB_SEND_SIGNALED;
 
        rc = ib_post_send(ssk->qp, &wr, &bad_wr);
        if (rc) {
-               sdp_dbg(sk_ssk(ssk),
-                       "ib_post_keepalive failed with status %d.\n", rc);
-               sdp_set_error(sk_ssk(ssk), -ECONNRESET);
+               if (__ratelimit(&_rs))
+                       sdp_warn(sk_ssk(ssk),
+                               "ib_post_keepalive "
+                               "failed with status %d.\n", rc);
+       } else {
+               sdp_cnt(sdp_keepalive_probes_sent);
        }
 
-       sdp_cnt(sdp_keepalive_probes_sent);
+       sdp_xmit_poll(ssk, 1);
 }
 
 static void sdp_tx_cq_event_handler(struct ib_event *event, void *data)