2508 /*
2509 * User is requesting that the token be checked.
2510 * If there was another set after the user's get
2511 * it's an error
2512 */
2513 if (ppi->ppi_token_valid) {
2514 if (ppi->ppi_token != ppd->ppd_token) {
2515 *err_ret = STMF_IOCERR_PPD_UPDATED;
2516 mutex_exit(&stmf_state.stmf_lock);
2517 return (EINVAL);
2518 }
2519 }
2520
2521 if ((ret = nvlist_unpack((char *)ppi->ppi_data,
2522 (size_t)ppi->ppi_data_size, &nv, KM_NOSLEEP)) != 0) {
2523 mutex_exit(&stmf_state.stmf_lock);
2524 return (ret);
2525 }
2526
2527 /* Free any existing lists and add this one to the ppd */
2528 if (ppd->ppd_nv)
2529 nvlist_free(ppd->ppd_nv);
2530 ppd->ppd_nv = nv;
2531
2532 /* set the token for writes */
2533 ppd->ppd_token++;
2534 /* return token to caller */
2535 if (ppi_token) {
2536 *ppi_token = ppd->ppd_token;
2537 }
2538
2539 /* If there is a provider registered, do the notifications */
2540 if (ppd->ppd_provider) {
2541 uint32_t cb_flags = 0;
2542
2543 if (stmf_state.stmf_config_state == STMF_CONFIG_INIT)
2544 cb_flags |= STMF_PCB_STMF_ONLINING;
2545 if (ppi->ppi_lu_provider) {
2546 ilp = (stmf_i_lu_provider_t *)ppd->ppd_provider;
2547 if (ilp->ilp_lp->lp_cb == NULL)
2548 goto bail_out;
2581 if (ppd->ppd_lu_provider) {
2582 ((stmf_i_lu_provider_t *)
2583 ppd->ppd_provider)->ilp_ppd = NULL;
2584 } else {
2585 ((stmf_i_port_provider_t *)
2586 ppd->ppd_provider)->ipp_ppd = NULL;
2587 }
2588 ppd->ppd_provider = NULL;
2589 }
2590
2591 for (pppd = &stmf_state.stmf_ppdlist; *pppd != NULL;
2592 pppd = &((*pppd)->ppd_next)) {
2593 if (*pppd == ppd)
2594 break;
2595 }
2596
2597 if (*pppd == NULL)
2598 return;
2599
2600 *pppd = ppd->ppd_next;
2601 if (ppd->ppd_nv)
2602 nvlist_free(ppd->ppd_nv);
2603
2604 kmem_free(ppd, ppd->ppd_alloc_size);
2605 }
2606
2607 int
2608 stmf_delete_ppd_ioctl(stmf_ppioctl_data_t *ppi)
2609 {
2610 stmf_pp_data_t *ppd;
2611 int ret = ENOENT;
2612
2613 if ((ppi->ppi_lu_provider + ppi->ppi_port_provider) != 1) {
2614 return (EINVAL);
2615 }
2616
2617 mutex_enter(&stmf_state.stmf_lock);
2618
2619 for (ppd = stmf_state.stmf_ppdlist; ppd != NULL; ppd = ppd->ppd_next) {
2620 if (ppi->ppi_lu_provider) {
2621 if (!ppd->ppd_lu_provider)
|
2508 /*
2509 * User is requesting that the token be checked.
2510 * If there was another set after the user's get
2511 * it's an error
2512 */
2513 if (ppi->ppi_token_valid) {
2514 if (ppi->ppi_token != ppd->ppd_token) {
2515 *err_ret = STMF_IOCERR_PPD_UPDATED;
2516 mutex_exit(&stmf_state.stmf_lock);
2517 return (EINVAL);
2518 }
2519 }
2520
2521 if ((ret = nvlist_unpack((char *)ppi->ppi_data,
2522 (size_t)ppi->ppi_data_size, &nv, KM_NOSLEEP)) != 0) {
2523 mutex_exit(&stmf_state.stmf_lock);
2524 return (ret);
2525 }
2526
2527 /* Free any existing lists and add this one to the ppd */
2528 nvlist_free(ppd->ppd_nv);
2529 ppd->ppd_nv = nv;
2530
2531 /* set the token for writes */
2532 ppd->ppd_token++;
2533 /* return token to caller */
2534 if (ppi_token) {
2535 *ppi_token = ppd->ppd_token;
2536 }
2537
2538 /* If there is a provider registered, do the notifications */
2539 if (ppd->ppd_provider) {
2540 uint32_t cb_flags = 0;
2541
2542 if (stmf_state.stmf_config_state == STMF_CONFIG_INIT)
2543 cb_flags |= STMF_PCB_STMF_ONLINING;
2544 if (ppi->ppi_lu_provider) {
2545 ilp = (stmf_i_lu_provider_t *)ppd->ppd_provider;
2546 if (ilp->ilp_lp->lp_cb == NULL)
2547 goto bail_out;
2580 if (ppd->ppd_lu_provider) {
2581 ((stmf_i_lu_provider_t *)
2582 ppd->ppd_provider)->ilp_ppd = NULL;
2583 } else {
2584 ((stmf_i_port_provider_t *)
2585 ppd->ppd_provider)->ipp_ppd = NULL;
2586 }
2587 ppd->ppd_provider = NULL;
2588 }
2589
2590 for (pppd = &stmf_state.stmf_ppdlist; *pppd != NULL;
2591 pppd = &((*pppd)->ppd_next)) {
2592 if (*pppd == ppd)
2593 break;
2594 }
2595
2596 if (*pppd == NULL)
2597 return;
2598
2599 *pppd = ppd->ppd_next;
2600 nvlist_free(ppd->ppd_nv);
2601
2602 kmem_free(ppd, ppd->ppd_alloc_size);
2603 }
2604
2605 int
2606 stmf_delete_ppd_ioctl(stmf_ppioctl_data_t *ppi)
2607 {
2608 stmf_pp_data_t *ppd;
2609 int ret = ENOENT;
2610
2611 if ((ppi->ppi_lu_provider + ppi->ppi_port_provider) != 1) {
2612 return (EINVAL);
2613 }
2614
2615 mutex_enter(&stmf_state.stmf_lock);
2616
2617 for (ppd = stmf_state.stmf_ppdlist; ppd != NULL; ppd = ppd->ppd_next) {
2618 if (ppi->ppi_lu_provider) {
2619 if (!ppd->ppd_lu_provider)
|