sunvnet.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. /* length of time (or less) we expect pending descriptors to be marked
  11. * as VIO_DESC_DONE and skbs ready to be freed
  12. */
  13. #define VNET_CLEAN_TIMEOUT ((HZ/100)+1)
  14. #define VNET_MAXPACKET (65535ULL + ETH_HLEN + VLAN_HLEN)
  15. #define VNET_TX_RING_SIZE 512
  16. #define VNET_TX_WAKEUP_THRESH(dr) ((dr)->pending / 4)
  17. /* VNET packets are sent in buffers with the first 6 bytes skipped
  18. * so that after the ethernet header the IPv4/IPv6 headers are aligned
  19. * properly.
  20. */
  21. #define VNET_PACKET_SKIP 6
  22. #define VNET_MAXCOOKIES (VNET_MAXPACKET/PAGE_SIZE + 1)
  23. struct vnet_tx_entry {
  24. struct sk_buff *skb;
  25. unsigned int ncookies;
  26. struct ldc_trans_cookie cookies[VNET_MAXCOOKIES];
  27. };
  28. struct vnet;
  29. struct vnet_port {
  30. struct vio_driver_state vio;
  31. struct hlist_node hash;
  32. u8 raddr[ETH_ALEN];
  33. u8 switch_port;
  34. u8 __pad;
  35. struct vnet *vp;
  36. struct vnet_tx_entry tx_bufs[VNET_TX_RING_SIZE];
  37. struct list_head list;
  38. u32 stop_rx_idx;
  39. bool stop_rx;
  40. bool start_cons;
  41. struct timer_list clean_timer;
  42. u64 rmtu;
  43. };
  44. static inline struct vnet_port *to_vnet_port(struct vio_driver_state *vio)
  45. {
  46. return container_of(vio, struct vnet_port, vio);
  47. }
  48. #define VNET_PORT_HASH_SIZE 16
  49. #define VNET_PORT_HASH_MASK (VNET_PORT_HASH_SIZE - 1)
  50. static inline unsigned int vnet_hashfn(u8 *mac)
  51. {
  52. unsigned int val = mac[4] ^ mac[5];
  53. return val & (VNET_PORT_HASH_MASK);
  54. }
  55. struct vnet_mcast_entry {
  56. u8 addr[ETH_ALEN];
  57. u8 sent;
  58. u8 hit;
  59. struct vnet_mcast_entry *next;
  60. };
  61. struct vnet {
  62. /* Protects port_list and port_hash. */
  63. spinlock_t lock;
  64. struct net_device *dev;
  65. u32 msg_enable;
  66. struct list_head port_list;
  67. struct hlist_head port_hash[VNET_PORT_HASH_SIZE];
  68. struct vnet_mcast_entry *mcast_list;
  69. struct list_head list;
  70. u64 local_mac;
  71. struct tasklet_struct vnet_tx_wakeup;
  72. };
  73. #endif /* _SUNVNET_H */