Lines Matching refs:ndev

163 	struct net_device *ndev;  member
192 static inline void __iomem *w5100_mmio(struct net_device *ndev) in w5100_mmio() argument
194 struct w5100_mmio_priv *mmio_priv = w5100_mmio_priv(ndev); in w5100_mmio()
205 static inline int w5100_read_direct(struct net_device *ndev, u32 addr) in w5100_read_direct() argument
207 return ioread8(w5100_mmio(ndev) + (addr << CONFIG_WIZNET_BUS_SHIFT)); in w5100_read_direct()
210 static inline int __w5100_write_direct(struct net_device *ndev, u32 addr, in __w5100_write_direct() argument
213 iowrite8(data, w5100_mmio(ndev) + (addr << CONFIG_WIZNET_BUS_SHIFT)); in __w5100_write_direct()
218 static inline int w5100_write_direct(struct net_device *ndev, u32 addr, u8 data) in w5100_write_direct() argument
220 __w5100_write_direct(ndev, addr, data); in w5100_write_direct()
225 static int w5100_read16_direct(struct net_device *ndev, u32 addr) in w5100_read16_direct() argument
228 data = w5100_read_direct(ndev, addr) << 8; in w5100_read16_direct()
229 data |= w5100_read_direct(ndev, addr + 1); in w5100_read16_direct()
233 static int w5100_write16_direct(struct net_device *ndev, u32 addr, u16 data) in w5100_write16_direct() argument
235 __w5100_write_direct(ndev, addr, data >> 8); in w5100_write16_direct()
236 __w5100_write_direct(ndev, addr + 1, data); in w5100_write16_direct()
241 static int w5100_readbulk_direct(struct net_device *ndev, u32 addr, u8 *buf, in w5100_readbulk_direct() argument
247 *buf++ = w5100_read_direct(ndev, addr); in w5100_readbulk_direct()
252 static int w5100_writebulk_direct(struct net_device *ndev, u32 addr, in w5100_writebulk_direct() argument
258 __w5100_write_direct(ndev, addr, *buf++); in w5100_writebulk_direct()
263 static int w5100_mmio_init(struct net_device *ndev) in w5100_mmio_init() argument
265 struct platform_device *pdev = to_platform_device(ndev->dev.parent); in w5100_mmio_init()
266 struct w5100_mmio_priv *mmio_priv = w5100_mmio_priv(ndev); in w5100_mmio_init()
299 static int w5100_read_indirect(struct net_device *ndev, u32 addr) in w5100_read_indirect() argument
301 struct w5100_mmio_priv *mmio_priv = w5100_mmio_priv(ndev); in w5100_read_indirect()
306 w5100_write16_direct(ndev, W5100_IDM_AR, addr); in w5100_read_indirect()
307 data = w5100_read_direct(ndev, W5100_IDM_DR); in w5100_read_indirect()
313 static int w5100_write_indirect(struct net_device *ndev, u32 addr, u8 data) in w5100_write_indirect() argument
315 struct w5100_mmio_priv *mmio_priv = w5100_mmio_priv(ndev); in w5100_write_indirect()
319 w5100_write16_direct(ndev, W5100_IDM_AR, addr); in w5100_write_indirect()
320 w5100_write_direct(ndev, W5100_IDM_DR, data); in w5100_write_indirect()
326 static int w5100_read16_indirect(struct net_device *ndev, u32 addr) in w5100_read16_indirect() argument
328 struct w5100_mmio_priv *mmio_priv = w5100_mmio_priv(ndev); in w5100_read16_indirect()
333 w5100_write16_direct(ndev, W5100_IDM_AR, addr); in w5100_read16_indirect()
334 data = w5100_read_direct(ndev, W5100_IDM_DR) << 8; in w5100_read16_indirect()
335 data |= w5100_read_direct(ndev, W5100_IDM_DR); in w5100_read16_indirect()
341 static int w5100_write16_indirect(struct net_device *ndev, u32 addr, u16 data) in w5100_write16_indirect() argument
343 struct w5100_mmio_priv *mmio_priv = w5100_mmio_priv(ndev); in w5100_write16_indirect()
347 w5100_write16_direct(ndev, W5100_IDM_AR, addr); in w5100_write16_indirect()
348 __w5100_write_direct(ndev, W5100_IDM_DR, data >> 8); in w5100_write16_indirect()
349 w5100_write_direct(ndev, W5100_IDM_DR, data); in w5100_write16_indirect()
355 static int w5100_readbulk_indirect(struct net_device *ndev, u32 addr, u8 *buf, in w5100_readbulk_indirect() argument
358 struct w5100_mmio_priv *mmio_priv = w5100_mmio_priv(ndev); in w5100_readbulk_indirect()
363 w5100_write16_direct(ndev, W5100_IDM_AR, addr); in w5100_readbulk_indirect()
366 *buf++ = w5100_read_direct(ndev, W5100_IDM_DR); in w5100_readbulk_indirect()
373 static int w5100_writebulk_indirect(struct net_device *ndev, u32 addr, in w5100_writebulk_indirect() argument
376 struct w5100_mmio_priv *mmio_priv = w5100_mmio_priv(ndev); in w5100_writebulk_indirect()
381 w5100_write16_direct(ndev, W5100_IDM_AR, addr); in w5100_writebulk_indirect()
384 __w5100_write_direct(ndev, W5100_IDM_DR, *buf++); in w5100_writebulk_indirect()
391 static int w5100_reset_indirect(struct net_device *ndev) in w5100_reset_indirect() argument
393 w5100_write_direct(ndev, W5100_MR, MR_RST); in w5100_reset_indirect()
395 w5100_write_direct(ndev, W5100_MR, MR_PB | MR_AI | MR_IND); in w5100_reset_indirect()
416 return w5100_read_direct(priv->ndev, addr); in w5100_read()
421 return w5100_write_direct(priv->ndev, addr, data); in w5100_write()
426 return w5100_read16_direct(priv->ndev, addr); in w5100_read16()
431 return w5100_write16_direct(priv->ndev, addr, data); in w5100_write16()
436 return w5100_readbulk_direct(priv->ndev, addr, buf, len); in w5100_readbulk()
442 return w5100_writebulk_direct(priv->ndev, addr, buf, len); in w5100_writebulk()
449 return w5100_read_indirect(priv->ndev, addr); in w5100_read()
454 return w5100_write_indirect(priv->ndev, addr, data); in w5100_write()
459 return w5100_read16_indirect(priv->ndev, addr); in w5100_read16()
464 return w5100_write16_indirect(priv->ndev, addr, data); in w5100_write16()
469 return w5100_readbulk_indirect(priv->ndev, addr, buf, len); in w5100_readbulk()
475 return w5100_writebulk_indirect(priv->ndev, addr, buf, len); in w5100_writebulk()
482 return priv->ops->read(priv->ndev, addr); in w5100_read()
487 return priv->ops->write(priv->ndev, addr, data); in w5100_write()
492 return priv->ops->read16(priv->ndev, addr); in w5100_read16()
497 return priv->ops->write16(priv->ndev, addr, data); in w5100_write16()
502 return priv->ops->readbulk(priv->ndev, addr, buf, len); in w5100_readbulk()
508 return priv->ops->writebulk(priv->ndev, addr, buf, len); in w5100_writebulk()
563 return priv->ops->reset(priv->ndev); in w5100_reset()
591 struct net_device *ndev = priv->ndev; in w5100_write_macaddr() local
593 w5100_writebulk(priv, W5100_SHAR, ndev->dev_addr, ETH_ALEN); in w5100_write_macaddr()
719 static void w5100_get_drvinfo(struct net_device *ndev, in w5100_get_drvinfo() argument
724 strlcpy(info->bus_info, dev_name(ndev->dev.parent), in w5100_get_drvinfo()
728 static u32 w5100_get_link(struct net_device *ndev) in w5100_get_link() argument
730 struct w5100_priv *priv = netdev_priv(ndev); in w5100_get_link()
738 static u32 w5100_get_msglevel(struct net_device *ndev) in w5100_get_msglevel() argument
740 struct w5100_priv *priv = netdev_priv(ndev); in w5100_get_msglevel()
745 static void w5100_set_msglevel(struct net_device *ndev, u32 value) in w5100_set_msglevel() argument
747 struct w5100_priv *priv = netdev_priv(ndev); in w5100_set_msglevel()
752 static int w5100_get_regs_len(struct net_device *ndev) in w5100_get_regs_len() argument
757 static void w5100_get_regs(struct net_device *ndev, in w5100_get_regs() argument
760 struct w5100_priv *priv = netdev_priv(ndev); in w5100_get_regs()
768 static void w5100_restart(struct net_device *ndev) in w5100_restart() argument
770 struct w5100_priv *priv = netdev_priv(ndev); in w5100_restart()
772 netif_stop_queue(ndev); in w5100_restart()
775 ndev->stats.tx_errors++; in w5100_restart()
776 netif_trans_update(ndev); in w5100_restart()
777 netif_wake_queue(ndev); in w5100_restart()
785 w5100_restart(priv->ndev); in w5100_restart_work()
788 static void w5100_tx_timeout(struct net_device *ndev, unsigned int txqueue) in w5100_tx_timeout() argument
790 struct w5100_priv *priv = netdev_priv(ndev); in w5100_tx_timeout()
795 w5100_restart(ndev); in w5100_tx_timeout()
798 static void w5100_tx_skb(struct net_device *ndev, struct sk_buff *skb) in w5100_tx_skb() argument
800 struct w5100_priv *priv = netdev_priv(ndev); in w5100_tx_skb()
806 ndev->stats.tx_bytes += skb->len; in w5100_tx_skb()
807 ndev->stats.tx_packets++; in w5100_tx_skb()
823 w5100_tx_skb(priv->ndev, skb); in w5100_tx_work()
826 static netdev_tx_t w5100_start_tx(struct sk_buff *skb, struct net_device *ndev) in w5100_start_tx() argument
828 struct w5100_priv *priv = netdev_priv(ndev); in w5100_start_tx()
830 netif_stop_queue(ndev); in w5100_start_tx()
837 w5100_tx_skb(ndev, skb); in w5100_start_tx()
843 static struct sk_buff *w5100_rx_skb(struct net_device *ndev) in w5100_rx_skb() argument
845 struct w5100_priv *priv = netdev_priv(ndev); in w5100_rx_skb()
859 skb = netdev_alloc_skb_ip_align(ndev, rx_len); in w5100_rx_skb()
863 ndev->stats.rx_dropped++; in w5100_rx_skb()
871 skb->protocol = eth_type_trans(skb, ndev); in w5100_rx_skb()
873 ndev->stats.rx_packets++; in w5100_rx_skb()
874 ndev->stats.rx_bytes += rx_len; in w5100_rx_skb()
885 while ((skb = w5100_rx_skb(priv->ndev))) in w5100_rx_work()
897 struct sk_buff *skb = w5100_rx_skb(priv->ndev); in w5100_napi_poll()
915 struct net_device *ndev = ndev_instance; in w5100_interrupt() local
916 struct w5100_priv *priv = netdev_priv(ndev); in w5100_interrupt()
924 netif_dbg(priv, tx_done, ndev, "tx done\n"); in w5100_interrupt()
925 netif_wake_queue(ndev); in w5100_interrupt()
942 struct net_device *ndev = ndev_instance; in w5100_detect_link() local
943 struct w5100_priv *priv = netdev_priv(ndev); in w5100_detect_link()
945 if (netif_running(ndev)) { in w5100_detect_link()
947 netif_info(priv, link, ndev, "link is up\n"); in w5100_detect_link()
948 netif_carrier_on(ndev); in w5100_detect_link()
950 netif_info(priv, link, ndev, "link is down\n"); in w5100_detect_link()
951 netif_carrier_off(ndev); in w5100_detect_link()
966 static void w5100_set_rx_mode(struct net_device *ndev) in w5100_set_rx_mode() argument
968 struct w5100_priv *priv = netdev_priv(ndev); in w5100_set_rx_mode()
969 bool set_promisc = (ndev->flags & IFF_PROMISC) != 0; in w5100_set_rx_mode()
981 static int w5100_set_macaddr(struct net_device *ndev, void *addr) in w5100_set_macaddr() argument
983 struct w5100_priv *priv = netdev_priv(ndev); in w5100_set_macaddr()
988 eth_hw_addr_set(ndev, sock_addr->sa_data); in w5100_set_macaddr()
993 static int w5100_open(struct net_device *ndev) in w5100_open() argument
995 struct w5100_priv *priv = netdev_priv(ndev); in w5100_open()
997 netif_info(priv, ifup, ndev, "enabling\n"); in w5100_open()
1000 netif_start_queue(ndev); in w5100_open()
1003 netif_carrier_on(ndev); in w5100_open()
1007 static int w5100_stop(struct net_device *ndev) in w5100_stop() argument
1009 struct w5100_priv *priv = netdev_priv(ndev); in w5100_stop()
1011 netif_info(priv, ifdown, ndev, "shutting down\n"); in w5100_stop()
1013 netif_carrier_off(ndev); in w5100_stop()
1014 netif_stop_queue(ndev); in w5100_stop()
1072 void *w5100_ops_priv(const struct net_device *ndev) in w5100_ops_priv() argument
1074 return netdev_priv(ndev) + in w5100_ops_priv()
1084 struct net_device *ndev; in w5100_probe() local
1095 ndev = alloc_etherdev(alloc_size); in w5100_probe()
1096 if (!ndev) in w5100_probe()
1098 SET_NETDEV_DEV(ndev, dev); in w5100_probe()
1099 dev_set_drvdata(dev, ndev); in w5100_probe()
1100 priv = netdev_priv(ndev); in w5100_probe()
1129 priv->ndev = ndev; in w5100_probe()
1134 ndev->netdev_ops = &w5100_netdev_ops; in w5100_probe()
1135 ndev->ethtool_ops = &w5100_ethtool_ops; in w5100_probe()
1136 netif_napi_add(ndev, &priv->napi, w5100_napi_poll, 16); in w5100_probe()
1141 ndev->features |= NETIF_F_VLAN_CHALLENGED; in w5100_probe()
1143 err = register_netdev(ndev); in w5100_probe()
1148 netdev_name(ndev)); in w5100_probe()
1160 eth_hw_addr_set(ndev, mac_addr); in w5100_probe()
1162 eth_hw_addr_random(ndev); in w5100_probe()
1165 err = priv->ops->init(priv->ndev); in w5100_probe()
1177 netdev_name(ndev), ndev); in w5100_probe()
1180 IRQF_TRIGGER_LOW, netdev_name(ndev), ndev); in w5100_probe()
1192 snprintf(link_name, 16, "%s-link", netdev_name(ndev)); in w5100_probe()
1197 link_name, priv->ndev) < 0) in w5100_probe()
1204 free_irq(priv->irq, ndev); in w5100_probe()
1208 unregister_netdev(ndev); in w5100_probe()
1210 free_netdev(ndev); in w5100_probe()
1217 struct net_device *ndev = dev_get_drvdata(dev); in w5100_remove() local
1218 struct w5100_priv *priv = netdev_priv(ndev); in w5100_remove()
1221 free_irq(priv->irq, ndev); in w5100_remove()
1223 free_irq(priv->link_irq, ndev); in w5100_remove()
1229 unregister_netdev(ndev); in w5100_remove()
1230 free_netdev(ndev); in w5100_remove()
1237 struct net_device *ndev = dev_get_drvdata(dev); in w5100_suspend() local
1238 struct w5100_priv *priv = netdev_priv(ndev); in w5100_suspend()
1240 if (netif_running(ndev)) { in w5100_suspend()
1241 netif_carrier_off(ndev); in w5100_suspend()
1242 netif_device_detach(ndev); in w5100_suspend()
1251 struct net_device *ndev = dev_get_drvdata(dev); in w5100_resume() local
1252 struct w5100_priv *priv = netdev_priv(ndev); in w5100_resume()
1254 if (netif_running(ndev)) { in w5100_resume()
1258 netif_device_attach(ndev); in w5100_resume()
1261 netif_carrier_on(ndev); in w5100_resume()