sunvnet.h 1.7 KB

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