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.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #include <ipxe/netdevice.h>
  11. /** A VLAN header */
  12. struct vlan_header {
  13. /** Tag control information */
  14. uint16_t tci;
  15. /** Encapsulated protocol */
  16. uint16_t net_proto;
  17. } __attribute__ (( packed ));
  18. /**
  19. * Extract VLAN tag from tag control information
  20. *
  21. * @v tci Tag control information
  22. * @ret tag VLAN tag
  23. */
  24. #define VLAN_TAG( tci ) ( (tci) & 0x0fff )
  25. /**
  26. * Extract VLAN priority from tag control information
  27. *
  28. * @v tci Tag control information
  29. * @ret priority Priority
  30. */
  31. #define VLAN_PRIORITY( tci ) ( (tci) >> 13 )
  32. /**
  33. * Construct VLAN tag control information
  34. *
  35. * @v tag VLAN tag
  36. * @v priority Priority
  37. * @ret tci Tag control information
  38. */
  39. #define VLAN_TCI( tag, priority ) ( ( (priority) << 13 ) | (tag) )
  40. /**
  41. * Check VLAN tag is valid
  42. *
  43. * @v tag VLAN tag
  44. * @ret is_valid VLAN tag is valid
  45. */
  46. #define VLAN_TAG_IS_VALID( tag ) ( (tag) < 0xfff )
  47. /**
  48. * Check VLAN priority is valid
  49. *
  50. * @v priority VLAN priority
  51. * @ret is_valid VLAN priority is valid
  52. */
  53. #define VLAN_PRIORITY_IS_VALID( priority ) ( (priority) <= 7 )
  54. extern unsigned int vlan_tag ( struct net_device *netdev );
  55. extern int vlan_can_be_trunk ( struct net_device *trunk );
  56. extern int vlan_create ( struct net_device *trunk, unsigned int tag,
  57. unsigned int priority );
  58. extern int vlan_destroy ( struct net_device *netdev );
  59. extern void vlan_netdev_rx ( struct net_device *netdev, unsigned int tag,
  60. struct io_buffer *iobuf );
  61. extern void vlan_netdev_rx_err ( struct net_device *netdev, unsigned int tag,
  62. struct io_buffer *iobuf, int rc );
  63. #endif /* _IPXE_VLAN_H */