02f507db99512789b35676e1b2a60d2dbaed7f75
[pandora-kernel.git] / drivers / net / ethernet / sun / sunvnet.h
1 #ifndef _SUNVNET_H
2 #define _SUNVNET_H
3
4 #include <linux/interrupt.h>
5
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 /* 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
19 #define VNET_MAXPACKET                  1518ULL /* ETH_FRAMELEN + VLAN_HDR */
20 #define VNET_TX_RING_SIZE               512
21 #define VNET_TX_WAKEUP_THRESH(dr)       ((dr)->pending / 4)
22
23 /* VNET packets are sent in buffers with the first 6 bytes skipped
24  * so that after the ethernet header the IPv4/IPv6 headers are aligned
25  * properly.
26  */
27 #define VNET_PACKET_SKIP                6
28
29 struct vnet_tx_entry {
30         struct sk_buff          *skb;
31         unsigned int            ncookies;
32         struct ldc_trans_cookie cookies[2];
33 };
34
35 struct vnet;
36 struct vnet_port {
37         struct vio_driver_state vio;
38
39         struct hlist_node       hash;
40         u8                      raddr[ETH_ALEN];
41         u8                      switch_port;
42         u8                      __pad;
43
44         struct vnet             *vp;
45
46         struct vnet_tx_entry    tx_bufs[VNET_TX_RING_SIZE];
47
48         struct list_head        list;
49
50         u32                     stop_rx_idx;
51         bool                    stop_rx;
52         bool                    start_cons;
53
54         struct timer_list       clean_timer;
55
56         u64                     rmtu;
57 };
58
59 static inline struct vnet_port *to_vnet_port(struct vio_driver_state *vio)
60 {
61         return container_of(vio, struct vnet_port, vio);
62 }
63
64 #define VNET_PORT_HASH_SIZE     16
65 #define VNET_PORT_HASH_MASK     (VNET_PORT_HASH_SIZE - 1)
66
67 static inline unsigned int vnet_hashfn(u8 *mac)
68 {
69         unsigned int val = mac[4] ^ mac[5];
70
71         return val & (VNET_PORT_HASH_MASK);
72 }
73
74 struct vnet_mcast_entry {
75         u8                      addr[ETH_ALEN];
76         u8                      sent;
77         u8                      hit;
78         struct vnet_mcast_entry *next;
79 };
80
81 struct vnet {
82         /* Protects port_list and port_hash.  */
83         spinlock_t              lock;
84
85         struct net_device       *dev;
86
87         u32                     msg_enable;
88
89         struct list_head        port_list;
90
91         struct hlist_head       port_hash[VNET_PORT_HASH_SIZE];
92
93         struct vnet_mcast_entry *mcast_list;
94
95         struct list_head        list;
96         u64                     local_mac;
97
98         struct tasklet_struct   vnet_tx_wakeup;
99 };
100
101 #endif /* _SUNVNET_H */