aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/backport-5.10/881-v5.19-rndis_host-enable-the-bogus-MAC-fixup-for-ZTE-device.patch
diff options
context:
space:
mode:
authorLech Perczak <lech.perczak@gmail.com>2022-04-01 22:05:08 +0200
committerHauke Mehrtens <hauke@hauke-m.de>2022-04-17 21:31:02 +0200
commit19c65d36d776b4f9e2a19f0f487fc9bc8fcc2858 (patch)
treef7896af96d5472f5858ecc204a615a39d91fac6f /target/linux/generic/backport-5.10/881-v5.19-rndis_host-enable-the-bogus-MAC-fixup-for-ZTE-device.patch
parent835454661d69aa8a031e320602ad359381812c98 (diff)
downloadupstream-19c65d36d776b4f9e2a19f0f487fc9bc8fcc2858.tar.gz
upstream-19c65d36d776b4f9e2a19f0f487fc9bc8fcc2858.tar.bz2
upstream-19c65d36d776b4f9e2a19f0f487fc9bc8fcc2858.zip
kernel: backport ZTE RNDIS bogus MAC address fix
This is required to support built-in modem of ZTE MF286R, in addition to other external modems, such as MF831, MF910, MF920, which refuse to reconfigure their remote MAC address, even if "locally administered" bit is set, leading to dropped traffic towards the host. Add a workaround for that issue already present in cdc_ether to rndis_host driver as well. Signed-off-by: Lech Perczak <lech.perczak@gmail.com> (cherry picked from commit c99013e242682a71051619806f9cc4f4e51a58fa)
Diffstat (limited to 'target/linux/generic/backport-5.10/881-v5.19-rndis_host-enable-the-bogus-MAC-fixup-for-ZTE-device.patch')
-rw-r--r--target/linux/generic/backport-5.10/881-v5.19-rndis_host-enable-the-bogus-MAC-fixup-for-ZTE-device.patch118
1 files changed, 118 insertions, 0 deletions
diff --git a/target/linux/generic/backport-5.10/881-v5.19-rndis_host-enable-the-bogus-MAC-fixup-for-ZTE-device.patch b/target/linux/generic/backport-5.10/881-v5.19-rndis_host-enable-the-bogus-MAC-fixup-for-ZTE-device.patch
new file mode 100644
index 0000000000..99f0146e50
--- /dev/null
+++ b/target/linux/generic/backport-5.10/881-v5.19-rndis_host-enable-the-bogus-MAC-fixup-for-ZTE-device.patch
@@ -0,0 +1,118 @@
+From 69a9efb689b43fedf5f19431f1889aa6b8d35d55 Mon Sep 17 00:00:00 2001
+From: Lech Perczak <lech.perczak@gmail.com>
+Date: Fri, 1 Apr 2022 22:04:01 +0200
+Subject: [PATCH 2/3] rndis_host: enable the bogus MAC fixup for ZTE devices
+ from cdc_ether
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Certain ZTE modems, namely: MF823. MF831, MF910, built-in modem from
+MF286R, expose both CDC-ECM and RNDIS network interfaces.
+They have a trait of ignoring the locally-administered MAC address
+configured on the interface both in CDC-ECM and RNDIS part,
+and this leads to dropping of incoming traffic by the host.
+However, the workaround was only present in CDC-ECM, and MF286R
+explicitly requires it in RNDIS mode.
+
+Re-use the workaround in rndis_host as well, to fix operation of MF286R
+module, some versions of which expose only the RNDIS interface. Do so by
+introducing new flag, RNDIS_DRIVER_DATA_DST_MAC_FIXUP, and testing for it
+in rndis_rx_fixup. This is required, as RNDIS uses frame batching, and all
+of the packets inside the batch need the fixup. This might introduce a
+performance penalty, because test is done for every returned Ethernet
+frame.
+
+Apply the workaround to both "flavors" of RNDIS interfaces, as older ZTE
+modems, like MF823 found in the wild, report the USB_CLASS_COMM class
+interfaces, while MF286R reports USB_CLASS_WIRELESS_CONTROLLER.
+
+Suggested-by: Bjørn Mork <bjorn@mork.no>
+Cc: Kristian Evensen <kristian.evensen@gmail.com>
+Cc: Oliver Neukum <oliver@neukum.org>
+Signed-off-by: Lech Perczak <lech.perczak@gmail.com>
+---
+ drivers/net/usb/rndis_host.c | 32 ++++++++++++++++++++++++++++++++
+ include/linux/usb/rndis_host.h | 1 +
+ 2 files changed, 33 insertions(+)
+
+--- a/drivers/net/usb/rndis_host.c
++++ b/drivers/net/usb/rndis_host.c
+@@ -485,10 +485,14 @@ EXPORT_SYMBOL_GPL(rndis_unbind);
+ */
+ int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
+ {
++ bool dst_mac_fixup;
++
+ /* This check is no longer done by usbnet */
+ if (skb->len < dev->net->hard_header_len)
+ return 0;
+
++ dst_mac_fixup = !!(dev->driver_info->data & RNDIS_DRIVER_DATA_DST_MAC_FIXUP);
++
+ /* peripheral may have batched packets to us... */
+ while (likely(skb->len)) {
+ struct rndis_data_hdr *hdr = (void *)skb->data;
+@@ -523,10 +527,17 @@ int rndis_rx_fixup(struct usbnet *dev, s
+ break;
+ skb_pull(skb, msg_len - sizeof *hdr);
+ skb_trim(skb2, data_len);
++
++ if (unlikely(dst_mac_fixup))
++ usbnet_cdc_zte_rx_fixup(dev, skb2);
++
+ usbnet_skb_return(dev, skb2);
+ }
+
+ /* caller will usbnet_skb_return the remaining packet */
++ if (unlikely(dst_mac_fixup))
++ usbnet_cdc_zte_rx_fixup(dev, skb);
++
+ return 1;
+ }
+ EXPORT_SYMBOL_GPL(rndis_rx_fixup);
+@@ -600,6 +611,17 @@ static const struct driver_info rndis_po
+ .tx_fixup = rndis_tx_fixup,
+ };
+
++static const struct driver_info zte_rndis_info = {
++ .description = "ZTE RNDIS device",
++ .flags = FLAG_ETHER | FLAG_POINTTOPOINT | FLAG_FRAMING_RN | FLAG_NO_SETINT,
++ .data = RNDIS_DRIVER_DATA_DST_MAC_FIXUP,
++ .bind = rndis_bind,
++ .unbind = rndis_unbind,
++ .status = rndis_status,
++ .rx_fixup = rndis_rx_fixup,
++ .tx_fixup = rndis_tx_fixup,
++};
++
+ /*-------------------------------------------------------------------------*/
+
+ static const struct usb_device_id products [] = {
+@@ -609,6 +631,16 @@ static const struct usb_device_id produc
+ USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
+ .driver_info = (unsigned long) &rndis_poll_status_info,
+ }, {
++ /* ZTE WWAN modules */
++ USB_VENDOR_AND_INTERFACE_INFO(0x19d2,
++ USB_CLASS_WIRELESS_CONTROLLER, 1, 3),
++ .driver_info = (unsigned long)&zte_rndis_info,
++}, {
++ /* ZTE WWAN modules, ACM flavour */
++ USB_VENDOR_AND_INTERFACE_INFO(0x19d2,
++ USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
++ .driver_info = (unsigned long)&zte_rndis_info,
++}, {
+ /* Hytera Communications DMR radios' "Radio to PC Network" */
+ USB_VENDOR_AND_INTERFACE_INFO(0x238b,
+ USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
+--- a/include/linux/usb/rndis_host.h
++++ b/include/linux/usb/rndis_host.h
+@@ -197,6 +197,7 @@ struct rndis_keepalive_c { /* IN (option
+
+ /* Flags for driver_info::data */
+ #define RNDIS_DRIVER_DATA_POLL_STATUS 1 /* poll status before control */
++#define RNDIS_DRIVER_DATA_DST_MAC_FIXUP 2 /* device ignores configured MAC address */
+
+ extern void rndis_status(struct usbnet *dev, struct urb *urb);
+ extern int