Lines Matching refs:ndev
75 struct net_device *ndev; member
85 struct net_device *ndev = data; in ntb_netdev_event_handler() local
86 struct ntb_netdev *dev = netdev_priv(ndev); in ntb_netdev_event_handler()
88 netdev_dbg(ndev, "Event %x, Link %x\n", link_is_up, in ntb_netdev_event_handler()
93 netif_carrier_on(ndev); in ntb_netdev_event_handler()
95 netif_carrier_off(ndev); in ntb_netdev_event_handler()
102 struct net_device *ndev = qp_data; in ntb_netdev_rx_handler() local
110 netdev_dbg(ndev, "%s: %d byte payload received\n", __func__, len); in ntb_netdev_rx_handler()
113 ndev->stats.rx_errors++; in ntb_netdev_rx_handler()
114 ndev->stats.rx_length_errors++; in ntb_netdev_rx_handler()
119 skb->protocol = eth_type_trans(skb, ndev); in ntb_netdev_rx_handler()
123 ndev->stats.rx_errors++; in ntb_netdev_rx_handler()
124 ndev->stats.rx_dropped++; in ntb_netdev_rx_handler()
126 ndev->stats.rx_packets++; in ntb_netdev_rx_handler()
127 ndev->stats.rx_bytes += len; in ntb_netdev_rx_handler()
130 skb = netdev_alloc_skb(ndev, ndev->mtu + ETH_HLEN); in ntb_netdev_rx_handler()
132 ndev->stats.rx_errors++; in ntb_netdev_rx_handler()
133 ndev->stats.rx_frame_errors++; in ntb_netdev_rx_handler()
138 rc = ntb_transport_rx_enqueue(qp, skb, skb->data, ndev->mtu + ETH_HLEN); in ntb_netdev_rx_handler()
141 ndev->stats.rx_errors++; in ntb_netdev_rx_handler()
142 ndev->stats.rx_fifo_errors++; in ntb_netdev_rx_handler()
166 static int ntb_netdev_maybe_stop_tx(struct net_device *ndev, in ntb_netdev_maybe_stop_tx() argument
169 if (netif_queue_stopped(ndev) || in ntb_netdev_maybe_stop_tx()
173 return __ntb_netdev_maybe_stop_tx(ndev, qp, size); in ntb_netdev_maybe_stop_tx()
179 struct net_device *ndev = qp_data; in ntb_netdev_tx_handler() local
181 struct ntb_netdev *dev = netdev_priv(ndev); in ntb_netdev_tx_handler()
184 if (!skb || !ndev) in ntb_netdev_tx_handler()
188 ndev->stats.tx_packets++; in ntb_netdev_tx_handler()
189 ndev->stats.tx_bytes += skb->len; in ntb_netdev_tx_handler()
191 ndev->stats.tx_errors++; in ntb_netdev_tx_handler()
192 ndev->stats.tx_aborted_errors++; in ntb_netdev_tx_handler()
202 if (netif_queue_stopped(ndev)) in ntb_netdev_tx_handler()
203 netif_wake_queue(ndev); in ntb_netdev_tx_handler()
208 struct net_device *ndev) in ntb_netdev_start_xmit() argument
210 struct ntb_netdev *dev = netdev_priv(ndev); in ntb_netdev_start_xmit()
213 ntb_netdev_maybe_stop_tx(ndev, dev->qp, tx_stop); in ntb_netdev_start_xmit()
220 ntb_netdev_maybe_stop_tx(ndev, dev->qp, tx_stop); in ntb_netdev_start_xmit()
225 ndev->stats.tx_dropped++; in ntb_netdev_start_xmit()
226 ndev->stats.tx_errors++; in ntb_netdev_start_xmit()
233 struct net_device *ndev = dev->ndev; in ntb_netdev_tx_timer() local
242 if (netif_queue_stopped(ndev)) in ntb_netdev_tx_timer()
243 netif_wake_queue(ndev); in ntb_netdev_tx_timer()
247 static int ntb_netdev_open(struct net_device *ndev) in ntb_netdev_open() argument
249 struct ntb_netdev *dev = netdev_priv(ndev); in ntb_netdev_open()
255 skb = netdev_alloc_skb(ndev, ndev->mtu + ETH_HLEN); in ntb_netdev_open()
262 ndev->mtu + ETH_HLEN); in ntb_netdev_open()
271 netif_carrier_off(ndev); in ntb_netdev_open()
273 netif_start_queue(ndev); in ntb_netdev_open()
283 static int ntb_netdev_close(struct net_device *ndev) in ntb_netdev_close() argument
285 struct ntb_netdev *dev = netdev_priv(ndev); in ntb_netdev_close()
299 static int ntb_netdev_change_mtu(struct net_device *ndev, int new_mtu) in ntb_netdev_change_mtu() argument
301 struct ntb_netdev *dev = netdev_priv(ndev); in ntb_netdev_change_mtu()
308 if (!netif_running(ndev)) { in ntb_netdev_change_mtu()
309 ndev->mtu = new_mtu; in ntb_netdev_change_mtu()
316 if (ndev->mtu < new_mtu) { in ntb_netdev_change_mtu()
323 skb = netdev_alloc_skb(ndev, new_mtu + ETH_HLEN); in ntb_netdev_change_mtu()
338 ndev->mtu = new_mtu; in ntb_netdev_change_mtu()
350 netdev_err(ndev, "Error changing MTU, device inoperable\n"); in ntb_netdev_change_mtu()
362 static void ntb_get_drvinfo(struct net_device *ndev, in ntb_get_drvinfo() argument
365 struct ntb_netdev *dev = netdev_priv(ndev); in ntb_get_drvinfo()
404 struct net_device *ndev; in ntb_netdev_probe() local
414 ndev = alloc_etherdev(sizeof(*dev)); in ntb_netdev_probe()
415 if (!ndev) in ntb_netdev_probe()
418 SET_NETDEV_DEV(ndev, client_dev); in ntb_netdev_probe()
420 dev = netdev_priv(ndev); in ntb_netdev_probe()
421 dev->ndev = ndev; in ntb_netdev_probe()
423 ndev->features = NETIF_F_HIGHDMA; in ntb_netdev_probe()
425 ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; in ntb_netdev_probe()
427 ndev->hw_features = ndev->features; in ntb_netdev_probe()
428 ndev->watchdog_timeo = msecs_to_jiffies(NTB_TX_TIMEOUT_MS); in ntb_netdev_probe()
430 eth_random_addr(ndev->perm_addr); in ntb_netdev_probe()
431 memcpy(ndev->dev_addr, ndev->perm_addr, ndev->addr_len); in ntb_netdev_probe()
433 ndev->netdev_ops = &ntb_netdev_ops; in ntb_netdev_probe()
434 ndev->ethtool_ops = &ntb_ethtool_ops; in ntb_netdev_probe()
436 ndev->min_mtu = 0; in ntb_netdev_probe()
437 ndev->max_mtu = ETH_MAX_MTU; in ntb_netdev_probe()
439 dev->qp = ntb_transport_create_queue(ndev, client_dev, in ntb_netdev_probe()
446 ndev->mtu = ntb_transport_max_size(dev->qp) - ETH_HLEN; in ntb_netdev_probe()
448 rc = register_netdev(ndev); in ntb_netdev_probe()
452 dev_set_drvdata(client_dev, ndev); in ntb_netdev_probe()
453 dev_info(&pdev->dev, "%s created\n", ndev->name); in ntb_netdev_probe()
459 free_netdev(ndev); in ntb_netdev_probe()
465 struct net_device *ndev = dev_get_drvdata(client_dev); in ntb_netdev_remove() local
466 struct ntb_netdev *dev = netdev_priv(ndev); in ntb_netdev_remove()
468 unregister_netdev(ndev); in ntb_netdev_remove()
470 free_netdev(ndev); in ntb_netdev_remove()