Commit | Line | Data |
---|---|---|
31762eaa AY |
1 | #ifndef _SUNVNETCOMMON_H |
2 | #define _SUNVNETCOMMON_H | |
4c521e42 | 3 | |
1d311ad2 SV |
4 | #include <linux/interrupt.h> |
5 | ||
8e845f4c DS |
6 | /* length of time (or less) we expect pending descriptors to be marked |
7 | * as VIO_DESC_DONE and skbs ready to be freed | |
8 | */ | |
31762eaa | 9 | #define VNET_CLEAN_TIMEOUT ((HZ / 100) + 1) |
8e845f4c | 10 | |
42db672d | 11 | #define VNET_MAXPACKET (65535ULL + ETH_HLEN + VLAN_HLEN) |
4c521e42 DM |
12 | #define VNET_TX_RING_SIZE 512 |
13 | #define VNET_TX_WAKEUP_THRESH(dr) ((dr)->pending / 4) | |
14 | ||
368e36ed DS |
15 | #define VNET_MINTSO 2048 /* VIO protocol's minimum TSO len */ |
16 | #define VNET_MAXTSO 65535 /* VIO protocol's maximum TSO len */ | |
17 | ||
4c521e42 DM |
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 | ||
31762eaa AY |
24 | #define VNET_MAXCOOKIES (VNET_MAXPACKET / PAGE_SIZE + 1) |
25 | ||
26 | #define VNET_MAX_TXQS 16 | |
42db672d | 27 | |
4c521e42 | 28 | struct vnet_tx_entry { |
8e845f4c | 29 | struct sk_buff *skb; |
4c521e42 | 30 | unsigned int ncookies; |
42db672d | 31 | struct ldc_trans_cookie cookies[VNET_MAXCOOKIES]; |
4c521e42 DM |
32 | }; |
33 | ||
34 | struct vnet; | |
67d0719f AY |
35 | |
36 | /* Structure to describe a vnet-port or vsw-port in the MD. | |
37 | * If the vsw bit is set, this structure represents a vswitch | |
38 | * port, and the net_device can be found from ->dev. If the | |
39 | * vsw bit is not set, the net_device is available from ->vp->dev. | |
40 | * See the VNET_PORT_TO_NET_DEVICE macro below. | |
41 | */ | |
4c521e42 DM |
42 | struct vnet_port { |
43 | struct vio_driver_state vio; | |
44 | ||
45 | struct hlist_node hash; | |
46 | u8 raddr[ETH_ALEN]; | |
368e36ed DS |
47 | unsigned switch_port:1; |
48 | unsigned tso:1; | |
67d0719f AY |
49 | unsigned vsw:1; |
50 | unsigned __pad:13; | |
4c521e42 DM |
51 | |
52 | struct vnet *vp; | |
67d0719f | 53 | struct net_device *dev; |
4c521e42 DM |
54 | |
55 | struct vnet_tx_entry tx_bufs[VNET_TX_RING_SIZE]; | |
56 | ||
57 | struct list_head list; | |
d1015645 SV |
58 | |
59 | u32 stop_rx_idx; | |
60 | bool stop_rx; | |
61 | bool start_cons; | |
e4defc77 | 62 | |
8e845f4c DS |
63 | struct timer_list clean_timer; |
64 | ||
e4defc77 | 65 | u64 rmtu; |
368e36ed | 66 | u16 tsolen; |
69088822 SV |
67 | |
68 | struct napi_struct napi; | |
69 | u32 napi_stop_idx; | |
70 | bool napi_resume; | |
71 | int rx_event; | |
d51bffd1 | 72 | u16 q_index; |
4c521e42 DM |
73 | }; |
74 | ||
75 | static inline struct vnet_port *to_vnet_port(struct vio_driver_state *vio) | |
76 | { | |
77 | return container_of(vio, struct vnet_port, vio); | |
78 | } | |
79 | ||
80 | #define VNET_PORT_HASH_SIZE 16 | |
81 | #define VNET_PORT_HASH_MASK (VNET_PORT_HASH_SIZE - 1) | |
82 | ||
83 | static inline unsigned int vnet_hashfn(u8 *mac) | |
84 | { | |
85 | unsigned int val = mac[4] ^ mac[5]; | |
86 | ||
87 | return val & (VNET_PORT_HASH_MASK); | |
88 | } | |
89 | ||
028ebff2 DM |
90 | struct vnet_mcast_entry { |
91 | u8 addr[ETH_ALEN]; | |
92 | u8 sent; | |
93 | u8 hit; | |
94 | struct vnet_mcast_entry *next; | |
95 | }; | |
96 | ||
4c521e42 DM |
97 | struct vnet { |
98 | /* Protects port_list and port_hash. */ | |
99 | spinlock_t lock; | |
100 | ||
101 | struct net_device *dev; | |
102 | ||
103 | u32 msg_enable; | |
4c521e42 DM |
104 | |
105 | struct list_head port_list; | |
106 | ||
107 | struct hlist_head port_hash[VNET_PORT_HASH_SIZE]; | |
9184a046 | 108 | |
028ebff2 DM |
109 | struct vnet_mcast_entry *mcast_list; |
110 | ||
9184a046 DM |
111 | struct list_head list; |
112 | u64 local_mac; | |
1d311ad2 | 113 | |
d51bffd1 | 114 | int nports; |
4c521e42 DM |
115 | }; |
116 | ||
67d0719f AY |
117 | /* Def used by common code to get the net_device from the proper location */ |
118 | #define VNET_PORT_TO_NET_DEVICE(__port) \ | |
119 | ((__port)->vsw ? (__port)->dev : (__port)->vp->dev) | |
120 | ||
31762eaa AY |
121 | /* Common funcs */ |
122 | void sunvnet_clean_timer_expire_common(unsigned long port0); | |
123 | int sunvnet_open_common(struct net_device *dev); | |
124 | int sunvnet_close_common(struct net_device *dev); | |
67d0719f | 125 | void sunvnet_set_rx_mode_common(struct net_device *dev, struct vnet *vp); |
31762eaa AY |
126 | int sunvnet_set_mac_addr_common(struct net_device *dev, void *p); |
127 | void sunvnet_tx_timeout_common(struct net_device *dev); | |
128 | int sunvnet_change_mtu_common(struct net_device *dev, int new_mtu); | |
67d0719f AY |
129 | int sunvnet_start_xmit_common(struct sk_buff *skb, struct net_device *dev, |
130 | struct vnet_port *(*vnet_tx_port) | |
131 | (struct sk_buff *, struct net_device *)); | |
31762eaa | 132 | #ifdef CONFIG_NET_POLL_CONTROLLER |
67d0719f | 133 | void sunvnet_poll_controller_common(struct net_device *dev, struct vnet *vp); |
31762eaa AY |
134 | #endif |
135 | void sunvnet_event_common(void *arg, int event); | |
136 | int sunvnet_send_attr_common(struct vio_driver_state *vio); | |
137 | int sunvnet_handle_attr_common(struct vio_driver_state *vio, void *arg); | |
138 | void sunvnet_handshake_complete_common(struct vio_driver_state *vio); | |
139 | int sunvnet_poll_common(struct napi_struct *napi, int budget); | |
140 | void sunvnet_port_free_tx_bufs_common(struct vnet_port *port); | |
67d0719f | 141 | bool sunvnet_port_is_up_common(struct vnet_port *vnet); |
31762eaa AY |
142 | void sunvnet_port_add_txq_common(struct vnet_port *port); |
143 | void sunvnet_port_rm_txq_common(struct vnet_port *port); | |
144 | ||
145 | #endif /* _SUNVNETCOMMON_H */ |