sunvnet.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #define VNET_MINTSO 2048 /* VIO protocol's minimum TSO len */
  18. #define VNET_MAXTSO 65535 /* VIO protocol's maximum TSO len */
  19. /* VNET packets are sent in buffers with the first 6 bytes skipped
  20. * so that after the ethernet header the IPv4/IPv6 headers are aligned
  21. * properly.
  22. */
  23. #define VNET_PACKET_SKIP 6
  24. #define VNET_MAXCOOKIES (VNET_MAXPACKET/PAGE_SIZE + 1)
  25. struct vnet_tx_entry {
  26. struct sk_buff *skb;
  27. unsigned int ncookies;
  28. struct ldc_trans_cookie cookies[VNET_MAXCOOKIES];
  29. };
  30. struct vnet;
  31. struct vnet_port {
  32. struct vio_driver_state vio;
  33. struct hlist_node hash;
  34. u8 raddr[ETH_ALEN];
  35. unsigned switch_port:1;
  36. unsigned tso:1;
  37. unsigned __pad:14;
  38. struct vnet *vp;
  39. struct vnet_tx_entry tx_bufs[VNET_TX_RING_SIZE];
  40. struct list_head list;
  41. u32 stop_rx_idx;
  42. bool stop_rx;
  43. bool start_cons;
  44. struct timer_list clean_timer;
  45. u64 rmtu;
  46. u16 tsolen;
  47. struct napi_struct napi;
  48. u32 napi_stop_idx;
  49. bool napi_resume;
  50. int rx_event;
  51. u16 q_index;
  52. };
  53. static inline struct vnet_port *to_vnet_port(struct vio_driver_state *vio)
  54. {
  55. return container_of(vio, struct vnet_port, vio);
  56. }
  57. #define VNET_PORT_HASH_SIZE 16
  58. #define VNET_PORT_HASH_MASK (VNET_PORT_HASH_SIZE - 1)
  59. static inline unsigned int vnet_hashfn(u8 *mac)
  60. {
  61. unsigned int val = mac[4] ^ mac[5];
  62. return val & (VNET_PORT_HASH_MASK);
  63. }
  64. struct vnet_mcast_entry {
  65. u8 addr[ETH_ALEN];
  66. u8 sent;
  67. u8 hit;
  68. struct vnet_mcast_entry *next;
  69. };
  70. struct vnet {
  71. /* Protects port_list and port_hash. */
  72. spinlock_t lock;
  73. struct net_device *dev;
  74. u32 msg_enable;
  75. struct list_head port_list;
  76. struct hlist_head port_hash[VNET_PORT_HASH_SIZE];
  77. struct vnet_mcast_entry *mcast_list;
  78. struct list_head list;
  79. u64 local_mac;
  80. int nports;
  81. };
  82. #endif /* _SUNVNET_H */