Lines Matching refs:dev

59 	struct net_device	*dev;
117 static int veth_get_link_ksettings(struct net_device *dev,
127 static void veth_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
133 static void veth_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
142 for (i = 0; i < dev->real_num_rx_queues; i++) {
150 for (i = 0; i < dev->real_num_tx_queues; i++) {
162 static int veth_get_sset_count(struct net_device *dev, int sset)
167 VETH_RQ_STATS_LEN * dev->real_num_rx_queues +
168 VETH_TQ_STATS_LEN * dev->real_num_tx_queues;
174 static void veth_get_ethtool_stats(struct net_device *dev,
177 struct veth_priv *rcv_priv, *priv = netdev_priv(dev);
183 for (i = 0; i < dev->real_num_rx_queues; i++) {
209 tx_idx += (i % dev->real_num_tx_queues) * VETH_TQ_STATS_LEN;
275 static int veth_forward_skb(struct net_device *dev, struct sk_buff *skb,
278 return __dev_forward_skb(dev, skb) ?: xdp ?
283 static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
285 struct veth_priv *rcv_priv, *priv = netdev_priv(dev);
310 dev_lstats_add(dev, length);
325 static u64 veth_stats_tx(struct net_device *dev, u64 *packets, u64 *bytes)
327 struct veth_priv *priv = netdev_priv(dev);
329 dev_lstats_read(dev, packets, bytes);
333 static void veth_stats_rx(struct veth_stats *result, struct net_device *dev)
335 struct veth_priv *priv = netdev_priv(dev);
343 for (i = 0; i < dev->num_rx_queues; i++) {
364 static void veth_get_stats64(struct net_device *dev,
367 struct veth_priv *priv = netdev_priv(dev);
372 tot->tx_dropped = veth_stats_tx(dev, &packets, &bytes);
376 veth_stats_rx(&rx, dev);
399 static void veth_set_multicast_list(struct net_device *dev)
418 static int veth_select_rxq(struct net_device *dev)
420 return smp_processor_id() % dev->real_num_rx_queues;
423 static struct net_device *veth_peer_dev(struct net_device *dev)
425 struct veth_priv *priv = netdev_priv(dev);
431 static int veth_xdp_xmit(struct net_device *dev, int n,
435 struct veth_priv *rcv_priv, *priv = netdev_priv(dev);
490 static int veth_ndo_xdp_xmit(struct net_device *dev, int n,
495 err = veth_xdp_xmit(dev, n, frames, flags, true);
497 struct veth_priv *priv = netdev_priv(dev);
509 sent = veth_xdp_xmit(rq->dev, bq->count, bq->q, 0, false);
516 trace_xdp_bulk_tx(rq->dev, sent, bq->count - sent, err);
528 struct veth_priv *rcv_priv, *priv = netdev_priv(rq->dev);
600 trace_xdp_exception(rq->dev, xdp_prog, act);
611 if (xdp_do_redirect(rq->dev, &xdp, xdp_prog)) {
623 trace_xdp_exception(rq->dev, xdp_prog, act);
642 skb->protocol = eth_type_trans(skb, rq->dev);
736 trace_xdp_exception(rq->dev, xdp_prog, act);
747 if (xdp_do_redirect(rq->dev, &xdp, xdp_prog)) {
758 trace_xdp_exception(rq->dev, xdp_prog, act);
779 skb->protocol = eth_type_trans(skb, rq->dev);
872 static int veth_napi_add(struct net_device *dev)
874 struct veth_priv *priv = netdev_priv(dev);
877 for (i = 0; i < dev->real_num_rx_queues; i++) {
885 for (i = 0; i < dev->real_num_rx_queues; i++) {
888 netif_napi_add(dev, &rq->xdp_napi, veth_poll, NAPI_POLL_WEIGHT);
900 static void veth_napi_del(struct net_device *dev)
902 struct veth_priv *priv = netdev_priv(dev);
905 for (i = 0; i < dev->real_num_rx_queues; i++) {
913 for (i = 0; i < dev->real_num_rx_queues; i++) {
921 static int veth_enable_xdp(struct net_device *dev)
923 struct veth_priv *priv = netdev_priv(dev);
927 for (i = 0; i < dev->real_num_rx_queues; i++) {
930 err = xdp_rxq_info_reg(&rq->xdp_rxq, dev, i);
944 err = veth_napi_add(dev);
949 for (i = 0; i < dev->real_num_rx_queues; i++)
962 static void veth_disable_xdp(struct net_device *dev)
964 struct veth_priv *priv = netdev_priv(dev);
967 for (i = 0; i < dev->real_num_rx_queues; i++)
969 veth_napi_del(dev);
970 for (i = 0; i < dev->real_num_rx_queues; i++) {
978 static int veth_open(struct net_device *dev)
980 struct veth_priv *priv = netdev_priv(dev);
988 err = veth_enable_xdp(dev);
994 netif_carrier_on(dev);
1001 static int veth_close(struct net_device *dev)
1003 struct veth_priv *priv = netdev_priv(dev);
1006 netif_carrier_off(dev);
1011 veth_disable_xdp(dev);
1021 static int veth_alloc_queues(struct net_device *dev)
1023 struct veth_priv *priv = netdev_priv(dev);
1026 priv->rq = kcalloc(dev->num_rx_queues, sizeof(*priv->rq), GFP_KERNEL);
1030 for (i = 0; i < dev->num_rx_queues; i++) {
1031 priv->rq[i].dev = dev;
1038 static void veth_free_queues(struct net_device *dev)
1040 struct veth_priv *priv = netdev_priv(dev);
1045 static int veth_dev_init(struct net_device *dev)
1049 dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats);
1050 if (!dev->lstats)
1053 err = veth_alloc_queues(dev);
1055 free_percpu(dev->lstats);
1062 static void veth_dev_free(struct net_device *dev)
1064 veth_free_queues(dev);
1065 free_percpu(dev->lstats);
1069 static void veth_poll_controller(struct net_device *dev)
1083 static int veth_get_iflink(const struct net_device *dev)
1085 struct veth_priv *priv = netdev_priv(dev);
1097 static netdev_features_t veth_fix_features(struct net_device *dev,
1100 struct veth_priv *priv = netdev_priv(dev);
1114 static void veth_set_rx_headroom(struct net_device *dev, int new_hr)
1116 struct veth_priv *peer_priv, *priv = netdev_priv(dev);
1130 dev->needed_headroom = new_hr;
1137 static int veth_xdp_set(struct net_device *dev, struct bpf_prog *prog,
1140 struct veth_priv *priv = netdev_priv(dev);
1166 if (dev->real_num_rx_queues < peer->real_num_tx_queues) {
1172 if (dev->flags & IFF_UP) {
1173 err = veth_enable_xdp(dev);
1188 if (dev->flags & IFF_UP)
1189 veth_disable_xdp(dev);
1209 static int veth_xdp(struct net_device *dev, struct netdev_bpf *xdp)
1213 return veth_xdp_set(dev, xdp->prog, xdp->extack);
1245 static void veth_setup(struct net_device *dev)
1247 ether_setup(dev);
1249 dev->priv_flags &= ~IFF_TX_SKB_SHARING;
1250 dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
1251 dev->priv_flags |= IFF_NO_QUEUE;
1252 dev->priv_flags |= IFF_PHONY_HEADROOM;
1254 dev->netdev_ops = &veth_netdev_ops;
1255 dev->ethtool_ops = &veth_ethtool_ops;
1256 dev->features |= NETIF_F_LLTX;
1257 dev->features |= VETH_FEATURES;
1258 dev->vlan_features = dev->features &
1263 dev->needs_free_netdev = true;
1264 dev->priv_destructor = veth_dev_free;
1265 dev->max_mtu = ETH_MAX_MTU;
1267 dev->hw_features = VETH_FEATURES;
1268 dev->hw_enc_features = VETH_FEATURES;
1269 dev->mpls_features = NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE;
1294 static int veth_newlink(struct net *src_net, struct net_device *dev,
1351 if (ifmp && (dev->ifindex != 0))
1354 peer->gso_max_size = dev->gso_max_size;
1355 peer->gso_max_segs = dev->gso_max_segs;
1370 * register dev last
1372 * note, that since we've registered new device the dev's name
1377 eth_hw_addr_random(dev);
1380 nla_strlcpy(dev->name, tb[IFLA_IFNAME], IFNAMSIZ);
1382 snprintf(dev->name, IFNAMSIZ, DRV_NAME "%%d");
1384 err = register_netdevice(dev);
1388 netif_carrier_off(dev);
1394 priv = netdev_priv(dev);
1398 rcu_assign_pointer(priv->peer, dev);
1413 static void veth_dellink(struct net_device *dev, struct list_head *head)
1418 priv = netdev_priv(dev);
1426 unregister_netdevice_queue(dev, head);
1439 static struct net *veth_get_link_net(const struct net_device *dev)
1441 struct veth_priv *priv = netdev_priv(dev);
1444 return peer ? dev_net(peer) : dev_net(dev);