1386 adapt_infop->library = lib_infop;
1387 adapt_infop->next = _hbaapi_adapterlist;
1388 adapt_infop->index = _hbaapi_total_adapter_count;
1389 _hbaapi_adapterlist = adapt_infop;
1390 _hbaapi_total_adapter_count++;
1391 }
1392 }
1393 RELEASE_MUTEX(&_hbaapi_AL_mutex);
1394 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, _hbaapi_total_adapter_count);
1395 }
1396
1397 HBA_STATUS
1398 HBA_GetAdapterName(
1399 HBA_UINT32 adapterindex,
1400 char *adaptername)
1401 {
1402 HBA_ADAPTER_INFO *adapt_infop;
1403 HBA_STATUS ret = HBA_STATUS_ERROR_ILLEGAL_INDEX;
1404
1405 if (adaptername == NULL) {
1406 DEBUG(1, "HBA_GetAdapterName: NULL pointer adatpername",
1407 0, 0, 0);
1408 return (HBA_STATUS_ERROR_ARG);
1409 }
1410
1411 /*
1412 * The adapter index is from old code, but we have
1413 * to support it. Go down the list looking for
1414 * the adapter
1415 */
1416 ARE_WE_INITED();
1417 GRAB_MUTEX(&_hbaapi_AL_mutex);
1418 *adaptername = '\0';
1419 for (adapt_infop = _hbaapi_adapterlist;
1420 adapt_infop != NULL;
1421 adapt_infop = adapt_infop->next) {
1422
1423 if (adapt_infop->index == adapterindex) {
1424 if (adapt_infop->name != NULL &&
1425 adapt_infop->GNstatus == HBA_STATUS_OK) {
1426 (void) strcpy(adaptername, adapt_infop->name);
1434 DEBUG(2, "GetAdapterName for index:%d ->%s",
1435 adapterindex, adaptername, 0);
1436 RELEASE_MUTEX_RETURN(&_hbaapi_AL_mutex, ret);
1437 }
1438
1439 HBA_HANDLE
1440 HBA_OpenAdapter(char *adaptername)
1441 {
1442 HBA_HANDLE handle;
1443 HBAOpenAdapterFunc OpenAdapterFunc;
1444 HBA_ADAPTER_INFO *adapt_infop;
1445 HBA_LIBRARY_INFO *lib_infop;
1446
1447 DEBUG(2, "OpenAdapter: %s", adaptername, 0, 0);
1448
1449 handle = HBA_HANDLE_INVALID;
1450 if (_hbaapi_librarylist == NULL) {
1451 return (handle);
1452 }
1453 if (adaptername == NULL) {
1454 DEBUG(1, "HBA_OpenAdapter: NULL pointer adatpername",
1455 0, 0, 0);
1456 return (handle);
1457 }
1458 GRAB_MUTEX(&_hbaapi_AL_mutex);
1459 for (adapt_infop = _hbaapi_adapterlist;
1460 adapt_infop != NULL;
1461 adapt_infop = adapt_infop->next) {
1462 if (strcmp(adaptername, adapt_infop->name) != 0) {
1463 continue;
1464 }
1465 lib_infop = adapt_infop->library;
1466 OpenAdapterFunc = FUNCCOMMON(lib_infop, OpenAdapterHandler);
1467
1468 if (OpenAdapterFunc != NULL) {
1469 /* retrieve the vendor handle */
1470 handle = (OpenAdapterFunc)(adaptername);
1471 if (handle != 0) {
1472 /* or this with the library index to get the common handle */
1473 handle = HBA_HANDLE_FROM_LOCAL(lib_infop->index, handle);
1474 }
4312
4313 CHECKLIBRARYANDVERSION(SMHBA);
4314
4315 SendSMPPassThruFunc = lib_infop->ftable.\
4316 smhbafunctionTable.SendSMPPassThruHandler;
4317
4318 if (SendSMPPassThruFunc != NULL) {
4319 status = (SendSMPPassThruFunc)
4320 (vendorHandle, hbaPortWWN, destWWN, domainPortWWN,
4321 pReqBuffer, ReqBufferSize, pRspBuffer, pRspBufferSize);
4322 } else {
4323 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4324 }
4325 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4326 }
4327
4328 /*
4329 * Following the similar logic of HBAAPI addaspterevents_callback.
4330 *
4331 * Unlike other events Adapter Add Event is not limited to a specific
4332 * adpater(i.e. no adatper handle is passed for registration) so
4333 * the event should be passed to all registrants. The routine below
4334 * is passed to the VSLs as a callback and when Adapter Add event is detected
4335 * by VSL it will call smhba_adapteraddevents_callback() which in turn check
4336 * if the passed userdata ptr matches with the one stored in the callback list
4337 * and calls the stored callback.
4338 *
4339 * For the situation that multiple clients are registered for Adapter Add event
4340 * each registration is passed to VSLs so VSL may call
4341 * smhba_adapteraddevents_callback() multiple times or it may call only once
4342 * since the callback function is same. For this implemneation, the userdata
4343 * is stored in HBA_ALLADAPTERSCALLBACK_ELEM so it is expected that VSL call
4344 * smhba_adapteraddevents_callback() only once and
4345 * smhba_adapteraddevents_callback() will call the client callback with proper
4346 * userdata.
4347 */
4348 static void
4349 smhba_adapteraddevents_callback(
4350 /* LINTED E_FUNC_ARG_UNUSED */
4351 void *data,
4352 HBA_WWN PortWWN,
|
1386 adapt_infop->library = lib_infop;
1387 adapt_infop->next = _hbaapi_adapterlist;
1388 adapt_infop->index = _hbaapi_total_adapter_count;
1389 _hbaapi_adapterlist = adapt_infop;
1390 _hbaapi_total_adapter_count++;
1391 }
1392 }
1393 RELEASE_MUTEX(&_hbaapi_AL_mutex);
1394 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, _hbaapi_total_adapter_count);
1395 }
1396
1397 HBA_STATUS
1398 HBA_GetAdapterName(
1399 HBA_UINT32 adapterindex,
1400 char *adaptername)
1401 {
1402 HBA_ADAPTER_INFO *adapt_infop;
1403 HBA_STATUS ret = HBA_STATUS_ERROR_ILLEGAL_INDEX;
1404
1405 if (adaptername == NULL) {
1406 DEBUG(1, "HBA_GetAdapterName: NULL pointer adaptername",
1407 0, 0, 0);
1408 return (HBA_STATUS_ERROR_ARG);
1409 }
1410
1411 /*
1412 * The adapter index is from old code, but we have
1413 * to support it. Go down the list looking for
1414 * the adapter
1415 */
1416 ARE_WE_INITED();
1417 GRAB_MUTEX(&_hbaapi_AL_mutex);
1418 *adaptername = '\0';
1419 for (adapt_infop = _hbaapi_adapterlist;
1420 adapt_infop != NULL;
1421 adapt_infop = adapt_infop->next) {
1422
1423 if (adapt_infop->index == adapterindex) {
1424 if (adapt_infop->name != NULL &&
1425 adapt_infop->GNstatus == HBA_STATUS_OK) {
1426 (void) strcpy(adaptername, adapt_infop->name);
1434 DEBUG(2, "GetAdapterName for index:%d ->%s",
1435 adapterindex, adaptername, 0);
1436 RELEASE_MUTEX_RETURN(&_hbaapi_AL_mutex, ret);
1437 }
1438
1439 HBA_HANDLE
1440 HBA_OpenAdapter(char *adaptername)
1441 {
1442 HBA_HANDLE handle;
1443 HBAOpenAdapterFunc OpenAdapterFunc;
1444 HBA_ADAPTER_INFO *adapt_infop;
1445 HBA_LIBRARY_INFO *lib_infop;
1446
1447 DEBUG(2, "OpenAdapter: %s", adaptername, 0, 0);
1448
1449 handle = HBA_HANDLE_INVALID;
1450 if (_hbaapi_librarylist == NULL) {
1451 return (handle);
1452 }
1453 if (adaptername == NULL) {
1454 DEBUG(1, "HBA_OpenAdapter: NULL pointer adaptername",
1455 0, 0, 0);
1456 return (handle);
1457 }
1458 GRAB_MUTEX(&_hbaapi_AL_mutex);
1459 for (adapt_infop = _hbaapi_adapterlist;
1460 adapt_infop != NULL;
1461 adapt_infop = adapt_infop->next) {
1462 if (strcmp(adaptername, adapt_infop->name) != 0) {
1463 continue;
1464 }
1465 lib_infop = adapt_infop->library;
1466 OpenAdapterFunc = FUNCCOMMON(lib_infop, OpenAdapterHandler);
1467
1468 if (OpenAdapterFunc != NULL) {
1469 /* retrieve the vendor handle */
1470 handle = (OpenAdapterFunc)(adaptername);
1471 if (handle != 0) {
1472 /* or this with the library index to get the common handle */
1473 handle = HBA_HANDLE_FROM_LOCAL(lib_infop->index, handle);
1474 }
4312
4313 CHECKLIBRARYANDVERSION(SMHBA);
4314
4315 SendSMPPassThruFunc = lib_infop->ftable.\
4316 smhbafunctionTable.SendSMPPassThruHandler;
4317
4318 if (SendSMPPassThruFunc != NULL) {
4319 status = (SendSMPPassThruFunc)
4320 (vendorHandle, hbaPortWWN, destWWN, domainPortWWN,
4321 pReqBuffer, ReqBufferSize, pRspBuffer, pRspBufferSize);
4322 } else {
4323 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4324 }
4325 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4326 }
4327
4328 /*
4329 * Following the similar logic of HBAAPI addaspterevents_callback.
4330 *
4331 * Unlike other events Adapter Add Event is not limited to a specific
4332 * adapter(i.e. no adapter handle is passed for registration) so
4333 * the event should be passed to all registrants. The routine below
4334 * is passed to the VSLs as a callback and when Adapter Add event is detected
4335 * by VSL it will call smhba_adapteraddevents_callback() which in turn check
4336 * if the passed userdata ptr matches with the one stored in the callback list
4337 * and calls the stored callback.
4338 *
4339 * For the situation that multiple clients are registered for Adapter Add event
4340 * each registration is passed to VSLs so VSL may call
4341 * smhba_adapteraddevents_callback() multiple times or it may call only once
4342 * since the callback function is same. For this implemneation, the userdata
4343 * is stored in HBA_ALLADAPTERSCALLBACK_ELEM so it is expected that VSL call
4344 * smhba_adapteraddevents_callback() only once and
4345 * smhba_adapteraddevents_callback() will call the client callback with proper
4346 * userdata.
4347 */
4348 static void
4349 smhba_adapteraddevents_callback(
4350 /* LINTED E_FUNC_ARG_UNUSED */
4351 void *data,
4352 HBA_WWN PortWWN,
|