Lines Matching refs:hp
534 struct uhso_port *hp;
543 hp = sc->sc_port[i];
544 if (hp != NULL)
545 (*hp->hp_abort)(hp);
571 hp = sc->sc_port[i];
572 if (hp != NULL)
573 (*hp->hp_detach)(hp);
733 struct uhso_port *hp;
800 hp = kmem_zalloc(sizeof(struct uhso_port), KM_SLEEP);
801 sc->sc_port[uhso_mux_port[i]] = hp;
803 hp->hp_sc = sc;
804 hp->hp_index = i;
805 hp->hp_ipipe = pipe;
806 hp->hp_ibuf = buf;
807 hp->hp_isize = size;
808 hp->hp_flags = flags;
809 hp->hp_abort = uhso_mux_abort;
810 hp->hp_detach = uhso_mux_detach;
811 hp->hp_init = uhso_mux_init;
812 hp->hp_clean = uhso_mux_clean;
813 hp->hp_write = uhso_mux_write;
814 hp->hp_write_cb = uhso_tty_write_cb;
815 hp->hp_read = uhso_mux_read;
816 hp->hp_read_cb = uhso_tty_read_cb;
817 hp->hp_control = uhso_mux_control;
818 hp->hp_wsize = UHSO_MUX_WSIZE;
819 hp->hp_rsize = UHSO_MUX_RSIZE;
821 uhso_tty_attach(hp);
844 uhso_mux_abort(struct uhso_port *hp)
846 struct uhso_softc *sc = hp->hp_sc;
848 DPRINTF(1, "hp=%p\n", hp);
850 if (!ISSET(hp->hp_flags, UHSO_PORT_MUXPIPE))
851 usbd_abort_pipe(hp->hp_ipipe);
855 return (*hp->hp_clean)(hp);
859 uhso_mux_detach(struct uhso_port *hp)
862 DPRINTF(1, "hp=%p\n", hp);
864 if (!ISSET(hp->hp_flags, UHSO_PORT_MUXPIPE)) {
866 usbd_abort_pipe(hp->hp_ipipe);
867 usbd_close_pipe(hp->hp_ipipe);
868 kmem_free(hp->hp_ibuf, hp->hp_isize);
871 uhso_tty_detach(hp);
872 kmem_free(hp, sizeof(struct uhso_port));
877 uhso_mux_init(struct uhso_port *hp)
880 DPRINTF(1, "hp=%p\n", hp);
882 CLR(hp->hp_flags, UHSO_PORT_MUXBUSY | UHSO_PORT_MUXREADY);
883 SET(hp->hp_status, TIOCM_DSR | TIOCM_CAR);
885 struct uhso_softc *sc = hp->hp_sc;
889 error = usbd_create_xfer(pipe0, hp->hp_rsize, 0, 0, &hp->hp_rxfer);
893 hp->hp_rbuf = usbd_get_buffer(hp->hp_rxfer);
895 error = usbd_create_xfer(pipe0, hp->hp_wsize, 0, 0, &hp->hp_wxfer);
899 hp->hp_wbuf = usbd_get_buffer(hp->hp_wxfer);
905 uhso_mux_clean(struct uhso_port *hp)
908 DPRINTF(1, "hp=%p\n", hp);
910 CLR(hp->hp_flags, UHSO_PORT_MUXREADY);
911 CLR(hp->hp_status, TIOCM_DTR | TIOCM_DSR | TIOCM_CAR);
916 uhso_mux_write(struct uhso_port *hp)
918 struct uhso_softc *sc = hp->hp_sc;
922 DPRINTF(5, "hp=%p, index=%d, wlen=%zd\n", hp, hp->hp_index,
923 hp->hp_wlen);
928 USETW(req.wIndex, hp->hp_index);
929 USETW(req.wLength, hp->hp_wlen);
931 usbd_setup_default_xfer(hp->hp_wxfer, sc->sc_udev, hp, USBD_NO_TIMEOUT,
932 &req, hp->hp_wbuf, hp->hp_wlen, 0, hp->hp_write_cb);
934 status = usbd_transfer(hp->hp_wxfer);
945 uhso_mux_read(struct uhso_port *hp)
947 struct uhso_softc *sc = hp->hp_sc;
951 CLR(hp->hp_flags, UHSO_PORT_MUXBUSY);
953 if (hp->hp_rlen == 0 && !ISSET(hp->hp_flags, UHSO_PORT_MUXREADY))
956 SET(hp->hp_flags, UHSO_PORT_MUXBUSY);
957 CLR(hp->hp_flags, UHSO_PORT_MUXREADY);
959 DPRINTF(5, "hp=%p, index=%d\n", hp, hp->hp_index);
964 USETW(req.wIndex, hp->hp_index);
965 USETW(req.wLength, hp->hp_rsize);
967 usbd_setup_default_xfer(hp->hp_rxfer, sc->sc_udev, hp, USBD_NO_TIMEOUT,
968 &req, hp->hp_rbuf, hp->hp_rsize, USBD_SHORT_XFER_OK,
969 hp->hp_read_cb);
971 status = usbd_transfer(hp->hp_rxfer);
974 CLR(hp->hp_flags, UHSO_PORT_MUXBUSY);
983 uhso_mux_control(struct uhso_port *hp)
986 DPRINTF(1, "hp=%p\n", hp);
995 struct uhso_port *hp;
1016 hp = sc->sc_port[uhso_mux_port[i]];
1017 if (hp == NULL
1018 || hp->hp_tp == NULL
1019 || !ISSET(hp->hp_status, TIOCM_DTR))
1022 SET(hp->hp_flags, UHSO_PORT_MUXREADY);
1023 if (ISSET(hp->hp_flags, UHSO_PORT_MUXBUSY))
1026 uhso_mux_read(hp);
1043 struct uhso_port *hp;
1076 hp = kmem_zalloc(sizeof(struct uhso_port), KM_SLEEP);
1077 sc->sc_port[index] = hp;
1079 hp->hp_sc = sc;
1080 hp->hp_ifh = ifh;
1081 hp->hp_index = id->bInterfaceNumber;
1082 hp->hp_raddr = in;
1083 hp->hp_waddr = out;
1084 hp->hp_abort = uhso_bulk_abort;
1085 hp->hp_detach = uhso_bulk_detach;
1086 hp->hp_init = uhso_bulk_init;
1087 hp->hp_clean = uhso_bulk_clean;
1088 hp->hp_write = uhso_bulk_write;
1089 hp->hp_write_cb = uhso_tty_write_cb;
1090 hp->hp_read = uhso_bulk_read;
1091 hp->hp_read_cb = uhso_tty_read_cb;
1092 hp->hp_control = uhso_bulk_control;
1093 hp->hp_wsize = UHSO_BULK_WSIZE;
1094 hp->hp_rsize = UHSO_BULK_RSIZE;
1099 hp->hp_iaddr = ed->bEndpointAddress;
1100 hp->hp_isize = UGETW(ed->wMaxPacketSize);
1104 uhso_tty_attach(hp);
1112 uhso_bulk_abort(struct uhso_port *hp)
1115 DPRINTF(1, "hp=%p\n", hp);
1117 return (*hp->hp_clean)(hp);
1121 uhso_bulk_detach(struct uhso_port *hp)
1124 DPRINTF(1, "hp=%p\n", hp);
1126 uhso_tty_detach(hp);
1127 kmem_free(hp, sizeof(struct uhso_port));
1132 uhso_bulk_init(struct uhso_port *hp)
1136 DPRINTF(1, "hp=%p\n", hp);
1138 if (hp->hp_isize > 0) {
1139 hp->hp_ibuf = kmem_alloc(hp->hp_isize, KM_SLEEP);
1141 status = usbd_open_pipe_intr(hp->hp_ifh, hp->hp_iaddr,
1142 USBD_SHORT_XFER_OK, &hp->hp_ipipe, hp, hp->hp_ibuf,
1143 hp->hp_isize, uhso_bulk_intr, USBD_DEFAULT_INTERVAL);
1153 status = usbd_open_pipe(hp->hp_ifh, hp->hp_raddr, 0, &hp->hp_rpipe);
1159 status = usbd_open_pipe(hp->hp_ifh, hp->hp_waddr, 0, &hp->hp_wpipe);
1165 int error = usbd_create_xfer(hp->hp_rpipe, hp->hp_rsize,
1166 0, 0, &hp->hp_rxfer);
1170 hp->hp_rbuf = usbd_get_buffer(hp->hp_rxfer);
1172 error = usbd_create_xfer(hp->hp_wpipe, hp->hp_wsize, 0, 0,
1173 &hp->hp_wxfer);
1176 hp->hp_wbuf = usbd_get_buffer(hp->hp_wxfer);
1182 uhso_bulk_clean(struct uhso_port *hp)
1185 DPRINTF(1, "hp=%p\n", hp);
1187 if (hp->hp_ipipe != NULL) {
1188 usbd_abort_pipe(hp->hp_ipipe);
1189 usbd_close_pipe(hp->hp_ipipe);
1190 hp->hp_ipipe = NULL;
1193 if (hp->hp_ibuf != NULL) {
1194 kmem_free(hp->hp_ibuf, hp->hp_isize);
1195 hp->hp_ibuf = NULL;
1198 if (hp->hp_rpipe != NULL) {
1199 usbd_abort_pipe(hp->hp_rpipe);
1202 if (hp->hp_wpipe != NULL) {
1203 usbd_abort_pipe(hp->hp_wpipe);
1206 if (hp->hp_rxfer != NULL) {
1207 usbd_destroy_xfer(hp->hp_rxfer);
1208 hp->hp_rxfer = NULL;
1209 hp->hp_rbuf = NULL;
1212 if (hp->hp_wxfer != NULL) {
1213 usbd_destroy_xfer(hp->hp_wxfer);
1214 hp->hp_wxfer = NULL;
1215 hp->hp_wbuf = NULL;
1218 if (hp->hp_rpipe != NULL) {
1219 usbd_close_pipe(hp->hp_rpipe);
1220 hp->hp_rpipe = NULL;
1223 if (hp->hp_wpipe != NULL) {
1224 usbd_close_pipe(hp->hp_wpipe);
1225 hp->hp_wpipe = NULL;
1232 uhso_bulk_write(struct uhso_port *hp)
1234 struct uhso_softc *sc = hp->hp_sc;
1237 DPRINTF(5, "hp=%p, wlen=%zd\n", hp, hp->hp_wlen);
1239 usbd_setup_xfer(hp->hp_wxfer, hp, hp->hp_wbuf, hp->hp_wlen, 0,
1240 USBD_NO_TIMEOUT, hp->hp_write_cb);
1242 status = usbd_transfer(hp->hp_wxfer);
1253 uhso_bulk_read(struct uhso_port *hp)
1255 struct uhso_softc *sc = hp->hp_sc;
1258 DPRINTF(5, "hp=%p\n", hp);
1260 usbd_setup_xfer(hp->hp_rxfer, hp, hp->hp_rbuf, hp->hp_rsize,
1261 USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, hp->hp_read_cb);
1263 status = usbd_transfer(hp->hp_rxfer);
1274 uhso_bulk_control(struct uhso_port *hp)
1276 struct uhso_softc *sc = hp->hp_sc;
1281 DPRINTF(1, "hp=%p\n", hp);
1283 if (hp->hp_isize == 0)
1287 if (ISSET(hp->hp_status, TIOCM_DTR))
1289 if (ISSET(hp->hp_status, TIOCM_RTS))
1295 USETW(req.wIndex, hp->hp_index);
1316 struct uhso_port *hp = p;
1317 struct tty *tp = hp->hp_tp;
1333 || UGETW(msg->wIndex) != hp->hp_index
1339 old = hp->hp_status;
1340 CLR(hp->hp_status, TIOCM_RNG | TIOCM_DSR | TIOCM_CAR);
1342 SET(hp->hp_status, TIOCM_RNG);
1344 SET(hp->hp_status, TIOCM_DSR);
1346 SET(hp->hp_status, TIOCM_CAR);
1348 if (ISSET(hp->hp_status ^ old, TIOCM_CAR)) {
1350 tp->t_linesw->l_modem(tp, ISSET(hp->hp_status, TIOCM_CAR));
1354 if (ISSET((hp->hp_status ^ old), TIOCM_RNG | TIOCM_DSR | TIOCM_CAR))
1356 (ISSET(hp->hp_status, TIOCM_RNG) ? "on" : "off"),
1357 (ISSET(hp->hp_status, TIOCM_DSR) ? "on" : "off"),
1358 (ISSET(hp->hp_status, TIOCM_CAR) ? "on" : "off"));
1369 uhso_tty_attach(struct uhso_port *hp)
1377 hp->hp_tp = tp;
1380 DPRINTF(1, "hp=%p, tp=%p\n", hp, tp);
1384 uhso_tty_detach(struct uhso_port *hp)
1387 DPRINTF(1, "hp=%p\n", hp);
1389 uhso_tty_clean(hp);
1391 tty_detach(hp->hp_tp);
1392 tty_free(hp->hp_tp);
1393 hp->hp_tp = NULL;
1399 struct uhso_port *hp = p;
1400 struct uhso_softc *sc = hp->hp_sc;
1401 struct tty *tp = hp->hp_tp;
1411 if (status == USBD_STALLED && hp->hp_wpipe != NULL)
1412 usbd_clear_endpoint_stall_async(hp->hp_wpipe);
1418 DPRINTF(5, "wrote %d bytes (of %zd)\n", cc, hp->hp_wlen);
1419 if (cc != hp->hp_wlen)
1420 DPRINTF(0, "cc=%u, wlen=%zd\n", cc, hp->hp_wlen);
1432 struct uhso_port *hp = p;
1433 struct uhso_softc *sc = hp->hp_sc;
1434 struct tty *tp = hp->hp_tp;
1445 if (status == USBD_STALLED && hp->hp_rpipe != NULL)
1446 usbd_clear_endpoint_stall_async(hp->hp_rpipe);
1450 hp->hp_rlen = 0;
1454 hp->hp_rlen = cc;
1469 (*hp->hp_read)(hp);
1483 struct uhso_port *hp;
1495 hp = sc->sc_port[UHSOPORT(dev)];
1496 if (hp == NULL || hp->hp_tp == NULL)
1499 tp = hp->hp_tp;
1507 error = uhso_tty_init(hp);
1519 uhso_tty_clean(hp);
1521 DPRINTF(1, "sc=%p, hp=%p, tp=%p, error=%d\n", sc, hp, tp, error);
1527 uhso_tty_init(struct uhso_port *hp)
1529 struct tty *tp = hp->hp_tp;
1533 DPRINTF(1, "sc=%p, hp=%p, tp=%p\n", sc, hp, tp);
1542 if (ISSET(hp->hp_swflags, TIOCFLAG_CLOCAL))
1544 if (ISSET(hp->hp_swflags, TIOCFLAG_CRTSCTS))
1546 if (ISSET(hp->hp_swflags, TIOCFLAG_MDMBUF))
1559 hp->hp_status = 0;
1560 error = (*hp->hp_init)(hp);
1571 uhso_tty_control(hp, TIOCMBIS, TIOCM_DTR | TIOCM_RTS);
1574 error = (*hp->hp_read)(hp);
1585 struct uhso_port *hp = sc->sc_port[UHSOPORT(dev)];
1586 struct tty *tp = hp->hp_tp;
1591 DPRINTF(1, "sc=%p, hp=%p, tp=%p\n", sc, hp, tp);
1599 uhso_tty_clean(hp);
1608 uhso_tty_clean(struct uhso_port *hp)
1611 DPRINTF(1, "hp=%p\n", hp);
1613 if (ISSET(hp->hp_status, TIOCM_DTR)
1614 && ISSET(hp->hp_tp->t_cflag, HUPCL))
1615 uhso_tty_control(hp, TIOCMBIC, TIOCM_DTR);
1617 (*hp->hp_clean)(hp);
1619 if (hp->hp_rxfer != NULL) {
1620 usbd_destroy_xfer(hp->hp_rxfer);
1621 hp->hp_rxfer = NULL;
1622 hp->hp_rbuf = NULL;
1625 if (hp->hp_wxfer != NULL) {
1626 usbd_destroy_xfer(hp->hp_wxfer);
1627 hp->hp_wxfer = NULL;
1628 hp->hp_wbuf = NULL;
1636 struct uhso_port *hp = sc->sc_port[UHSOPORT(dev)];
1637 struct tty *tp = hp->hp_tp;
1643 DPRINTF(5, "sc=%p, hp=%p, tp=%p\n", sc, hp, tp);
1659 struct uhso_port *hp = sc->sc_port[UHSOPORT(dev)];
1660 struct tty *tp = hp->hp_tp;
1666 DPRINTF(5, "sc=%p, hp=%p, tp=%p\n", sc, hp, tp);
1682 struct uhso_port *hp = sc->sc_port[UHSOPORT(dev)];
1688 DPRINTF(1, "sc=%p, hp=%p\n", sc, hp);
1692 error = uhso_tty_do_ioctl(hp, cmd, data, flag, l);
1701 uhso_tty_do_ioctl(struct uhso_port *hp, u_long cmd, void *data, int flag,
1704 struct tty *tp = hp->hp_tp;
1721 error = uhso_tty_control(hp, TIOCMBIS, TIOCM_DTR);
1725 error = uhso_tty_control(hp, TIOCMBIC, TIOCM_DTR);
1729 *(int *)data = hp->hp_swflags;
1739 hp->hp_swflags = *(int *)data;
1745 error = uhso_tty_control(hp, cmd, *(int *)data);
1749 *(int *)data = hp->hp_status;
1768 struct uhso_port *hp = sc->sc_port[UHSOPORT(tp->t_dev)];
1778 struct uhso_port *hp = sc->sc_port[UHSOPORT(dev)];
1780 return hp->hp_tp;
1787 struct uhso_port *hp = sc->sc_port[UHSOPORT(dev)];
1788 struct tty *tp = hp->hp_tp;
1809 struct uhso_port *hp = sc->sc_port[UHSOPORT(tp->t_dev)];
1814 DPRINTF(1, "hp=%p, tp=%p, termios iflag=%x, oflag=%x, cflag=%x\n",
1815 hp, tp, t->c_iflag, t->c_oflag, t->c_cflag);
1823 if (ISSET(hp->hp_swflags, TIOCFLAG_SOFTCAR)) {
1838 tp->t_linesw->l_modem(tp, ISSET(hp->hp_status, TIOCM_CAR));
1847 struct uhso_port *hp = sc->sc_port[UHSOPORT(tp->t_dev)];
1859 hp->hp_wlen = q_to_b(&tp->t_outq, hp->hp_wbuf, hp->hp_wsize);
1860 if (hp->hp_wlen > 0) {
1862 (*hp->hp_write)(hp);
1870 uhso_tty_control(struct uhso_port *hp, u_long cmd, int bits)
1881 CLR(hp->hp_status, bits);
1885 SET(hp->hp_status, bits);
1889 CLR(hp->hp_status, TIOCM_DTR | TIOCM_RTS);
1890 SET(hp->hp_status, bits);
1894 return (*hp->hp_control)(hp);
1908 struct uhso_port *hp;
1939 hp = kmem_zalloc(sizeof(struct uhso_port), KM_SLEEP);
1940 sc->sc_port[index] = hp;
1944 ifp->if_softc = hp;
1954 hp->hp_sc = sc;
1955 hp->hp_ifp = ifp;
1956 hp->hp_ifh = ifh;
1957 hp->hp_raddr = in;
1958 hp->hp_waddr = out;
1959 hp->hp_abort = uhso_ifnet_abort;
1960 hp->hp_detach = uhso_ifnet_detach;
1961 hp->hp_init = uhso_bulk_init;
1962 hp->hp_clean = uhso_bulk_clean;
1963 hp->hp_write = uhso_bulk_write;
1964 hp->hp_write_cb = uhso_ifnet_write_cb;
1965 hp->hp_read = uhso_bulk_read;
1966 hp->hp_read_cb = uhso_ifnet_read_cb;
1967 hp->hp_wsize = MCLBYTES;
1968 hp->hp_rsize = MCLBYTES;
1979 hp)
1981 struct ifnet *ifp = hp->hp_ifp;
1986 return (*hp->hp_clean)(hp);
1990 uhso_ifnet_detach(struct uhso_port *hp)
1992 struct ifnet *ifp = hp->hp_ifp;
2001 kmem_free(hp, sizeof(struct uhso_port));
2008 struct uhso_port *hp = p;
2009 struct uhso_softc *sc= hp->hp_sc;
2010 struct ifnet *ifp = hp->hp_ifp;
2023 if (status == USBD_STALLED && hp->hp_wpipe != NULL)
2024 usbd_clear_endpoint_stall_async(hp->hp_wpipe);
2031 DPRINTF(5, "wrote %d bytes (of %zd)\n", cc, hp->hp_wlen);
2033 if (cc != hp->hp_wlen)
2034 DPRINTF(0, "cc=%u, wlen=%zd\n", cc, hp->hp_wlen);
2049 struct uhso_port *hp = p;
2050 struct uhso_softc *sc= hp->hp_sc;
2051 struct ifnet *ifp = hp->hp_ifp;
2064 if (status == USBD_STALLED && hp->hp_rpipe != NULL)
2065 usbd_clear_endpoint_stall_async(hp->hp_rpipe);
2070 hp->hp_rlen = 0;
2074 hp->hp_rlen = cc;
2077 uhso_ifnet_input(ifp, &hp->hp_mbuf, cp, cc);
2080 (*hp->hp_read)(hp);
2192 struct uhso_port *hp = ifp->if_softc;
2204 error = uhso_ifnet_init(hp);
2206 uhso_ifnet_clean(hp);
2211 DPRINTF(1, "hp=%p, ifp=%p INITIFADDR\n", hp,
2227 if (((struct ifreq *)data)->ifr_mtu > hp->hp_wsize) {
2245 error = uhso_ifnet_init(hp);
2247 uhso_ifnet_clean(hp);
2252 DPRINTF(1, "hp=%p, ifp=%p RUNNING\n", hp, ifp);
2256 uhso_ifnet_clean(hp);
2258 DPRINTF(1, "hp=%p, ifp=%p STOPPED\n", hp, ifp);
2278 uhso_ifnet_init(struct uhso_port *hp)
2280 struct uhso_softc *sc = hp->hp_sc;
2283 DPRINTF(1, "sc=%p, hp=%p\n", sc, hp);
2288 error = (*hp->hp_init)(hp);
2292 error = (*hp->hp_read)(hp);
2300 uhso_ifnet_clean(struct uhso_port *hp)
2303 DPRINTF(1, "hp=%p\n", hp);
2305 (*hp->hp_clean)(hp);
2312 struct uhso_port *hp = ifp->if_softc;
2327 hp->hp_wlen = m->m_pkthdr.len;
2328 if (hp->hp_wlen > hp->hp_wsize) {
2331 hp->hp_wlen, hp->hp_wsize);
2333 hp->hp_wlen = hp->hp_wsize;
2338 m_copydata(m, 0, hp->hp_wlen, hp->hp_wbuf);
2341 if ((*hp->hp_write)(hp) != 0) {