blob: 986e04b9313dbabddda278551b075f0d56ee261e [file] [log] [blame]
David S. Miller4c521e42007-07-09 22:23:51 -07001#ifndef _SUNVNET_H
2#define _SUNVNET_H
3
Sowmini Varadhan1d311ad2014-08-13 10:29:41 -04004#include <linux/interrupt.h>
5
David S. Miller4c521e42007-07-09 22:23:51 -07006#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 Stevense4defc72014-09-29 19:47:59 -040014#define VNET_MAXPACKET 1518ULL /* ETH_FRAMELEN + VLAN_HDR */
David S. Miller4c521e42007-07-09 22:23:51 -070015#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
24struct vnet_tx_entry {
25 void *buf;
26 unsigned int ncookies;
27 struct ldc_trans_cookie cookies[2];
28};
29
30struct vnet;
31struct vnet_port {
32 struct vio_driver_state vio;
33
34 struct hlist_node hash;
35 u8 raddr[ETH_ALEN];
David S. Miller028ebff2007-07-20 02:30:25 -070036 u8 switch_port;
37 u8 __pad;
David S. Miller4c521e42007-07-09 22:23:51 -070038
39 struct vnet *vp;
40
41 struct vnet_tx_entry tx_bufs[VNET_TX_RING_SIZE];
42
43 struct list_head list;
Sowmini Varadhand1015642014-09-11 09:57:22 -040044
45 u32 stop_rx_idx;
46 bool stop_rx;
47 bool start_cons;
David L Stevense4defc72014-09-29 19:47:59 -040048
49 u64 rmtu;
David S. Miller4c521e42007-07-09 22:23:51 -070050};
51
52static 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
60static 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. Miller028ebff2007-07-20 02:30:25 -070067struct vnet_mcast_entry {
68 u8 addr[ETH_ALEN];
69 u8 sent;
70 u8 hit;
71 struct vnet_mcast_entry *next;
72};
73
David S. Miller4c521e42007-07-09 22:23:51 -070074struct 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. Miller4c521e42007-07-09 22:23:51 -070081
82 struct list_head port_list;
83
84 struct hlist_head port_hash[VNET_PORT_HASH_SIZE];
David S. Miller9184a042007-07-17 22:19:10 -070085
David S. Miller028ebff2007-07-20 02:30:25 -070086 struct vnet_mcast_entry *mcast_list;
87
David S. Miller9184a042007-07-17 22:19:10 -070088 struct list_head list;
89 u64 local_mac;
Sowmini Varadhan1d311ad2014-08-13 10:29:41 -040090
91 struct tasklet_struct vnet_tx_wakeup;
David S. Miller4c521e42007-07-09 22:23:51 -070092};
93
94#endif /* _SUNVNET_H */