Whamcloud - gitweb
LU-12477 lnet: Remove obsolete config options
[fs/lustre-release.git] / lnet / klnds / socklnd / socklnd_lib.c
index db244c8..93d4b8f 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 #include "socklnd.h"
 
 int
-ksocknal_lib_get_conn_addrs (ksock_conn_t *conn)
+ksocknal_lib_get_conn_addrs(struct ksock_conn *conn)
 {
        int rc = lnet_sock_getaddr(conn->ksnc_sock, true,
-                                     &conn->ksnc_ipaddr,
-                                     &conn->ksnc_port);
+                                  &conn->ksnc_ipaddr,
+                                  &conn->ksnc_port);
 
         /* Didn't need the {get,put}connsock dance to deref ksnc_sock... */
         LASSERT (!conn->ksnc_closing);
 
         if (rc != 0) {
-                CERROR ("Error %d getting sock peer IP\n", rc);
+                CERROR ("Error %d getting sock peer_ni IP\n", rc);
                 return rc;
         }
 
@@ -62,7 +58,7 @@ ksocknal_lib_get_conn_addrs (ksock_conn_t *conn)
 }
 
 int
-ksocknal_lib_zc_capable(ksock_conn_t *conn)
+ksocknal_lib_zc_capable(struct ksock_conn *conn)
 {
        int  caps = conn->ksnc_sock->sk->sk_route_caps;
 
@@ -75,7 +71,8 @@ ksocknal_lib_zc_capable(ksock_conn_t *conn)
 }
 
 int
-ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx)
+ksocknal_lib_send_iov(struct ksock_conn *conn, struct ksock_tx *tx,
+                     struct kvec *scratchiov)
 {
        struct socket  *sock = conn->ksnc_sock;
        int             nob;
@@ -96,7 +93,6 @@ ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx)
                struct kvec *scratchiov = &scratch;
                unsigned int niov = 1;
 #else
-               struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
                unsigned int niov = tx->tx_niov;
 #endif
                struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
@@ -117,41 +113,41 @@ ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx)
 }
 
 int
-ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
+ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx,
+                      struct kvec *scratchiov)
 {
-        struct socket *sock = conn->ksnc_sock;
-        lnet_kiov_t   *kiov = tx->tx_kiov;
-        int            rc;
-        int            nob;
+       struct socket *sock = conn->ksnc_sock;
+       lnet_kiov_t   *kiov = tx->tx_kiov;
+       int            rc;
+       int            nob;
 
-        /* Not NOOP message */
-        LASSERT (tx->tx_lnetmsg != NULL);
+       /* Not NOOP message */
+       LASSERT(tx->tx_lnetmsg != NULL);
 
-        /* NB we can't trust socket ops to either consume our iovs
-         * or leave them alone. */
-        if (tx->tx_msg.ksm_zc_cookies[0] != 0) {
-                /* Zero copy is enabled */
-                struct sock   *sk = sock->sk;
-                struct page   *page = kiov->kiov_page;
-                int            offset = kiov->kiov_offset;
-                int            fragsize = kiov->kiov_len;
-                int            msgflg = MSG_DONTWAIT;
+       /* NB we can't trust socket ops to either consume our iovs
+        * or leave them alone. */
+       if (tx->tx_msg.ksm_zc_cookies[0] != 0) {
+               /* Zero copy is enabled */
+               struct sock   *sk = sock->sk;
+               struct page   *page = kiov->kiov_page;
+               int            offset = kiov->kiov_offset;
+               int            fragsize = kiov->kiov_len;
+               int            msgflg = MSG_DONTWAIT;
 
-                CDEBUG(D_NET, "page %p + offset %x for %d\n",
-                               page, offset, kiov->kiov_len);
+               CDEBUG(D_NET, "page %p + offset %x for %d\n",
+                              page, offset, kiov->kiov_len);
 
                if (!list_empty(&conn->ksnc_tx_queue) ||
-                    fragsize < tx->tx_resid)
-                        msgflg |= MSG_MORE;
-
-                if (sk->sk_prot->sendpage != NULL) {
-                        rc = sk->sk_prot->sendpage(sk, page,
-                                                   offset, fragsize, msgflg);
-                } else {
-                        rc = cfs_tcp_sendpage(sk, page, offset, fragsize,
-                                              msgflg);
-                }
-        } else {
+                   fragsize < tx->tx_resid)
+                       msgflg |= MSG_MORE;
+
+               if (sk->sk_prot->sendpage != NULL) {
+                       rc = sk->sk_prot->sendpage(sk, page,
+                                                  offset, fragsize, msgflg);
+               } else {
+                       rc = tcp_sendpage(sk, page, offset, fragsize, msgflg);
+               }
+       } else {
 #if SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_RISK_KMAP_DEADLOCK
                struct kvec     scratch;
                struct kvec   *scratchiov = &scratch;
@@ -160,7 +156,6 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
 #ifdef CONFIG_HIGHMEM
 #warning "XXX risk of kmap deadlock on multiple frags..."
 #endif
-               struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
                unsigned int  niov = tx->tx_nkiov;
 #endif
                struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
@@ -185,29 +180,28 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
 }
 
 void
-ksocknal_lib_eager_ack (ksock_conn_t *conn)
+ksocknal_lib_eager_ack(struct ksock_conn *conn)
 {
-        int            opt = 1;
-        struct socket *sock = conn->ksnc_sock;
+       int opt = 1;
+       struct socket *sock = conn->ksnc_sock;
 
         /* Remind the socket to ACK eagerly.  If I don't, the socket might
          * think I'm about to send something it could piggy-back the ACK
          * on, introducing delay in completing zero-copy sends in my
-         * peer. */
+         * peer_ni. */
 
        kernel_setsockopt(sock, SOL_TCP, TCP_QUICKACK,
                          (char *)&opt, sizeof(opt));
 }
 
 int
-ksocknal_lib_recv_iov (ksock_conn_t *conn)
+ksocknal_lib_recv_iov(struct ksock_conn *conn, struct kvec *scratchiov)
 {
 #if SOCKNAL_SINGLE_FRAG_RX
        struct kvec  scratch;
        struct kvec *scratchiov = &scratch;
        unsigned int  niov = 1;
 #else
-       struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
        unsigned int  niov = conn->ksnc_rx_niov;
 #endif
        struct kvec *iov = conn->ksnc_rx_iov;
@@ -305,7 +299,8 @@ ksocknal_lib_kiov_vmap(lnet_kiov_t *kiov, int niov,
 }
 
 int
-ksocknal_lib_recv_kiov (ksock_conn_t *conn)
+ksocknal_lib_recv_kiov(struct ksock_conn *conn, struct page **pages,
+                      struct kvec *scratchiov)
 {
 #if SOCKNAL_SINGLE_FRAG_RX || !SOCKNAL_RISK_KMAP_DEADLOCK
        struct kvec   scratch;
@@ -316,8 +311,6 @@ ksocknal_lib_recv_kiov (ksock_conn_t *conn)
 #ifdef CONFIG_HIGHMEM
 #warning "XXX risk of kmap deadlock on multiple frags..."
 #endif
-       struct kvec  *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
-       struct page  **pages      = conn->ksnc_scheduler->kss_rx_scratch_pgs;
        unsigned int   niov       = conn->ksnc_rx_nkiov;
 #endif
        lnet_kiov_t   *kiov = conn->ksnc_rx_kiov;
@@ -384,7 +377,7 @@ ksocknal_lib_recv_kiov (ksock_conn_t *conn)
 }
 
 void
-ksocknal_lib_csum_tx(ksock_tx_t *tx)
+ksocknal_lib_csum_tx(struct ksock_tx *tx)
 {
         int          i;
         __u32        csum;
@@ -423,7 +416,7 @@ ksocknal_lib_csum_tx(ksock_tx_t *tx)
 }
 
 int
-ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int *nagle)
+ksocknal_lib_get_conn_tunables(struct ksock_conn *conn, int *txmem, int *rxmem, int *nagle)
 {
         struct socket *sock = conn->ksnc_sock;
         int            len;
@@ -584,13 +577,13 @@ ksocknal_lib_setup_sock (struct socket *sock)
 }
 
 void
-ksocknal_lib_push_conn (ksock_conn_t *conn)
+ksocknal_lib_push_conn(struct ksock_conn *conn)
 {
-        struct sock    *sk;
-        struct tcp_sock *tp;
-        int             nonagle;
-        int             val = 1;
-        int             rc;
+       struct sock *sk;
+       struct tcp_sock *tp;
+       int nonagle;
+       int val = 1;
+       int rc;
 
         rc = ksocknal_connsock_addref(conn);
         if (rc != 0)                            /* being shut down */
@@ -615,8 +608,8 @@ ksocknal_lib_push_conn (ksock_conn_t *conn)
         ksocknal_connsock_decref(conn);
 }
 
-extern void ksocknal_read_callback (ksock_conn_t *conn);
-extern void ksocknal_write_callback (ksock_conn_t *conn);
+void ksocknal_read_callback(struct ksock_conn *conn);
+void ksocknal_write_callback(struct ksock_conn *conn);
 /*
  * socket call back in Linux
  */
@@ -627,7 +620,7 @@ ksocknal_data_ready(struct sock *sk)
 ksocknal_data_ready(struct sock *sk, int n)
 #endif
 {
-       ksock_conn_t  *conn;
+       struct ksock_conn  *conn;
        ENTRY;
 
         /* interleave correctly with closing sockets... */
@@ -653,7 +646,7 @@ ksocknal_data_ready(struct sock *sk, int n)
 static void
 ksocknal_write_space (struct sock *sk)
 {
-        ksock_conn_t  *conn;
+       struct ksock_conn  *conn;
         int            wspace;
         int            min_wpace;
 
@@ -696,14 +689,14 @@ ksocknal_write_space (struct sock *sk)
 }
 
 void
-ksocknal_lib_save_callback(struct socket *sock, ksock_conn_t *conn)
+ksocknal_lib_save_callback(struct socket *sock, struct ksock_conn *conn)
 {
         conn->ksnc_saved_data_ready = sock->sk->sk_data_ready;
         conn->ksnc_saved_write_space = sock->sk->sk_write_space;
 }
 
 void
-ksocknal_lib_set_callback(struct socket *sock,  ksock_conn_t *conn)
+ksocknal_lib_set_callback(struct socket *sock,  struct ksock_conn *conn)
 {
         sock->sk->sk_user_data = conn;
         sock->sk->sk_data_ready = ksocknal_data_ready;
@@ -712,7 +705,7 @@ ksocknal_lib_set_callback(struct socket *sock,  ksock_conn_t *conn)
 }
 
 void
-ksocknal_lib_reset_callback(struct socket *sock, ksock_conn_t *conn)
+ksocknal_lib_reset_callback(struct socket *sock, struct ksock_conn *conn)
 {
         /* Remove conn's network callbacks.
          * NB I _have_ to restore the callback, rather than storing a noop,
@@ -729,10 +722,10 @@ ksocknal_lib_reset_callback(struct socket *sock, ksock_conn_t *conn)
 }
 
 int
-ksocknal_lib_memory_pressure(ksock_conn_t *conn)
+ksocknal_lib_memory_pressure(struct ksock_conn *conn)
 {
        int            rc = 0;
-       ksock_sched_t *sched;
+       struct ksock_sched *sched;
 
        sched = conn->ksnc_scheduler;
        spin_lock_bh(&sched->kss_lock);