components/open-fabrics/libibumad/patches/base.patch
changeset 715 eed3ed08f692
parent 636 da28b1dc61e7
child 900 63d3bf696d85
equal deleted inserted replaced
714:b205ca9f0d84 715:eed3ed08f692
   102 -#define IBWARN(fmt, args...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", getpid(), __func__, ## args)
   102 -#define IBWARN(fmt, args...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", getpid(), __func__, ## args)
   103 +#define IBWARN(fmt, args...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", (int)getpid(), __func__, ## args)
   103 +#define IBWARN(fmt, args...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", (int)getpid(), __func__, ## args)
   104  
   104  
   105  #define TRACE	if (umaddebug)	IBWARN
   105  #define TRACE	if (umaddebug)	IBWARN
   106  #define DEBUG	if (umaddebug)	IBWARN
   106  #define DEBUG	if (umaddebug)	IBWARN
   107 @@ -172,6 +176,82 @@
   107 @@ -172,6 +176,73 @@
   108  	memcpy(&port->port_guid, gid + 8, sizeof port->port_guid);
   108  	memcpy(&port->port_guid, gid + 8, sizeof port->port_guid);
   109  
   109  
   110  	snprintf(port_dir + len, sizeof(port_dir) - len, "/pkeys");
   110  	snprintf(port_dir + len, sizeof(port_dir) - len, "/pkeys");
   111 +
   111 +
   112 +#if defined(__SVR4) && defined(__sun)
   112 +#if defined(__SVR4) && defined(__sun)
   164 +		 */
   164 +		 */
   165 +		portnum |= 0x80;
   165 +		portnum |= 0x80;
   166 +		num_pkeys = ibv_query_pkey(ctx, portnum, port_attr.pkey_tbl_len,
   166 +		num_pkeys = ibv_query_pkey(ctx, portnum, port_attr.pkey_tbl_len,
   167 +		    port->pkeys);
   167 +		    port->pkeys);
   168 +		if (num_pkeys != 0) {
   168 +		if (num_pkeys != 0) {
   169 +			/*
   169 +			IBWARN("get_port: ibv_query_pkey() failed for \"%s\"",
   170 +			 * have to do one at a time.
   170 +			    ca_name);
   171 +			 */
   171 +			ibv_close_device(ctx);
   172 +			portnum &= 0x7f;
   172 +			ibv_free_device_list(root_dev_list);
   173 +			for (i = 0; i < port_attr.pkey_tbl_len; i++) {
   173 +			goto clean;
   174 +				if (ibv_query_pkey(ctx, portnum, i,
       
   175 +				    &(port->pkeys[i]))) {
       
   176 +					IBWARN("Could not retrieve pkeys for "
       
   177 +					    "\"%s\"", ca_name);
       
   178 +					ibv_close_device(ctx);
       
   179 +					ibv_free_device_list(root_dev_list);
       
   180 +					goto clean;
       
   181 +				}
       
   182 +			}
       
   183 +		}
   174 +		}
   184 +		port->pkeys_size = port_attr.pkey_tbl_len;
   175 +		port->pkeys_size = port_attr.pkey_tbl_len;
   185 +	}
   176 +	}
   186 +#else
   177 +#else
   187  	num_pkeys = scandir(port_dir, &namelist, check_for_digit_name, NULL);
   178  	num_pkeys = scandir(port_dir, &namelist, check_for_digit_name, NULL);
   188  	if (num_pkeys <= 0) {
   179  	if (num_pkeys <= 0) {
   189  		IBWARN("no pkeys found for %s:%u (at dir %s)...",
   180  		IBWARN("no pkeys found for %s:%u (at dir %s)...",
   190 @@ -193,6 +273,8 @@
   181 @@ -193,6 +264,8 @@
   191  	port->pkeys_size = num_pkeys;
   182  	port->pkeys_size = num_pkeys;
   192  	free(namelist);
   183  	free(namelist);
   193  	namelist = NULL;
   184  	namelist = NULL;
   194 +#endif
   185 +#endif
   195 +
   186 +
   196  	port_dir[len] = '\0';
   187  	port_dir[len] = '\0';
   197  
   188  
   198  	/* FIXME: handle gids */
   189  	/* FIXME: handle gids */
   199 @@ -384,6 +466,7 @@
   190 @@ -384,6 +457,7 @@
   200  	snprintf(dir_name, sizeof(dir_name), "%s/%s/%s",
   191  	snprintf(dir_name, sizeof(dir_name), "%s/%s/%s",
   201  		 SYS_INFINIBAND, ca->ca_name, SYS_CA_PORTS_DIR);
   192  		 SYS_INFINIBAND, ca->ca_name, SYS_CA_PORTS_DIR);
   202  
   193  
   203 +#if !(defined(__SVR4) && defined(__sun))
   194 +#if !(defined(__SVR4) && defined(__sun))
   204  	if (!(dir = opendir(dir_name)))
   195  	if (!(dir = opendir(dir_name)))
   205  		return -ENOENT;
   196  		return -ENOENT;
   206  
   197  
   207 @@ -425,15 +508,41 @@
   198 @@ -425,15 +499,41 @@
   208  	free(namelist);
   199  	free(namelist);
   209  
   200  
   210  	closedir(dir);
   201  	closedir(dir);
   211 +#else
   202 +#else
   212 +	// TODO: hardcoded 2 ports
   203 +	// TODO: hardcoded 2 ports
   244  	closedir(dir);
   235  	closedir(dir);
   245 +#endif
   236 +#endif
   246  	release_ca(ca);
   237  	release_ca(ca);
   247  
   238  
   248  	return ret;
   239  	return ret;
   249 @@ -484,6 +593,11 @@
   240 @@ -484,6 +584,11 @@
   250  int umad_init(void)
   241  int umad_init(void)
   251  {
   242  {
   252  	TRACE("umad_init");
   243  	TRACE("umad_init");
   253 +	struct ibv_device **devlist = ibv_get_device_list(NULL);
   244 +	struct ibv_device **devlist = ibv_get_device_list(NULL);
   254 +	if (devlist == NULL) {
   245 +	if (devlist == NULL) {
   256 +		return -1;
   247 +		return -1;
   257 +	}
   248 +	}
   258  	if (sys_read_uint(IB_UMAD_ABI_DIR, IB_UMAD_ABI_FILE, &abi_version) < 0) {
   249  	if (sys_read_uint(IB_UMAD_ABI_DIR, IB_UMAD_ABI_FILE, &abi_version) < 0) {
   259  		IBWARN
   250  		IBWARN
   260  		    ("can't read ABI version from %s/%s (%m): is ib_umad module loaded?",
   251  		    ("can't read ABI version from %s/%s (%m): is ib_umad module loaded?",
   261 @@ -522,6 +636,28 @@
   252 @@ -522,6 +627,28 @@
   262  
   253  
   263  int umad_get_cas_names(char cas[][UMAD_CA_NAME_LEN], int max)
   254  int umad_get_cas_names(char cas[][UMAD_CA_NAME_LEN], int max)
   264  {
   255  {
   265 +#if defined(__SVR4) && defined(__sun)
   256 +#if defined(__SVR4) && defined(__sun)
   266 +	struct ibv_device **devlist = ibv_get_device_list(NULL);
   257 +	struct ibv_device **devlist = ibv_get_device_list(NULL);
   285 +	}
   276 +	}
   286 +#else
   277 +#else
   287  	struct dirent **namelist;
   278  	struct dirent **namelist;
   288  	int n, i, j = 0;
   279  	int n, i, j = 0;
   289  
   280  
   290 @@ -547,6 +683,7 @@
   281 @@ -547,6 +674,7 @@
   291  	}
   282  	}
   292  	if (n >= 0)
   283  	if (n >= 0)
   293  		free(namelist);
   284  		free(namelist);
   294 +#endif
   285 +#endif
   295  	return j;
   286  	return j;