linux/include/linux/if_tap.h
<<
>>
Prefs
   1#ifndef _LINUX_IF_TAP_H_
   2#define _LINUX_IF_TAP_H_
   3
   4#if IS_ENABLED(CONFIG_TAP)
   5struct socket *tap_get_socket(struct file *);
   6#else
   7#include <linux/err.h>
   8#include <linux/errno.h>
   9struct file;
  10struct socket;
  11static inline struct socket *tap_get_socket(struct file *f)
  12{
  13        return ERR_PTR(-EINVAL);
  14}
  15#endif /* CONFIG_TAP */
  16
  17#include <net/sock.h>
  18#include <linux/skb_array.h>
  19
  20#define MAX_TAP_QUEUES 256
  21
  22struct tap_queue;
  23
  24struct tap_dev {
  25        struct net_device       *dev;
  26        u16                     flags;
  27        /* This array tracks active taps. */
  28        struct tap_queue    __rcu *taps[MAX_TAP_QUEUES];
  29        /* This list tracks all taps (both enabled and disabled) */
  30        struct list_head        queue_list;
  31        int                     numvtaps;
  32        int                     numqueues;
  33        netdev_features_t       tap_features;
  34        int                     minor;
  35
  36        void (*update_features)(struct tap_dev *tap, netdev_features_t features);
  37        void (*count_tx_dropped)(struct tap_dev *tap);
  38        void (*count_rx_dropped)(struct tap_dev *tap);
  39};
  40
  41/*
  42 * A tap queue is the central object of tap module, it connects
  43 * an open character device to virtual interface. There can be
  44 * multiple queues on one interface, which map back to queues
  45 * implemented in hardware on the underlying device.
  46 *
  47 * tap_proto is used to allocate queues through the sock allocation
  48 * mechanism.
  49 *
  50 */
  51
  52struct tap_queue {
  53        struct sock sk;
  54        struct socket sock;
  55        struct socket_wq wq;
  56        int vnet_hdr_sz;
  57        struct tap_dev __rcu *tap;
  58        struct file *file;
  59        unsigned int flags;
  60        u16 queue_index;
  61        bool enabled;
  62        struct list_head next;
  63        struct skb_array skb_array;
  64};
  65
  66rx_handler_result_t tap_handle_frame(struct sk_buff **pskb);
  67void tap_del_queues(struct tap_dev *tap);
  68int tap_get_minor(dev_t major, struct tap_dev *tap);
  69void tap_free_minor(dev_t major, struct tap_dev *tap);
  70int tap_queue_resize(struct tap_dev *tap);
  71int tap_create_cdev(struct cdev *tap_cdev,
  72                    dev_t *tap_major, const char *device_name);
  73void tap_destroy_cdev(dev_t major, struct cdev *tap_cdev);
  74
  75#endif /*_LINUX_IF_TAP_H_*/
  76