1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_IF_TAP_H_
3 #define _LINUX_IF_TAP_H_
5 #if IS_ENABLED(CONFIG_TAP)
6 struct socket *tap_get_socket(struct file *);
7 struct ptr_ring *tap_get_ptr_ring(struct file *file);
10 #include <linux/errno.h>
13 static inline struct socket *tap_get_socket(struct file *f)
15 return ERR_PTR(-EINVAL);
17 static inline struct ptr_ring *tap_get_ptr_ring(struct file *f)
19 return ERR_PTR(-EINVAL);
21 #endif /* CONFIG_TAP */
24 #include <linux/skb_array.h>
27 * Maximum times a tap device can be opened. This can be used to
28 * configure the number of receive queue, e.g. for multiqueue virtio.
30 #define MAX_TAP_QUEUES 256
35 struct net_device *dev;
37 /* This array tracks active taps. */
38 struct tap_queue __rcu *taps[MAX_TAP_QUEUES];
39 /* This list tracks all taps (both enabled and disabled) */
40 struct list_head queue_list;
43 netdev_features_t tap_features;
46 void (*update_features)(struct tap_dev *tap, netdev_features_t features);
47 void (*count_tx_dropped)(struct tap_dev *tap);
48 void (*count_rx_dropped)(struct tap_dev *tap);
52 * A tap queue is the central object of tap module, it connects
53 * an open character device to virtual interface. There can be
54 * multiple queues on one interface, which map back to queues
55 * implemented in hardware on the underlying device.
57 * tap_proto is used to allocate queues through the sock allocation
66 struct tap_dev __rcu *tap;
71 struct list_head next;
75 rx_handler_result_t tap_handle_frame(struct sk_buff **pskb);
76 void tap_del_queues(struct tap_dev *tap);
77 int tap_get_minor(dev_t major, struct tap_dev *tap);
78 void tap_free_minor(dev_t major, struct tap_dev *tap);
79 int tap_queue_resize(struct tap_dev *tap);
80 int tap_create_cdev(struct cdev *tap_cdev, dev_t *tap_major,
81 const char *device_name, struct module *module);
82 void tap_destroy_cdev(dev_t major, struct cdev *tap_cdev);
84 #endif /*_LINUX_IF_TAP_H_*/