Lines Matching refs:tap
144 static int tap_enable_queue(struct tap_dev *tap, struct file *file, in tap_enable_queue() argument
155 rcu_assign_pointer(tap->taps[tap->numvtaps], q); in tap_enable_queue()
156 q->queue_index = tap->numvtaps; in tap_enable_queue()
159 tap->numvtaps++; in tap_enable_queue()
165 static int tap_set_queue(struct tap_dev *tap, struct file *file, in tap_set_queue() argument
168 if (tap->numqueues == MAX_TAP_QUEUES) in tap_set_queue()
171 rcu_assign_pointer(q->tap, tap); in tap_set_queue()
172 rcu_assign_pointer(tap->taps[tap->numvtaps], q); in tap_set_queue()
176 q->queue_index = tap->numvtaps; in tap_set_queue()
179 list_add_tail(&q->next, &tap->queue_list); in tap_set_queue()
181 tap->numvtaps++; in tap_set_queue()
182 tap->numqueues++; in tap_set_queue()
189 struct tap_dev *tap; in tap_disable_queue() local
196 tap = rtnl_dereference(q->tap); in tap_disable_queue()
198 if (tap) { in tap_disable_queue()
200 BUG_ON(index >= tap->numvtaps); in tap_disable_queue()
201 nq = rtnl_dereference(tap->taps[tap->numvtaps - 1]); in tap_disable_queue()
204 rcu_assign_pointer(tap->taps[index], nq); in tap_disable_queue()
205 RCU_INIT_POINTER(tap->taps[tap->numvtaps - 1], NULL); in tap_disable_queue()
208 tap->numvtaps--; in tap_disable_queue()
224 struct tap_dev *tap; in tap_put_queue() local
227 tap = rtnl_dereference(q->tap); in tap_put_queue()
229 if (tap) { in tap_put_queue()
233 tap->numqueues--; in tap_put_queue()
234 RCU_INIT_POINTER(q->tap, NULL); in tap_put_queue()
252 static struct tap_queue *tap_get_queue(struct tap_dev *tap, in tap_get_queue() argument
261 int numvtaps = READ_ONCE(tap->numvtaps); in tap_get_queue()
273 queue = rcu_dereference(tap->taps[rxq % numvtaps]); in tap_get_queue()
283 queue = rcu_dereference(tap->taps[rxq]); in tap_get_queue()
288 queue = rcu_dereference(tap->taps[0]); in tap_get_queue()
298 void tap_del_queues(struct tap_dev *tap) in tap_del_queues() argument
303 list_for_each_entry_safe(q, tmp, &tap->queue_list, next) { in tap_del_queues()
305 RCU_INIT_POINTER(q->tap, NULL); in tap_del_queues()
307 tap->numvtaps--; in tap_del_queues()
308 tap->numqueues--; in tap_del_queues()
311 BUG_ON(tap->numvtaps); in tap_del_queues()
312 BUG_ON(tap->numqueues); in tap_del_queues()
314 tap->numvtaps = MAX_TAP_QUEUES; in tap_del_queues()
322 struct tap_dev *tap; in tap_handle_frame() local
326 tap = tap_dev_get_rcu(dev); in tap_handle_frame()
327 if (!tap) in tap_handle_frame()
330 q = tap_get_queue(tap, skb); in tap_handle_frame()
341 features |= tap->tap_features; in tap_handle_frame()
384 if (tap->count_rx_dropped) in tap_handle_frame()
385 tap->count_rx_dropped(tap); in tap_handle_frame()
403 int tap_get_minor(dev_t major, struct tap_dev *tap) in tap_get_minor() argument
416 retval = idr_alloc(&tap_major->minor_idr, tap, 1, TAP_NUM_DEVS, GFP_ATOMIC); in tap_get_minor()
418 tap->minor = retval; in tap_get_minor()
420 netdev_err(tap->dev, "Too many tap devices\n"); in tap_get_minor()
431 void tap_free_minor(dev_t major, struct tap_dev *tap) in tap_free_minor() argument
442 if (tap->minor) { in tap_free_minor()
443 idr_remove(&tap_major->minor_idr, tap->minor); in tap_free_minor()
444 tap->minor = 0; in tap_free_minor()
456 struct tap_dev *tap; in dev_get_by_tap_file() local
462 tap = NULL; in dev_get_by_tap_file()
467 tap = idr_find(&tap_major->minor_idr, minor); in dev_get_by_tap_file()
468 if (tap) { in dev_get_by_tap_file()
469 dev = tap->dev; in dev_get_by_tap_file()
476 return tap; in dev_get_by_tap_file()
502 struct tap_dev *tap; in tap_open() local
507 tap = dev_get_by_tap_file(imajor(inode), iminor(inode)); in tap_open()
508 if (!tap) in tap_open()
516 if (ptr_ring_init(&q->ring, tap->dev->tx_queue_len, GFP_KERNEL)) { in tap_open()
539 if ((tap->dev->features & NETIF_F_HIGHDMA) && (tap->dev->features & NETIF_F_SG)) in tap_open()
542 err = tap_set_queue(tap, file, q); in tap_open()
548 dev_put(tap->dev); in tap_open()
556 if (tap) in tap_open()
557 dev_put(tap->dev); in tap_open()
625 struct tap_dev *tap; in tap_get_user() local
721 tap = rcu_dereference(q->tap); in tap_get_user()
732 if (tap) { in tap_get_user()
733 skb->dev = tap->dev; in tap_get_user()
747 tap = rcu_dereference(q->tap); in tap_get_user()
748 if (tap && tap->count_tx_dropped) in tap_get_user()
749 tap->count_tx_dropped(tap); in tap_get_user()
886 struct tap_dev *tap; in tap_get_tap_dev() local
889 tap = rtnl_dereference(q->tap); in tap_get_tap_dev()
890 if (tap) in tap_get_tap_dev()
891 dev_hold(tap->dev); in tap_get_tap_dev()
893 return tap; in tap_get_tap_dev()
896 static void tap_put_tap_dev(struct tap_dev *tap) in tap_put_tap_dev() argument
898 dev_put(tap->dev); in tap_put_tap_dev()
904 struct tap_dev *tap; in tap_ioctl_set_queue() local
907 tap = tap_get_tap_dev(q); in tap_ioctl_set_queue()
908 if (!tap) in tap_ioctl_set_queue()
912 ret = tap_enable_queue(tap, file, q); in tap_ioctl_set_queue()
918 tap_put_tap_dev(tap); in tap_ioctl_set_queue()
924 struct tap_dev *tap; in set_offload() local
928 tap = rtnl_dereference(q->tap); in set_offload()
929 if (!tap) in set_offload()
932 features = tap->dev->features; in set_offload()
963 tap->tap_features = feature_mask; in set_offload()
964 if (tap->update_features) in set_offload()
965 tap->update_features(tap, features); in set_offload()
977 struct tap_dev *tap; in tap_ioctl() local
1003 tap = tap_get_tap_dev(q); in tap_ioctl()
1004 if (!tap) { in tap_ioctl()
1011 if (copy_to_user(&ifr->ifr_name, tap->dev->name, IFNAMSIZ) || in tap_ioctl()
1014 tap_put_tap_dev(tap); in tap_ioctl()
1089 tap = tap_get_tap_dev(q); in tap_ioctl()
1090 if (!tap) { in tap_ioctl()
1095 dev_get_mac_address(&sa, dev_net(tap->dev), tap->dev->name); in tap_ioctl()
1096 if (copy_to_user(&ifr->ifr_name, tap->dev->name, IFNAMSIZ) || in tap_ioctl()
1099 tap_put_tap_dev(tap); in tap_ioctl()
1107 tap = tap_get_tap_dev(q); in tap_ioctl()
1108 if (!tap) { in tap_ioctl()
1112 ret = dev_set_mac_address_user(tap->dev, &sa, NULL); in tap_ioctl()
1113 tap_put_tap_dev(tap); in tap_ioctl()
1140 struct tap_dev *tap; in tap_get_user_xdp() local
1172 tap = rcu_dereference(q->tap); in tap_get_user_xdp()
1173 if (tap) { in tap_get_user_xdp()
1174 skb->dev = tap->dev; in tap_get_user_xdp()
1188 tap = rcu_dereference(q->tap); in tap_get_user_xdp()
1189 if (tap && tap->count_tx_dropped) in tap_get_user_xdp()
1190 tap->count_tx_dropped(tap); in tap_get_user_xdp()
1277 int tap_queue_resize(struct tap_dev *tap) in tap_queue_resize() argument
1279 struct net_device *dev = tap->dev; in tap_queue_resize()
1282 int n = tap->numqueues; in tap_queue_resize()
1289 list_for_each_entry(q, &tap->queue_list, next) in tap_queue_resize()