Skip to content

Commit

Permalink
tc35815: Improve BLEx / FDAEx handling
Browse files Browse the repository at this point in the history
Clear Int_BLEx / Int_FDAEx after (not before) processing Rx interrupt.
This will reduce number of unnecessary interrupts.
Also print rx error messages only if netif_msg_rx_err() enabled.

Signed-off-by: Atsushi Nemoto <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
atsushi-nemoto authored and davem330 committed Aug 6, 2009
1 parent 297713d commit db30f5e
Showing 1 changed file with 26 additions and 34 deletions.
60 changes: 26 additions & 34 deletions drivers/net/tc35815.c
Original file line number Diff line number Diff line change
Expand Up @@ -1541,8 +1541,6 @@ static int tc35815_do_interrupt(struct net_device *dev, u32 status)
#endif
{
struct tc35815_local *lp = netdev_priv(dev);
struct tc35815_regs __iomem *tr =
(struct tc35815_regs __iomem *)dev->base_addr;
int ret = -1;

/* Fatal errors... */
Expand All @@ -1552,27 +1550,26 @@ static int tc35815_do_interrupt(struct net_device *dev, u32 status)
}
/* recoverable errors */
if (status & Int_IntFDAEx) {
/* disable FDAEx int. (until we make rooms...) */
tc_writel(tc_readl(&tr->Int_En) & ~Int_FDAExEn, &tr->Int_En);
printk(KERN_WARNING
"%s: Free Descriptor Area Exhausted (%#x).\n",
dev->name, status);
if (netif_msg_rx_err(lp))
dev_warn(&dev->dev,
"Free Descriptor Area Exhausted (%#x).\n",
status);
dev->stats.rx_dropped++;
ret = 0;
}
if (status & Int_IntBLEx) {
/* disable BLEx int. (until we make rooms...) */
tc_writel(tc_readl(&tr->Int_En) & ~Int_BLExEn, &tr->Int_En);
printk(KERN_WARNING
"%s: Buffer List Exhausted (%#x).\n",
dev->name, status);
if (netif_msg_rx_err(lp))
dev_warn(&dev->dev,
"Buffer List Exhausted (%#x).\n",
status);
dev->stats.rx_dropped++;
ret = 0;
}
if (status & Int_IntExBD) {
printk(KERN_WARNING
"%s: Excessive Buffer Descriptiors (%#x).\n",
dev->name, status);
if (netif_msg_rx_err(lp))
dev_warn(&dev->dev,
"Excessive Buffer Descriptiors (%#x).\n",
status);
dev->stats.rx_length_errors++;
ret = 0;
}
Expand Down Expand Up @@ -1631,8 +1628,12 @@ static irqreturn_t tc35815_interrupt(int irq, void *dev_id)

spin_lock(&lp->lock);
status = tc_readl(&tr->Int_Src);
tc_writel(status, &tr->Int_Src); /* write to clear */
/* BLEx, FDAEx will be cleared later */
tc_writel(status & ~(Int_BLEx | Int_FDAEx),
&tr->Int_Src); /* write to clear */
handled = tc35815_do_interrupt(dev, status);
if (status & (Int_BLEx | Int_FDAEx))
tc_writel(status & (Int_BLEx | Int_FDAEx), &tr->Int_Src);
(void)tc_readl(&tr->Int_Src); /* flush */
spin_unlock(&lp->lock);
return IRQ_RETVAL(handled >= 0);
Expand Down Expand Up @@ -1660,8 +1661,6 @@ tc35815_rx(struct net_device *dev)
struct tc35815_local *lp = netdev_priv(dev);
unsigned int fdctl;
int i;
int buf_free_count = 0;
int fd_free_count = 0;
#ifdef TC35815_NAPI
int received = 0;
#endif
Expand Down Expand Up @@ -1770,8 +1769,9 @@ tc35815_rx(struct net_device *dev)
dev->stats.rx_bytes += pkt_len;
} else {
dev->stats.rx_errors++;
printk(KERN_DEBUG "%s: Rx error (status %x)\n",
dev->name, status & Rx_Stat_Mask);
if (netif_msg_rx_err(lp))
dev_info(&dev->dev, "Rx error (status %x)\n",
status & Rx_Stat_Mask);
/* WORKAROUND: LongErr and CRCErr means Overflow. */
if ((status & Rx_LongErr) && (status & Rx_CRCErr)) {
status &= ~(Rx_LongErr|Rx_CRCErr);
Expand Down Expand Up @@ -1849,7 +1849,6 @@ tc35815_rx(struct net_device *dev)
#else
lp->fbl_count++;
#endif
buf_free_count++;
}
}

Expand All @@ -1871,7 +1870,6 @@ tc35815_rx(struct net_device *dev)
#endif
lp->rfd_cur->fd.FDCtl = cpu_to_le32(FD_CownsFD);
lp->rfd_cur++;
fd_free_count++;
}
if (lp->rfd_cur > lp->rfd_limit)
lp->rfd_cur = lp->rfd_base;
Expand All @@ -1882,17 +1880,6 @@ tc35815_rx(struct net_device *dev)
#endif
}

/* re-enable BL/FDA Exhaust interrupts. */
if (fd_free_count) {
struct tc35815_regs __iomem *tr =
(struct tc35815_regs __iomem *)dev->base_addr;
u32 en, en_old = tc_readl(&tr->Int_En);
en = en_old | Int_FDAExEn;
if (buf_free_count)
en |= Int_BLExEn;
if (en != en_old)
tc_writel(en, &tr->Int_En);
}
#ifdef TC35815_NAPI
return received;
#endif
Expand All @@ -1911,9 +1898,14 @@ static int tc35815_poll(struct napi_struct *napi, int budget)
spin_lock(&lp->lock);
status = tc_readl(&tr->Int_Src);
do {
tc_writel(status, &tr->Int_Src); /* write to clear */
/* BLEx, FDAEx will be cleared later */
tc_writel(status & ~(Int_BLEx | Int_FDAEx),
&tr->Int_Src); /* write to clear */

handled = tc35815_do_interrupt(dev, status, budget - received);
if (status & (Int_BLEx | Int_FDAEx))
tc_writel(status & (Int_BLEx | Int_FDAEx),
&tr->Int_Src);
if (handled >= 0) {
received += handled;
if (received >= budget)
Expand Down

0 comments on commit db30f5e

Please sign in to comment.