Changeset 277 for freebsd-mos-driver
- Timestamp:
- Feb 15, 2011, 7:33:06 AM (14 years ago)
- Location:
- freebsd-mos-driver
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
freebsd-mos-driver/if_mos.c
r276 r277 142 142 DPRINTF("mos: %s: " fmt "\n",__FUNCTION__,## __VA_ARGS__) 143 143 144 #define USB_PRODUCT_MOSCHIP_MCS7730 0x7730 /* MCS7730 Ethernet */ 145 #define USB_PRODUCT_SITECOMEU_LN030 0x0021 /* LN-030 */ 146 147 148 149 /* 150 * Various supported device vendors/products. 151 */ 144 #define USB_PRODUCT_MOSCHIP_MCS7730 0x7730 145 #define USB_PRODUCT_SITECOMEU_LN030 0x0021 146 147 148 149 /* Various supported device vendors/products. */ 152 150 static const struct usb_device_id mos_devs[] = { 153 151 {USB_VPI(USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7730, MCS7730)}, … … 196 194 .flags = {.pipe_bof = 1,.force_short_xfer = 1,}, 197 195 .callback = mos_bulk_write_callback, 198 .timeout = 10000, /* 10 seconds */196 .timeout = 10000, 199 197 }, 200 198 … … 213 211 .direction = UE_DIR_IN, 214 212 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, 215 .bufsize = 0, /* use wMaxPacketSize */213 .bufsize = 0, 216 214 .callback = mos_intr_callback, 217 215 }, … … 316 314 usb_error_t err; 317 315 uByte val; 318 319 316 val = aval; 320 317 … … 533 530 struct mos_softc *sc = ifp->if_softc; 534 531 struct mii_data *mii = GET_MII(sc); 532 struct mii_softc *miisc; 535 533 536 534 MOS_LOCK_ASSERT(sc, MA_OWNED); … … 538 536 sc->mos_link = 0; 539 537 if (mii->mii_instance) { 540 struct mii_softc *miisc;541 542 538 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) 543 539 mii_phy_reset(miisc); … … 570 566 struct ifnet *ifp = uether_getifp(ue); 571 567 572 u _int8_t rxmode;568 uint8_t rxmode; 573 569 574 570 MOS_LOCK_ASSERT(sc, MA_OWNED); … … 595 591 struct ifmultiaddr *ifma; 596 592 597 u _int32_t h = 0;598 u _int8_t rxmode;599 u _int8_t hashtbl[8] = {0, 0, 0, 0, 0, 0, 0, 0};593 uint32_t h = 0; 594 uint8_t rxmode; 595 uint8_t hashtbl[8] = {0, 0, 0, 0, 0, 0, 0, 0}; 600 596 int allmulti = 0; 601 597 … … 616 612 h = ether_crc32_be(LLADDR((struct sockaddr_dl *) 617 613 ifma->ifma_addr), ETHER_ADDR_LEN) >> 26; 618 //h = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26;619 614 hashtbl[h / 8] |= 1 << (h % 8); 620 615 } … … 635 630 mos_reset(struct mos_softc *sc) 636 631 { 637 u _int8_t ctl;632 uint8_t ctl; 638 633 639 634 ctl = mos_reg_read_1(sc, MOS_CTL); … … 674 669 mos_probe(device_t dev) 675 670 { 676 DPRINTFN(11, "mos: probe\n");677 671 struct usb_attach_arg *uaa = device_get_ivars(dev); 672 int retval; 678 673 679 674 if (uaa->usb_mode != USB_MODE_HOST) { 680 DPRINTFN(11, "mos: not USB_MODE_HOST\n");681 675 return (ENXIO); 682 676 } 683 677 if (uaa->info.bConfigNum != MOS_CONFIG_NO) { 684 DPRINTFN(11, "mos: not MOS_CONFIG_NO %i vs %i\n", uaa->info.bConfigNum, MOS_CONFIG_NO);685 678 return (ENXIO); 686 679 } 687 if (uaa->info.bIfaceIndex != MOS_IFACE_IDX) { 688 DPRINTFN(11, "mos: not MOS_IFACE_IDX %i vs %i\n", uaa->info.bIfaceIndex, MOS_IFACE_IDX); 680 if (uaa->info.bIfaceIndex != 0) { 689 681 return (ENXIO); 690 682 } 691 DPRINTFN(11, "mos: probe by generic means\n"); 692 int retval = usbd_lookup_id_by_uaa(mos_devs, sizeof(mos_devs), uaa); 693 694 DPRINTFN(11, "mos: probe retval: %i (ENXIO:%i)\n", retval, ENXIO); 683 684 retval = usbd_lookup_id_by_uaa(mos_devs, sizeof(mos_devs), uaa); 695 685 return retval; 696 686 } … … 706 696 struct mos_softc *sc = device_get_softc(dev); 707 697 struct usb_ether *ue = &sc->sc_ue; 708 709 698 uint8_t iface_index; 710 699 int error; … … 732 721 733 722 if (sc->mos_flags & MCS7730) { 734 DPRINTF("model: MCS7730\n");723 MOS_DPRINTFN("model: MCS7730"); 735 724 } else if (sc->mos_flags & MCS7830) { 736 DPRINTF("model: MCS7830\n");725 MOS_DPRINTFN("model: MCS7830"); 737 726 } 738 727 error = uether_ifattach(ue); … … 741 730 goto detach; 742 731 } 743 return (0); /* success */732 return (0); 744 733 745 734 746 735 detach: 747 736 mos_detach(dev); 748 return (ENXIO); /* failure */737 return (ENXIO); 749 738 } 750 739 … … 754 743 { 755 744 struct mos_softc *sc = uether_getsc(ue); 756 757 /* 758 * Read MAC address, inform the world. 759 */ 760 int err = mos_readmac(sc, ue->ue_eaddr); 745 int err; 746 747 /* Read MAC address, inform the world. */ 748 err = mos_readmac(sc, ue->ue_eaddr); 761 749 762 750 if (err) … … 799 787 uint16_t pktlen = 0; 800 788 struct usb_page_cache *pc; 801 802 789 803 790 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); … … 843 830 uether_rxflush(ue); 844 831 return; 845 default: /* Error */832 default: 846 833 MOS_DPRINTFN("bulk read error, %s", usbd_errstr(error)); 847 834 if (error != USB_ERR_CANCELLED) { 848 /* try to clear stall first */849 835 usbd_xfer_set_stall(xfer); 850 836 goto tr_setup; … … 859 845 * the list buffers. 860 846 */ 861 862 847 static void 863 848 mos_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) … … 902 887 ifp->if_opackets++; 903 888 return; 904 default: /* Error */889 default: 905 890 MOS_DPRINTFN("usb error on tx: %s\n", usbd_errstr(error)); 906 891 ifp->if_oerrors++; 907 892 if (error != USB_ERR_CANCELLED) { 908 /* try to clear stall first */909 893 usbd_xfer_set_stall(xfer); 910 894 goto tr_setup; … … 950 934 struct mos_softc *sc = uether_getsc(ue); 951 935 struct ifnet *ifp = uether_getifp(ue); 952 u _int8_t rxmode;936 uint8_t rxmode; 953 937 954 938 MOS_LOCK_ASSERT(sc, MA_OWNED); 955 939 956 /* 957 * Cancel pending I/O and free all RX/TX buffers. 958 */ 940 /* Cancel pending I/O and free all RX/TX buffers. */ 959 941 mos_reset(sc); 960 942 961 /* 962 * Write MAC address 963 */ 943 /* Write MAC address */ 964 944 mos_writemac(sc, IF_LLADDR(ifp)); 965 966 967 945 968 946 /* Read and set transmitter IPG values */ … … 983 961 984 962 /* XXX: broadcast mode? */ 985 986 963 mos_reg_write_1(sc, MOS_CTL, rxmode); 987 964 … … 1000 977 struct ifnet *ifp = uether_getifp(&sc->sc_ue); 1001 978 struct usb_page_cache *pc; 979 uint32_t pkt; 1002 980 int actlen; 1003 long pkt;1004 981 1005 982 ifp->if_oerrors++; … … 1017 994 tr_setup: 1018 995 return; 1019 default: /* Error */996 default: 1020 997 if (error != USB_ERR_CANCELLED) { 1021 /* try to clear stall first */1022 998 usbd_xfer_set_stall(xfer); 1023 999 goto tr_setup; … … 1043 1019 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; 1044 1020 1045 /* 1046 * stop all the transfers, if not already stopped: 1047 */ 1021 /* stop all the transfers, if not already stopped */ 1048 1022 usbd_transfer_stop(sc->sc_xfer[MOS_ENDPT_TX]); 1049 1023 usbd_transfer_stop(sc->sc_xfer[MOS_ENDPT_RX]); -
freebsd-mos-driver/if_mosreg.h
r274 r277 150 150 #define MOS_IFACE_IDX 0 151 151 152 #define MCS7730 0x0001 /* MCS7730 */153 #define MCS7830 0x0002 /* MCS7830 */152 #define MCS7730 0x0001 153 #define MCS7830 0x0002 154 154 155 155 #define MOS_INC(x, y) (x) = (x + 1) % y … … 159 159 struct ifnet ifp; 160 160 161 u_int16_t mos_flags; 161 struct mtx sc_mtx; 162 struct usb_xfer *sc_xfer[MOS_ENDPT_MAX]; 162 163 163 int mos_link; 164 uint16_t mos_flags; 165 166 int mos_link; 164 167 unsigned char mos_ipgs[2]; 165 168 unsigned char mos_phyaddrs[2]; 166 167 struct mtx sc_mtx;168 struct usb_xfer *sc_xfer[MOS_ENDPT_MAX];169 169 }; 170 170
Note:
See TracChangeset
for help on using the changeset viewer.