quectel_QMI_WWAN: port to linux 6.1 support

This commit is contained in:
coolsnowwolf 2023-02-02 23:55:49 +08:00
parent de25320d7a
commit 1daa71c005
2 changed files with 51 additions and 2 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=qmi_wwan_q
PKG_VERSION:=3.0
PKG_RELEASE:=1
PKG_RELEASE:=2
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/package.mk
@ -17,7 +17,7 @@ include $(INCLUDE_DIR)/package.mk
define KernelPackage/qmi_wwan_q
SUBMENU:=qmiwwan Support
TITLE:=Quectel Linux USB QMI WWAN Driver
DEPENDS:=+kmod-usb-net kmod-usb-wdm
DEPENDS:=+kmod-usb-net +kmod-usb-wdm
FILES:=$(PKG_BUILD_DIR)/qmi_wwan_q.ko
AUTOLOAD:=$(call AutoLoad,81,qmi_wwan_q)
endef

View File

@ -319,7 +319,11 @@ static int bridge_arp_reply(struct net_device *net, struct sk_buff *skb, uint br
reply->ip_summed = CHECKSUM_UNNECESSARY;
reply->pkt_type = PACKET_HOST;
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
netif_rx_ni(reply);
#else
netif_rx(reply);
#endif
}
return 1;
}
@ -383,7 +387,11 @@ static struct sk_buff *bridge_mode_tx_fixup(struct net_device *net, struct sk_bu
__skb_pull(reply, skb_network_offset(reply));
reply->ip_summed = CHECKSUM_UNNECESSARY;
reply->pkt_type = PACKET_HOST;
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
netif_rx_ni(reply);
#else
netif_rx(reply);
#endif
return NULL;
}
#endif
@ -753,12 +761,22 @@ static void rmnet_vnd_update_rx_stats(struct net_device *net,
struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->stats64);
u64_stats_update_begin(&stats64->syncp);
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
stats64->rx_packets += rx_packets;
stats64->rx_bytes += rx_bytes;
#else
u64_stats_add(&stats64->rx_packets, rx_packets);
u64_stats_add(&stats64->rx_bytes, rx_bytes);
#endif
u64_stats_update_end(&stats64->syncp);
#else
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
net->stats.rx_packets += rx_packets;
net->stats.rx_bytes += rx_bytes;
#else
u64_stats_add(&net->stats.rx_packets, rx_packets);
u64_stats_add(&net->stats.rx_bytes, rx_bytes);
#endif
#endif
}
@ -769,12 +787,22 @@ static void rmnet_vnd_update_tx_stats(struct net_device *net,
struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->stats64);
u64_stats_update_begin(&stats64->syncp);
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
stats64->tx_packets += tx_packets;
stats64->tx_bytes += tx_bytes;
#else
u64_stats_add(&stats64->tx_packets, tx_packets);
u64_stats_add(&stats64->tx_bytes, tx_bytes);
#endif
u64_stats_update_end(&stats64->syncp);
#else
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
net->stats.tx_packets += tx_packets;
net->stats.tx_bytes += tx_bytes;
#else
u64_stats_add(&net->stats.tx_packets, tx_packets);
u64_stats_add(&net->tx_bytes, tx_bytes);
#endif
#endif
}
@ -801,16 +829,25 @@ static struct rtnl_link_stats64 *_rmnet_vnd_get_stats64(struct net_device *net,
do {
start = u64_stats_fetch_begin_irq(&stats64->syncp);
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
rx_packets = stats64->rx_packets;
rx_bytes = stats64->rx_bytes;
tx_packets = stats64->tx_packets;
tx_bytes = stats64->tx_bytes;
#else
rx_packets = u64_stats_read(&stats64->rx_packets);
rx_bytes = u64_stats_read(&stats64->rx_bytes);
tx_packets = u64_stats_read(&stats64->tx_packets);
tx_bytes = u64_stats_read(&stats64->tx_bytes);
#endif
} while (u64_stats_fetch_retry_irq(&stats64->syncp, start));
stats->rx_packets += rx_packets;
stats->rx_bytes += rx_bytes;
stats->tx_packets += tx_packets;
stats->tx_bytes += tx_bytes;
}
return stats;
@ -1258,7 +1295,11 @@ static int qmap_register_device(sQmiWwanQmap * pDev, u8 offset_id)
priv->dev = pDev->mpNetDev;
priv->qmap_version = pDev->qmap_version;
priv->mux_id = QUECTEL_QMAP_MUX_ID + offset_id;
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0)
memcpy (qmap_net->dev_addr, real_dev->dev_addr, ETH_ALEN);
#else
eth_hw_addr_set (real_dev, qmap_net->dev_addr);
#endif
#ifdef QUECTEL_BRIDGE_MODE
priv->bridge_mode = !!(pDev->bridge_mode & BIT(offset_id));
@ -2025,8 +2066,16 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
/* make MAC addr easily distinguishable from an IP header */
if (possibly_iphdr(dev->net->dev_addr)) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
dev->net->dev_addr[0] |= 0x02; /* set local assignment bit */
dev->net->dev_addr[0] &= 0xbf; /* clear "IP" bit */
#else
u8 addr = dev->net->dev_addr[0];
addr |= 0x02; /* set local assignment bit */
addr &= 0xbf; /* clear "IP" bit */
dev_addr_mod(dev->net, 0, &addr, 1);
#endif
}
if (!_usbnet_get_stats64)
_usbnet_get_stats64 = dev->net->netdev_ops->ndo_get_stats64;