From patchwork Wed Jul 15 01:23:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Wxcaf=C3=A9?= X-Patchwork-Id: 11663963 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C90D4913 for ; Wed, 15 Jul 2020 01:23:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA4FE20758 for ; Wed, 15 Jul 2020 01:23:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728006AbgGOBXO (ORCPT ); Tue, 14 Jul 2020 21:23:14 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:39175 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725977AbgGOBXO (ORCPT ); Tue, 14 Jul 2020 21:23:14 -0400 Received: from cwh (fob.gandi.net [217.70.181.1]) (Authenticated sender: wxcafe@wxcafe.net) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 3C3A220004; Wed, 15 Jul 2020 01:23:11 +0000 (UTC) Message-ID: <8ac19ec98239400a1e4870f7e322b8904673a137.camel@wxcafe.net> Subject: [PATCH 1/4] cdc_ether: use dev->intf to get interface information From: =?iso-8859-1?q?Wxcaf=E9?= To: linux-usb@vger.kernel.org Cc: Miguel =?iso-8859-1?q?Rodr=EDguez_P=E9rez?= , oliver@neukum.org, netdev@vger.kernel.org Date: Tue, 14 Jul 2020 21:23:07 -0400 User-Agent: Evolution 3.36.3 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org usbnet_cdc_update_filter was getting the interface number from the usb_interface struct in cdc_state->control. However, cdc_ncm does not initialize that structure in its bind function, but uses cdc_ncm_cts instead. Getting intf directly from struct usbnet solves the problem. Signed-off-by: Miguel Rodríguez Pérez --- drivers/net/usb/cdc_ether.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index a657943c9f01..2afe258e3648 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c @@ -65,8 +65,6 @@ static const u8 mbm_guid[16] = { 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_DIRECTED @@ -86,7 +84,7 @@ static void usbnet_cdc_update_filter(struct usbnet *dev) USB_CDC_SET_ETHERNET_PACKET_FILTER, USB_TYPE_CLASS | USB_RECIP_INTERFACE, cdc_filter, - intf->cur_altsetting->desc.bInterfaceNumber, + dev->intf->cur_altsetting->desc.bInterfaceNumber, NULL, 0, USB_CTRL_SET_TIMEOUT From patchwork Wed Jul 15 01:25:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Wxcaf=C3=A9?= X-Patchwork-Id: 11663965 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 03DE413B6 for ; Wed, 15 Jul 2020 01:25:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA19020663 for ; Wed, 15 Jul 2020 01:25:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727024AbgGOBZT (ORCPT ); Tue, 14 Jul 2020 21:25:19 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:39929 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726356AbgGOBZT (ORCPT ); Tue, 14 Jul 2020 21:25:19 -0400 Received: from cwh (fob.gandi.net [217.70.181.1]) (Authenticated sender: wxcafe@wxcafe.net) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id CFFD040007; Wed, 15 Jul 2020 01:25:16 +0000 (UTC) Message-ID: <0202c34b1b335d8d8fcdd5406f5e8178b4c198ec.camel@wxcafe.net> Subject: [PATCH 2/4] cdc_ether: use dev->intf to get interface information From: =?iso-8859-1?q?Wxcaf=E9?= To: linux-usb@vger.kernel.org Cc: Miguel =?iso-8859-1?q?Rodr=EDguez_P=E9rez?= , oliver@neukum.org, netdev@vger.kernel.org Date: Tue, 14 Jul 2020 21:25:13 -0400 User-Agent: Evolution 3.36.3 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This makes the function available to other drivers, like cdn_ncm. Signed-off-by: Miguel Rodríguez Pérez --- drivers/net/usb/cdc_ether.c | 3 ++- include/linux/usb/usbnet.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 2afe258e3648..8c1d61c2cbac 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c @@ -63,7 +63,7 @@ static const u8 mbm_guid[16] = { 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a, }; -static void usbnet_cdc_update_filter(struct usbnet *dev) +void usbnet_cdc_update_filter(struct usbnet *dev) { struct net_device *net = dev->net; @@ -90,6 +90,7 @@ static void usbnet_cdc_update_filter(struct usbnet *dev) USB_CTRL_SET_TIMEOUT ); } +EXPORT_SYMBOL_GPL(usbnet_cdc_update_filter); /* probes control interface, claims data interface, collects the bulk * endpoints, activates data interface (if needed), maybe sets MTU. diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h index b0bff3083278..33e7803b85af 100644 --- a/include/linux/usb/usbnet.h +++ b/include/linux/usb/usbnet.h @@ -286,4 +286,5 @@ extern void usbnet_update_max_qlen(struct usbnet *dev); extern void usbnet_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats); +extern void usbnet_cdc_update_filter(struct usbnet *); #endif /* __LINUX_USB_USBNET_H */ From patchwork Wed Jul 15 01:26:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Wxcaf=C3=A9?= X-Patchwork-Id: 11663967 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B296A913 for ; Wed, 15 Jul 2020 01:26:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99A532072D for ; Wed, 15 Jul 2020 01:26:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726965AbgGOB07 (ORCPT ); Tue, 14 Jul 2020 21:26:59 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:55091 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726759AbgGOB06 (ORCPT ); Tue, 14 Jul 2020 21:26:58 -0400 Received: from cwh (fob.gandi.net [217.70.181.1]) (Authenticated sender: wxcafe@wxcafe.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 3D05EE0003; Wed, 15 Jul 2020 01:26:56 +0000 (UTC) Message-ID: Subject: [PATCH 3/4] cdc_ncm: replace the way cdc_ncm hooks into usbnet_change_mtu From: =?iso-8859-1?q?Wxcaf=E9?= To: linux-usb@vger.kernel.org Cc: Miguel =?iso-8859-1?q?Rodr=EDguez_P=E9rez?= , oliver@neukum.org, netdev@vger.kernel.org Date: Tue, 14 Jul 2020 21:26:53 -0400 User-Agent: Evolution 3.36.3 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Previously cdc_ncm overwrited netdev_ops used by usbnet thus preventing hooking into set_rx_mode. This patch preserves usbnet hooks into netdev_ops, and add an additional one for change_mtu needed by cdc_ncm. Signed-off-by: Miguel Rodríguez Pérez --- drivers/net/usb/cdc_ncm.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 8929669b5e6d..2abaf5f8b23b 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -787,16 +787,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, u8 data_altsetting, int drvflags) { @@ -953,6 +944,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); From patchwork Wed Jul 15 01:28:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Wxcaf=C3=A9?= X-Patchwork-Id: 11663969 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8844613B6 for ; Wed, 15 Jul 2020 01:28:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79B2920663 for ; Wed, 15 Jul 2020 01:28:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727819AbgGOB2I (ORCPT ); Tue, 14 Jul 2020 21:28:08 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:50963 "EHLO relay9-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727798AbgGOB2I (ORCPT ); Tue, 14 Jul 2020 21:28:08 -0400 Received: from cwh (fob.gandi.net [217.70.181.1]) (Authenticated sender: wxcafe@wxcafe.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id A17A8FF806; Wed, 15 Jul 2020 01:28:05 +0000 (UTC) Message-ID: <528220d4c2ab1712c10d86c90eea328ad3446659.camel@wxcafe.net> Subject: [PATCH 4/4] cdc_ncm: hook into set_rx_mode to admit multicast traffic From: =?iso-8859-1?q?Wxcaf=E9?= To: linux-usb@vger.kernel.org Cc: Miguel =?iso-8859-1?q?Rodr=EDguez_P=E9rez?= , oliver@neukum.org, netdev@vger.kernel.org Date: Tue, 14 Jul 2020 21:28:02 -0400 User-Agent: Evolution 3.36.3 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org We set set_rx_mode to usbnet_cdc_update_filter provided by cdc_ether that simply admits all multicast traffic if there is more than one multicast filter configured. Signed-off-by: Miguel Rodríguez Pérez --- drivers/net/usb/cdc_ncm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 2abaf5f8b23b..c58aae2c90d1 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -1888,6 +1888,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 = usbnet_cdc_update_filter, }; /* Same as cdc_ncm_info, but with FLAG_WWAN */ @@ -1901,6 +1902,7 @@ static const struct driver_info wwan_info = { .status = cdc_ncm_status, .rx_fixup = cdc_ncm_rx_fixup, .tx_fixup = cdc_ncm_tx_fixup, + .set_rx_mode = usbnet_cdc_update_filter, }; /* Same as wwan_info, but with FLAG_NOARP */ @@ -1914,6 +1916,7 @@ static const struct driver_info wwan_noarp_info = { .status = cdc_ncm_status, .rx_fixup = cdc_ncm_rx_fixup, .tx_fixup = cdc_ncm_tx_fixup, + .set_rx_mode = usbnet_cdc_update_filter, }; static const struct usb_device_id cdc_devs[] = {