Lines Matching defs:ndev

42 static inline void moxart_emac_write(struct net_device *ndev,
45 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
50 static void moxart_update_mac_address(struct net_device *ndev)
52 moxart_emac_write(ndev, REG_MAC_MS_ADDRESS,
53 ((ndev->dev_addr[0] << 8) | (ndev->dev_addr[1])));
54 moxart_emac_write(ndev, REG_MAC_MS_ADDRESS + 4,
55 ((ndev->dev_addr[2] << 24) |
56 (ndev->dev_addr[3] << 16) |
57 (ndev->dev_addr[4] << 8) |
58 (ndev->dev_addr[5])));
61 static int moxart_set_mac_address(struct net_device *ndev, void *addr)
65 eth_hw_addr_set(ndev, address->sa_data);
66 moxart_update_mac_address(ndev);
71 static void moxart_mac_free_memory(struct net_device *ndev)
73 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
89 static void moxart_mac_reset(struct net_device *ndev)
91 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
102 static void moxart_mac_enable(struct net_device *ndev)
104 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
117 static void moxart_mac_setup_desc_ring(struct net_device *ndev)
119 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
147 netdev_err(ndev, "DMA mapping error\n");
163 static int moxart_mac_open(struct net_device *ndev)
165 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
169 moxart_mac_reset(ndev);
170 moxart_update_mac_address(ndev);
171 moxart_mac_setup_desc_ring(ndev);
172 moxart_mac_enable(ndev);
173 netif_start_queue(ndev);
175 netdev_dbg(ndev, "%s: IMR=0x%x, MACCR=0x%x\n",
182 static int moxart_mac_stop(struct net_device *ndev)
184 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
189 netif_stop_queue(ndev);
210 struct net_device *ndev = priv->ndev;
228 ndev->stats.rx_dropped++;
229 ndev->stats.rx_errors++;
241 skb = netdev_alloc_skb_ip_align(ndev, len);
245 ndev->stats.rx_dropped++;
246 ndev->stats.rx_errors++;
252 skb->protocol = eth_type_trans(skb, ndev);
256 ndev->stats.rx_packets++;
257 ndev->stats.rx_bytes += len;
259 ndev->stats.multicast++;
278 static int moxart_tx_queue_space(struct net_device *ndev)
280 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
285 static void moxart_tx_finished(struct net_device *ndev)
287 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
295 ndev->stats.tx_packets++;
296 ndev->stats.tx_bytes += priv->tx_skb[tx_tail]->len;
304 if (netif_queue_stopped(ndev) &&
305 moxart_tx_queue_space(ndev) >= TX_WAKE_THRESHOLD)
306 netif_wake_queue(ndev);
311 struct net_device *ndev = (struct net_device *)dev_id;
312 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
316 moxart_tx_finished(ndev);
330 struct net_device *ndev)
332 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
344 if (moxart_tx_queue_space(ndev) == 1)
345 netif_stop_queue(ndev);
349 ndev->stats.tx_dropped++;
359 netdev_err(ndev, "DMA mapping error\n");
392 netif_trans_update(ndev);
400 static void moxart_mac_setmulticast(struct net_device *ndev)
402 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
406 netdev_for_each_mc_addr(ha, ndev) {
421 static void moxart_mac_set_rx_mode(struct net_device *ndev)
423 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
427 (ndev->flags & IFF_PROMISC) ? (priv->reg_maccr |= RCV_ALL) :
430 (ndev->flags & IFF_ALLMULTI) ? (priv->reg_maccr |= RX_MULTIPKT) :
433 if ((ndev->flags & IFF_MULTICAST) && netdev_mc_count(ndev)) {
435 moxart_mac_setmulticast(ndev);
458 struct net_device *ndev;
464 ndev = alloc_etherdev(sizeof(struct moxart_mac_priv_t));
465 if (!ndev)
470 netdev_err(ndev, "irq_of_parse_and_map failed\n");
475 priv = netdev_priv(ndev);
476 priv->ndev = ndev;
484 ndev->base_addr = res->start;
486 ret = platform_get_ethdev_address(p_dev, ndev);
490 eth_hw_addr_random(ndev);
491 moxart_update_mac_address(ndev);
528 platform_set_drvdata(pdev, ndev);
531 pdev->name, ndev);
533 netdev_err(ndev, "devm_request_irq failed\n");
537 ndev->netdev_ops = &moxart_netdev_ops;
538 netif_napi_add_weight(ndev, &priv->napi, moxart_rx_poll, RX_DESC_NUM);
539 ndev->priv_flags |= IFF_UNICAST_FLT;
540 ndev->irq = irq;
542 SET_NETDEV_DEV(ndev, &pdev->dev);
544 ret = register_netdev(ndev);
548 netdev_dbg(ndev, "%s: IRQ=%d address=%pM\n",
549 __func__, ndev->irq, ndev->dev_addr);
554 netdev_err(ndev, "init failed\n");
555 moxart_mac_free_memory(ndev);
557 free_netdev(ndev);
563 struct net_device *ndev = platform_get_drvdata(pdev);
565 unregister_netdev(ndev);
566 devm_free_irq(&pdev->dev, ndev->irq, ndev);
567 moxart_mac_free_memory(ndev);
568 free_netdev(ndev);