--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/open-fabrics/libibumad/patches/001-libibumad-solaris_port.patch Fri Jul 01 13:38:15 2016 -0700
@@ -0,0 +1,437 @@
+#This patch was developed both in-house and from outside. We plan to submit it
+#upstream, but do not yet have a target date for doing so
+#
+# HG changeset patch
+# Parent 2bd95ad341be80bc24c2f033948996ceecc52db7
+libibumad Solaris specific changes
+
+diff -r 2bd95ad341be Makefile.in
+--- a/Makefile.in Wed Oct 14 12:54:37 2015 -0700
++++ b/Makefile.in Fri Nov 13 07:28:27 2015 -0800
+@@ -411,8 +411,8 @@
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+- echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+- $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
++ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) -m 755 $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
++ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) -m 755 $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+ }
+
+ uninstall-libLTLIBRARIES:
+diff -r 2bd95ad341be configure
+--- a/configure Wed Oct 14 12:54:37 2015 -0700
++++ b/configure Fri Nov 13 07:28:27 2015 -0800
+@@ -8735,6 +8735,7 @@
+ ;;
+ esac
+ link_all_deplibs=yes
++ hardcode_libdir_flag_spec=
+ ;;
+
+ sunos4*)
+diff -r 2bd95ad341be include/infiniband/umad.h
+--- a/include/infiniband/umad.h Wed Oct 14 12:54:37 2015 -0700
++++ b/include/infiniband/umad.h Fri Nov 13 07:28:27 2015 -0800
+@@ -36,7 +36,9 @@
+
+ #include <stdint.h>
+ #include <stdlib.h>
++#if !(defined(__SVR4) && defined(__sun))
+ #include <byteswap.h>
++#endif
+ #include <arpa/inet.h>
+
+ #ifdef __cplusplus
+@@ -53,7 +55,15 @@
+ typedef uint32_t be32_t;
+ typedef uint64_t be64_t;
+
+-#define UMAD_MAX_DEVICES 32
++/* To accomodate max. of 16 PCIe slots and 63 VFs per HCA, */
++/* we define MAX_HCAS = (63VFs + 1PF) * 16HCAs */
++/* MAX_PORTS = MAX_HCAS * 2ports per HCA */
++#define MAX_HCAS (64*16)
++#define MAX_PORTS (MAX_HCAS*2)
++#define UMAD_MAX_DEVICES MAX_HCAS
++#define UMAD_MAX_HCAS MAX_HCAS
++#define UMAD_MAX_PORTS MAX_PORTS
++
+ #define UMAD_ANY_PORT 0
+ typedef struct ib_mad_addr {
+ be32_t qpn;
+@@ -104,9 +114,13 @@
+ #define SYS_IB_MAD_PORT "port"
+ #define SYS_IB_MAD_DEV "ibdev"
+
+-#define UMAD_MAX_PORTS 64
++#define UMAD_MAX_PORTS MAX_PORTS
+
++#if defined(__SVR4) && defined(__sun)
++#define UMAD_DEV_DIR "/dev/infiniband/ofs"
++#else
+ #define UMAD_DEV_DIR "/dev/infiniband"
++#endif
+
+ #define SYS_CA_PORTS_DIR "ports"
+
+@@ -229,6 +243,8 @@
+ free(umad);
+ }
+
++#if !(defined(__SVR4) && defined(__sun))
++
+ #ifndef ntohll
+ #if __BYTE_ORDER == __LITTLE_ENDIAN
+ #define ntohll(x) bswap_64(x)
+@@ -240,5 +256,9 @@
+ #define htonll ntohll
+ #endif
+
++#else
++#include <infiniband/ofa_solaris.h>
++#endif
++
+ END_C_DECLS
+ #endif /* _UMAD_H */
+diff -r 2bd95ad341be src/sysfs.c
+--- a/src/sysfs.c Wed Oct 14 12:54:37 2015 -0700
++++ b/src/sysfs.c Fri Nov 13 07:28:27 2015 -0800
+@@ -46,9 +46,14 @@
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
++#if !(defined(__SVR4) && defined(__sun))
+ #include <endian.h>
+ #include <byteswap.h>
++#endif
+ #include <netinet/in.h>
++#if defined(__SVR4) && defined(__sun)
++#include <infiniband/driver.h>
++#endif
+
+ #if __BYTE_ORDER == __LITTLE_ENDIAN
+ #define htonll(x) bswap_64(x)
+@@ -70,6 +75,16 @@
+ char path[256], *s;
+ int fd, r;
+
++#if defined(__SVR4) && defined(__sun)
++ if ((r = ibv_read_sysfs_file(dir_name, file_name, str, max_len)) < 0) {
++ return -EINVAL;
++ }
++
++ str[(r < max_len) ? r : max_len - 1] = 0;
++
++ if ((s = strrchr(str, '\n')))
++ *s = 0;
++#else
+ snprintf(path, sizeof(path), "%s/%s", dir_name, file_name);
+
+ if ((fd = open(path, O_RDONLY)) < 0)
+@@ -88,6 +103,7 @@
+ *s = 0;
+
+ close(fd);
++#endif
+ return 0;
+ }
+
+diff -r 2bd95ad341be src/umad.c
+--- a/src/umad.c Wed Oct 14 12:54:37 2015 -0700
++++ b/src/umad.c Fri Nov 13 07:28:27 2015 -0800
+@@ -52,6 +52,11 @@
+
+ #include "umad.h"
+
++#if defined(__SVR4) && defined(__sun)
++#include <infiniband/verbs.h>
++#define IB_OFS_DEVPATH_PREFIX "/dev/infiniband/ofs"
++#endif
++
+ #define IB_OPENIB_OUI (0x001405)
+
+ #ifdef HAVE_VALGRIND_MEMCHECK_H
+@@ -97,7 +102,7 @@
+ extern int sys_read_uint64(const char *dir_name, const char *file_name, uint64_t * u);
+ extern int sys_read_uint(const char *dir_name, const char *file_name, unsigned *u);
+
+-#define IBWARN(fmt, args...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", getpid(), __func__, ## args)
++#define IBWARN(fmt, args...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", (int)getpid(), __func__, ## args)
+
+ #define TRACE if (umaddebug) IBWARN
+ #define DEBUG if (umaddebug) IBWARN
+@@ -141,7 +146,12 @@
+ return *p ? 0 : 1;
+ }
+
+-static int get_port(const char *ca_name, const char *dir, int portnum, umad_port_t * port)
++#if defined(__SVR4) && defined(__sun)
++static int get_port(char *ca_name, const char *dir, int portnum,
++ struct ibv_context *ctx, umad_port_t * port)
++#else
++ static int get_port(const char *ca_name, const char *dir, int portnum, umad_port_t * port)
++#endif
+ {
+ char port_dir[256];
+ uint8_t gid[16];
+@@ -187,6 +197,39 @@
+ memcpy(&port->port_guid, gid + 8, sizeof port->port_guid);
+
+ snprintf(port_dir + len, sizeof(port_dir) - len, "/pkeys");
++
++#if defined(__SVR4) && defined(__sun)
++ {
++ struct ibv_port_attr port_attr;
++
++ if (sol_ibv_query_port(ctx, portnum, &port_attr)) {
++ IBWARN("Could not query \"%s\" port %d", ca_name,
++ portnum);
++ goto clean;
++ }
++
++ port->pkeys =
++ malloc(sizeof (uint16_t) * port_attr.pkey_tbl_len);
++
++ if (!port->pkeys) {
++ IBWARN("Could not retrieve pkeys for \"%s\"", ca_name);
++ goto clean;
++ }
++
++ /*
++ * set high bit of port_num, and try get all pkeys in one go.
++ */
++ portnum |= 0x80;
++ num_pkeys = ibv_query_pkey(ctx, portnum, port_attr.pkey_tbl_len,
++ port->pkeys);
++ if (num_pkeys != 0) {
++ IBWARN("get_port: ibv_query_pkey() failed for \"%s\"",
++ ca_name);
++ goto clean;
++ }
++ port->pkeys_size = port_attr.pkey_tbl_len;
++ }
++#else
+ num_pkeys = scandir(port_dir, &namelist, check_for_digit_name, NULL);
+ if (num_pkeys <= 0) {
+ IBWARN("no pkeys found for %s:%u (at dir %s)...",
+@@ -208,6 +251,8 @@
+ port->pkeys_size = num_pkeys;
+ free(namelist);
+ namelist = NULL;
++#endif
++
+ port_dir[len] = '\0';
+
+ /* FIXME: handle gids */
+@@ -420,6 +465,7 @@
+ snprintf(dir_name, sizeof(dir_name), "%s/%s/%s",
+ SYS_INFINIBAND, ca->ca_name, SYS_CA_PORTS_DIR);
+
++#if !(defined(__SVR4) && defined(__sun))
+ if (!(dir = opendir(dir_name)))
+ return -ENOENT;
+
+@@ -461,15 +507,100 @@
+ free(namelist);
+
+ closedir(dir);
++#else
++ {
++ struct ibv_device **root_dev_list, **dev_list = NULL;
++ struct ibv_context ctx;
++ struct ibv_device_attr dev_attr;
++ int num_dev;
++ int ret;
++ char uverbs_devpath[MAXPATHLEN];
++
++ root_dev_list = dev_list = ibv_get_device_list(&num_dev);
++ if (!dev_list) {
++ IBWARN("No HCA devices found");
++ return -EIO;
++ }
++
++ for (i = 0; i < num_dev; i++, dev_list++) {
++ if (strcmp(ibv_get_device_name(*dev_list), ca_name)
++ == 0) {
++ break;
++ }
++ }
++
++ if (i == num_dev) {
++ IBWARN("Could not find \"%s\"", ca_name);
++ ibv_free_device_list(root_dev_list);
++ ret = -EIO;
++ goto clean;
++ }
++
++ snprintf(uverbs_devpath, MAXPATHLEN, "%s/%s",
++ IB_OFS_DEVPATH_PREFIX, (*dev_list)->dev_name);
++
++ ctx.device = *dev_list;
++
++ if ((ctx.cmd_fd = open(uverbs_devpath, O_RDWR)) < 0) {
++ IBWARN("failed to open device \"%s\"", ca_name);
++ ibv_free_device_list(root_dev_list);
++ ret = -EIO;
++ goto clean;
++ }
++
++ /* Get port count */
++ memset(&dev_attr, 0, sizeof (struct ibv_device_attr));
++ if (sol_ibv_query_device(*dev_list, &dev_attr) != 0) {
++ IBWARN("failed to query device \"%s\"", ca_name);
++ ibv_free_device_list(root_dev_list);
++ if (ctx.cmd_fd > 0)
++ close(ctx.cmd_fd);
++ ret = -EIO;
++ goto clean;
++ }
++
++ ca->numports = 0;
++ memset(ca->ports, 0, sizeof ca->ports);
++
++ for (portnum = 1; portnum <= dev_attr.phys_port_cnt; portnum++) {
++
++ if (!(ca->ports[portnum] = calloc(1,
++ sizeof(*ca->ports[portnum])))) {
++ ret = -ENOMEM;
++ ibv_free_device_list(root_dev_list);
++ if (ctx.cmd_fd > 0)
++ close(ctx.cmd_fd);
++ goto clean;
++ }
++ if (get_port(ca_name, dir_name, portnum, &ctx,
++ ca->ports[portnum]) < 0) {
++ free(ca->ports[portnum]);
++ ca->ports[portnum] = NULL;
++ ret = -EIO;
++ ibv_free_device_list(root_dev_list);
++ if (ctx.cmd_fd > 0)
++ close(ctx.cmd_fd);
++ goto clean;
++ }
++ if (ca->numports < portnum)
++ ca->numports = portnum;
++ }
++ }
++#endif
++
+ put_ca(ca);
+ return 0;
+
+ clean:
++#if !(defined(__SVR4) && defined(__sun))
+ for (i = 0; i < r; i++)
+ free(namelist[i]);
+ free(namelist);
++#endif
+ error:
++#if !(defined(__SVR4) && defined(__sun))
+ closedir(dir);
++#endif
+ release_ca(ca);
+
+ return ret;
+@@ -520,6 +651,11 @@
+ int umad_init(void)
+ {
+ TRACE("umad_init");
++ struct ibv_device **devlist = ibv_get_device_list(NULL);
++ if (devlist == NULL) {
++ IBWARN("No IB devices found");
++ return -1;
++ }
+ if (sys_read_uint(IB_UMAD_ABI_DIR, IB_UMAD_ABI_FILE, &abi_version) < 0) {
+ IBWARN
+ ("can't read ABI version from %s/%s (%m): is ib_umad module loaded?",
+@@ -558,6 +694,28 @@
+
+ int umad_get_cas_names(char cas[][UMAD_CA_NAME_LEN], int max)
+ {
++#if defined(__SVR4) && defined(__sun)
++ struct ibv_device **devlist = ibv_get_device_list(NULL);
++ int j = 0;
++
++ TRACE("max %d", max);
++
++ if (devlist) {
++ while (devlist[j] && j < max) {
++ strncpy(cas[j], ibv_get_device_name(devlist[j]),
++ UMAD_CA_NAME_LEN);
++ j++;
++ }
++ ibv_free_device_list(devlist);
++ DEBUG("return %d cas", j);
++ }
++ if (j == 0 && max > 0) {
++ /* Is this still needed ? */
++ strncpy((char *)cas, def_ca_name, UMAD_CA_NAME_LEN);
++ DEBUG("return 1 ca");
++ j = 1;
++ }
++#else
+ struct dirent **namelist;
+ int n, i, j = 0;
+
+@@ -583,6 +741,7 @@
+ }
+ if (n >= 0)
+ free(namelist);
++#endif
+ return j;
+ }
+
+@@ -709,7 +868,52 @@
+ snprintf(dir_name, sizeof(dir_name), "%s/%s/%s",
+ SYS_INFINIBAND, ca_name, SYS_CA_PORTS_DIR);
+
++#if defined(__SVR4) && defined(__sun)
++ {
++ struct ibv_device **root_dev_list, **dev_list = NULL;
++ struct ibv_context ctx;
++ int num_dev, ret, i;
++ char uverbs_devpath[MAXPATHLEN];
++
++ root_dev_list = dev_list = ibv_get_device_list(&num_dev);
++ if (!dev_list) {
++ IBWARN("No HCA devices found");
++ return -EIO;
++ }
++
++ for (i = 0; i < num_dev; i++, dev_list++) {
++ if (strcmp(ibv_get_device_name(*dev_list), ca_name)
++ == 0) {
++ break;
++ }
++ }
++
++ if (i == num_dev) {
++ IBWARN("Could not find \"%s\"", ca_name);
++ ibv_free_device_list(root_dev_list);
++ return -EIO;
++ }
++
++
++ snprintf(uverbs_devpath, MAXPATHLEN, "%s/%s",
++ IB_OFS_DEVPATH_PREFIX, (*dev_list)->dev_name);
++
++ if ((ctx.cmd_fd = open(uverbs_devpath, O_RDWR)) < 0) {
++ IBWARN("failed to open device \"%s\"", ca_name);
++ ibv_free_device_list(root_dev_list);
++ return -EIO;
++ }
++
++ if ((ret = get_port(ca_name, dir_name, portnum, &ctx, port)) != 0) {
++ ibv_free_device_list(root_dev_list);
++ if (ctx.cmd_fd > 0)
++ close(ctx.cmd_fd);
++ }
++ return ret;
++ }
++#else
+ return get_port(ca_name, dir_name, portnum, port);
++#endif
+ }
+
+ int umad_release_port(umad_port_t * port)