Gilles Chanteperdrix wrote:
Jan Kiszka wrote:
Gilles Chanteperdrix wrote:
Jens Köhler wrote:
Hello all,
I am using the rt_8139too.koo network driver. Is there a possibility to get
a statistic about received, sent packets and errors?
Hi,
In case it could be for interest to anyone, here is a patch which adds
supports for rtnet per-device statistics, and make them accessible
through rtifconfig.
Note that to make these statistics work, you will have to write a
per-driver callback, but for most drivers the callback is already there,
you only have to uncomment it.
Note that this patch was extracted from a bunch of other stuff, so,
there may be some things missing, if it happens and this patch is of
some interest to you, let me know.
This is definitely an interesting patch, and I would welcome (ie. merge)
this framework + potential driver patches.
Ok. I will send the drivers patches, as I said maintaining the stats is
already done in most drivers what need to be done is simply to uncomment
or implement the function which returns the pointer to the statistics
structure, so, the job should not be to hard.
Here comes the drivers patch. Only e1000 and rt_loopback were left aside
since they do not do any accounting.
--
Gilles.
diff -x '*~' -Naurdp
rtnet-0.9.9-stats/drivers/experimental/rt2500/rt_rt2x00core.c
rtnet-0.9.9-stats-drivers/drivers/experimental/rt2500/rt_rt2x00core.c
--- rtnet-0.9.9-stats/drivers/experimental/rt2500/rt_rt2x00core.c
2006-07-30 15:22:49.000000000 +0200
+++ rtnet-0.9.9-stats-drivers/drivers/experimental/rt2500/rt_rt2x00core.c
2008-06-24 11:27:06.000000000 +0200
@@ -316,6 +316,13 @@ static int rt2x00_close (struct rtnet_de
return 0;
}
+static struct net_device_stats *rt2x00_get_stats(struct rtnet_device *rtdev)
+{
+ struct rtwlan_device * rtwlan_dev = rtnetdev_priv(rtnet_dev);
+ struct _rt2x00_core * core = rtwlan_priv(rtwlan_dev);
+
+ return &core->rtwlan_dev->stats;
+}
/*
* Initialization handlers.
@@ -398,6 +405,7 @@ struct rtnet_device * rt2x00_core_probe(
rtnet_dev->stop = &rt2x00_close;
rtnet_dev->do_ioctl = &rt2x00_ioctl;
rtnet_dev->hard_header = &rt_eth_header;
+ rtnet_dev->get_stats = &rt2x00_get_stats;
if ((err = rt_register_rtnetdev(rtnet_dev)) != 0) {
rtdev_free(rtnet_dev);
diff -x '*~' -Naurdp rtnet-0.9.9-stats/drivers/experimental/rt_3c59x.c
rtnet-0.9.9-stats-drivers/drivers/experimental/rt_3c59x.c
--- rtnet-0.9.9-stats/drivers/experimental/rt_3c59x.c 2006-11-26
16:57:32.000000000 +0100
+++ rtnet-0.9.9-stats-drivers/drivers/experimental/rt_3c59x.c 2008-06-24
11:46:56.000000000 +0200
@@ -859,10 +859,8 @@ static int boomerang_interrupt(rtdm_irq_
static int vortex_close(struct rtnet_device *rtdev);
static void dump_tx_ring(struct rtnet_device *rtdev);
-// *** RTnet ***
-//static void update_stats(long ioaddr, struct net_device *dev);
-//static struct net_device_stats *vortex_get_stats(struct net_device *dev);
-// *** RTnet ***
+static void update_stats(long ioaddr, struct rtnet_device *dev);
+static struct net_device_stats *vortex_get_stats(struct rtnet_device *rtdev);
static void set_rx_mode(struct rtnet_device *rtdev);
@@ -1397,6 +1395,7 @@ static int __devinit vortex_probe1(struc
} else {
rtdev->hard_start_xmit = vortex_start_xmit;
}
+ rtdev->get_stats = vortex_get_stats;
if (print_info) {
printk(KERN_INFO "%s: scatter/gather %sabled. h/w checksums
%sabled\n",
@@ -3023,20 +3022,18 @@ dump_tx_ring(struct rtnet_device *rtdev)
}
}
-#if 0
-static struct net_device_stats *vortex_get_stats(struct net_device *dev)
+static struct net_device_stats *vortex_get_stats(struct rtnet_device *rtdev)
{
- struct vortex_private *vp = (struct vortex_private *)dev->priv;
- unsigned long flags;
+ struct vortex_private *vp = (struct vortex_private *)rtdev->priv;
+ rtdm_lockctx_t flags;
- if (netif_device_present(dev)) { /* AKPM: Used to be
netif_running */
- spin_lock_irqsave (&vp->lock, flags);
+ if (rtnetif_device_present(dev)) { /* AKPM: Used to be
netif_running */
+ rtdm_lock_get_irqsave (&vp->lock, flags);
update_stats(dev->base_addr, dev);
- spin_unlock_irqrestore (&vp->lock, flags);
+ rtdm_lock_put_irqrestore (&vp->lock, flags);
}
return &vp->stats;
}
-#endif
/* Update statistics.
Unlike with the EL3 we need not worry about interrupts changing
@@ -3045,7 +3042,6 @@ static struct net_device_stats *vortex_g
table. This is done by checking that the ASM (!) code generated uses
atomic updates with '+='.
*/
-#if 0
static void update_stats(long ioaddr, struct rtnet_device *rtdev)
{
struct vortex_private *vp = (struct vortex_private *)rtdev->priv;
@@ -3084,7 +3080,6 @@ static void update_stats(long ioaddr, st
EL3WINDOW(old_window >> 13);
return;
}
-#endif
#if 0
static int netdev_ethtool_ioctl(struct rtnet_device *rtdev, void *useraddr)
{
diff -x '*~' -Naurdp rtnet-0.9.9-stats/drivers/experimental/rt_r8169.c
rtnet-0.9.9-stats-drivers/drivers/experimental/rt_r8169.c
--- rtnet-0.9.9-stats/drivers/experimental/rt_r8169.c 2006-09-10
16:20:15.000000000 +0200
+++ rtnet-0.9.9-stats-drivers/drivers/experimental/rt_r8169.c 2008-06-24
11:49:31.000000000 +0200
@@ -467,7 +467,7 @@ static int rtl8169_close (struct rtnet_d
static inline u32 ether_crc (int length, unsigned char *data);
static void rtl8169_set_rx_mode (struct rtnet_device *rtdev);
/* static void rtl8169_tx_timeout (struct net_device *dev); */ /*** RTnet ***/
-/* static struct net_device_stats *rtl8169_get_stats(struct net_device
*netdev); */ /*** RTnet ***/
+static struct net_device_stats *rtl8169_get_stats(struct rtnet_device *netdev);
#ifdef RTL8169_JUMBO_FRAME_SUPPORT
static int rtl8169_change_mtu(struct net_device *dev, int new_mtu);
@@ -862,7 +862,7 @@ static int __devinit rtl8169_init_one (s
rtdev->open = rtl8169_open;
rtdev->hard_start_xmit = rtl8169_start_xmit;
- /* dev->get_stats = rtl8169_get_stats; */ /***
RTnet ***/
+ rtdev->get_stats = rtl8169_get_stats;
rtdev->stop = rtl8169_close;
/* dev->tx_timeout = rtl8169_tx_timeout; */
/*** RTnet ***/
/* dev->set_multicast_list = rtl8169_set_rx_mode; */ /*** RTnet ***/
@@ -2073,15 +2073,13 @@ static void rtl8169_set_rx_mode (struct
//================================================================================
-#if 0 /*** RTnet ***/
-struct net_device_stats *rtl8169_get_stats(struct net_device *dev)
+static struct net_device_stats *rtl8169_get_stats(struct rtnet_device *rtdev)
{
- struct rtl8169_private *priv = dev->priv;
+ struct rtl8169_private *priv = rtdev->priv;
return &priv->stats;
}
-#endif /* #if 0 */ /*** /RTnet ***/
diff -x '*~' -Naurdp rtnet-0.9.9-stats/drivers/mpc52xx_fec/rt_mpc52xx_fec.c
rtnet-0.9.9-stats-drivers/drivers/mpc52xx_fec/rt_mpc52xx_fec.c
--- rtnet-0.9.9-stats/drivers/mpc52xx_fec/rt_mpc52xx_fec.c 2006-09-10
16:20:15.000000000 +0200
+++ rtnet-0.9.9-stats-drivers/drivers/mpc52xx_fec/rt_mpc52xx_fec.c
2008-06-24 11:53:41.000000000 +0200
@@ -98,8 +98,8 @@ static struct rtnet_device *mpc5xxx_fec_
static int mpc5xxx_fec_interrupt(rtdm_irq_t *irq_handle);
static int mpc5xxx_sdma_receive_interrupt(rtdm_irq_t *irq_handle);
static int mpc5xxx_sdma_transmit_interrupt(rtdm_irq_t *irq_handle);
+static struct net_device_stats *mpc5xxx_fec_get_stats(struct rtnet_device *);
#ifdef ORIGINAL_VERSION
-static struct rtnet_device_stats *mpc5xxx_fec_get_stats(struct rtnet_device *);
static void mpc5xxx_fec_set_multicast_list(struct rtnet_device *dev);
#endif
#ifdef CONFIG_RTNET_USE_MDIO
@@ -1321,9 +1321,7 @@ static void mpc5xxx_fec_reinit(struct rt
u16 u16_value;
#endif
u32 u32_value;
-#ifdef ORIGINAL_CODE
static void mpc5xxx_fec_update_stat(struct rtnet_device *);
-#endif
rtnetif_stop_queue(dev);
out_be32(&fec->imask, 0x0);
@@ -1377,13 +1375,11 @@ static void mpc5xxx_fec_reinit(struct rt
mpc5xxx_fec_restart(dev, priv->full_duplex);
-#ifdef ORIGINAL_CODE
/*
* Read MIB counters in order to reset them,
* then zero all the stats fields in memory
*/
mpc5xxx_fec_update_stat(dev);
-#endif
#ifdef CONFIG_USE_MDIO
if (priv->sequence_done) { /* redo the mpc5xxx_fec_open() */
@@ -1469,21 +1465,18 @@ mpc5xxx_fec_close(struct rtnet_device *d
}
-#ifdef ORIGINAL_CODE
mpc5xxx_fec_get_stats(dev);
-#endif
RTNET_MOD_DEC_USE_COUNT;
return 0;
}
-#ifdef ORIGINAL_CODE
/*
* Get the current statistics.
* This may be called with the card open or closed.
*/
-static struct rtnet_device_stats *
+static struct net_device_stats *
mpc5xxx_fec_get_stats(struct rtnet_device *dev)
{
struct mpc5xxx_fec_priv *priv = (struct mpc5xxx_fec_priv *)dev->priv;
@@ -1543,6 +1536,7 @@ mpc5xxx_fec_update_stat(struct rtnet_dev
mpc5xxx_fec_get_stats(dev);
}
+#ifdef ORIGINAL_CODE
/*
* Set or clear the multicast filter for this adaptor.
*/
@@ -1826,9 +1820,9 @@ mpc5xxx_fec_init(void)
dev->open = mpc5xxx_fec_open;
dev->stop = mpc5xxx_fec_close;
dev->hard_start_xmit = mpc5xxx_fec_hard_start_xmit;
+ dev->get_stats = mpc5xxx_fec_get_stats;
#ifdef ORIGINAL_CODE
dev->do_ioctl = mpc5xxx_fec_ioctl;
- dev->get_stats = mpc5xxx_fec_get_stats;
dev->set_mac_address = mpc5xxx_fec_set_mac_address;
dev->set_multicast_list = mpc5xxx_fec_set_multicast_list;
@@ -1976,13 +1970,11 @@ mpc5xxx_fec_init(void)
priv->old_status = 0;
#endif
-#ifdef ORIGINAL_CODE
/*
* Read MIB counters in order to reset them,
* then zero all the stats fields in memory
*/
mpc5xxx_fec_update_stat(dev);
-#endif
return 0;
}
diff -x '*~' -Naurdp rtnet-0.9.9-stats/drivers/rt_8139too.c
rtnet-0.9.9-stats-drivers/drivers/rt_8139too.c
--- rtnet-0.9.9-stats/drivers/rt_8139too.c 2007-02-23 21:26:43.000000000
+0100
+++ rtnet-0.9.9-stats-drivers/drivers/rt_8139too.c 2008-06-24
14:26:43.000000000 +0200
@@ -522,6 +522,7 @@ static int rtl8139_interrupt (rtdm_irq_t
static int rtl8139_start_xmit (struct rtskb *skb, struct rtnet_device *rtdev);
static int rtl8139_ioctl(struct rtnet_device *rtdev, unsigned int request,
void *cmd);
+static struct net_device_stats *rtl8139_get_stats(struct rtnet_device*rtdev);
static void rtl8139_init_ring (struct rtnet_device *rtdev);
static void rtl8139_set_rx_mode (struct rtnet_device *rtdev);
@@ -832,6 +833,7 @@ static int __devinit rtl8139_init_one (s
rtdev->hard_header = &rt_eth_header;
rtdev->hard_start_xmit = rtl8139_start_xmit;
rtdev->do_ioctl = rtl8139_ioctl;
+ rtdev->get_stats = rtl8139_get_stats;
/*rtdev->set_multicast_list = rtl8139_set_rx_mode; */
rtdev->features |= NETIF_F_SG|NETIF_F_HW_CSUM;
@@ -1368,6 +1370,12 @@ static int rtl8139_ioctl(struct rtnet_de
return nReturn;
}
+static struct net_device_stats *rtl8139_get_stats(struct rtnet_device*rtdev)
+{
+ struct rtl8139_private *tp = rtdev->priv;
+ return &tp->stats;
+}
+
static void rtl8139_tx_interrupt (struct rtnet_device *rtdev,
struct rtl8139_private *tp,
void *ioaddr)
diff -x '*~' -Naurdp rtnet-0.9.9-stats/drivers/rt_eepro100.c
rtnet-0.9.9-stats-drivers/drivers/rt_eepro100.c
--- rtnet-0.9.9-stats/drivers/rt_eepro100.c 2007-01-19 21:45:03.000000000
+0100
+++ rtnet-0.9.9-stats-drivers/drivers/rt_eepro100.c 2008-06-24
14:30:02.000000000 +0200
@@ -561,7 +561,7 @@ static int speedo_interrupt(rtdm_irq_t *
static int speedo_close(struct rtnet_device *rtdev);
static void set_rx_mode(struct rtnet_device *rtdev);
static void speedo_show_state(struct rtnet_device *rtdev);
-
+static struct net_device_stats *speedo_get_stats(struct rtnet_device *rtdev);
static inline void speedo_write_flush(long ioaddr)
@@ -797,6 +797,7 @@ static int speedo_found1(struct pci_dev
rtdev->hard_start_xmit = &speedo_start_xmit;
rtdev->stop = &speedo_close;
rtdev->hard_header = &rt_eth_header;
+ rtdev->get_stats = &speedo_get_stats;
//rtdev->do_ioctl = NULL;
if (rtskb_pool_init(&sp->skb_pool, RX_RING_SIZE*2) < RX_RING_SIZE*2) {
@@ -1049,6 +1050,12 @@ static void speedo_show_state(struct rtn
}
}
+static struct net_device_stats *speedo_get_stats(struct rtnet_device *rtdev)
+{
+ struct speedo_private *sp = (struct speedo_private *)rtdev->priv;
+ return &sp->stats;
+}
+
/* Initialize the Rx and Tx rings, along with various 'dev' bits. */
static void
speedo_init_rx_ring(struct rtnet_device *rtdev)
diff -x '*~' -Naurdp rtnet-0.9.9-stats/drivers/rt_eth1394.c
rtnet-0.9.9-stats-drivers/drivers/rt_eth1394.c
--- rtnet-0.9.9-stats/drivers/rt_eth1394.c 2006-11-26 17:00:24.000000000
+0100
+++ rtnet-0.9.9-stats-drivers/drivers/rt_eth1394.c 2008-06-24
14:32:05.000000000 +0200
@@ -259,13 +259,13 @@ static int eth1394_stop (struct rtnet_de
return 0;
}
-#if 0
/* Return statistics to the caller */
static struct net_device_stats *eth1394_stats (struct rtnet_device *dev)
{
return &(((struct eth1394_priv *)dev->priv)->stats);
}
+#if 0
static void eth1394_tx_timeout (struct rtnet_device *dev)
{
ETH1394_PRINT (KERN_ERR, dev->name, "Timeout, resetting host %s\n",
@@ -396,6 +396,7 @@ static void eth1394_add_host (struct hps
dev->hard_start_xmit = eth1394_tx;
dev->stop = eth1394_stop;
dev->hard_header = eth1394_header;
+ dev->get_stats = eth1394_stats;
dev->flags = IFF_BROADCAST | IFF_MULTICAST;
dev->addr_len = ETH_ALEN;
dev->hard_header_len = ETH_HLEN;
diff -x '*~' -Naurdp rtnet-0.9.9-stats/drivers/rt_mpc8260_fcc_enet.c
rtnet-0.9.9-stats-drivers/drivers/rt_mpc8260_fcc_enet.c
--- rtnet-0.9.9-stats/drivers/rt_mpc8260_fcc_enet.c 2006-11-26
17:01:06.000000000 +0100
+++ rtnet-0.9.9-stats-drivers/drivers/rt_mpc8260_fcc_enet.c 2008-06-24
14:34:34.000000000 +0200
@@ -156,8 +156,8 @@ static int fcc_enet_rx(struct rtnet_dev
static int fcc_enet_interrupt(rtdm_irq_t *irq_handle);
static int fcc_enet_close(struct rtnet_device *dev);
+static struct net_device_stats *fcc_enet_get_stats(struct rtnet_device *rtdev);
#ifdef ORIGINAL_VERSION
-static struct net_device_stats *fcc_enet_get_stats(struct net_device *dev);
static void set_multicast_list(struct net_device *dev);
static int fcc_enet_set_mac_address(struct net_device *dev, void *addr);
#endif /* ORIGINAL_VERSION */
@@ -812,14 +812,12 @@ fcc_enet_close(struct rtnet_device *rtde
return 0;
}
-#ifdef ORIGINAL_VERSION
-static struct net_device_stats *fcc_enet_get_stats(struct net_device *dev)
+static struct net_device_stats *fcc_enet_get_stats(struct rtnet_device *rtdev)
{
- struct fcc_enet_private *cep = (struct fcc_enet_private *)dev->priv;
+ struct fcc_enet_private *cep = (struct fcc_enet_private *)rtdev->priv;
return &cep->stats;
}
-#endif
#ifdef CONFIG_RTAI_RTNET_USE_MDIO
@@ -1672,6 +1670,7 @@ int __init fec_enet_init(void)
rtdev->hard_start_xmit = fcc_enet_start_xmit;
rtdev->stop = fcc_enet_close;
rtdev->hard_header = &rt_eth_header;
+ rtdev->get_stats = fcc_enet_get_stats;
if (!rx_pool_size)
rx_pool_size = RX_RING_SIZE * 2;
diff -x '*~' -Naurdp rtnet-0.9.9-stats/drivers/rt_mpc8xx_enet.c
rtnet-0.9.9-stats-drivers/drivers/rt_mpc8xx_enet.c
--- rtnet-0.9.9-stats/drivers/rt_mpc8xx_enet.c 2006-11-26 17:01:20.000000000
+0100
+++ rtnet-0.9.9-stats-drivers/drivers/rt_mpc8xx_enet.c 2008-06-24
14:58:21.000000000 +0200
@@ -173,8 +173,8 @@ static int scc_enet_rx(struct rtnet_devi
static int scc_enet_interrupt(rtdm_irq_t *irq_handle);
static int scc_enet_close(struct rtnet_device *rtdev);
+static struct net_device_stats *scc_enet_get_stats(struct rtnet_device *rtdev);
#ifdef ORIGINAL_VERSION
-static struct net_device_stats *scc_enet_get_stats(struct net_device *dev);
static void set_multicast_list(struct net_device *dev);
#endif
@@ -596,14 +596,12 @@ scc_enet_close(struct rtnet_device *rtde
return 0;
}
-#ifdef ORIGINAL_VERSION
-static struct net_device_stats *scc_enet_get_stats(struct net_device *dev)
+static struct net_device_stats *scc_enet_get_stats(struct rtnet_device *rtdev)
{
- struct scc_enet_private *cep = (struct scc_enet_private *)dev->priv;
+ struct scc_enet_private *cep = (struct scc_enet_private *)rtdev->priv;
return &cep->stats;
}
-#endif
#ifdef ORIGINAL_VERSION
/* Set or clear the multicast filter for this adaptor.
@@ -1042,6 +1040,7 @@ int __init scc_enet_init(void)
rtdev->hard_start_xmit = scc_enet_start_xmit;
rtdev->stop = scc_enet_close;
rtdev->hard_header = &rt_eth_header;
+ rtdev->get_stats = scc_enet_get_stats;
if (!rx_pool_size)
rx_pool_size = RX_RING_SIZE * 2;
diff -x '*~' -Naurdp rtnet-0.9.9-stats/drivers/rt_mpc8xx_fec.c
rtnet-0.9.9-stats-drivers/drivers/rt_mpc8xx_fec.c
--- rtnet-0.9.9-stats/drivers/rt_mpc8xx_fec.c 2006-11-26 17:01:29.000000000
+0100
+++ rtnet-0.9.9-stats-drivers/drivers/rt_mpc8xx_fec.c 2008-06-24
15:00:01.000000000 +0200
@@ -230,8 +230,8 @@ static void fec_stop(struct rtnet_device
#ifdef CONFIG_RTAI_RTNET_USE_MDIO
static void fec_enet_mii(struct net_device *dev);
#endif /* CONFIG_RTAI_RTNET_USE_MDIO */
+static struct net_device_stats *fec_enet_get_stats(struct rtnet_device *rtdev);
#ifdef ORIGINAL_VERSION
-static struct net_device_stats *fec_enet_get_stats(struct net_device *dev);
static void set_multicast_list(struct net_device *dev);
#endif /* ORIGINAL_VERSION */
@@ -1635,14 +1635,12 @@ fec_enet_close(struct rtnet_device *rtde
return 0;
}
-#ifdef ORIGINAL_VERSION
-static struct net_device_stats *fec_enet_get_stats(struct net_device *dev)
+static struct net_device_stats *fec_enet_get_stats(struct rtnet_device *rtdev)
{
struct fec_enet_private *fep = (struct fec_enet_private *)rtdev->priv;
return &fep->stats;
}
-#endif
#ifdef CONFIG_RTAI_RTNET_USE_MDIO
@@ -2098,6 +2096,7 @@ int __init fec_enet_init(void)
rtdev->hard_start_xmit = fec_enet_start_xmit;
rtdev->stop = fec_enet_close;
rtdev->hard_header = &rt_eth_header;
+ rtdev->get_stats = fec_enet_get_stats;
if (!rx_pool_size)
rx_pool_size = RX_RING_SIZE * 2;
diff -x '*~' -Naurdp rtnet-0.9.9-stats/drivers/rt_natsemi.c
rtnet-0.9.9-stats-drivers/drivers/rt_natsemi.c
--- rtnet-0.9.9-stats/drivers/rt_natsemi.c 2006-11-26 17:01:38.000000000
+0100
+++ rtnet-0.9.9-stats-drivers/drivers/rt_natsemi.c 2008-06-24
15:05:21.000000000 +0200
@@ -721,7 +721,7 @@ static void netdev_rx(struct rtnet_devic
static void netdev_tx_done(struct rtnet_device *dev);
static void __set_rx_mode(struct rtnet_device *dev);
/*static void set_rx_mode(struct rtnet_device *dev);*/
-static void __get_stats(struct rtnet_device *dev);
+static void __get_stats(struct rtnet_device *rtdev);
/*static struct net_device_stats *get_stats(struct net_device *dev);
static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
static int netdev_set_wol(struct rtnet_device *dev, u32 newval);
@@ -868,8 +868,8 @@ static int __devinit natsemi_probe1 (str
dev->open = &netdev_open;
dev->hard_start_xmit = &start_tx;
dev->stop = &netdev_close;
-/*** RTnet ***
dev->get_stats = &get_stats;
+/*** RTnet ***
dev->set_multicast_list = &set_rx_mode;
dev->do_ioctl = &netdev_ioctl;
dev->tx_timeout = &tx_timeout;
@@ -2002,22 +2002,19 @@ static void __get_stats(struct rtnet_dev
np->stats.rx_missed_errors += readl((void *)(ioaddr + RxMissed));
}
-/*** RTnet ***/
-#if 0
-static struct net_device_stats *get_stats(struct net_device *dev)
+static struct net_device_stats *get_stats(struct net_device *rtdev)
{
- struct netdev_private *np = dev->priv;
+ struct netdev_private *np = rtdev->priv;
+ rtdm_lockctx_t context;
/* The chip only need report frame silently dropped. */
- spin_lock_irq(&np->lock);
- if (netif_running(dev) && !np->hands_off)
+ rtdm_lock_get_irqsave(&np->lock, context);
+ if (rtnetif_running(dev) && !np->hands_off)
__get_stats(dev);
- spin_unlock_irq(&np->lock);
+ rtdm_lock_put_irqrestore(&np->lock, context);
return &np->stats;
}
-#endif
-/*** RTnet ***/
/**
* dp83815_crc - computer CRC for hash table entries
diff -x '*~' -Naurdp rtnet-0.9.9-stats/drivers/rt_pcnet32.c
rtnet-0.9.9-stats-drivers/drivers/rt_pcnet32.c
--- rtnet-0.9.9-stats/drivers/rt_pcnet32.c 2007-01-19 21:45:03.000000000
+0100
+++ rtnet-0.9.9-stats-drivers/drivers/rt_pcnet32.c 2008-06-24
15:10:57.000000000 +0200
@@ -350,7 +350,7 @@ static int pcnet32_rx(struct rtnet_devi
//static void pcnet32_tx_timeout (struct net_device *dev);
static int pcnet32_interrupt(rtdm_irq_t *irq_handle);
static int pcnet32_close(struct rtnet_device *);
-//static struct net_device_stats *pcnet32_get_stats(struct net_device *);
+static struct net_device_stats *pcnet32_get_stats(struct rtnet_device *);
//static void pcnet32_set_multicast_list(struct net_device *);
//static int pcnet32_ioctl(struct net_device *, struct ifreq *, int);
//static int mdio_read(struct net_device *dev, int phy_id, int reg_num);
@@ -830,8 +830,8 @@ pcnet32_probe1(unsigned long ioaddr, uns
dev->open = &pcnet32_open;
dev->hard_start_xmit = &pcnet32_start_xmit;
dev->stop = &pcnet32_close;
-/*** RTnet ***
dev->get_stats = &pcnet32_get_stats;
+/*** RTnet ***
dev->set_multicast_list = &pcnet32_set_multicast_list;
dev->do_ioctl = &pcnet32_ioctl;
dev->tx_timeout = pcnet32_tx_timeout;
@@ -1529,24 +1529,24 @@ pcnet32_close(struct rtnet_device *dev)
}
/*** RTnet ***/
-#if 0
static struct net_device_stats *
-pcnet32_get_stats(struct net_device *dev)
+pcnet32_get_stats(struct rtnet_device *rtdev)
{
- struct pcnet32_private *lp = dev->priv;
- unsigned long ioaddr = dev->base_addr;
+ struct pcnet32_private *lp = rtdev->priv;
+ unsigned long ioaddr = rtdev->base_addr;
+ rtdm_lockctx_t context;
u16 saved_addr;
- unsigned long flags;
- spin_lock_irqsave(&lp->lock, flags);
+ rtdm_lock_get_irqsave(&lp->lock, context);
saved_addr = lp->a.read_rap(ioaddr);
lp->stats.rx_missed_errors = lp->a.read_csr (ioaddr, 112);
lp->a.write_rap(ioaddr, saved_addr);
- spin_unlock_irqrestore(&lp->lock, flags);
+ rtdm_lock_put_irqrestore(&lp->lock, context);
return &lp->stats;
}
+#if 0
/* taken from the sunlance driver, which it took from the depca driver */
static void pcnet32_load_multicast (struct net_device *dev)
{
diff -x '*~' -Naurdp rtnet-0.9.9-stats/drivers/rt_smc91111.c
rtnet-0.9.9-stats-drivers/drivers/rt_smc91111.c
--- rtnet-0.9.9-stats/drivers/rt_smc91111.c 2006-09-10 16:20:15.000000000
+0200
+++ rtnet-0.9.9-stats-drivers/drivers/rt_smc91111.c 2008-06-24
15:12:15.000000000 +0200
@@ -356,7 +356,7 @@ static int smc_close(struct rtnet_device
. This routine allows the proc file system to query the driver's
. statistics.
*/
-//static struct net_device_stats * smc_query_statistics( struct net_device
*dev);
+static struct net_device_stats *smc_query_statistics(struct rtnet_device
*rtdev);
/*
. Finally, a call to set promiscuous mode ( for TCPDUMP and related
@@ -1325,8 +1325,8 @@ static int __init smc_probe(struct rtnet
dev->open = smc_open;
dev->stop = smc_close;
dev->hard_start_xmit = smc_wait_to_send_packet;
+ dev->get_stats = smc_query_statistics;
// dev->tx_timeout = smc_timeout;
-// dev->get_stats = smc_query_statistics;
#ifdef HAVE_MULTICAST
// dev->set_multicast_list = &smc_set_multicast_list;
#endif
@@ -1932,19 +1932,18 @@ static int smc_close(struct rtnet_device
return 0;
}
-#if 0
/*------------------------------------------------------------
. Get the current statistics.
. This may be called with the card open or closed.
.-------------------------------------------------------------*/
-static struct net_device_stats* smc_query_statistics(struct net_device *dev) {
- struct smc_local *lp = (struct smc_local *)dev->priv;
+static struct net_device_stats* smc_query_statistics(struct rtnet_device
*rtdev)
+{
+ struct smc_local *lp = (struct smc_local *)rtdev->priv;
- PRINTK2("%s:smc_query_statistics\n", dev->name);
+ PRINTK2("%s:smc_query_statistics\n", rtdev->name);
return &lp->stats;
}
-#endif
/*-----------------------------------------------------------
. smc_set_multicast_list
diff -x '*~' -Naurdp rtnet-0.9.9-stats/drivers/rt_via-rhine.c
rtnet-0.9.9-stats-drivers/drivers/rt_via-rhine.c
--- rtnet-0.9.9-stats/drivers/rt_via-rhine.c 2006-11-26 16:44:49.000000000
+0100
+++ rtnet-0.9.9-stats-drivers/drivers/rt_via-rhine.c 2008-06-24
15:14:54.000000000 +0200
@@ -556,8 +556,8 @@ static void via_rhine_tx(struct rtnet_de
static void via_rhine_rx(struct rtnet_device *dev, nanosecs_abs_t *time_stamp);
static void via_rhine_error(struct rtnet_device *dev, int intr_status);
static void via_rhine_set_rx_mode(struct rtnet_device *dev);
-/*static struct net_device_stats *via_rhine_get_stats(struct net_device *dev);
-static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);*/
+static struct net_device_stats *via_rhine_get_stats(struct rtnet_device
*rtdev);
+/*static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);*/
static int via_rhine_close(struct rtnet_device *dev);
/*** RTnet ***/
@@ -807,8 +807,8 @@ static int __devinit via_rhine_init_one
dev->open = via_rhine_open;
dev->hard_start_xmit = via_rhine_start_tx;
dev->stop = via_rhine_close;
-/*** RTnet ***
dev->get_stats = via_rhine_get_stats;
+/*** RTnet ***
dev->set_multicast_list = via_rhine_set_rx_mode;
dev->do_ioctl = netdev_ioctl;
dev->tx_timeout = via_rhine_tx_timeout;
@@ -1791,22 +1791,20 @@ static void via_rhine_error(struct rtnet
rtdm_lock_put(&np->lock); /*** RTnet ***/
}
-/*** RTnet ***
-static struct net_device_stats *via_rhine_get_stats(struct net_device *dev)
+static struct net_device_stats *via_rhine_get_stats(struct rtnet_device *rtdev)
{
- struct netdev_private *np = dev->priv;
- long ioaddr = dev->base_addr;
- unsigned long flags;
+ struct netdev_private *np = rtdev->priv;
+ long ioaddr = rtdev->base_addr;
+ rtdm_lockctx_t context;
- spin_lock_irqsave(&np->lock, flags);
+ rtdm_lock_get_irqsave(&np->lock, context);
np->stats.rx_crc_errors += readw(ioaddr + RxCRCErrs);
np->stats.rx_missed_errors += readw(ioaddr + RxMissed);
clear_tally_counters(ioaddr);
- spin_unlock_irqrestore(&np->lock, flags);
+ rtdm_lock_put_irqrestore(&np->lock, context);
return &np->stats;
}
- *** RTnet ***/
static void via_rhine_set_rx_mode(struct rtnet_device *dev) /*** RTnet ***/
{
diff -x '*~' -Naurdp rtnet-0.9.9-stats/drivers/tulip/tulip_core.c
rtnet-0.9.9-stats-drivers/drivers/tulip/tulip_core.c
--- rtnet-0.9.9-stats/drivers/tulip/tulip_core.c 2007-01-19
21:45:03.000000000 +0100
+++ rtnet-0.9.9-stats-drivers/drivers/tulip/tulip_core.c 2008-06-24
15:19:10.000000000 +0200
@@ -254,6 +254,7 @@ static int tulip_open(/*RTnet*/struct rt
static int tulip_close(/*RTnet*/struct rtnet_device *rtdev);
static void tulip_up(/*RTnet*/struct rtnet_device *rtdev);
static void tulip_down(/*RTnet*/struct rtnet_device *rtdev);
+static struct net_device_stats *tulip_get_stats(struct rtnet_device *rtdev);
//static void set_rx_mode(struct net_device *dev);
@@ -665,6 +666,12 @@ static void tulip_clean_tx_ring(struct t
}
}
+static struct net_device_stats *tulip_get_stats(struct rtnet_device *rtdev)
+{
+ struct tulip_private *tp = (struct tulip_private *) rtdev->priv;
+ return &tp->stats;
+}
+
static void tulip_down (/*RTnet*/struct rtnet_device *rtdev)
{
long ioaddr = rtdev->base_addr;
@@ -1413,6 +1420,7 @@ static int __devinit tulip_init_one (str
rtdev->stop = tulip_close;
rtdev->hard_header = rt_eth_header;
rtdev->hard_start_xmit = tulip_start_xmit;
+ rtdev->get_stats = tulip_get_stats;
/*RTnet*/
if (rtskb_pool_init(&tp->skb_pool, RX_RING_SIZE*2) < RX_RING_SIZE*2)
diff -x '*~' -Naurdp rtnet-0.9.9-stats/stack/include/rtnet_port.h
rtnet-0.9.9-stats-drivers/stack/include/rtnet_port.h
--- rtnet-0.9.9-stats/stack/include/rtnet_port.h 2007-02-09
23:00:02.000000000 +0100
+++ rtnet-0.9.9-stats-drivers/stack/include/rtnet_port.h 2008-06-24
11:40:39.000000000 +0200
@@ -83,6 +83,11 @@ static inline int rtnetif_running(struct
return test_bit(__LINK_STATE_START, &rtdev->state);
}
+static inline int rtnetif_device_present(struct rtnet_device *rtdev)
+{
+ return test_bit(__LINK_STATE_PRESENT, &rtdev->state);
+}
+
static inline void rtnetif_carrier_on(struct rtnet_device *rtdev)
{
clear_bit(__LINK_STATE_NOCARRIER, &rtdev->state);
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
RTnet-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rtnet-developers