David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 1 | #ifndef _SUNVNET_H |
| 2 | #define _SUNVNET_H |
| 3 | |
Sowmini Varadhan | 1d311ad | 2014-08-13 10:29:41 -0400 | [diff] [blame] | 4 | #include <linux/interrupt.h> |
| 5 | |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 6 | #define DESC_NCOOKIES(entry_size) \ |
| 7 | ((entry_size) - sizeof(struct vio_net_desc)) |
| 8 | |
| 9 | /* length of time before we decide the hardware is borked, |
| 10 | * and dev->tx_timeout() should be called to fix the problem |
| 11 | */ |
| 12 | #define VNET_TX_TIMEOUT (5 * HZ) |
| 13 | |
| 14 | #define VNET_TX_RING_SIZE 512 |
| 15 | #define VNET_TX_WAKEUP_THRESH(dr) ((dr)->pending / 4) |
| 16 | |
| 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 | |
| 23 | struct vnet_tx_entry { |
| 24 | void *buf; |
| 25 | unsigned int ncookies; |
| 26 | struct ldc_trans_cookie cookies[2]; |
| 27 | }; |
| 28 | |
| 29 | struct vnet; |
| 30 | struct vnet_port { |
| 31 | struct vio_driver_state vio; |
| 32 | |
| 33 | struct hlist_node hash; |
| 34 | u8 raddr[ETH_ALEN]; |
David S. Miller | 028ebff | 2007-07-20 02:30:25 -0700 | [diff] [blame] | 35 | u8 switch_port; |
| 36 | u8 __pad; |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 37 | |
| 38 | struct vnet *vp; |
| 39 | |
| 40 | struct vnet_tx_entry tx_bufs[VNET_TX_RING_SIZE]; |
| 41 | |
| 42 | struct list_head list; |
Sowmini Varadhan | d101564 | 2014-09-11 09:57:22 -0400 | [diff] [blame^] | 43 | |
| 44 | u32 stop_rx_idx; |
| 45 | bool stop_rx; |
| 46 | bool start_cons; |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | static inline struct vnet_port *to_vnet_port(struct vio_driver_state *vio) |
| 50 | { |
| 51 | return container_of(vio, struct vnet_port, vio); |
| 52 | } |
| 53 | |
| 54 | #define VNET_PORT_HASH_SIZE 16 |
| 55 | #define VNET_PORT_HASH_MASK (VNET_PORT_HASH_SIZE - 1) |
| 56 | |
| 57 | static inline unsigned int vnet_hashfn(u8 *mac) |
| 58 | { |
| 59 | unsigned int val = mac[4] ^ mac[5]; |
| 60 | |
| 61 | return val & (VNET_PORT_HASH_MASK); |
| 62 | } |
| 63 | |
David S. Miller | 028ebff | 2007-07-20 02:30:25 -0700 | [diff] [blame] | 64 | struct vnet_mcast_entry { |
| 65 | u8 addr[ETH_ALEN]; |
| 66 | u8 sent; |
| 67 | u8 hit; |
| 68 | struct vnet_mcast_entry *next; |
| 69 | }; |
| 70 | |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 71 | struct vnet { |
| 72 | /* Protects port_list and port_hash. */ |
| 73 | spinlock_t lock; |
| 74 | |
| 75 | struct net_device *dev; |
| 76 | |
| 77 | u32 msg_enable; |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 78 | |
| 79 | struct list_head port_list; |
| 80 | |
| 81 | struct hlist_head port_hash[VNET_PORT_HASH_SIZE]; |
David S. Miller | 9184a04 | 2007-07-17 22:19:10 -0700 | [diff] [blame] | 82 | |
David S. Miller | 028ebff | 2007-07-20 02:30:25 -0700 | [diff] [blame] | 83 | struct vnet_mcast_entry *mcast_list; |
| 84 | |
David S. Miller | 9184a04 | 2007-07-17 22:19:10 -0700 | [diff] [blame] | 85 | struct list_head list; |
| 86 | u64 local_mac; |
Sowmini Varadhan | 1d311ad | 2014-08-13 10:29:41 -0400 | [diff] [blame] | 87 | |
| 88 | struct tasklet_struct vnet_tx_wakeup; |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | #endif /* _SUNVNET_H */ |