Whamcloud - gitweb
LU-9425 lnd: Turn on 2 sges by default
[fs/lustre-release.git] / lnet / klnds / o2iblnd / o2iblnd_modparams.c
index 7143085..3ca0689 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -36,6 +36,8 @@
 
 #include "o2iblnd.h"
 
+#define CURRENT_LND_VERSION 1
+
 static int service = 987;
 module_param(service, int, 0444);
 MODULE_PARM_DESC(service, "service number (within RDMA_PS_TCP)");
@@ -54,6 +56,10 @@ static int nscheds;
 module_param(nscheds, int, 0444);
 MODULE_PARM_DESC(nscheds, "number of threads in each scheduler pool");
 
+static unsigned int conns_per_peer = 1;
+module_param(conns_per_peer, uint, 0444);
+MODULE_PARM_DESC(conns_per_peer, "number of connections per peer");
+
 /* NB: this value is shared by all CPTs, it can grow at runtime */
 static int ntx = 512;
 module_param(ntx, int, 0444);
@@ -104,7 +110,14 @@ static int concurrent_sends;
 module_param(concurrent_sends, int, 0444);
 MODULE_PARM_DESC(concurrent_sends, "send work-queue sizing");
 
-static int map_on_demand;
+#ifdef HAVE_IB_GET_DMA_MR
+#define IBLND_DEFAULT_MAP_ON_DEMAND 0
+#define IBLND_MIN_MAP_ON_DEMAND 0
+#else
+#define IBLND_DEFAULT_MAP_ON_DEMAND IBLND_MAX_RDMA_FRAGS
+#define IBLND_MIN_MAP_ON_DEMAND 1
+#endif
+static int map_on_demand = IBLND_DEFAULT_MAP_ON_DEMAND;
 module_param(map_on_demand, int, 0444);
 MODULE_PARM_DESC(map_on_demand, "map on demand");
 
@@ -139,6 +152,10 @@ static int use_privileged_port = 1;
 module_param(use_privileged_port, int, 0644);
 MODULE_PARM_DESC(use_privileged_port, "use privileged port when initiating connection");
 
+static unsigned int wrq_sge = 2;
+module_param(wrq_sge, uint, 0444);
+MODULE_PARM_DESC(wrq_sge, "# scatter/gather element per work request");
+
 kib_tunables_t kiblnd_tunables = {
         .kib_dev_failover           = &dev_failover,
         .kib_service                = &service,
@@ -152,45 +169,42 @@ kib_tunables_t kiblnd_tunables = {
         .kib_ib_mtu                 = &ib_mtu,
         .kib_require_priv_port      = &require_privileged_port,
        .kib_use_priv_port          = &use_privileged_port,
-       .kib_nscheds                = &nscheds
+       .kib_nscheds                = &nscheds,
+       .kib_wrq_sge                = &wrq_sge,
 };
 
 static struct lnet_ioctl_config_o2iblnd_tunables default_tunables;
 
 /* # messages/RDMAs in-flight */
 int
-kiblnd_msg_queue_size(int version, lnet_ni_t *ni)
+kiblnd_msg_queue_size(int version, struct lnet_ni *ni)
 {
        if (version == IBLND_MSG_VERSION_1)
                return IBLND_MSG_QUEUE_SIZE_V1;
        else if (ni)
-               return ni->ni_peertxcredits;
+               return ni->ni_net->net_tunables.lct_peer_tx_credits;
        else
                return peer_credits;
 }
 
 int
-kiblnd_tunables_setup(lnet_ni_t *ni)
+kiblnd_tunables_setup(struct lnet_ni *ni)
 {
        struct lnet_ioctl_config_o2iblnd_tunables *tunables;
+       struct lnet_ioctl_config_lnd_cmn_tunables *net_tunables;
 
        /*
         * if there was no tunables specified, setup the tunables to be
         * defaulted
         */
-       if (!ni->ni_lnd_tunables) {
-               LIBCFS_ALLOC(ni->ni_lnd_tunables,
-                            sizeof(*ni->ni_lnd_tunables));
-               if (!ni->ni_lnd_tunables)
-                       return -ENOMEM;
-
-               memcpy(&ni->ni_lnd_tunables->lt_tun_u.lt_o2ib,
+       if (!ni->ni_lnd_tunables_set)
+               memcpy(&ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib,
                       &default_tunables, sizeof(*tunables));
-       }
-       tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib;
+
+       tunables = &ni->ni_lnd_tunables.lnd_tun_u.lnd_o2ib;
 
        /* Current API version */
-       tunables->lnd_version = 0;
+       tunables->lnd_version = CURRENT_LND_VERSION;
 
        if (kiblnd_translate_mtu(*kiblnd_tunables.kib_ib_mtu) < 0) {
                CERROR("Invalid ib_mtu %d, expected 256/512/1024/2048/4096\n",
@@ -198,40 +212,47 @@ kiblnd_tunables_setup(lnet_ni_t *ni)
                return -EINVAL;
        }
 
-       if (!ni->ni_peertimeout)
-               ni->ni_peertimeout = peer_timeout;
+       net_tunables = &ni->ni_net->net_tunables;
+
+       if (net_tunables->lct_peer_timeout == -1)
+               net_tunables->lct_peer_timeout = peer_timeout;
 
-       if (!ni->ni_maxtxcredits)
-               ni->ni_maxtxcredits = credits;
+       if (net_tunables->lct_max_tx_credits == -1)
+               net_tunables->lct_max_tx_credits = credits;
 
-       if (!ni->ni_peertxcredits)
-               ni->ni_peertxcredits = peer_credits;
+       if (net_tunables->lct_peer_tx_credits == -1)
+               net_tunables->lct_peer_tx_credits = peer_credits;
 
-       if (!ni->ni_peerrtrcredits)
-               ni->ni_peerrtrcredits = peer_buffer_credits;
+       if (net_tunables->lct_peer_rtr_credits == -1)
+               net_tunables->lct_peer_rtr_credits = peer_buffer_credits;
 
-       if (ni->ni_peertxcredits < IBLND_CREDITS_DEFAULT)
-               ni->ni_peertxcredits = IBLND_CREDITS_DEFAULT;
+       if (net_tunables->lct_peer_tx_credits < IBLND_CREDITS_DEFAULT)
+               net_tunables->lct_peer_tx_credits = IBLND_CREDITS_DEFAULT;
 
-       if (ni->ni_peertxcredits > IBLND_CREDITS_MAX)
-               ni->ni_peertxcredits = IBLND_CREDITS_MAX;
+       if (net_tunables->lct_peer_tx_credits > IBLND_CREDITS_MAX)
+               net_tunables->lct_peer_tx_credits = IBLND_CREDITS_MAX;
 
-       if (ni->ni_peertxcredits > credits)
-               ni->ni_peertxcredits = credits;
+       if (net_tunables->lct_peer_tx_credits >
+           net_tunables->lct_max_tx_credits)
+               net_tunables->lct_peer_tx_credits =
+                       net_tunables->lct_max_tx_credits;
 
        if (!tunables->lnd_peercredits_hiw)
                tunables->lnd_peercredits_hiw = peer_credits_hiw;
 
-       if (tunables->lnd_peercredits_hiw < ni->ni_peertxcredits / 2)
-               tunables->lnd_peercredits_hiw = ni->ni_peertxcredits / 2;
+       if (tunables->lnd_peercredits_hiw < net_tunables->lct_peer_tx_credits / 2)
+               tunables->lnd_peercredits_hiw = net_tunables->lct_peer_tx_credits / 2;
 
-       if (tunables->lnd_peercredits_hiw >= ni->ni_peertxcredits)
-               tunables->lnd_peercredits_hiw = ni->ni_peertxcredits - 1;
+       if (tunables->lnd_peercredits_hiw >= net_tunables->lct_peer_tx_credits)
+               tunables->lnd_peercredits_hiw = net_tunables->lct_peer_tx_credits - 1;
 
-       if (tunables->lnd_map_on_demand < 0 ||
+       if (tunables->lnd_map_on_demand < IBLND_MIN_MAP_ON_DEMAND ||
            tunables->lnd_map_on_demand > IBLND_MAX_RDMA_FRAGS) {
-               /* disable map-on-demand */
-               tunables->lnd_map_on_demand = 0;
+               /* Use the default */
+               CWARN("Invalid map_on_demand (%d), expects %d - %d. Using default of %d\n",
+                     tunables->lnd_map_on_demand, IBLND_MIN_MAP_ON_DEMAND,
+                     IBLND_MAX_RDMA_FRAGS, IBLND_DEFAULT_MAP_ON_DEMAND);
+               tunables->lnd_map_on_demand = IBLND_DEFAULT_MAP_ON_DEMAND;
        }
 
        if (tunables->lnd_map_on_demand == 1) {
@@ -243,22 +264,24 @@ kiblnd_tunables_setup(lnet_ni_t *ni)
                if (tunables->lnd_map_on_demand > 0 &&
                    tunables->lnd_map_on_demand <= IBLND_MAX_RDMA_FRAGS / 8) {
                        tunables->lnd_concurrent_sends =
-                                               ni->ni_peertxcredits * 2;
+                                       net_tunables->lct_peer_tx_credits * 2;
                } else {
-                       tunables->lnd_concurrent_sends = ni->ni_peertxcredits;
+                       tunables->lnd_concurrent_sends =
+                               net_tunables->lct_peer_tx_credits;
                }
        }
 
-       if (tunables->lnd_concurrent_sends > ni->ni_peertxcredits * 2)
-               tunables->lnd_concurrent_sends = ni->ni_peertxcredits * 2;
+       if (tunables->lnd_concurrent_sends > net_tunables->lct_peer_tx_credits * 2)
+               tunables->lnd_concurrent_sends = net_tunables->lct_peer_tx_credits * 2;
 
-       if (tunables->lnd_concurrent_sends < ni->ni_peertxcredits / 2)
-               tunables->lnd_concurrent_sends = ni->ni_peertxcredits / 2;
+       if (tunables->lnd_concurrent_sends < net_tunables->lct_peer_tx_credits / 2)
+               tunables->lnd_concurrent_sends = net_tunables->lct_peer_tx_credits / 2;
 
-       if (tunables->lnd_concurrent_sends < ni->ni_peertxcredits) {
+       if (tunables->lnd_concurrent_sends < net_tunables->lct_peer_tx_credits) {
                CWARN("Concurrent sends %d is lower than message "
                      "queue size: %d, performance may drop slightly.\n",
-                     tunables->lnd_concurrent_sends, ni->ni_peertxcredits);
+                     tunables->lnd_concurrent_sends,
+                     net_tunables->lct_peer_tx_credits);
        }
 
        if (!tunables->lnd_fmr_pool_size)
@@ -267,6 +290,10 @@ kiblnd_tunables_setup(lnet_ni_t *ni)
                tunables->lnd_fmr_flush_trigger = fmr_flush_trigger;
        if (!tunables->lnd_fmr_cache)
                tunables->lnd_fmr_cache = fmr_cache;
+       if (!tunables->lnd_conns_per_peer) {
+               tunables->lnd_conns_per_peer = (conns_per_peer) ?
+                       conns_per_peer : 1;
+       }
 
        return 0;
 }
@@ -274,12 +301,13 @@ kiblnd_tunables_setup(lnet_ni_t *ni)
 int
 kiblnd_tunables_init(void)
 {
-       default_tunables.lnd_version = 0;
+       default_tunables.lnd_version = CURRENT_LND_VERSION;
        default_tunables.lnd_peercredits_hiw = peer_credits_hiw,
        default_tunables.lnd_map_on_demand = map_on_demand;
        default_tunables.lnd_concurrent_sends = concurrent_sends;
        default_tunables.lnd_fmr_pool_size = fmr_pool_size;
        default_tunables.lnd_fmr_flush_trigger = fmr_flush_trigger;
        default_tunables.lnd_fmr_cache = fmr_cache;
+       default_tunables.lnd_conns_per_peer = conns_per_peer;
        return 0;
 }