BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq, acr_nid) != 8);
BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq *)0)->acr_nid) != 8);
+ /* Checks for struct lnet_acceptor_connreq_v2 */
+ BUILD_BUG_ON((int)sizeof(struct lnet_acceptor_connreq_v2) != 28);
+ BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq_v2, acr_magic) != 0);
+ BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq_v2 *)0)->acr_magic) != 4);
+ BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq_v2, acr_version) != 4);
+ BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq_v2 *)0)->acr_version) != 4);
+ BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq_v2, acr_nid) != 8);
+ BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq_v2 *)0)->acr_nid) != 20);
+
/* Checks for struct lnet_counters_common */
BUILD_BUG_ON((int)sizeof(struct lnet_counters_common) != 60);
BUILD_BUG_ON((int)offsetof(struct lnet_counters_common, lcc_msgs_alloc) != 0);
int
lnet_net_add_pref_rtr(struct lnet_net *net,
- lnet_nid_t gw_nid)
+ struct lnet_nid *gw_nid)
__must_hold(&the_lnet.ln_api_mutex)
{
struct lnet_nid_list *ne;
* lock.
*/
list_for_each_entry(ne, &net->net_rtr_pref_nids, nl_list) {
- if (ne->nl_nid == gw_nid)
+ if (nid_same(&ne->nl_nid, gw_nid))
return -EEXIST;
}
if (!ne)
return -ENOMEM;
- ne->nl_nid = gw_nid;
+ ne->nl_nid = *gw_nid;
/* Lock the cpt to protect against addition and checks in the
* selection algorithm
}
bool
-lnet_net_is_pref_rtr_locked(struct lnet_net *net, lnet_nid_t rtr_nid)
+lnet_net_is_pref_rtr_locked(struct lnet_net *net, struct lnet_nid *rtr_nid)
{
struct lnet_nid_list *ne;
- CDEBUG(D_NET, "%s: rtr pref emtpy: %d\n",
+ CDEBUG(D_NET, "%s: rtr pref empty: %d\n",
libcfs_net2str(net->net_id),
list_empty(&net->net_rtr_pref_nids));
list_for_each_entry(ne, &net->net_rtr_pref_nids, nl_list) {
CDEBUG(D_NET, "Comparing pref %s with gw %s\n",
- libcfs_nid2str(ne->nl_nid),
- libcfs_nid2str(rtr_nid));
- if (rtr_nid == ne->nl_nid)
+ libcfs_nidstr(&ne->nl_nid),
+ libcfs_nidstr(rtr_nid));
+ if (nid_same(rtr_nid, &ne->nl_nid))
return true;
}
return false;
}
-unsigned int
-lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number)
+static unsigned int
+lnet_nid4_cpt_hash(lnet_nid_t nid, unsigned int number)
{
__u64 key = nid;
unsigned int val;
return (unsigned int)(key + val + (val >> 1)) % number;
}
+unsigned int
+lnet_nid_cpt_hash(struct lnet_nid *nid, unsigned int number)
+{
+ unsigned int val;
+ u32 h = 0;
+ int i;
+
+ LASSERT(number >= 1 && number <= LNET_CPT_NUMBER);
+
+ if (number == 1)
+ return 0;
+
+ if (nid_is_nid4(nid))
+ return lnet_nid4_cpt_hash(lnet_nid_to_nid4(nid), number);
+
+ for (i = 0; i < 4; i++)
+ h = hash_32(nid->nid_addr[i]^h, 32);
+ val = hash_32(LNET_NID_NET(nid) ^ h, LNET_CPT_BITS);
+ if (val < number)
+ return val;
+ return (unsigned int)(h + val + (val >> 1)) % number;
+}
+
int
lnet_cpt_of_nid_locked(struct lnet_nid *nid, struct lnet_ni *ni)
{
struct lnet_net *net;
- /* FIXME handle long-addr nid */
- lnet_nid_t nid4 = lnet_nid_to_nid4(nid);
/* must called with hold of lnet_net_lock */
if (LNET_CPT_NUMBER == 1)
*/
if (ni != NULL) {
if (ni->ni_cpts != NULL)
- return ni->ni_cpts[lnet_nid_cpt_hash(nid4,
+ return ni->ni_cpts[lnet_nid_cpt_hash(nid,
ni->ni_ncpts)];
else
- return lnet_nid_cpt_hash(nid4, LNET_CPT_NUMBER);
+ return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
}
/* no NI provided so look at the net */
net = lnet_get_net_locked(LNET_NID_NET(nid));
if (net != NULL && net->net_cpts != NULL) {
- return net->net_cpts[lnet_nid_cpt_hash(nid4, net->net_ncpts)];
+ return net->net_cpts[lnet_nid_cpt_hash(nid, net->net_ncpts)];
}
- return lnet_nid_cpt_hash(nid4, LNET_CPT_NUMBER);
+ return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
}
int
-lnet_cpt_of_nid(lnet_nid_t nid4, struct lnet_ni *ni)
+lnet_nid2cpt(struct lnet_nid *nid, struct lnet_ni *ni)
{
int cpt;
int cpt2;
- struct lnet_nid nid;
if (LNET_CPT_NUMBER == 1)
return 0; /* the only one */
- lnet_nid4_to_nid(nid4, &nid);
cpt = lnet_net_lock_current();
- cpt2 = lnet_cpt_of_nid_locked(&nid, ni);
+ cpt2 = lnet_cpt_of_nid_locked(nid, ni);
lnet_net_unlock(cpt);
return cpt2;
}
+EXPORT_SYMBOL(lnet_nid2cpt);
+
+int
+lnet_cpt_of_nid(lnet_nid_t nid4, struct lnet_ni *ni)
+{
+ struct lnet_nid nid;
+
+ if (LNET_CPT_NUMBER == 1)
+ return 0; /* the only one */
+
+ lnet_nid4_to_nid(nid4, &nid);
+ return lnet_nid2cpt(&nid, ni);
+}
EXPORT_SYMBOL(lnet_cpt_of_nid);
int
EXPORT_SYMBOL(lnet_nid_to_ni_addref);
int
-lnet_islocalnid(lnet_nid_t nid)
+lnet_islocalnid4(lnet_nid_t nid)
{
struct lnet_ni *ni;
int cpt;
}
int
+lnet_islocalnid(struct lnet_nid *nid)
+{
+ struct lnet_ni *ni;
+ int cpt;
+
+ cpt = lnet_net_lock_current();
+ ni = lnet_nid_to_ni_locked(nid, cpt);
+ lnet_net_unlock(cpt);
+
+ return ni != NULL;
+}
+
+int
lnet_count_acceptor_nets(void)
{
/* Return the # of NIs that need the acceptor. */
struct lnet_handle_md *ping_mdh,
int ni_count, bool set_eq)
{
- struct lnet_process_id id = {
- .nid = LNET_NID_ANY,
+ struct lnet_processid id = {
+ .nid = LNET_ANY_NID,
.pid = LNET_PID_ANY
};
struct lnet_me *me;
}
/* Ping target ME/MD */
- me = LNetMEAttach(LNET_RESERVED_PORTAL, id,
+ me = LNetMEAttach(LNET_RESERVED_PORTAL, &id,
LNET_PROTO_PING_MATCHBITS, 0,
LNET_UNLINK, LNET_INS_AFTER);
if (IS_ERR(me)) {
int lnet_push_target_post(struct lnet_ping_buffer *pbuf,
struct lnet_handle_md *mdhp)
{
- struct lnet_process_id id = { LNET_NID_ANY, LNET_PID_ANY };
+ struct lnet_processid id = { LNET_ANY_NID, LNET_PID_ANY };
struct lnet_md md = { NULL };
struct lnet_me *me;
int rc;
- me = LNetMEAttach(LNET_RESERVED_PORTAL, id,
+ me = LNetMEAttach(LNET_RESERVED_PORTAL, &id,
LNET_PROTO_PING_MATCHBITS, 0,
LNET_UNLINK, LNET_INS_AFTER);
if (IS_ERR(me)) {
list->lkl_maxattr);
nla_put_u16(msg, LN_SCALAR_ATTR_INDEX, count);
- if (props[count].lkp_values)
+ if (props[count].lkp_value)
nla_put_string(msg, LN_SCALAR_ATTR_VALUE,
- props[count].lkp_values);
+ props[count].lkp_value);
if (props[count].lkp_key_format)
nla_put_u16(msg, LN_SCALAR_ATTR_KEY_FORMAT,
props[count].lkp_key_format);
rc = lnet_genl_parse_list(msg, data, ++idx);
if (rc < 0)
return rc;
+ idx = rc;
}
nla_nest_end(msg, key);
}
nla_nest_end(msg, node);
- return 0;
+ return idx;
}
int lnet_genl_send_scalar_list(struct sk_buff *msg, u32 portid, u32 seq,
canceled:
if (rc < 0)
genlmsg_cancel(msg, hdr);
- return rc;
+ return rc > 0 ? 0 : rc;
}
EXPORT_SYMBOL(lnet_genl_send_scalar_list);
struct lnet_ioctl_config_data *config;
struct lnet_process_id id = {0};
struct lnet_ni *ni;
+ struct lnet_nid nid;
int rc;
BUILD_BUG_ON(sizeof(struct lnet_ioctl_net_config) +
config->cfg_config_u.cfg_route.rtr_sensitivity;
}
+ lnet_nid4_to_nid(config->cfg_nid, &nid);
mutex_lock(&the_lnet.ln_api_mutex);
rc = lnet_add_route(config->cfg_net,
config->cfg_config_u.cfg_route.rtr_hop,
- config->cfg_nid,
+ &nid,
config->cfg_config_u.cfg_route.
rtr_priority, sensitivity);
mutex_unlock(&the_lnet.ln_api_mutex);
mutex_lock(&the_lnet.ln_api_mutex);
lp = lnet_find_peer(ping->ping_id.nid);
if (lp) {
- ping->ping_id.nid = lp->lp_primary_nid;
+ ping->ping_id.nid =
+ lnet_nid_to_nid4(&lp->lp_primary_nid);
ping->mr_info = lnet_peer_is_multi_rail(lp);
lnet_peer_decref_locked(lp);
}
mutex_lock(&the_lnet.ln_api_mutex);
lp = lnet_find_peer(discover->ping_id.nid);
if (lp) {
- discover->ping_id.nid = lp->lp_primary_nid;
+ discover->ping_id.nid =
+ lnet_nid_to_nid4(&lp->lp_primary_nid);
discover->mr_info = lnet_peer_is_multi_rail(lp);
lnet_peer_decref_locked(lp);
}