Esempio n. 1
0
char *
libcfs_lnd2modname(int lnd)
{
        struct netstrfns *nf = libcfs_lnd2netstrfns(lnd);

        return (nf == NULL) ? NULL : nf->nf_modname;
}
Esempio n. 2
0
char *
libcfs_nid2str(lnet_nid_t nid)
{
        __u32             addr = LNET_NIDADDR(nid);
        __u32             net = LNET_NIDNET(nid);
        int               lnd = LNET_NETTYP(net);
        int               nnum = LNET_NETNUM(net);
        struct netstrfns *nf;
        char             *str;
        int               nob;

        if (nid == LNET_NID_ANY)
                return "<?>";

        nf = libcfs_lnd2netstrfns(lnd);
        str = libcfs_next_nidstring();

        if (nf == NULL)
                snprintf(str, LNET_NIDSTR_SIZE, "%x@<%u:%u>", addr, lnd, nnum);
        else {
                nf->nf_addr2str(addr, str);
                nob = strlen(str);
                if (nnum == 0)
                        snprintf(str + nob, LNET_NIDSTR_SIZE - nob, "@%s",
                                 nf->nf_name);
                else
                        snprintf(str + nob, LNET_NIDSTR_SIZE - nob, "@%s%u",
                                 nf->nf_name, nnum);
        }

        return str;
}
Esempio n. 3
0
char *
libcfs_lnd2str(int lnd)
{
        char           *str;
        struct netstrfns *nf = libcfs_lnd2netstrfns(lnd);

        if (nf != NULL)
                return nf->nf_name;

        str = libcfs_next_nidstring();
        snprintf(str, LNET_NIDSTR_SIZE, "?%u?", lnd);
        return str;
}
Esempio n. 4
0
void
libcfs_net2str2(__u32 net, char str[LNET_NIDSTR_SIZE])
{
	int               lnd = LNET_NETTYP(net);
	int               num = LNET_NETNUM(net);
	struct netstrfns *nf  = libcfs_lnd2netstrfns(lnd);

	if (nf == NULL)
		snprintf(str, LNET_NIDSTR_SIZE, "<%u:%u>", lnd, num);
	else if (num == 0)
		snprintf(str, LNET_NIDSTR_SIZE, "%s", nf->nf_name);
	else
		snprintf(str, LNET_NIDSTR_SIZE, "%s%u", nf->nf_name, num);
}
Esempio n. 5
0
char *
libcfs_net2str(__u32 net)
{
        int               lnd = LNET_NETTYP(net);
        int               num = LNET_NETNUM(net);
        struct netstrfns *nf  = libcfs_lnd2netstrfns(lnd);
        char             *str = libcfs_next_nidstring();

        if (nf == NULL)
                snprintf(str, LNET_NIDSTR_SIZE, "<%u:%u>", lnd, num);
        else if (num == 0)
                snprintf(str, LNET_NIDSTR_SIZE, "%s", nf->nf_name);
        else
                snprintf(str, LNET_NIDSTR_SIZE, "%s%u", nf->nf_name, num);

        return str;
}
Esempio n. 6
0
void
libcfs_setnet0alias(int lnd)
{
	struct netstrfns *nf = libcfs_lnd2netstrfns(lnd);
	struct netstrfns *nf0 = &libcfs_netstrfns[libcfs_nnetstrfns - 1];

	/* Ghastly hack to allow LNET to inter-operate with portals.
	 * NET type 0 becomes an alias for whatever local network we have, and
	 * this assignment here means we can parse and print its NIDs */

	LASSERT (nf != NULL);
	LASSERT (nf0->nf_type < 0);

	nf0->nf_name = "zero";//nf->nf_name;
	nf0->nf_modname = nf->nf_modname;
	nf0->nf_addr2str = nf->nf_addr2str;
	nf0->nf_str2addr = nf->nf_str2addr;
	mb();
	nf0->nf_type = 0;
}
Esempio n. 7
0
lnet_nid_t
libcfs_str2nid(const char *str)
{
        const char       *sep = strchr(str, '@');
        struct netstrfns *nf;
        __u32             net;
        __u32             addr;

        if (sep != NULL) {
                nf = libcfs_str2net_internal(sep + 1, &net);
                if (nf == NULL)
                        return LNET_NID_ANY;
        } else {
                sep = str + strlen(str);
                net = LNET_MKNET(SOCKLND, 0);
                nf = libcfs_lnd2netstrfns(SOCKLND);
                LASSERT (nf != NULL);
        }

        if (!nf->nf_str2addr(str, (int)(sep - str), &addr))
                return LNET_NID_ANY;

        return LNET_MKNID(net, addr);
}
Esempio n. 8
0
int
libcfs_isknown_lnd(int type)
{
        return libcfs_lnd2netstrfns(type) != NULL;
}