+2005-02-04 Cluster File Systems, Inc. <info@clusterfs.com>
+ * miscellania
+ - update vibnal (Voltaire IB NAL)
+ - update gmnal (Myrinet NAL), gmnalid
+
2005-02-04 Eric Barton <eeb@bartonsoftware.com>
* Landed portals:b_port_step as follows...
#
AC_DEFUN([LP_CONFIGURE],
[# portals/utils/portals.c
-AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h endian.h])
+AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h endian.h sys/ioctl.h])
AC_CHECK_FUNCS([gethostbyname socket connect])
# portals/utils/debug.c
* USER LEVEL STUFF BELOW
*/
-#define PORTAL_IOCTL_VERSION 0x00010007
+#define PORTAL_IOCTL_VERSION 0x00010008
#define PING_SYNC 0
#define PING_ASYNC 1
# define DEBUG_SUBSYSTEM S_UNDEFINED
#endif
+#ifdef __KERNEL__
#if 1
#define CDEBUG(mask, format, a...) \
do { \
CDEBUG(D_TRACE, "Process leaving\n"); \
EXIT_NESTING; \
} while(0)
-#else
+#else /* !1 */
#define RETURN(rc) return (rc)
#define ENTRY
#define CWARN(format, a...) printk(KERN_WARNING format, ## a)
#define CERROR(format, a...) printk(KERN_ERR format, ## a)
#define CEMERG(format, a...) printk(KERN_EMERG format, ## a)
+#define LCONSOLE(mask, format, a...) do { } while (0)
+#define LCONSOLE_INFO(format, a...) printk(KERN_INFO format, ## a)
+#define LCONSOLE_WARN(format, a...) printk(KERN_WARNING format, ## a)
+#define LCONSOLE_ERROR(format, a...) printk(KERN_ERROR format, ## a)
+#define LCONSOLE_EMERG(format, a...) printk(KERN_EMERG format, ## a)
#define GOTO(label, rc) do { (void)(rc); goto label; } while (0)
#define RETURN(rc) return (rc)
#define ENTRY do { } while (0)
#define EXIT do { } while (0)
-#endif
+#endif /* !1 */
+#else /* !__KERNEL__ */
+#define CDEBUG(mask, format, a...) do { } while (0)
+#define LCONSOLE(mask, format, a...) do { } while (0)
+#ifdef stderr
+#define CWARN(format, a...) fprintf(stderr, "<4>" format, ## a)
+#define CERROR(format, a...) fprintf(stderr, "<3>" format, ## a)
+#define CEMERG(format, a...) fprintf(stderr, "<0>" format, ## a)
+#define LCONSOLE_INFO(format, a...) fprintf(stderr, format, ## a)
+#define LCONSOLE_WARN(format, a...) fprintf(stderr, format, ## a)
+#define LCONSOLE_ERROR(format, a...) fprintf(stderr, format, ## a)
+#define LCONSOLE_EMERG(format, a...) fprintf(stderr, format, ## a)
+#else
+#define CWARN(format, a...) do { } while (0)
+#define CERROR(format, a...) do { } while (0)
+#define CEMERG(format, a...) do { } while (0)
+#define LCONSOLE_INFO(format, a...) do { } while (0)
+#define LCONSOLE_WARN(format, a...) do { } while (0)
+#define LCONSOLE_ERROR(format, a...) do { } while (0)
+#define LCONSOLE_EMERG(format, a...) do { } while (0)
+#endif /* !stderr */
+#define GOTO(label, rc) do { (void)(rc); goto label; } while (0)
+#define RETURN(rc) return (rc)
+#define ENTRY do { } while (0)
+#define EXIT do { } while (0)
+#endif /* !__KERNEL__ */
#define LUSTRE_SRV_PTL_PID LUSTRE_PTL_PID
-#define PORTALS_CFG_VERSION 0x00010001
+/*
+ * eeb cfg
+ * ecf6
+ * ecfG
+ */
+#define PORTALS_CFG_VERSION 0xecf60001
struct portals_cfg {
__u32 pcfg_version;
__u32 pcfg_flags;
__u32 pcfg_gw_nal;
+ __u32 pcfg_padding1;
+
__u64 pcfg_nid;
__u64 pcfg_nid2;
__u64 pcfg_nid3;
__u32 pcfg_wait;
__u32 pcfg_plen1; /* buffers in userspace */
- char *pcfg_pbuf1;
__u32 pcfg_plen2; /* buffers in userspace */
- char *pcfg_pbuf2;
+ __u32 pcfg_alloc_size; /* size of this allocated portals_cfg */
+ char pcfg_pbuf[0];
};
#define PCFG_INIT(pcfg, cmd) \
do { \
- memset(&pcfg, 0, sizeof(pcfg)); \
- pcfg.pcfg_version = PORTALS_CFG_VERSION; \
- pcfg.pcfg_command = (cmd); \
+ memset(&(pcfg), 0, sizeof((pcfg))); \
+ (pcfg).pcfg_version = PORTALS_CFG_VERSION; \
+ (pcfg).pcfg_command = (cmd); \
\
} while (0)
+#define PCFG_INIT_PBUF(pcfg, cmd, plen1, plen2) \
+ do { \
+ int bufsize = size_round(sizeof(*(pcfg))); \
+ bufsize += size_round(plen1) + size_round(plen2); \
+ PORTAL_ALLOC((pcfg), bufsize); \
+ if ((pcfg)) { \
+ memset((pcfg), 0, bufsize); \
+ (pcfg)->pcfg_version = PORTALS_CFG_VERSION; \
+ (pcfg)->pcfg_command = (cmd); \
+ (pcfg)->pcfg_plen1 = (plen1); \
+ (pcfg)->pcfg_plen2 = (plen2); \
+ (pcfg)->pcfg_alloc_size = bufsize; \
+ } \
+ } while (0)
+
+#define PCFG_FREE_PBUF(pcfg) PORTAL_FREE((pcfg), (pcfg)->pcfg_alloc_size)
+
+#define PCFG_PBUF(pcfg, idx) \
+ (0 == (idx) \
+ ? ((char *)(pcfg) + size_round(sizeof(*(pcfg)))) \
+ : (1 == (idx) \
+ ? ((char *)(pcfg) + size_round(sizeof(*(pcfg))) + size_round(pcfg->pcfg_plen1)) \
+ : (NULL)))
+
typedef int (nal_cmd_handler_fn)(struct portals_cfg *, void *);
int libcfs_nal_cmd_register(int nal, nal_cmd_handler_fn *handler, void *arg);
int libcfs_nal_cmd(struct portals_cfg *pcfg);
#define CFS_LIST_HEAD(n) LIST_HEAD(n)
#define CFS_INIT_LIST_HEAD(p) INIT_LIST_HEAD(p)
-#else /* !defined (__linux__) && defined(__KERNEL__) */
+#else /* !defined (__linux__) || !defined(__KERNEL__) */
/*
* Simple doubly linked list implementation.
case(GMNAL_IOC_GET_GNID):
PORTAL_ALLOC(name, pcfg->pcfg_plen1);
- copy_from_user(name, pcfg->pcfg_pbuf1, pcfg->pcfg_plen1);
+ copy_from_user(name, PCFG_PBUF(pcfg, 1), pcfg->pcfg_plen1);
GMNAL_GM_LOCK(nal_data);
//nid = gm_host_name_to_node_id(nal_data->gm_port, name);
return(-1);
}
CDEBUG(D_INFO, "Global node is is [%u][%x]\n", gnid, gnid);
- copy_to_user(pcfg->pcfg_pbuf2, &gnid, pcfg->pcfg_plen2);
+ copy_to_user(PCFG_PBUF(pcfg, 2), &gnid, pcfg->pcfg_plen2);
break;
default:
CDEBUG(D_INFO, "gmnal_cmd UNKNOWN[%d]\n", pcfg->pcfg_command);
ktx = list_entry (tmp, kqswnal_tx_t, ktx_list);
hdr = (ptl_hdr_t *)ktx->ktx_buffer;
- pcfg->pcfg_pbuf1 = (char *)ktx;
+ memcpy(pcfg->pcfg_pbuf, ktx,
+ MIN(sizeof(*ktx), pcfg->pcfg_plen1));
pcfg->pcfg_count = le32_to_cpu(hdr->type);
pcfg->pcfg_size = le32_to_cpu(hdr->payload_length);
pcfg->pcfg_nid = le64_to_cpu(hdr->dest_nid);
case VIBNAL:
case OPENIBNAL:
case RANAL:
- case SOCKNAL:
+ case SOCKNAL: {
+ /* HIPQUAD requires __u32, but we can't cast in it */
+ __u32 nid32 = (__u32)nid;
if ((__u32)(nid >> 32)) {
snprintf(str, PTL_NALFMT_SIZE, "%u:%u.%u.%u.%u",
- (__u32)(nid >> 32), HIPQUAD(nid));
+ (__u32)(nid >> 32), HIPQUAD(nid32));
} else {
snprintf(str, PTL_NALFMT_SIZE, "%u.%u.%u.%u",
- HIPQUAD(nid));
+ HIPQUAD(nid32));
}
break;
+ }
case QSWNAL:
case GMNAL:
case LONAL:
int rc = -EINVAL;
ENTRY;
+ if (pcfg->pcfg_version != PORTALS_CFG_VERSION) {
+ RETURN(-EINVAL);
+ }
+
mutex_down(&nal_cmd_mutex);
cmd = libcfs_find_nal_cmd_handler(nal);
if (cmd != NULL) {
CDEBUG (D_IOCTL, "nal command nal %x cmd %d\n", pcfg.pcfg_nal,
pcfg.pcfg_command);
- err = libcfs_nal_cmd(&pcfg);
+ if (pcfg.pcfg_version != PORTALS_CFG_VERSION) {
+ /* set this so userspace can tell when they
+ * have an incompatible version and print a
+ * decent message to the user
+ */
+ pcfg.pcfg_version = PORTALS_CFG_VERSION;
+ if (copy_to_user((char *)data->ioc_pbuf1, &pcfg,
+ sizeof (pcfg)))
+ err = -EFAULT;
+ else
+ err = -EINVAL;
+ } else {
+ err = libcfs_nal_cmd(&pcfg);
- if (err == 0 &&
- copy_to_user((char *)data->ioc_pbuf1, &pcfg,
- sizeof (pcfg)))
- err = -EFAULT;
+ if (err == 0 &&
+ copy_to_user((char *)data->ioc_pbuf1, &pcfg,
+ sizeof (pcfg)))
+ err = -EFAULT;
+ }
break;
}
tcd = trace_get_tcd(flags);
spin_lock(&pc->pc_lock);
- list_splice_init(&tcd->tcd_pages, &pc->pc_pages);
+ list_splice(&tcd->tcd_pages, &pc->pc_pages);
+ CFS_INIT_LIST_HEAD(&tcd->tcd_pages);
tcd->tcd_cur_pages = 0;
if (pc->pc_want_daemon_pages) {
- list_splice_init(&tcd->tcd_daemon_pages, &pc->pc_pages);
+ list_splice(&tcd->tcd_daemon_pages, &pc->pc_pages);
+ CFS_INIT_LIST_HEAD(&tcd->tcd_pages);
tcd->tcd_cur_daemon_pages = 0;
}
spin_unlock(&pc->pc_lock);
}
}
CFS_MMSPACE_CLOSE;
- cfs_filp_close(filp);
+ cfs_filp_close(filp);
put_pages_on_daemon_list(&pc);
}
complete(&tctl->tctl_stop);
#endif
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#else
+#include "ioctl.h"
+#endif
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#ifdef HAVE_LINUX_VERSION_H
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
struct mod_paths *mp;
- char *path = "..";
+ char *path = "";
char *kernel = "linux";
if (argc >= 2)
printf("query_module(%s) failed: %s\n",
mp->name, strerror(errno));
} else {
- printf("add-symbol-file %s/%s/%s.o 0x%0lx\n", path,
- mp->path, mp->name,
+ printf("add-symbol-file %s%s%s/%s.o 0x%0lx\n", path,
+ path[0] ? "/" : "", mp->path, mp->name,
info.addr + sizeof(struct module));
}
}
static int jt_dbg_modules_2_5(int argc, char **argv)
{
struct mod_paths *mp;
- char *path = "..";
+ char *path = "";
char *kernel = "linux";
const char *proc = "/proc/modules";
char modname[128], others[128];
break;
}
if (mp->name) {
- printf("add-symbol-file %s/%s/%s.o 0x%0lx\n", path,
- mp->path, mp->name, modaddr);
+ printf("add-symbol-file %s%s%s/%s.o 0x%0lx\n", path,
+ path[0] ? "/" : "", mp->path, mp->name, modaddr);
}
}
*/
#define GM_UNIT 0
-/*
- * prototypes
- */
-unsigned u_getgmnid(char *name, int get_local_id);
-void usage(char *prg, int h);
-
-int main(int argc, char **argv)
+void
+usage(char *prg, int h)
{
- unsigned int nid = 0;
- char *name = NULL;
- int c;
- int get_local_id = 0;
-
-
-
- while ((c = getopt(argc, argv, "n:lh")) != -1) {
- switch(c) {
- case('n'):
- if (get_local_id) {
- usage(argv[0], 0);
- exit(-1);
- }
- name = optarg;
- break;
- case('h'):
- usage(argv[0], 1);
- exit(-1);
- break;
- case('l'):
- if (name) {
- usage(argv[0], 0);
- exit(-1);
- }
- get_local_id = 1;
- break;
- default:
- usage(argv[0], 0);
- exit(-1);
- }
- }
-
- if (!name && !get_local_id) {
- usage(argv[0], 0);
- exit(-1);
- }
-
- nid = u_getgmnid(name, get_local_id);
- printf("%u\n", nid);
- exit(0);
+ fprintf(stderr, "usage %s -n hostname | -l | -h\n", prg);
+ if (h) {
+ printf("\nGet Myrinet Global network ids for specified host\n"
+ "-l gets network id for local host\n");
+ }
}
unsigned
u_getgmnid(char *name, int get_local_id)
{
- struct gm_port *gm_port;
- int gm_port_id = 2;
- gm_status_t gm_status = GM_SUCCESS;
+ struct gm_port *gm_port;
+ int gm_port_id = 2;
+ gm_status_t gm_status = GM_SUCCESS;
+ unsigned global_nid = 0, local_nid = 0; /* gm ids never 0 */
- /*
- * gm global or local ids are never 0
- */
- unsigned global_nid = 0, local_nid = 0;
+ gm_status = gm_init();
+ if (gm_status != GM_SUCCESS) {
+ fprintf(stderr, "gm_init: %s\n", gm_strerror(gm_status));
+ return(0);
+ }
- gm_status = gm_init();
- if (gm_status != GM_SUCCESS) {
- fprintf(stderr, "gm_init :: %s\n", gm_strerror(gm_status));
- return(0);
- }
-
- gm_status = gm_open(&gm_port, GM_UNIT, gm_port_id,
- "gmnalnid", GM_API_VERSION);
+ gm_status = gm_open(&gm_port, GM_UNIT, gm_port_id, "gmnalnid",
+ GM_API_VERSION);
+ if (gm_status != GM_SUCCESS) {
+ /* Couldn't open port 2, try 4 5 6 7 */
+ for (gm_port_id = 4; gm_port_id < 8; gm_port_id++) {
+ gm_status = gm_open(&gm_port, GM_UNIT, gm_port_id,
+ "gmnalnid", GM_API_VERSION);
+ if (gm_status == GM_SUCCESS)
+ break;
+
+ fprintf(stderr, "gm_open: %s\n",gm_strerror(gm_status));
+ gm_finalize();
+ return(0);
+ }
+ }
- if (gm_status != GM_SUCCESS) {
- /*
- * Couldn't open port 2
- * try 4 5 6 7
- */
-
- for (gm_port_id=4; gm_port_id<8; gm_port_id++) {
- gm_status = gm_open(&gm_port,
- GM_UNIT,
- gm_port_id,
- "gmnalnid",
- GM_API_VERSION);
- if (gm_status == GM_SUCCESS) {
- break;
- }
- fprintf(stderr, "gm_open :: %s\n",
- gm_strerror(gm_status));
- gm_finalize();
- return(0);
+ if (get_local_id) {
+ local_nid = 1;
+ } else {
+ gm_status = gm_host_name_to_node_id_ex(gm_port, 1000000, name,
+ &local_nid);
+ if (gm_status != GM_SUCCESS) {
+ fprintf(stderr, "gm_host_name_to_node_id_ex: %s\n",
+ gm_strerror(gm_status));
+ gm_close(gm_port);
+ gm_finalize();
+ return(0);
+ }
}
- }
- if (get_local_id) {
- local_nid = 1;
- } else {
- gm_status = gm_host_name_to_node_id_ex(gm_port, 1000000, name,
- &local_nid);
+ gm_status = gm_node_id_to_global_id(gm_port, local_nid, &global_nid) ;
if (gm_status != GM_SUCCESS) {
- fprintf(stderr, "gm_host_name_to_node_id_ex :: %s\n",
- gm_strerror(gm_status));
- gm_close(gm_port);
- gm_finalize();
- return(0);
+ fprintf(stderr, "gm_node_id_to_global_id: %s\n",
+ gm_strerror(gm_status));
+ gm_close(gm_port);
+ gm_finalize();
+ return(0);
}
- }
-
- gm_status = gm_node_id_to_global_id(gm_port, local_nid, &global_nid) ;
- if (gm_status != GM_SUCCESS) {
- fprintf(stderr, "gm_node_id_to_global_id :: %s\n",
- gm_strerror(gm_status));
gm_close(gm_port);
gm_finalize();
- return(0);
- }
- gm_close(gm_port);
- gm_finalize();
- return(global_nid);
+ return(global_nid);
}
-void
-usage(char *prg, int h)
+int main(int argc, char **argv)
{
+ unsigned int nid = 0;
+ char *name = NULL;
+ int c;
+ int get_local_id = 0;
+
+ while ((c = getopt(argc, argv, "n:lh")) != -1) {
+ switch(c) {
+ case('n'):
+ if (get_local_id) {
+ usage(argv[0], 0);
+ exit(-1);
+ }
+ name = optarg;
+ break;
+ case('h'):
+ usage(argv[0], 1);
+ exit(-1);
+ break;
+ case('l'):
+ if (name) {
+ usage(argv[0], 0);
+ exit(-1);
+ }
+ get_local_id = 1;
+ break;
+ default:
+ usage(argv[0], 0);
+ exit(-1);
+ }
+ }
+
+ if (!name && !get_local_id) {
+ usage(argv[0], 0);
+ exit(-1);
+ }
- fprintf(stderr, "usage %s -n hostname | -l | -h\n", prg);
- if (h) {
- printf("\nGet Myrinet Global network ids for specified host\n");
- printf("-l gets network id for local host\n");
- }
- return;
+ nid = u_getgmnid(name, get_local_id);
+ printf("%u\n", nid);
+ exit(0);
}
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
+#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
+#else
+#include "ioctl.h"
+#endif
#include <errno.h>
#include <unistd.h>
#include <time.h>
data.ioc_nid = pcfg->pcfg_nid;
rc = l_ioctl (PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data);
+
+ if (rc == 0 && pcfg->pcfg_version != PORTALS_CFG_VERSION)
+ return -EINVAL;
}
return (rc);
pcfg.pcfg_fd, pcfg.pcfg_count);
}
- if (index == 0)
- printf ("<no interfaces>\n");
+ if (index == 0) {
+ if (errno == ENOENT) {
+ printf ("<no interfaces>\n");
+ } else {
+ fprintf(stderr, "Error getting interfaces: %s: "
+ "check dmesg.\n",
+ strerror(errno));
+ }
+ }
+
return 0;
}
pcfg.pcfg_nid, pcfg.pcfg_wait);
}
- if (index == 0)
- printf ("<no peers>\n");
+ if (index == 0) {
+ if (errno == ENOENT) {
+ printf ("<no peers>\n");
+ } else {
+ fprintf(stderr, "Error getting peer list: %s: "
+ "check dmesg.\n",
+ strerror(errno));
+ }
+ }
return 0;
}
OPENIBNAL, IIBNAL, VIBNAL, 0))
return -1;
- for (index = 0;;index++) {
+ for (index = 0; ; index++) {
PCFG_INIT (pcfg, NAL_CMD_GET_CONN);
pcfg.pcfg_count = index;
pcfg.pcfg_nid);
}
- if (index == 0)
- printf ("<no connections>\n");
+ if (index == 0) {
+ if (errno == ENOENT) {
+ printf ("<no connections>\n");
+ } else {
+ fprintf(stderr, "Error getting connection list: %s: "
+ "check dmesg.\n",
+ strerror(errno));
+ }
+ }
return 0;
}
if (rc != 0)
break;
- printf ("%p: %5s payload %6d bytes to "LPX64" via "LPX64" by pid %6d: %s, %s, state %d\n",
- pcfg.pcfg_pbuf1,
+ printf ("%5s payload %6d bytes to "LPX64" via "LPX64" by pid %6d: %s, %s, state %d\n",
pcfg.pcfg_count == PTL_MSG_ACK ? "ACK" :
pcfg.pcfg_count == PTL_MSG_PUT ? "PUT" :
pcfg.pcfg_count == PTL_MSG_GET ? "GET" :
- pcfg.pcfg_count == PTL_MSG_REPLY ? "REPLY" : "<wierd message>",
+ pcfg.pcfg_count == PTL_MSG_REPLY ? "REPLY" : "<weird message>",
pcfg.pcfg_size,
pcfg.pcfg_nid,
pcfg.pcfg_nid2,
pcfg.pcfg_flags >> 2);
}
- if (index == 0)
- printf ("<no active descs>\n");
+ if (index == 0) {
+ if (errno == ENOENT) {
+ printf ("<no active descs>\n");
+ } else {
+ fprintf(stderr, "Error getting active transmits list: "
+ "%s: check dmesg.\n",
+ strerror(errno));
+ }
+ }
return 0;
}
ptl_nid2str (buffer[2], nid2),
alive ? "up" : "down");
}
+
+ if (index == 0 && errno != ENOENT) {
+ fprintf(stderr, "Error getting routes: %s: check dmesg.\n",
+ strerror(errno));
+ }
return (0);
}