mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-12-18 10:17:09 +02:00
[ar71xx] ag71xx driver: add OOM handler
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@13545 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
e36d68b178
commit
1b055785c6
@ -38,9 +38,10 @@
|
|||||||
#define ETH_FCS_LEN 4
|
#define ETH_FCS_LEN 4
|
||||||
|
|
||||||
#define AG71XX_DRV_NAME "ag71xx"
|
#define AG71XX_DRV_NAME "ag71xx"
|
||||||
#define AG71XX_DRV_VERSION "0.5.12"
|
#define AG71XX_DRV_VERSION "0.5.13"
|
||||||
|
|
||||||
#define AG71XX_NAPI_WEIGHT 64
|
#define AG71XX_NAPI_WEIGHT 64
|
||||||
|
#define AG71XX_OOM_REFILL (1 + HZ/10)
|
||||||
|
|
||||||
#define AG71XX_INT_ERR (AG71XX_INT_RX_BE | AG71XX_INT_TX_BE)
|
#define AG71XX_INT_ERR (AG71XX_INT_RX_BE | AG71XX_INT_TX_BE)
|
||||||
#define AG71XX_INT_TX (AG71XX_INT_TX_PS)
|
#define AG71XX_INT_TX (AG71XX_INT_TX_PS)
|
||||||
@ -127,6 +128,7 @@ struct ag71xx {
|
|||||||
int duplex;
|
int duplex;
|
||||||
|
|
||||||
struct work_struct restart_work;
|
struct work_struct restart_work;
|
||||||
|
struct timer_list oom_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct ethtool_ops ag71xx_ethtool_ops;
|
extern struct ethtool_ops ag71xx_ethtool_ops;
|
||||||
|
@ -231,11 +231,8 @@ static int ag71xx_ring_rx_refill(struct ag71xx *ag)
|
|||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
|
|
||||||
skb = dev_alloc_skb(AG71XX_RX_PKT_SIZE);
|
skb = dev_alloc_skb(AG71XX_RX_PKT_SIZE);
|
||||||
if (skb == NULL) {
|
if (skb == NULL)
|
||||||
printk(KERN_ERR "%s: no memory for skb\n",
|
|
||||||
ag->dev->name);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
dma_map_single(NULL, skb->data, AG71XX_RX_PKT_SIZE,
|
dma_map_single(NULL, skb->data, AG71XX_RX_PKT_SIZE,
|
||||||
DMA_FROM_DEVICE);
|
DMA_FROM_DEVICE);
|
||||||
@ -443,6 +440,7 @@ static int ag71xx_stop(struct net_device *dev)
|
|||||||
ag71xx_phy_stop(ag);
|
ag71xx_phy_stop(ag);
|
||||||
|
|
||||||
napi_disable(&ag->napi);
|
napi_disable(&ag->napi);
|
||||||
|
del_timer_sync(&ag->oom_timer);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&ag->lock, flags);
|
spin_unlock_irqrestore(&ag->lock, flags);
|
||||||
|
|
||||||
@ -551,6 +549,14 @@ static int ag71xx_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
|||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ag71xx_oom_timer_handler(unsigned long data)
|
||||||
|
{
|
||||||
|
struct net_device *dev = (struct net_device *) data;
|
||||||
|
struct ag71xx *ag = netdev_priv(dev);
|
||||||
|
|
||||||
|
netif_rx_schedule(dev, &ag->napi);
|
||||||
|
}
|
||||||
|
|
||||||
static void ag71xx_tx_timeout(struct net_device *dev)
|
static void ag71xx_tx_timeout(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct ag71xx *ag = netdev_priv(dev);
|
struct ag71xx *ag = netdev_priv(dev);
|
||||||
@ -664,6 +670,7 @@ static int ag71xx_poll(struct napi_struct *napi, int limit)
|
|||||||
struct ag71xx *ag = container_of(napi, struct ag71xx, napi);
|
struct ag71xx *ag = container_of(napi, struct ag71xx, napi);
|
||||||
struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
|
struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
|
||||||
struct net_device *dev = ag->dev;
|
struct net_device *dev = ag->dev;
|
||||||
|
struct ag71xx_ring *rx_ring;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
u32 status;
|
u32 status;
|
||||||
int done;
|
int done;
|
||||||
@ -674,7 +681,9 @@ static int ag71xx_poll(struct napi_struct *napi, int limit)
|
|||||||
DBG("%s: processing RX ring\n", dev->name);
|
DBG("%s: processing RX ring\n", dev->name);
|
||||||
done = ag71xx_rx_packets(ag, limit);
|
done = ag71xx_rx_packets(ag, limit);
|
||||||
|
|
||||||
/* TODO: add OOM handler */
|
rx_ring = &ag->rx_ring;
|
||||||
|
if (rx_ring->buf[rx_ring->dirty % AG71XX_RX_RING_SIZE].skb == NULL)
|
||||||
|
goto oom;
|
||||||
|
|
||||||
status = ag71xx_rr(ag, AG71XX_REG_RX_STATUS);
|
status = ag71xx_rr(ag, AG71XX_REG_RX_STATUS);
|
||||||
if (unlikely(status & RX_STATUS_OF)) {
|
if (unlikely(status & RX_STATUS_OF)) {
|
||||||
@ -702,13 +711,21 @@ static int ag71xx_poll(struct napi_struct *napi, int limit)
|
|||||||
spin_lock_irqsave(&ag->lock, flags);
|
spin_lock_irqsave(&ag->lock, flags);
|
||||||
ag71xx_int_enable(ag, AG71XX_INT_POLL);
|
ag71xx_int_enable(ag, AG71XX_INT_POLL);
|
||||||
spin_unlock_irqrestore(&ag->lock, flags);
|
spin_unlock_irqrestore(&ag->lock, flags);
|
||||||
return done;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
more:
|
more:
|
||||||
DBG("%s: stay in polling mode, done=%d, limit=%d\n",
|
DBG("%s: stay in polling mode, done=%d, limit=%d\n",
|
||||||
dev->name, done, limit);
|
dev->name, done, limit);
|
||||||
return done;
|
return 1;
|
||||||
|
|
||||||
|
oom:
|
||||||
|
if (netif_msg_rx_err(ag))
|
||||||
|
printk(KERN_DEBUG "%s: out of memory\n", dev->name);
|
||||||
|
|
||||||
|
mod_timer(&ag->oom_timer, jiffies + AG71XX_OOM_REFILL);
|
||||||
|
netif_rx_complete(dev, napi);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static irqreturn_t ag71xx_interrupt(int irq, void *dev_id)
|
static irqreturn_t ag71xx_interrupt(int irq, void *dev_id)
|
||||||
@ -842,6 +859,10 @@ static int __init ag71xx_probe(struct platform_device *pdev)
|
|||||||
dev->tx_timeout = ag71xx_tx_timeout;
|
dev->tx_timeout = ag71xx_tx_timeout;
|
||||||
INIT_WORK(&ag->restart_work, ag71xx_restart_work_func);
|
INIT_WORK(&ag->restart_work, ag71xx_restart_work_func);
|
||||||
|
|
||||||
|
init_timer(&ag->oom_timer);
|
||||||
|
ag->oom_timer.data = (unsigned long) dev;
|
||||||
|
ag->oom_timer.function = ag71xx_oom_timer_handler;
|
||||||
|
|
||||||
netif_napi_add(dev, &ag->napi, ag71xx_poll, AG71XX_NAPI_WEIGHT);
|
netif_napi_add(dev, &ag->napi, ag71xx_poll, AG71XX_NAPI_WEIGHT);
|
||||||
|
|
||||||
if (is_valid_ether_addr(pdata->mac_addr))
|
if (is_valid_ether_addr(pdata->mac_addr))
|
||||||
|
Loading…
Reference in New Issue
Block a user