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 | 8e845f4c | 2014-09-29 19:48:11 -0400 | [diff] [blame] | 14 | /* length of time (or less) we expect pending descriptors to be marked |
| 15 | * as VIO_DESC_DONE and skbs ready to be freed |
| 16 | */ |
| 17 | #define VNET_CLEAN_TIMEOUT ((HZ/100)+1) |
| 18 | |
David L Stevens | 42db672 | 2014-09-29 19:48:18 -0400 | [diff] [blame] | 19 | #define VNET_MAXPACKET (65535ULL + ETH_HLEN + VLAN_HLEN) |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 20 | #define VNET_TX_RING_SIZE 512 |
| 21 | #define VNET_TX_WAKEUP_THRESH(dr) ((dr)->pending / 4) |
| 22 | |
David L Stevens | 368e36e | 2014-12-02 15:31:38 -0500 | [diff] [blame] | 23 | #define VNET_MINTSO 2048 /* VIO protocol's minimum TSO len */ |
| 24 | #define VNET_MAXTSO 65535 /* VIO protocol's maximum TSO len */ |
| 25 | |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 26 | /* VNET packets are sent in buffers with the first 6 bytes skipped |
| 27 | * so that after the ethernet header the IPv4/IPv6 headers are aligned |
| 28 | * properly. |
| 29 | */ |
| 30 | #define VNET_PACKET_SKIP 6 |
| 31 | |
David L Stevens | 42db672 | 2014-09-29 19:48:18 -0400 | [diff] [blame] | 32 | #define VNET_MAXCOOKIES (VNET_MAXPACKET/PAGE_SIZE + 1) |
| 33 | |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 34 | struct vnet_tx_entry { |
David L Stevens | 8e845f4c | 2014-09-29 19:48:11 -0400 | [diff] [blame] | 35 | struct sk_buff *skb; |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 36 | unsigned int ncookies; |
David L Stevens | 42db672 | 2014-09-29 19:48:18 -0400 | [diff] [blame] | 37 | struct ldc_trans_cookie cookies[VNET_MAXCOOKIES]; |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | struct vnet; |
| 41 | struct vnet_port { |
| 42 | struct vio_driver_state vio; |
| 43 | |
| 44 | struct hlist_node hash; |
| 45 | u8 raddr[ETH_ALEN]; |
David L Stevens | 368e36e | 2014-12-02 15:31:38 -0500 | [diff] [blame] | 46 | unsigned switch_port:1; |
| 47 | unsigned tso:1; |
| 48 | unsigned __pad:14; |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 49 | |
| 50 | struct vnet *vp; |
| 51 | |
| 52 | struct vnet_tx_entry tx_bufs[VNET_TX_RING_SIZE]; |
| 53 | |
| 54 | struct list_head list; |
Sowmini Varadhan | d101564 | 2014-09-11 09:57:22 -0400 | [diff] [blame] | 55 | |
| 56 | u32 stop_rx_idx; |
| 57 | bool stop_rx; |
| 58 | bool start_cons; |
David L Stevens | e4defc7 | 2014-09-29 19:47:59 -0400 | [diff] [blame] | 59 | |
David L Stevens | 8e845f4c | 2014-09-29 19:48:11 -0400 | [diff] [blame] | 60 | struct timer_list clean_timer; |
| 61 | |
David L Stevens | e4defc7 | 2014-09-29 19:47:59 -0400 | [diff] [blame] | 62 | u64 rmtu; |
David L Stevens | 368e36e | 2014-12-02 15:31:38 -0500 | [diff] [blame] | 63 | u16 tsolen; |
Sowmini Varadhan | 6908882 | 2014-10-25 15:12:12 -0400 | [diff] [blame] | 64 | |
| 65 | struct napi_struct napi; |
| 66 | u32 napi_stop_idx; |
| 67 | bool napi_resume; |
| 68 | int rx_event; |
Sowmini Varadhan | d51bffd | 2014-10-30 12:46:09 -0400 | [diff] [blame] | 69 | u16 q_index; |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | static inline struct vnet_port *to_vnet_port(struct vio_driver_state *vio) |
| 73 | { |
| 74 | return container_of(vio, struct vnet_port, vio); |
| 75 | } |
| 76 | |
| 77 | #define VNET_PORT_HASH_SIZE 16 |
| 78 | #define VNET_PORT_HASH_MASK (VNET_PORT_HASH_SIZE - 1) |
| 79 | |
| 80 | static inline unsigned int vnet_hashfn(u8 *mac) |
| 81 | { |
| 82 | unsigned int val = mac[4] ^ mac[5]; |
| 83 | |
| 84 | return val & (VNET_PORT_HASH_MASK); |
| 85 | } |
| 86 | |
David S. Miller | 028ebff | 2007-07-20 02:30:25 -0700 | [diff] [blame] | 87 | struct vnet_mcast_entry { |
| 88 | u8 addr[ETH_ALEN]; |
| 89 | u8 sent; |
| 90 | u8 hit; |
| 91 | struct vnet_mcast_entry *next; |
| 92 | }; |
| 93 | |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 94 | struct vnet { |
| 95 | /* Protects port_list and port_hash. */ |
| 96 | spinlock_t lock; |
| 97 | |
| 98 | struct net_device *dev; |
| 99 | |
| 100 | u32 msg_enable; |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 101 | |
| 102 | struct list_head port_list; |
| 103 | |
| 104 | struct hlist_head port_hash[VNET_PORT_HASH_SIZE]; |
David S. Miller | 9184a04 | 2007-07-17 22:19:10 -0700 | [diff] [blame] | 105 | |
David S. Miller | 028ebff | 2007-07-20 02:30:25 -0700 | [diff] [blame] | 106 | struct vnet_mcast_entry *mcast_list; |
| 107 | |
David S. Miller | 9184a04 | 2007-07-17 22:19:10 -0700 | [diff] [blame] | 108 | struct list_head list; |
| 109 | u64 local_mac; |
Sowmini Varadhan | 1d311ad | 2014-08-13 10:29:41 -0400 | [diff] [blame] | 110 | |
Sowmini Varadhan | d51bffd | 2014-10-30 12:46:09 -0400 | [diff] [blame] | 111 | int nports; |
David S. Miller | 4c521e4 | 2007-07-09 22:23:51 -0700 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | #endif /* _SUNVNET_H */ |