Lines Matching refs:tap
146 static int tap_enable_queue(struct tap_dev *tap, struct file *file, in tap_enable_queue() argument
157 rcu_assign_pointer(tap->taps[tap->numvtaps], q); in tap_enable_queue()
158 q->queue_index = tap->numvtaps; in tap_enable_queue()
161 tap->numvtaps++; in tap_enable_queue()
167 static int tap_set_queue(struct tap_dev *tap, struct file *file, in tap_set_queue() argument
170 if (tap->numqueues == MAX_TAP_QUEUES) in tap_set_queue()
173 rcu_assign_pointer(q->tap, tap); in tap_set_queue()
174 rcu_assign_pointer(tap->taps[tap->numvtaps], q); in tap_set_queue()
178 q->queue_index = tap->numvtaps; in tap_set_queue()
181 list_add_tail(&q->next, &tap->queue_list); in tap_set_queue()
183 tap->numvtaps++; in tap_set_queue()
184 tap->numqueues++; in tap_set_queue()
191 struct tap_dev *tap; in tap_disable_queue() local
198 tap = rtnl_dereference(q->tap); in tap_disable_queue()
200 if (tap) { in tap_disable_queue()
202 BUG_ON(index >= tap->numvtaps); in tap_disable_queue()
203 nq = rtnl_dereference(tap->taps[tap->numvtaps - 1]); in tap_disable_queue()
206 rcu_assign_pointer(tap->taps[index], nq); in tap_disable_queue()
207 RCU_INIT_POINTER(tap->taps[tap->numvtaps - 1], NULL); in tap_disable_queue()
210 tap->numvtaps--; in tap_disable_queue()
226 struct tap_dev *tap; in tap_put_queue() local
229 tap = rtnl_dereference(q->tap); in tap_put_queue()
231 if (tap) { in tap_put_queue()
235 tap->numqueues--; in tap_put_queue()
236 RCU_INIT_POINTER(q->tap, NULL); in tap_put_queue()
254 static struct tap_queue *tap_get_queue(struct tap_dev *tap, in tap_get_queue() argument
263 int numvtaps = READ_ONCE(tap->numvtaps); in tap_get_queue()
275 queue = rcu_dereference(tap->taps[rxq % numvtaps]); in tap_get_queue()
285 queue = rcu_dereference(tap->taps[rxq]); in tap_get_queue()
290 queue = rcu_dereference(tap->taps[0]); in tap_get_queue()
300 void tap_del_queues(struct tap_dev *tap) in tap_del_queues() argument
305 list_for_each_entry_safe(q, tmp, &tap->queue_list, next) { in tap_del_queues()
307 RCU_INIT_POINTER(q->tap, NULL); in tap_del_queues()
309 tap->numvtaps--; in tap_del_queues()
310 tap->numqueues--; in tap_del_queues()
313 BUG_ON(tap->numvtaps); in tap_del_queues()
314 BUG_ON(tap->numqueues); in tap_del_queues()
316 tap->numvtaps = MAX_TAP_QUEUES; in tap_del_queues()
324 struct tap_dev *tap; in tap_handle_frame() local
329 tap = tap_dev_get_rcu(dev); in tap_handle_frame()
330 if (!tap) in tap_handle_frame()
333 q = tap_get_queue(tap, skb); in tap_handle_frame()
344 features |= tap->tap_features; in tap_handle_frame()
396 if (tap->count_rx_dropped) in tap_handle_frame()
397 tap->count_rx_dropped(tap); in tap_handle_frame()
415 int tap_get_minor(dev_t major, struct tap_dev *tap) in tap_get_minor() argument
428 retval = idr_alloc(&tap_major->minor_idr, tap, 1, TAP_NUM_DEVS, GFP_ATOMIC); in tap_get_minor()
430 tap->minor = retval; in tap_get_minor()
432 netdev_err(tap->dev, "Too many tap devices\n"); in tap_get_minor()
443 void tap_free_minor(dev_t major, struct tap_dev *tap) in tap_free_minor() argument
454 if (tap->minor) { in tap_free_minor()
455 idr_remove(&tap_major->minor_idr, tap->minor); in tap_free_minor()
456 tap->minor = 0; in tap_free_minor()
468 struct tap_dev *tap; in dev_get_by_tap_file() local
474 tap = NULL; in dev_get_by_tap_file()
479 tap = idr_find(&tap_major->minor_idr, minor); in dev_get_by_tap_file()
480 if (tap) { in dev_get_by_tap_file()
481 dev = tap->dev; in dev_get_by_tap_file()
488 return tap; in dev_get_by_tap_file()
514 struct tap_dev *tap; in tap_open() local
519 tap = dev_get_by_tap_file(imajor(inode), iminor(inode)); in tap_open()
520 if (!tap) in tap_open()
528 if (ptr_ring_init(&q->ring, tap->dev->tx_queue_len, GFP_KERNEL)) { in tap_open()
551 if ((tap->dev->features & NETIF_F_HIGHDMA) && (tap->dev->features & NETIF_F_SG)) in tap_open()
554 err = tap_set_queue(tap, file, q); in tap_open()
563 dev_put(tap->dev); in tap_open()
571 if (tap) in tap_open()
572 dev_put(tap->dev); in tap_open()
642 struct tap_dev *tap; in tap_get_user() local
727 tap = rcu_dereference(q->tap); in tap_get_user()
728 if (!tap) { in tap_get_user()
733 skb->dev = tap->dev; in tap_get_user()
769 tap = rcu_dereference(q->tap); in tap_get_user()
770 if (tap && tap->count_tx_dropped) in tap_get_user()
771 tap->count_tx_dropped(tap); in tap_get_user()
916 struct tap_dev *tap; in tap_get_tap_dev() local
919 tap = rtnl_dereference(q->tap); in tap_get_tap_dev()
920 if (tap) in tap_get_tap_dev()
921 dev_hold(tap->dev); in tap_get_tap_dev()
923 return tap; in tap_get_tap_dev()
926 static void tap_put_tap_dev(struct tap_dev *tap) in tap_put_tap_dev() argument
928 dev_put(tap->dev); in tap_put_tap_dev()
934 struct tap_dev *tap; in tap_ioctl_set_queue() local
937 tap = tap_get_tap_dev(q); in tap_ioctl_set_queue()
938 if (!tap) in tap_ioctl_set_queue()
942 ret = tap_enable_queue(tap, file, q); in tap_ioctl_set_queue()
948 tap_put_tap_dev(tap); in tap_ioctl_set_queue()
954 struct tap_dev *tap; in set_offload() local
958 tap = rtnl_dereference(q->tap); in set_offload()
959 if (!tap) in set_offload()
962 features = tap->dev->features; in set_offload()
998 tap->tap_features = feature_mask; in set_offload()
999 if (tap->update_features) in set_offload()
1000 tap->update_features(tap, features); in set_offload()
1012 struct tap_dev *tap; in tap_ioctl() local
1038 tap = tap_get_tap_dev(q); in tap_ioctl()
1039 if (!tap) { in tap_ioctl()
1046 if (copy_to_user(&ifr->ifr_name, tap->dev->name, IFNAMSIZ) || in tap_ioctl()
1049 tap_put_tap_dev(tap); in tap_ioctl()
1125 tap = tap_get_tap_dev(q); in tap_ioctl()
1126 if (!tap) { in tap_ioctl()
1131 dev_get_mac_address(&sa, dev_net(tap->dev), tap->dev->name); in tap_ioctl()
1132 if (copy_to_user(&ifr->ifr_name, tap->dev->name, IFNAMSIZ) || in tap_ioctl()
1135 tap_put_tap_dev(tap); in tap_ioctl()
1143 tap = tap_get_tap_dev(q); in tap_ioctl()
1144 if (!tap) { in tap_ioctl()
1148 ret = dev_set_mac_address_user(tap->dev, &sa, NULL); in tap_ioctl()
1149 tap_put_tap_dev(tap); in tap_ioctl()
1176 struct tap_dev *tap; in tap_get_user_xdp() local
1213 tap = rcu_dereference(q->tap); in tap_get_user_xdp()
1214 if (tap) { in tap_get_user_xdp()
1215 skb->dev = tap->dev; in tap_get_user_xdp()
1229 tap = rcu_dereference(q->tap); in tap_get_user_xdp()
1230 if (tap && tap->count_tx_dropped) in tap_get_user_xdp()
1231 tap->count_tx_dropped(tap); in tap_get_user_xdp()
1318 int tap_queue_resize(struct tap_dev *tap) in tap_queue_resize() argument
1320 struct net_device *dev = tap->dev; in tap_queue_resize()
1323 int n = tap->numqueues; in tap_queue_resize()
1330 list_for_each_entry(q, &tap->queue_list, next) in tap_queue_resize()