Lines Matching refs:dm2sp

121 void dm2s_start(queue_t *wq, dm2s_t *dm2sp);
124 void dm2s_receive(dm2s_t *dm2sp);
129 static void dm2s_cleanup(dm2s_t *dm2sp);
130 static int dm2s_mbox_init(dm2s_t *dm2sp);
131 static void dm2s_mbox_fini(dm2s_t *dm2sp);
248 dm2s_t *dm2sp;
267 dm2sp = (dm2s_t *)ddi_get_soft_state(dm2s_softstate, instance);
268 if (dm2sp == NULL) {
273 dm2sp->ms_dip = dip;
274 dm2sp->ms_major = ddi_driver_major(dip);
275 dm2sp->ms_ppa = instance;
286 &dm2sp->ms_ibcookie) != DDI_SUCCESS) {
290 mutex_init(&dm2sp->ms_lock, NULL, MUTEX_DRIVER,
291 (void *)dm2sp->ms_ibcookie);
293 dm2sp->ms_clean |= DM2S_CLEAN_LOCK;
294 cv_init(&dm2sp->ms_wait, NULL, CV_DRIVER, NULL);
295 dm2sp->ms_clean |= DM2S_CLEAN_CV;
305 dm2sp->ms_clean |= DM2S_CLEAN_NODE;
306 ddi_set_driver_private(dip, (caddr_t)dm2sp);
310 dm2s_cleanup(dm2sp);
321 dm2s_t *dm2sp;
328 dm2sp = (dm2s_t *)ddi_get_soft_state(dm2s_softstate, minor);
329 if (dm2sp == NULL) {
332 *result = dm2sp->ms_dip;
356 dm2s_t *dm2sp;
363 dm2sp = (dm2s_t *)ddi_get_soft_state(dm2s_softstate, instance);
364 if (dm2sp == NULL) {
368 mutex_enter(&dm2sp->ms_lock);
371 if (dm2sp->ms_state & DM2S_MB_INITED) {
372 mutex_exit(&dm2sp->ms_lock);
376 mutex_exit(&dm2sp->ms_lock);
377 dm2s_cleanup(dm2sp);
390 dm2s_t *dm2sp;
406 if ((dm2sp = ddi_get_soft_state(dm2s_softstate, instance)) == NULL) {
411 mutex_enter(&dm2sp->ms_lock);
412 if (dm2sp->ms_state & DM2S_OPENED) {
414 mutex_exit(&dm2sp->ms_lock);
419 dm2sp->ms_state |= DM2S_OPENED;
421 if ((ret = dm2s_mbox_init(dm2sp)) != 0) {
422 dm2sp->ms_state = 0;
423 mutex_exit(&dm2sp->ms_lock);
426 rq->q_ptr = WR(rq)->q_ptr = (void *)dm2sp;
427 dm2sp->ms_rq = rq;
428 dm2sp->ms_wq = WR(rq);
429 mutex_exit(&dm2sp->ms_lock);
445 dm2s_t *dm2sp = (dm2s_t *)rq->q_ptr;
448 if (dm2sp == NULL) {
454 mutex_enter(&dm2sp->ms_lock);
455 (void) scf_mb_flush(dm2sp->ms_target, dm2sp->ms_key, MB_FLUSH_ALL);
456 dm2s_mbox_fini(dm2sp);
457 mutex_exit(&dm2sp->ms_lock);
465 if (dm2sp->ms_rbufcid != 0) {
466 qunbufcall(rq, dm2sp->ms_rbufcid);
467 dm2sp->ms_rbufcid = 0;
469 if (dm2sp->ms_rq_timeoutid != 0) {
470 DTRACE_PROBE1(dm2s_rqtimeout__cancel, dm2s_t, dm2sp);
471 (void) quntimeout(dm2sp->ms_rq, dm2sp->ms_rq_timeoutid);
472 dm2sp->ms_rq_timeoutid = 0;
474 if (dm2sp->ms_wq_timeoutid != 0) {
475 DTRACE_PROBE1(dm2s_wqtimeout__cancel, dm2s_t, dm2sp);
476 (void) quntimeout(dm2sp->ms_wq, dm2sp->ms_wq_timeoutid);
477 dm2sp->ms_wq_timeoutid = 0;
482 mutex_enter(&dm2sp->ms_lock);
483 dm2sp->ms_rq = dm2sp->ms_wq = NULL;
484 dm2sp->ms_state &= ~DM2S_OPENED;
485 mutex_exit(&dm2sp->ms_lock);
503 dm2s_t *dm2sp = (dm2s_t *)rq->q_ptr;
506 ASSERT(dm2sp != NULL);
507 mutex_enter(&dm2sp->ms_lock);
510 dm2s_receive(dm2sp);
511 mutex_exit(&dm2sp->ms_lock);
535 dm2s_t *dm2sp = (dm2s_t *)wq->q_ptr;
538 ASSERT(dm2sp != NULL);
540 if (dm2sp->ms_wq_timeoutid != 0) {
541 DTRACE_PROBE1(dm2s_wqtimeout__cancel, dm2s_t, dm2sp);
542 (void) quntimeout(dm2sp->ms_wq, dm2sp->ms_wq_timeoutid);
543 dm2sp->ms_wq_timeoutid = 0;
545 mutex_enter(&dm2sp->ms_lock);
546 dm2s_start(wq, dm2sp);
547 mutex_exit(&dm2sp->ms_lock);
562 dm2s_t *dm2sp = (dm2s_t *)wq->q_ptr;
565 if (dm2sp == NULL) {
626 (void) scf_mb_flush(dm2sp->ms_target, dm2sp->ms_key,
632 (void) scf_mb_flush(dm2sp->ms_target, dm2sp->ms_key,
653 dm2s_cleanup(dm2s_t *dm2sp)
658 ASSERT(dm2sp != NULL);
659 if (dm2sp->ms_clean & DM2S_CLEAN_NODE) {
660 (void) sprintf(name, "%s%d", DM2S_MODNAME, dm2sp->ms_ppa);
661 ddi_remove_minor_node(dm2sp->ms_dip, name);
663 if (dm2sp->ms_clean & DM2S_CLEAN_LOCK)
664 mutex_destroy(&dm2sp->ms_lock);
665 if (dm2sp->ms_clean & DM2S_CLEAN_CV)
666 cv_destroy(&dm2sp->ms_wait);
667 ddi_set_driver_private(dm2sp->ms_dip, NULL);
668 ddi_soft_state_free(dm2s_softstate, dm2sp->ms_ppa);
675 dm2s_mbox_init(dm2s_t *dm2sp)
680 ASSERT(MUTEX_HELD(&dm2sp->ms_lock));
681 dm2sp->ms_target = DM2S_TARGET_ID;
682 dm2sp->ms_key = DSCP_KEY;
683 dm2sp->ms_state &= ~DM2S_MB_INITED;
686 while (!(dm2sp->ms_state & DM2S_MB_CONN)) {
688 ret = scf_mb_init(dm2sp->ms_target, dm2sp->ms_key,
689 dm2s_event_handler, (void *)dm2sp);
697 dm2sp->ms_state |= DM2S_MB_INITED;
700 while (!(dm2sp->ms_state &
703 if (cv_wait_sig(&dm2sp->ms_wait,
704 &dm2sp->ms_lock) <= 0) {
712 if ((ret != 0) || (dm2sp->ms_state & DM2S_MB_DISC)) {
714 if (dm2sp->ms_state & DM2S_MB_INITED) {
715 (void) scf_mb_fini(dm2sp->ms_target,
716 dm2sp->ms_key);
718 if (dm2sp->ms_state & DM2S_MB_DISC) {
725 dm2sp->ms_state &= ~(DM2S_MB_INITED | DM2S_MB_DISC |
738 ret = cv_reltimedwait_sig(&dm2sp->ms_wait,
739 &dm2sp->ms_lock, tout, TR_CLOCK_TICK);
755 ret = scf_mb_ctrl(dm2sp->ms_target, dm2sp->ms_key,
756 SCF_MBOP_MAXMSGSIZE, &dm2sp->ms_mtu);
758 if ((ret == 0) && (dm2sp->ms_mtu < DM2S_DEF_MTU)) {
760 "but found %d\n", DM2S_DEF_MTU, dm2sp->ms_mtu);
765 dm2sp->ms_state &= ~DM2S_MB_INITED;
766 (void) scf_mb_fini(dm2sp->ms_target, dm2sp->ms_key);
776 dm2s_mbox_fini(dm2s_t *dm2sp)
780 ASSERT(dm2sp != NULL);
781 if (dm2sp->ms_state & DM2S_MB_INITED) {
783 ret = scf_mb_fini(dm2sp->ms_target, dm2sp->ms_key);
789 dm2sp->ms_state &= ~(DM2S_MB_INITED |DM2S_MB_CONN |
800 dm2s_t *dm2sp = (dm2s_t *)arg;
803 ASSERT(dm2sp != NULL);
804 mutex_enter(&dm2sp->ms_lock);
805 if (!(dm2sp->ms_state & DM2S_MB_INITED)) {
810 mutex_exit(&dm2sp->ms_lock);
821 dm2sp->ms_state |= DM2S_MB_CONN;
822 cv_broadcast(&dm2sp->ms_wait);
827 if (!DM2S_MBOX_READY(dm2sp)) {
837 if (dm2sp->ms_rq != NULL) {
838 qenable(dm2sp->ms_rq);
844 if (!DM2S_MBOX_READY(dm2sp)) {
854 if (dm2sp->ms_wq != NULL) {
855 qenable(dm2sp->ms_wq);
860 dm2sp->ms_state |= DM2S_MB_DISC;
861 if (dm2sp->ms_state & DM2S_MB_CONN) {
866 rq = dm2sp->ms_rq;
868 mutex_exit(&dm2sp->ms_lock);
874 DTRACE_PROBE1(dm2s_hangup, dm2s_t, dm2sp);
875 mutex_enter(&dm2sp->ms_lock);
882 cv_broadcast(&dm2sp->ms_wait);
890 mutex_exit(&dm2sp->ms_lock);
901 dm2s_start(queue_t *wq, dm2s_t *dm2sp)
907 ASSERT(dm2sp != NULL);
908 ASSERT(MUTEX_HELD(&dm2sp->ms_lock));
914 ret = dm2s_transmit(wq, mp, dm2sp->ms_target,
915 dm2sp->ms_key);
922 if (dm2sp->ms_wq_timeoutid == 0) {
924 dm2s_t, dm2sp);
925 dm2sp->ms_wq_timeoutid = qtimeout(wq,
926 dm2s_wq_timeout, (void *)dm2sp,
931 mutex_exit(&dm2sp->ms_lock);
939 DTRACE_PROBE1(dm2s_hangup, dm2s_t, dm2sp);
943 mutex_enter(&dm2sp->ms_lock);
963 dm2s_receive(dm2s_t *dm2sp)
965 queue_t *rq = dm2sp->ms_rq;
971 ASSERT(dm2sp != NULL);
972 ASSERT(MUTEX_HELD(&dm2sp->ms_lock));
980 while (DM2S_MBOX_READY(dm2sp) && ((ret = scf_mb_canget(dm2sp->ms_target,
981 dm2sp->ms_key, &len)) == 0)) {
993 dm2sp->ms_rbufcid = qbufcall(rq, len, BPRI_MED,
994 dm2s_bufcall_rcv, dm2sp);
995 if (dm2sp->ms_rbufcid == 0) {
1003 dm2s_t, dm2sp);
1004 dm2sp->ms_rq_timeoutid = qtimeout(rq,
1005 dm2s_rq_timeout, (void *)dm2sp,
1014 dm2sp->ms_sg_rcv.msc_dptr = (caddr_t)mp->b_wptr;
1015 dm2sp->ms_sg_rcv.msc_len = len;
1017 ret = scf_mb_getmsg(dm2sp->ms_target, dm2sp->ms_key, len, 1,
1018 &dm2sp->ms_sg_rcv, 0);
1024 DMPBYTES("dm2s: Getmsg: ", len, 1, &dm2sp->ms_sg_rcv);
1033 if ((!DM2S_MBOX_READY(dm2sp)) || (ret != ENOMSG && ret != EMSGSIZE)) {
1039 mutex_exit(&dm2sp->ms_lock);
1042 DTRACE_PROBE1(dm2s_hangup, dm2s_t, dm2sp);
1043 mutex_enter(&dm2sp->ms_lock);
1055 dm2s_t *dm2sp = (dm2s_t *)wq->q_ptr;
1061 ASSERT(dm2sp != NULL);
1062 ASSERT(MUTEX_HELD(&dm2sp->ms_lock));
1066 if (!DM2S_MBOX_READY(dm2sp)) {
1073 if (len > dm2sp->ms_mtu) {
1078 DTRACE_PROBE2(dm2s_msg_too_big, dm2s_t, dm2sp, uint32_t, len);
1083 if ((ret = dm2s_prep_scatgath(mp, &numsg, dm2sp->ms_sg_tx,
1091 ret = scf_mb_putmsg(target, key, len, numsg, dm2sp->ms_sg_tx, 0);
1095 if (++dm2sp->ms_retries >= DM2S_MAX_RETRIES) {
1102 DTRACE_PROBE2(dm2s_retry_fail, dm2s_t, dm2sp, int, ret);
1104 dm2sp->ms_retries = 0;
1107 DTRACE_PROBE2(dm2s_mb_busy, dm2s_t, dm2sp, int, ret);
1114 DMPBYTES("dm2s: Putmsg: ", len, numsg, dm2sp->ms_sg_tx);
1115 dm2sp->ms_retries = 0;
1130 dm2s_t *dm2sp = (dm2s_t *)arg;
1133 mutex_enter(&dm2sp->ms_lock);
1134 dm2sp->ms_rbufcid = 0;
1135 if (dm2sp->ms_rq != NULL) {
1136 qenable(dm2sp->ms_rq);
1138 mutex_exit(&dm2sp->ms_lock);
1150 dm2s_t *dm2sp = (dm2s_t *)arg;
1153 mutex_enter(&dm2sp->ms_lock);
1154 dm2sp->ms_rq_timeoutid = 0;
1155 if (dm2sp->ms_rq != NULL) {
1156 qenable(dm2sp->ms_rq);
1158 mutex_exit(&dm2sp->ms_lock);
1170 dm2s_t *dm2sp = (dm2s_t *)arg;
1173 mutex_enter(&dm2sp->ms_lock);
1174 dm2sp->ms_wq_timeoutid = 0;
1175 if (dm2sp->ms_wq != NULL) {
1176 qenable(dm2sp->ms_wq);
1178 mutex_exit(&dm2sp->ms_lock);