fix: qmi_wwan_* for higher kernel versions

Signed-off-by: sfwtw <wtw@cr.cx>
This commit is contained in:
sfwtw 2025-03-09 22:54:29 +08:00
parent 729bebe78f
commit a4619fa1ec
2 changed files with 31 additions and 23 deletions

View File

@ -688,8 +688,7 @@ static void rmnet_vnd_update_tx_stats(struct net_device *net,
#endif #endif
} }
#if defined(MHI_NETDEV_STATUS64) static struct rtnl_link_stats64 * _rmnet_vnd_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats)
static struct rtnl_link_stats64 *_rmnet_vnd_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats)
{ {
struct qmap_priv *dev = netdev_priv(net); struct qmap_priv *dev = netdev_priv(net);
unsigned int start; unsigned int start;
@ -708,23 +707,31 @@ static struct rtnl_link_stats64 *_rmnet_vnd_get_stats64(struct net_device *net,
struct pcpu_sw_netstats *stats64; struct pcpu_sw_netstats *stats64;
u64 rx_packets, rx_bytes; u64 rx_packets, rx_bytes;
u64 tx_packets, tx_bytes; u64 tx_packets, tx_bytes;
stats64 = per_cpu_ptr(dev->stats64, cpu); stats64 = per_cpu_ptr(dev->stats64, cpu);
do { do {
start = u64_stats_fetch_begin_irq(&stats64->syncp); #if LINUX_VERSION_CODE < KERNEL_VERSION(6,6,0)
start = u64_stats_fetch_begin_irq(&stats64->syncp);
#else
start = u64_stats_fetch_begin(&stats64->syncp);
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0) #if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
rx_packets = stats64->rx_packets; rx_packets = stats64->rx_packets;
rx_bytes = stats64->rx_bytes; rx_bytes = stats64->rx_bytes;
tx_packets = stats64->tx_packets; tx_packets = stats64->tx_packets;
tx_bytes = stats64->tx_bytes; tx_bytes = stats64->tx_bytes;
#else #else
rx_packets = u64_stats_read(&stats64->rx_packets); rx_packets = u64_stats_read(&stats64->rx_packets);
rx_bytes = u64_stats_read(&stats64->rx_bytes); rx_bytes = u64_stats_read(&stats64->rx_bytes);
tx_packets = u64_stats_read(&stats64->tx_packets); tx_packets = u64_stats_read(&stats64->tx_packets);
tx_bytes = u64_stats_read(&stats64->tx_bytes); tx_bytes = u64_stats_read(&stats64->tx_bytes);
#endif #endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,6,0)
} while (u64_stats_fetch_retry_irq(&stats64->syncp, start)); } while (u64_stats_fetch_retry_irq(&stats64->syncp, start));
#else
} while (u64_stats_fetch_retry(&stats64->syncp, start));
#endif
stats->rx_packets += rx_packets; stats->rx_packets += rx_packets;
stats->rx_bytes += rx_bytes; stats->rx_bytes += rx_bytes;
@ -735,6 +742,7 @@ static struct rtnl_link_stats64 *_rmnet_vnd_get_stats64(struct net_device *net,
return stats; return stats;
} }
#if defined(MHI_NETDEV_STATUS64)
#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,10,0 )) //bc1f44709cf27fb2a5766cadafe7e2ad5e9cb221 #if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,10,0 )) //bc1f44709cf27fb2a5766cadafe7e2ad5e9cb221
static void rmnet_vnd_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats) { static void rmnet_vnd_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats) {
_rmnet_vnd_get_stats64(net, stats); _rmnet_vnd_get_stats64(net, stats);
@ -1187,7 +1195,7 @@ static int qmap_register_device(sQmiWwanQmap * pDev, u8 offset_id)
priv->mux_id = FIBOCOM_QMAP_MUX_ID + offset_id; priv->mux_id = FIBOCOM_QMAP_MUX_ID + offset_id;
sprintf(qmap_net->name, "%s.%d", real_dev->name, offset_id + 1); sprintf(qmap_net->name, "%s.%d", real_dev->name, offset_id + 1);
qmap_net->netdev_ops = &qmap_netdev_ops; qmap_net->netdev_ops = &qmap_netdev_ops;
memcpy (qmap_net->dev_addr, real_dev->dev_addr, ETH_ALEN); ether_addr_copy(qmap_net->dev_addr, real_dev->dev_addr);
#ifdef FIBOCOM_BRIDGE_MODE #ifdef FIBOCOM_BRIDGE_MODE
priv->bridge_mode = !!(pDev->bridge_mode & BIT(offset_id)); priv->bridge_mode = !!(pDev->bridge_mode & BIT(offset_id));

View File

@ -828,35 +828,35 @@ static struct rtnl_link_stats64 *_rmnet_vnd_get_stats64(struct net_device *net,
#if (LINUX_VERSION_CODE < KERNEL_VERSION( 6,1,0 )) #if (LINUX_VERSION_CODE < KERNEL_VERSION( 6,1,0 ))
u64 rx_packets, rx_bytes; u64 rx_packets, rx_bytes;
u64 tx_packets, tx_bytes; u64 tx_packets, tx_bytes;
#else
u64_stats_t rx_packets, rx_bytes;
u64_stats_t tx_packets, tx_bytes;
#endif
stats64 = per_cpu_ptr(dev->stats64, cpu); stats64 = per_cpu_ptr(dev->stats64, cpu);
do { do {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 6,6,0 ))
start = u64_stats_fetch_begin(&stats64->syncp);
#else
start = u64_stats_fetch_begin_irq(&stats64->syncp); start = u64_stats_fetch_begin_irq(&stats64->syncp);
#endif
rx_packets = stats64->rx_packets; rx_packets = stats64->rx_packets;
rx_bytes = stats64->rx_bytes; rx_bytes = stats64->rx_bytes;
tx_packets = stats64->tx_packets; tx_packets = stats64->tx_packets;
tx_bytes = stats64->tx_bytes; tx_bytes = stats64->tx_bytes;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 6,6,0 ))
} while (u64_stats_fetch_retry(&stats64->syncp, start));
#else
} while (u64_stats_fetch_retry_irq(&stats64->syncp, start)); } while (u64_stats_fetch_retry_irq(&stats64->syncp, start));
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION( 6,1,0 ))
stats->rx_packets += rx_packets; stats->rx_packets += rx_packets;
stats->rx_bytes += rx_bytes; stats->rx_bytes += rx_bytes;
stats->tx_packets += tx_packets; stats->tx_packets += tx_packets;
stats->tx_bytes += tx_bytes; stats->tx_bytes += tx_bytes;
#else #else
u64_stats_t rx_packets, rx_bytes;
u64_stats_t tx_packets, tx_bytes;
stats64 = per_cpu_ptr(dev->stats64, cpu);
do {
start = u64_stats_fetch_begin_irq(&stats64->syncp);
rx_packets = stats64->rx_packets;
rx_bytes = stats64->rx_bytes;
tx_packets = stats64->tx_packets;
tx_bytes = stats64->tx_bytes;
} while (u64_stats_fetch_retry_irq(&stats64->syncp, start));
stats->rx_packets += u64_stats_read(&rx_packets); stats->rx_packets += u64_stats_read(&rx_packets);
stats->rx_bytes += u64_stats_read(&rx_bytes); stats->rx_bytes += u64_stats_read(&rx_bytes);
stats->tx_packets += u64_stats_read(&tx_packets); stats->tx_packets += u64_stats_read(&tx_packets);