Changeset 199 for freebsd-mos-driver
- Timestamp:
- Oct 10, 2010, 8:13:45 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
freebsd-mos-driver/if_mos.c
r177 r199 367 367 368 368 if (err) { 369 DPRINTF("mos_readmac error");370 369 return (-1); 371 370 } … … 424 423 uWord val; 425 424 int i,res, locked; 426 DPRINTF("%s enter\n", __func__);427 425 428 426 USETW(val, 0); … … 720 718 721 719 722 DPRINTF("%s:", "mos");723 724 720 if (sc->mos_flags & MCS7730) { 725 DPRINTF(" MCS7730");721 DPRINTF("model: MCS7730\n"); 726 722 } else if (sc->mos_flags & MCS7830) { 727 DPRINTF(" MCS7830");723 DPRINTF("model: MCS7830\n"); 728 724 } 729 725 … … 791 787 u_int16_t pktlen = 0; 792 788 struct mbuf *stat; 793 uint8_t status;794 789 struct usb_page_cache *pc; 795 790 … … 799 794 pc = usbd_xfer_get_frame(xfer, 0); 800 795 801 status = USB_GET_STATE(xfer); 802 if (status != USB_ST_SETUP) { 803 if (status == USB_ST_TRANSFERRED) { 804 if (actlen <= 1) 805 goto done; 806 807 usbd_copy_out(pc, actlen - sizeof(stat), &stat, 808 sizeof(stat)); 809 810 /* evaluate status byte at the end */ 811 pktlen = actlen - 1; 812 //rxstat = stat[pktlen] & MOS_RXSTS_MASK; 813 m_freem(stat); 814 815 if (rxstat != MOS_RXSTS_VALID) { 816 DPRINTF("%s: erroneous frame received: ", 817 "mos"); 818 if (rxstat & MOS_RXSTS_SHORT_FRAME) 819 DPRINTF("frame size less than 64 bytes\n"); 820 if (rxstat & MOS_RXSTS_LARGE_FRAME) 821 DPRINTF("frame size larger than 1532 bytes\n"); 822 if (rxstat & MOS_RXSTS_CRC_ERROR) 823 DPRINTF("CRC error\n"); 824 if (rxstat & MOS_RXSTS_ALIGN_ERROR) 825 DPRINTF("alignment error\n"); 826 ifp->if_ierrors++; 827 goto done; 828 } 829 830 if ( pktlen < sizeof(struct ether_header) ) { 831 ifp->if_ierrors++; 832 goto done; 833 } 834 835 uether_rxbuf(ue, pc, 0, actlen); 836 837 } else { 838 DPRINTF("bulk read error, %s\n", usbd_errstr(error)); 839 if (error == USB_ERR_CANCELLED) { 840 return; 841 } else { 842 /* try to clear stall first */ 843 usbd_xfer_set_stall(xfer); 844 goto done; 845 } 796 switch (USB_GET_STATE(xfer)) { 797 case USB_ST_TRANSFERRED: 798 DPRINTF("read_callback actlen : %d\n", actlen); 799 if (actlen <= 1) 800 ifp->if_ierrors++; 801 goto tr_setup; 802 803 usbd_copy_out(pc, actlen - sizeof(stat), &stat, 804 sizeof(stat)); 805 806 /* evaluate status byte at the end */ 807 pktlen = actlen - 1; 808 //rxstat = stat[pktlen] & MOS_RXSTS_MASK; 809 if (stat != NULL) { 810 m_freem(stat); 811 } else { 812 DPRINTF("Potential NULL error\n"); 846 813 } 847 } 848 done: 849 usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer)); 850 usbd_transfer_submit(xfer); 851 uether_rxflush(ue); 852 DPRINTF("%s: %s: start rx\n", "mos", __func__); 853 854 return; 814 815 if (rxstat != MOS_RXSTS_VALID) { 816 DPRINTF("%s: erroneous frame received: ", 817 "mos"); 818 if (rxstat & MOS_RXSTS_SHORT_FRAME) 819 DPRINTF("frame size less than 64 bytes\n"); 820 if (rxstat & MOS_RXSTS_LARGE_FRAME) 821 DPRINTF("frame size larger than 1532 bytes\n"); 822 if (rxstat & MOS_RXSTS_CRC_ERROR) 823 DPRINTF("CRC error\n"); 824 if (rxstat & MOS_RXSTS_ALIGN_ERROR) 825 DPRINTF("alignment error\n"); 826 ifp->if_ierrors++; 827 goto tr_setup; 828 } 829 830 if ( pktlen < sizeof(struct ether_header) ) { 831 ifp->if_ierrors++; 832 goto tr_setup; 833 } 834 835 uether_rxbuf(ue, pc, 0, actlen); 836 837 /* FALLTHROUGH */ 838 case USB_ST_SETUP: 839 tr_setup: 840 usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer)); 841 usbd_transfer_submit(xfer); 842 uether_rxflush(ue); 843 return; 844 default: /* Error */ 845 DPRINTF("bulk read error, %s\n", usbd_errstr(error)); 846 if (error != USB_ERR_CANCELLED) { 847 /* try to clear stall first */ 848 usbd_xfer_set_stall(xfer); 849 goto tr_setup; 850 } 851 DPRINTF("start rx %i\n", usbd_xfer_max_len(xfer)); 852 return; 853 } 855 854 } 856 855 … … 867 866 struct usb_page_cache *pc; 868 867 struct mbuf *m; 869 uint8_t status;870 868 int actlen; 869 870 DPRINTF("%s: %s: enter\n", "mos",__func__); 871 871 872 872 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); 873 873 pc = usbd_xfer_get_frame(xfer, 0); 874 874 875 status = USB_GET_STATE(xfer); 876 877 if (status != USB_ST_SETUP) { 878 if (status == USB_ST_TRANSFERRED) { 879 DPRINTF("transfer of %d bytes complete\n", actlen); 880 ifp->if_opackets++; 881 } else { 882 DPRINTF("%s: usb error on tx: %s\n", "mos", usbd_errstr(status)); 875 switch (USB_GET_STATE(xfer)) { 876 case USB_ST_TRANSFERRED: 877 DPRINTF("transfer of %d bytes complete\n", actlen); 878 ifp->if_opackets++; 879 /* FALLTHROUGH */ 880 case USB_ST_SETUP: 881 tr_setup: 882 /* 883 * XXX: don't send anything if there is no link? 884 */ 885 IFQ_DRV_DEQUEUE(&ifp->if_snd, m); 886 887 usbd_xfer_set_frame_len(xfer, 0, m->m_pkthdr.len); 888 889 usbd_m_copy_in(pc, 0, m, 0, m->m_pkthdr.len); 890 891 /* 892 * if there's a BPF listener, bounce a copy 893 * of this frame to him: 894 */ 895 BPF_MTAP(ifp, m); 896 897 m_freem(m); 898 899 usbd_transfer_submit(xfer); 900 901 ifp->if_opackets++; 902 return; 903 default: /* Error */ 904 DPRINTF("%s: usb error on tx: %s\n", "mos", usbd_errstr(error)); 883 905 ifp->if_oerrors++; 884 if (error == USB_ERR_CANCELLED) { 885 return; 906 if (error != USB_ERR_CANCELLED) { 907 /* try to clear stall first */ 908 usbd_xfer_set_stall(xfer); 909 goto tr_setup; 886 910 } 887 } 888 } 889 890 IFQ_DRV_DEQUEUE(&ifp->if_snd, m); 891 892 usbd_xfer_set_frame_len(xfer, 0, m->m_pkthdr.len); 893 894 usbd_m_copy_in(pc, 0, m, 0, m->m_pkthdr.len); 895 896 /* 897 * if there's a BPF listener, bounce a copy 898 * of this frame to him: 899 */ 900 BPF_MTAP(ifp, m); 901 902 m_freem(m); 903 904 usbd_transfer_submit(xfer); 905 906 ifp->if_opackets++; 907 return; 911 return; 912 } 908 913 } 909 914 … … 1015 1020 mos_setmulti(ue); 1016 1021 1017 usbd_xfer_set_stall(sc->sc_xfer[MOS_ENDPT_TX]);1018 1019 1022 ifp->if_flags |= IFF_DRV_RUNNING; 1020 1023 mos_start(ue);
Note:
See TracChangeset
for help on using the changeset viewer.