usb Ether works ok
authorxzj <xzj@rock-chips.com>
Sat, 3 Dec 2011 03:38:32 +0000 (11:38 +0800)
committerxzj <xzj@rock-chips.com>
Sat, 3 Dec 2011 07:22:14 +0000 (15:22 +0800)
arch/arm/configs/rk29_ddr3sdk_defconfig
drivers/net/usb/dm9620.c
drivers/net/usb/sr9700.c
include/linux/usb/usbnet.h

index 2ce8fbb0a69589bd2bd58d96ed94cfde0cf9b6af..24c4a298439c9dddb067d3b2466cf7258c5aa9d1 100755 (executable)
@@ -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
index 34019e8927c7428c13e7780313b3a86c1e18fa19..2f5a8fa1f6c5709fa6995cd54fe8975d36f8d68a 100755 (executable)
@@ -19,9 +19,9 @@
  * V1.5 - Support RK2818 (Debug the Register Function) 
  */
 
-//#define DEBUG
+#define DEBUG
 
-#define RK2818
+//#define RK2818
 
 
 #include <linux/module.h>
@@ -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);
 }
 
  
index b25eb29805f1fed7ccdac7b19e4ced91016508a1..cd16b97f0d77099fa38540a6ca3e1867392fd40f 100755 (executable)
@@ -9,7 +9,7 @@
  * kind, whether express or implied.
  */
 
-//#define DEBUG
+#define DEBUG
 
 #include <linux/module.h>
 #include <linux/sched.h>
@@ -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)
index 605b0aa8d852f63d4d0c7a3cf18add1f518e2acd..5bfdd1b2f0f1f1aba841c6dcef1a71eb639a214b 100644 (file)
@@ -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 */