Commit 0108ce25 authored by Alexander Viro's avatar Alexander Viro Committed by Stephen Hemminger

[wan hdlc] new hdlc_stats() helper

New inlined helper - hdlc_stats().  A lot of places had it spelled out;
replaced with calls.
parent 06aef211
......@@ -129,7 +129,7 @@ static void sca_msci_intr(port_t *port)
sca_out(stat & ST1_UDRN, MSCI0_OFFSET + ST1, card);
if (stat & ST1_UDRN) {
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
struct net_device_stats *stats = hdlc_stats(dev);
stats->tx_errors++; /* TX Underrun error detected */
stats->tx_fifo_errors++;
}
......
......@@ -636,7 +636,7 @@ static inline void dscc4_rx_skb(struct dscc4_dev_priv *dpriv,
struct net_device *dev)
{
struct RxFD *rx_fd = dpriv->rx_fd + dpriv->rx_current%RX_RING_SIZE;
struct net_device_stats *stats = &dpriv->hdlc.stats;
struct net_device_stats *stats = hdlc_stats(dev);
struct pci_dev *pdev = dpriv->pci_priv->pdev;
struct sk_buff *skb;
int pkt_len;
......@@ -1547,7 +1547,7 @@ static inline void dscc4_tx_irq(struct dscc4_pci_priv *ppriv,
if (state & SccEvt) {
if (state & Alls) {
struct net_device_stats *stats = &dpriv->hdlc.stats;
struct net_device_stats *stats = hdlc_stats(dev);
struct sk_buff *skb;
struct TxFD *tx_fd;
......@@ -1675,7 +1675,7 @@ static inline void dscc4_tx_irq(struct dscc4_pci_priv *ppriv,
}
if (state & Err) {
printk(KERN_INFO "%s: Tx ERR\n", dev->name);
dev_to_hdlc(dev)->stats.tx_errors++;
hdlc_stats(dev)->tx_errors++;
state &= ~Err;
}
}
......@@ -1811,7 +1811,7 @@ static inline void dscc4_rx_irq(struct dscc4_pci_priv *priv,
if (!(rx_fd->state2 & DataComplete))
break;
if (rx_fd->state2 & FrameAborted) {
dev_to_hdlc(dev)->stats.rx_over_errors++;
hdlc_stats(dev)->rx_over_errors++;
rx_fd->state1 |= Hold;
rx_fd->state2 = 0x00000000;
rx_fd->end = 0xbabeface;
......
......@@ -652,7 +652,7 @@ fst_intr_rx ( struct fst_card_info *card, struct fst_port_info *port )
unsigned short len;
struct sk_buff *skb;
struct net_device *dev = port_to_dev(port);
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
struct net_device_stats *stats = hdlc_stats(dev);
int i;
......@@ -837,8 +837,8 @@ fst_intr ( int irq, void *dev_id, struct pt_regs *regs )
* always load up the entire packet for DMA.
*/
dbg ( DBG_TX,"Tx underflow port %d\n", event & 0x03 );
dev_to_hdlc(port_to_dev(port))->stats.tx_errors++;
dev_to_hdlc(port_to_dev(port))->stats.tx_fifo_errors++;
hdlc_stats(port_to_dev(port))->tx_errors++;
hdlc_stats(port_to_dev(port))->tx_fifo_errors++;
break;
case INIT_CPLT:
......@@ -1346,7 +1346,7 @@ static void
fst_tx_timeout ( struct net_device *dev )
{
struct fst_port_info *port;
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
struct net_device_stats *stats = hdlc_stats(dev);
dbg ( DBG_INTR | DBG_TX,"tx_timeout\n");
......@@ -1366,7 +1366,7 @@ fst_tx_timeout ( struct net_device *dev )
static int
fst_start_xmit ( struct sk_buff *skb, struct net_device *dev )
{
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
struct net_device_stats *stats = hdlc_stats(dev);
struct fst_card_info *card;
struct fst_port_info *port;
unsigned char dmabits;
......
......@@ -256,9 +256,9 @@ static inline void sca_msci_intr(port_t *port)
sca_out(stat & (ST1_UDRN | ST1_CDCD), msci + ST1, card);
if (stat & ST1_UDRN) {
hdlc_device *hdlc = dev_to_hdlc(port_to_dev(port));
hdlc->stats.tx_errors++; /* TX Underrun error detected */
hdlc->stats.tx_fifo_errors++;
struct net_device_stats *stats = hdlc_stats(port_to_dev(port));
stats->tx_errors++; /* TX Underrun error detected */
stats->tx_fifo_errors++;
}
if (stat & ST1_CDCD)
......@@ -272,7 +272,7 @@ static inline void sca_msci_intr(port_t *port)
static inline void sca_rx(card_t *card, port_t *port, pkt_desc *desc, u16 rxin)
{
struct net_device *dev = port_to_dev(port);
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
struct net_device_stats *stats = hdlc_stats(dev);
struct sk_buff *skb;
u16 len;
u32 buff;
......@@ -330,7 +330,7 @@ static inline void sca_rx_intr(port_t *port)
u16 dmac = get_dmac_rx(port);
card_t *card = port_to_card(port);
u8 stat = sca_in(DSR_RX(phy_node(port)), card); /* read DMA Status */
struct net_device_stats *stats = &dev_to_hdlc(port_to_dev(port))->stats;
struct net_device_stats *stats = hdlc_stats(port_to_dev(port));
/* Reset DSR status bits */
sca_out((stat & (DSR_EOT | DSR_EOM | DSR_BOF | DSR_COF)) | DSR_DWE,
......@@ -378,7 +378,7 @@ static inline void sca_rx_intr(port_t *port)
static inline void sca_tx_intr(port_t *port)
{
struct net_device *dev = port_to_dev(port);
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
struct net_device_stats *stats = hdlc_stats(dev);
u16 dmac = get_dmac_tx(port);
card_t* card = port_to_card(port);
u8 stat;
......
......@@ -50,7 +50,7 @@ static int hdlc_change_mtu(struct net_device *dev, int new_mtu)
static struct net_device_stats *hdlc_get_stats(struct net_device *dev)
{
return &dev_to_hdlc(dev)->stats;
return hdlc_stats(dev);
}
......
......@@ -33,7 +33,7 @@ static int eth_tx(struct sk_buff *skb, struct net_device *dev)
int len = skb->len;
if (skb_tailroom(skb) < pad)
if (pskb_expand_head(skb, 0, pad, GFP_ATOMIC)) {
dev_to_hdlc(dev)->stats.tx_dropped++;
hdlc_stats(dev)->tx_dropped++;
dev_kfree_skb(skb);
return 0;
}
......
......@@ -1774,7 +1774,7 @@ void cpc_tx_timeout(struct net_device *dev)
pc300dev_t *d = (pc300dev_t *) dev->priv;
pc300ch_t *chan = (pc300ch_t *) d->chan;
pc300_t *card = (pc300_t *) chan->card;
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
struct net_device_stats *stats = hdlc_stats(dev);
int ch = chan->channel;
uclong flags;
ucchar ilar;
......@@ -1802,7 +1802,7 @@ int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev)
pc300dev_t *d = (pc300dev_t *) dev->priv;
pc300ch_t *chan = (pc300ch_t *) d->chan;
pc300_t *card = (pc300_t *) chan->card;
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
struct net_device_stats *stats = hdlc_stats(dev);
int ch = chan->channel;
uclong flags;
#ifdef PC300_DEBUG_TX
......@@ -1885,7 +1885,7 @@ void cpc_net_rx(struct net_device *dev)
pc300dev_t *d = (pc300dev_t *) dev->priv;
pc300ch_t *chan = (pc300ch_t *) d->chan;
pc300_t *card = (pc300_t *) chan->card;
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
struct net_device_stats *stats = hdlc_stats(dev);
int ch = chan->channel;
#ifdef PC300_DEBUG_RX
int i;
......@@ -1974,7 +1974,7 @@ static void sca_tx_intr(pc300dev_t *dev)
pc300_t *card = (pc300_t *)chan->card;
int ch = chan->channel;
volatile pcsca_bd_t * ptdescr;
struct net_device_stats *stats = &dev_to_hdlc(dev->dev)->stats;
struct net_device_stats *stats = hdlc_stats(dev->dev);
/* Clean up descriptors from previous transmission */
ptdescr = (pcsca_bd_t *)(card->hw.rambase +
......@@ -2817,7 +2817,7 @@ int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
static struct net_device_stats *cpc_get_stats(struct net_device *dev)
{
return &dev_to_hdlc(dev)->stats;
return hdlc_stats(dev);
}
static int clock_rate_calc(uclong rate, uclong clock, int *br_io)
......
......@@ -452,7 +452,7 @@ static int cpc_tty_write(struct tty_struct *tty, int from_user,
(from_user)?"from user" : "from kernel",count);
pc300chan = (pc300ch_t *)((pc300dev_t*)cpc_tty->pc300dev)->chan;
stats = &dev_to_hdlc(((pc300dev_t*)cpc_tty->pc300dev)->dev)->stats;
stats = hdlc_stats(((pc300dev_t*)cpc_tty->pc300dev)->dev);
card = (pc300_t *) pc300chan->card;
ch = pc300chan->channel;
......@@ -738,7 +738,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
pc300_t *card = (pc300_t *)pc300chan->card;
int ch = pc300chan->channel;
volatile pcsca_bd_t * ptdescr;
struct net_device_stats *stats = &dev_to_hdlc(pc300dev->dev)->stats;
struct net_device_stats *stats = hdlc_stats(pc300dev->dev);
int rx_len, rx_aux;
volatile unsigned char status;
unsigned short first_bd = pc300chan->rx_first_bd;
......@@ -914,7 +914,7 @@ static int cpc_tty_send_to_card(pc300dev_t *dev,void* buf, int len)
pc300ch_t *chan = (pc300ch_t *)dev->chan;
pc300_t *card = (pc300_t *)chan->card;
int ch = chan->channel;
struct net_device_stats *stats = &dev_to_hdlc(dev->dev)->stats;
struct net_device_stats *stats = hdlc_stats(dev->dev);
unsigned long flags;
volatile pcsca_bd_t * ptdescr;
int i, nchar;
......
......@@ -175,7 +175,7 @@ static inline void wanxl_cable_intr(port_t *port)
static inline void wanxl_tx_intr(port_t *port)
{
struct net_device *dev = port_to_dev(port);
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
struct net_device_stats *stats = hdlc_stats(dev);
while (1) {
desc_t *desc = &get_status(port)->tx_descs[port->tx_in];
struct sk_buff *skb = port->tx_skbs[port->tx_in];
......@@ -214,7 +214,7 @@ static inline void wanxl_rx_intr(card_t *card)
struct sk_buff *skb = card->rx_skbs[card->rx_in];
port_t *port = card->ports[desc->stat & PACKET_PORT_MASK];
struct net_device *dev = port_to_dev(port);
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
struct net_device_stats *stats = hdlc_stats(dev);
if ((desc->stat & PACKET_PORT_MASK) > card->n_ports)
printk(KERN_CRIT "wanXL %s: received packet for"
......@@ -480,14 +480,13 @@ static int wanxl_close(struct net_device *dev)
static struct net_device_stats *wanxl_get_stats(struct net_device *dev)
{
hdlc_device *hdlc = dev_to_hdlc(dev);
struct net_device_stats *stats = hdlc_stats(dev);
port_t *port = dev_to_port(dev);
hdlc->stats.rx_over_errors = get_status(port)->rx_overruns;
hdlc->stats.rx_frame_errors = get_status(port)->rx_frame_errors;
hdlc->stats.rx_errors = hdlc->stats.rx_over_errors +
hdlc->stats.rx_frame_errors;
return &hdlc->stats;
stats->rx_over_errors = get_status(port)->rx_overruns;
stats->rx_frame_errors = get_status(port)->rx_frame_errors;
stats->rx_errors = stats->rx_over_errors + stats->rx_frame_errors;
return stats;
}
......
......@@ -238,6 +238,12 @@ static __inline__ void hdlc_proto_detach(hdlc_device *hdlc)
}
static __inline__ struct net_device_stats *hdlc_stats(struct net_device *dev)
{
return &dev_to_hdlc(dev)->stats;
}
static __inline__ unsigned short hdlc_type_trans(struct sk_buff *skb,
struct net_device *dev)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment