#endif
lnet_t the_lnet; /* THE state of the network */
+EXPORT_SYMBOL(the_lnet);
#ifdef __KERNEL__
LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex);
}
+EXPORT_SYMBOL(lnet_register_lnd);
void
lnet_unregister_lnd (lnd_t *lnd)
LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex);
}
+EXPORT_SYMBOL(lnet_unregister_lnd);
void
lnet_counters_get(lnet_counters_t *counters)
{
int count = 0;
- if (rec->rec_type == 0) /* not set yet, it's a uninitialized */
+ if (rec->rec_type == 0) /* not set yet, it's uninitialized */
return;
while (!cfs_list_empty(&rec->rec_active)) {
lnet_libhandle_t *lh;
unsigned int hash;
- if ((cookie & (LNET_COOKIE_TYPES - 1)) != rec->rec_type)
+ if ((cookie & LNET_COOKIE_MASK) != rec->rec_type)
return NULL;
hash = cookie >> (LNET_COOKIE_TYPE_BITS + LNET_CPT_BITS);
int
lnet_prepare(lnet_pid_t requested_pid)
{
- /* Prepare to bring up the network */
+ /* Prepare to bring up the network */
struct lnet_res_container **recs;
int rc = 0;
CFS_INIT_LIST_HEAD(&the_lnet.ln_test_peers);
CFS_INIT_LIST_HEAD(&the_lnet.ln_nis);
+ CFS_INIT_LIST_HEAD(&the_lnet.ln_nis_cpt);
CFS_INIT_LIST_HEAD(&the_lnet.ln_nis_zombie);
CFS_INIT_LIST_HEAD(&the_lnet.ln_remote_nets);
CFS_INIT_LIST_HEAD(&the_lnet.ln_routers);
if (rc != 0)
goto failed;
- /* NB: we will have instance of message container per CPT soon */
rc = lnet_msg_containers_create();
if (rc != 0)
goto failed;
the_lnet.ln_me_containers = recs;
- /* NB: we will have instance of MD container per CPT soon */
recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD, LNET_FL_MAX_MDS,
sizeof(lnet_libmd_t));
if (recs == NULL)
LASSERT(the_lnet.ln_refcount == 0);
LASSERT(cfs_list_empty(&the_lnet.ln_test_peers));
LASSERT(cfs_list_empty(&the_lnet.ln_nis));
+ LASSERT(cfs_list_empty(&the_lnet.ln_nis_cpt));
LASSERT(cfs_list_empty(&the_lnet.ln_nis_zombie));
lnet_portals_destroy();
return NULL;
}
-unsigned int
-lnet_nid_cpt_hash(lnet_nid_t nid)
+lnet_ni_t *
+lnet_net2ni(__u32 net)
+{
+ lnet_ni_t *ni;
+
+ lnet_net_lock(0);
+ ni = lnet_net2ni_locked(net, 0);
+ lnet_net_unlock(0);
+
+ return ni;
+}
+EXPORT_SYMBOL(lnet_net2ni);
+
+static unsigned int
+lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number)
{
__u64 key = nid;
unsigned int val;
+ LASSERT(number >= 1 && number <= LNET_CPT_NUMBER);
+
+ if (number == 1)
+ return 0;
+
val = cfs_hash_long(key, LNET_CPT_BITS);
/* NB: LNET_CP_NUMBER doesn't have to be PO2 */
- if (val < LNET_CPT_NUMBER)
+ if (val < number)
return val;
- return (unsigned int)((key + val + (val >> 1)) % LNET_CPT_NUMBER);
+ return (unsigned int)(key + val + (val >> 1)) % number;
+}
+
+int
+lnet_cpt_of_nid_locked(lnet_nid_t nid)
+{
+ struct lnet_ni *ni;
+
+ /* must called with hold of lnet_net_lock */
+ if (LNET_CPT_NUMBER == 1)
+ return 0; /* the only one */
+
+ /* take lnet_net_lock(any) would be OK */
+ if (!cfs_list_empty(&the_lnet.ln_nis_cpt)) {
+ cfs_list_for_each_entry(ni, &the_lnet.ln_nis_cpt, ni_cptlist) {
+ if (LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid))
+ continue;
+
+ LASSERT(ni->ni_cpts != NULL);
+ return ni->ni_cpts[lnet_nid_cpt_hash
+ (nid, ni->ni_ncpts)];
+ }
+ }
+
+ return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
}
int
lnet_cpt_of_nid(lnet_nid_t nid)
{
+ int cpt;
+ int cpt2;
+
if (LNET_CPT_NUMBER == 1)
return 0; /* the only one */
- return lnet_nid_cpt_hash(nid);
+ if (cfs_list_empty(&the_lnet.ln_nis_cpt))
+ return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
+
+ cpt = lnet_net_lock_current();
+ cpt2 = lnet_cpt_of_nid_locked(nid);
+ lnet_net_unlock(cpt);
+
+ return cpt2;
}
EXPORT_SYMBOL(lnet_cpt_of_nid);
{
int credits;
- credits = ni->ni_maxtxcredits / LNET_CPT_NUMBER;
+ LASSERT(ni->ni_ncpts >= 1);
+
+ if (ni->ni_ncpts == 1)
+ return ni->ni_maxtxcredits;
+
+ credits = ni->ni_maxtxcredits / ni->ni_ncpts;
credits = max(credits, 8 * ni->ni_peertxcredits);
credits = min(credits, ni->ni_maxtxcredits);
/* move it to zombie list and nobody can find it anymore */
cfs_list_move(&ni->ni_list, &the_lnet.ln_nis_zombie);
lnet_ni_decref_locked(ni, 0); /* drop ln_nis' ref */
+
+ if (!cfs_list_empty(&ni->ni_cptlist)) {
+ cfs_list_del_init(&ni->ni_cptlist);
+ lnet_ni_decref_locked(ni, 0);
+ }
}
/* Drop the cached eqwait NI. */
/* refcount for ln_nis */
lnet_ni_addref_locked(ni, 0);
cfs_list_add_tail(&ni->ni_list, &the_lnet.ln_nis);
+ if (ni->ni_cpts != NULL) {
+ cfs_list_add_tail(&ni->ni_cptlist,
+ &the_lnet.ln_nis_cpt);
+ lnet_ni_addref_locked(ni, 0);
+ }
lnet_net_unlock(LNET_LOCK_EX);
{
int rc;
- lnet_assert_wire_constants ();
- LASSERT (!the_lnet.ln_init);
+ lnet_assert_wire_constants();
+ LASSERT(!the_lnet.ln_init);
- memset(&the_lnet, 0, sizeof(the_lnet));
+ memset(&the_lnet, 0, sizeof(the_lnet));
/* refer to global cfs_cpt_table for now */
the_lnet.ln_cpt_table = cfs_cpt_table;
return -1;
}
- the_lnet.ln_refcount = 0;
- the_lnet.ln_init = 1;
- LNetInvalidateHandle(&the_lnet.ln_rc_eqh);
- CFS_INIT_LIST_HEAD(&the_lnet.ln_lnds);
+ the_lnet.ln_refcount = 0;
+ the_lnet.ln_init = 1;
+ LNetInvalidateHandle(&the_lnet.ln_rc_eqh);
+ CFS_INIT_LIST_HEAD(&the_lnet.ln_lnds);
CFS_INIT_LIST_HEAD(&the_lnet.ln_rcd_zombie);
CFS_INIT_LIST_HEAD(&the_lnet.ln_rcd_deathrow);
#else
/* Register LNDs
* NB the order here determines default 'networks=' order */
-# ifdef CRAY_XT3
- LNET_REGISTER_ULND(the_ptllnd);
-# endif
# ifdef HAVE_LIBPTHREAD
LNET_REGISTER_ULND(the_tcplnd);
# endif
lnet_register_lnd(&the_lolnd);
return 0;
}
+EXPORT_SYMBOL(LNetInit);
/**
* Finalize LNet library.
the_lnet.ln_init = 0;
}
+EXPORT_SYMBOL(LNetFini);
/**
* Set LNet PID and start LNet interfaces, routing, and forwarding.
LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex);
return rc;
}
+EXPORT_SYMBOL(LNetNIInit);
/**
* Stop LNet interfaces, routing, and forwarding.
LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex);
return 0;
}
+EXPORT_SYMBOL(LNetNIFini);
/**
* This is an ugly hack to export IOC_LIBCFS_DEBUG_PEER and
}
/* not reached */
}
+EXPORT_SYMBOL(LNetCtl);
/**
* Retrieve the lnet_process_id_t ID of LNet interface at \a index. Note that
lnet_net_unlock(cpt);
return rc;
}
+EXPORT_SYMBOL(LNetGetId);
/**
* Print a string representation of handle \a h into buffer \a str of
{
snprintf(str, len, LPX64, h.cookie);
}
+EXPORT_SYMBOL(LNetSnprintHandle);
static int
lnet_create_ping_info(void)
pinfo->pi_nnis = n;
pinfo->pi_pid = the_lnet.ln_pid;
pinfo->pi_magic = LNET_PROTO_PING_MAGIC;
- pinfo->pi_version = LNET_PROTO_PING_VERSION;
+ pinfo->pi_features = LNET_PING_FEAT_NI_STATUS;
for (i = 0; i < n; i++) {
lnet_ni_status_t *ns = &pinfo->pi_ni[i];
lnet_ni_decref_locked(ni, 0);
lnet_net_unlock(0);
- }
+ }
- the_lnet.ln_ping_info = pinfo;
- return 0;
+ the_lnet.ln_ping_info = pinfo;
+ return 0;
}
static void
goto out_1;
}
- if (info->pi_version != LNET_PROTO_PING_VERSION) {
- CERROR("%s: Unexpected version 0x%x\n",
- libcfs_id2str(id), info->pi_version);
- goto out_1;
- }
+ if ((info->pi_features & LNET_PING_FEAT_NI_STATUS) == 0) {
+ CERROR("%s: ping w/o NI status: 0x%x\n",
+ libcfs_id2str(id), info->pi_features);
+ goto out_1;
+ }
if (nob < offsetof(lnet_ping_info_t, pi_ni[0])) {
CERROR("%s: Short reply %d(%d min)\n", libcfs_id2str(id),