From: xzj Date: Sat, 3 Dec 2011 03:38:32 +0000 (+0800) Subject: usb Ether works ok X-Git-Tag: firefly_0821_release~9732^2~2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=395e7ecfc6a73b59f3a7a345ffeee5c634f87eef;p=firefly-linux-kernel-4.4.55.git usb Ether works ok --- diff --git a/arch/arm/configs/rk29_ddr3sdk_defconfig b/arch/arm/configs/rk29_ddr3sdk_defconfig index 2ce8fbb0a695..24c4a298439c 100755 --- a/arch/arm/configs/rk29_ddr3sdk_defconfig +++ b/arch/arm/configs/rk29_ddr3sdk_defconfig @@ -192,12 +192,12 @@ CONFIG_BLK_DEV_DM=y CONFIG_DM_CRYPT=y CONFIG_DM_UEVENT=y CONFIG_NETDEVICES=y -CONFIG_NET_ETHERNET=y -CONFIG_RK29_VMAC=y +CONFIG_PHYLIB=y # CONFIG_NETDEV_1000 is not set # CONFIG_NETDEV_10000 is not set CONFIG_WLAN_80211=y CONFIG_BCM4329=y +CONFIG_USB_USBNET=y CONFIG_PPP=y CONFIG_PPP_MULTILINK=y CONFIG_PPP_FILTER=y diff --git a/drivers/net/usb/dm9620.c b/drivers/net/usb/dm9620.c index 34019e8927c7..2f5a8fa1f6c5 100755 --- a/drivers/net/usb/dm9620.c +++ b/drivers/net/usb/dm9620.c @@ -19,9 +19,9 @@ * V1.5 - Support RK2818 (Debug the Register Function) */ -//#define DEBUG +#define DEBUG -#define RK2818 +//#define RK2818 #include @@ -525,31 +525,31 @@ static struct ethtool_ops dm9620_ethtool_ops = { static void dm9620_set_multicast(struct net_device *net) { - struct usbnet *dev = netdev_priv(net); - /* We use the 20 byte dev->data for our 8 byte filter buffer - * to avoid allocating memory that is tricky to free later */ - u8 *hashes = (u8 *) & dev->data; - u8 rx_ctl = 0x31; - - memset(hashes, 0x00, DM_MCAST_SIZE); - hashes[DM_MCAST_SIZE - 1] |= 0x80; /* broadcast address */ - - if (net->flags & IFF_PROMISC) { - rx_ctl |= 0x02; - } else if (net->flags & IFF_ALLMULTI || net->mc_count > DM_MAX_MCAST) { - rx_ctl |= 0x04; - } else if (net->mc_count) { - struct dev_mc_list *mc_list = net->mc_list; - int i; - - for (i = 0; i < net->mc_count; i++, mc_list = mc_list->next) { - u32 crc = ether_crc(ETH_ALEN, mc_list->dmi_addr) >> 26; - hashes[crc >> 3] |= 1 << (crc & 0x7); - } - } - - dm_write_async(dev, DM_MCAST_ADDR, DM_MCAST_SIZE, hashes); - dm_write_reg_async(dev, DM_RX_CTRL, rx_ctl); + struct usbnet *dev = netdev_priv(net); + /* We use the 20 byte dev->data for our 8 byte filter buffer + * to avoid allocating memory that is tricky to free later */ + u8 *hashes = (u8 *) & dev->data; + u8 rx_ctl = 0x31; + + memset(hashes, 0x00, DM_MCAST_SIZE); + hashes[DM_MCAST_SIZE - 1] |= 0x80; /* broadcast address */ + + if (net->flags & IFF_PROMISC) { + rx_ctl |= 0x02; + } else if (net->flags & IFF_ALLMULTI || + netdev_mc_count(net) > DM_MAX_MCAST) { + rx_ctl |= 0x04; + } else if (!netdev_mc_empty(net)) { + struct netdev_hw_addr *ha; + + netdev_for_each_mc_addr(ha, net) { + u32 crc = ether_crc(ETH_ALEN, ha->addr) >> 26; + hashes[crc >> 3] |= 1 << (crc & 0x7); + } + } + + dm_write_async(dev, DM_MCAST_ADDR, DM_MCAST_SIZE, hashes); + dm_write_reg_async(dev, DM_RX_CTRL, rx_ctl); } diff --git a/drivers/net/usb/sr9700.c b/drivers/net/usb/sr9700.c index b25eb29805f1..cd16b97f0d77 100755 --- a/drivers/net/usb/sr9700.c +++ b/drivers/net/usb/sr9700.c @@ -9,7 +9,7 @@ * kind, whether express or implied. */ -//#define DEBUG +#define DEBUG #include #include @@ -353,31 +353,31 @@ static const struct ethtool_ops sr9700_android_ethtool_ops = { static void sr9700_android_set_multicast(struct net_device *net) { - struct usbnet *dev = netdev_priv(net); - /* We use the 20 byte dev->data for our 8 byte filter buffer - * to avoid allocating memory that is tricky to free later */ - u8 *hashes = (u8 *) & dev->data; - u8 rx_ctl = 0x31; // enable, disable_long, disable_crc - - memset(hashes, 0x00, QF_MCAST_SIZE); - hashes[QF_MCAST_SIZE - 1] |= 0x80; /* broadcast address */ - - if (net->flags & IFF_PROMISC) { - rx_ctl |= 0x02; - } else if (net->flags & IFF_ALLMULTI || net->mc_count > QF_MCAST_MAX) { - rx_ctl |= 0x04; - } else if (net->mc_count) { - struct dev_mc_list *mc_list = net->mc_list; - int i; - - for (i = 0; i < net->mc_count; i++, mc_list = mc_list->next) { - u32 crc = ether_crc(ETH_ALEN, mc_list->dmi_addr) >> 26; - hashes[crc >> 3] |= 1 << (crc & 0x7); - } - } - - qf_write_async(dev, MAR, QF_MCAST_SIZE, hashes); - qf_write_reg_async(dev, RCR, rx_ctl); + struct usbnet *dev = netdev_priv(net); + /* We use the 20 byte dev->data for our 8 byte filter buffer + * to avoid allocating memory that is tricky to free later */ + u8 *hashes = (u8 *) & dev->data; + u8 rx_ctl = 0x31; + + memset(hashes, 0x00, QF_MCAST_SIZE); + hashes[QF_MCAST_SIZE - 1] |= 0x80; /* broadcast address */ + + if (net->flags & IFF_PROMISC) { + rx_ctl |= 0x02; + } else if (net->flags & IFF_ALLMULTI || + netdev_mc_count(net) > QF_MCAST_MAX) { + rx_ctl |= 0x04; + } else if (!netdev_mc_empty(net)) { + struct netdev_hw_addr *ha; + + netdev_for_each_mc_addr(ha, net) { + u32 crc = ether_crc(ETH_ALEN, ha->addr) >> 26; + hashes[crc >> 3] |= 1 << (crc & 0x7); + } + } + + qf_write_async(dev, MAR, QF_MCAST_SIZE, hashes); + qf_write_reg_async(dev, RCR, rx_ctl); } static int sr9700_android_set_mac_address(struct net_device *net, void *p) diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h index 605b0aa8d852..5bfdd1b2f0f1 100644 --- a/include/linux/usb/usbnet.h +++ b/include/linux/usb/usbnet.h @@ -228,4 +228,22 @@ extern void usbnet_set_msglevel(struct net_device *, u32); extern void usbnet_get_drvinfo(struct net_device *, struct ethtool_drvinfo *); extern int usbnet_nway_reset(struct net_device *net); + +#ifdef DEBUG +#define devdbg(usbnet, fmt, arg...) \ + printk(KERN_DEBUG "%s: " fmt "\n" , (usbnet)->net->name , ## arg) +#else +#define devdbg(usbnet, fmt, arg...) \ + ({ if (0) printk(KERN_DEBUG "%s: " fmt "\n" , (usbnet)->net->name , \ + ## arg); 0; }) +#endif + +#define deverr(usbnet, fmt, arg...) \ + printk(KERN_ERR "%s: " fmt "\n" , (usbnet)->net->name , ## arg) +#define devwarn(usbnet, fmt, arg...) \ + printk(KERN_WARNING "%s: " fmt "\n" , (usbnet)->net->name , ## arg) + +#define devinfo(usbnet, fmt, arg...) \ + printk(KERN_INFO "%s: " fmt "\n" , (usbnet)->net->name , ## arg); + #endif /* __LINUX_USB_USBNET_H */