You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vlan.h 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef _IPXE_VLAN_H
  2. #define _IPXE_VLAN_H
  3. /**
  4. * @file
  5. *
  6. * Virtual LANs
  7. *
  8. */
  9. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  10. /** A VLAN header */
  11. struct vlan_header {
  12. /** Tag control information */
  13. uint16_t tci;
  14. /** Encapsulated protocol */
  15. uint16_t net_proto;
  16. } __attribute__ (( packed ));
  17. /**
  18. * Extract VLAN tag from tag control information
  19. *
  20. * @v tci Tag control information
  21. * @ret tag VLAN tag
  22. */
  23. #define VLAN_TAG( tci ) ( (tci) & 0x0fff )
  24. /**
  25. * Extract VLAN priority from tag control information
  26. *
  27. * @v tci Tag control information
  28. * @ret priority Priority
  29. */
  30. #define VLAN_PRIORITY( tci ) ( (tci) >> 13 )
  31. /**
  32. * Construct VLAN tag control information
  33. *
  34. * @v tag VLAN tag
  35. * @v priority Priority
  36. * @ret tci Tag control information
  37. */
  38. #define VLAN_TCI( tag, priority ) ( ( (priority) << 13 ) | (tag) )
  39. /**
  40. * Check VLAN tag is valid
  41. *
  42. * @v tag VLAN tag
  43. * @ret is_valid VLAN tag is valid
  44. */
  45. #define VLAN_TAG_IS_VALID( tag ) ( (tag) < 0xfff )
  46. /**
  47. * Check VLAN priority is valid
  48. *
  49. * @v priority VLAN priority
  50. * @ret is_valid VLAN priority is valid
  51. */
  52. #define VLAN_PRIORITY_IS_VALID( priority ) ( (priority) <= 7 )
  53. extern struct net_device * vlan_find ( struct net_device *trunk,
  54. unsigned int tag );
  55. extern unsigned int vlan_tag ( struct net_device *netdev );
  56. extern int vlan_can_be_trunk ( struct net_device *trunk );
  57. extern int vlan_create ( struct net_device *trunk, unsigned int tag,
  58. unsigned int priority );
  59. extern int vlan_destroy ( struct net_device *netdev );
  60. #endif /* _IPXE_VLAN_H */