vlan.h 4.4 KB

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