Print this page
3217 cfgadm should spell "adaptors" correctly
Reviewed by: Alexander Eremin <alexander.r.eremin@gmail.com>
Reviewed by: David Hoeppner <0xffea@gmail.com>
Reviewed by: Gary Mills <gary_mills@fastmail.fm>
Reviewed by: Eric Schrock <Eric.Schrock@delphix.com>


 120 {ERR_DEV_GETSTATE,      0, 1,   "failed to get state for FC device"},
 121 {ERR_RESET,             0, 1,   "reset failed"},
 122 {ERR_LIST,              0, 1,   "list operation failed"},
 123 {ERR_SIG_STATE,         0, 1,   "could not restore signal disposition"},
 124 {ERR_MAYBE_BUSY,        0, 1,   "device may be busy"},
 125 {ERR_BUS_DEV_MISMATCH,  0, 1,   "mismatched FC bus and device"},
 126 {ERR_MEM_ALLOC,         0, 1,   "Failed to allocated memory"},
 127 {ERR_DEVCTL_OFFLINE,    0, 1,   "failed to offline device"},
 128 {ERR_UPD_REP,           0, 1,   "Repository update failed"},
 129 {ERR_CONF_OK_UPD_REP,   0, 1,
 130                 "Configuration successful, but Repository update failed"},
 131 {ERR_UNCONF_OK_UPD_REP, 0, 1,
 132                 "Unconfiguration successful, but Repository update failed"},
 133 {ERR_PARTIAL_SUCCESS,   0, 1,
 134                         "Operation partially successful. Some failures seen"},
 135 {ERR_HBA_LOAD_LIBRARY,  0, 1,
 136                         "HBA load library failed"},
 137 {ERR_MATCHING_HBA_PORT, 0, 1,
 138                         "No match HBA port found"},
 139 {ERR_NO_ADAPTER_FOUND,  0, 1,
 140                         "No Fibre Channel adpaters found"},
 141 
 142 /* Errors with arguments */
 143 {ERRARG_OPT_INVAL,      1, 1,   "invalid option: "},
 144 {ERRARG_HWCMD_INVAL,    1, 1,   "invalid command: "},
 145 {ERRARG_DEVINFO,        1, 1,   "libdevinfo failed on path: "},
 146 {ERRARG_NOT_IN_DEVLIST, 1, 1,   "Device not found in fabric device list: "},
 147 {ERRARG_NOT_IN_DEVINFO, 1, 1,   "Could not find entry in devinfo tree: "},
 148 {ERRARG_DI_GET_PROP,    1, 1,   "Could not get libdevinfo property: "},
 149 {ERRARG_DC_DDEF_ALLOC,  1, 1,   "failed to alloc ddef space: "},
 150 {ERRARG_DC_BYTE_ARRAY,  1, 1,   "failed to add property: "},
 151 {ERRARG_DC_BUS_ACQUIRE, 1, 1,   "failed to acquire bus handle: "},
 152 {ERRARG_BUS_DEV_CREATE, 1, 1,   "failed to create device node: "},
 153 {ERRARG_BUS_DEV_CREATE_UNKNOWN, 1, 1,
 154         "failed to create device node... Device may be unconfigurable: "},
 155 {ERRARG_DEV_ACQUIRE,    1, 1,   "device acquire operation failed: "},
 156 {ERRARG_DEV_REMOVE,     1, 1,   "remove operation failed: "},
 157 
 158 /* Fibre Channel operation Errors */
 159 {ERR_FC,                0, 1,   "FC error"},
 160 {ERR_FC_GET_DEVLIST,    0, 1,   "Failed to get fabric device list"},


1269             if (status != HBA_STATUS_OK) {
1270                 /* May have been DR'd */
1271                 continue;
1272             }
1273             handle = HBA_OpenAdapter(adapterName);
1274             if (handle == 0) {
1275                 /* May have been DR'd */
1276                 continue;
1277             }
1278 
1279             do {
1280                 if (getAdapterAttrs(handle, &hbaAttrs)) {
1281                 /* Should never happen */
1282                     HBA_CloseAdapter(handle);
1283                     continue;
1284                 }
1285 
1286                 /* Loop over all HBA Ports */
1287                 for (portIndex = 0;
1288                     portIndex < hbaAttrs.NumberOfPorts; portIndex++) {
1289                     if ((status = getAdapterPortAttrs(handle, portIndex,

1290                         &portAttrs)) != HBA_STATUS_OK) {
1291                         /* Need to refresh adapter */
1292                         if (status == HBA_STATUS_ERROR_STALE_DATA) {

1293                             HBA_RefreshInformation(handle);
1294                             break;
1295                         } else {
1296                             continue;
1297                         }
1298                     }
1299 
1300                         /*
1301                          * check to see if OSDeviceName is a /dev/cfg link
1302                          * or the physical path
1303                          */
1304                     if (strncmp(portAttrs.OSDeviceName, CFGA_DEV_DIR,

1305                         strlen(CFGA_DEV_DIR)) != 0) {
1306                         tmpPtr = strstr(portAttrs.OSDeviceName, MINOR_SEP);
1307                         if (tmpPtr != NULL) {
1308                                 if (strncmp(portPath,

1309                                             portAttrs.OSDeviceName,
1310                                             strlen(portAttrs.OSDeviceName) -
1311                                             strlen(tmpPtr)) == 0) {
1312                                         if (matchingHandle)
1313                                                 *matchingHandle = handle;

1314                                         if (matchingPortIndex)
1315                                                 *matchingPortIndex = portIndex;

1316                                         if (matchingPortAttrs)
1317                                                 *matchingPortAttrs = portAttrs;

1318                                         return (FPCFGA_OK);
1319                                 }
1320                         }
1321                     } else {
1322                         /*
1323                          * strip off the /dev/cfg/ portion of the
1324                          * OSDeviceName
1325                          * make sure that the OSDeviceName is at least
1326                          * strlen("/dev/cfg") + 1 + 1 long.
1327                          *      first 1 is for the / after /dev/cfg
1328                          *      second 1 is to make sure there is somthing
1329                          *      after
1330                          */
1331                         if (strlen(portAttrs.OSDeviceName) <
1332                             (strlen(CFGA_DEV_DIR) + 1 + 1))
1333                                 continue;
1334                         cfg_ptr = portAttrs.OSDeviceName +
1335                             strlen(CFGA_DEV_DIR) + 1;
1336                         if (logical_apid == NULL) {
1337                                 /* get the /dev/cfg link from the portPath */
1338                                 if (make_xport_logid(portPath, &logical_apid,




1339                                             &l_errno) != FPCFGA_OK) {
1340                                         cfga_err(errstring, l_errno,

1341                                             ERR_LIST, 0);
1342                                         HBA_FreeLibrary();
1343                                         return (FPCFGA_LIB_ERR);

1344                                 }
1345                         }
1346                         /* compare logical ap_id */
1347                         if (strcmp(logical_apid, cfg_ptr) == 0) {

1348                                 if (matchingHandle)
1349                                         *matchingHandle = handle;

1350                                 if (matchingPortIndex)
1351                                         *matchingPortIndex = portIndex;

1352                                 if (matchingPortAttrs)
1353                                         *matchingPortAttrs = portAttrs;

1354                                 S_FREE(logical_apid);
1355                                 return (FPCFGA_OK);
1356                         }
1357                     }
1358                 }
1359                 if (logical_apid != NULL)
1360                         S_FREE(logical_apid);
1361             } while ((status == HBA_STATUS_ERROR_STALE_DATA) &&
1362                 (retry++ < HBA_MAX_RETRIES));
1363 
1364             HBA_CloseAdapter(handle);
1365         }
1366         free(logical_apid);
1367 
1368         /* Got here. No mathcing adatper port found. */
1369         cfga_err(errstring, 0, ERR_MATCHING_HBA_PORT, 0);
1370         HBA_FreeLibrary();
1371         return (FPCFGA_LIB_ERR);
1372 }


 120 {ERR_DEV_GETSTATE,      0, 1,   "failed to get state for FC device"},
 121 {ERR_RESET,             0, 1,   "reset failed"},
 122 {ERR_LIST,              0, 1,   "list operation failed"},
 123 {ERR_SIG_STATE,         0, 1,   "could not restore signal disposition"},
 124 {ERR_MAYBE_BUSY,        0, 1,   "device may be busy"},
 125 {ERR_BUS_DEV_MISMATCH,  0, 1,   "mismatched FC bus and device"},
 126 {ERR_MEM_ALLOC,         0, 1,   "Failed to allocated memory"},
 127 {ERR_DEVCTL_OFFLINE,    0, 1,   "failed to offline device"},
 128 {ERR_UPD_REP,           0, 1,   "Repository update failed"},
 129 {ERR_CONF_OK_UPD_REP,   0, 1,
 130                 "Configuration successful, but Repository update failed"},
 131 {ERR_UNCONF_OK_UPD_REP, 0, 1,
 132                 "Unconfiguration successful, but Repository update failed"},
 133 {ERR_PARTIAL_SUCCESS,   0, 1,
 134                         "Operation partially successful. Some failures seen"},
 135 {ERR_HBA_LOAD_LIBRARY,  0, 1,
 136                         "HBA load library failed"},
 137 {ERR_MATCHING_HBA_PORT, 0, 1,
 138                         "No match HBA port found"},
 139 {ERR_NO_ADAPTER_FOUND,  0, 1,
 140                         "No Fibre Channel adapters found"},
 141 
 142 /* Errors with arguments */
 143 {ERRARG_OPT_INVAL,      1, 1,   "invalid option: "},
 144 {ERRARG_HWCMD_INVAL,    1, 1,   "invalid command: "},
 145 {ERRARG_DEVINFO,        1, 1,   "libdevinfo failed on path: "},
 146 {ERRARG_NOT_IN_DEVLIST, 1, 1,   "Device not found in fabric device list: "},
 147 {ERRARG_NOT_IN_DEVINFO, 1, 1,   "Could not find entry in devinfo tree: "},
 148 {ERRARG_DI_GET_PROP,    1, 1,   "Could not get libdevinfo property: "},
 149 {ERRARG_DC_DDEF_ALLOC,  1, 1,   "failed to alloc ddef space: "},
 150 {ERRARG_DC_BYTE_ARRAY,  1, 1,   "failed to add property: "},
 151 {ERRARG_DC_BUS_ACQUIRE, 1, 1,   "failed to acquire bus handle: "},
 152 {ERRARG_BUS_DEV_CREATE, 1, 1,   "failed to create device node: "},
 153 {ERRARG_BUS_DEV_CREATE_UNKNOWN, 1, 1,
 154         "failed to create device node... Device may be unconfigurable: "},
 155 {ERRARG_DEV_ACQUIRE,    1, 1,   "device acquire operation failed: "},
 156 {ERRARG_DEV_REMOVE,     1, 1,   "remove operation failed: "},
 157 
 158 /* Fibre Channel operation Errors */
 159 {ERR_FC,                0, 1,   "FC error"},
 160 {ERR_FC_GET_DEVLIST,    0, 1,   "Failed to get fabric device list"},


1269                 if (status != HBA_STATUS_OK) {
1270                         /* May have been DR'd */
1271                         continue;
1272                 }
1273                 handle = HBA_OpenAdapter(adapterName);
1274                 if (handle == 0) {
1275                         /* May have been DR'd */
1276                         continue;
1277                 }
1278 
1279                 do {
1280                         if (getAdapterAttrs(handle, &hbaAttrs)) {
1281                                 /* Should never happen */
1282                                 HBA_CloseAdapter(handle);
1283                                 continue;
1284                         }
1285 
1286                         /* Loop over all HBA Ports */
1287                         for (portIndex = 0;
1288                             portIndex < hbaAttrs.NumberOfPorts; portIndex++) {
1289                                 if ((status = getAdapterPortAttrs(handle,
1290                                     portIndex,
1291                                     &portAttrs)) != HBA_STATUS_OK) {
1292                                         /* Need to refresh adapter */
1293                                         if (status ==
1294                                             HBA_STATUS_ERROR_STALE_DATA) {
1295                                                 HBA_RefreshInformation(handle);
1296                                                 break;
1297                                         } else {
1298                                                 continue;
1299                                         }
1300                                 }
1301 
1302                                 /*
1303                                  * check to see if OSDeviceName is a /dev/cfg
1304                                  * link or the physical path
1305                                  */
1306                                 if (strncmp(portAttrs.OSDeviceName,
1307                                     CFGA_DEV_DIR,
1308                                     strlen(CFGA_DEV_DIR)) != 0) {
1309                                         tmpPtr = strstr(portAttrs.OSDeviceName,
1310                                             MINOR_SEP);
1311                                         if ((tmpPtr != NULL) &&
1312                                             strncmp(portPath,
1313                                             portAttrs.OSDeviceName,
1314                                             strlen(portAttrs.OSDeviceName) -
1315                                             strlen(tmpPtr)) == 0) {
1316                                                 if (matchingHandle)
1317                                                         *matchingHandle =
1318                                                             handle;
1319                                                 if (matchingPortIndex)
1320                                                         *matchingPortIndex =
1321                                                             portIndex;
1322                                                 if (matchingPortAttrs)
1323                                                         *matchingPortAttrs =
1324                                                             portAttrs;
1325                                                 return (FPCFGA_OK);
1326                                         }

1327                                 } else {
1328                                         /*
1329                                          * strip off the /dev/cfg/ portion of
1330                                          * the OSDeviceName make sure that the
1331                                          * OSDeviceName is at least
1332                                          * strlen("/dev/cfg") + 1 + 1 long.
1333                                          * first 1 is for the / after /dev/cfg
1334                                          * second 1 is to make sure there is
1335                                          * somthing after
1336                                          */
1337                                         if (strlen(portAttrs.OSDeviceName) <
1338                                             (strlen(CFGA_DEV_DIR) + 1 + 1))
1339                                                 continue;
1340                                         cfg_ptr = portAttrs.OSDeviceName +
1341                                             strlen(CFGA_DEV_DIR) + 1;
1342                                         if (logical_apid == NULL) {
1343                                                 /*
1344                                                  * get the /dev/cfg link from
1345                                                  * the portPath
1346                                                  */
1347                                                 if (make_xport_logid(portPath,
1348                                                     &logical_apid,
1349                                                     &l_errno) != FPCFGA_OK) {
1350                                                         cfga_err(errstring,
1351                                                             l_errno,
1352                                                             ERR_LIST, 0);
1353                                                         HBA_FreeLibrary();
1354                                                         return
1355                                                             (FPCFGA_LIB_ERR);
1356                                                 }
1357                                         }
1358                                         /* compare logical ap_id */
1359                                         if (strcmp(logical_apid,
1360                                             cfg_ptr) == 0) {
1361                                                 if (matchingHandle)
1362                                                         *matchingHandle =
1363                                                             handle;
1364                                                 if (matchingPortIndex)
1365                                                         *matchingPortIndex =
1366                                                             portIndex;
1367                                                 if (matchingPortAttrs)
1368                                                         *matchingPortAttrs =
1369                                                             portAttrs;
1370                                                 S_FREE(logical_apid);
1371                                                 return (FPCFGA_OK);
1372                                         }
1373                                 }
1374                         }
1375                         if (logical_apid != NULL)
1376                                 S_FREE(logical_apid);
1377                 } while ((status == HBA_STATUS_ERROR_STALE_DATA) &&
1378                     (retry++ < HBA_MAX_RETRIES));
1379 
1380                 HBA_CloseAdapter(handle);
1381         }
1382         free(logical_apid);
1383 
1384         /* Got here. No matching adapter port found. */
1385         cfga_err(errstring, 0, ERR_MATCHING_HBA_PORT, 0);
1386         HBA_FreeLibrary();
1387         return (FPCFGA_LIB_ERR);
1388 }