--- ../old/adm5120sw.c 2008-01-29 15:20:01.000000000 +0100 +++ target/linux/adm5120/files/drivers/net/adm5120sw.c 2008-01-30 23:02:14.000000000 +0100 @@ -95,6 +95,11 @@ struct adm5120_if_priv { unsigned int vlan_no; unsigned int port_mask; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) +#else + struct net_device* adm5120_net_dev; +#endif + struct napi_struct napi; }; struct dma_desc { @@ -495,9 +500,17 @@ } #ifdef CONFIG_ADM5120_SWITCH_NAPI +#if (KERNEL_VERSION_CODE < KERNEL_VERSION(2,6,24) static int adm5120_if_poll(struct net_device *dev, int *budget) { int limit = min(dev->quota, *budget); +#else +static int adm5120_if_poll(struct napi_struct *napi, int budget) +{ + struct adm5120_if_priv *lp = container_of(napi, struct adm5120_if_priv, napi); + struct net_device *dev = lp->adm5120_net_dev; + int limit = budget; +#endif int done; u32 status; @@ -508,23 +521,32 @@ SW_DBG("%s: processing RX ring\n", dev->name); done = adm5120_switch_rx(limit); - +#if (KERNEL_VERSION_CODE < KERNEL_VERSION(2,6,24)) *budget -= done; dev->quota -= done; +#endif status = sw_int_status() & SWITCH_INTS_POLL; if ((done < limit) && (!status)) { SW_DBG("disable polling mode for %s\n", dev->name); +#if (KERNEL_VERSION_CODE < KERNEL_VERSION(2,6,24)) netif_rx_complete(dev); +#else + netif_rx_complete(dev, napi); +#endif sw_int_unmask(SWITCH_INTS_POLL); return 0; } SW_DBG("%s still in polling mode, done=%d, status=%x\n", dev->name, done, status); +#if (KERNEL_VERSION_CODE < KERNEL_VERSION(2,6,24)) + return done; +#else return 1; +#endif } -#endif /* CONFIG_ADM5120_SWITCH_USE_NAPI */ +#endif /* CONFIG_ADM5120_SWITCH_NAPI */ static irqreturn_t adm5120_switch_irq(int irq, void *dev_id) @@ -540,11 +562,20 @@ sw_int_ack(status & ~SWITCH_INTS_POLL); if (status & SWITCH_INTS_POLL) { - struct net_device *dev = dev_id; + struct net_device *dev = (struct net_device *) dev_id; +#if (KERNEL_VERSION_CODE < KERNEL_VERSION(2,6,24) + struct adm5120_if_priv *lp = netdev_priv(dev); +#endif + sw_dump_intr_mask("poll ints", status); SW_DBG("enable polling mode for %s\n", dev->name); sw_int_mask(SWITCH_INTS_POLL); + +#if (KERNEL_VERSION_CODE < KERNEL_VERSION(2,6,24) + netif_rx_schedule(dev, &lp->napi); +#else netif_rx_schedule(dev); +#endif } #else sw_int_ack(status); @@ -781,6 +812,7 @@ static int adm5120_if_open(struct net_device *dev) { + struct adm5120_if_priv *lp = netdev_priv(dev); u32 t; int err; int i; @@ -792,6 +824,9 @@ goto err; } +#ifdef CONFIG_ADM5120_SWITCH_NAPI + napi_enable(&lp->napi); +#endif if (!sw_used++) /* enable interrupts on first open */ sw_int_unmask(SWITCH_INTS_USED); @@ -814,11 +849,15 @@ static int adm5120_if_stop(struct net_device *dev) { + struct adm5120_if_priv *lp = netdev_priv(dev); u32 t; int i; netif_stop_queue(dev); +#ifdef CONFIG_ADM5120_SWITCH_NAPI + napi_disable(&lp->napi); +#endif /* disable port if not assigned to other devices */ t = sw_read_reg(SWITCH_REG_PORT_CONF0); t |= SWITCH_PORTS_NOCPU; @@ -1010,13 +1049,17 @@ dev->tx_timeout = adm5120_if_tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; dev->set_mac_address = adm5120_if_set_mac_address; +#if (KERNEL_VERSION_CODE < KERNEL_VERSION(2,6,24)) #ifdef CONFIG_ADM5120_SWITCH_NAPI dev->poll = adm5120_if_poll; dev->weight = 64; #endif - SET_MODULE_OWNER(dev); - +#else +#ifdef CONFIG_ADM5120_SWITCH_NAPI + netif_napi_add(dev, &priv->napi, adm5120_if_poll, 64); +#endif +#endif return dev; } @@ -1108,6 +1151,10 @@ priv->vlan_no = i; priv->port_mask = adm5120_eth_vlans[i]; +#if (KERNEL_VERSION_CODE < KERNEL_VERSION(2,6,24)) +#else + priv->adm5120_net_dev = dev; +#endif memcpy(dev->dev_addr, adm5120_eth_macs[i], 6); adm5120_write_mac(dev);