components/open-fabrics/libibumad/patches/base.patch
author Boris Chiu <boris.chiu@oracle.com>
Thu, 05 Jun 2014 10:22:33 -0700
changeset 1934 49005740c7f6
parent 1793 b253729db1c0
permissions -rw-r--r--
18865372 modify libibumad on solaris to avoid call to ibv_open_device
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
     1
diff -r -u /tmp/libibumad-1.3.7/Makefile.in libibumad-1.3.7/Makefile.in
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
     2
--- /tmp/libibumad-1.3.7/Makefile.in	Mon Feb 14 06:18:00 2011
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
     3
+++ libibumad-1.3.7/Makefile.in	Fri Feb 25 03:11:40 2011
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
     4
@@ -367,8 +367,8 @@
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
     5
 	  else :; fi; \
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
     6
 	done; \
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
     7
 	test -z "$$list2" || { \
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
     8
-	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
     9
-	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    10
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) -m 755 $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    11
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) -m 755 $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    12
 	}
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    13
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    14
 uninstall-libLTLIBRARIES:
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    15
diff -r -u /tmp/libibumad-1.3.7/include/infiniband/umad.h libibumad-1.3.7/include/infiniband/umad.h
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    16
--- /tmp/libibumad-1.3.7/include/infiniband/umad.h	Mon Feb 14 01:08:29 2011
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    17
+++ libibumad-1.3.7/include/infiniband/umad.h	Fri May 13 04:28:12 2011
1793
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    18
@@ -45,7 +45,15 @@
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    19
 #endif				/* __cplusplus */
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    20
 
1793
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    21
 BEGIN_C_DECLS
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    22
-#define UMAD_MAX_DEVICES 32
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    23
+/* To accomodate max. of 16 PCIe slots and 63 VFs per HCA, */
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    24
+/* we define	MAX_HCAS = (63VFs + 1PF) * 16HCAs */
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    25
+/* 		MAX_PORTS = MAX_HCAS * 2ports per HCA */
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    26
+#define MAX_HCAS	(64*16)
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    27
+#define MAX_PORTS	(MAX_HCAS*2)
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    28
+#define UMAD_MAX_DEVICES MAX_HCAS
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    29
+#define	UMAD_MAX_HCAS	MAX_HCAS
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    30
+#define	UMAD_MAX_PORTS	MAX_PORTS
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    31
+
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    32
 #define UMAD_ANY_PORT	0
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    33
 typedef struct ib_mad_addr {
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    34
 	uint32_t qpn;
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    35
@@ -94,9 +102,13 @@
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    36
 #define SYS_IB_MAD_PORT		"port"
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    37
 #define SYS_IB_MAD_DEV		"ibdev"
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    38
 
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    39
-#define UMAD_MAX_PORTS		64
b253729db1c0 18117487 saquery -m -t 50000 failed with multiple VFs created
Boris Chiu <boris.chiu@oracle.com>
parents: 900
diff changeset
    40
+#define UMAD_MAX_PORTS		MAX_PORTS
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    41
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    42
+#if defined(__SVR4) && defined(__sun)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    43
+#define	UMAD_DEV_DIR		"/dev/infiniband/ofs"
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    44
+#else
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    45
 #define UMAD_DEV_DIR		"/dev/infiniband"
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    46
+#endif
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    47
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    48
 #define SYS_CA_PORTS_DIR	"ports"
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    49
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    50
diff -r -u /tmp/libibumad-1.3.7/configure libibumad-1.3.7/configure
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    51
--- /tmp/libibumad-1.3.7/configure	Mon Feb 14 06:18:01 2011
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    52
+++ libibumad-1.3.7/configure	Thu Feb 24 11:27:18 2011
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    53
@@ -8713,6 +8713,7 @@
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    54
 	;;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    55
       esac
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    56
       link_all_deplibs=yes
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    57
+      hardcode_libdir_flag_spec=
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    58
       ;;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    59
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    60
     sunos4*)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    61
diff -r -u /tmp/libibumad-1.3.7/src/sysfs.c libibumad-1.3.7/src/sysfs.c
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    62
--- /tmp/libibumad-1.3.7/src/sysfs.c	Mon Feb 14 01:08:29 2011
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    63
+++ libibumad-1.3.7/src/sysfs.c	Thu Feb 24 11:27:30 2011
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    64
@@ -46,9 +46,14 @@
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    65
 #include <sys/types.h>
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    66
 #include <sys/stat.h>
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    67
 #include <fcntl.h>
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    68
+#if !(defined(__SVR4) && defined(__sun))
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    69
 #include <endian.h>
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    70
 #include <byteswap.h>
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    71
+#endif
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    72
 #include <netinet/in.h>
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    73
+#if defined(__SVR4) && defined(__sun)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    74
+#include <infiniband/driver.h>
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    75
+#endif
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    76
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    77
 #if __BYTE_ORDER == __LITTLE_ENDIAN
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    78
 #define htonll(x) bswap_64(x)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    79
@@ -70,6 +75,16 @@
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    80
 	char path[256], *s;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    81
 	int fd, r;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    82
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    83
+#if defined(__SVR4) && defined(__sun)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    84
+	if ((r = ibv_read_sysfs_file(dir_name, file_name, str, max_len)) < 0) {
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    85
+		return -EINVAL;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    86
+	}
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    87
+
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    88
+	str[(r < max_len) ? r : max_len - 1] = 0;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    89
+
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    90
+	if ((s = strrchr(str, '\n')))
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    91
+		*s = 0;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    92
+#else
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    93
 	snprintf(path, sizeof(path), "%s/%s", dir_name, file_name);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    94
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    95
 	if ((fd = open(path, O_RDONLY)) < 0)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    96
@@ -88,6 +103,7 @@
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    97
 		*s = 0;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    98
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
    99
 	close(fd);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   100
+#endif
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   101
 	return 0;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   102
 }
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   103
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   104
diff -r -u /tmp/libibumad-1.3.7/src/umad.c libibumad-1.3.7/src/umad.c
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   105
--- /tmp/libibumad-1.3.7/src/umad.c	Mon Feb 14 01:08:29 2011
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   106
+++ libibumad-1.3.7/src/umad.c	Fri May  6 05:18:47 2011
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   107
@@ -50,6 +50,11 @@
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   108
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   109
 #include "umad.h"
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   110
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   111
+#if defined(__SVR4) && defined(__sun)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   112
+#include <infiniband/verbs.h>
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   113
+#define IB_OFS_DEVPATH_PREFIX	"/dev/infiniband/ofs"
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   114
+#endif
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   115
+
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   116
 #define IB_OPENIB_OUI                 (0x001405)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   117
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   118
 #ifdef HAVE_VALGRIND_MEMCHECK_H
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   119
@@ -82,7 +87,7 @@
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   120
 extern int sys_read_uint64(char *dir_name, char *file_name, uint64_t * u);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   121
 extern int sys_read_uint(char *dir_name, char *file_name, unsigned *u);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   122
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   123
-#define IBWARN(fmt, args...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", getpid(), __func__, ## args)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   124
+#define IBWARN(fmt, args...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", (int)getpid(), __func__, ## args)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   125
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   126
 #define TRACE	if (umaddebug)	IBWARN
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   127
 #define DEBUG	if (umaddebug)	IBWARN
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   128
@@ -126,7 +131,12 @@
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   129
 	return *p ? 0 : 1;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   130
 }
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   131
 
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   132
+#if defined(__SVR4) && defined(__sun)
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   133
+static int get_port(char *ca_name, char *dir, int portnum,
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   134
+    struct ibv_context *ctx, umad_port_t * port)
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   135
+#else
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   136
 static int get_port(char *ca_name, char *dir, int portnum, umad_port_t * port)
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   137
+#endif
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   138
 {
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   139
 	char port_dir[256];
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   140
 	uint8_t gid[16];
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   141
@@ -172,6 +182,39 @@
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   142
 	memcpy(&port->port_guid, gid + 8, sizeof port->port_guid);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   143
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   144
 	snprintf(port_dir + len, sizeof(port_dir) - len, "/pkeys");
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   145
+
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   146
+#if defined(__SVR4) && defined(__sun)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   147
+	{
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   148
+		struct ibv_port_attr	port_attr;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   149
+
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   150
+		if (sol_ibv_query_port(ctx, portnum, &port_attr)) {
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   151
+			IBWARN("Could not query \"%s\" port %d", ca_name,
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   152
+			       portnum);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   153
+			goto clean;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   154
+		}
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   155
+
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   156
+		port->pkeys =
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   157
+		    malloc(sizeof (uint16_t) * port_attr.pkey_tbl_len);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   158
+
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   159
+		if (!port->pkeys) {
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   160
+			IBWARN("Could not retrieve pkeys for \"%s\"", ca_name);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   161
+			goto clean;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   162
+		}
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   163
+
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   164
+		/*
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   165
+		 * set high bit of port_num, and try get all pkeys in one go.
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   166
+		 */
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   167
+		portnum |= 0x80;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   168
+		num_pkeys = ibv_query_pkey(ctx, portnum, port_attr.pkey_tbl_len,
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   169
+		    port->pkeys);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   170
+		if (num_pkeys != 0) {
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   171
+			IBWARN("get_port: ibv_query_pkey() failed for \"%s\"",
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   172
+			    ca_name);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   173
+			goto clean;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   174
+		}
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   175
+		port->pkeys_size = port_attr.pkey_tbl_len;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   176
+	}
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   177
+#else
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   178
 	num_pkeys = scandir(port_dir, &namelist, check_for_digit_name, NULL);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   179
 	if (num_pkeys <= 0) {
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   180
 		IBWARN("no pkeys found for %s:%u (at dir %s)...",
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   181
@@ -193,6 +236,8 @@
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   182
 	port->pkeys_size = num_pkeys;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   183
 	free(namelist);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   184
 	namelist = NULL;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   185
+#endif
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   186
+
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   187
 	port_dir[len] = '\0';
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   188
 
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   189
 	/* FIXME: handle gids */
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   190
@@ -384,6 +429,7 @@
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   191
 	snprintf(dir_name, sizeof(dir_name), "%s/%s/%s",
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   192
 		 SYS_INFINIBAND, ca->ca_name, SYS_CA_PORTS_DIR);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   193
 
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   194
+#if !(defined(__SVR4) && defined(__sun))
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   195
 	if (!(dir = opendir(dir_name)))
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   196
 		return -ENOENT;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   197
 
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   198
@@ -425,15 +471,100 @@
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   199
 	free(namelist);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   200
 
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   201
 	closedir(dir);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   202
+#else
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   203
+	{
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   204
+		struct ibv_device	**root_dev_list, **dev_list = NULL;
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   205
+		struct ibv_context	ctx;
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   206
+		struct ibv_device_attr  dev_attr;
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   207
+		int			num_dev;
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   208
+		int                     ret;
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   209
+		char			uverbs_devpath[MAXPATHLEN];
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   210
+
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   211
+		root_dev_list = dev_list = ibv_get_device_list(&num_dev);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   212
+		if (!dev_list) {
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   213
+			IBWARN("No HCA devices found");
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   214
+			return -EIO;
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   215
+		}
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   216
+
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   217
+		for (i = 0; i < num_dev; i++, dev_list++) {
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   218
+			if (strcmp(ibv_get_device_name(*dev_list), ca_name)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   219
+			    == 0) {
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   220
+				break;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   221
+			}
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   222
+		}
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   223
+
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   224
+		if (i == num_dev) {
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   225
+			IBWARN("Could not find \"%s\"", ca_name);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   226
+			ibv_free_device_list(root_dev_list);
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   227
+			ret = -EIO;
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   228
+			goto clean;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   229
+		}
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   230
+
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   231
+		snprintf(uverbs_devpath, MAXPATHLEN, "%s/%s",
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   232
+		    IB_OFS_DEVPATH_PREFIX, (*dev_list)->dev_name);
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   233
+
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   234
+		ctx.device = *dev_list;
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   235
+
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   236
+		if ((ctx.cmd_fd = open(uverbs_devpath, O_RDWR)) < 0) {
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   237
+			IBWARN("failed to open device \"%s\"", ca_name);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   238
+			ibv_free_device_list(root_dev_list);
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   239
+			ret = -EIO;
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   240
+			goto clean;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   241
+		}
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   242
+
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   243
+		/* Get port count */
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   244
+		memset(&dev_attr, 0, sizeof (struct ibv_device_attr));
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   245
+		if (sol_ibv_query_device(*dev_list, &dev_attr) != 0) {
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   246
+			IBWARN("failed to query device \"%s\"", ca_name);
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   247
+			ibv_free_device_list(root_dev_list);
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   248
+			if (ctx.cmd_fd > 0)
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   249
+				close(ctx.cmd_fd);
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   250
+			ret = -EIO;
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   251
+			goto clean;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   252
+		}
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   253
+
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   254
+		ca->numports = 0;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   255
+		memset(ca->ports, 0, sizeof ca->ports);
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   256
+
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   257
+		for (portnum = 1; portnum <= dev_attr.phys_port_cnt; portnum++) {
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   258
+
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   259
+		        if (!(ca->ports[portnum] = calloc(1,
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   260
+			    sizeof(*ca->ports[portnum])))) {
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   261
+			        ret = -ENOMEM;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   262
+				ibv_free_device_list(root_dev_list);
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   263
+				if (ctx.cmd_fd > 0)
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   264
+					close(ctx.cmd_fd);
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   265
+				goto clean;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   266
+			}
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   267
+			if (get_port(ca_name, dir_name, portnum, &ctx,
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   268
+			    ca->ports[portnum]) < 0) {
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   269
+			        free(ca->ports[portnum]);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   270
+				ca->ports[portnum] = NULL;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   271
+				ret = -EIO;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   272
+				ibv_free_device_list(root_dev_list);
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   273
+				if (ctx.cmd_fd > 0)
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   274
+					close(ctx.cmd_fd);
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   275
+				goto clean;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   276
+			}
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   277
+			if (ca->numports < portnum)
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   278
+			        ca->numports = portnum;
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   279
+		}
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   280
+	}
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   281
+#endif
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   282
+
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   283
 	put_ca(ca);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   284
 	return 0;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   285
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   286
 clean:
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   287
+#if !(defined(__SVR4) && defined(__sun))
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   288
 	for (i = 0; i < r; i++)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   289
 		free(namelist[i]);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   290
 	free(namelist);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   291
+#endif
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   292
 error:
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   293
+#if !(defined(__SVR4) && defined(__sun))
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   294
 	closedir(dir);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   295
+#endif
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   296
 	release_ca(ca);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   297
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   298
 	return ret;
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   299
@@ -484,6 +615,11 @@
636
da28b1dc61e7 PSARC 2011/291 EOL Tavor IB HCA driver
Boris Chiu <Boris.Chiu@oracle.COM>
parents: 369
diff changeset
   300
 int umad_init(void)
da28b1dc61e7 PSARC 2011/291 EOL Tavor IB HCA driver
Boris Chiu <Boris.Chiu@oracle.COM>
parents: 369
diff changeset
   301
 {
da28b1dc61e7 PSARC 2011/291 EOL Tavor IB HCA driver
Boris Chiu <Boris.Chiu@oracle.COM>
parents: 369
diff changeset
   302
 	TRACE("umad_init");
da28b1dc61e7 PSARC 2011/291 EOL Tavor IB HCA driver
Boris Chiu <Boris.Chiu@oracle.COM>
parents: 369
diff changeset
   303
+	struct ibv_device **devlist = ibv_get_device_list(NULL);
da28b1dc61e7 PSARC 2011/291 EOL Tavor IB HCA driver
Boris Chiu <Boris.Chiu@oracle.COM>
parents: 369
diff changeset
   304
+	if (devlist == NULL) {
da28b1dc61e7 PSARC 2011/291 EOL Tavor IB HCA driver
Boris Chiu <Boris.Chiu@oracle.COM>
parents: 369
diff changeset
   305
+		IBWARN("No IB devices found");
da28b1dc61e7 PSARC 2011/291 EOL Tavor IB HCA driver
Boris Chiu <Boris.Chiu@oracle.COM>
parents: 369
diff changeset
   306
+		return -1;
da28b1dc61e7 PSARC 2011/291 EOL Tavor IB HCA driver
Boris Chiu <Boris.Chiu@oracle.COM>
parents: 369
diff changeset
   307
+	}
da28b1dc61e7 PSARC 2011/291 EOL Tavor IB HCA driver
Boris Chiu <Boris.Chiu@oracle.COM>
parents: 369
diff changeset
   308
 	if (sys_read_uint(IB_UMAD_ABI_DIR, IB_UMAD_ABI_FILE, &abi_version) < 0) {
da28b1dc61e7 PSARC 2011/291 EOL Tavor IB HCA driver
Boris Chiu <Boris.Chiu@oracle.COM>
parents: 369
diff changeset
   309
 		IBWARN
da28b1dc61e7 PSARC 2011/291 EOL Tavor IB HCA driver
Boris Chiu <Boris.Chiu@oracle.COM>
parents: 369
diff changeset
   310
 		    ("can't read ABI version from %s/%s (%m): is ib_umad module loaded?",
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   311
@@ -522,6 +658,28 @@
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   312
 
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   313
 int umad_get_cas_names(char cas[][UMAD_CA_NAME_LEN], int max)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   314
 {
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   315
+#if defined(__SVR4) && defined(__sun)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   316
+	struct ibv_device **devlist = ibv_get_device_list(NULL);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   317
+	int j = 0;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   318
+
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   319
+	TRACE("max %d", max);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   320
+
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   321
+	if (devlist) {
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   322
+		while (devlist[j] && j < max) {
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   323
+			strncpy(cas[j], ibv_get_device_name(devlist[j]),
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   324
+						UMAD_CA_NAME_LEN);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   325
+			j++;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   326
+		}
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   327
+		ibv_free_device_list(devlist);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   328
+		DEBUG("return %d cas", j);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   329
+	}
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   330
+	if (j == 0 && max > 0) {
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   331
+		/* Is this still needed ? */
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   332
+		strncpy((char *)cas, def_ca_name, UMAD_CA_NAME_LEN);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   333
+		DEBUG("return 1 ca");
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   334
+		j = 1;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   335
+	}
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   336
+#else
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   337
 	struct dirent **namelist;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   338
 	int n, i, j = 0;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   339
 
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   340
@@ -547,6 +705,7 @@
369
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   341
 	}
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   342
 	if (n >= 0)
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   343
 		free(namelist);
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   344
+#endif
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   345
 	return j;
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   346
 }
cc8c00719da9 PSARC 2011/165 OFUV update of existing components
Boris Chiu <Boris.Chiu@Sun.COM>
parents:
diff changeset
   347
 
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   348
@@ -673,7 +832,52 @@
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   349
 	snprintf(dir_name, sizeof(dir_name), "%s/%s/%s",
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   350
 		 SYS_INFINIBAND, ca_name, SYS_CA_PORTS_DIR);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   351
 
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   352
+#if defined(__SVR4) && defined(__sun)
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   353
+	{
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   354
+		struct ibv_device	**root_dev_list, **dev_list = NULL;
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   355
+		struct ibv_context	ctx;
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   356
+		int			num_dev, ret, i;
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   357
+		char			uverbs_devpath[MAXPATHLEN];
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   358
+
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   359
+		root_dev_list = dev_list = ibv_get_device_list(&num_dev);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   360
+		if (!dev_list) {
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   361
+			IBWARN("No HCA devices found");
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   362
+			return -EIO;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   363
+		}
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   364
+
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   365
+		for (i = 0; i < num_dev; i++, dev_list++) {
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   366
+			if (strcmp(ibv_get_device_name(*dev_list), ca_name)
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   367
+			    == 0) {
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   368
+				break;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   369
+			}
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   370
+		}
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   371
+
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   372
+		if (i == num_dev) {
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   373
+			IBWARN("Could not find \"%s\"", ca_name);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   374
+			ibv_free_device_list(root_dev_list);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   375
+			return -EIO;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   376
+		}
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   377
+
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   378
+
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   379
+		snprintf(uverbs_devpath, MAXPATHLEN, "%s/%s",
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   380
+		    IB_OFS_DEVPATH_PREFIX, (*dev_list)->dev_name);
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   381
+
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   382
+		if ((ctx.cmd_fd = open(uverbs_devpath, O_RDWR)) < 0) {
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   383
+			IBWARN("failed to open device \"%s\"", ca_name);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   384
+			ibv_free_device_list(root_dev_list);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   385
+			return -EIO;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   386
+		}
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   387
+
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   388
+		if ((ret = get_port(ca_name, dir_name, portnum, &ctx, port)) != 0) {
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   389
+		        ibv_free_device_list(root_dev_list);
1934
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   390
+			if (ctx.cmd_fd > 0)
49005740c7f6 18865372 modify libibumad on solaris to avoid call to ibv_open_device
Boris Chiu <boris.chiu@oracle.com>
parents: 1793
diff changeset
   391
+				close(ctx.cmd_fd);
900
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   392
+		}
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   393
+		return ret;
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   394
+	}
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   395
+#else
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   396
 	return get_port(ca_name, dir_name, portnum, port);
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   397
+#endif
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   398
 }
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   399
 
63d3bf696d85 7178014 Some OFED tools print errors with a single port HCA
Sharath M Srinivasan <sharath.srinivasan@oracle.com>
parents: 715
diff changeset
   400
 int umad_release_port(umad_port_t * port)