2609 job = fcsm->sm_job_head;
2610 if (job->job_next == NULL) {
2611 ASSERT(fcsm->sm_job_tail == job);
2612 fcsm->sm_job_tail = NULL;
2613 }
2614 fcsm->sm_job_head = job->job_next;
2615 job->job_next = NULL;
2616 }
2617
2618 return (job);
2619 }
2620
2621
2622 /* Dedicated per port thread to process various commands */
2623 static void
2624 fcsm_job_thread(fcsm_t *fcsm)
2625 {
2626 fcsm_job_t *job;
2627
2628 ASSERT(fcsm != NULL);
2629 #ifndef __lock_lint
2630 CALLB_CPR_INIT(&fcsm->sm_cpr_info, &fcsm->sm_mutex,
2631 callb_generic_cpr, "fcsm_job_thread");
2632 #endif /* __lock_lint */
2633
2634 for (;;) {
2635 mutex_enter(&fcsm->sm_mutex);
2636
2637 while (fcsm->sm_job_head == NULL ||
2638 fcsm->sm_flags & FCSM_SERIALIZE_JOBTHREAD) {
2639 CALLB_CPR_SAFE_BEGIN(&fcsm->sm_cpr_info);
2640 cv_wait(&fcsm->sm_job_cv, &fcsm->sm_mutex);
2641 CALLB_CPR_SAFE_END(&fcsm->sm_cpr_info, &fcsm->sm_mutex);
2642 }
2643
2644 job = fcsm_deque_job(fcsm);
2645
2646 mutex_exit(&fcsm->sm_mutex);
2647
2648 mutex_enter(&job->job_mutex);
2649 if (job->job_flags & FCSM_JOBFLAG_SERIALIZE) {
2650 mutex_exit(&job->job_mutex);
2651
2652 mutex_enter(&fcsm->sm_mutex);
2664 fcsm_display(CE_WARN, SM_LOG, fcsm, NULL,
2665 "job_thread: uninitialized job code");
2666 job->job_result = FC_FAILURE;
2667 fcsm_jobdone(job);
2668 break;
2669
2670 case FCSM_JOB_THREAD_SHUTDOWN:
2671 FCSM_DEBUG(SMDL_TRACE, (CE_WARN, SM_LOG, fcsm, NULL,
2672 "job_thread: job code <JOB PORT SHUTDOWN>"));
2673
2674 /*
2675 * There should not be any pending jobs, when this
2676 * is being called.
2677 */
2678 mutex_enter(&fcsm->sm_mutex);
2679 ASSERT(fcsm->sm_job_head == NULL);
2680 ASSERT(fcsm->sm_job_tail == NULL);
2681 ASSERT(fcsm->sm_retry_head == NULL);
2682 ASSERT(fcsm->sm_retry_tail == NULL);
2683 job->job_result = FC_SUCCESS;
2684 #ifndef __lock_lint
2685 CALLB_CPR_EXIT(&fcsm->sm_cpr_info);
2686 #endif
2687 /* CPR_EXIT has also dropped the fcsm->sm_mutex */
2688
2689 fcsm_jobdone(job);
2690 thread_exit();
2691 /* NOTREACHED */
2692 break;
2693
2694 case FCSM_JOB_LOGIN_NAME_SERVER:
2695 FCSM_DEBUG(SMDL_TRACE, (CE_CONT, SM_LOG, fcsm, NULL,
2696 "job_thread: job code <LOGIN_NAME_SERVER>"));
2697 job->job_result = FC_SUCCESS;
2698 fcsm_jobdone(job);
2699 break;
2700
2701 case FCSM_JOB_LOGIN_MGMT_SERVER:
2702 FCSM_DEBUG(SMDL_TRACE, (CE_CONT, SM_LOG, fcsm, NULL,
2703 "job_thread: job code <LOGIN_MGMT_SERVER>"));
2704 fcsm_job_login_mgmt_server(job);
2705 break;
2706
|
2609 job = fcsm->sm_job_head;
2610 if (job->job_next == NULL) {
2611 ASSERT(fcsm->sm_job_tail == job);
2612 fcsm->sm_job_tail = NULL;
2613 }
2614 fcsm->sm_job_head = job->job_next;
2615 job->job_next = NULL;
2616 }
2617
2618 return (job);
2619 }
2620
2621
2622 /* Dedicated per port thread to process various commands */
2623 static void
2624 fcsm_job_thread(fcsm_t *fcsm)
2625 {
2626 fcsm_job_t *job;
2627
2628 ASSERT(fcsm != NULL);
2629 CALLB_CPR_INIT(&fcsm->sm_cpr_info, &fcsm->sm_mutex,
2630 callb_generic_cpr, "fcsm_job_thread");
2631
2632 for (;;) {
2633 mutex_enter(&fcsm->sm_mutex);
2634
2635 while (fcsm->sm_job_head == NULL ||
2636 fcsm->sm_flags & FCSM_SERIALIZE_JOBTHREAD) {
2637 CALLB_CPR_SAFE_BEGIN(&fcsm->sm_cpr_info);
2638 cv_wait(&fcsm->sm_job_cv, &fcsm->sm_mutex);
2639 CALLB_CPR_SAFE_END(&fcsm->sm_cpr_info, &fcsm->sm_mutex);
2640 }
2641
2642 job = fcsm_deque_job(fcsm);
2643
2644 mutex_exit(&fcsm->sm_mutex);
2645
2646 mutex_enter(&job->job_mutex);
2647 if (job->job_flags & FCSM_JOBFLAG_SERIALIZE) {
2648 mutex_exit(&job->job_mutex);
2649
2650 mutex_enter(&fcsm->sm_mutex);
2662 fcsm_display(CE_WARN, SM_LOG, fcsm, NULL,
2663 "job_thread: uninitialized job code");
2664 job->job_result = FC_FAILURE;
2665 fcsm_jobdone(job);
2666 break;
2667
2668 case FCSM_JOB_THREAD_SHUTDOWN:
2669 FCSM_DEBUG(SMDL_TRACE, (CE_WARN, SM_LOG, fcsm, NULL,
2670 "job_thread: job code <JOB PORT SHUTDOWN>"));
2671
2672 /*
2673 * There should not be any pending jobs, when this
2674 * is being called.
2675 */
2676 mutex_enter(&fcsm->sm_mutex);
2677 ASSERT(fcsm->sm_job_head == NULL);
2678 ASSERT(fcsm->sm_job_tail == NULL);
2679 ASSERT(fcsm->sm_retry_head == NULL);
2680 ASSERT(fcsm->sm_retry_tail == NULL);
2681 job->job_result = FC_SUCCESS;
2682 CALLB_CPR_EXIT(&fcsm->sm_cpr_info);
2683 /* CPR_EXIT has also dropped the fcsm->sm_mutex */
2684
2685 fcsm_jobdone(job);
2686 thread_exit();
2687 /* NOTREACHED */
2688 break;
2689
2690 case FCSM_JOB_LOGIN_NAME_SERVER:
2691 FCSM_DEBUG(SMDL_TRACE, (CE_CONT, SM_LOG, fcsm, NULL,
2692 "job_thread: job code <LOGIN_NAME_SERVER>"));
2693 job->job_result = FC_SUCCESS;
2694 fcsm_jobdone(job);
2695 break;
2696
2697 case FCSM_JOB_LOGIN_MGMT_SERVER:
2698 FCSM_DEBUG(SMDL_TRACE, (CE_CONT, SM_LOG, fcsm, NULL,
2699 "job_thread: job code <LOGIN_MGMT_SERVER>"));
2700 fcsm_job_login_mgmt_server(job);
2701 break;
2702
|