vlan.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. * @vlan_rx_stats: ptr to percpu rx stats
  43. */
  44. struct vlan_dev_info {
  45. unsigned int nr_ingress_mappings;
  46. u32 ingress_priority_map[8];
  47. unsigned int nr_egress_mappings;
  48. struct vlan_priority_tci_mapping *egress_priority_map[16];
  49. u16 vlan_id;
  50. u16 flags;
  51. struct net_device *real_dev;
  52. unsigned char real_dev_addr[ETH_ALEN];
  53. struct proc_dir_entry *dent;
  54. struct vlan_rx_stats __percpu *vlan_rx_stats;
  55. };
  56. static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
  57. {
  58. return netdev_priv(dev);
  59. }
  60. /* found in vlan_dev.c */
  61. int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
  62. struct packet_type *ptype, struct net_device *orig_dev);
  63. void vlan_dev_set_ingress_priority(const struct net_device *dev,
  64. u32 skb_prio, u16 vlan_prio);
  65. int vlan_dev_set_egress_priority(const struct net_device *dev,
  66. u32 skb_prio, u16 vlan_prio);
  67. int vlan_dev_change_flags(const struct net_device *dev, u32 flag, u32 mask);
  68. void vlan_dev_get_realdev_name(const struct net_device *dev, char *result);
  69. int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id);
  70. void vlan_setup(struct net_device *dev);
  71. int register_vlan_dev(struct net_device *dev);
  72. void unregister_vlan_dev(struct net_device *dev, struct list_head *head);
  73. static inline u32 vlan_get_ingress_priority(struct net_device *dev,
  74. u16 vlan_tci)
  75. {
  76. struct vlan_dev_info *vip = vlan_dev_info(dev);
  77. return vip->ingress_priority_map[(vlan_tci >> VLAN_PRIO_SHIFT) & 0x7];
  78. }
  79. #ifdef CONFIG_VLAN_8021Q_GVRP
  80. extern int vlan_gvrp_request_join(const struct net_device *dev);
  81. extern void vlan_gvrp_request_leave(const struct net_device *dev);
  82. extern int vlan_gvrp_init_applicant(struct net_device *dev);
  83. extern void vlan_gvrp_uninit_applicant(struct net_device *dev);
  84. extern int vlan_gvrp_init(void);
  85. extern void vlan_gvrp_uninit(void);
  86. #else
  87. static inline int vlan_gvrp_request_join(const struct net_device *dev) { return 0; }
  88. static inline void vlan_gvrp_request_leave(const struct net_device *dev) {}
  89. static inline int vlan_gvrp_init_applicant(struct net_device *dev) { return 0; }
  90. static inline void vlan_gvrp_uninit_applicant(struct net_device *dev) {}
  91. static inline int vlan_gvrp_init(void) { return 0; }
  92. static inline void vlan_gvrp_uninit(void) {}
  93. #endif
  94. extern const char vlan_fullname[];
  95. extern const char vlan_version[];
  96. extern int vlan_netlink_init(void);
  97. extern void vlan_netlink_fini(void);
  98. extern struct rtnl_link_ops vlan_link_ops;
  99. static inline int is_vlan_dev(struct net_device *dev)
  100. {
  101. return dev->priv_flags & IFF_802_1Q_VLAN;
  102. }
  103. extern int vlan_net_id;
  104. struct proc_dir_entry;
  105. struct vlan_net {
  106. /* /proc/net/vlan */
  107. struct proc_dir_entry *proc_vlan_dir;
  108. /* /proc/net/vlan/config */
  109. struct proc_dir_entry *proc_vlan_conf;
  110. /* Determines interface naming scheme. */
  111. unsigned short name_type;
  112. };
  113. #endif /* !(__BEN_VLAN_802_1Q_INC__) */