vlan.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef __BEN_VLAN_802_1Q_INC__
  2. #define __BEN_VLAN_802_1Q_INC__
  3. #include <linux/if_vlan.h>
  4. #include <linux/u64_stats_sync.h>
  5. /**
  6. * struct vlan_priority_tci_mapping - vlan egress priority mappings
  7. * @priority: skb priority
  8. * @vlan_qos: vlan priority: (skb->priority << 13) & 0xE000
  9. * @next: pointer to next struct
  10. */
  11. struct vlan_priority_tci_mapping {
  12. u32 priority;
  13. u16 vlan_qos;
  14. struct vlan_priority_tci_mapping *next;
  15. };
  16. /**
  17. * struct vlan_rx_stats - VLAN percpu rx stats
  18. * @rx_packets: number of received packets
  19. * @rx_bytes: number of received bytes
  20. * @rx_multicast: number of received multicast packets
  21. * @syncp: synchronization point for 64bit counters
  22. * @rx_errors: number of errors
  23. */
  24. struct vlan_rx_stats {
  25. u64 rx_packets;
  26. u64 rx_bytes;
  27. u64 rx_multicast;
  28. struct u64_stats_sync syncp;
  29. unsigned long rx_errors;
  30. };
  31. /**
  32. * struct vlan_dev_info - VLAN private device data
  33. * @nr_ingress_mappings: number of ingress priority mappings
  34. * @ingress_priority_map: ingress priority mappings
  35. * @nr_egress_mappings: number of egress priority mappings
  36. * @egress_priority_map: hash of egress priority mappings
  37. * @vlan_id: VLAN identifier
  38. * @flags: device flags
  39. * @real_dev: underlying netdevice
  40. * @real_dev_addr: address of underlying netdevice
  41. * @dent: proc dir entry
  42. * @cnt_inc_headroom_on_tx: statistic - number of skb expansions on TX
  43. * @cnt_encap_on_xmit: statistic - number of skb encapsulations on TX
  44. * @vlan_rx_stats: ptr to percpu rx stats
  45. */
  46. struct vlan_dev_info {
  47. unsigned int nr_ingress_mappings;
  48. u32 ingress_priority_map[8];
  49. unsigned int nr_egress_mappings;
  50. struct vlan_priority_tci_mapping *egress_priority_map[16];
  51. u16 vlan_id;
  52. u16 flags;
  53. struct net_device *real_dev;
  54. unsigned char real_dev_addr[ETH_ALEN];
  55. struct proc_dir_entry *dent;
  56. unsigned long cnt_inc_headroom_on_tx;
  57. unsigned long cnt_encap_on_xmit;
  58. struct vlan_rx_stats __percpu *vlan_rx_stats;
  59. };
  60. static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
  61. {
  62. return netdev_priv(dev);
  63. }
  64. /* found in vlan_dev.c */
  65. int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
  66. struct packet_type *ptype, struct net_device *orig_dev);
  67. void vlan_dev_set_ingress_priority(const struct net_device *dev,
  68. u32 skb_prio, u16 vlan_prio);
  69. int vlan_dev_set_egress_priority(const struct net_device *dev,
  70. u32 skb_prio, u16 vlan_prio);
  71. int vlan_dev_change_flags(const struct net_device *dev, u32 flag, u32 mask);
  72. void vlan_dev_get_realdev_name(const struct net_device *dev, char *result);
  73. int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id);
  74. void vlan_setup(struct net_device *dev);
  75. int register_vlan_dev(struct net_device *dev);
  76. void unregister_vlan_dev(struct net_device *dev, struct list_head *head);
  77. static inline u32 vlan_get_ingress_priority(struct net_device *dev,
  78. u16 vlan_tci)
  79. {
  80. struct vlan_dev_info *vip = vlan_dev_info(dev);
  81. return vip->ingress_priority_map[(vlan_tci >> VLAN_PRIO_SHIFT) & 0x7];
  82. }
  83. #ifdef CONFIG_VLAN_8021Q_GVRP
  84. extern int vlan_gvrp_request_join(const struct net_device *dev);
  85. extern void vlan_gvrp_request_leave(const struct net_device *dev);
  86. extern int vlan_gvrp_init_applicant(struct net_device *dev);
  87. extern void vlan_gvrp_uninit_applicant(struct net_device *dev);
  88. extern int vlan_gvrp_init(void);
  89. extern void vlan_gvrp_uninit(void);
  90. #else
  91. static inline int vlan_gvrp_request_join(const struct net_device *dev) { return 0; }
  92. static inline void vlan_gvrp_request_leave(const struct net_device *dev) {}
  93. static inline int vlan_gvrp_init_applicant(struct net_device *dev) { return 0; }
  94. static inline void vlan_gvrp_uninit_applicant(struct net_device *dev) {}
  95. static inline int vlan_gvrp_init(void) { return 0; }
  96. static inline void vlan_gvrp_uninit(void) {}
  97. #endif
  98. extern const char vlan_fullname[];
  99. extern const char vlan_version[];
  100. extern int vlan_netlink_init(void);
  101. extern void vlan_netlink_fini(void);
  102. extern struct rtnl_link_ops vlan_link_ops;
  103. static inline int is_vlan_dev(struct net_device *dev)
  104. {
  105. return dev->priv_flags & IFF_802_1Q_VLAN;
  106. }
  107. extern int vlan_net_id;
  108. struct proc_dir_entry;
  109. struct vlan_net {
  110. /* /proc/net/vlan */
  111. struct proc_dir_entry *proc_vlan_dir;
  112. /* /proc/net/vlan/config */
  113. struct proc_dir_entry *proc_vlan_conf;
  114. /* Determines interface naming scheme. */
  115. unsigned short name_type;
  116. };
  117. #endif /* !(__BEN_VLAN_802_1Q_INC__) */