cdc-ether: implement MULTICAST flag on the device
authorOliver Neukum <oneukum@suse.de>
Thu, 6 Nov 2014 14:19:14 +0000 (15:19 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 7 Nov 2014 20:17:45 +0000 (15:17 -0500)
Olivier having laid the groundwork this patch transmits the
multicast flag to the device to save some bus traffic.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/cdc_ether.c

index d3920b54a92ce3de23a581d3cf80e99aa7d61e72..9311a08565bed17cf5082a21b9c6dca7ab02dfe1 100644 (file)
@@ -71,18 +71,19 @@ static void usbnet_cdc_update_filter(struct usbnet *dev)
 {
        struct cdc_state        *info = (void *) &dev->data;
        struct usb_interface    *intf = info->control;
+       struct net_device       *net = dev->net;
 
-       u16 cdc_filter =
-           USB_CDC_PACKET_TYPE_ALL_MULTICAST | USB_CDC_PACKET_TYPE_DIRECTED |
-           USB_CDC_PACKET_TYPE_BROADCAST;
+       u16 cdc_filter = USB_CDC_PACKET_TYPE_DIRECTED
+                       | USB_CDC_PACKET_TYPE_BROADCAST;
 
-       if (dev->net->flags & IFF_PROMISC)
-               cdc_filter |= USB_CDC_PACKET_TYPE_PROMISCUOUS;
-
-       /* FIXME cdc-ether has some multicast code too, though it complains
-        * in routine cases.  info->ether describes the multicast support.
-        * Implement that here, manipulating the cdc filter as needed.
+       /* filtering on the device is an optional feature and not worth
+        * the hassle so we just roughly care about snooping and if any
+        * multicast is requested, we take every multicast
         */
+       if (net->flags & IFF_PROMISC)
+               cdc_filter |= USB_CDC_PACKET_TYPE_PROMISCUOUS;
+       if (!netdev_mc_empty(net) || (net->flags & IFF_ALLMULTI))
+               cdc_filter |= USB_CDC_PACKET_TYPE_ALL_MULTICAST;
 
        usb_control_msg(dev->udev,
                        usb_sndctrlpipe(dev->udev, 0),