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 | |
David L Stevens | e4defc7 | 2014-09-29 19:47:59 -0400 | [diff] [blame^] | 14 | #define VNET_MAXPACKET 1518ULL /* ETH_FRAMELEN + VLAN_HDR */ |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 15 | #define VNET_TX_RING_SIZE 512 |
| 16 | #define VNET_TX_WAKEUP_THRESH(dr) ((dr)->pending / 4) |
| 17 | |
| 18 | /* VNET packets are sent in buffers with the first 6 bytes skipped |
| 19 | * so that after the ethernet header the IPv4/IPv6 headers are aligned |
| 20 | * properly. |
| 21 | */ |
| 22 | #define VNET_PACKET_SKIP 6 |
| 23 | |
| 24 | struct vnet_tx_entry { |
| 25 | void *buf; |
| 26 | unsigned int ncookies; |
| 27 | struct ldc_trans_cookie cookies[2]; |
| 28 | }; |
| 29 | |
| 30 | struct vnet; |
| 31 | struct vnet_port { |
| 32 | struct vio_driver_state vio; |
| 33 | |
| 34 | struct hlist_node hash; |
| 35 | u8 raddr[ETH_ALEN]; |
David S. Miller | 028ebff | 2007-07-20 02:30:25 -0700 | [diff] [blame] | 36 | u8 switch_port; |
| 37 | u8 __pad; |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 38 | |
| 39 | struct vnet *vp; |
| 40 | |
| 41 | struct vnet_tx_entry tx_bufs[VNET_TX_RING_SIZE]; |
| 42 | |
| 43 | struct list_head list; |
Sowmini Varadhan | d101564 | 2014-09-11 09:57:22 -0400 | [diff] [blame] | 44 | |
| 45 | u32 stop_rx_idx; |
| 46 | bool stop_rx; |
| 47 | bool start_cons; |
David L Stevens | e4defc7 | 2014-09-29 19:47:59 -0400 | [diff] [blame^] | 48 | |
| 49 | u64 rmtu; |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | static inline struct vnet_port *to_vnet_port(struct vio_driver_state *vio) |
| 53 | { |
| 54 | return container_of(vio, struct vnet_port, vio); |
| 55 | } |
| 56 | |
| 57 | #define VNET_PORT_HASH_SIZE 16 |
| 58 | #define VNET_PORT_HASH_MASK (VNET_PORT_HASH_SIZE - 1) |
| 59 | |
| 60 | static inline unsigned int vnet_hashfn(u8 *mac) |
| 61 | { |
| 62 | unsigned int val = mac[4] ^ mac[5]; |
| 63 | |
| 64 | return val & (VNET_PORT_HASH_MASK); |
| 65 | } |
| 66 | |
David S. Miller | 028ebff | 2007-07-20 02:30:25 -0700 | [diff] [blame] | 67 | struct vnet_mcast_entry { |
| 68 | u8 addr[ETH_ALEN]; |
| 69 | u8 sent; |
| 70 | u8 hit; |
| 71 | struct vnet_mcast_entry *next; |
| 72 | }; |
| 73 | |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 74 | struct vnet { |
| 75 | /* Protects port_list and port_hash. */ |
| 76 | spinlock_t lock; |
| 77 | |
| 78 | struct net_device *dev; |
| 79 | |
| 80 | u32 msg_enable; |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 81 | |
| 82 | struct list_head port_list; |
| 83 | |
| 84 | struct hlist_head port_hash[VNET_PORT_HASH_SIZE]; |
David S. Miller | 9184a04 | 2007-07-17 22:19:10 -0700 | [diff] [blame] | 85 | |
David S. Miller | 028ebff | 2007-07-20 02:30:25 -0700 | [diff] [blame] | 86 | struct vnet_mcast_entry *mcast_list; |
| 87 | |
David S. Miller | 9184a04 | 2007-07-17 22:19:10 -0700 | [diff] [blame] | 88 | struct list_head list; |
| 89 | u64 local_mac; |
Sowmini Varadhan | 1d311ad | 2014-08-13 10:29:41 -0400 | [diff] [blame] | 90 | |
| 91 | struct tasklet_struct vnet_tx_wakeup; |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | #endif /* _SUNVNET_H */ |