sunvnet.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. struct vnet *vp;
  27. struct vnet_tx_entry tx_bufs[VNET_TX_RING_SIZE];
  28. struct list_head list;
  29. };
  30. static inline struct vnet_port *to_vnet_port(struct vio_driver_state *vio)
  31. {
  32. return container_of(vio, struct vnet_port, vio);
  33. }
  34. #define VNET_PORT_HASH_SIZE 16
  35. #define VNET_PORT_HASH_MASK (VNET_PORT_HASH_SIZE - 1)
  36. static inline unsigned int vnet_hashfn(u8 *mac)
  37. {
  38. unsigned int val = mac[4] ^ mac[5];
  39. return val & (VNET_PORT_HASH_MASK);
  40. }
  41. struct vnet {
  42. /* Protects port_list and port_hash. */
  43. spinlock_t lock;
  44. struct net_device *dev;
  45. u32 msg_enable;
  46. struct vio_dev *vdev;
  47. struct list_head port_list;
  48. struct hlist_head port_hash[VNET_PORT_HASH_SIZE];
  49. };
  50. #endif /* _SUNVNET_H */