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