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)
68 memcpy(ndev->dev_addr, address->sa_data, ndev->addr_len);
69 moxart_update_mac_address(ndev);
74 static void moxart_mac_free_memory(struct net_device *ndev)
76 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
92 static void moxart_mac_reset(struct net_device *ndev)
94 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
105 static void moxart_mac_enable(struct net_device *ndev)
107 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
120 static void moxart_mac_setup_desc_ring(struct net_device *ndev)
122 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
150 netdev_err(ndev, "DMA mapping error\n");
166 static int moxart_mac_open(struct net_device *ndev)
168 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
170 if (!is_valid_ether_addr(ndev->dev_addr))
175 moxart_mac_reset(ndev);
176 moxart_update_mac_address(ndev);
177 moxart_mac_setup_desc_ring(ndev);
178 moxart_mac_enable(ndev);
179 netif_start_queue(ndev);
181 netdev_dbg(ndev, "%s: IMR=0x%x, MACCR=0x%x\n",
188 static int moxart_mac_stop(struct net_device *ndev)
190 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
195 netif_stop_queue(ndev);
216 struct net_device *ndev = priv->ndev;
234 ndev->stats.rx_dropped++;
235 ndev->stats.rx_errors++;
247 skb = netdev_alloc_skb_ip_align(ndev, len);
251 ndev->stats.rx_dropped++;
252 ndev->stats.rx_errors++;
258 skb->protocol = eth_type_trans(skb, ndev);
262 ndev->stats.rx_packets++;
263 ndev->stats.rx_bytes += len;
265 ndev->stats.multicast++;
284 static int moxart_tx_queue_space(struct net_device *ndev)
286 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
291 static void moxart_tx_finished(struct net_device *ndev)
293 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
301 ndev->stats.tx_packets++;
302 ndev->stats.tx_bytes += priv->tx_skb[tx_tail]->len;
310 if (netif_queue_stopped(ndev) &&
311 moxart_tx_queue_space(ndev) >= TX_WAKE_THRESHOLD)
312 netif_wake_queue(ndev);
317 struct net_device *ndev = (struct net_device *)dev_id;
318 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
322 moxart_tx_finished(ndev);
336 struct net_device *ndev)
338 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
350 if (moxart_tx_queue_space(ndev) == 1)
351 netif_stop_queue(ndev);
355 ndev->stats.tx_dropped++;
365 netdev_err(ndev, "DMA mapping error\n");
398 netif_trans_update(ndev);
406 static void moxart_mac_setmulticast(struct net_device *ndev)
408 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
412 netdev_for_each_mc_addr(ha, ndev) {
427 static void moxart_mac_set_rx_mode(struct net_device *ndev)
429 struct moxart_mac_priv_t *priv = netdev_priv(ndev);
433 (ndev->flags & IFF_PROMISC) ? (priv->reg_maccr |= RCV_ALL) :
436 (ndev->flags & IFF_ALLMULTI) ? (priv->reg_maccr |= RX_MULTIPKT) :
439 if ((ndev->flags & IFF_MULTICAST) && netdev_mc_count(ndev)) {
441 moxart_mac_setmulticast(ndev);
464 struct net_device *ndev;
470 ndev = alloc_etherdev(sizeof(struct moxart_mac_priv_t));
471 if (!ndev)
476 netdev_err(ndev, "irq_of_parse_and_map failed\n");
481 priv = netdev_priv(ndev);
482 priv->ndev = ndev;
491 ndev->base_addr = res->start;
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(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);