[02/34] lnet: Create struct lnet_net
diff mbox series

Message ID 153628137129.8267.345070695068208597.stgit@noble
State New
Headers show
Series
  • Beginning of multi-rail support for drivers/staging/lustre
Related show

Commit Message

NeilBrown Sept. 7, 2018, 12:49 a.m. UTC
This will contain some fields from lnet_ni, to be shared
between multiple ni on the one network.

For now, only tunables are moved across, using
 struct lnet_ioctl_config_lnd_cmn_tunables
which is changed to use signed values so -1 can be stored.
-1 means "no value"
If the tunables haven't been initialised, then net_tunables_set is
false.  Previously a NULL pointer had this meaning.

A 'struct lnet_net' is allocated as part of lnet_ni_alloc(), and freed
by lnet_ni_free().

This is part of
    8cbb8cd3e771e7f7e0f99cafc19fad32770dc015
       LU-7734 lnet: Multi-Rail local NI split

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/lnet/lib-types.h  |   25 ++++++--
 .../lustre/include/uapi/linux/lnet/lnet-dlc.h      |    8 +--
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    2 -
 .../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c  |   61 +++++++++++---------
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |   19 ++++--
 drivers/staging/lustre/lnet/lnet/api-ni.c          |   45 +++++++++------
 drivers/staging/lustre/lnet/lnet/config.c          |   24 ++++++--
 drivers/staging/lustre/lnet/lnet/lib-move.c        |    5 +-
 drivers/staging/lustre/lnet/lnet/peer.c            |    9 ++-
 drivers/staging/lustre/lnet/lnet/router.c          |    8 ++-
 drivers/staging/lustre/lnet/lnet/router_proc.c     |    6 +-
 11 files changed, 129 insertions(+), 83 deletions(-)

Comments

Doug Oucharek Sept. 10, 2018, 10:56 p.m. UTC | #1
Reviewed-by: Doug Oucharek <dougso@me.com<mailto:dougso@me.com>>

Doug

On Sep 6, 2018, at 5:49 PM, NeilBrown <neilb@suse.com<mailto:neilb@suse.com>> wrote:

This will contain some fields from lnet_ni, to be shared
between multiple ni on the one network.

For now, only tunables are moved across, using
struct lnet_ioctl_config_lnd_cmn_tunables
which is changed to use signed values so -1 can be stored.
-1 means "no value"
If the tunables haven't been initialised, then net_tunables_set is
false.  Previously a NULL pointer had this meaning.

A 'struct lnet_net' is allocated as part of lnet_ni_alloc(), and freed
by lnet_ni_free().

This is part of
   8cbb8cd3e771e7f7e0f99cafc19fad32770dc015
      LU-7734 lnet: Multi-Rail local NI split

Signed-off-by: NeilBrown <neilb@suse.com<mailto:neilb@suse.com>>
---
.../staging/lustre/include/linux/lnet/lib-types.h  |   25 ++++++--
.../lustre/include/uapi/linux/lnet/lnet-dlc.h      |    8 +--
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    2 -
.../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c  |   61 +++++++++++---------
.../staging/lustre/lnet/klnds/socklnd/socklnd.c    |   19 ++++--
drivers/staging/lustre/lnet/lnet/api-ni.c          |   45 +++++++++------
drivers/staging/lustre/lnet/lnet/config.c          |   24 ++++++--
drivers/staging/lustre/lnet/lnet/lib-move.c        |    5 +-
drivers/staging/lustre/lnet/lnet/peer.c            |    9 ++-
drivers/staging/lustre/lnet/lnet/router.c          |    8 ++-
drivers/staging/lustre/lnet/lnet/router_proc.c     |    6 +-
11 files changed, 129 insertions(+), 83 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h
index 078bc97a9ebf..ead8a4e1125a 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-types.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h
@@ -43,6 +43,7 @@

#include <uapi/linux/lnet/lnet-types.h>
#include <uapi/linux/lnet/lnetctl.h>
+#include <uapi/linux/lnet/lnet-dlc.h>

/* Max payload size */
#define LNET_MAX_PAYLOAD      CONFIG_LNET_MAX_PAYLOAD
@@ -252,17 +253,22 @@ struct lnet_tx_queue {
struct list_head tq_delayed; /* delayed TXs */
};

+struct lnet_net {
+ /* network tunables */
+ struct lnet_ioctl_config_lnd_cmn_tunables net_tunables;
+
+ /*
+ * boolean to indicate that the tunables have been set and
+ * shouldn't be reset
+ */
+ bool  net_tunables_set;
+};
+
struct lnet_ni {
spinlock_t  ni_lock;
struct list_head  ni_list; /* chain on ln_nis */
struct list_head  ni_cptlist; /* chain on ln_nis_cpt */
- int  ni_maxtxcredits; /* # tx credits  */
- /* # per-peer send credits */
- int  ni_peertxcredits;
- /* # per-peer router buffer credits */
- int  ni_peerrtrcredits;
- /* seconds to consider peer dead */
- int  ni_peertimeout;
+
/* number of CPTs */
int ni_ncpts;

@@ -286,6 +292,9 @@ struct lnet_ni {
/* when I was last alive */
time64_t ni_last_alive;

+ /* pointer to parent network */
+ struct lnet_net *ni_net;
+
/* my health status */
struct lnet_ni_status *ni_status;

@@ -397,7 +406,7 @@ struct lnet_peer_table {
 * lnet_ni::ni_peertimeout has been set to a positive value
 */
#define lnet_peer_aliveness_enabled(lp) (the_lnet.ln_routing && \
- (lp)->lp_ni->ni_peertimeout > 0)
+ (lp)->lp_ni->ni_net->net_tunables.lct_peer_timeout > 0)

struct lnet_route {
struct list_head lr_list; /* chain on net */
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
index c1619f411d81..a8eb3b8f9fd7 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
@@ -39,10 +39,10 @@

struct lnet_ioctl_config_lnd_cmn_tunables {
__u32 lct_version;
- __u32 lct_peer_timeout;
- __u32 lct_peer_tx_credits;
- __u32 lct_peer_rtr_credits;
- __u32 lct_max_tx_credits;
+ __s32 lct_peer_timeout;
+ __s32 lct_peer_tx_credits;
+ __s32 lct_peer_rtr_credits;
+ __s32 lct_max_tx_credits;
};

struct lnet_ioctl_config_o2iblnd_tunables {
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index f496e6fcc416..0d17e22c4401 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -337,7 +337,7 @@ int kiblnd_create_peer(struct lnet_ni *ni, struct kib_peer **peerp,
peer->ibp_error = 0;
peer->ibp_last_alive = 0;
peer->ibp_max_frags = kiblnd_cfg_rdma_frags(peer->ibp_ni);
- peer->ibp_queue_depth = ni->ni_peertxcredits;
+ peer->ibp_queue_depth = ni->ni_net->net_tunables.lct_peer_tx_credits;
atomic_set(&peer->ibp_refcount, 1);  /* 1 ref for caller */

INIT_LIST_HEAD(&peer->ibp_list);     /* not in the peer table yet */
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
index 39d07926d603..a1aca4dda38f 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
@@ -171,7 +171,7 @@ int 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;
}
@@ -179,6 +179,7 @@ int kiblnd_msg_queue_size(int version, struct lnet_ni *ni)
int 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
@@ -204,35 +205,39 @@ int kiblnd_tunables_setup(struct lnet_ni *ni)
return -EINVAL;
}

- if (!ni->ni_peertimeout)
- ni->ni_peertimeout = peer_timeout;
+ net_tunables = &ni->ni_net->net_tunables;

- if (!ni->ni_maxtxcredits)
- ni->ni_maxtxcredits = credits;
+ if (net_tunables->lct_peer_timeout == -1)
+ net_tunables->lct_peer_timeout = peer_timeout;

- if (!ni->ni_peertxcredits)
- ni->ni_peertxcredits = peer_credits;
+ if (net_tunables->lct_max_tx_credits == -1)
+ net_tunables->lct_max_tx_credits = credits;

- if (!ni->ni_peerrtrcredits)
- ni->ni_peerrtrcredits = peer_buffer_credits;
+ if (net_tunables->lct_peer_tx_credits == -1)
+ net_tunables->lct_peer_tx_credits = peer_credits;

- if (ni->ni_peertxcredits < IBLND_CREDITS_DEFAULT)
- ni->ni_peertxcredits = IBLND_CREDITS_DEFAULT;
+ if (net_tunables->lct_peer_rtr_credits == -1)
+ net_tunables->lct_peer_rtr_credits = peer_buffer_credits;

- if (ni->ni_peertxcredits > IBLND_CREDITS_MAX)
- ni->ni_peertxcredits = IBLND_CREDITS_MAX;
+ if (net_tunables->lct_peer_tx_credits < IBLND_CREDITS_DEFAULT)
+ net_tunables->lct_peer_tx_credits = IBLND_CREDITS_DEFAULT;

- if (ni->ni_peertxcredits > credits)
- ni->ni_peertxcredits = credits;
+ if (net_tunables->lct_peer_tx_credits > IBLND_CREDITS_MAX)
+ net_tunables->lct_peer_tx_credits = IBLND_CREDITS_MAX;
+
+ 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 ||
   tunables->lnd_map_on_demand > IBLND_MAX_RDMA_FRAGS) {
@@ -252,21 +257,23 @@ int kiblnd_tunables_setup(struct lnet_ni *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)
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 4dde158451ea..4ad885f10235 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -2739,12 +2739,19 @@ ksocknal_startup(struct lnet_ni *ni)
goto fail_0;

spin_lock_init(&net->ksnn_lock);
- net->ksnn_incarnation = ktime_get_real_ns();
- ni->ni_data = net;
- ni->ni_peertimeout    = *ksocknal_tunables.ksnd_peertimeout;
- ni->ni_maxtxcredits   = *ksocknal_tunables.ksnd_credits;
- ni->ni_peertxcredits  = *ksocknal_tunables.ksnd_peertxcredits;
- ni->ni_peerrtrcredits = *ksocknal_tunables.ksnd_peerrtrcredits;
+        net->ksnn_incarnation = ktime_get_real_ns();
+        ni->ni_data = net;
+ if (!ni->ni_net->net_tunables_set) {
+ ni->ni_net->net_tunables.lct_peer_timeout =
+ *ksocknal_tunables.ksnd_peertimeout;
+ ni->ni_net->net_tunables.lct_max_tx_credits =
+ *ksocknal_tunables.ksnd_credits;
+ ni->ni_net->net_tunables.lct_peer_tx_credits =
+ *ksocknal_tunables.ksnd_peertxcredits;
+ ni->ni_net->net_tunables.lct_peer_rtr_credits =
+ *ksocknal_tunables.ksnd_peerrtrcredits;
+ ni->ni_net->net_tunables_set = true;
+ }

net->ksnn_ninterfaces = 0;
if (!ni->ni_interfaces[0]) {
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index f9fcce2a5643..cd4189fa7acb 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -1036,11 +1036,11 @@ lnet_ni_tq_credits(struct lnet_ni *ni)
LASSERT(ni->ni_ncpts >= 1);

if (ni->ni_ncpts == 1)
- return ni->ni_maxtxcredits;
+ return ni->ni_net->net_tunables.lct_max_tx_credits;

- credits = ni->ni_maxtxcredits / ni->ni_ncpts;
- credits = max(credits, 8 * ni->ni_peertxcredits);
- credits = min(credits, ni->ni_maxtxcredits);
+ credits = ni->ni_net->net_tunables.lct_max_tx_credits / ni->ni_ncpts;
+ credits = max(credits, 8 * ni->ni_net->net_tunables.lct_peer_tx_credits);
+ credits = min(credits, ni->ni_net->net_tunables.lct_max_tx_credits);

return credits;
}
@@ -1271,16 +1271,16 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
*/
if (conf) {
if (conf->cfg_config_u.cfg_net.net_peer_rtr_credits >= 0)
- ni->ni_peerrtrcredits =
+ ni->ni_net->net_tunables.lct_peer_rtr_credits =
conf->cfg_config_u.cfg_net.net_peer_rtr_credits;
if (conf->cfg_config_u.cfg_net.net_peer_timeout >= 0)
- ni->ni_peertimeout =
+ ni->ni_net->net_tunables.lct_peer_timeout =
conf->cfg_config_u.cfg_net.net_peer_timeout;
if (conf->cfg_config_u.cfg_net.net_peer_tx_credits != -1)
- ni->ni_peertxcredits =
+ ni->ni_net->net_tunables.lct_peer_tx_credits =
conf->cfg_config_u.cfg_net.net_peer_tx_credits;
if (conf->cfg_config_u.cfg_net.net_max_tx_credits >= 0)
- ni->ni_maxtxcredits =
+ ni->ni_net->net_tunables.lct_max_tx_credits =
conf->cfg_config_u.cfg_net.net_max_tx_credits;
}

@@ -1297,8 +1297,6 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
goto failed0;
}

- LASSERT(ni->ni_peertimeout <= 0 || lnd->lnd_query);
-
lnet_net_lock(LNET_LOCK_EX);
/* refcount for ln_nis */
lnet_ni_addref_locked(ni, 0);
@@ -1314,13 +1312,18 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
lnet_ni_addref(ni);
LASSERT(!the_lnet.ln_loni);
the_lnet.ln_loni = ni;
+ ni->ni_net->net_tunables.lct_peer_tx_credits = 0;
+ ni->ni_net->net_tunables.lct_peer_rtr_credits = 0;
+ ni->ni_net->net_tunables.lct_max_tx_credits = 0;
+ ni->ni_net->net_tunables.lct_peer_timeout = 0;
return 0;
}

- if (!ni->ni_peertxcredits || !ni->ni_maxtxcredits) {
+ if (!ni->ni_net->net_tunables.lct_peer_tx_credits ||
+    !ni->ni_net->net_tunables.lct_max_tx_credits) {
LCONSOLE_ERROR_MSG(0x107, "LNI %s has no %scredits\n",
  libcfs_lnd2str(lnd->lnd_type),
-   !ni->ni_peertxcredits ?
+   !ni->ni_net->net_tunables.lct_peer_tx_credits ?
  "" : "per-peer ");
/*
* shutdown the NI since if we get here then it must've already
@@ -1343,9 +1346,11 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
add_device_randomness(&seed, sizeof(seed));

CDEBUG(D_LNI, "Added LNI %s [%d/%d/%d/%d]\n",
-       libcfs_nid2str(ni->ni_nid), ni->ni_peertxcredits,
+       libcfs_nid2str(ni->ni_nid),
+ ni->ni_net->net_tunables.lct_peer_tx_credits,
      lnet_ni_tq_credits(ni) * LNET_CPT_NUMBER,
-       ni->ni_peerrtrcredits, ni->ni_peertimeout);
+       ni->ni_net->net_tunables.lct_peer_rtr_credits,
+ ni->ni_net->net_tunables.lct_peer_timeout);

return 0;
failed0:
@@ -1667,10 +1672,14 @@ lnet_fill_ni_info(struct lnet_ni *ni, struct lnet_ioctl_config_data *config)
}

config->cfg_nid = ni->ni_nid;
- config->cfg_config_u.cfg_net.net_peer_timeout = ni->ni_peertimeout;
- config->cfg_config_u.cfg_net.net_max_tx_credits = ni->ni_maxtxcredits;
- config->cfg_config_u.cfg_net.net_peer_tx_credits = ni->ni_peertxcredits;
- config->cfg_config_u.cfg_net.net_peer_rtr_credits = ni->ni_peerrtrcredits;
+ config->cfg_config_u.cfg_net.net_peer_timeout =
+ ni->ni_net->net_tunables.lct_peer_timeout;
+ config->cfg_config_u.cfg_net.net_max_tx_credits =
+ ni->ni_net->net_tunables.lct_max_tx_credits;
+ config->cfg_config_u.cfg_net.net_peer_tx_credits =
+ ni->ni_net->net_tunables.lct_peer_tx_credits;
+ config->cfg_config_u.cfg_net.net_peer_rtr_credits =
+ ni->ni_net->net_tunables.lct_peer_rtr_credits;

net_config->ni_status = ni->ni_status->ns_status;

diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c
index 091c4f714e84..86a53854e427 100644
--- a/drivers/staging/lustre/lnet/lnet/config.c
+++ b/drivers/staging/lustre/lnet/lnet/config.c
@@ -114,29 +114,38 @@ lnet_ni_free(struct lnet_ni *ni)
if (ni->ni_net_ns)
put_net(ni->ni_net_ns);

+ kvfree(ni->ni_net);
kfree(ni);
}

struct lnet_ni *
-lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
+lnet_ni_alloc(__u32 net_id, struct cfs_expr_list *el, struct list_head *nilist)
{
struct lnet_tx_queue *tq;
struct lnet_ni *ni;
int rc;
int i;
+ struct lnet_net *net;

- if (!lnet_net_unique(net, nilist)) {
+ if (!lnet_net_unique(net_id, nilist)) {
LCONSOLE_ERROR_MSG(0x111, "Duplicate network specified: %s\n",
-   libcfs_net2str(net));
+   libcfs_net2str(net_id));
return NULL;
}

ni = kzalloc(sizeof(*ni), GFP_NOFS);
- if (!ni) {
+ net = kzalloc(sizeof(*net), GFP_NOFS);
+ if (!ni || !net) {
+ kfree(ni); kfree(net);
CERROR("Out of memory creating network %s\n",
-       libcfs_net2str(net));
+       libcfs_net2str(net_id));
return NULL;
}
+ /* initialize global paramters to undefiend */
+ net->net_tunables.lct_peer_timeout = -1;
+ net->net_tunables.lct_max_tx_credits = -1;
+ net->net_tunables.lct_peer_tx_credits = -1;
+ net->net_tunables.lct_peer_rtr_credits = -1;

spin_lock_init(&ni->ni_lock);
INIT_LIST_HEAD(&ni->ni_cptlist);
@@ -160,7 +169,7 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
rc = cfs_expr_list_values(el, LNET_CPT_NUMBER, &ni->ni_cpts);
if (rc <= 0) {
CERROR("Failed to set CPTs for NI %s: %d\n",
-       libcfs_net2str(net), rc);
+       libcfs_net2str(net_id), rc);
goto failed;
}

@@ -173,8 +182,9 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
ni->ni_ncpts = rc;
}

+ ni->ni_net = net;
/* LND will fill in the address part of the NID */
- ni->ni_nid = LNET_MKNID(net, 0);
+ ni->ni_nid = LNET_MKNID(net_id, 0);

/* Store net namespace in which current ni is being created */
if (current->nsproxy->net_ns)
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index edcafac055ed..f186e6a16d34 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -524,7 +524,8 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
   lp->lp_timestamp >= lp->lp_last_alive)
return 0;

- deadline = lp->lp_last_alive + lp->lp_ni->ni_peertimeout;
+ deadline = lp->lp_last_alive +
+ lp->lp_ni->ni_net->net_tunables.lct_peer_timeout;
alive = deadline > now;

/* Update obsolete lp_alive except for routers assumed to be dead
@@ -569,7 +570,7 @@ lnet_peer_alive_locked(struct lnet_peer *lp)
     libcfs_nid2str(lp->lp_nid),
     now, next_query,
     lnet_queryinterval,
-      lp->lp_ni->ni_peertimeout);
+      lp->lp_ni->ni_net->net_tunables.lct_peer_timeout);
return 0;
}
}
diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
index d9452c322e4d..b76ac3e051d9 100644
--- a/drivers/staging/lustre/lnet/lnet/peer.c
+++ b/drivers/staging/lustre/lnet/lnet/peer.c
@@ -342,8 +342,8 @@ lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt)
goto out;
}

- lp->lp_txcredits = lp->lp_ni->ni_peertxcredits;
- lp->lp_mintxcredits = lp->lp_ni->ni_peertxcredits;
+ lp->lp_txcredits = lp->lp_ni->ni_net->net_tunables.lct_peer_tx_credits;
+ lp->lp_mintxcredits = lp->lp_ni->ni_net->net_tunables.lct_peer_tx_credits;
lp->lp_rtrcredits = lnet_peer_buffer_credits(lp->lp_ni);
lp->lp_minrtrcredits = lnet_peer_buffer_credits(lp->lp_ni);

@@ -383,7 +383,7 @@ lnet_debug_peer(lnet_nid_t nid)

CDEBUG(D_WARNING, "%-24s %4d %5s %5d %5d %5d %5d %5d %ld\n",
      libcfs_nid2str(lp->lp_nid), lp->lp_refcount,
-       aliveness, lp->lp_ni->ni_peertxcredits,
+       aliveness, lp->lp_ni->ni_net->net_tunables.lct_peer_tx_credits,
      lp->lp_rtrcredits, lp->lp_minrtrcredits,
      lp->lp_txcredits, lp->lp_mintxcredits, lp->lp_txqnob);

@@ -438,7 +438,8 @@ lnet_get_peer_info(__u32 peer_index, __u64 *nid,

*nid = lp->lp_nid;
*refcount = lp->lp_refcount;
- *ni_peer_tx_credits = lp->lp_ni->ni_peertxcredits;
+ *ni_peer_tx_credits =
+ lp->lp_ni->ni_net->net_tunables.lct_peer_tx_credits;
*peer_tx_credits = lp->lp_txcredits;
*peer_rtr_credits = lp->lp_rtrcredits;
*peer_min_rtr_credits = lp->lp_mintxcredits;
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index 02241fbc9eaa..7d61c5d71426 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -57,9 +57,11 @@ MODULE_PARM_DESC(auto_down, "Automatically mark peers down on comms error");
int
lnet_peer_buffer_credits(struct lnet_ni *ni)
{
+ struct lnet_net *net = ni->ni_net;
+
/* NI option overrides LNet default */
- if (ni->ni_peerrtrcredits > 0)
- return ni->ni_peerrtrcredits;
+ if (net->net_tunables.lct_peer_rtr_credits > 0)
+ return net->net_tunables.lct_peer_rtr_credits;
if (peer_buffer_credits > 0)
return peer_buffer_credits;

@@ -67,7 +69,7 @@ lnet_peer_buffer_credits(struct lnet_ni *ni)
* As an approximation, allow this peer the same number of router
* buffers as it is allowed outstanding sends
*/
- return ni->ni_peertxcredits;
+ return net->net_tunables.lct_peer_tx_credits;
}

/* forward ref's */
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
index 31f4982f7f17..19cea7076057 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -489,7 +489,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
int nrefs = peer->lp_refcount;
time64_t lastalive = -1;
char *aliveness = "NA";
- int maxcr = peer->lp_ni->ni_peertxcredits;
+ int maxcr = peer->lp_ni->ni_net->net_tunables.lct_peer_tx_credits;
int txcr = peer->lp_txcredits;
int mintxcr = peer->lp_mintxcredits;
int rtrcr = peer->lp_rtrcredits;
@@ -704,8 +704,8 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
     "%-24s %6s %5lld %4d %4d %4d %5d %5d %5d\n",
     libcfs_nid2str(ni->ni_nid), stat,
     last_alive, *ni->ni_refs[i],
-      ni->ni_peertxcredits,
-      ni->ni_peerrtrcredits,
+      ni->ni_net->net_tunables.lct_peer_tx_credits,
+      ni->ni_net->net_tunables.lct_peer_rtr_credits,
     tq->tq_credits_max,
     tq->tq_credits,
     tq->tq_credits_min);
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Reviewed-by: Doug Oucharek &lt;<a href="mailto:dougso@me.com" class="">dougso@me.com</a>&gt;
<div class=""><br class="">
</div>
<div class="">Doug</div>
<div class=""><br class="">
<div style="">
<blockquote type="cite" class="">
<div class="">On Sep 6, 2018, at 5:49 PM, NeilBrown &lt;<a href="mailto:neilb@suse.com" class="">neilb@suse.com</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">This will contain some fields from lnet_ni, to be shared<br class="">
between multiple ni on the one network.<br class="">
<br class="">
For now, only tunables are moved across, using<br class="">
struct lnet_ioctl_config_lnd_cmn_tunables<br class="">
which is changed to use signed values so -1 can be stored.<br class="">
-1 means &quot;no value&quot;<br class="">
If the tunables haven't been initialised, then net_tunables_set is<br class="">
false. &nbsp;Previously a NULL pointer had this meaning.<br class="">
<br class="">
A 'struct lnet_net' is allocated as part of lnet_ni_alloc(), and freed<br class="">
by lnet_ni_free().<br class="">
<br class="">
This is part of<br class="">
&nbsp;&nbsp;&nbsp;8cbb8cd3e771e7f7e0f99cafc19fad32770dc015<br class="">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LU-7734 lnet: Multi-Rail local NI split<br class="">
<br class="">
Signed-off-by: NeilBrown &lt;<a href="mailto:neilb@suse.com" class="">neilb@suse.com</a>&gt;<br class="">
---<br class="">
.../staging/lustre/include/linux/lnet/lib-types.h &nbsp;| &nbsp;&nbsp;25 &#43;&#43;&#43;&#43;&#43;&#43;--<br class="">
.../lustre/include/uapi/linux/lnet/lnet-dlc.h &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;8 &#43;--<br class="">
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c &nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;2 -<br class="">
.../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c &nbsp;| &nbsp;&nbsp;61 &#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;---------<br class="">
.../staging/lustre/lnet/klnds/socklnd/socklnd.c &nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;19 &#43;&#43;&#43;&#43;--<br class="">
drivers/staging/lustre/lnet/lnet/api-ni.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;45 &#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;------<br class="">
drivers/staging/lustre/lnet/lnet/config.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;24 &#43;&#43;&#43;&#43;&#43;&#43;--<br class="">
drivers/staging/lustre/lnet/lnet/lib-move.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;5 &#43;-<br class="">
drivers/staging/lustre/lnet/lnet/peer.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;9 &#43;&#43;-<br class="">
drivers/staging/lustre/lnet/lnet/router.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;8 &#43;&#43;-<br class="">
drivers/staging/lustre/lnet/lnet/router_proc.c &nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;6 &#43;-<br class="">
11 files changed, 129 insertions(&#43;), 83 deletions(-)<br class="">
<br class="">
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h<br class="">
index 078bc97a9ebf..ead8a4e1125a 100644<br class="">
--- a/drivers/staging/lustre/include/linux/lnet/lib-types.h<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/include/linux/lnet/lib-types.h<br class="">
@@ -43,6 &#43;43,7 @@<br class="">
<br class="">
#include &lt;uapi/linux/lnet/lnet-types.h&gt;<br class="">
#include &lt;uapi/linux/lnet/lnetctl.h&gt;<br class="">
&#43;#include &lt;uapi/linux/lnet/lnet-dlc.h&gt;<br class="">
<br class="">
/* Max payload size */<br class="">
#define LNET_MAX_PAYLOAD &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CONFIG_LNET_MAX_PAYLOAD<br class="">
@@ -252,17 &#43;253,22 @@ struct lnet_tx_queue {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct list_head<span class="Apple-tab-span" style="white-space:pre">
</span>tq_delayed;<span class="Apple-tab-span" style="white-space:pre"> </span>/* delayed TXs */<br class="">
};<br class="">
<br class="">
&#43;struct lnet_net {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>/* network tunables */<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>struct lnet_ioctl_config_lnd_cmn_tunables net_tunables;<br class="">
&#43;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>/*<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>* boolean to indicate that the tunables have been set and<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>* shouldn't be reset<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>*/<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>bool<span class="Apple-tab-span" style="white-space:pre">
</span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;net_tunables_set;<br class="">
&#43;};<br class="">
&#43;<br class="">
struct lnet_ni {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>spinlock_t<span class="Apple-tab-span" style="white-space:pre">
</span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;ni_lock;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct list_head<span class="Apple-tab-span" style="white-space:pre">
</span>&nbsp;ni_list;<span class="Apple-tab-span" style="white-space:pre"> </span>/* chain on ln_nis */<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct list_head<span class="Apple-tab-span" style="white-space:pre">
</span>&nbsp;ni_cptlist;<span class="Apple-tab-span" style="white-space:pre"> </span>/* chain on ln_nis_cpt */<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>int<span class="Apple-tab-span" style="white-space:pre">
</span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;ni_maxtxcredits; /* # tx credits &nbsp;*/<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>/* # per-peer send credits */<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>int<span class="Apple-tab-span" style="white-space:pre">
</span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;ni_peertxcredits;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>/* # per-peer router buffer credits */<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>int<span class="Apple-tab-span" style="white-space:pre">
</span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;ni_peerrtrcredits;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>/* seconds to consider peer dead */<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>int<span class="Apple-tab-span" style="white-space:pre">
</span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;ni_peertimeout;<br class="">
&#43;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* number of CPTs */<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>int<span class="Apple-tab-span" style="white-space:pre">
</span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>ni_ncpts;<br class="">
<br class="">
@@ -286,6 &#43;292,9 @@ struct lnet_ni {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* when I was last alive */<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>time64_t<span class="Apple-tab-span" style="white-space:pre">
</span><span class="Apple-tab-span" style="white-space:pre"></span>ni_last_alive;<br class="">
<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>/* pointer to parent network */<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>struct lnet_net<span class="Apple-tab-span" style="white-space:pre">
</span><span class="Apple-tab-span" style="white-space:pre"></span>*ni_net;<br class="">
&#43;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* my health status */<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_ni_status<span class="Apple-tab-span" style="white-space:pre">
</span>*ni_status;<br class="">
<br class="">
@@ -397,7 &#43;406,7 @@ struct lnet_peer_table {<br class="">
&nbsp;* lnet_ni::ni_peertimeout has been set to a positive value<br class="">
&nbsp;*/<br class="">
#define lnet_peer_aliveness_enabled(lp) (the_lnet.ln_routing &amp;&amp; \<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>(lp)-&gt;lp_ni-&gt;ni_peertimeout
 &gt; 0)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>(lp)-&gt;lp_ni-&gt;ni_net-&gt;net_tunables.lct_peer_timeout
 &gt; 0)<br class="">
<br class="">
struct lnet_route {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct list_head<span class="Apple-tab-span" style="white-space:pre">
</span>lr_list;<span class="Apple-tab-span" style="white-space:pre"> </span>/* chain on net */<br class="">
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h<br class="">
index c1619f411d81..a8eb3b8f9fd7 100644<br class="">
--- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h<br class="">
@@ -39,10 &#43;39,10 @@<br class="">
<br class="">
struct lnet_ioctl_config_lnd_cmn_tunables {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>__u32 lct_version;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>__u32 lct_peer_timeout;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>__u32 lct_peer_tx_credits;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>__u32 lct_peer_rtr_credits;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>__u32 lct_max_tx_credits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>__s32 lct_peer_timeout;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>__s32 lct_peer_tx_credits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>__s32 lct_peer_rtr_credits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>__s32 lct_max_tx_credits;<br class="">
};<br class="">
<br class="">
struct lnet_ioctl_config_o2iblnd_tunables {<br class="">
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c<br class="">
index f496e6fcc416..0d17e22c4401 100644<br class="">
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c<br class="">
@@ -337,7 &#43;337,7 @@ int kiblnd_create_peer(struct lnet_ni *ni, struct kib_peer **peerp,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>peer-&gt;ibp_error = 0;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>peer-&gt;ibp_last_alive = 0;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>peer-&gt;ibp_max_frags = kiblnd_cfg_rdma_frags(peer-&gt;ibp_ni);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>peer-&gt;ibp_queue_depth = ni-&gt;ni_peertxcredits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>peer-&gt;ibp_queue_depth = ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>atomic_set(&amp;peer-&gt;ibp_refcount, 1); &nbsp;/* 1 ref for caller */<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>INIT_LIST_HEAD(&amp;peer-&gt;ibp_list); &nbsp;&nbsp;&nbsp;&nbsp;/* not in the peer table yet */<br class="">
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c<br class="">
index 39d07926d603..a1aca4dda38f 100644<br class="">
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c<br class="">
@@ -171,7 &#43;171,7 @@ int kiblnd_msg_queue_size(int version, struct lnet_ni *ni)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (version == IBLND_MSG_VERSION_1)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return IBLND_MSG_QUEUE_SIZE_V1;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>else if (ni)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>return ni-&gt;ni_peertxcredits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>return ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>else<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return peer_credits;<br class="">
}<br class="">
@@ -179,6 &#43;179,7 @@ int kiblnd_msg_queue_size(int version, struct lnet_ni *ni)<br class="">
int kiblnd_tunables_setup(struct lnet_ni *ni)<br class="">
{<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_ioctl_config_o2iblnd_tunables *tunables;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>struct lnet_ioctl_config_lnd_cmn_tunables *net_tunables;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/*<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* if there was no tunables specified, setup the tunables to be<br class="">
@@ -204,35 &#43;205,39 @@ int kiblnd_tunables_setup(struct lnet_ni *ni)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return -EINVAL;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (!ni-&gt;ni_peertimeout)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_peertimeout = peer_timeout;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>net_tunables = &amp;ni-&gt;ni_net-&gt;net_tunables;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (!ni-&gt;ni_maxtxcredits)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_maxtxcredits = credits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (net_tunables-&gt;lct_peer_timeout == -1)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>net_tunables-&gt;lct_peer_timeout = peer_timeout;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (!ni-&gt;ni_peertxcredits)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_peertxcredits = peer_credits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (net_tunables-&gt;lct_max_tx_credits == -1)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>net_tunables-&gt;lct_max_tx_credits = credits;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (!ni-&gt;ni_peerrtrcredits)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_peerrtrcredits = peer_buffer_credits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (net_tunables-&gt;lct_peer_tx_credits == -1)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>net_tunables-&gt;lct_peer_tx_credits = peer_credits;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (ni-&gt;ni_peertxcredits &lt; IBLND_CREDITS_DEFAULT)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_peertxcredits = IBLND_CREDITS_DEFAULT;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (net_tunables-&gt;lct_peer_rtr_credits == -1)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>net_tunables-&gt;lct_peer_rtr_credits = peer_buffer_credits;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (ni-&gt;ni_peertxcredits &gt; IBLND_CREDITS_MAX)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_peertxcredits = IBLND_CREDITS_MAX;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (net_tunables-&gt;lct_peer_tx_credits &lt; IBLND_CREDITS_DEFAULT)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>net_tunables-&gt;lct_peer_tx_credits = IBLND_CREDITS_DEFAULT;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (ni-&gt;ni_peertxcredits &gt; credits)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_peertxcredits = credits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (net_tunables-&gt;lct_peer_tx_credits &gt; IBLND_CREDITS_MAX)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>net_tunables-&gt;lct_peer_tx_credits = IBLND_CREDITS_MAX;<br class="">
&#43;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (net_tunables-&gt;lct_peer_tx_credits &gt;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>&nbsp;&nbsp;&nbsp;net_tunables-&gt;lct_max_tx_credits)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>net_tunables-&gt;lct_peer_tx_credits =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>net_tunables-&gt;lct_max_tx_credits;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (!tunables-&gt;lnd_peercredits_hiw)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>tunables-&gt;lnd_peercredits_hiw = peer_credits_hiw;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (tunables-&gt;lnd_peercredits_hiw &lt; ni-&gt;ni_peertxcredits / 2)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>tunables-&gt;lnd_peercredits_hiw = ni-&gt;ni_peertxcredits / 2;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (tunables-&gt;lnd_peercredits_hiw &lt; net_tunables-&gt;lct_peer_tx_credits / 2)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>tunables-&gt;lnd_peercredits_hiw = net_tunables-&gt;lct_peer_tx_credits / 2;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (tunables-&gt;lnd_peercredits_hiw &gt;= ni-&gt;ni_peertxcredits)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>tunables-&gt;lnd_peercredits_hiw = ni-&gt;ni_peertxcredits - 1;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (tunables-&gt;lnd_peercredits_hiw &gt;= net_tunables-&gt;lct_peer_tx_credits)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>tunables-&gt;lnd_peercredits_hiw = net_tunables-&gt;lct_peer_tx_credits - 1;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (tunables-&gt;lnd_map_on_demand &lt;= 0 ||<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;tunables-&gt;lnd_map_on_demand &gt; IBLND_MAX_RDMA_FRAGS) {<br class="">
@@ -252,21 &#43;257,23 @@ int kiblnd_tunables_setup(struct lnet_ni *ni)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>if (tunables-&gt;lnd_map_on_demand &gt; 0 &amp;&amp;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;tunables-&gt;lnd_map_on_demand &lt;= IBLND_MAX_RDMA_FRAGS / 8) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>tunables-&gt;lnd_concurrent_sends =<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_peertxcredits
 * 2;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>net_tunables-&gt;lct_peer_tx_credits
 * 2;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>} else {<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>tunables-&gt;lnd_concurrent_sends = ni-&gt;ni_peertxcredits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>tunables-&gt;lnd_concurrent_sends =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>net_tunables-&gt;lct_peer_tx_credits;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (tunables-&gt;lnd_concurrent_sends &gt; ni-&gt;ni_peertxcredits * 2)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>tunables-&gt;lnd_concurrent_sends = ni-&gt;ni_peertxcredits * 2;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (tunables-&gt;lnd_concurrent_sends &gt; net_tunables-&gt;lct_peer_tx_credits * 2)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>tunables-&gt;lnd_concurrent_sends = net_tunables-&gt;lct_peer_tx_credits * 2;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (tunables-&gt;lnd_concurrent_sends &lt; ni-&gt;ni_peertxcredits / 2)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>tunables-&gt;lnd_concurrent_sends = ni-&gt;ni_peertxcredits / 2;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (tunables-&gt;lnd_concurrent_sends &lt; net_tunables-&gt;lct_peer_tx_credits / 2)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>tunables-&gt;lnd_concurrent_sends = net_tunables-&gt;lct_peer_tx_credits / 2;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (tunables-&gt;lnd_concurrent_sends &lt; ni-&gt;ni_peertxcredits) {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (tunables-&gt;lnd_concurrent_sends &lt; net_tunables-&gt;lct_peer_tx_credits) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>CWARN(&quot;Concurrent sends %d is lower than message queue size: %d, performance may drop slightly.\n&quot;,<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tunables-&gt;lnd_concurrent_sends, ni-&gt;ni_peertxcredits);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tunables-&gt;lnd_concurrent_sends,<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;net_tunables-&gt;lct_peer_tx_credits);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (!tunables-&gt;lnd_fmr_pool_size)<br class="">
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c<br class="">
index 4dde158451ea..4ad885f10235 100644<br class="">
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c<br class="">
@@ -2739,12 &#43;2739,19 @@ ksocknal_startup(struct lnet_ni *ni)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>goto fail_0;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>spin_lock_init(&amp;net-&gt;ksnn_lock);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>net-&gt;ksnn_incarnation = ktime_get_real_ns();<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>ni-&gt;ni_data = net;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>ni-&gt;ni_peertimeout &nbsp;&nbsp;&nbsp;= *ksocknal_tunables.ksnd_peertimeout;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>ni-&gt;ni_maxtxcredits &nbsp;&nbsp;= *ksocknal_tunables.ksnd_credits;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>ni-&gt;ni_peertxcredits &nbsp;= *ksocknal_tunables.ksnd_peertxcredits;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>ni-&gt;ni_peerrtrcredits = *ksocknal_tunables.ksnd_peerrtrcredits;<br class="">
&#43; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;net-&gt;ksnn_incarnation = ktime_get_real_ns();<br class="">
&#43; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ni-&gt;ni_data = net;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (!ni-&gt;ni_net-&gt;net_tunables_set) {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_peer_timeout =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>*ksocknal_tunables.ksnd_peertimeout;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_max_tx_credits =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>*ksocknal_tunables.ksnd_credits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>*ksocknal_tunables.ksnd_peertxcredits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_peer_rtr_credits =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>*ksocknal_tunables.ksnd_peerrtrcredits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables_set = true;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>}<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>net-&gt;ksnn_ninterfaces = 0;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (!ni-&gt;ni_interfaces[0]) {<br class="">
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c<br class="">
index f9fcce2a5643..cd4189fa7acb 100644<br class="">
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/lnet/api-ni.c<br class="">
@@ -1036,11 &#43;1036,11 @@ lnet_ni_tq_credits(struct lnet_ni *ni)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>LASSERT(ni-&gt;ni_ncpts &gt;= 1);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (ni-&gt;ni_ncpts == 1)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>return ni-&gt;ni_maxtxcredits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>return ni-&gt;ni_net-&gt;net_tunables.lct_max_tx_credits;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>credits = ni-&gt;ni_maxtxcredits / ni-&gt;ni_ncpts;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>credits = max(credits, 8 * ni-&gt;ni_peertxcredits);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>credits = min(credits, ni-&gt;ni_maxtxcredits);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>credits = ni-&gt;ni_net-&gt;net_tunables.lct_max_tx_credits / ni-&gt;ni_ncpts;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>credits = max(credits, 8 * ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>credits = min(credits, ni-&gt;ni_net-&gt;net_tunables.lct_max_tx_credits);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>return credits;<br class="">
}<br class="">
@@ -1271,16 &#43;1271,16 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>*/<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (conf) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>if (conf-&gt;cfg_config_u.cfg_net.net_peer_rtr_credits &gt;= 0)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_peerrtrcredits =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_peer_rtr_credits =<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>conf-&gt;cfg_config_u.cfg_net.net_peer_rtr_credits;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>if (conf-&gt;cfg_config_u.cfg_net.net_peer_timeout &gt;= 0)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_peertimeout =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_peer_timeout =<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>conf-&gt;cfg_config_u.cfg_net.net_peer_timeout;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>if (conf-&gt;cfg_config_u.cfg_net.net_peer_tx_credits != -1)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_peertxcredits =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits =<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>conf-&gt;cfg_config_u.cfg_net.net_peer_tx_credits;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>if (conf-&gt;cfg_config_u.cfg_net.net_max_tx_credits &gt;= 0)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_maxtxcredits =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_max_tx_credits =<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>conf-&gt;cfg_config_u.cfg_net.net_max_tx_credits;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<br class="">
@@ -1297,8 &#43;1297,6 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>goto failed0;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>LASSERT(ni-&gt;ni_peertimeout &lt;= 0 || lnd-&gt;lnd_query);<br class="">
-<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>lnet_net_lock(LNET_LOCK_EX);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* refcount for ln_nis */<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>lnet_ni_addref_locked(ni, 0);<br class="">
@@ -1314,13 &#43;1312,18 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>lnet_ni_addref(ni);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>LASSERT(!the_lnet.ln_loni);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>the_lnet.ln_loni = ni;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits = 0;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_peer_rtr_credits = 0;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_max_tx_credits = 0;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_peer_timeout = 0;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return 0;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (!ni-&gt;ni_peertxcredits || !ni-&gt;ni_maxtxcredits) {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (!ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits ||<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>&nbsp;&nbsp;&nbsp;!ni-&gt;ni_net-&gt;net_tunables.lct_max_tx_credits) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>LCONSOLE_ERROR_MSG(0x107, &quot;LNI %s has no %scredits\n&quot;,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;libcfs_lnd2str(lnd-&gt;lnd_type),<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;!ni-&gt;ni_peertxcredits
 ?<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;!ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits
 ?<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&quot;&quot; : &quot;per-peer
 &quot;);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>/*<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>* shutdown the NI since if we get here then it must've already<br class="">
@@ -1343,9 &#43;1346,11 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>add_device_randomness(&amp;seed, sizeof(seed));<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>CDEBUG(D_LNI, &quot;Added LNI %s [%d/%d/%d/%d]\n&quot;,<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libcfs_nid2str(ni-&gt;ni_nid), ni-&gt;ni_peertxcredits,<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libcfs_nid2str(ni-&gt;ni_nid),<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lnet_ni_tq_credits(ni) * LNET_CPT_NUMBER,<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ni-&gt;ni_peerrtrcredits, ni-&gt;ni_peertimeout);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ni-&gt;ni_net-&gt;net_tunables.lct_peer_rtr_credits,<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_peer_timeout);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>return 0;<br class="">
failed0:<br class="">
@@ -1667,10 &#43;1672,14 @@ lnet_fill_ni_info(struct lnet_ni *ni, struct lnet_ioctl_config_data *config)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>config-&gt;cfg_nid = ni-&gt;ni_nid;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>config-&gt;cfg_config_u.cfg_net.net_peer_timeout = ni-&gt;ni_peertimeout;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>config-&gt;cfg_config_u.cfg_net.net_max_tx_credits = ni-&gt;ni_maxtxcredits;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>config-&gt;cfg_config_u.cfg_net.net_peer_tx_credits = ni-&gt;ni_peertxcredits;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>config-&gt;cfg_config_u.cfg_net.net_peer_rtr_credits = ni-&gt;ni_peerrtrcredits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>config-&gt;cfg_config_u.cfg_net.net_peer_timeout =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_peer_timeout;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>config-&gt;cfg_config_u.cfg_net.net_max_tx_credits =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_max_tx_credits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>config-&gt;cfg_config_u.cfg_net.net_peer_tx_credits =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>config-&gt;cfg_config_u.cfg_net.net_peer_rtr_credits =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_net-&gt;net_tunables.lct_peer_rtr_credits;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>net_config-&gt;ni_status = ni-&gt;ni_status-&gt;ns_status;<br class="">
<br class="">
diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c<br class="">
index 091c4f714e84..86a53854e427 100644<br class="">
--- a/drivers/staging/lustre/lnet/lnet/config.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/lnet/config.c<br class="">
@@ -114,29 &#43;114,38 @@ lnet_ni_free(struct lnet_ni *ni)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (ni-&gt;ni_net_ns)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>put_net(ni-&gt;ni_net_ns);<br class="">
<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>kvfree(ni-&gt;ni_net);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>kfree(ni);<br class="">
}<br class="">
<br class="">
struct lnet_ni *<br class="">
-lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)<br class="">
&#43;lnet_ni_alloc(__u32 net_id, struct cfs_expr_list *el, struct list_head *nilist)<br class="">
{<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_tx_queue *tq;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>struct lnet_ni *ni;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>int rc;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>int i;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>struct lnet_net<span class="Apple-tab-span" style="white-space:pre">
</span><span class="Apple-tab-span" style="white-space:pre"></span>*net;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (!lnet_net_unique(net, nilist)) {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (!lnet_net_unique(net_id, nilist)) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>LCONSOLE_ERROR_MSG(0x111, &quot;Duplicate network specified: %s\n&quot;,<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;libcfs_net2str(net));<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;libcfs_net2str(net_id));<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return NULL;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>ni = kzalloc(sizeof(*ni), GFP_NOFS);<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (!ni) {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>net = kzalloc(sizeof(*net), GFP_NOFS);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (!ni || !net) {<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>kfree(ni); kfree(net);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>CERROR(&quot;Out of memory creating network %s\n&quot;,<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libcfs_net2str(net));<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libcfs_net2str(net_id));<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return NULL;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>/* initialize global paramters to undefiend */<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>net-&gt;net_tunables.lct_peer_timeout = -1;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>net-&gt;net_tunables.lct_max_tx_credits = -1;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>net-&gt;net_tunables.lct_peer_tx_credits = -1;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>net-&gt;net_tunables.lct_peer_rtr_credits = -1;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>spin_lock_init(&amp;ni-&gt;ni_lock);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>INIT_LIST_HEAD(&amp;ni-&gt;ni_cptlist);<br class="">
@@ -160,7 &#43;169,7 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>rc = cfs_expr_list_values(el, LNET_CPT_NUMBER, &amp;ni-&gt;ni_cpts);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>if (rc &lt;= 0) {<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>CERROR(&quot;Failed to set CPTs for NI %s: %d\n&quot;,<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libcfs_net2str(net), rc);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libcfs_net2str(net_id), rc);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>goto failed;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<br class="">
@@ -173,8 &#43;182,9 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>ni-&gt;ni_ncpts = rc;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>ni-&gt;ni_net = net;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* LND will fill in the address part of the NID */<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>ni-&gt;ni_nid = LNET_MKNID(net, 0);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>ni-&gt;ni_nid = LNET_MKNID(net_id, 0);<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* Store net namespace in which current ni is being created */<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (current-&gt;nsproxy-&gt;net_ns)<br class="">
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c<br class="">
index edcafac055ed..f186e6a16d34 100644<br class="">
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/lnet/lib-move.c<br class="">
@@ -524,7 &#43;524,8 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;lp-&gt;lp_timestamp &gt;= lp-&gt;lp_last_alive)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return 0;<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>deadline = lp-&gt;lp_last_alive &#43; lp-&gt;lp_ni-&gt;ni_peertimeout;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>deadline = lp-&gt;lp_last_alive &#43;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>lp-&gt;lp_ni-&gt;ni_net-&gt;net_tunables.lct_peer_timeout;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>alive = deadline &gt; now;<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* Update obsolete lp_alive except for routers assumed to be dead<br class="">
@@ -569,7 &#43;570,7 @@ lnet_peer_alive_locked(struct lnet_peer *lp)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libcfs_nid2str(lp-&gt;lp_nid),<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;now, next_query,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lnet_queryinterval,<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lp-&gt;lp_ni-&gt;ni_peertimeout);<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lp-&gt;lp_ni-&gt;ni_net-&gt;net_tunables.lct_peer_timeout);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return 0;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c<br class="">
index d9452c322e4d..b76ac3e051d9 100644<br class="">
--- a/drivers/staging/lustre/lnet/lnet/peer.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/lnet/peer.c<br class="">
@@ -342,8 &#43;342,8 @@ lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>goto out;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>}<br class="">
<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>lp-&gt;lp_txcredits = lp-&gt;lp_ni-&gt;ni_peertxcredits;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>lp-&gt;lp_mintxcredits = lp-&gt;lp_ni-&gt;ni_peertxcredits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>lp-&gt;lp_txcredits = lp-&gt;lp_ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>lp-&gt;lp_mintxcredits = lp-&gt;lp_ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>lp-&gt;lp_rtrcredits = lnet_peer_buffer_credits(lp-&gt;lp_ni);<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>lp-&gt;lp_minrtrcredits = lnet_peer_buffer_credits(lp-&gt;lp_ni);<br class="">
<br class="">
@@ -383,7 &#43;383,7 @@ lnet_debug_peer(lnet_nid_t nid)<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>CDEBUG(D_WARNING, &quot;%-24s %4d %5s %5d %5d %5d %5d %5d %ld\n&quot;,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libcfs_nid2str(lp-&gt;lp_nid), lp-&gt;lp_refcount,<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aliveness, lp-&gt;lp_ni-&gt;ni_peertxcredits,<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aliveness, lp-&gt;lp_ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lp-&gt;lp_rtrcredits, lp-&gt;lp_minrtrcredits,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lp-&gt;lp_txcredits, lp-&gt;lp_mintxcredits, lp-&gt;lp_txqnob);<br class="">
<br class="">
@@ -438,7 &#43;438,8 @@ lnet_get_peer_info(__u32 peer_index, __u64 *nid,<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>*nid = lp-&gt;lp_nid;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>*refcount = lp-&gt;lp_refcount;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>*ni_peer_tx_credits = lp-&gt;lp_ni-&gt;ni_peertxcredits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>*ni_peer_tx_credits =<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>lp-&gt;lp_ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>*peer_tx_credits = lp-&gt;lp_txcredits;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>*peer_rtr_credits = lp-&gt;lp_rtrcredits;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>*peer_min_rtr_credits = lp-&gt;lp_mintxcredits;<br class="">
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c<br class="">
index 02241fbc9eaa..7d61c5d71426 100644<br class="">
--- a/drivers/staging/lustre/lnet/lnet/router.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/lnet/router.c<br class="">
@@ -57,9 &#43;57,11 @@ MODULE_PARM_DESC(auto_down, &quot;Automatically mark peers down on comms error&quot;);<br class="">
int<br class="">
lnet_peer_buffer_credits(struct lnet_ni *ni)<br class="">
{<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>struct lnet_net *net = ni-&gt;ni_net;<br class="">
&#43;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>/* NI option overrides LNet default */<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>if (ni-&gt;ni_peerrtrcredits &gt; 0)<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>return ni-&gt;ni_peerrtrcredits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if (net-&gt;net_tunables.lct_peer_rtr_credits &gt; 0)<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>return net-&gt;net_tunables.lct_peer_rtr_credits;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>if (peer_buffer_credits &gt; 0)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>return peer_buffer_credits;<br class="">
<br class="">
@@ -67,7 &#43;69,7 @@ lnet_peer_buffer_credits(struct lnet_ni *ni)<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* As an approximation, allow this peer the same number of router<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>* buffers as it is allowed outstanding sends<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span>*/<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span>return ni-&gt;ni_peertxcredits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>return net-&gt;net_tunables.lct_peer_tx_credits;<br class="">
}<br class="">
<br class="">
/* forward ref's */<br class="">
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c<br class="">
index 31f4982f7f17..19cea7076057 100644<br class="">
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c<br class="">
&#43;&#43;&#43; b/drivers/staging/lustre/lnet/lnet/router_proc.c<br class="">
@@ -489,7 &#43;489,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>int nrefs = peer-&gt;lp_refcount;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>time64_t lastalive = -1;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>char *aliveness = &quot;NA&quot;;<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>int maxcr = peer-&gt;lp_ni-&gt;ni_peertxcredits;<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>int maxcr = peer-&gt;lp_ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>int txcr = peer-&gt;lp_txcredits;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>int mintxcr = peer-&gt;lp_mintxcredits;<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>int rtrcr = peer-&gt;lp_rtrcredits;<br class="">
@@ -704,8 &#43;704,8 @@ static int proc_lnet_nis(struct ctl_table *table, int write,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;%-24s
 %6s %5lld %4d %4d %4d %5d %5d %5d\n&quot;,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libcfs_nid2str(ni-&gt;ni_nid),
 stat,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;last_alive,
 *ni-&gt;ni_refs[i],<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ni-&gt;ni_peertxcredits,<br class="">
-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ni-&gt;ni_peerrtrcredits,<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ni-&gt;ni_net-&gt;net_tunables.lct_peer_tx_credits,<br class="">
&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ni-&gt;ni_net-&gt;net_tunables.lct_peer_rtr_credits,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tq-&gt;tq_credits_max,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tq-&gt;tq_credits,<br class="">
<span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tq-&gt;tq_credits_min);<br class="">
<br class="">
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>
James Simmons Sept. 10, 2018, 11:23 p.m. UTC | #2
> This will contain some fields from lnet_ni, to be shared
> between multiple ni on the one network.
> 
> For now, only tunables are moved across, using
>  struct lnet_ioctl_config_lnd_cmn_tunables
> which is changed to use signed values so -1 can be stored.
> -1 means "no value"
> If the tunables haven't been initialised, then net_tunables_set is
> false.  Previously a NULL pointer had this meaning.
> 
> A 'struct lnet_net' is allocated as part of lnet_ni_alloc(), and freed
> by lnet_ni_free().

Acked-by: James Simmons <jsimmons@infradead.org>

The below needs fixing based on response to cover letter.

> This is part of
>     8cbb8cd3e771e7f7e0f99cafc19fad32770dc015
>        LU-7734 lnet: Multi-Rail local NI split
> 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/include/linux/lnet/lib-types.h  |   25 ++++++--
>  .../lustre/include/uapi/linux/lnet/lnet-dlc.h      |    8 +--
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    2 -
>  .../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c  |   61 +++++++++++---------
>  .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |   19 ++++--
>  drivers/staging/lustre/lnet/lnet/api-ni.c          |   45 +++++++++------
>  drivers/staging/lustre/lnet/lnet/config.c          |   24 ++++++--
>  drivers/staging/lustre/lnet/lnet/lib-move.c        |    5 +-
>  drivers/staging/lustre/lnet/lnet/peer.c            |    9 ++-
>  drivers/staging/lustre/lnet/lnet/router.c          |    8 ++-
>  drivers/staging/lustre/lnet/lnet/router_proc.c     |    6 +-
>  11 files changed, 129 insertions(+), 83 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h
> index 078bc97a9ebf..ead8a4e1125a 100644
> --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h
> +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h
> @@ -43,6 +43,7 @@
>  
>  #include <uapi/linux/lnet/lnet-types.h>
>  #include <uapi/linux/lnet/lnetctl.h>
> +#include <uapi/linux/lnet/lnet-dlc.h>
>  
>  /* Max payload size */
>  #define LNET_MAX_PAYLOAD      CONFIG_LNET_MAX_PAYLOAD
> @@ -252,17 +253,22 @@ struct lnet_tx_queue {
>  	struct list_head	tq_delayed;	/* delayed TXs */
>  };
>  
> +struct lnet_net {
> +	/* network tunables */
> +	struct lnet_ioctl_config_lnd_cmn_tunables net_tunables;
> +
> +	/*
> +	 * boolean to indicate that the tunables have been set and
> +	 * shouldn't be reset
> +	 */
> +	bool			  net_tunables_set;
> +};
> +
>  struct lnet_ni {
>  	spinlock_t		  ni_lock;
>  	struct list_head	  ni_list;	/* chain on ln_nis */
>  	struct list_head	  ni_cptlist;	/* chain on ln_nis_cpt */
> -	int			  ni_maxtxcredits; /* # tx credits  */
> -	/* # per-peer send credits */
> -	int			  ni_peertxcredits;
> -	/* # per-peer router buffer credits */
> -	int			  ni_peerrtrcredits;
> -	/* seconds to consider peer dead */
> -	int			  ni_peertimeout;
> +
>  	/* number of CPTs */
>  	int			ni_ncpts;
>  
> @@ -286,6 +292,9 @@ struct lnet_ni {
>  	/* when I was last alive */
>  	time64_t		ni_last_alive;
>  
> +	/* pointer to parent network */
> +	struct lnet_net		*ni_net;
> +
>  	/* my health status */
>  	struct lnet_ni_status	*ni_status;
>  
> @@ -397,7 +406,7 @@ struct lnet_peer_table {
>   * lnet_ni::ni_peertimeout has been set to a positive value
>   */
>  #define lnet_peer_aliveness_enabled(lp) (the_lnet.ln_routing && \
> -					 (lp)->lp_ni->ni_peertimeout > 0)
> +					 (lp)->lp_ni->ni_net->net_tunables.lct_peer_timeout > 0)
>  
>  struct lnet_route {
>  	struct list_head	 lr_list;	/* chain on net */
> diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
> index c1619f411d81..a8eb3b8f9fd7 100644
> --- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
> +++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
> @@ -39,10 +39,10 @@
>  
>  struct lnet_ioctl_config_lnd_cmn_tunables {
>  	__u32 lct_version;
> -	__u32 lct_peer_timeout;
> -	__u32 lct_peer_tx_credits;
> -	__u32 lct_peer_rtr_credits;
> -	__u32 lct_max_tx_credits;
> +	__s32 lct_peer_timeout;
> +	__s32 lct_peer_tx_credits;
> +	__s32 lct_peer_rtr_credits;
> +	__s32 lct_max_tx_credits;
>  };
>  
>  struct lnet_ioctl_config_o2iblnd_tunables {
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> index f496e6fcc416..0d17e22c4401 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> @@ -337,7 +337,7 @@ int kiblnd_create_peer(struct lnet_ni *ni, struct kib_peer **peerp,
>  	peer->ibp_error = 0;
>  	peer->ibp_last_alive = 0;
>  	peer->ibp_max_frags = kiblnd_cfg_rdma_frags(peer->ibp_ni);
> -	peer->ibp_queue_depth = ni->ni_peertxcredits;
> +	peer->ibp_queue_depth = ni->ni_net->net_tunables.lct_peer_tx_credits;
>  	atomic_set(&peer->ibp_refcount, 1);  /* 1 ref for caller */
>  
>  	INIT_LIST_HEAD(&peer->ibp_list);     /* not in the peer table yet */
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
> index 39d07926d603..a1aca4dda38f 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
> @@ -171,7 +171,7 @@ int 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;
>  }
> @@ -179,6 +179,7 @@ int kiblnd_msg_queue_size(int version, struct lnet_ni *ni)
>  int 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
> @@ -204,35 +205,39 @@ int kiblnd_tunables_setup(struct lnet_ni *ni)
>  		return -EINVAL;
>  	}
>  
> -	if (!ni->ni_peertimeout)
> -		ni->ni_peertimeout = peer_timeout;
> +	net_tunables = &ni->ni_net->net_tunables;
>  
> -	if (!ni->ni_maxtxcredits)
> -		ni->ni_maxtxcredits = credits;
> +	if (net_tunables->lct_peer_timeout == -1)
> +		net_tunables->lct_peer_timeout = peer_timeout;
>  
> -	if (!ni->ni_peertxcredits)
> -		ni->ni_peertxcredits = peer_credits;
> +	if (net_tunables->lct_max_tx_credits == -1)
> +		net_tunables->lct_max_tx_credits = credits;
>  
> -	if (!ni->ni_peerrtrcredits)
> -		ni->ni_peerrtrcredits = peer_buffer_credits;
> +	if (net_tunables->lct_peer_tx_credits == -1)
> +		net_tunables->lct_peer_tx_credits = peer_credits;
>  
> -	if (ni->ni_peertxcredits < IBLND_CREDITS_DEFAULT)
> -		ni->ni_peertxcredits = IBLND_CREDITS_DEFAULT;
> +	if (net_tunables->lct_peer_rtr_credits == -1)
> +		net_tunables->lct_peer_rtr_credits = peer_buffer_credits;
>  
> -	if (ni->ni_peertxcredits > IBLND_CREDITS_MAX)
> -		ni->ni_peertxcredits = IBLND_CREDITS_MAX;
> +	if (net_tunables->lct_peer_tx_credits < IBLND_CREDITS_DEFAULT)
> +		net_tunables->lct_peer_tx_credits = IBLND_CREDITS_DEFAULT;
>  
> -	if (ni->ni_peertxcredits > credits)
> -		ni->ni_peertxcredits = credits;
> +	if (net_tunables->lct_peer_tx_credits > IBLND_CREDITS_MAX)
> +		net_tunables->lct_peer_tx_credits = IBLND_CREDITS_MAX;
> +
> +	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 ||
>  	    tunables->lnd_map_on_demand > IBLND_MAX_RDMA_FRAGS) {
> @@ -252,21 +257,23 @@ int kiblnd_tunables_setup(struct lnet_ni *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)
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> index 4dde158451ea..4ad885f10235 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> @@ -2739,12 +2739,19 @@ ksocknal_startup(struct lnet_ni *ni)
>  		goto fail_0;
>  
>  	spin_lock_init(&net->ksnn_lock);
> -	net->ksnn_incarnation = ktime_get_real_ns();
> -	ni->ni_data = net;
> -	ni->ni_peertimeout    = *ksocknal_tunables.ksnd_peertimeout;
> -	ni->ni_maxtxcredits   = *ksocknal_tunables.ksnd_credits;
> -	ni->ni_peertxcredits  = *ksocknal_tunables.ksnd_peertxcredits;
> -	ni->ni_peerrtrcredits = *ksocknal_tunables.ksnd_peerrtrcredits;
> +        net->ksnn_incarnation = ktime_get_real_ns();
> +        ni->ni_data = net;
> +	if (!ni->ni_net->net_tunables_set) {
> +		ni->ni_net->net_tunables.lct_peer_timeout =
> +			*ksocknal_tunables.ksnd_peertimeout;
> +		ni->ni_net->net_tunables.lct_max_tx_credits =
> +			*ksocknal_tunables.ksnd_credits;
> +		ni->ni_net->net_tunables.lct_peer_tx_credits =
> +			*ksocknal_tunables.ksnd_peertxcredits;
> +		ni->ni_net->net_tunables.lct_peer_rtr_credits =
> +			*ksocknal_tunables.ksnd_peerrtrcredits;
> +		ni->ni_net->net_tunables_set = true;
> +	}
>  
>  	net->ksnn_ninterfaces = 0;
>  	if (!ni->ni_interfaces[0]) {
> diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
> index f9fcce2a5643..cd4189fa7acb 100644
> --- a/drivers/staging/lustre/lnet/lnet/api-ni.c
> +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
> @@ -1036,11 +1036,11 @@ lnet_ni_tq_credits(struct lnet_ni *ni)
>  	LASSERT(ni->ni_ncpts >= 1);
>  
>  	if (ni->ni_ncpts == 1)
> -		return ni->ni_maxtxcredits;
> +		return ni->ni_net->net_tunables.lct_max_tx_credits;
>  
> -	credits = ni->ni_maxtxcredits / ni->ni_ncpts;
> -	credits = max(credits, 8 * ni->ni_peertxcredits);
> -	credits = min(credits, ni->ni_maxtxcredits);
> +	credits = ni->ni_net->net_tunables.lct_max_tx_credits / ni->ni_ncpts;
> +	credits = max(credits, 8 * ni->ni_net->net_tunables.lct_peer_tx_credits);
> +	credits = min(credits, ni->ni_net->net_tunables.lct_max_tx_credits);
>  
>  	return credits;
>  }
> @@ -1271,16 +1271,16 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
>  	 */
>  	if (conf) {
>  		if (conf->cfg_config_u.cfg_net.net_peer_rtr_credits >= 0)
> -			ni->ni_peerrtrcredits =
> +			ni->ni_net->net_tunables.lct_peer_rtr_credits =
>  				conf->cfg_config_u.cfg_net.net_peer_rtr_credits;
>  		if (conf->cfg_config_u.cfg_net.net_peer_timeout >= 0)
> -			ni->ni_peertimeout =
> +			ni->ni_net->net_tunables.lct_peer_timeout =
>  				conf->cfg_config_u.cfg_net.net_peer_timeout;
>  		if (conf->cfg_config_u.cfg_net.net_peer_tx_credits != -1)
> -			ni->ni_peertxcredits =
> +			ni->ni_net->net_tunables.lct_peer_tx_credits =
>  				conf->cfg_config_u.cfg_net.net_peer_tx_credits;
>  		if (conf->cfg_config_u.cfg_net.net_max_tx_credits >= 0)
> -			ni->ni_maxtxcredits =
> +			ni->ni_net->net_tunables.lct_max_tx_credits =
>  				conf->cfg_config_u.cfg_net.net_max_tx_credits;
>  	}
>  
> @@ -1297,8 +1297,6 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
>  		goto failed0;
>  	}
>  
> -	LASSERT(ni->ni_peertimeout <= 0 || lnd->lnd_query);
> -
>  	lnet_net_lock(LNET_LOCK_EX);
>  	/* refcount for ln_nis */
>  	lnet_ni_addref_locked(ni, 0);
> @@ -1314,13 +1312,18 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
>  		lnet_ni_addref(ni);
>  		LASSERT(!the_lnet.ln_loni);
>  		the_lnet.ln_loni = ni;
> +		ni->ni_net->net_tunables.lct_peer_tx_credits = 0;
> +		ni->ni_net->net_tunables.lct_peer_rtr_credits = 0;
> +		ni->ni_net->net_tunables.lct_max_tx_credits = 0;
> +		ni->ni_net->net_tunables.lct_peer_timeout = 0;
>  		return 0;
>  	}
>  
> -	if (!ni->ni_peertxcredits || !ni->ni_maxtxcredits) {
> +	if (!ni->ni_net->net_tunables.lct_peer_tx_credits ||
> +	    !ni->ni_net->net_tunables.lct_max_tx_credits) {
>  		LCONSOLE_ERROR_MSG(0x107, "LNI %s has no %scredits\n",
>  				   libcfs_lnd2str(lnd->lnd_type),
> -				   !ni->ni_peertxcredits ?
> +				   !ni->ni_net->net_tunables.lct_peer_tx_credits ?
>  				   "" : "per-peer ");
>  		/*
>  		 * shutdown the NI since if we get here then it must've already
> @@ -1343,9 +1346,11 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
>  	add_device_randomness(&seed, sizeof(seed));
>  
>  	CDEBUG(D_LNI, "Added LNI %s [%d/%d/%d/%d]\n",
> -	       libcfs_nid2str(ni->ni_nid), ni->ni_peertxcredits,
> +	       libcfs_nid2str(ni->ni_nid),
> +		ni->ni_net->net_tunables.lct_peer_tx_credits,
>  	       lnet_ni_tq_credits(ni) * LNET_CPT_NUMBER,
> -	       ni->ni_peerrtrcredits, ni->ni_peertimeout);
> +	       ni->ni_net->net_tunables.lct_peer_rtr_credits,
> +		ni->ni_net->net_tunables.lct_peer_timeout);
>  
>  	return 0;
>  failed0:
> @@ -1667,10 +1672,14 @@ lnet_fill_ni_info(struct lnet_ni *ni, struct lnet_ioctl_config_data *config)
>  	}
>  
>  	config->cfg_nid = ni->ni_nid;
> -	config->cfg_config_u.cfg_net.net_peer_timeout = ni->ni_peertimeout;
> -	config->cfg_config_u.cfg_net.net_max_tx_credits = ni->ni_maxtxcredits;
> -	config->cfg_config_u.cfg_net.net_peer_tx_credits = ni->ni_peertxcredits;
> -	config->cfg_config_u.cfg_net.net_peer_rtr_credits = ni->ni_peerrtrcredits;
> +	config->cfg_config_u.cfg_net.net_peer_timeout =
> +		ni->ni_net->net_tunables.lct_peer_timeout;
> +	config->cfg_config_u.cfg_net.net_max_tx_credits =
> +		ni->ni_net->net_tunables.lct_max_tx_credits;
> +	config->cfg_config_u.cfg_net.net_peer_tx_credits =
> +		ni->ni_net->net_tunables.lct_peer_tx_credits;
> +	config->cfg_config_u.cfg_net.net_peer_rtr_credits =
> +		ni->ni_net->net_tunables.lct_peer_rtr_credits;
>  
>  	net_config->ni_status = ni->ni_status->ns_status;
>  
> diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c
> index 091c4f714e84..86a53854e427 100644
> --- a/drivers/staging/lustre/lnet/lnet/config.c
> +++ b/drivers/staging/lustre/lnet/lnet/config.c
> @@ -114,29 +114,38 @@ lnet_ni_free(struct lnet_ni *ni)
>  	if (ni->ni_net_ns)
>  		put_net(ni->ni_net_ns);
>  
> +	kvfree(ni->ni_net);
>  	kfree(ni);
>  }
>  
>  struct lnet_ni *
> -lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
> +lnet_ni_alloc(__u32 net_id, struct cfs_expr_list *el, struct list_head *nilist)
>  {
>  	struct lnet_tx_queue *tq;
>  	struct lnet_ni *ni;
>  	int rc;
>  	int i;
> +	struct lnet_net		*net;
>  
> -	if (!lnet_net_unique(net, nilist)) {
> +	if (!lnet_net_unique(net_id, nilist)) {
>  		LCONSOLE_ERROR_MSG(0x111, "Duplicate network specified: %s\n",
> -				   libcfs_net2str(net));
> +				   libcfs_net2str(net_id));
>  		return NULL;
>  	}
>  
>  	ni = kzalloc(sizeof(*ni), GFP_NOFS);
> -	if (!ni) {
> +	net = kzalloc(sizeof(*net), GFP_NOFS);
> +	if (!ni || !net) {
> +		kfree(ni); kfree(net);
>  		CERROR("Out of memory creating network %s\n",
> -		       libcfs_net2str(net));
> +		       libcfs_net2str(net_id));
>  		return NULL;
>  	}
> +	/* initialize global paramters to undefiend */
> +	net->net_tunables.lct_peer_timeout = -1;
> +	net->net_tunables.lct_max_tx_credits = -1;
> +	net->net_tunables.lct_peer_tx_credits = -1;
> +	net->net_tunables.lct_peer_rtr_credits = -1;
>  
>  	spin_lock_init(&ni->ni_lock);
>  	INIT_LIST_HEAD(&ni->ni_cptlist);
> @@ -160,7 +169,7 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
>  		rc = cfs_expr_list_values(el, LNET_CPT_NUMBER, &ni->ni_cpts);
>  		if (rc <= 0) {
>  			CERROR("Failed to set CPTs for NI %s: %d\n",
> -			       libcfs_net2str(net), rc);
> +			       libcfs_net2str(net_id), rc);
>  			goto failed;
>  		}
>  
> @@ -173,8 +182,9 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
>  		ni->ni_ncpts = rc;
>  	}
>  
> +	ni->ni_net = net;
>  	/* LND will fill in the address part of the NID */
> -	ni->ni_nid = LNET_MKNID(net, 0);
> +	ni->ni_nid = LNET_MKNID(net_id, 0);
>  
>  	/* Store net namespace in which current ni is being created */
>  	if (current->nsproxy->net_ns)
> diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
> index edcafac055ed..f186e6a16d34 100644
> --- a/drivers/staging/lustre/lnet/lnet/lib-move.c
> +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
> @@ -524,7 +524,8 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
>  	    lp->lp_timestamp >= lp->lp_last_alive)
>  		return 0;
>  
> -	deadline = lp->lp_last_alive + lp->lp_ni->ni_peertimeout;
> +	deadline = lp->lp_last_alive +
> +		lp->lp_ni->ni_net->net_tunables.lct_peer_timeout;
>  	alive = deadline > now;
>  
>  	/* Update obsolete lp_alive except for routers assumed to be dead
> @@ -569,7 +570,7 @@ lnet_peer_alive_locked(struct lnet_peer *lp)
>  				      libcfs_nid2str(lp->lp_nid),
>  				      now, next_query,
>  				      lnet_queryinterval,
> -				      lp->lp_ni->ni_peertimeout);
> +				      lp->lp_ni->ni_net->net_tunables.lct_peer_timeout);
>  			return 0;
>  		}
>  	}
> diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
> index d9452c322e4d..b76ac3e051d9 100644
> --- a/drivers/staging/lustre/lnet/lnet/peer.c
> +++ b/drivers/staging/lustre/lnet/lnet/peer.c
> @@ -342,8 +342,8 @@ lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt)
>  		goto out;
>  	}
>  
> -	lp->lp_txcredits = lp->lp_ni->ni_peertxcredits;
> -	lp->lp_mintxcredits = lp->lp_ni->ni_peertxcredits;
> +	lp->lp_txcredits = lp->lp_ni->ni_net->net_tunables.lct_peer_tx_credits;
> +	lp->lp_mintxcredits = lp->lp_ni->ni_net->net_tunables.lct_peer_tx_credits;
>  	lp->lp_rtrcredits = lnet_peer_buffer_credits(lp->lp_ni);
>  	lp->lp_minrtrcredits = lnet_peer_buffer_credits(lp->lp_ni);
>  
> @@ -383,7 +383,7 @@ lnet_debug_peer(lnet_nid_t nid)
>  
>  	CDEBUG(D_WARNING, "%-24s %4d %5s %5d %5d %5d %5d %5d %ld\n",
>  	       libcfs_nid2str(lp->lp_nid), lp->lp_refcount,
> -	       aliveness, lp->lp_ni->ni_peertxcredits,
> +	       aliveness, lp->lp_ni->ni_net->net_tunables.lct_peer_tx_credits,
>  	       lp->lp_rtrcredits, lp->lp_minrtrcredits,
>  	       lp->lp_txcredits, lp->lp_mintxcredits, lp->lp_txqnob);
>  
> @@ -438,7 +438,8 @@ lnet_get_peer_info(__u32 peer_index, __u64 *nid,
>  
>  			*nid = lp->lp_nid;
>  			*refcount = lp->lp_refcount;
> -			*ni_peer_tx_credits = lp->lp_ni->ni_peertxcredits;
> +			*ni_peer_tx_credits =
> +				lp->lp_ni->ni_net->net_tunables.lct_peer_tx_credits;
>  			*peer_tx_credits = lp->lp_txcredits;
>  			*peer_rtr_credits = lp->lp_rtrcredits;
>  			*peer_min_rtr_credits = lp->lp_mintxcredits;
> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
> index 02241fbc9eaa..7d61c5d71426 100644
> --- a/drivers/staging/lustre/lnet/lnet/router.c
> +++ b/drivers/staging/lustre/lnet/lnet/router.c
> @@ -57,9 +57,11 @@ MODULE_PARM_DESC(auto_down, "Automatically mark peers down on comms error");
>  int
>  lnet_peer_buffer_credits(struct lnet_ni *ni)
>  {
> +	struct lnet_net *net = ni->ni_net;
> +
>  	/* NI option overrides LNet default */
> -	if (ni->ni_peerrtrcredits > 0)
> -		return ni->ni_peerrtrcredits;
> +	if (net->net_tunables.lct_peer_rtr_credits > 0)
> +		return net->net_tunables.lct_peer_rtr_credits;
>  	if (peer_buffer_credits > 0)
>  		return peer_buffer_credits;
>  
> @@ -67,7 +69,7 @@ lnet_peer_buffer_credits(struct lnet_ni *ni)
>  	 * As an approximation, allow this peer the same number of router
>  	 * buffers as it is allowed outstanding sends
>  	 */
> -	return ni->ni_peertxcredits;
> +	return net->net_tunables.lct_peer_tx_credits;
>  }
>  
>  /* forward ref's */
> diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
> index 31f4982f7f17..19cea7076057 100644
> --- a/drivers/staging/lustre/lnet/lnet/router_proc.c
> +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
> @@ -489,7 +489,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
>  			int nrefs = peer->lp_refcount;
>  			time64_t lastalive = -1;
>  			char *aliveness = "NA";
> -			int maxcr = peer->lp_ni->ni_peertxcredits;
> +			int maxcr = peer->lp_ni->ni_net->net_tunables.lct_peer_tx_credits;
>  			int txcr = peer->lp_txcredits;
>  			int mintxcr = peer->lp_mintxcredits;
>  			int rtrcr = peer->lp_rtrcredits;
> @@ -704,8 +704,8 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
>  					      "%-24s %6s %5lld %4d %4d %4d %5d %5d %5d\n",
>  					      libcfs_nid2str(ni->ni_nid), stat,
>  					      last_alive, *ni->ni_refs[i],
> -					      ni->ni_peertxcredits,
> -					      ni->ni_peerrtrcredits,
> +					      ni->ni_net->net_tunables.lct_peer_tx_credits,
> +					      ni->ni_net->net_tunables.lct_peer_rtr_credits,
>  					      tq->tq_credits_max,
>  					      tq->tq_credits,
>  					      tq->tq_credits_min);
> 
> 
>

Patch
diff mbox series

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h
index 078bc97a9ebf..ead8a4e1125a 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-types.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h
@@ -43,6 +43,7 @@ 
 
 #include <uapi/linux/lnet/lnet-types.h>
 #include <uapi/linux/lnet/lnetctl.h>
+#include <uapi/linux/lnet/lnet-dlc.h>
 
 /* Max payload size */
 #define LNET_MAX_PAYLOAD      CONFIG_LNET_MAX_PAYLOAD
@@ -252,17 +253,22 @@  struct lnet_tx_queue {
 	struct list_head	tq_delayed;	/* delayed TXs */
 };
 
+struct lnet_net {
+	/* network tunables */
+	struct lnet_ioctl_config_lnd_cmn_tunables net_tunables;
+
+	/*
+	 * boolean to indicate that the tunables have been set and
+	 * shouldn't be reset
+	 */
+	bool			  net_tunables_set;
+};
+
 struct lnet_ni {
 	spinlock_t		  ni_lock;
 	struct list_head	  ni_list;	/* chain on ln_nis */
 	struct list_head	  ni_cptlist;	/* chain on ln_nis_cpt */
-	int			  ni_maxtxcredits; /* # tx credits  */
-	/* # per-peer send credits */
-	int			  ni_peertxcredits;
-	/* # per-peer router buffer credits */
-	int			  ni_peerrtrcredits;
-	/* seconds to consider peer dead */
-	int			  ni_peertimeout;
+
 	/* number of CPTs */
 	int			ni_ncpts;
 
@@ -286,6 +292,9 @@  struct lnet_ni {
 	/* when I was last alive */
 	time64_t		ni_last_alive;
 
+	/* pointer to parent network */
+	struct lnet_net		*ni_net;
+
 	/* my health status */
 	struct lnet_ni_status	*ni_status;
 
@@ -397,7 +406,7 @@  struct lnet_peer_table {
  * lnet_ni::ni_peertimeout has been set to a positive value
  */
 #define lnet_peer_aliveness_enabled(lp) (the_lnet.ln_routing && \
-					 (lp)->lp_ni->ni_peertimeout > 0)
+					 (lp)->lp_ni->ni_net->net_tunables.lct_peer_timeout > 0)
 
 struct lnet_route {
 	struct list_head	 lr_list;	/* chain on net */
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
index c1619f411d81..a8eb3b8f9fd7 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
@@ -39,10 +39,10 @@ 
 
 struct lnet_ioctl_config_lnd_cmn_tunables {
 	__u32 lct_version;
-	__u32 lct_peer_timeout;
-	__u32 lct_peer_tx_credits;
-	__u32 lct_peer_rtr_credits;
-	__u32 lct_max_tx_credits;
+	__s32 lct_peer_timeout;
+	__s32 lct_peer_tx_credits;
+	__s32 lct_peer_rtr_credits;
+	__s32 lct_max_tx_credits;
 };
 
 struct lnet_ioctl_config_o2iblnd_tunables {
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index f496e6fcc416..0d17e22c4401 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -337,7 +337,7 @@  int kiblnd_create_peer(struct lnet_ni *ni, struct kib_peer **peerp,
 	peer->ibp_error = 0;
 	peer->ibp_last_alive = 0;
 	peer->ibp_max_frags = kiblnd_cfg_rdma_frags(peer->ibp_ni);
-	peer->ibp_queue_depth = ni->ni_peertxcredits;
+	peer->ibp_queue_depth = ni->ni_net->net_tunables.lct_peer_tx_credits;
 	atomic_set(&peer->ibp_refcount, 1);  /* 1 ref for caller */
 
 	INIT_LIST_HEAD(&peer->ibp_list);     /* not in the peer table yet */
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
index 39d07926d603..a1aca4dda38f 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
@@ -171,7 +171,7 @@  int 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;
 }
@@ -179,6 +179,7 @@  int kiblnd_msg_queue_size(int version, struct lnet_ni *ni)
 int 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
@@ -204,35 +205,39 @@  int kiblnd_tunables_setup(struct lnet_ni *ni)
 		return -EINVAL;
 	}
 
-	if (!ni->ni_peertimeout)
-		ni->ni_peertimeout = peer_timeout;
+	net_tunables = &ni->ni_net->net_tunables;
 
-	if (!ni->ni_maxtxcredits)
-		ni->ni_maxtxcredits = credits;
+	if (net_tunables->lct_peer_timeout == -1)
+		net_tunables->lct_peer_timeout = peer_timeout;
 
-	if (!ni->ni_peertxcredits)
-		ni->ni_peertxcredits = peer_credits;
+	if (net_tunables->lct_max_tx_credits == -1)
+		net_tunables->lct_max_tx_credits = credits;
 
-	if (!ni->ni_peerrtrcredits)
-		ni->ni_peerrtrcredits = peer_buffer_credits;
+	if (net_tunables->lct_peer_tx_credits == -1)
+		net_tunables->lct_peer_tx_credits = peer_credits;
 
-	if (ni->ni_peertxcredits < IBLND_CREDITS_DEFAULT)
-		ni->ni_peertxcredits = IBLND_CREDITS_DEFAULT;
+	if (net_tunables->lct_peer_rtr_credits == -1)
+		net_tunables->lct_peer_rtr_credits = peer_buffer_credits;
 
-	if (ni->ni_peertxcredits > IBLND_CREDITS_MAX)
-		ni->ni_peertxcredits = IBLND_CREDITS_MAX;
+	if (net_tunables->lct_peer_tx_credits < IBLND_CREDITS_DEFAULT)
+		net_tunables->lct_peer_tx_credits = IBLND_CREDITS_DEFAULT;
 
-	if (ni->ni_peertxcredits > credits)
-		ni->ni_peertxcredits = credits;
+	if (net_tunables->lct_peer_tx_credits > IBLND_CREDITS_MAX)
+		net_tunables->lct_peer_tx_credits = IBLND_CREDITS_MAX;
+
+	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 ||
 	    tunables->lnd_map_on_demand > IBLND_MAX_RDMA_FRAGS) {
@@ -252,21 +257,23 @@  int kiblnd_tunables_setup(struct lnet_ni *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)
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 4dde158451ea..4ad885f10235 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -2739,12 +2739,19 @@  ksocknal_startup(struct lnet_ni *ni)
 		goto fail_0;
 
 	spin_lock_init(&net->ksnn_lock);
-	net->ksnn_incarnation = ktime_get_real_ns();
-	ni->ni_data = net;
-	ni->ni_peertimeout    = *ksocknal_tunables.ksnd_peertimeout;
-	ni->ni_maxtxcredits   = *ksocknal_tunables.ksnd_credits;
-	ni->ni_peertxcredits  = *ksocknal_tunables.ksnd_peertxcredits;
-	ni->ni_peerrtrcredits = *ksocknal_tunables.ksnd_peerrtrcredits;
+        net->ksnn_incarnation = ktime_get_real_ns();
+        ni->ni_data = net;
+	if (!ni->ni_net->net_tunables_set) {
+		ni->ni_net->net_tunables.lct_peer_timeout =
+			*ksocknal_tunables.ksnd_peertimeout;
+		ni->ni_net->net_tunables.lct_max_tx_credits =
+			*ksocknal_tunables.ksnd_credits;
+		ni->ni_net->net_tunables.lct_peer_tx_credits =
+			*ksocknal_tunables.ksnd_peertxcredits;
+		ni->ni_net->net_tunables.lct_peer_rtr_credits =
+			*ksocknal_tunables.ksnd_peerrtrcredits;
+		ni->ni_net->net_tunables_set = true;
+	}
 
 	net->ksnn_ninterfaces = 0;
 	if (!ni->ni_interfaces[0]) {
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index f9fcce2a5643..cd4189fa7acb 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -1036,11 +1036,11 @@  lnet_ni_tq_credits(struct lnet_ni *ni)
 	LASSERT(ni->ni_ncpts >= 1);
 
 	if (ni->ni_ncpts == 1)
-		return ni->ni_maxtxcredits;
+		return ni->ni_net->net_tunables.lct_max_tx_credits;
 
-	credits = ni->ni_maxtxcredits / ni->ni_ncpts;
-	credits = max(credits, 8 * ni->ni_peertxcredits);
-	credits = min(credits, ni->ni_maxtxcredits);
+	credits = ni->ni_net->net_tunables.lct_max_tx_credits / ni->ni_ncpts;
+	credits = max(credits, 8 * ni->ni_net->net_tunables.lct_peer_tx_credits);
+	credits = min(credits, ni->ni_net->net_tunables.lct_max_tx_credits);
 
 	return credits;
 }
@@ -1271,16 +1271,16 @@  lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
 	 */
 	if (conf) {
 		if (conf->cfg_config_u.cfg_net.net_peer_rtr_credits >= 0)
-			ni->ni_peerrtrcredits =
+			ni->ni_net->net_tunables.lct_peer_rtr_credits =
 				conf->cfg_config_u.cfg_net.net_peer_rtr_credits;
 		if (conf->cfg_config_u.cfg_net.net_peer_timeout >= 0)
-			ni->ni_peertimeout =
+			ni->ni_net->net_tunables.lct_peer_timeout =
 				conf->cfg_config_u.cfg_net.net_peer_timeout;
 		if (conf->cfg_config_u.cfg_net.net_peer_tx_credits != -1)
-			ni->ni_peertxcredits =
+			ni->ni_net->net_tunables.lct_peer_tx_credits =
 				conf->cfg_config_u.cfg_net.net_peer_tx_credits;
 		if (conf->cfg_config_u.cfg_net.net_max_tx_credits >= 0)
-			ni->ni_maxtxcredits =
+			ni->ni_net->net_tunables.lct_max_tx_credits =
 				conf->cfg_config_u.cfg_net.net_max_tx_credits;
 	}
 
@@ -1297,8 +1297,6 @@  lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
 		goto failed0;
 	}
 
-	LASSERT(ni->ni_peertimeout <= 0 || lnd->lnd_query);
-
 	lnet_net_lock(LNET_LOCK_EX);
 	/* refcount for ln_nis */
 	lnet_ni_addref_locked(ni, 0);
@@ -1314,13 +1312,18 @@  lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
 		lnet_ni_addref(ni);
 		LASSERT(!the_lnet.ln_loni);
 		the_lnet.ln_loni = ni;
+		ni->ni_net->net_tunables.lct_peer_tx_credits = 0;
+		ni->ni_net->net_tunables.lct_peer_rtr_credits = 0;
+		ni->ni_net->net_tunables.lct_max_tx_credits = 0;
+		ni->ni_net->net_tunables.lct_peer_timeout = 0;
 		return 0;
 	}
 
-	if (!ni->ni_peertxcredits || !ni->ni_maxtxcredits) {
+	if (!ni->ni_net->net_tunables.lct_peer_tx_credits ||
+	    !ni->ni_net->net_tunables.lct_max_tx_credits) {
 		LCONSOLE_ERROR_MSG(0x107, "LNI %s has no %scredits\n",
 				   libcfs_lnd2str(lnd->lnd_type),
-				   !ni->ni_peertxcredits ?
+				   !ni->ni_net->net_tunables.lct_peer_tx_credits ?
 				   "" : "per-peer ");
 		/*
 		 * shutdown the NI since if we get here then it must've already
@@ -1343,9 +1346,11 @@  lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
 	add_device_randomness(&seed, sizeof(seed));
 
 	CDEBUG(D_LNI, "Added LNI %s [%d/%d/%d/%d]\n",
-	       libcfs_nid2str(ni->ni_nid), ni->ni_peertxcredits,
+	       libcfs_nid2str(ni->ni_nid),
+		ni->ni_net->net_tunables.lct_peer_tx_credits,
 	       lnet_ni_tq_credits(ni) * LNET_CPT_NUMBER,
-	       ni->ni_peerrtrcredits, ni->ni_peertimeout);
+	       ni->ni_net->net_tunables.lct_peer_rtr_credits,
+		ni->ni_net->net_tunables.lct_peer_timeout);
 
 	return 0;
 failed0:
@@ -1667,10 +1672,14 @@  lnet_fill_ni_info(struct lnet_ni *ni, struct lnet_ioctl_config_data *config)
 	}
 
 	config->cfg_nid = ni->ni_nid;
-	config->cfg_config_u.cfg_net.net_peer_timeout = ni->ni_peertimeout;
-	config->cfg_config_u.cfg_net.net_max_tx_credits = ni->ni_maxtxcredits;
-	config->cfg_config_u.cfg_net.net_peer_tx_credits = ni->ni_peertxcredits;
-	config->cfg_config_u.cfg_net.net_peer_rtr_credits = ni->ni_peerrtrcredits;
+	config->cfg_config_u.cfg_net.net_peer_timeout =
+		ni->ni_net->net_tunables.lct_peer_timeout;
+	config->cfg_config_u.cfg_net.net_max_tx_credits =
+		ni->ni_net->net_tunables.lct_max_tx_credits;
+	config->cfg_config_u.cfg_net.net_peer_tx_credits =
+		ni->ni_net->net_tunables.lct_peer_tx_credits;
+	config->cfg_config_u.cfg_net.net_peer_rtr_credits =
+		ni->ni_net->net_tunables.lct_peer_rtr_credits;
 
 	net_config->ni_status = ni->ni_status->ns_status;
 
diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c
index 091c4f714e84..86a53854e427 100644
--- a/drivers/staging/lustre/lnet/lnet/config.c
+++ b/drivers/staging/lustre/lnet/lnet/config.c
@@ -114,29 +114,38 @@  lnet_ni_free(struct lnet_ni *ni)
 	if (ni->ni_net_ns)
 		put_net(ni->ni_net_ns);
 
+	kvfree(ni->ni_net);
 	kfree(ni);
 }
 
 struct lnet_ni *
-lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
+lnet_ni_alloc(__u32 net_id, struct cfs_expr_list *el, struct list_head *nilist)
 {
 	struct lnet_tx_queue *tq;
 	struct lnet_ni *ni;
 	int rc;
 	int i;
+	struct lnet_net		*net;
 
-	if (!lnet_net_unique(net, nilist)) {
+	if (!lnet_net_unique(net_id, nilist)) {
 		LCONSOLE_ERROR_MSG(0x111, "Duplicate network specified: %s\n",
-				   libcfs_net2str(net));
+				   libcfs_net2str(net_id));
 		return NULL;
 	}
 
 	ni = kzalloc(sizeof(*ni), GFP_NOFS);
-	if (!ni) {
+	net = kzalloc(sizeof(*net), GFP_NOFS);
+	if (!ni || !net) {
+		kfree(ni); kfree(net);
 		CERROR("Out of memory creating network %s\n",
-		       libcfs_net2str(net));
+		       libcfs_net2str(net_id));
 		return NULL;
 	}
+	/* initialize global paramters to undefiend */
+	net->net_tunables.lct_peer_timeout = -1;
+	net->net_tunables.lct_max_tx_credits = -1;
+	net->net_tunables.lct_peer_tx_credits = -1;
+	net->net_tunables.lct_peer_rtr_credits = -1;
 
 	spin_lock_init(&ni->ni_lock);
 	INIT_LIST_HEAD(&ni->ni_cptlist);
@@ -160,7 +169,7 @@  lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
 		rc = cfs_expr_list_values(el, LNET_CPT_NUMBER, &ni->ni_cpts);
 		if (rc <= 0) {
 			CERROR("Failed to set CPTs for NI %s: %d\n",
-			       libcfs_net2str(net), rc);
+			       libcfs_net2str(net_id), rc);
 			goto failed;
 		}
 
@@ -173,8 +182,9 @@  lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
 		ni->ni_ncpts = rc;
 	}
 
+	ni->ni_net = net;
 	/* LND will fill in the address part of the NID */
-	ni->ni_nid = LNET_MKNID(net, 0);
+	ni->ni_nid = LNET_MKNID(net_id, 0);
 
 	/* Store net namespace in which current ni is being created */
 	if (current->nsproxy->net_ns)
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index edcafac055ed..f186e6a16d34 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -524,7 +524,8 @@  lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
 	    lp->lp_timestamp >= lp->lp_last_alive)
 		return 0;
 
-	deadline = lp->lp_last_alive + lp->lp_ni->ni_peertimeout;
+	deadline = lp->lp_last_alive +
+		lp->lp_ni->ni_net->net_tunables.lct_peer_timeout;
 	alive = deadline > now;
 
 	/* Update obsolete lp_alive except for routers assumed to be dead
@@ -569,7 +570,7 @@  lnet_peer_alive_locked(struct lnet_peer *lp)
 				      libcfs_nid2str(lp->lp_nid),
 				      now, next_query,
 				      lnet_queryinterval,
-				      lp->lp_ni->ni_peertimeout);
+				      lp->lp_ni->ni_net->net_tunables.lct_peer_timeout);
 			return 0;
 		}
 	}
diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
index d9452c322e4d..b76ac3e051d9 100644
--- a/drivers/staging/lustre/lnet/lnet/peer.c
+++ b/drivers/staging/lustre/lnet/lnet/peer.c
@@ -342,8 +342,8 @@  lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt)
 		goto out;
 	}
 
-	lp->lp_txcredits = lp->lp_ni->ni_peertxcredits;
-	lp->lp_mintxcredits = lp->lp_ni->ni_peertxcredits;
+	lp->lp_txcredits = lp->lp_ni->ni_net->net_tunables.lct_peer_tx_credits;
+	lp->lp_mintxcredits = lp->lp_ni->ni_net->net_tunables.lct_peer_tx_credits;
 	lp->lp_rtrcredits = lnet_peer_buffer_credits(lp->lp_ni);
 	lp->lp_minrtrcredits = lnet_peer_buffer_credits(lp->lp_ni);
 
@@ -383,7 +383,7 @@  lnet_debug_peer(lnet_nid_t nid)
 
 	CDEBUG(D_WARNING, "%-24s %4d %5s %5d %5d %5d %5d %5d %ld\n",
 	       libcfs_nid2str(lp->lp_nid), lp->lp_refcount,
-	       aliveness, lp->lp_ni->ni_peertxcredits,
+	       aliveness, lp->lp_ni->ni_net->net_tunables.lct_peer_tx_credits,
 	       lp->lp_rtrcredits, lp->lp_minrtrcredits,
 	       lp->lp_txcredits, lp->lp_mintxcredits, lp->lp_txqnob);
 
@@ -438,7 +438,8 @@  lnet_get_peer_info(__u32 peer_index, __u64 *nid,
 
 			*nid = lp->lp_nid;
 			*refcount = lp->lp_refcount;
-			*ni_peer_tx_credits = lp->lp_ni->ni_peertxcredits;
+			*ni_peer_tx_credits =
+				lp->lp_ni->ni_net->net_tunables.lct_peer_tx_credits;
 			*peer_tx_credits = lp->lp_txcredits;
 			*peer_rtr_credits = lp->lp_rtrcredits;
 			*peer_min_rtr_credits = lp->lp_mintxcredits;
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index 02241fbc9eaa..7d61c5d71426 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -57,9 +57,11 @@  MODULE_PARM_DESC(auto_down, "Automatically mark peers down on comms error");
 int
 lnet_peer_buffer_credits(struct lnet_ni *ni)
 {
+	struct lnet_net *net = ni->ni_net;
+
 	/* NI option overrides LNet default */
-	if (ni->ni_peerrtrcredits > 0)
-		return ni->ni_peerrtrcredits;
+	if (net->net_tunables.lct_peer_rtr_credits > 0)
+		return net->net_tunables.lct_peer_rtr_credits;
 	if (peer_buffer_credits > 0)
 		return peer_buffer_credits;
 
@@ -67,7 +69,7 @@  lnet_peer_buffer_credits(struct lnet_ni *ni)
 	 * As an approximation, allow this peer the same number of router
 	 * buffers as it is allowed outstanding sends
 	 */
-	return ni->ni_peertxcredits;
+	return net->net_tunables.lct_peer_tx_credits;
 }
 
 /* forward ref's */
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
index 31f4982f7f17..19cea7076057 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -489,7 +489,7 @@  static int proc_lnet_peers(struct ctl_table *table, int write,
 			int nrefs = peer->lp_refcount;
 			time64_t lastalive = -1;
 			char *aliveness = "NA";
-			int maxcr = peer->lp_ni->ni_peertxcredits;
+			int maxcr = peer->lp_ni->ni_net->net_tunables.lct_peer_tx_credits;
 			int txcr = peer->lp_txcredits;
 			int mintxcr = peer->lp_mintxcredits;
 			int rtrcr = peer->lp_rtrcredits;
@@ -704,8 +704,8 @@  static int proc_lnet_nis(struct ctl_table *table, int write,
 					      "%-24s %6s %5lld %4d %4d %4d %5d %5d %5d\n",
 					      libcfs_nid2str(ni->ni_nid), stat,
 					      last_alive, *ni->ni_refs[i],
-					      ni->ni_peertxcredits,
-					      ni->ni_peerrtrcredits,
+					      ni->ni_net->net_tunables.lct_peer_tx_credits,
+					      ni->ni_net->net_tunables.lct_peer_rtr_credits,
 					      tq->tq_credits_max,
 					      tq->tq_credits,
 					      tq->tq_credits_min);