sunvnet.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef _SUNVNET_H
  2. #define _SUNVNET_H
  3. #define DESC_NCOOKIES(entry_size) \
  4. ((entry_size) - sizeof(struct vio_net_desc))
  5. /* length of time before we decide the hardware is borked,
  6. * and dev->tx_timeout() should be called to fix the problem
  7. */
  8. #define VNET_TX_TIMEOUT (5 * HZ)
  9. #define VNET_TX_RING_SIZE 512
  10. #define VNET_TX_WAKEUP_THRESH(dr) ((dr)->pending / 4)
  11. /* VNET packets are sent in buffers with the first 6 bytes skipped
  12. * so that after the ethernet header the IPv4/IPv6 headers are aligned
  13. * properly.
  14. */
  15. #define VNET_PACKET_SKIP 6
  16. struct vnet_tx_entry {
  17. void *buf;
  18. unsigned int ncookies;
  19. struct ldc_trans_cookie cookies[2];
  20. };
  21. struct vnet;
  22. struct vnet_port {
  23. struct vio_driver_state vio;
  24. struct hlist_node hash;
  25. u8 raddr[ETH_ALEN];
  26. u8 switch_port;
  27. u8 __pad;
  28. struct vnet *vp;
  29. struct vnet_tx_entry tx_bufs[VNET_TX_RING_SIZE];
  30. struct list_head list;
  31. };
  32. static inline struct vnet_port *to_vnet_port(struct vio_driver_state *vio)
  33. {
  34. return container_of(vio, struct vnet_port, vio);
  35. }
  36. #define VNET_PORT_HASH_SIZE 16
  37. #define VNET_PORT_HASH_MASK (VNET_PORT_HASH_SIZE - 1)
  38. static inline unsigned int vnet_hashfn(u8 *mac)
  39. {
  40. unsigned int val = mac[4] ^ mac[5];
  41. return val & (VNET_PORT_HASH_MASK);
  42. }
  43. struct vnet_mcast_entry {
  44. u8 addr[ETH_ALEN];
  45. u8 sent;
  46. u8 hit;
  47. struct vnet_mcast_entry *next;
  48. };
  49. struct vnet {
  50. /* Protects port_list and port_hash. */
  51. spinlock_t lock;
  52. struct net_device *dev;
  53. u32 msg_enable;
  54. struct list_head port_list;
  55. struct hlist_head port_hash[VNET_PORT_HASH_SIZE];
  56. struct vnet_mcast_entry *mcast_list;
  57. struct list_head list;
  58. u64 local_mac;
  59. };
  60. #endif /* _SUNVNET_H */