Whamcloud - gitweb
LU-7734 lnet: fix routing selection
[fs/lustre-release.git] / lnet / lnet / nidstrings.c
index 95f485a..f97b464 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2014, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -60,8 +56,8 @@
  * between getting its string and using it.
  */
 
-static char      libcfs_nidstrings[LNET_NIDSTR_COUNT][LNET_NIDSTR_SIZE];
-static int       libcfs_nidstring_idx;
+static char     libcfs_nidstrings[LNET_NIDSTR_COUNT][LNET_NIDSTR_SIZE];
+static int      libcfs_nidstring_idx;
 
 static DEFINE_SPINLOCK(libcfs_nidstring_lock);
 
@@ -70,7 +66,7 @@ static struct netstrfns *libcfs_namenum2netstrfns(const char *name);
 char *
 libcfs_next_nidstring(void)
 {
-       char          *str;
+       char          *str;
        unsigned long  flags;
 
        spin_lock_irqsave(&libcfs_nidstring_lock, flags);
@@ -88,22 +84,22 @@ EXPORT_SYMBOL(libcfs_next_nidstring);
  * Nid range list syntax.
  * \verbatim
  *
- * <nidlist>         :== <nidrange> [ ' ' <nidrange> ]
- * <nidrange>        :== <addrrange> '@' <net>
- * <addrrange>       :== '*' |
- *                       <ipaddr_range> |
+ * <nidlist>        :== <nidrange> [ ' ' <nidrange> ]
+ * <nidrange>       :== <addrrange> '@' <net>
+ * <addrrange>      :== '*' |
+ *                      <ipaddr_range> |
  *                      <cfs_expr_list>
  * <ipaddr_range>    :== <cfs_expr_list>.<cfs_expr_list>.<cfs_expr_list>.
  *                      <cfs_expr_list>
  * <cfs_expr_list>   :== <number> |
- *                       <expr_list>
- * <expr_list>       :== '[' <range_expr> [ ',' <range_expr>] ']'
+ *                      <expr_list>
+ * <expr_list>      :== '[' <range_expr> [ ',' <range_expr>] ']'
  * <range_expr>      :== <number> |
- *                       <number> '-' <number> |
- *                       <number> '-' <number> '/' <number>
- * <net>             :== <netname> | <netname><number>
- * <netname>         :== "lo" | "tcp" | "o2ib" | "cib" | "openib" | "iib" |
- *                       "vib" | "ra" | "elan" | "mx" | "ptl"
+ *                      <number> '-' <number> |
+ *                      <number> '-' <number> '/' <number>
+ * <net>            :== <netname> | <netname><number>
+ * <netname>        :== "lo" | "tcp" | "o2ib" | "cib" | "openib" | "iib" |
+ *                      "vib" | "ra" | "elan" | "mx" | "ptl"
  * \endverbatim
  */
 
@@ -249,10 +245,8 @@ parse_nidrange(struct cfs_lstr *src, struct list_head *nidlist)
 {
        struct cfs_lstr addrrange;
        struct cfs_lstr net;
-       struct cfs_lstr tmp;
        struct nidrange *nr;
 
-       tmp = *src;
        if (cfs_gettok(src, '@', &addrrange) == 0)
                goto failed;
 
@@ -268,7 +262,6 @@ parse_nidrange(struct cfs_lstr *src, struct list_head *nidlist)
 
        return 1;
 failed:
-       CWARN("can't parse nidrange: \"%.*s\"\n", tmp.ls_len, tmp.ls_str);
        return 0;
 }
 
@@ -901,7 +894,7 @@ libcfs_decnum_addr2str(__u32 addr, char *str, size_t size)
 static int
 libcfs_num_str2addr(const char *str, int nob, __u32 *addr)
 {
-       int     n;
+       int     n;
 
        n = nob;
        if (sscanf(str, "0x%x%n", addr, &n) >= 1 && n == nob)
@@ -1020,6 +1013,16 @@ static struct netstrfns libcfs_netstrfns[] = {
          .nf_match_addr        = cfs_ip_addr_match,
          .nf_is_contiguous     = cfs_ip_is_contiguous,
          .nf_min_max           = cfs_ip_min_max },
+       { .nf_type              = PTL4LND,
+         .nf_name              = "ptlf",
+         .nf_modname           = "kptl4lnd",
+         .nf_addr2str          = libcfs_decnum_addr2str,
+         .nf_str2addr          = libcfs_num_str2addr,
+         .nf_parse_addrlist    = libcfs_num_parse,
+         .nf_print_addrlist    = libcfs_num_addr_range_print,
+         .nf_match_addr        = libcfs_num_match,
+         .nf_is_contiguous     = cfs_num_is_contiguous,
+         .nf_min_max           = cfs_num_min_max},
 };
 
 static const size_t libcfs_nnetstrfns = ARRAY_SIZE(libcfs_netstrfns);
@@ -1040,7 +1043,7 @@ static struct netstrfns *
 libcfs_namenum2netstrfns(const char *name)
 {
        struct netstrfns *nf;
-       int               i;
+       int               i;
 
        for (i = 0; i < libcfs_nnetstrfns; i++) {
                nf = &libcfs_netstrfns[i];
@@ -1210,10 +1213,10 @@ EXPORT_SYMBOL(libcfs_str2net);
 lnet_nid_t
 libcfs_str2nid(const char *str)
 {
-       const char       *sep = strchr(str, '@');
+       const char       *sep = strchr(str, '@');
        struct netstrfns *nf;
-       __u32             net;
-       __u32             addr;
+       __u32             net;
+       __u32             addr;
 
        if (sep != NULL) {
                nf = libcfs_str2net_internal(sep + 1, &net);