Lines Matching refs:softsp

195 static int	glvc_peek(glvc_soft_state_t *softsp,
199 static int glvc_ioctl_opt_op(glvc_soft_state_t *softsp,
257 glvc_soft_state_t *softsp; in glvc_attach() local
296 softsp = ddi_get_soft_state(glvc_ssp, instance); in glvc_attach()
299 softsp->dip = dip; in glvc_attach()
301 softsp->open_state = GLVC_NO_OPEN; in glvc_attach()
302 softsp->send_complete_flag = 1; in glvc_attach()
305 softsp->dip, DDI_PROP_DONTPASS, "glvc_debug", glvc_debug); in glvc_attach()
307 if ((softsp->s_id = (uint64_t)ddi_getprop(DDI_DEV_T_ANY, in glvc_attach()
308 softsp->dip, DDI_PROP_DONTPASS, "channel#", -1)) in glvc_attach()
314 if ((softsp->mtu = (uint64_t)ddi_getprop(DDI_DEV_T_ANY, in glvc_attach()
315 softsp->dip, DDI_PROP_DONTPASS, "mtu", -1)) in glvc_attach()
321 softsp->mb_recv_buf = in glvc_attach()
322 (char *)kmem_zalloc(softsp->mtu, KM_NOSLEEP); in glvc_attach()
323 if (softsp->mb_recv_buf == NULL) { in glvc_attach()
327 softsp->mb_recv_buf_pa = in glvc_attach()
328 va_to_pa((caddr_t)softsp->mb_recv_buf); in glvc_attach()
330 softsp->mb_send_buf = in glvc_attach()
331 (char *)kmem_zalloc(softsp->mtu, KM_NOSLEEP); in glvc_attach()
332 if (softsp->mb_send_buf == NULL) { in glvc_attach()
333 kmem_free(softsp->mb_recv_buf, softsp->mtu); in glvc_attach()
337 softsp->mb_send_buf_pa = in glvc_attach()
338 va_to_pa((caddr_t)softsp->mb_send_buf); in glvc_attach()
343 kmem_free(softsp->mb_recv_buf, softsp->mtu); in glvc_attach()
344 kmem_free(softsp->mb_send_buf, softsp->mtu); in glvc_attach()
349 mutex_init(&(softsp->open_mutex), NULL, MUTEX_DRIVER, NULL); in glvc_attach()
350 mutex_init(&(softsp->recv_mutex), NULL, MUTEX_DRIVER, NULL); in glvc_attach()
351 mutex_init(&(softsp->send_complete_mutex), NULL, in glvc_attach()
353 mutex_init(&(softsp->statusreg_mutex), NULL, in glvc_attach()
355 cv_init(&(softsp->recv_cv), NULL, CV_DRIVER, NULL); in glvc_attach()
356 cv_init(&(softsp->send_complete_cv), NULL, CV_DRIVER, NULL); in glvc_attach()
365 kmem_free(softsp->mb_recv_buf, softsp->mtu); in glvc_attach()
366 kmem_free(softsp->mb_send_buf, softsp->mtu); in glvc_attach()
375 if (softsp->intr_mode == GLVC_POLLING_MODE) in glvc_attach()
376 ddi_trigger_softintr(softsp->poll_mode_softint_id); in glvc_attach()
381 "mtu %lu attached\n", instance, softsp->s_id, in glvc_attach()
382 softsp->mtu)); in glvc_attach()
392 cv_destroy(&(softsp->send_complete_cv)); in glvc_attach()
393 cv_destroy(&(softsp->recv_cv)); in glvc_attach()
394 mutex_destroy(&(softsp->open_mutex)); in glvc_attach()
395 mutex_destroy(&(softsp->send_complete_mutex)); in glvc_attach()
396 mutex_destroy(&(softsp->recv_mutex)); in glvc_attach()
397 mutex_destroy(&(softsp->statusreg_mutex)); in glvc_attach()
415 glvc_soft_state_t *softsp; in glvc_detach() local
422 softsp = ddi_get_soft_state(glvc_ssp, instance); in glvc_detach()
424 cv_destroy(&(softsp->send_complete_cv)); in glvc_detach()
425 cv_destroy(&(softsp->recv_cv)); in glvc_detach()
426 mutex_destroy(&(softsp->open_mutex)); in glvc_detach()
427 mutex_destroy(&(softsp->statusreg_mutex)); in glvc_detach()
428 mutex_destroy(&(softsp->send_complete_mutex)); in glvc_detach()
429 mutex_destroy(&(softsp->recv_mutex)); in glvc_detach()
431 kmem_free(softsp->mb_recv_buf, softsp->mtu); in glvc_detach()
432 kmem_free(softsp->mb_send_buf, softsp->mtu); in glvc_detach()
462 glvc_soft_state_t *softsp; in glvc_add_intr_handlers() local
467 softsp = ddi_get_soft_state(glvc_ssp, instance); in glvc_add_intr_handlers()
469 if ((uint64_t)ddi_getprop(DDI_DEV_T_ANY, softsp->dip, in glvc_add_intr_handlers()
472 (caddr_t)softsp); in glvc_add_intr_handlers()
480 softsp->intr_mode = GLVC_INTR_MODE; in glvc_add_intr_handlers()
482 softsp->dip, DDI_PROP_DONTPASS, "intrmode_poll", in glvc_add_intr_handlers()
486 softsp->polling_interval = drv_usectohz(polling_interval); in glvc_add_intr_handlers()
490 softsp->intr_mode = GLVC_POLLING_MODE; in glvc_add_intr_handlers()
493 softsp->dip, DDI_PROP_DONTPASS, "pollmode_poll", in glvc_add_intr_handlers()
497 softsp->polling_interval = in glvc_add_intr_handlers()
502 if (softsp->intr_mode == GLVC_INTR_MODE) { in glvc_add_intr_handlers()
503 err = hv_service_setstatus(softsp->s_id, in glvc_add_intr_handlers()
515 &softsp->poll_mode_softint_id, NULL, NULL, in glvc_add_intr_handlers()
516 glvc_soft_intr, (caddr_t)softsp); in glvc_add_intr_handlers()
525 glvc_soft_state_t *softsp; in glvc_remove_intr_handlers() local
528 softsp = ddi_get_soft_state(glvc_ssp, instance); in glvc_remove_intr_handlers()
530 if (softsp->intr_mode == GLVC_INTR_MODE) in glvc_remove_intr_handlers()
533 ddi_remove_softintr(softsp->poll_mode_softint_id); in glvc_remove_intr_handlers()
535 softsp->intr_mode = GLVC_MODE_NONE; in glvc_remove_intr_handlers()
536 softsp->polling_interval = 0; in glvc_remove_intr_handlers()
559 glvc_soft_state_t *softsp; in glvc_open() local
563 softsp = ddi_get_soft_state(glvc_ssp, instance); in glvc_open()
565 mutex_enter(&softsp->open_mutex); in glvc_open()
567 switch (softsp->open_state) { in glvc_open()
570 softsp->open_state = GLVC_EXCL_OPEN; in glvc_open()
572 softsp->open_state = GLVC_OPEN; in glvc_open()
587 softsp->open_state); in glvc_open()
592 mutex_exit(&softsp->open_mutex); in glvc_open()
601 glvc_soft_state_t *softsp; in glvc_close() local
607 softsp = ddi_get_soft_state(glvc_ssp, instance); in glvc_close()
609 mutex_enter(&softsp->open_mutex); in glvc_close()
610 if (softsp->open_state == GLVC_NO_OPEN) { in glvc_close()
615 softsp->open_state = GLVC_NO_OPEN; in glvc_close()
617 mutex_exit(&softsp->open_mutex); in glvc_close()
626 glvc_soft_state_t *softsp; in glvc_read() local
634 softsp = ddi_get_soft_state(glvc_ssp, instance); in glvc_read()
636 mutex_enter(&softsp->recv_mutex); in glvc_read()
638 hverr = hv_service_getstatus(softsp->s_id, &status_reg); in glvc_read()
650 rv = cv_reltimedwait_sig(&softsp->recv_cv, in glvc_read()
651 &softsp->recv_mutex, softsp->polling_interval, in glvc_read()
657 mutex_exit(&softsp->recv_mutex); in glvc_read()
665 ddi_trigger_softintr(softsp->poll_mode_softint_id); in glvc_read()
667 hverr = hv_service_getstatus(softsp->s_id, &status_reg); in glvc_read()
673 hverr = hv_service_recv(softsp->s_id, softsp->mb_recv_buf_pa, in glvc_read()
674 softsp->mtu, &recv_count); in glvc_read()
685 mutex_exit(&softsp->recv_mutex); in glvc_read()
689 error = uiomove(softsp->mb_recv_buf, recv_count, in glvc_read()
696 if (hv_service_clrstatus(softsp->s_id, GLVC_REG_RECV) != H_EOK) { in glvc_read()
701 if (softsp->intr_mode == GLVC_INTR_MODE) in glvc_read()
702 if (hv_service_setstatus(softsp->s_id, GLVC_REG_RECV_ENA) in glvc_read()
707 mutex_exit(&softsp->recv_mutex); in glvc_read()
716 glvc_soft_state_t *softsp; in glvc_write() local
723 softsp = ddi_get_soft_state(glvc_ssp, instance); in glvc_write()
725 if (uiop->uio_resid > softsp->mtu) in glvc_write()
732 mutex_enter(&softsp->send_complete_mutex); in glvc_write()
733 while (softsp->send_complete_flag == 0) { in glvc_write()
734 rv = cv_reltimedwait_sig(&softsp->send_complete_cv, in glvc_write()
735 &softsp->send_complete_mutex, softsp->polling_interval, in glvc_write()
741 mutex_exit(&softsp->send_complete_mutex); in glvc_write()
749 ddi_trigger_softintr(softsp->poll_mode_softint_id); in glvc_write()
754 error = uiomove(softsp->mb_send_buf, send_count, in glvc_write()
758 hverr = hv_service_send(softsp->s_id, in glvc_write()
759 softsp->mb_send_buf_pa, send_count, &send_count); in glvc_write()
766 softsp->send_complete_flag = 0; in glvc_write()
768 mutex_exit(&softsp->send_complete_mutex); in glvc_write()
779 glvc_soft_state_t *softsp = (glvc_soft_state_t *)arg; in glvc_intr() local
785 mutex_enter(&softsp->recv_mutex); in glvc_intr()
786 mutex_enter(&softsp->send_complete_mutex); in glvc_intr()
787 hverr = hv_service_getstatus(softsp->s_id, &status_reg); in glvc_intr()
796 if ((softsp->intr_mode == GLVC_INTR_MODE) && in glvc_intr()
800 if ((hverr = hv_service_clrstatus(softsp->s_id, clr_bits)) in glvc_intr()
804 mutex_exit(&softsp->send_complete_mutex); in glvc_intr()
805 mutex_exit(&softsp->recv_mutex); in glvc_intr()
810 cv_broadcast(&softsp->recv_cv); in glvc_intr()
815 softsp->send_complete_flag = 1; in glvc_intr()
816 cv_broadcast(&softsp->send_complete_cv); in glvc_intr()
820 mutex_exit(&softsp->send_complete_mutex); in glvc_intr()
821 mutex_exit(&softsp->recv_mutex); in glvc_intr()
832 glvc_peek(glvc_soft_state_t *softsp, glvc_xport_msg_peek_t *msg_peek) in glvc_peek() argument
839 mutex_enter(&softsp->recv_mutex); in glvc_peek()
841 hverr = hv_service_getstatus(softsp->s_id, &status_reg); in glvc_peek()
852 rv = cv_reltimedwait_sig(&softsp->recv_cv, in glvc_peek()
853 &softsp->recv_mutex, softsp->polling_interval, in glvc_peek()
859 mutex_exit(&softsp->recv_mutex); in glvc_peek()
867 ddi_trigger_softintr(softsp->poll_mode_softint_id); in glvc_peek()
869 hverr = hv_service_getstatus(softsp->s_id, &status_reg); in glvc_peek()
875 hverr = hv_service_recv(softsp->s_id, softsp->mb_recv_buf_pa, in glvc_peek()
876 softsp->mtu, &recv_count); in glvc_peek()
882 softsp->mb_recv_buf, recv_count); in glvc_peek()
888 mutex_exit(&softsp->recv_mutex); in glvc_peek()
894 glvc_ioctl_opt_op(glvc_soft_state_t *softsp, intptr_t arg, int mode) in glvc_ioctl_opt_op() argument
909 glvc_xport_cmd.opt_val = softsp->mtu; in glvc_ioctl_opt_op()
920 mutex_enter(&softsp->statusreg_mutex); in glvc_ioctl_opt_op()
921 hverr = hv_service_getstatus(softsp->s_id, &status_reg); in glvc_ioctl_opt_op()
922 mutex_exit(&softsp->statusreg_mutex); in glvc_ioctl_opt_op()
951 glvc_soft_state_t *softsp; in glvc_ioctl() local
958 softsp = ddi_get_soft_state(glvc_ssp, instance); in glvc_ioctl()
962 retval = glvc_ioctl_opt_op(softsp, arg, mode); in glvc_ioctl()
967 (char *)kmem_zalloc(softsp->mtu, KM_NOSLEEP); in glvc_ioctl()
970 retval = glvc_peek(softsp, &glvc_peek_msg); in glvc_ioctl()
1039 kmem_free(glvc_peek_msg.buf, softsp->mtu); in glvc_ioctl()