vlan.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #ifndef __BEN_VLAN_802_1Q_INC__
  2. #define __BEN_VLAN_802_1Q_INC__
  3. #include <linux/if_vlan.h>
  4. /**
  5. * struct vlan_priority_tci_mapping - vlan egress priority mappings
  6. * @priority: skb priority
  7. * @vlan_qos: vlan priority: (skb->priority << 13) & 0xE000
  8. * @next: pointer to next struct
  9. */
  10. struct vlan_priority_tci_mapping {
  11. u32 priority;
  12. u16 vlan_qos;
  13. struct vlan_priority_tci_mapping *next;
  14. };
  15. /**
  16. * struct vlan_rx_stats - VLAN percpu rx stats
  17. * @rx_packets: number of received packets
  18. * @rx_bytes: number of received bytes
  19. * @multicast: number of received multicast packets
  20. * @rx_errors: number of errors
  21. */
  22. struct vlan_rx_stats {
  23. unsigned long rx_packets;
  24. unsigned long rx_bytes;
  25. unsigned long multicast;
  26. unsigned long rx_errors;
  27. };
  28. /**
  29. * struct vlan_dev_info - VLAN private device data
  30. * @nr_ingress_mappings: number of ingress priority mappings
  31. * @ingress_priority_map: ingress priority mappings
  32. * @nr_egress_mappings: number of egress priority mappings
  33. * @egress_priority_map: hash of egress priority mappings
  34. * @vlan_id: VLAN identifier
  35. * @flags: device flags
  36. * @real_dev: underlying netdevice
  37. * @real_dev_addr: address of underlying netdevice
  38. * @dent: proc dir entry
  39. * @cnt_inc_headroom_on_tx: statistic - number of skb expansions on TX
  40. * @cnt_encap_on_xmit: statistic - number of skb encapsulations on TX
  41. * @vlan_rx_stats: ptr to percpu rx stats
  42. */
  43. struct vlan_dev_info {
  44. unsigned int nr_ingress_mappings;
  45. u32 ingress_priority_map[8];
  46. unsigned int nr_egress_mappings;
  47. struct vlan_priority_tci_mapping *egress_priority_map[16];
  48. u16 vlan_id;
  49. u16 flags;
  50. struct net_device *real_dev;
  51. unsigned char real_dev_addr[ETH_ALEN];
  52. struct proc_dir_entry *dent;
  53. unsigned long cnt_inc_headroom_on_tx;
  54. unsigned long cnt_encap_on_xmit;
  55. struct vlan_rx_stats *vlan_rx_stats;
  56. };
  57. static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
  58. {
  59. return netdev_priv(dev);
  60. }
  61. #define VLAN_GRP_HASH_SHIFT 5
  62. #define VLAN_GRP_HASH_SIZE (1 << VLAN_GRP_HASH_SHIFT)
  63. #define VLAN_GRP_HASH_MASK (VLAN_GRP_HASH_SIZE - 1)
  64. /* Find a VLAN device by the MAC address of its Ethernet device, and
  65. * it's VLAN ID. The default configuration is to have VLAN's scope
  66. * to be box-wide, so the MAC will be ignored. The mac will only be
  67. * looked at if we are configured to have a separate set of VLANs per
  68. * each MAC addressable interface. Note that this latter option does
  69. * NOT follow the spec for VLANs, but may be useful for doing very
  70. * large quantities of VLAN MUX/DEMUX onto FrameRelay or ATM PVCs.
  71. *
  72. * Must be invoked with rcu_read_lock (ie preempt disabled)
  73. * or with RTNL.
  74. */
  75. struct net_device *__find_vlan_dev(struct net_device *real_dev, u16 vlan_id);
  76. /* found in vlan_dev.c */
  77. int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
  78. struct packet_type *ptype, struct net_device *orig_dev);
  79. void vlan_dev_set_ingress_priority(const struct net_device *dev,
  80. u32 skb_prio, u16 vlan_prio);
  81. int vlan_dev_set_egress_priority(const struct net_device *dev,
  82. u32 skb_prio, u16 vlan_prio);
  83. int vlan_dev_change_flags(const struct net_device *dev, u32 flag, u32 mask);
  84. void vlan_dev_get_realdev_name(const struct net_device *dev, char *result);
  85. int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id);
  86. void vlan_setup(struct net_device *dev);
  87. int register_vlan_dev(struct net_device *dev);
  88. void unregister_vlan_dev(struct net_device *dev, struct list_head *head);
  89. static inline u32 vlan_get_ingress_priority(struct net_device *dev,
  90. u16 vlan_tci)
  91. {
  92. struct vlan_dev_info *vip = vlan_dev_info(dev);
  93. return vip->ingress_priority_map[(vlan_tci >> VLAN_PRIO_SHIFT) & 0x7];
  94. }
  95. #ifdef CONFIG_VLAN_8021Q_GVRP
  96. extern int vlan_gvrp_request_join(const struct net_device *dev);
  97. extern void vlan_gvrp_request_leave(const struct net_device *dev);
  98. extern int vlan_gvrp_init_applicant(struct net_device *dev);
  99. extern void vlan_gvrp_uninit_applicant(struct net_device *dev);
  100. extern int vlan_gvrp_init(void);
  101. extern void vlan_gvrp_uninit(void);
  102. #else
  103. static inline int vlan_gvrp_request_join(const struct net_device *dev) { return 0; }
  104. static inline void vlan_gvrp_request_leave(const struct net_device *dev) {}
  105. static inline int vlan_gvrp_init_applicant(struct net_device *dev) { return 0; }
  106. static inline void vlan_gvrp_uninit_applicant(struct net_device *dev) {}
  107. static inline int vlan_gvrp_init(void) { return 0; }
  108. static inline void vlan_gvrp_uninit(void) {}
  109. #endif
  110. extern const char vlan_fullname[];
  111. extern const char vlan_version[];
  112. extern int vlan_netlink_init(void);
  113. extern void vlan_netlink_fini(void);
  114. extern struct rtnl_link_ops vlan_link_ops;
  115. static inline int is_vlan_dev(struct net_device *dev)
  116. {
  117. return dev->priv_flags & IFF_802_1Q_VLAN;
  118. }
  119. extern int vlan_net_id;
  120. struct proc_dir_entry;
  121. struct vlan_net {
  122. /* /proc/net/vlan */
  123. struct proc_dir_entry *proc_vlan_dir;
  124. /* /proc/net/vlan/config */
  125. struct proc_dir_entry *proc_vlan_conf;
  126. /* Determines interface naming scheme. */
  127. unsigned short name_type;
  128. };
  129. #endif /* !(__BEN_VLAN_802_1Q_INC__) */