From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Bj=C3=B8rn_Mork?= Subject: Re: [PATCH 2/2] cdc_ncm: Admit multicast traffic Date: Sat, 30 Jun 2018 14:17:31 +0200 Message-ID: <87r2kozcx0.fsf@miraculix.mork.no> References: <69bbee1a-9a88-eabe-554f-fbc59e7fde79@det.uvigo.gal> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org To: Miguel =?utf-8?Q?Rodr=C3=ADguez_P=C3=A9rez?= Return-path: Received: from canardo.mork.no ([148.122.252.1]:47011 "EHLO canardo.mork.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936875AbeF3MRf (ORCPT ); Sat, 30 Jun 2018 08:17:35 -0400 In-Reply-To: ("Miguel =?utf-8?Q?Rodr=C3=ADguez_P=C3=A9rez=22's?= message of "Sat, 30 Jun 2018 13:26:57 +0200") Sender: netdev-owner@vger.kernel.org List-ID: Miguel Rodr=C3=ADguez P=C3=A9rez writes: > +static void cdc_ncm_update_filter(struct usbnet *dev) > +{ > + struct cdc_ncm_ctx *ctx =3D (struct cdc_ncm_ctx *)dev->data[0]; > + u8 iface_no =3D ctx->control->cur_altsetting->desc.bInterfaceNumber; > + struct net_device *net =3D dev->net; Why not change usbnet_cdc_update_filter to get the interface number from dev->intf instead? Then you can export it and reuse it here instead of creating a copy. And it will also work for any other usbnet minidriver. I.e. change this: static void usbnet_cdc_update_filter(struct usbnet *dev) { struct cdc_state *info =3D (void *) &dev->data; struct usb_interface *intf =3D info->control; into: static void usbnet_cdc_update_filter(struct usbnet *dev) { struct usb_interface *intf =3D dev->intf; or simply use dev->intf to deref directly into an interface number, like you do in your version. The local 'intf' variable doesn't do much good here. > + > + u16 cdc_filter =3D USB_CDC_PACKET_TYPE_DIRECTED > + | USB_CDC_PACKET_TYPE_BROADCAST; > + > + /* 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 |=3D USB_CDC_PACKET_TYPE_PROMISCUOUS; > + if (!netdev_mc_empty(net) || (net->flags & IFF_ALLMULTI)) > + cdc_filter |=3D USB_CDC_PACKET_TYPE_ALL_MULTICAST; > + > + usbnet_write_cmd(dev, This is a nice change. It should be probably done in usbnet_cdc_update_filter in any case. Unless there is some reason it doesn't alreay use usbnet_write_cmd? > + USB_CDC_SET_ETHERNET_PACKET_FILTER, > + USB_TYPE_CLASS | USB_DIR_OUT | USB_RECIP_INTERFACE, > + cdc_filter, > + iface_no, > + NULL, > + 0); > +} > + > static const struct ethtool_ops cdc_ncm_ethtool_ops =3D { > .get_link =3D usbnet_get_link, > .nway_reset =3D usbnet_nway_reset, > @@ -1652,6 +1679,7 @@ static const struct driver_info cdc_ncm_info =3D { > .status =3D cdc_ncm_status, > .rx_fixup =3D cdc_ncm_rx_fixup, > .tx_fixup =3D cdc_ncm_tx_fixup, > + .set_rx_mode =3D cdc_ncm_update_filter, > }; > > /* Same as cdc_ncm_info, but with FLAG_WWAN */ As the comment indicates: There are more 'struct driver_info' variants here. Please add .set_rx_mode to all of them, unless you have a reason not to? Bj=C3=B8rn