components/open-fabrics/infiniband-diags/solaris_set_nodedesc.c
changeset 636 da28b1dc61e7
parent 369 cc8c00719da9
child 715 eed3ed08f692
equal deleted inserted replaced
635:d4b487f99c39 636:da28b1dc61e7
    53 #include <sys/utsname.h>
    53 #include <sys/utsname.h>
    54 
    54 
    55 #include <infiniband/verbs.h>
    55 #include <infiniband/verbs.h>
    56 #include <infiniband/arch.h>
    56 #include <infiniband/arch.h>
    57 
    57 
    58 #include <sys/ib/adapters/tavor/tavor_ioctl.h>
       
    59 #include <sys/ib/adapters/hermon/hermon_ioctl.h>
    58 #include <sys/ib/adapters/hermon/hermon_ioctl.h>
    60 
    59 
    61 /*
    60 /*
    62  * Local defines for HCA driver IOCTLs, used while
    61  * Local defines for HCA driver IOCTLs, used while
    63  * building on build system without the change in
    62  * building on build system without the change in
    72 #endif
    71 #endif
    73 #ifndef HERMON_IOCTL_GET_NODEDESC
    72 #ifndef HERMON_IOCTL_GET_NODEDESC
    74 #define	HERMON_IOCTL_GET_NODEDESC	(('t' << 8) | 0x31)
    73 #define	HERMON_IOCTL_GET_NODEDESC	(('t' << 8) | 0x31)
    75 #endif
    74 #endif
    76 
    75 
    77 #ifdef	TAVOR_NODEDESC_UPDATE_STR
       
    78 #define	TAVOR_NODEDESC_UPDATE_STRING		0x00000001
       
    79 #endif
       
    80 #ifndef	TAVOR_NODEDESC_UPDATE_HCA_STRING
       
    81 #define	TAVOR_NODEDESC_UPDATE_HCA_STRING	0x00000002
       
    82 #undef	TAVOR_NODEDESC_UPDATE_HCA_MAP
       
    83 #endif
       
    84 #ifndef TAVOR_IOCTL_GET_NODEDESC
       
    85 #define	TAVOR_IOCTL_GET_NODEDESC	(('t' << 8) | 0x31)
       
    86 #endif
       
    87 
       
    88 #define	NODEDESC_UPDATE_STRING		0x00000001
    76 #define	NODEDESC_UPDATE_STRING		0x00000001
    89 #define	NODEDESC_UPDATE_HCA_STRING	0x00000002
    77 #define	NODEDESC_UPDATE_HCA_STRING	0x00000002
    90 #define	NODEDESC_READ			0x80000000
    78 #define	NODEDESC_READ			0x80000000
    91 
    79 
    92 #include "ibdiag_common.h"
    80 #include "ibdiag_common.h"
    93 
    81 
    94 static char *devpath_prefix = "/devices";
    82 static char *devpath_prefix = "/devices";
    95 static char *devpath_suffix = ":devctl";
    83 static char *devpath_suffix = ":devctl";
    96 static char *ib_hca_driver_list[] = {
    84 static char *ib_hca_driver_list[] = {
    97 	"tavor", "hermon", NULL
    85 	"hermon", NULL
    98 };
    86 };
    99 static di_node_t	di_rootnode;
    87 static di_node_t	di_rootnode;
   100 char *argv0 = "solaris_set_nodedesc";
    88 char *argv0 = "solaris_set_nodedesc";
   101 
    89 
   102 #define	MAX_HCAS	32
    90 #define	MAX_HCAS	32
   213 			IBERROR("open device file %s failed", access_devname);
   201 			IBERROR("open device file %s failed", access_devname);
   214 			free(access_devname);
   202 			free(access_devname);
   215 			hcanode = di_drv_next_node(hcanode);
   203 			hcanode = di_drv_next_node(hcanode);
   216 			continue;
   204 			continue;
   217 		}
   205 		}
   218 		if (strcmp(drivername, "tavor") == 0) {
   206 		if (strcmp(drivername, "hermon") == 0) {
   219 			tavor_nodedesc_ioctl_t		nodedesc_ioctl;
       
   220 
       
   221 			if ((rc = ioctl(devfd, TAVOR_IOCTL_GET_NODEDESC,
       
   222 			    (void *)&nodedesc_ioctl)) != 0) {
       
   223 				IBERROR("tavor ioctl failure");
       
   224 				free(access_devname);
       
   225 				close(devfd);
       
   226 				hcanode = di_drv_next_node(hcanode);
       
   227 				continue;
       
   228 			}
       
   229 			add_read_info_arr((char *)nodedesc_ioctl.node_desc_str,
       
   230 			    *hca_guid);
       
   231 		} else if (strcmp(drivername, "hermon") == 0) {
       
   232 			hermon_nodedesc_ioctl_t		nodedesc_ioctl;
   207 			hermon_nodedesc_ioctl_t		nodedesc_ioctl;
   233 
   208 
   234 			if ((rc = ioctl(devfd, HERMON_IOCTL_GET_NODEDESC,
   209 			if ((rc = ioctl(devfd, HERMON_IOCTL_GET_NODEDESC,
   235 			    (void *)&nodedesc_ioctl)) != 0) {
   210 			    (void *)&nodedesc_ioctl)) != 0) {
   236 				IBERROR("hermon ioctl failure");
   211 				IBERROR("hermon ioctl failure");
   239 				hcanode = di_drv_next_node(hcanode);
   214 				hcanode = di_drv_next_node(hcanode);
   240 				continue;
   215 				continue;
   241 			}
   216 			}
   242 			add_read_info_arr((char *)nodedesc_ioctl.node_desc_str,
   217 			add_read_info_arr((char *)nodedesc_ioctl.node_desc_str,
   243 			    *hca_guid);
   218 			    *hca_guid);
       
   219 		} else {
       
   220 			IBERROR("drivername != hermon: %s", drivername);
   244 		}
   221 		}
   245 
   222 
   246 		free(access_devname);
   223 		free(access_devname);
   247 		close(devfd);
   224 		close(devfd);
   248 		hcanode = di_drv_next_node(hcanode);
   225 		hcanode = di_drv_next_node(hcanode);
   298 	if ((devfd = open(access_devname, O_RDONLY)) < 0) {
   275 	if ((devfd = open(access_devname, O_RDONLY)) < 0) {
   299 		IBERROR("open device file %s failed", access_devname);
   276 		IBERROR("open device file %s failed", access_devname);
   300 		free(access_devname);
   277 		free(access_devname);
   301 		return (rc);
   278 		return (rc);
   302 	}
   279 	}
   303 	if (strcmp(drivername, "tavor") == 0) {
   280 	if (strcmp(drivername, "hermon") == 0) {
   304 		tavor_nodedesc_ioctl_t		nodedesc_ioctl;
       
   305 
       
   306 		strncpy(nodedesc_ioctl.node_desc_str, desc_str, 64);
       
   307 		if (update_flag & NODEDESC_UPDATE_STRING)
       
   308 			nodedesc_ioctl.node_desc_update_flag =
       
   309 			    TAVOR_NODEDESC_UPDATE_STRING;
       
   310 		else if (update_flag & NODEDESC_UPDATE_HCA_STRING)
       
   311 			nodedesc_ioctl.node_desc_update_flag =
       
   312 			    TAVOR_NODEDESC_UPDATE_HCA_STRING;
       
   313 		else {
       
   314 			IBERROR("Invalid option");
       
   315 			exit(-1);
       
   316 		}
       
   317 		if ((rc = ioctl(devfd, TAVOR_IOCTL_SET_NODEDESC,
       
   318 		    (void *)&nodedesc_ioctl)) != 0) {
       
   319 			IBERROR("tavor ioctl failure");
       
   320 		}
       
   321 	} else if (strcmp(drivername, "hermon") == 0) {
       
   322 		hermon_nodedesc_ioctl_t		nodedesc_ioctl;
   281 		hermon_nodedesc_ioctl_t		nodedesc_ioctl;
   323 
   282 
   324 		strncpy(nodedesc_ioctl.node_desc_str, desc_str, 64);
   283 		strncpy(nodedesc_ioctl.node_desc_str, desc_str, 64);
   325 		if (update_flag & NODEDESC_UPDATE_STRING)
   284 		if (update_flag & NODEDESC_UPDATE_STRING)
   326 			nodedesc_ioctl.node_desc_update_flag =
   285 			nodedesc_ioctl.node_desc_update_flag =
   334 		}
   293 		}
   335 		if ((rc = ioctl(devfd, HERMON_IOCTL_SET_NODEDESC,
   294 		if ((rc = ioctl(devfd, HERMON_IOCTL_SET_NODEDESC,
   336 		    (void *)&nodedesc_ioctl)) != 0) {
   295 		    (void *)&nodedesc_ioctl)) != 0) {
   337 			IBERROR("hermon ioctl failure");
   296 			IBERROR("hermon ioctl failure");
   338 		}
   297 		}
       
   298 	} else {
       
   299 		IBERROR("drivername != hermon: %s", drivername);
   339 	}
   300 	}
   340 
   301 
   341 	free(access_devname);
   302 	free(access_devname);
   342 	close(devfd);
   303 	close(devfd);
   343 	return (rc);
   304 	return (rc);