diff --git a/network/src/net_device_adapter.c b/network/src/net_device_adapter.c old mode 100644 new mode 100755 index 4b8ede6e1f6639ac943e0f74e1f79efcd5715793..256a7798d734b9e7ba9cdde6e5bfac93def7a6aa --- a/network/src/net_device_adapter.c +++ b/network/src/net_device_adapter.c @@ -67,6 +67,42 @@ static netdev_tx_t NetDevXmit(struct sk_buff *skb, struct net_device *dev) return NETDEV_TX_OK; } +static struct net_device_stats* NetDevGetStats(struct net_device *dev) +{ + struct FullNetDevicePriv *priv = NULL; + struct NetDevice *netDev = NULL; + struct NetDeviceInterFace *netDevIf = NULL; + struct NetDevStats *devStat; + static struct net_device_stats netStats; + + memset(&netStats, 0, sizeof(struct net_device_stats)); + + priv = (struct FullNetDevicePriv *)netdev_priv(dev); + if (priv == NULL || priv->dev == NULL || priv->impl == NULL) { + HDF_LOGE("%s fail : priv NULL!", __func__); + return HDF_ERR_INVALID_PARAM; + } + + netDev = priv->impl->netDevice; + netDevIf = netDev->netDeviceIf; + if (netDevIf != NULL && netDevIf->getStats != NULL) { + devStat = netDevIf->getStats(netDev); + if (devStat != NULL) { + netStats.rx_packets = devStat->rxPackets; + netStats.tx_packets = devStat->txPackets; + netStats.rx_bytes = devStat->rxBytes; + netStats.tx_bytes = devStat->txBytes; + netStats.rx_errors = devStat->rxErrors; + netStats.tx_errors = devStat->txErrors; + netStats.rx_dropped = devStat->rxDropped; + netStats.tx_dropped = devStat->txDropped; + } + } else { + HDF_LOGE("%s fail : netdevIf = null or getStats = null!", __func__); + } + return &netStats; +} + static int NetDevChangeMtu(struct net_device *dev, int mtu) { if (mtu > WLAN_MAX_MTU || mtu < WLAN_MIN_MTU || dev == NULL) { @@ -100,6 +136,7 @@ static int NetDevStop(struct net_device *dev) static struct net_device_ops g_netDeviceOps = { .ndo_start_xmit = NetDevXmit, .ndo_change_mtu = NetDevChangeMtu, + .ndo_get_stats = NetDevGetStats, .ndo_open = NetDevOpen, .ndo_stop = NetDevStop };