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_pcpu_stats - VLAN percpu rx/tx stats
  18. * @rx_packets: number of received packets
  19. * @rx_bytes: number of received bytes
  20. * @rx_multicast: number of received multicast packets
  21. * @tx_packets: number of transmitted packets
  22. * @tx_bytes: number of transmitted bytes
  23. * @syncp: synchronization point for 64bit counters
  24. * @rx_errors: number of rx errors
  25. * @tx_dropped: number of tx drops
  26. */
  27. struct vlan_pcpu_stats {
  28. u64 rx_packets;
  29. u64 rx_bytes;
  30. u64 rx_multicast;
  31. u64 tx_packets;
  32. u64 tx_bytes;
  33. struct u64_stats_sync syncp;
  34. u32 rx_errors;
  35. u32 tx_dropped;
  36. };
  37. /**
  38. * struct vlan_dev_info - VLAN private device data
  39. * @nr_ingress_mappings: number of ingress priority mappings
  40. * @ingress_priority_map: ingress priority mappings
  41. * @nr_egress_mappings: number of egress priority mappings
  42. * @egress_priority_map: hash of egress priority mappings
  43. * @vlan_id: VLAN identifier
  44. * @flags: device flags
  45. * @real_dev: underlying netdevice
  46. * @real_dev_addr: address of underlying netdevice
  47. * @dent: proc dir entry
  48. * @vlan_pcpu_stats: ptr to percpu rx stats
  49. */
  50. struct vlan_dev_info {
  51. unsigned int nr_ingress_mappings;
  52. u32 ingress_priority_map[8];
  53. unsigned int nr_egress_mappings;
  54. struct vlan_priority_tci_mapping *egress_priority_map[16];
  55. u16 vlan_id;
  56. u16 flags;
  57. struct net_device *real_dev;
  58. unsigned char real_dev_addr[ETH_ALEN];
  59. struct proc_dir_entry *dent;
  60. struct vlan_pcpu_stats __percpu *vlan_pcpu_stats;
  61. };
  62. static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
  63. {
  64. return netdev_priv(dev);
  65. }
  66. /* found in vlan_dev.c */
  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. 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__) */