~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/if_macvlan.h

Version: ~ [ linux-5.5 ] ~ [ linux-5.4.15 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.98 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.167 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.211 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.211 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.81 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef _LINUX_IF_MACVLAN_H
  2 #define _LINUX_IF_MACVLAN_H
  3 
  4 #include <linux/if_link.h>
  5 #include <linux/list.h>
  6 #include <linux/netdevice.h>
  7 #include <linux/netlink.h>
  8 #include <net/netlink.h>
  9 #include <linux/u64_stats_sync.h>
 10 
 11 #if defined(CONFIG_MACVTAP) || defined(CONFIG_MACVTAP_MODULE)
 12 struct socket *macvtap_get_socket(struct file *);
 13 #else
 14 #include <linux/err.h>
 15 #include <linux/errno.h>
 16 struct file;
 17 struct socket;
 18 static inline struct socket *macvtap_get_socket(struct file *f)
 19 {
 20         return ERR_PTR(-EINVAL);
 21 }
 22 #endif /* CONFIG_MACVTAP */
 23 
 24 struct macvlan_port;
 25 struct macvtap_queue;
 26 
 27 /**
 28  *      struct macvlan_pcpu_stats - MACVLAN percpu stats
 29  *      @rx_packets: number of received packets
 30  *      @rx_bytes: number of received bytes
 31  *      @rx_multicast: number of received multicast packets
 32  *      @tx_packets: number of transmitted packets
 33  *      @tx_bytes: number of transmitted bytes
 34  *      @syncp: synchronization point for 64bit counters
 35  *      @rx_errors: number of rx errors
 36  *      @tx_dropped: number of tx dropped packets
 37  */
 38 struct macvlan_pcpu_stats {
 39         u64                     rx_packets;
 40         u64                     rx_bytes;
 41         u64                     rx_multicast;
 42         u64                     tx_packets;
 43         u64                     tx_bytes;
 44         struct u64_stats_sync   syncp;
 45         u32                     rx_errors;
 46         u32                     tx_dropped;
 47 };
 48 
 49 /*
 50  * Maximum times a macvtap device can be opened. This can be used to
 51  * configure the number of receive queue, e.g. for multiqueue virtio.
 52  */
 53 #define MAX_MACVTAP_QUEUES      (NR_CPUS < 16 ? NR_CPUS : 16)
 54 
 55 struct macvlan_dev {
 56         struct net_device       *dev;
 57         struct list_head        list;
 58         struct hlist_node       hlist;
 59         struct macvlan_port     *port;
 60         struct net_device       *lowerdev;
 61         struct macvlan_pcpu_stats __percpu *pcpu_stats;
 62         enum macvlan_mode       mode;
 63         u16                     flags;
 64         int (*receive)(struct sk_buff *skb);
 65         int (*forward)(struct net_device *dev, struct sk_buff *skb);
 66         struct macvtap_queue    *taps[MAX_MACVTAP_QUEUES];
 67         int                     numvtaps;
 68         int                     minor;
 69 };
 70 
 71 static inline void macvlan_count_rx(const struct macvlan_dev *vlan,
 72                                     unsigned int len, bool success,
 73                                     bool multicast)
 74 {
 75         if (likely(success)) {
 76                 struct macvlan_pcpu_stats *pcpu_stats;
 77 
 78                 pcpu_stats = this_cpu_ptr(vlan->pcpu_stats);
 79                 u64_stats_update_begin(&pcpu_stats->syncp);
 80                 pcpu_stats->rx_packets++;
 81                 pcpu_stats->rx_bytes += len;
 82                 if (multicast)
 83                         pcpu_stats->rx_multicast++;
 84                 u64_stats_update_end(&pcpu_stats->syncp);
 85         } else {
 86                 this_cpu_inc(vlan->pcpu_stats->rx_errors);
 87         }
 88 }
 89 
 90 extern void macvlan_common_setup(struct net_device *dev);
 91 
 92 extern int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
 93                                   struct nlattr *tb[], struct nlattr *data[],
 94                                   int (*receive)(struct sk_buff *skb),
 95                                   int (*forward)(struct net_device *dev,
 96                                                  struct sk_buff *skb));
 97 
 98 extern void macvlan_count_rx(const struct macvlan_dev *vlan,
 99                              unsigned int len, bool success,
100                              bool multicast);
101 
102 extern void macvlan_dellink(struct net_device *dev, struct list_head *head);
103 
104 extern int macvlan_link_register(struct rtnl_link_ops *ops);
105 
106 extern netdev_tx_t macvlan_start_xmit(struct sk_buff *skb,
107                                       struct net_device *dev);
108 
109 #endif /* _LINUX_IF_MACVLAN_H */
110 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp