Lines Matching refs:ndev
64 struct net_device *ndev; member
75 struct net_device *ndev = data; in ntb_netdev_event_handler() local
76 struct ntb_netdev *dev = netdev_priv(ndev); in ntb_netdev_event_handler()
78 netdev_dbg(ndev, "Event %x, Link %x\n", status, in ntb_netdev_event_handler()
83 netif_carrier_off(ndev); in ntb_netdev_event_handler()
89 netif_carrier_on(ndev); in ntb_netdev_event_handler()
92 netdev_warn(ndev, "Unsupported event type %d\n", status); in ntb_netdev_event_handler()
99 struct net_device *ndev = qp_data; in ntb_netdev_rx_handler() local
107 netdev_dbg(ndev, "%s: %d byte payload received\n", __func__, len); in ntb_netdev_rx_handler()
110 skb->protocol = eth_type_trans(skb, ndev); in ntb_netdev_rx_handler()
114 ndev->stats.rx_errors++; in ntb_netdev_rx_handler()
115 ndev->stats.rx_dropped++; in ntb_netdev_rx_handler()
117 ndev->stats.rx_packets++; in ntb_netdev_rx_handler()
118 ndev->stats.rx_bytes += len; in ntb_netdev_rx_handler()
121 skb = netdev_alloc_skb(ndev, ndev->mtu + ETH_HLEN); in ntb_netdev_rx_handler()
123 ndev->stats.rx_errors++; in ntb_netdev_rx_handler()
124 ndev->stats.rx_frame_errors++; in ntb_netdev_rx_handler()
128 rc = ntb_transport_rx_enqueue(qp, skb, skb->data, ndev->mtu + ETH_HLEN); in ntb_netdev_rx_handler()
131 ndev->stats.rx_errors++; in ntb_netdev_rx_handler()
132 ndev->stats.rx_fifo_errors++; in ntb_netdev_rx_handler()
139 struct net_device *ndev = qp_data; in ntb_netdev_tx_handler() local
143 if (!skb || !ndev) in ntb_netdev_tx_handler()
147 ndev->stats.tx_packets++; in ntb_netdev_tx_handler()
148 ndev->stats.tx_bytes += skb->len; in ntb_netdev_tx_handler()
150 ndev->stats.tx_errors++; in ntb_netdev_tx_handler()
151 ndev->stats.tx_aborted_errors++; in ntb_netdev_tx_handler()
158 struct net_device *ndev) in ntb_netdev_start_xmit() argument
160 struct ntb_netdev *dev = netdev_priv(ndev); in ntb_netdev_start_xmit()
163 netdev_dbg(ndev, "%s: skb len %d\n", __func__, skb->len); in ntb_netdev_start_xmit()
172 ndev->stats.tx_dropped++; in ntb_netdev_start_xmit()
173 ndev->stats.tx_errors++; in ntb_netdev_start_xmit()
177 static int ntb_netdev_open(struct net_device *ndev) in ntb_netdev_open() argument
179 struct ntb_netdev *dev = netdev_priv(ndev); in ntb_netdev_open()
185 skb = netdev_alloc_skb(ndev, ndev->mtu + ETH_HLEN); in ntb_netdev_open()
192 ndev->mtu + ETH_HLEN); in ntb_netdev_open()
199 netif_carrier_off(ndev); in ntb_netdev_open()
210 static int ntb_netdev_close(struct net_device *ndev) in ntb_netdev_close() argument
212 struct ntb_netdev *dev = netdev_priv(ndev); in ntb_netdev_close()
224 static int ntb_netdev_change_mtu(struct net_device *ndev, int new_mtu) in ntb_netdev_change_mtu() argument
226 struct ntb_netdev *dev = netdev_priv(ndev); in ntb_netdev_change_mtu()
233 if (!netif_running(ndev)) { in ntb_netdev_change_mtu()
234 ndev->mtu = new_mtu; in ntb_netdev_change_mtu()
241 if (ndev->mtu < new_mtu) { in ntb_netdev_change_mtu()
248 skb = netdev_alloc_skb(ndev, new_mtu + ETH_HLEN); in ntb_netdev_change_mtu()
263 ndev->mtu = new_mtu; in ntb_netdev_change_mtu()
275 netdev_err(ndev, "Error changing MTU, device inoperable\n"); in ntb_netdev_change_mtu()
287 static void ntb_get_drvinfo(struct net_device *ndev, in ntb_get_drvinfo() argument
290 struct ntb_netdev *dev = netdev_priv(ndev); in ntb_get_drvinfo()
327 struct net_device *ndev; in ntb_netdev_probe() local
331 ndev = alloc_etherdev(sizeof(struct ntb_netdev)); in ntb_netdev_probe()
332 if (!ndev) in ntb_netdev_probe()
335 dev = netdev_priv(ndev); in ntb_netdev_probe()
336 dev->ndev = ndev; in ntb_netdev_probe()
339 ndev->features = NETIF_F_HIGHDMA; in ntb_netdev_probe()
341 ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; in ntb_netdev_probe()
343 ndev->hw_features = ndev->features; in ntb_netdev_probe()
344 ndev->watchdog_timeo = msecs_to_jiffies(NTB_TX_TIMEOUT_MS); in ntb_netdev_probe()
346 random_ether_addr(ndev->perm_addr); in ntb_netdev_probe()
347 memcpy(ndev->dev_addr, ndev->perm_addr, ndev->addr_len); in ntb_netdev_probe()
349 ndev->netdev_ops = &ntb_netdev_ops; in ntb_netdev_probe()
350 ndev->ethtool_ops = &ntb_ethtool_ops; in ntb_netdev_probe()
352 dev->qp = ntb_transport_create_queue(ndev, pdev, &ntb_netdev_handlers); in ntb_netdev_probe()
358 ndev->mtu = ntb_transport_max_size(dev->qp) - ETH_HLEN; in ntb_netdev_probe()
360 rc = register_netdev(ndev); in ntb_netdev_probe()
365 dev_info(&pdev->dev, "%s created\n", ndev->name); in ntb_netdev_probe()
371 free_netdev(ndev); in ntb_netdev_probe()
377 struct net_device *ndev; in ntb_netdev_remove() local
392 ndev = dev->ndev; in ntb_netdev_remove()
394 unregister_netdev(ndev); in ntb_netdev_remove()
396 free_netdev(ndev); in ntb_netdev_remove()