From: "Bjørn Mork" <bjorn@mork.no>
To: "Miguel Rodríguez Pérez" <miguel@det.uvigo.gal>
Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH 2/2] cdc_ncm: Admit multicast traffic
Date: Sat, 30 Jun 2018 14:17:31 +0200 [thread overview]
Message-ID: <87r2kozcx0.fsf@miraculix.mork.no> (raw)
In-Reply-To: <ac0097e4-0c3a-1a06-12f4-8cb7fcf07eb1@det.uvigo.gal> ("Miguel Rodríguez Pérez"'s message of "Sat, 30 Jun 2018 13:26:57 +0200")
Miguel Rodríguez Pérez <miguel@det.uvigo.gal> writes:
> +static void cdc_ncm_update_filter(struct usbnet *dev)
> +{
> + struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
> + u8 iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
> + struct net_device *net = 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 = (void *) &dev->data;
struct usb_interface *intf = info->control;
into:
static void usbnet_cdc_update_filter(struct usbnet *dev)
{
struct usb_interface *intf = 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 = 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 |= USB_CDC_PACKET_TYPE_PROMISCUOUS;
> + if (!netdev_mc_empty(net) || (net->flags & IFF_ALLMULTI))
> + cdc_filter |= 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 = {
> .get_link = usbnet_get_link,
> .nway_reset = usbnet_nway_reset,
> @@ -1652,6 +1679,7 @@ static const struct driver_info cdc_ncm_info = {
> .status = cdc_ncm_status,
> .rx_fixup = cdc_ncm_rx_fixup,
> .tx_fixup = cdc_ncm_tx_fixup,
> + .set_rx_mode = 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ørn
next prev parent reply other threads:[~2018-06-30 12:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-30 11:21 [PATCH 0/2 ] cdc_ncm: Handle multicast Ethernet traffic Miguel Rodríguez Pérez
2018-06-30 11:26 ` [PATCH 1/2] cdc_ncm: Hook into usbnet_change_mtu respecting usbnet,driver_info Miguel Rodríguez Pérez
2018-06-30 12:01 ` Bjørn Mork
2018-06-30 14:22 ` Miguel Rodríguez Pérez
2018-06-30 11:26 ` [PATCH 2/2] cdc_ncm: Admit multicast traffic Miguel Rodríguez Pérez
2018-06-30 12:17 ` Bjørn Mork [this message]
2018-06-30 14:22 ` Miguel Rodríguez Pérez
2018-06-30 12:22 ` [PATCH 0/2 ] cdc_ncm: Handle multicast Ethernet traffic Bjørn Mork
2018-06-30 13:43 ` Miguel Rodríguez Pérez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r2kozcx0.fsf@miraculix.mork.no \
--to=bjorn@mork.no \
--cc=linux-usb@vger.kernel.org \
--cc=miguel@det.uvigo.gal \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).