Message ID | f7e03920-e32d-e49c-9c9e-d7a4473828ee@det.uvigo.gal (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Miguel Rodríguez Pérez <miguel@det.uvigo.gal> writes: > Change the way cdc_ncm_change_mtu hooks into the netdev_ops > structure so that changes into usbnet driver_info operations > can be respected. Without this, is was not possible to hook > into usbnet_set_rx_mode. Please export usbnet_set_rx_mode instead, so that cdc_ncm_netdev_ops can be kept const. Bjørn -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 30/06/18 14:01, Bjørn Mork wrote: > Miguel Rodríguez Pérez <miguel@det.uvigo.gal> writes: > >> Change the way cdc_ncm_change_mtu hooks into the netdev_ops >> structure so that changes into usbnet driver_info operations >> can be respected. Without this, is was not possible to hook >> into usbnet_set_rx_mode. > > Please export usbnet_set_rx_mode instead, so that cdc_ncm_netdev_ops > can be kept const. > I don't see how this would help. From my point of view, the problem is that cdc_ncm driver should not be setting net_device_ops in the first place, as that is usbnet.c job. Sadly there seems to be no way currently for cdc_ncm to be notified of mtu changes. This was the least intrusive way I could think of to respect usbnet's net_device_ops structure while keeping cdc_ncm notified of mtu changes. Without this change, set_rx_mode was not getting called for cdc_ncm even after modifying struct driver_info. > > Bjørn >
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 9e1b74590682..d6b51e2b9495 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -750,16 +750,7 @@ int cdc_ncm_change_mtu(struct net_device *net, int new_mtu) } EXPORT_SYMBOL_GPL(cdc_ncm_change_mtu); -static const struct net_device_ops cdc_ncm_netdev_ops = { - .ndo_open = usbnet_open, - .ndo_stop = usbnet_stop, - .ndo_start_xmit = usbnet_start_xmit, - .ndo_tx_timeout = usbnet_tx_timeout, - .ndo_get_stats64 = usbnet_get_stats64, - .ndo_change_mtu = cdc_ncm_change_mtu, - .ndo_set_mac_address = eth_mac_addr, - .ndo_validate_addr = eth_validate_addr, -}; +static struct net_device_ops cdc_ncm_netdev_ops; int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf,
Change the way cdc_ncm_change_mtu hooks into the netdev_ops structure so that changes into usbnet driver_info operations can be respected. Without this, is was not possible to hook into usbnet_set_rx_mode. Signed-off-by: Miguel Rodríguez Pérez <miguel@det.uvigo.gal> --- drivers/net/usb/cdc_ncm.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) u8 data_altsetting, int drvflags) { @@ -939,6 +930,8 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_ dev->net->sysfs_groups[0] = &cdc_ncm_sysfs_attr_group; /* must handle MTU changes */ + cdc_ncm_netdev_ops = *dev->net->netdev_ops; + cdc_ncm_netdev_ops.ndo_change_mtu = cdc_ncm_change_mtu; dev->net->netdev_ops = &cdc_ncm_netdev_ops; dev->net->max_mtu = cdc_ncm_max_dgram_size(dev) - cdc_ncm_eth_hlen(dev);