Whamcloud - gitweb
- we could call this "merely a merge from b_devel". Notes:
authorbraam <braam>
Tue, 8 Jul 2003 22:41:21 +0000 (22:41 +0000)
committerbraam <braam>
Tue, 8 Jul 2003 22:41:21 +0000 (22:41 +0000)
 - lprocfs is not managable
 - this oopses on mount, will be fixed soon.

57 files changed:
lnet/archdep.m4
lnet/include/config.h.in
lnet/include/linux/kp30.h
lnet/include/lnet/internal.h
lnet/include/lnet/lib-lnet.h
lnet/include/lnet/lib-p30.h
lnet/include/lnet/list.h
lnet/include/lnet/lnetctl.h
lnet/include/lnet/myrnal.h
lnet/include/lnet/nal.h
lnet/include/lnet/ppid.h
lnet/include/lnet/ptlctl.h
lnet/include/lnet/stringtab.h
lnet/klnds/qswlnd/qswlnd.c
lnet/klnds/qswlnd/qswlnd.h
lnet/klnds/qswlnd/qswlnd_cb.c
lnet/klnds/socklnd/socklnd.c
lnet/klnds/socklnd/socklnd.h
lnet/klnds/toelnd/toenal.c
lnet/klnds/toelnd/toenal_cb.c
lnet/libcfs/debug.c
lnet/libcfs/module.c
lnet/router/router.c
lnet/ulnds/connection.c
lnet/ulnds/connection.h
lnet/ulnds/socklnd/connection.c
lnet/ulnds/socklnd/connection.h
lnet/ulnds/socklnd/tcplnd.c
lnet/ulnds/tcplnd.c
lnet/utils/portals.c
lnet/utils/ptlctl.c
lustre/portals/archdep.m4
lustre/portals/include/config.h.in
lustre/portals/include/linux/kp30.h
lustre/portals/include/portals/lib-p30.h
lustre/portals/include/portals/list.h
lustre/portals/include/portals/myrnal.h
lustre/portals/include/portals/nal.h
lustre/portals/include/portals/ppid.h
lustre/portals/include/portals/ptlctl.h
lustre/portals/include/portals/stringtab.h
lustre/portals/knals/qswnal/qswnal.c
lustre/portals/knals/qswnal/qswnal.h
lustre/portals/knals/qswnal/qswnal_cb.c
lustre/portals/knals/socknal/socknal.c
lustre/portals/knals/socknal/socknal.h
lustre/portals/knals/toenal/toenal.c
lustre/portals/knals/toenal/toenal_cb.c
lustre/portals/libcfs/debug.c
lustre/portals/libcfs/module.c
lustre/portals/router/router.c
lustre/portals/unals/connection.c
lustre/portals/unals/connection.h
lustre/portals/unals/tcpnal.c
lustre/portals/utils/portals.c
lustre/portals/utils/ptlctl.c
lustre/utils/llstat.pl

index 1b93d37..16455a5 100644 (file)
@@ -111,7 +111,7 @@ case ${host_cpu} in
 
        ia64 )
        AC_MSG_RESULT($host_cpu)
-        KCFLAGS='-gstabs -O2 -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -pipe -ffixed-r13 -mfixed-range=f10-f15,f32-f127 -falign-functions=32 -mb-step'
+        KCFLAGS='-g -O2 -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -pipe -ffixed-r13 -mfixed-range=f10-f15,f32-f127 -falign-functions=32 -mb-step'
        KCPPFLAGS='-D__KERNEL__ -DMODULE'
         MOD_LINK=elf64_ia64
 ;;
@@ -224,7 +224,7 @@ else
   AC_MSG_RESULT(no)
 fi
 
-AC_ARG_ENABLE(zerocopy, [  --enable-zerocopy enable socknal zerocopy],enable_zerocopy="-DSOCKNAL_ZC=1", enable_zercopy=$enable_zerocopy_temp)
+AC_ARG_ENABLE(zerocopy, [  --enable-zerocopy enable socknal zerocopy],enable_zerocopy=$enable_zerocopy_temp, enable_zerocopy="")
 
 AC_ARG_ENABLE(affinity, [  --enable-affinity enable process/irq affinity],enable_affinity="-DCPU_AFFINITY=1", enable_affinity=$enable_affinity_temp)
 #####################################
index b05d0c4..3aa6909 100644 (file)
@@ -1,11 +1,58 @@
-/* ../include/config.h.in.  Generated automatically from configure.in by autoheader.  */
+/* portals/include/config.h.in.  Generated from configure.in by autoheader.  */
 
-/* Define if you have the readline library (-lreadline).  */
-#undef HAVE_LIBREADLINE
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* IOCTL Buffer Size */
+#undef OBD_MAX_IOCTL_BUFFER
 
 /* Name of package */
 #undef PACKAGE
 
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* The size of a `unsigned long long', as computed by sizeof. */
+#undef SIZEOF_UNSIGNED_LONG_LONG
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
 /* Version number of package */
 #undef VERSION
-
index 1555f78..9f30cce 100644 (file)
@@ -78,14 +78,21 @@ extern unsigned int portal_printk;
 
 #ifdef __KERNEL__
 # include <linux/sched.h> /* THREAD_SIZE */
-
-#ifdef  __ia64__
-#define CDEBUG_STACK ((unsigned long)__builtin_dwarf_cfa()&(THREAD_SIZE - 1))
 #else
-#define CDEBUG_STACK (THREAD_SIZE -                                      \
+# define THREAD_SIZE 8192
+#endif 
+
+#ifdef __KERNEL__
+
+# ifdef  __ia64__
+#  define CDEBUG_STACK (THREAD_SIZE -                                      \
+                        ((unsigned long)__builtin_dwarf_cfa() &            \
+                         (THREAD_SIZE - 1)))
+# else
+#  define CDEBUG_STACK (THREAD_SIZE -                                      \
                         ((unsigned long)__builtin_frame_address(0) &       \
                          (THREAD_SIZE - 1)))
-#endif
+# endif
 
 #define CHECK_STACK(stack)                                                    \
         do {                                                                  \
@@ -98,21 +105,21 @@ extern unsigned int portal_printk;
                       /*panic("LBUG");*/                                      \
                 }                                                             \
         } while (0)
-#else
-#define CHECK_STACK(stack) do{}while(0)
+#else /* __KERNEL__ */
+#define CHECK_STACK(stack) do { } while(0)
 #define CDEBUG_STACK (0L)
-#endif
+#endif /* __KERNEL__ */
 
 #if 1
 #define CDEBUG(mask, format, a...)                                            \
 do {                                                                          \
-        CHECK_STACK(CDEBUG_STACK);                                            \
+        CHECK_STACK(CDEBUG_STACK);                                          \
         if (!(mask) || ((mask) & (D_ERROR | D_EMERG)) ||                      \
             (portal_debug & (mask) &&                                         \
              portal_subsystem_debug & (1 << (DEBUG_SUBSYSTEM >> 24))))        \
                 portals_debug_msg(DEBUG_SUBSYSTEM, mask,                      \
                                   __FILE__, __FUNCTION__, __LINE__,           \
-                                  CDEBUG_STACK, format , ## a);               \
+                                  CDEBUG_STACK, format, ## a);              \
 } while (0)
 
 #define CWARN(format, a...) CDEBUG(D_WARNING, format, ## a)
@@ -204,8 +211,7 @@ static inline void our_cond_resched(void)
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) */
 
 #ifdef PORTAL_DEBUG
-extern void kportal_assertion_failed(char *expr, char *file,
-                                     const char *func, const int line);
+extern void kportal_assertion_failed(char *expr,char *file,const char *func,const int line);
 #define LASSERT(e) ((e) ? 0 : kportal_assertion_failed( #e , __FILE__,  \
                                                         __FUNCTION__, __LINE__))
 #else
@@ -257,28 +263,27 @@ do {                                                                          \
 
 #define PORTAL_ALLOC(ptr, size)                                           \
 do {                                                                      \
-        long s = size;                                                    \
         LASSERT (!in_interrupt());                                        \
-        if (s > PORTAL_VMALLOC_SIZE)                                      \
-                (ptr) = vmalloc(s);                                       \
+        if ((size) > PORTAL_VMALLOC_SIZE)                                 \
+                (ptr) = vmalloc(size);                                    \
         else                                                              \
-                (ptr) = kmalloc(s, GFP_KERNEL);                           \
+                (ptr) = kmalloc((size), GFP_NOFS);                        \
         if ((ptr) == NULL)                                                \
-                CERROR("PORTALS: out of memory at %s:%d (tried to alloc"  \
-                       " '" #ptr "' = %ld)\n", __FILE__, __LINE__, s);    \
+                CERROR("PORTALS: out of memory at %s:%d (tried to alloc '"\
+                       #ptr "' = %d)\n", __FILE__, __LINE__, (int)(size));\
         else {                                                            \
-                portal_kmem_inc((ptr), s);                                \
-                memset((ptr), 0, s);                                      \
+                portal_kmem_inc((ptr), (size));                           \
+                memset((ptr), 0, (size));                                 \
         }                                                                 \
-        CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %ld at %p (tot %d).\n",   \
-               s, (ptr), atomic_read (&portal_kmemory));                  \
+        CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %d at %p (tot %d).\n",    \
+               (int)(size), (ptr), atomic_read (&portal_kmemory));        \
 } while (0)
 
 #define PORTAL_FREE(ptr, size)                                          \
 do {                                                                    \
-        long s = (size);                                                \
+        int s = (size);                                                 \
         if ((ptr) == NULL) {                                            \
-                CERROR("PORTALS: free NULL '" #ptr "' (%ld bytes) at "  \
+                CERROR("PORTALS: free NULL '" #ptr "' (%d bytes) at "   \
                        "%s:%d\n", s, __FILE__, __LINE__);               \
                 break;                                                  \
         }                                                               \
@@ -287,39 +292,38 @@ do {                                                                    \
         else                                                            \
                 kfree(ptr);                                             \
         portal_kmem_dec((ptr), s);                                      \
-        CDEBUG(D_MALLOC, "kfreed '" #ptr "': %ld at %p (tot %d).\n",    \
-               s, (ptr), atomic_read (&portal_kmemory));                \
+        CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %d).\n",     \
+               s, (ptr), atomic_read(&portal_kmemory));                 \
 } while (0)
 
 #define PORTAL_SLAB_ALLOC(ptr, slab, size)                                \
 do {                                                                      \
-        long s = (size);                                                  \
-        LASSERT (!in_interrupt());                                        \
+        LASSERT(!in_interrupt());                                         \
         (ptr) = kmem_cache_alloc((slab), SLAB_KERNEL);                    \
         if ((ptr) == NULL) {                                              \
                 CERROR("PORTALS: out of memory at %s:%d (tried to alloc"  \
                        " '" #ptr "' from slab '" #slab "')\n", __FILE__,  \
                        __LINE__);                                         \
         } else {                                                          \
-                portal_kmem_inc((ptr), s);                                \
-                memset((ptr), 0, s);                                      \
+                portal_kmem_inc((ptr), (size));                           \
+                memset((ptr), 0, (size));                                 \
         }                                                                 \
         CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %ld at %p (tot %d).\n",   \
-               s, (ptr), atomic_read (&portal_kmemory));                  \
+               (int)(size), (ptr), atomic_read(&portal_kmemory));         \
 } while (0)
 
 #define PORTAL_SLAB_FREE(ptr, slab, size)                               \
 do {                                                                    \
-        long s = (size);                                                \
+        int s = (size);                                                 \
         if ((ptr) == NULL) {                                            \
-                CERROR("PORTALS: free NULL '" #ptr "' (%ld bytes) at "  \
+                CERROR("PORTALS: free NULL '" #ptr "' (%d bytes) at "   \
                        "%s:%d\n", s, __FILE__, __LINE__);               \
                 break;                                                  \
         }                                                               \
         memset((ptr), 0x5a, s);                                         \
         kmem_cache_free((slab), ptr);                                   \
         portal_kmem_dec((ptr), s);                                      \
-        CDEBUG(D_MALLOC, "kfreed '" #ptr "': %ld at %p (tot %d).\n",    \
+        CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %d).\n",     \
                s, (ptr), atomic_read (&portal_kmemory));                \
 } while (0)
 
@@ -462,8 +466,8 @@ kpr_lookup (kpr_router_t *router, ptl_nid_t nid, ptl_nid_t *gateway_nid)
 }
 
 static inline void
-kpr_fwd_init (kpr_fwd_desc_t *fwd, ptl_nid_t nid, 
-              int nob, int niov, struct iovec *iov, 
+kpr_fwd_init (kpr_fwd_desc_t *fwd, ptl_nid_t nid,
+              int nob, int niov, struct iovec *iov,
               kpr_fwd_callback_t callback, void *callback_arg)
 {
         fwd->kprfd_target_nid   = nid;
@@ -575,9 +579,8 @@ __s32 portals_debug_copy_to_user(char *buf, unsigned long len);
 # warning printf has been defined as a macro...
 # undef printf
 #endif
-void portals_debug_msg(int subsys, int mask, char *file, const char *fn, 
-                       const int line, unsigned long stack, char *format,
-                        ...)
+void portals_debug_msg (int subsys, int mask, char *file, const char *fn, const int line,
+                        unsigned long stack, const char *format, ...)
         __attribute__ ((format (printf, 7, 8)));
 #else
 void portals_debug_msg (int subsys, int mask, char *file, const char *fn,
@@ -608,7 +611,7 @@ extern void kportal_blockallsigs (void);
 # ifdef PORTAL_DEBUG
 #  undef NDEBUG
 #  include <assert.h>
-#  define LASSERT(e)   assert(e)
+#  define LASSERT(e)     assert(e)
 # else
 #  define LASSERT(e)
 # endif
@@ -621,6 +624,10 @@ extern void kportal_blockallsigs (void);
             getpid() , stack, ## a);
 #endif
 
+#ifndef CURRENT_TIME
+# define CURRENT_TIME time(0)
+#endif
+
 #include <linux/portals_lib.h>
 
 /*
@@ -908,7 +915,7 @@ void kportal_put_ni (int nal);
 #ifndef BITS_PER_LONG
 #if (~0UL) == 0xffffffffUL
 #define BITS_PER_LONG 32
-#else 
+#else
 #define BITS_PER_LONG 64
 #endif
 #endif
index d78cad4..a70b465 100644 (file)
@@ -1,5 +1,3 @@
-/*
-*/
 #ifndef _P30_INTERNAL_H_
 #define _P30_INTERNAL_H_
 
index ca92e5f..b623b93 100644 (file)
@@ -183,28 +183,28 @@ static inline lib_eq_t *
 lib_eq_alloc (nal_cb_t *nal)
 {
         /* NEVER called with statelock held */
-        lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_KERNEL);
-        
+        lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_NOFS);
+
         if (eq == NULL)
                 return (NULL);
-        
+
         atomic_inc (&eq_in_use_count);
         return (eq);
 }
 
-static inline void 
+static inline void
 lib_eq_free (nal_cb_t *nal, lib_eq_t *eq)
 {
         /* ALWAYS called with statelock held */
         atomic_dec (&eq_in_use_count);
-        kmem_cache_free(ptl_eq_slab, eq); 
+        kmem_cache_free(ptl_eq_slab, eq);
 }
 
 static inline lib_md_t *
 lib_md_alloc (nal_cb_t *nal)
 {
         /* NEVER called with statelock held */
-        lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_KERNEL); 
+        lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_NOFS);
 
         if (md == NULL)
                 return (NULL);
@@ -225,11 +225,11 @@ static inline lib_me_t *
 lib_me_alloc (nal_cb_t *nal)
 {
         /* NEVER called with statelock held */
-        lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_KERNEL);
+        lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_NOFS);
 
         if (me == NULL)
                 return (NULL);
-        
+
         atomic_inc (&me_in_use_count);
         return (me);
 }
index ca92e5f..b623b93 100644 (file)
@@ -183,28 +183,28 @@ static inline lib_eq_t *
 lib_eq_alloc (nal_cb_t *nal)
 {
         /* NEVER called with statelock held */
-        lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_KERNEL);
-        
+        lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_NOFS);
+
         if (eq == NULL)
                 return (NULL);
-        
+
         atomic_inc (&eq_in_use_count);
         return (eq);
 }
 
-static inline void 
+static inline void
 lib_eq_free (nal_cb_t *nal, lib_eq_t *eq)
 {
         /* ALWAYS called with statelock held */
         atomic_dec (&eq_in_use_count);
-        kmem_cache_free(ptl_eq_slab, eq); 
+        kmem_cache_free(ptl_eq_slab, eq);
 }
 
 static inline lib_md_t *
 lib_md_alloc (nal_cb_t *nal)
 {
         /* NEVER called with statelock held */
-        lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_KERNEL); 
+        lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_NOFS);
 
         if (md == NULL)
                 return (NULL);
@@ -225,11 +225,11 @@ static inline lib_me_t *
 lib_me_alloc (nal_cb_t *nal)
 {
         /* NEVER called with statelock held */
-        lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_KERNEL);
+        lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_NOFS);
 
         if (me == NULL)
                 return (NULL);
-        
+
         atomic_inc (&me_in_use_count);
         return (me);
 }
index 2b63312..78a1e2d 100644 (file)
@@ -1,6 +1,4 @@
 #ifndef _LINUX_LIST_H
-#define _LINUX_LIST_H
-
 
 /*
  * Simple doubly linked list implementation.
@@ -101,7 +99,9 @@ static inline void list_del_init(struct list_head *entry)
        __list_del(entry->prev, entry->next);
        INIT_LIST_HEAD(entry);
 }
+#endif
 
+#ifndef list_for_each_entry
 /**
  * list_move - delete from one list and add as another's head
  * @list: the entry to move
@@ -124,7 +124,10 @@ static inline void list_move_tail(struct list_head *list,
        __list_del(list->prev, list->next);
        list_add_tail(list, head);
 }
+#endif
 
+#ifndef _LINUX_LIST_H
+#define _LINUX_LIST_H
 /**
  * list_empty - tests whether a list is empty
  * @head: the list to test.
index fdaae69..dc02780 100644 (file)
@@ -38,6 +38,7 @@ int jt_ptl_connect(int argc, char **argv);
 int jt_ptl_disconnect(int argc, char **argv);
 int jt_ptl_push_connection(int argc, char **argv);
 int jt_ptl_ping(int argc, char **argv);
+int jt_ptl_shownid(int argc, char **argv);
 int jt_ptl_mynid(int argc, char **argv);
 int jt_ptl_add_uuid(int argc, char **argv);
 int jt_ptl_add_uuid_old(int argc, char **argv); /* backwards compatibility  */
index 12b1925..13790f7 100644 (file)
@@ -1,6 +1,3 @@
-/*
-*/
-
 #ifndef MYRNAL_H
 #define MYRNAL_H
 
index 88be63c..7cb3ab7 100644 (file)
@@ -1,5 +1,3 @@
-/*
-*/
 #ifndef _NAL_H_
 #define _NAL_H_
 
index 4727599..760f465 100644 (file)
@@ -1,6 +1,3 @@
-/*
- */
-
 #ifndef _INCppidh_
 #define _INCppidh_
 
index fdaae69..dc02780 100644 (file)
@@ -38,6 +38,7 @@ int jt_ptl_connect(int argc, char **argv);
 int jt_ptl_disconnect(int argc, char **argv);
 int jt_ptl_push_connection(int argc, char **argv);
 int jt_ptl_ping(int argc, char **argv);
+int jt_ptl_shownid(int argc, char **argv);
 int jt_ptl_mynid(int argc, char **argv);
 int jt_ptl_add_uuid(int argc, char **argv);
 int jt_ptl_add_uuid_old(int argc, char **argv); /* backwards compatibility  */
index c9683f7..33e4375 100644 (file)
@@ -1,5 +1,3 @@
 /*
-*/
-/*
  * stringtab.h
  */
index 0def863..1a8fb74 100644 (file)
@@ -101,17 +101,37 @@ static nal_t *
 kqswnal_init(int interface, ptl_pt_index_t ptl_size, ptl_ac_index_t ac_size,
             ptl_pid_t requested_pid)
 {
-       ptl_nid_t mynid = ep_nodeid (kqswnal_data.kqn_epdev);
-       int       nnids = ep_numnodes (kqswnal_data.kqn_epdev);
+       ptl_nid_t mynid = kqswnal_elanid2nid (kqswnal_data.kqn_elanid);
+       int       nnids = kqswnal_data.kqn_nnodes;
 
-        CDEBUG(D_NET, "calling lib_init with nid "LPX64" of %d\n", mynid,nnids);
+        CDEBUG(D_NET, "calling lib_init with nid "LPX64" of %d\n", mynid, nnids);
 
        lib_init(&kqswnal_lib, mynid, 0, nnids, ptl_size, ac_size);
 
        return (&kqswnal_api);
 }
 
-void /*__exit*/
+int
+kqswnal_cmd (struct portal_ioctl_data *data, void *private)
+{
+       LASSERT (data != NULL);
+       
+       switch (data->ioc_nal_cmd) {
+       case NAL_CMD_REGISTER_MYNID:
+               CDEBUG (D_IOCTL, "setting NID offset to "LPX64" (was "LPX64")\n",
+                       data->ioc_nid - kqswnal_data.kqn_elanid,
+                       kqswnal_data.kqn_nid_offset);
+               kqswnal_data.kqn_nid_offset =
+                       data->ioc_nid - kqswnal_data.kqn_elanid;
+               kqswnal_lib.ni.nid = data->ioc_nid;
+               return (0);
+               
+       default:
+               return (-EINVAL);
+       }
+}
+
+void __exit
 kqswnal_finalise (void)
 {
        switch (kqswnal_data.kqn_init)
@@ -324,6 +344,10 @@ kqswnal_initialise (void)
                return (-ENOMEM);
        }
 
+       kqswnal_data.kqn_nid_offset = 0;
+       kqswnal_data.kqn_nnodes     = ep_numnodes (kqswnal_data.kqn_epdev);
+       kqswnal_data.kqn_elanid     = ep_nodeid (kqswnal_data.kqn_epdev);
+       
        /**********************************************************************/
        /* Get the transmitter */
 
@@ -477,7 +501,7 @@ kqswnal_initialise (void)
                LASSERT (krx->krx_npages > 0);
                for (j = 0; j < krx->krx_npages; j++)
                {
-                       krx->krx_pages[j] = alloc_page (GFP_KERNEL);
+                       krx->krx_pages[j] = alloc_page(GFP_KERNEL);
                        if (krx->krx_pages[j] == NULL)
                        {
                                kqswnal_finalise ();
@@ -554,13 +578,19 @@ kqswnal_initialise (void)
        rc = kpr_register (&kqswnal_data.kqn_router, &kqswnal_router_interface);
        CDEBUG(D_NET, "Can't initialise routing interface (rc = %d): not routing\n",rc);
 
+       rc = kportal_nal_register (QSWNAL, &kqswnal_cmd, NULL);
+       if (rc != 0) {
+               CERROR ("Can't initialise command interface (rc = %d)\n", rc);
+               kqswnal_finalise ();
+               return (rc);
+       }
+
        PORTAL_SYMBOL_REGISTER(kqswnal_ni);
        kqswnal_data.kqn_init = KQN_INIT_ALL;
 
        printk(KERN_INFO "Routing QSW NAL loaded on node %d of %d "
               "(Routing %s, initial mem %d)\n", 
-              ep_nodeid (kqswnal_data.kqn_epdev),
-              ep_numnodes (kqswnal_data.kqn_epdev),
+              kqswnal_data.kqn_elanid, kqswnal_data.kqn_nnodes,
               kpr_routing (&kqswnal_data.kqn_router) ? "enabled" : "disabled",
               pkmem);
 
index 657b02b..85e585b 100644 (file)
@@ -104,7 +104,7 @@ typedef unsigned long kqsw_csum_t;
 #define KQSW_TX_MAXCONTIG              (1<<10) /* largest payload that gets made contiguous on transmit */
 
 #define KQSW_NTXMSGS                   8       /* # normal transmit messages */
-#define KQSW_NNBLK_TXMSGS              128     /* # reserved transmit messages if can't block */
+#define KQSW_NNBLK_TXMSGS              256     /* # reserved transmit messages if can't block */
 
 #define KQSW_NRXMSGS_LARGE             64      /* # large receive buffers */
 #define KQSW_EP_ENVELOPES_LARGE        128     /* # large ep envelopes */
@@ -200,6 +200,10 @@ typedef struct
        ELAN3_DMA_HANDLE  *kqn_eptxdmahandle;   /* elan reserved tx vaddrs */
        ELAN3_DMA_HANDLE  *kqn_eprxdmahandle;   /* elan reserved rx vaddrs */
         kpr_router_t       kqn_router;          /* connection to Kernel Portals Router module */
+
+        ptl_nid_t          kqn_nid_offset;      /* this cluster's NID offset */
+        int                kqn_nnodes;          /* this cluster's size */
+        int                kqn_elanid;          /* this nodes's elan ID */
 }  kqswnal_data_t;
 
 /* kqn_init state */
@@ -217,6 +221,23 @@ extern void kqswnal_rxhandler(EP_RXD *rxd);
 extern int kqswnal_scheduler (void *);
 extern void kqswnal_fwd_packet (void *arg, kpr_fwd_desc_t *fwd);
 
+static inline ptl_nid_t
+kqswnal_elanid2nid (int elanid) 
+{
+        return (kqswnal_data.kqn_nid_offset + elanid);
+}
+
+static inline int
+kqswnal_nid2elanid (ptl_nid_t nid) 
+{
+        /* not in this cluster? */
+        if (nid < kqswnal_data.kqn_nid_offset ||
+            nid >= kqswnal_data.kqn_nid_offset + kqswnal_data.kqn_nnodes)
+                return (-1);
+        
+        return (nid - kqswnal_data.kqn_nid_offset);
+}
+
 static inline void
 kqswnal_requeue_rx (kqswnal_rx_t *krx)
 {
index 5979885..c03d592 100644 (file)
@@ -109,21 +109,15 @@ kqswnal_sti(nal_cb_t *nal, unsigned long *flags)
 static int
 kqswnal_dist(nal_cb_t *nal, ptl_nid_t nid, unsigned long *dist)
 {
-        /* network distance doesn't mean much for this nal */
-        *dist = (nid == nal->ni.nid) ? 0 : 1;
+        if (nid == nal->ni.nid)
+                *dist = 0;                      /* it's me */
+        else if (kqswnal_nid2elanid (nid) >= 0)
+                *dist = 1;                      /* it's my peer */
+        else
+                *dist = 2;                      /* via router */
         return (0);
 }
 
-int
-kqswnal_ispeer (ptl_nid_t nid)
-{
-        unsigned int elanid = (unsigned int)nid;
-
-        /* didn't lose high bits on conversion and it's in this machine? */
-        return ((ptl_nid_t)elanid == nid &&
-                elanid < ep_numnodes (kqswnal_data.kqn_epdev));
-}
-
 void
 kqswnal_unmap_tx (kqswnal_tx_t *ktx)
 {
@@ -453,11 +447,14 @@ kqswnal_launch (kqswnal_tx_t *ktx)
 {
         /* Don't block for transmit descriptor if we're in interrupt context */
         int   attr = in_interrupt() ? (EP_NO_SLEEP | EP_NO_ALLOC) : 0;
-        int   rc   = ep_transmit_large(kqswnal_data.kqn_eptx, ktx->ktx_nid,
-                                       ktx->ktx_port, attr, kqswnal_txhandler,
-                                       ktx, ktx->ktx_iov, ktx->ktx_niov);
+        int   dest = kqswnal_nid2elanid (ktx->ktx_nid);
         long  flags;
-
+        int   rc;
+        
+        LASSERT (dest >= 0);                    /* must be a peer */
+        rc = ep_transmit_large(kqswnal_data.kqn_eptx, dest,
+                               ktx->ktx_port, attr, kqswnal_txhandler,
+                               ktx, ktx->ktx_iov, ktx->ktx_niov);
         if (rc == 0)
                 atomic_inc (&kqswnal_packets_launched);
 
@@ -595,7 +592,7 @@ kqswnal_sendmsg (nal_cb_t     *nal,
                 return (-1);
         }
 
-        if (!kqswnal_ispeer (nid)) {     /* Can't send direct: find gateway? */
+        if (kqswnal_nid2elanid (nid) < 0) {     /* Can't send direct: find gateway? */
                 rc = kpr_lookup (&kqswnal_data.kqn_router, nid, &gatewaynid);
                 if (rc != 0) {
                         CERROR("Can't route to "LPX64": router error %d\n",
@@ -603,7 +600,7 @@ kqswnal_sendmsg (nal_cb_t     *nal,
                         lib_finalize (&kqswnal_lib, private, cookie);
                         return (-1);
                 }
-                if (!kqswnal_ispeer (gatewaynid)) {
+                if (kqswnal_nid2elanid (gatewaynid) < 0) {
                         CERROR("Bad gateway "LPX64" for "LPX64"\n",
                                gatewaynid, nid);
                         lib_finalize (&kqswnal_lib, private, cookie);
@@ -620,6 +617,7 @@ kqswnal_sendmsg (nal_cb_t     *nal,
         if (ktx == NULL) {
                 kqswnal_cerror_hdr (hdr);
                 lib_finalize (&kqswnal_lib, private, cookie);
+                return (-1);
         }
 
         memcpy (ktx->ktx_buffer, hdr, sizeof (*hdr)); /* copy hdr from caller's stack */
@@ -757,7 +755,7 @@ kqswnal_fwd_packet (void *arg, kpr_fwd_desc_t *fwd)
         if (nid == kqswnal_lib.ni.nid)          /* gateway is me */
                 nid = fwd->kprfd_target_nid;    /* target is final dest */
 
-        if (!kqswnal_ispeer (nid)) {
+        if (kqswnal_nid2elanid (nid) < 0) {
                 CERROR("Can't forward [%p] to "LPX64": not a peer\n", fwd, nid);
                 rc = -EHOSTUNREACH;
                 goto failed;
@@ -844,7 +842,7 @@ kqswnal_rx (kqswnal_rx_t *krx)
         CERROR ("checksums for forwarded packets not implemented\n");
         LBUG ();
 #endif
-        if (kqswnal_ispeer (dest_nid))  /* should have gone direct to peer */
+        if (kqswnal_nid2elanid (dest_nid) >= 0)  /* should have gone direct to peer */
         {
                 CERROR("dropping packet from "LPX64" for "LPX64
                        ": target is peer\n", NTOH__u64(hdr->src_nid), dest_nid);
index da2b453..fe24e03 100644 (file)
@@ -95,10 +95,8 @@ nal_t *
 ksocknal_init(int interface, ptl_pt_index_t ptl_size,
               ptl_ac_index_t ac_size, ptl_pid_t requested_pid)
 {
-        CDEBUG(D_NET, "calling lib_init with nid "LPX64"\n",
-               ksocknal_data.ksnd_mynid);
-        lib_init(&ksocknal_lib, ksocknal_data.ksnd_mynid, 0, 10, ptl_size,
-                 ac_size);
+        CDEBUG(D_NET, "calling lib_init with nid "LPX64"\n", (ptl_nid_t)0);
+        lib_init(&ksocknal_lib, (ptl_nid_t)0, 0, 10, ptl_size, ac_size);
         return (&ksocknal_api);
 }
 
@@ -129,7 +127,6 @@ ksocknal_set_mynid(ptl_nid_t nid)
         CDEBUG(D_IOCTL, "setting mynid to "LPX64" (old nid="LPX64")\n",
                nid, ni->nid);
 
-        ksocknal_data.ksnd_mynid = nid;
         ni->nid = nid;
         return (0);
 }
@@ -190,7 +187,7 @@ ksocknal_add_sock (ptl_nid_t nid, int fd, int bind_irq)
         if (!conn)
                 GOTO(error, ret);
 
-        memset (conn, 0, sizeof (conn));        /* zero for consistency */
+#warning ZAB: fix me for 2.5 sock->sk->allocation = GFP_NOFS;    /* don't call info fs for alloc */
 
         conn->ksnc_file = file;
         conn->ksnc_sock = sock;
@@ -809,7 +806,7 @@ ksocknal_module_init (void)
 
                         LASSERT (fmb->fmb_npages > 0);
                         for (j = 0; j < fmb->fmb_npages; j++) {
-                                fmb->fmb_pages[j] = alloc_page (GFP_KERNEL);
+                                fmb->fmb_pages[j] = alloc_page(GFP_KERNEL);
 
                                 if (fmb->fmb_pages[j] == NULL) {
                                         ksocknal_module_fini ();
index f959889..188d1f2 100644 (file)
@@ -115,7 +115,6 @@ typedef struct {
         struct list_head  ksnd_socklist;        /* all my connections */
         rwlock_t          ksnd_socklist_lock;   /* stabilise add/find/remove */
 
-        ptl_nid_t         ksnd_mynid;
         nal_cb_t         *ksnd_nal_cb;
         spinlock_t        ksnd_nal_cb_lock;     /* lib cli/sti lock */
 
index 7adebf8..77ee473 100644 (file)
@@ -522,7 +522,7 @@ ktoenal_module_init (void)
                 LASSERT (fmb->fmb_npages > 0);
                 for (j = 0; j < fmb->fmb_npages; j++)
                 {
-                        fmb->fmb_pages[j] = alloc_page (GFP_KERNEL);
+                        fmb->fmb_pages[j] = alloc_page(GFP_KERNEL);
 
                         if (fmb->fmb_pages[j] == NULL)
                         {
index e5d2eef..abd0731 100644 (file)
@@ -423,11 +423,10 @@ ktoenal_send(nal_cb_t *nal, void *private, lib_msg_t *cookie,
          * packet as a side-effect of another packet, such as when an ACK has
          * been requested. -phil */
 
-        CDEBUG(D_NET, "sending "LPSZ" bytes from [%d](%p,%d)... to nid: "LPX64" pid %d\n",
-               payload_len, payload_niov,
+        CDEBUG(D_NET, "sending %d bytes from [%d](%p,%d)... to nid: "
+               LPX64" pid %d\n", (int)payload_len, payload_niov,
                payload_niov > 0 ? payload_iov[0].iov_base : NULL,
-               payload_niov > 0 ? payload_iov[0].iov_len  : 0,
-               nid, pid);
+               (int)(payload_niov > 0 ? payload_iov[0].iov_len : 0), nid, pid);
 
         if ((conn = ktoenal_get_conn (nid)) == NULL)
         {
index 2409812..6cdf101 100644 (file)
@@ -673,8 +673,8 @@ __s32 portals_debug_copy_to_user(char *buf, unsigned long len)
 
 /* FIXME: I'm not very smart; someone smarter should make this better. */
 void
-portals_debug_msg (int subsys, int mask, char *file, const char *fn, 
-                   const int line, unsigned long stack, char *format, ...)
+portals_debug_msg (int subsys, int mask, char *file, const char *fn, const int line,
+                   unsigned long stack, const char *format, ...)
 {
         va_list       ap;
         unsigned long flags;
@@ -804,7 +804,7 @@ void portals_run_lbug_upcall(char * file, const char *fn, const int line)
         argv[0] = portals_upcall;
         argv[1] = "LBUG";
         argv[2] = file;
-        argv[3] = (char *)fn;
+        argv[3] = fn;
         argv[4] = buf;
         argv[5] = NULL;
 
index e9f4545..f37d1e7 100644 (file)
@@ -47,6 +47,7 @@
 #include <portals/lib-p30.h>
 #include <portals/p30.h>
 #include <linux/kp30.h>
+#include <linux/portals_compat25.h>
 #include <linux/kernel_compat.h>
 
 #define PORTAL_MINOR 240
@@ -62,7 +63,7 @@ static struct nal_cmd_handler nal_cmd[NAL_MAX_NR + 1];
 struct semaphore nal_cmd_sem;
 
 #ifdef PORTAL_DEBUG
-void kportal_assertion_failed(char *expr, char *file, const char *func, 
+void kportal_assertion_failed(char *expr, char *file,  const char *func, 
                               const int line)
 {
         portals_debug_msg(0, D_EMERG, file, func, line, CDEBUG_STACK,
@@ -429,6 +430,7 @@ static int kportal_ioctl(struct inode *inode, struct file *file,
                         return (-EINVAL);
 
                 err = PtlFailNid (*nip, data->ioc_nid, data->ioc_count);
+                kportal_put_ni (data->ioc_nal);
                 break;
         }
 
index 6ba5e53..27a7fba 100644 (file)
@@ -202,15 +202,15 @@ kpr_forward_packet (void *arg, kpr_fwd_desc_t *fwd)
         LASSERT (nob == lib_iov_nob (fwd->kprfd_niov, fwd->kprfd_iov));
         
         atomic_inc (&kpr_queue_depth);
+       atomic_inc (&src_ne->kpne_refcount); /* source nal is busy until fwd completes */
 
         kpr_fwd_packets++;                   /* (loose) stats accounting */
         kpr_fwd_bytes += nob;
 
-       if (src_ne->kpne_shutdown)                      /* caller is shutting down */
+       if (src_ne->kpne_shutdown)           /* caller is shutting down */
                goto out;
 
-       fwd->kprfd_router_arg = src_ne;         /* stash caller's nal entry */
-       atomic_inc (&src_ne->kpne_refcount);    /* source nal is busy until fwd completes */
+       fwd->kprfd_router_arg = src_ne;      /* stash caller's nal entry */
 
        read_lock (&kpr_rwlock);
 
index 89c9f78..310e899 100644 (file)
@@ -120,9 +120,10 @@ int read_connection(connection c,
     return(1);
 }
 
-static int connection_input(connection c)
+static int connection_input(void *d)
 {
-    return((*c->m->handler)(c->m->handler_arg,c));
+        connection c = d;
+        return((*c->m->handler)(c->m->handler_arg,c));
 }
 
 
@@ -280,7 +281,7 @@ void shutdown_connections(manager m)
  *          zero if the fixed port could not be bound
  */
 manager init_connections(unsigned short pid,
-                         int (*input)(),
+                         int (*input)(void *, void *),
                          void *a)
 {
     manager m=(manager)malloc(sizeof(struct manager));
index f6b2994..6f57287 100644 (file)
@@ -25,14 +25,8 @@ typedef struct connection {
     manager m;
 } *connection;
 
-connection force_tcp_connection(manager m,
-                                unsigned int ip,  
-                               unsigned int short);
-manager init_connections(unsigned short,
-                         int (*f)(void *,connection),
-                         void *);
+connection force_tcp_connection(manager m, unsigned int ip, unsigned int short);
+manager init_connections(unsigned short, int (*f)(void *, void *), void *);
 void remove_connection(void *arg);
 void shutdown_connections(manager m);
-int read_connection(connection c,
-                    unsigned char *dest,
-                    int len);
+int read_connection(connection c, unsigned char *dest, int len);
index 89c9f78..310e899 100644 (file)
@@ -120,9 +120,10 @@ int read_connection(connection c,
     return(1);
 }
 
-static int connection_input(connection c)
+static int connection_input(void *d)
 {
-    return((*c->m->handler)(c->m->handler_arg,c));
+        connection c = d;
+        return((*c->m->handler)(c->m->handler_arg,c));
 }
 
 
@@ -280,7 +281,7 @@ void shutdown_connections(manager m)
  *          zero if the fixed port could not be bound
  */
 manager init_connections(unsigned short pid,
-                         int (*input)(),
+                         int (*input)(void *, void *),
                          void *a)
 {
     manager m=(manager)malloc(sizeof(struct manager));
index f6b2994..6f57287 100644 (file)
@@ -25,14 +25,8 @@ typedef struct connection {
     manager m;
 } *connection;
 
-connection force_tcp_connection(manager m,
-                                unsigned int ip,  
-                               unsigned int short);
-manager init_connections(unsigned short,
-                         int (*f)(void *,connection),
-                         void *);
+connection force_tcp_connection(manager m, unsigned int ip, unsigned int short);
+manager init_connections(unsigned short, int (*f)(void *, void *), void *);
 void remove_connection(void *arg);
 void shutdown_connections(manager m);
-int read_connection(connection c,
-                    unsigned char *dest,
-                    int len);
+int read_connection(connection c, unsigned char *dest, int len);
index 8bf55c4..534fc17 100644 (file)
@@ -151,15 +151,17 @@ int tcpnal_recv(nal_cb_t *n,
  *  available. It attempts to read the portals header and 
  *  pass it to the generic library for processing.
  */
-static int from_connection(void *a,connection c)
+static int from_connection(void *a, void *d)
 {
-    bridge b=a;
-    ptl_hdr_t hdr;
-    if (read_connection(c, (unsigned char *)&hdr, sizeof(hdr))){
-        lib_parse(b->nal_cb, &hdr, c);
-        return(1);
-    }
-    return(0);
+        connection c = d;
+        bridge b=a;
+        ptl_hdr_t hdr;
+
+        if (read_connection(c, (unsigned char *)&hdr, sizeof(hdr))){
+                lib_parse(b->nal_cb, &hdr, c);
+                return(1);
+        }
+        return(0);
 }
 
 
index 8bf55c4..534fc17 100644 (file)
@@ -151,15 +151,17 @@ int tcpnal_recv(nal_cb_t *n,
  *  available. It attempts to read the portals header and 
  *  pass it to the generic library for processing.
  */
-static int from_connection(void *a,connection c)
+static int from_connection(void *a, void *d)
 {
-    bridge b=a;
-    ptl_hdr_t hdr;
-    if (read_connection(c, (unsigned char *)&hdr, sizeof(hdr))){
-        lib_parse(b->nal_cb, &hdr, c);
-        return(1);
-    }
-    return(0);
+        connection c = d;
+        bridge b=a;
+        ptl_hdr_t hdr;
+
+        if (read_connection(c, (unsigned char *)&hdr, sizeof(hdr))){
+                lib_parse(b->nal_cb, &hdr, c);
+                return(1);
+        }
+        return(0);
 }
 
 
index 8235271..90d66f5 100644 (file)
@@ -106,13 +106,6 @@ nal2name (int nal)
         return ((e == NULL) ? "???" : e->name);
 }
 
-static int
-nid2nal (ptl_nid_t nid)
-{
-        /* BIG pragmatic assumption */
-        return ((((__u32)nid) & 0xffff0000) != 0 ? SOCKNAL : QSWNAL);
-}
-
 int
 ptl_parse_nid (ptl_nid_t *nidp, char *str)
 {
@@ -160,35 +153,15 @@ ptl_parse_nid (ptl_nid_t *nidp, char *str)
 char *
 ptl_nid2str (char *buffer, ptl_nid_t nid)
 {
-        switch (nid2nal(nid))
-        {
-        case QSWNAL:
-                sprintf (buffer, LPD64, nid);
-                return (buffer);
+        __u32           addr = htonl((__u32)nid); /* back to NETWORK byte order */
+        struct hostent *he = gethostbyaddr ((const char *)&addr, sizeof (addr), AF_INET);
 
-        case SCIMACNAL:
-                sprintf (buffer, LPX64, nid);
-                return (buffer);
-                
-        case SOCKNAL: {
-                __u32           addr = htonl((__u32)nid); /* back to NETWORK byte order */
-                struct hostent *he = gethostbyaddr ((const char *)&addr, sizeof (addr), AF_INET);
-                
-                if (he != NULL)
-                        strcpy (buffer, he->h_name);
-                else
-                {
-                        addr = (__u32)nid;
-                        sprintf (buffer, "%d.%d.%d.%d", 
-                                 (addr>>24)&0xff, (addr>>16)&0xff, (addr>>8)&0xff, addr&0xff);
-                }
-                return (buffer);
-        }
+        if (he != NULL)
+                strcpy (buffer, he->h_name);
+        else
+                sprintf (buffer, "0x"LPX64, nid);
         
-        default:
-                sprintf (buffer, "nid2nal broken");
-                return (buffer);
-        }
+        return (buffer);
 }
 
 int
@@ -704,18 +677,43 @@ int jt_ptl_ping(int argc, char **argv)
         return 0;
 }
 
+int jt_ptl_shownid(int argc, char **argv)
+{
+        struct portal_ioctl_data data;
+        int                      rc;
+        
+        if (argc > 1) {
+                fprintf(stderr, "usage: %s\n", argv[0]);
+                return 0;
+        }
+        
+        if (g_nal == 0) {
+                fprintf(stderr, "Error: you must run the 'network' command first\n");
+                return -1;
+        }
+        
+        PORTAL_IOC_INIT (data);
+        data.ioc_nal = g_nal;
+        rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_GET_NID, &data);
+        if (rc < 0)
+                fprintf(stderr, "getting my NID failed: %s\n",
+                        strerror (errno));
+        else
+                printf(LPX64"\n", data.ioc_nid);
+        return 0;
+}
+
 int jt_ptl_mynid(int argc, char **argv)
 {
         int rc;
-        struct hostent *h;
-        char buf[1024], *hostname;
+        char hostname[1024];
+        char *nidstr;
         struct portal_ioctl_data data;
         ptl_nid_t mynid;
         
         if (argc > 2) {
-                fprintf(stderr, "usage: %s [hostname]\n", argv[0]);
-                fprintf(stderr, "hostname defaults to the hostname of the "
-                        "machine.\n");
+                fprintf(stderr, "usage: %s [NID]\n", argv[0]);
+                fprintf(stderr, "NID defaults to the primary IP address of the machine.\n");
                 return 0;
         }
 
@@ -725,42 +723,21 @@ int jt_ptl_mynid(int argc, char **argv)
                 return -1;
         }
 
-        if (g_nal == QSWNAL) {
-                fprintf(stderr, "'mynid' doesn't make any sense for elan.\n");
-                return -1;
-        } else  if (g_nal == GMNAL) {
-                fprintf(stderr, "'mynid' doesn't make any sense for GM.\n");
-                return -1;
-        } else  if (g_nal == SCIMACNAL) {
-                fprintf(stderr, "'mynid' doesn't make any sense for SCI.\n");
-                return -1;
-        } 
-        
-        if (g_nal != SOCKNAL && g_nal != TOENAL) {
-                fprintf(stderr, "This should never happen.  Also it is very "
-                        "bad.\n");
+        if (argc >= 2)
+                nidstr = argv[1];
+        else if (gethostname(hostname, sizeof(hostname)) != 0) {
+                fprintf(stderr, "gethostname failed: %s\n",
+                        strerror(errno));
                 return -1;
         }
+        else
+                nidstr = hostname;
 
-        if (argc == 1) {
-                if (gethostname(buf, sizeof(buf)) != 0) {
-                        fprintf(stderr, "gethostname failed: %s\n",
-                                strerror(errno));
-                        return -1;
-                }
-                hostname = buf;
-        } else {
-                hostname = argv[1];
-        }
-
-        h = gethostbyname(hostname);
-
-        if (!h) {
-                fprintf(stderr, "cannot get address for host '%s': %d\n",
-                        hostname, h_errno);
+        rc = ptl_parse_nid (&mynid, nidstr);
+        if (rc != 0) {
+                fprintf (stderr, "Can't convert '%s' into a NID\n", nidstr);
                 return -1;
         }
-        mynid = (ptl_nid_t)ntohl (*(__u32 *)h->h_addr);      /* HOST byte order */
         
         PORTAL_IOC_INIT(data);
         data.ioc_nid = mynid;
@@ -769,7 +746,7 @@ int jt_ptl_mynid(int argc, char **argv)
 
         rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data);
         if (rc < 0)
-                fprintf(stderr, "IOC_PORTAL_REGISTER_MYNID failed: %s\n",
+                fprintf(stderr, "setting my NID failed: %s\n",
                        strerror(errno));
         else
                 printf("registered my nid "LPX64" (%s)\n", mynid, hostname);
@@ -888,7 +865,6 @@ jt_ptl_add_route (int argc, char **argv)
         ptl_nid_t                nid1;
         ptl_nid_t                nid2;
         ptl_nid_t                gateway_nid;
-        int                      gateway_nal;
         int                      rc;
         
         if (argc < 3)
@@ -897,14 +873,18 @@ jt_ptl_add_route (int argc, char **argv)
                 return (0);
         }
 
+        if (g_nal == 0) {
+                fprintf(stderr, "Error: you must run the 'network' command "
+                        "first.\n");
+                return (-1);
+        }
+
         if (ptl_parse_nid (&gateway_nid, argv[1]) != 0)
         {
                 fprintf (stderr, "Can't parse gateway NID \"%s\"\n", argv[1]);
                 return (-1);
         }
 
-        gateway_nal = nid2nal (gateway_nid);
-
         if (ptl_parse_nid (&nid1, argv[2]) != 0)
         {
                 fprintf (stderr, "Can't parse first target NID \"%s\"\n", argv[2]);
@@ -921,7 +901,7 @@ jt_ptl_add_route (int argc, char **argv)
 
         PORTAL_IOC_INIT(data);
         data.ioc_nid = gateway_nid;
-        data.ioc_nal = gateway_nal;
+        data.ioc_nal = g_nal;
         data.ioc_nid2 = MIN (nid1, nid2);
         data.ioc_nid3 = MAX (nid1, nid2);
 
index d38bd4a..8c56d93 100644 (file)
@@ -34,6 +34,7 @@ command_t list[] = {
         {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid (args: [hostname]"},
         {"push", jt_ptl_push_connection, 0, "flush connection to a remote nid (args: [hostname]"},
         {"ping", jt_ptl_ping, 0, "do a ping test (args: nid [count] [size] [timeout])"},
+        {"shownid", jt_ptl_shownid, 0, "print the local NID"},
         {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local NID (args: [hostname])"},
         {"add_route", jt_ptl_add_route, 0, "add an entry to the routing table (args: gatewayNID targetNID [targetNID])"},
         {"del_route", jt_ptl_del_route, 0, "delete an entry from the routing table (args: targetNID"},
index 1b93d37..16455a5 100644 (file)
@@ -111,7 +111,7 @@ case ${host_cpu} in
 
        ia64 )
        AC_MSG_RESULT($host_cpu)
-        KCFLAGS='-gstabs -O2 -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -pipe -ffixed-r13 -mfixed-range=f10-f15,f32-f127 -falign-functions=32 -mb-step'
+        KCFLAGS='-g -O2 -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -pipe -ffixed-r13 -mfixed-range=f10-f15,f32-f127 -falign-functions=32 -mb-step'
        KCPPFLAGS='-D__KERNEL__ -DMODULE'
         MOD_LINK=elf64_ia64
 ;;
@@ -224,7 +224,7 @@ else
   AC_MSG_RESULT(no)
 fi
 
-AC_ARG_ENABLE(zerocopy, [  --enable-zerocopy enable socknal zerocopy],enable_zerocopy="-DSOCKNAL_ZC=1", enable_zercopy=$enable_zerocopy_temp)
+AC_ARG_ENABLE(zerocopy, [  --enable-zerocopy enable socknal zerocopy],enable_zerocopy=$enable_zerocopy_temp, enable_zerocopy="")
 
 AC_ARG_ENABLE(affinity, [  --enable-affinity enable process/irq affinity],enable_affinity="-DCPU_AFFINITY=1", enable_affinity=$enable_affinity_temp)
 #####################################
index b05d0c4..3aa6909 100644 (file)
@@ -1,11 +1,58 @@
-/* ../include/config.h.in.  Generated automatically from configure.in by autoheader.  */
+/* portals/include/config.h.in.  Generated from configure.in by autoheader.  */
 
-/* Define if you have the readline library (-lreadline).  */
-#undef HAVE_LIBREADLINE
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* IOCTL Buffer Size */
+#undef OBD_MAX_IOCTL_BUFFER
 
 /* Name of package */
 #undef PACKAGE
 
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* The size of a `unsigned long long', as computed by sizeof. */
+#undef SIZEOF_UNSIGNED_LONG_LONG
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
 /* Version number of package */
 #undef VERSION
-
index 1555f78..9f30cce 100644 (file)
@@ -78,14 +78,21 @@ extern unsigned int portal_printk;
 
 #ifdef __KERNEL__
 # include <linux/sched.h> /* THREAD_SIZE */
-
-#ifdef  __ia64__
-#define CDEBUG_STACK ((unsigned long)__builtin_dwarf_cfa()&(THREAD_SIZE - 1))
 #else
-#define CDEBUG_STACK (THREAD_SIZE -                                      \
+# define THREAD_SIZE 8192
+#endif 
+
+#ifdef __KERNEL__
+
+# ifdef  __ia64__
+#  define CDEBUG_STACK (THREAD_SIZE -                                      \
+                        ((unsigned long)__builtin_dwarf_cfa() &            \
+                         (THREAD_SIZE - 1)))
+# else
+#  define CDEBUG_STACK (THREAD_SIZE -                                      \
                         ((unsigned long)__builtin_frame_address(0) &       \
                          (THREAD_SIZE - 1)))
-#endif
+# endif
 
 #define CHECK_STACK(stack)                                                    \
         do {                                                                  \
@@ -98,21 +105,21 @@ extern unsigned int portal_printk;
                       /*panic("LBUG");*/                                      \
                 }                                                             \
         } while (0)
-#else
-#define CHECK_STACK(stack) do{}while(0)
+#else /* __KERNEL__ */
+#define CHECK_STACK(stack) do { } while(0)
 #define CDEBUG_STACK (0L)
-#endif
+#endif /* __KERNEL__ */
 
 #if 1
 #define CDEBUG(mask, format, a...)                                            \
 do {                                                                          \
-        CHECK_STACK(CDEBUG_STACK);                                            \
+        CHECK_STACK(CDEBUG_STACK);                                          \
         if (!(mask) || ((mask) & (D_ERROR | D_EMERG)) ||                      \
             (portal_debug & (mask) &&                                         \
              portal_subsystem_debug & (1 << (DEBUG_SUBSYSTEM >> 24))))        \
                 portals_debug_msg(DEBUG_SUBSYSTEM, mask,                      \
                                   __FILE__, __FUNCTION__, __LINE__,           \
-                                  CDEBUG_STACK, format , ## a);               \
+                                  CDEBUG_STACK, format, ## a);              \
 } while (0)
 
 #define CWARN(format, a...) CDEBUG(D_WARNING, format, ## a)
@@ -204,8 +211,7 @@ static inline void our_cond_resched(void)
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) */
 
 #ifdef PORTAL_DEBUG
-extern void kportal_assertion_failed(char *expr, char *file,
-                                     const char *func, const int line);
+extern void kportal_assertion_failed(char *expr,char *file,const char *func,const int line);
 #define LASSERT(e) ((e) ? 0 : kportal_assertion_failed( #e , __FILE__,  \
                                                         __FUNCTION__, __LINE__))
 #else
@@ -257,28 +263,27 @@ do {                                                                          \
 
 #define PORTAL_ALLOC(ptr, size)                                           \
 do {                                                                      \
-        long s = size;                                                    \
         LASSERT (!in_interrupt());                                        \
-        if (s > PORTAL_VMALLOC_SIZE)                                      \
-                (ptr) = vmalloc(s);                                       \
+        if ((size) > PORTAL_VMALLOC_SIZE)                                 \
+                (ptr) = vmalloc(size);                                    \
         else                                                              \
-                (ptr) = kmalloc(s, GFP_KERNEL);                           \
+                (ptr) = kmalloc((size), GFP_NOFS);                        \
         if ((ptr) == NULL)                                                \
-                CERROR("PORTALS: out of memory at %s:%d (tried to alloc"  \
-                       " '" #ptr "' = %ld)\n", __FILE__, __LINE__, s);    \
+                CERROR("PORTALS: out of memory at %s:%d (tried to alloc '"\
+                       #ptr "' = %d)\n", __FILE__, __LINE__, (int)(size));\
         else {                                                            \
-                portal_kmem_inc((ptr), s);                                \
-                memset((ptr), 0, s);                                      \
+                portal_kmem_inc((ptr), (size));                           \
+                memset((ptr), 0, (size));                                 \
         }                                                                 \
-        CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %ld at %p (tot %d).\n",   \
-               s, (ptr), atomic_read (&portal_kmemory));                  \
+        CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %d at %p (tot %d).\n",    \
+               (int)(size), (ptr), atomic_read (&portal_kmemory));        \
 } while (0)
 
 #define PORTAL_FREE(ptr, size)                                          \
 do {                                                                    \
-        long s = (size);                                                \
+        int s = (size);                                                 \
         if ((ptr) == NULL) {                                            \
-                CERROR("PORTALS: free NULL '" #ptr "' (%ld bytes) at "  \
+                CERROR("PORTALS: free NULL '" #ptr "' (%d bytes) at "   \
                        "%s:%d\n", s, __FILE__, __LINE__);               \
                 break;                                                  \
         }                                                               \
@@ -287,39 +292,38 @@ do {                                                                    \
         else                                                            \
                 kfree(ptr);                                             \
         portal_kmem_dec((ptr), s);                                      \
-        CDEBUG(D_MALLOC, "kfreed '" #ptr "': %ld at %p (tot %d).\n",    \
-               s, (ptr), atomic_read (&portal_kmemory));                \
+        CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %d).\n",     \
+               s, (ptr), atomic_read(&portal_kmemory));                 \
 } while (0)
 
 #define PORTAL_SLAB_ALLOC(ptr, slab, size)                                \
 do {                                                                      \
-        long s = (size);                                                  \
-        LASSERT (!in_interrupt());                                        \
+        LASSERT(!in_interrupt());                                         \
         (ptr) = kmem_cache_alloc((slab), SLAB_KERNEL);                    \
         if ((ptr) == NULL) {                                              \
                 CERROR("PORTALS: out of memory at %s:%d (tried to alloc"  \
                        " '" #ptr "' from slab '" #slab "')\n", __FILE__,  \
                        __LINE__);                                         \
         } else {                                                          \
-                portal_kmem_inc((ptr), s);                                \
-                memset((ptr), 0, s);                                      \
+                portal_kmem_inc((ptr), (size));                           \
+                memset((ptr), 0, (size));                                 \
         }                                                                 \
         CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %ld at %p (tot %d).\n",   \
-               s, (ptr), atomic_read (&portal_kmemory));                  \
+               (int)(size), (ptr), atomic_read(&portal_kmemory));         \
 } while (0)
 
 #define PORTAL_SLAB_FREE(ptr, slab, size)                               \
 do {                                                                    \
-        long s = (size);                                                \
+        int s = (size);                                                 \
         if ((ptr) == NULL) {                                            \
-                CERROR("PORTALS: free NULL '" #ptr "' (%ld bytes) at "  \
+                CERROR("PORTALS: free NULL '" #ptr "' (%d bytes) at "   \
                        "%s:%d\n", s, __FILE__, __LINE__);               \
                 break;                                                  \
         }                                                               \
         memset((ptr), 0x5a, s);                                         \
         kmem_cache_free((slab), ptr);                                   \
         portal_kmem_dec((ptr), s);                                      \
-        CDEBUG(D_MALLOC, "kfreed '" #ptr "': %ld at %p (tot %d).\n",    \
+        CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %d).\n",     \
                s, (ptr), atomic_read (&portal_kmemory));                \
 } while (0)
 
@@ -462,8 +466,8 @@ kpr_lookup (kpr_router_t *router, ptl_nid_t nid, ptl_nid_t *gateway_nid)
 }
 
 static inline void
-kpr_fwd_init (kpr_fwd_desc_t *fwd, ptl_nid_t nid, 
-              int nob, int niov, struct iovec *iov, 
+kpr_fwd_init (kpr_fwd_desc_t *fwd, ptl_nid_t nid,
+              int nob, int niov, struct iovec *iov,
               kpr_fwd_callback_t callback, void *callback_arg)
 {
         fwd->kprfd_target_nid   = nid;
@@ -575,9 +579,8 @@ __s32 portals_debug_copy_to_user(char *buf, unsigned long len);
 # warning printf has been defined as a macro...
 # undef printf
 #endif
-void portals_debug_msg(int subsys, int mask, char *file, const char *fn, 
-                       const int line, unsigned long stack, char *format,
-                        ...)
+void portals_debug_msg (int subsys, int mask, char *file, const char *fn, const int line,
+                        unsigned long stack, const char *format, ...)
         __attribute__ ((format (printf, 7, 8)));
 #else
 void portals_debug_msg (int subsys, int mask, char *file, const char *fn,
@@ -608,7 +611,7 @@ extern void kportal_blockallsigs (void);
 # ifdef PORTAL_DEBUG
 #  undef NDEBUG
 #  include <assert.h>
-#  define LASSERT(e)   assert(e)
+#  define LASSERT(e)     assert(e)
 # else
 #  define LASSERT(e)
 # endif
@@ -621,6 +624,10 @@ extern void kportal_blockallsigs (void);
             getpid() , stack, ## a);
 #endif
 
+#ifndef CURRENT_TIME
+# define CURRENT_TIME time(0)
+#endif
+
 #include <linux/portals_lib.h>
 
 /*
@@ -908,7 +915,7 @@ void kportal_put_ni (int nal);
 #ifndef BITS_PER_LONG
 #if (~0UL) == 0xffffffffUL
 #define BITS_PER_LONG 32
-#else 
+#else
 #define BITS_PER_LONG 64
 #endif
 #endif
index ca92e5f..b623b93 100644 (file)
@@ -183,28 +183,28 @@ static inline lib_eq_t *
 lib_eq_alloc (nal_cb_t *nal)
 {
         /* NEVER called with statelock held */
-        lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_KERNEL);
-        
+        lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_NOFS);
+
         if (eq == NULL)
                 return (NULL);
-        
+
         atomic_inc (&eq_in_use_count);
         return (eq);
 }
 
-static inline void 
+static inline void
 lib_eq_free (nal_cb_t *nal, lib_eq_t *eq)
 {
         /* ALWAYS called with statelock held */
         atomic_dec (&eq_in_use_count);
-        kmem_cache_free(ptl_eq_slab, eq); 
+        kmem_cache_free(ptl_eq_slab, eq);
 }
 
 static inline lib_md_t *
 lib_md_alloc (nal_cb_t *nal)
 {
         /* NEVER called with statelock held */
-        lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_KERNEL); 
+        lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_NOFS);
 
         if (md == NULL)
                 return (NULL);
@@ -225,11 +225,11 @@ static inline lib_me_t *
 lib_me_alloc (nal_cb_t *nal)
 {
         /* NEVER called with statelock held */
-        lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_KERNEL);
+        lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_NOFS);
 
         if (me == NULL)
                 return (NULL);
-        
+
         atomic_inc (&me_in_use_count);
         return (me);
 }
index 2b63312..78a1e2d 100644 (file)
@@ -1,6 +1,4 @@
 #ifndef _LINUX_LIST_H
-#define _LINUX_LIST_H
-
 
 /*
  * Simple doubly linked list implementation.
@@ -101,7 +99,9 @@ static inline void list_del_init(struct list_head *entry)
        __list_del(entry->prev, entry->next);
        INIT_LIST_HEAD(entry);
 }
+#endif
 
+#ifndef list_for_each_entry
 /**
  * list_move - delete from one list and add as another's head
  * @list: the entry to move
@@ -124,7 +124,10 @@ static inline void list_move_tail(struct list_head *list,
        __list_del(list->prev, list->next);
        list_add_tail(list, head);
 }
+#endif
 
+#ifndef _LINUX_LIST_H
+#define _LINUX_LIST_H
 /**
  * list_empty - tests whether a list is empty
  * @head: the list to test.
index 4727599..760f465 100644 (file)
@@ -1,6 +1,3 @@
-/*
- */
-
 #ifndef _INCppidh_
 #define _INCppidh_
 
index fdaae69..dc02780 100644 (file)
@@ -38,6 +38,7 @@ int jt_ptl_connect(int argc, char **argv);
 int jt_ptl_disconnect(int argc, char **argv);
 int jt_ptl_push_connection(int argc, char **argv);
 int jt_ptl_ping(int argc, char **argv);
+int jt_ptl_shownid(int argc, char **argv);
 int jt_ptl_mynid(int argc, char **argv);
 int jt_ptl_add_uuid(int argc, char **argv);
 int jt_ptl_add_uuid_old(int argc, char **argv); /* backwards compatibility  */
index 0def863..1a8fb74 100644 (file)
@@ -101,17 +101,37 @@ static nal_t *
 kqswnal_init(int interface, ptl_pt_index_t ptl_size, ptl_ac_index_t ac_size,
             ptl_pid_t requested_pid)
 {
-       ptl_nid_t mynid = ep_nodeid (kqswnal_data.kqn_epdev);
-       int       nnids = ep_numnodes (kqswnal_data.kqn_epdev);
+       ptl_nid_t mynid = kqswnal_elanid2nid (kqswnal_data.kqn_elanid);
+       int       nnids = kqswnal_data.kqn_nnodes;
 
-        CDEBUG(D_NET, "calling lib_init with nid "LPX64" of %d\n", mynid,nnids);
+        CDEBUG(D_NET, "calling lib_init with nid "LPX64" of %d\n", mynid, nnids);
 
        lib_init(&kqswnal_lib, mynid, 0, nnids, ptl_size, ac_size);
 
        return (&kqswnal_api);
 }
 
-void /*__exit*/
+int
+kqswnal_cmd (struct portal_ioctl_data *data, void *private)
+{
+       LASSERT (data != NULL);
+       
+       switch (data->ioc_nal_cmd) {
+       case NAL_CMD_REGISTER_MYNID:
+               CDEBUG (D_IOCTL, "setting NID offset to "LPX64" (was "LPX64")\n",
+                       data->ioc_nid - kqswnal_data.kqn_elanid,
+                       kqswnal_data.kqn_nid_offset);
+               kqswnal_data.kqn_nid_offset =
+                       data->ioc_nid - kqswnal_data.kqn_elanid;
+               kqswnal_lib.ni.nid = data->ioc_nid;
+               return (0);
+               
+       default:
+               return (-EINVAL);
+       }
+}
+
+void __exit
 kqswnal_finalise (void)
 {
        switch (kqswnal_data.kqn_init)
@@ -324,6 +344,10 @@ kqswnal_initialise (void)
                return (-ENOMEM);
        }
 
+       kqswnal_data.kqn_nid_offset = 0;
+       kqswnal_data.kqn_nnodes     = ep_numnodes (kqswnal_data.kqn_epdev);
+       kqswnal_data.kqn_elanid     = ep_nodeid (kqswnal_data.kqn_epdev);
+       
        /**********************************************************************/
        /* Get the transmitter */
 
@@ -477,7 +501,7 @@ kqswnal_initialise (void)
                LASSERT (krx->krx_npages > 0);
                for (j = 0; j < krx->krx_npages; j++)
                {
-                       krx->krx_pages[j] = alloc_page (GFP_KERNEL);
+                       krx->krx_pages[j] = alloc_page(GFP_KERNEL);
                        if (krx->krx_pages[j] == NULL)
                        {
                                kqswnal_finalise ();
@@ -554,13 +578,19 @@ kqswnal_initialise (void)
        rc = kpr_register (&kqswnal_data.kqn_router, &kqswnal_router_interface);
        CDEBUG(D_NET, "Can't initialise routing interface (rc = %d): not routing\n",rc);
 
+       rc = kportal_nal_register (QSWNAL, &kqswnal_cmd, NULL);
+       if (rc != 0) {
+               CERROR ("Can't initialise command interface (rc = %d)\n", rc);
+               kqswnal_finalise ();
+               return (rc);
+       }
+
        PORTAL_SYMBOL_REGISTER(kqswnal_ni);
        kqswnal_data.kqn_init = KQN_INIT_ALL;
 
        printk(KERN_INFO "Routing QSW NAL loaded on node %d of %d "
               "(Routing %s, initial mem %d)\n", 
-              ep_nodeid (kqswnal_data.kqn_epdev),
-              ep_numnodes (kqswnal_data.kqn_epdev),
+              kqswnal_data.kqn_elanid, kqswnal_data.kqn_nnodes,
               kpr_routing (&kqswnal_data.kqn_router) ? "enabled" : "disabled",
               pkmem);
 
index 657b02b..85e585b 100644 (file)
@@ -104,7 +104,7 @@ typedef unsigned long kqsw_csum_t;
 #define KQSW_TX_MAXCONTIG              (1<<10) /* largest payload that gets made contiguous on transmit */
 
 #define KQSW_NTXMSGS                   8       /* # normal transmit messages */
-#define KQSW_NNBLK_TXMSGS              128     /* # reserved transmit messages if can't block */
+#define KQSW_NNBLK_TXMSGS              256     /* # reserved transmit messages if can't block */
 
 #define KQSW_NRXMSGS_LARGE             64      /* # large receive buffers */
 #define KQSW_EP_ENVELOPES_LARGE        128     /* # large ep envelopes */
@@ -200,6 +200,10 @@ typedef struct
        ELAN3_DMA_HANDLE  *kqn_eptxdmahandle;   /* elan reserved tx vaddrs */
        ELAN3_DMA_HANDLE  *kqn_eprxdmahandle;   /* elan reserved rx vaddrs */
         kpr_router_t       kqn_router;          /* connection to Kernel Portals Router module */
+
+        ptl_nid_t          kqn_nid_offset;      /* this cluster's NID offset */
+        int                kqn_nnodes;          /* this cluster's size */
+        int                kqn_elanid;          /* this nodes's elan ID */
 }  kqswnal_data_t;
 
 /* kqn_init state */
@@ -217,6 +221,23 @@ extern void kqswnal_rxhandler(EP_RXD *rxd);
 extern int kqswnal_scheduler (void *);
 extern void kqswnal_fwd_packet (void *arg, kpr_fwd_desc_t *fwd);
 
+static inline ptl_nid_t
+kqswnal_elanid2nid (int elanid) 
+{
+        return (kqswnal_data.kqn_nid_offset + elanid);
+}
+
+static inline int
+kqswnal_nid2elanid (ptl_nid_t nid) 
+{
+        /* not in this cluster? */
+        if (nid < kqswnal_data.kqn_nid_offset ||
+            nid >= kqswnal_data.kqn_nid_offset + kqswnal_data.kqn_nnodes)
+                return (-1);
+        
+        return (nid - kqswnal_data.kqn_nid_offset);
+}
+
 static inline void
 kqswnal_requeue_rx (kqswnal_rx_t *krx)
 {
index 5979885..c03d592 100644 (file)
@@ -109,21 +109,15 @@ kqswnal_sti(nal_cb_t *nal, unsigned long *flags)
 static int
 kqswnal_dist(nal_cb_t *nal, ptl_nid_t nid, unsigned long *dist)
 {
-        /* network distance doesn't mean much for this nal */
-        *dist = (nid == nal->ni.nid) ? 0 : 1;
+        if (nid == nal->ni.nid)
+                *dist = 0;                      /* it's me */
+        else if (kqswnal_nid2elanid (nid) >= 0)
+                *dist = 1;                      /* it's my peer */
+        else
+                *dist = 2;                      /* via router */
         return (0);
 }
 
-int
-kqswnal_ispeer (ptl_nid_t nid)
-{
-        unsigned int elanid = (unsigned int)nid;
-
-        /* didn't lose high bits on conversion and it's in this machine? */
-        return ((ptl_nid_t)elanid == nid &&
-                elanid < ep_numnodes (kqswnal_data.kqn_epdev));
-}
-
 void
 kqswnal_unmap_tx (kqswnal_tx_t *ktx)
 {
@@ -453,11 +447,14 @@ kqswnal_launch (kqswnal_tx_t *ktx)
 {
         /* Don't block for transmit descriptor if we're in interrupt context */
         int   attr = in_interrupt() ? (EP_NO_SLEEP | EP_NO_ALLOC) : 0;
-        int   rc   = ep_transmit_large(kqswnal_data.kqn_eptx, ktx->ktx_nid,
-                                       ktx->ktx_port, attr, kqswnal_txhandler,
-                                       ktx, ktx->ktx_iov, ktx->ktx_niov);
+        int   dest = kqswnal_nid2elanid (ktx->ktx_nid);
         long  flags;
-
+        int   rc;
+        
+        LASSERT (dest >= 0);                    /* must be a peer */
+        rc = ep_transmit_large(kqswnal_data.kqn_eptx, dest,
+                               ktx->ktx_port, attr, kqswnal_txhandler,
+                               ktx, ktx->ktx_iov, ktx->ktx_niov);
         if (rc == 0)
                 atomic_inc (&kqswnal_packets_launched);
 
@@ -595,7 +592,7 @@ kqswnal_sendmsg (nal_cb_t     *nal,
                 return (-1);
         }
 
-        if (!kqswnal_ispeer (nid)) {     /* Can't send direct: find gateway? */
+        if (kqswnal_nid2elanid (nid) < 0) {     /* Can't send direct: find gateway? */
                 rc = kpr_lookup (&kqswnal_data.kqn_router, nid, &gatewaynid);
                 if (rc != 0) {
                         CERROR("Can't route to "LPX64": router error %d\n",
@@ -603,7 +600,7 @@ kqswnal_sendmsg (nal_cb_t     *nal,
                         lib_finalize (&kqswnal_lib, private, cookie);
                         return (-1);
                 }
-                if (!kqswnal_ispeer (gatewaynid)) {
+                if (kqswnal_nid2elanid (gatewaynid) < 0) {
                         CERROR("Bad gateway "LPX64" for "LPX64"\n",
                                gatewaynid, nid);
                         lib_finalize (&kqswnal_lib, private, cookie);
@@ -620,6 +617,7 @@ kqswnal_sendmsg (nal_cb_t     *nal,
         if (ktx == NULL) {
                 kqswnal_cerror_hdr (hdr);
                 lib_finalize (&kqswnal_lib, private, cookie);
+                return (-1);
         }
 
         memcpy (ktx->ktx_buffer, hdr, sizeof (*hdr)); /* copy hdr from caller's stack */
@@ -757,7 +755,7 @@ kqswnal_fwd_packet (void *arg, kpr_fwd_desc_t *fwd)
         if (nid == kqswnal_lib.ni.nid)          /* gateway is me */
                 nid = fwd->kprfd_target_nid;    /* target is final dest */
 
-        if (!kqswnal_ispeer (nid)) {
+        if (kqswnal_nid2elanid (nid) < 0) {
                 CERROR("Can't forward [%p] to "LPX64": not a peer\n", fwd, nid);
                 rc = -EHOSTUNREACH;
                 goto failed;
@@ -844,7 +842,7 @@ kqswnal_rx (kqswnal_rx_t *krx)
         CERROR ("checksums for forwarded packets not implemented\n");
         LBUG ();
 #endif
-        if (kqswnal_ispeer (dest_nid))  /* should have gone direct to peer */
+        if (kqswnal_nid2elanid (dest_nid) >= 0)  /* should have gone direct to peer */
         {
                 CERROR("dropping packet from "LPX64" for "LPX64
                        ": target is peer\n", NTOH__u64(hdr->src_nid), dest_nid);
index da2b453..fe24e03 100644 (file)
@@ -95,10 +95,8 @@ nal_t *
 ksocknal_init(int interface, ptl_pt_index_t ptl_size,
               ptl_ac_index_t ac_size, ptl_pid_t requested_pid)
 {
-        CDEBUG(D_NET, "calling lib_init with nid "LPX64"\n",
-               ksocknal_data.ksnd_mynid);
-        lib_init(&ksocknal_lib, ksocknal_data.ksnd_mynid, 0, 10, ptl_size,
-                 ac_size);
+        CDEBUG(D_NET, "calling lib_init with nid "LPX64"\n", (ptl_nid_t)0);
+        lib_init(&ksocknal_lib, (ptl_nid_t)0, 0, 10, ptl_size, ac_size);
         return (&ksocknal_api);
 }
 
@@ -129,7 +127,6 @@ ksocknal_set_mynid(ptl_nid_t nid)
         CDEBUG(D_IOCTL, "setting mynid to "LPX64" (old nid="LPX64")\n",
                nid, ni->nid);
 
-        ksocknal_data.ksnd_mynid = nid;
         ni->nid = nid;
         return (0);
 }
@@ -190,7 +187,7 @@ ksocknal_add_sock (ptl_nid_t nid, int fd, int bind_irq)
         if (!conn)
                 GOTO(error, ret);
 
-        memset (conn, 0, sizeof (conn));        /* zero for consistency */
+#warning ZAB: fix me for 2.5 sock->sk->allocation = GFP_NOFS;    /* don't call info fs for alloc */
 
         conn->ksnc_file = file;
         conn->ksnc_sock = sock;
@@ -809,7 +806,7 @@ ksocknal_module_init (void)
 
                         LASSERT (fmb->fmb_npages > 0);
                         for (j = 0; j < fmb->fmb_npages; j++) {
-                                fmb->fmb_pages[j] = alloc_page (GFP_KERNEL);
+                                fmb->fmb_pages[j] = alloc_page(GFP_KERNEL);
 
                                 if (fmb->fmb_pages[j] == NULL) {
                                         ksocknal_module_fini ();
index f959889..188d1f2 100644 (file)
@@ -115,7 +115,6 @@ typedef struct {
         struct list_head  ksnd_socklist;        /* all my connections */
         rwlock_t          ksnd_socklist_lock;   /* stabilise add/find/remove */
 
-        ptl_nid_t         ksnd_mynid;
         nal_cb_t         *ksnd_nal_cb;
         spinlock_t        ksnd_nal_cb_lock;     /* lib cli/sti lock */
 
index 7adebf8..77ee473 100644 (file)
@@ -522,7 +522,7 @@ ktoenal_module_init (void)
                 LASSERT (fmb->fmb_npages > 0);
                 for (j = 0; j < fmb->fmb_npages; j++)
                 {
-                        fmb->fmb_pages[j] = alloc_page (GFP_KERNEL);
+                        fmb->fmb_pages[j] = alloc_page(GFP_KERNEL);
 
                         if (fmb->fmb_pages[j] == NULL)
                         {
index e5d2eef..abd0731 100644 (file)
@@ -423,11 +423,10 @@ ktoenal_send(nal_cb_t *nal, void *private, lib_msg_t *cookie,
          * packet as a side-effect of another packet, such as when an ACK has
          * been requested. -phil */
 
-        CDEBUG(D_NET, "sending "LPSZ" bytes from [%d](%p,%d)... to nid: "LPX64" pid %d\n",
-               payload_len, payload_niov,
+        CDEBUG(D_NET, "sending %d bytes from [%d](%p,%d)... to nid: "
+               LPX64" pid %d\n", (int)payload_len, payload_niov,
                payload_niov > 0 ? payload_iov[0].iov_base : NULL,
-               payload_niov > 0 ? payload_iov[0].iov_len  : 0,
-               nid, pid);
+               (int)(payload_niov > 0 ? payload_iov[0].iov_len : 0), nid, pid);
 
         if ((conn = ktoenal_get_conn (nid)) == NULL)
         {
index 2409812..6cdf101 100644 (file)
@@ -673,8 +673,8 @@ __s32 portals_debug_copy_to_user(char *buf, unsigned long len)
 
 /* FIXME: I'm not very smart; someone smarter should make this better. */
 void
-portals_debug_msg (int subsys, int mask, char *file, const char *fn, 
-                   const int line, unsigned long stack, char *format, ...)
+portals_debug_msg (int subsys, int mask, char *file, const char *fn, const int line,
+                   unsigned long stack, const char *format, ...)
 {
         va_list       ap;
         unsigned long flags;
@@ -804,7 +804,7 @@ void portals_run_lbug_upcall(char * file, const char *fn, const int line)
         argv[0] = portals_upcall;
         argv[1] = "LBUG";
         argv[2] = file;
-        argv[3] = (char *)fn;
+        argv[3] = fn;
         argv[4] = buf;
         argv[5] = NULL;
 
index e9f4545..f37d1e7 100644 (file)
@@ -47,6 +47,7 @@
 #include <portals/lib-p30.h>
 #include <portals/p30.h>
 #include <linux/kp30.h>
+#include <linux/portals_compat25.h>
 #include <linux/kernel_compat.h>
 
 #define PORTAL_MINOR 240
@@ -62,7 +63,7 @@ static struct nal_cmd_handler nal_cmd[NAL_MAX_NR + 1];
 struct semaphore nal_cmd_sem;
 
 #ifdef PORTAL_DEBUG
-void kportal_assertion_failed(char *expr, char *file, const char *func, 
+void kportal_assertion_failed(char *expr, char *file,  const char *func, 
                               const int line)
 {
         portals_debug_msg(0, D_EMERG, file, func, line, CDEBUG_STACK,
@@ -429,6 +430,7 @@ static int kportal_ioctl(struct inode *inode, struct file *file,
                         return (-EINVAL);
 
                 err = PtlFailNid (*nip, data->ioc_nid, data->ioc_count);
+                kportal_put_ni (data->ioc_nal);
                 break;
         }
 
index 6ba5e53..27a7fba 100644 (file)
@@ -202,15 +202,15 @@ kpr_forward_packet (void *arg, kpr_fwd_desc_t *fwd)
         LASSERT (nob == lib_iov_nob (fwd->kprfd_niov, fwd->kprfd_iov));
         
         atomic_inc (&kpr_queue_depth);
+       atomic_inc (&src_ne->kpne_refcount); /* source nal is busy until fwd completes */
 
         kpr_fwd_packets++;                   /* (loose) stats accounting */
         kpr_fwd_bytes += nob;
 
-       if (src_ne->kpne_shutdown)                      /* caller is shutting down */
+       if (src_ne->kpne_shutdown)           /* caller is shutting down */
                goto out;
 
-       fwd->kprfd_router_arg = src_ne;         /* stash caller's nal entry */
-       atomic_inc (&src_ne->kpne_refcount);    /* source nal is busy until fwd completes */
+       fwd->kprfd_router_arg = src_ne;      /* stash caller's nal entry */
 
        read_lock (&kpr_rwlock);
 
index 89c9f78..310e899 100644 (file)
@@ -120,9 +120,10 @@ int read_connection(connection c,
     return(1);
 }
 
-static int connection_input(connection c)
+static int connection_input(void *d)
 {
-    return((*c->m->handler)(c->m->handler_arg,c));
+        connection c = d;
+        return((*c->m->handler)(c->m->handler_arg,c));
 }
 
 
@@ -280,7 +281,7 @@ void shutdown_connections(manager m)
  *          zero if the fixed port could not be bound
  */
 manager init_connections(unsigned short pid,
-                         int (*input)(),
+                         int (*input)(void *, void *),
                          void *a)
 {
     manager m=(manager)malloc(sizeof(struct manager));
index f6b2994..6f57287 100644 (file)
@@ -25,14 +25,8 @@ typedef struct connection {
     manager m;
 } *connection;
 
-connection force_tcp_connection(manager m,
-                                unsigned int ip,  
-                               unsigned int short);
-manager init_connections(unsigned short,
-                         int (*f)(void *,connection),
-                         void *);
+connection force_tcp_connection(manager m, unsigned int ip, unsigned int short);
+manager init_connections(unsigned short, int (*f)(void *, void *), void *);
 void remove_connection(void *arg);
 void shutdown_connections(manager m);
-int read_connection(connection c,
-                    unsigned char *dest,
-                    int len);
+int read_connection(connection c, unsigned char *dest, int len);
index 8bf55c4..534fc17 100644 (file)
@@ -151,15 +151,17 @@ int tcpnal_recv(nal_cb_t *n,
  *  available. It attempts to read the portals header and 
  *  pass it to the generic library for processing.
  */
-static int from_connection(void *a,connection c)
+static int from_connection(void *a, void *d)
 {
-    bridge b=a;
-    ptl_hdr_t hdr;
-    if (read_connection(c, (unsigned char *)&hdr, sizeof(hdr))){
-        lib_parse(b->nal_cb, &hdr, c);
-        return(1);
-    }
-    return(0);
+        connection c = d;
+        bridge b=a;
+        ptl_hdr_t hdr;
+
+        if (read_connection(c, (unsigned char *)&hdr, sizeof(hdr))){
+                lib_parse(b->nal_cb, &hdr, c);
+                return(1);
+        }
+        return(0);
 }
 
 
index 8235271..90d66f5 100644 (file)
@@ -106,13 +106,6 @@ nal2name (int nal)
         return ((e == NULL) ? "???" : e->name);
 }
 
-static int
-nid2nal (ptl_nid_t nid)
-{
-        /* BIG pragmatic assumption */
-        return ((((__u32)nid) & 0xffff0000) != 0 ? SOCKNAL : QSWNAL);
-}
-
 int
 ptl_parse_nid (ptl_nid_t *nidp, char *str)
 {
@@ -160,35 +153,15 @@ ptl_parse_nid (ptl_nid_t *nidp, char *str)
 char *
 ptl_nid2str (char *buffer, ptl_nid_t nid)
 {
-        switch (nid2nal(nid))
-        {
-        case QSWNAL:
-                sprintf (buffer, LPD64, nid);
-                return (buffer);
+        __u32           addr = htonl((__u32)nid); /* back to NETWORK byte order */
+        struct hostent *he = gethostbyaddr ((const char *)&addr, sizeof (addr), AF_INET);
 
-        case SCIMACNAL:
-                sprintf (buffer, LPX64, nid);
-                return (buffer);
-                
-        case SOCKNAL: {
-                __u32           addr = htonl((__u32)nid); /* back to NETWORK byte order */
-                struct hostent *he = gethostbyaddr ((const char *)&addr, sizeof (addr), AF_INET);
-                
-                if (he != NULL)
-                        strcpy (buffer, he->h_name);
-                else
-                {
-                        addr = (__u32)nid;
-                        sprintf (buffer, "%d.%d.%d.%d", 
-                                 (addr>>24)&0xff, (addr>>16)&0xff, (addr>>8)&0xff, addr&0xff);
-                }
-                return (buffer);
-        }
+        if (he != NULL)
+                strcpy (buffer, he->h_name);
+        else
+                sprintf (buffer, "0x"LPX64, nid);
         
-        default:
-                sprintf (buffer, "nid2nal broken");
-                return (buffer);
-        }
+        return (buffer);
 }
 
 int
@@ -704,18 +677,43 @@ int jt_ptl_ping(int argc, char **argv)
         return 0;
 }
 
+int jt_ptl_shownid(int argc, char **argv)
+{
+        struct portal_ioctl_data data;
+        int                      rc;
+        
+        if (argc > 1) {
+                fprintf(stderr, "usage: %s\n", argv[0]);
+                return 0;
+        }
+        
+        if (g_nal == 0) {
+                fprintf(stderr, "Error: you must run the 'network' command first\n");
+                return -1;
+        }
+        
+        PORTAL_IOC_INIT (data);
+        data.ioc_nal = g_nal;
+        rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_GET_NID, &data);
+        if (rc < 0)
+                fprintf(stderr, "getting my NID failed: %s\n",
+                        strerror (errno));
+        else
+                printf(LPX64"\n", data.ioc_nid);
+        return 0;
+}
+
 int jt_ptl_mynid(int argc, char **argv)
 {
         int rc;
-        struct hostent *h;
-        char buf[1024], *hostname;
+        char hostname[1024];
+        char *nidstr;
         struct portal_ioctl_data data;
         ptl_nid_t mynid;
         
         if (argc > 2) {
-                fprintf(stderr, "usage: %s [hostname]\n", argv[0]);
-                fprintf(stderr, "hostname defaults to the hostname of the "
-                        "machine.\n");
+                fprintf(stderr, "usage: %s [NID]\n", argv[0]);
+                fprintf(stderr, "NID defaults to the primary IP address of the machine.\n");
                 return 0;
         }
 
@@ -725,42 +723,21 @@ int jt_ptl_mynid(int argc, char **argv)
                 return -1;
         }
 
-        if (g_nal == QSWNAL) {
-                fprintf(stderr, "'mynid' doesn't make any sense for elan.\n");
-                return -1;
-        } else  if (g_nal == GMNAL) {
-                fprintf(stderr, "'mynid' doesn't make any sense for GM.\n");
-                return -1;
-        } else  if (g_nal == SCIMACNAL) {
-                fprintf(stderr, "'mynid' doesn't make any sense for SCI.\n");
-                return -1;
-        } 
-        
-        if (g_nal != SOCKNAL && g_nal != TOENAL) {
-                fprintf(stderr, "This should never happen.  Also it is very "
-                        "bad.\n");
+        if (argc >= 2)
+                nidstr = argv[1];
+        else if (gethostname(hostname, sizeof(hostname)) != 0) {
+                fprintf(stderr, "gethostname failed: %s\n",
+                        strerror(errno));
                 return -1;
         }
+        else
+                nidstr = hostname;
 
-        if (argc == 1) {
-                if (gethostname(buf, sizeof(buf)) != 0) {
-                        fprintf(stderr, "gethostname failed: %s\n",
-                                strerror(errno));
-                        return -1;
-                }
-                hostname = buf;
-        } else {
-                hostname = argv[1];
-        }
-
-        h = gethostbyname(hostname);
-
-        if (!h) {
-                fprintf(stderr, "cannot get address for host '%s': %d\n",
-                        hostname, h_errno);
+        rc = ptl_parse_nid (&mynid, nidstr);
+        if (rc != 0) {
+                fprintf (stderr, "Can't convert '%s' into a NID\n", nidstr);
                 return -1;
         }
-        mynid = (ptl_nid_t)ntohl (*(__u32 *)h->h_addr);      /* HOST byte order */
         
         PORTAL_IOC_INIT(data);
         data.ioc_nid = mynid;
@@ -769,7 +746,7 @@ int jt_ptl_mynid(int argc, char **argv)
 
         rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data);
         if (rc < 0)
-                fprintf(stderr, "IOC_PORTAL_REGISTER_MYNID failed: %s\n",
+                fprintf(stderr, "setting my NID failed: %s\n",
                        strerror(errno));
         else
                 printf("registered my nid "LPX64" (%s)\n", mynid, hostname);
@@ -888,7 +865,6 @@ jt_ptl_add_route (int argc, char **argv)
         ptl_nid_t                nid1;
         ptl_nid_t                nid2;
         ptl_nid_t                gateway_nid;
-        int                      gateway_nal;
         int                      rc;
         
         if (argc < 3)
@@ -897,14 +873,18 @@ jt_ptl_add_route (int argc, char **argv)
                 return (0);
         }
 
+        if (g_nal == 0) {
+                fprintf(stderr, "Error: you must run the 'network' command "
+                        "first.\n");
+                return (-1);
+        }
+
         if (ptl_parse_nid (&gateway_nid, argv[1]) != 0)
         {
                 fprintf (stderr, "Can't parse gateway NID \"%s\"\n", argv[1]);
                 return (-1);
         }
 
-        gateway_nal = nid2nal (gateway_nid);
-
         if (ptl_parse_nid (&nid1, argv[2]) != 0)
         {
                 fprintf (stderr, "Can't parse first target NID \"%s\"\n", argv[2]);
@@ -921,7 +901,7 @@ jt_ptl_add_route (int argc, char **argv)
 
         PORTAL_IOC_INIT(data);
         data.ioc_nid = gateway_nid;
-        data.ioc_nal = gateway_nal;
+        data.ioc_nal = g_nal;
         data.ioc_nid2 = MIN (nid1, nid2);
         data.ioc_nid3 = MAX (nid1, nid2);
 
index d38bd4a..8c56d93 100644 (file)
@@ -34,6 +34,7 @@ command_t list[] = {
         {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid (args: [hostname]"},
         {"push", jt_ptl_push_connection, 0, "flush connection to a remote nid (args: [hostname]"},
         {"ping", jt_ptl_ping, 0, "do a ping test (args: nid [count] [size] [timeout])"},
+        {"shownid", jt_ptl_shownid, 0, "print the local NID"},
         {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local NID (args: [hostname])"},
         {"add_route", jt_ptl_add_route, 0, "add an entry to the routing table (args: gatewayNID targetNID [targetNID])"},
         {"del_route", jt_ptl_del_route, 0, "delete an entry from the routing table (args: targetNID"},
index 28eb778..eb65e46 100755 (executable)
@@ -70,9 +70,10 @@ sub readstat()
                    printf "%10s", "stddev";
                }
                 printf "\n";
+               $| = 1;
            }
            elsif ($cumulcount!=0) {
-               printf "%-25s %-10Lu %-10Lu %-10Lu",
+               printf "%-25s %-10lu %-10lu %-10lu",
                       $name, $diff, ($diff/$tdiff), $cumulcount;
                
                if (defined($sum)) {
@@ -83,7 +84,7 @@ sub readstat()
                        $sum = $sum/$mhz;
                        $max = $max/$mhz;
                    }
-                   printf "%-8s %10Lu %12.2f %10Lu", $unit, $min, ($sum/$cumulcount), $max;
+                   printf "%-8s %10lu %12.2f %10lu", $unit, $min, ($sum/$cumulcount), $max;
                    if (defined($sumsquare)) {
                        my $s = $sumsquare - (($sum_orig*$sum_orig)/$cumulcount);
                        if ($s >= 0) {
@@ -97,6 +98,7 @@ sub readstat()
                    }
                }
                printf "\n";
+               $| = 1;
            }
        }
        else {