]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - drivers/net/ethernet/sun/sunvnet_common.h
ethernet/sun: use core min/max MTU checking
[mirror_ubuntu-zesty-kernel.git] / drivers / net / ethernet / sun / sunvnet_common.h
CommitLineData
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
540bfe30
JW
18#define VNET_MAX_MTU 65535
19
4c521e42
DM
20/* VNET packets are sent in buffers with the first 6 bytes skipped
21 * so that after the ethernet header the IPv4/IPv6 headers are aligned
22 * properly.
23 */
24#define VNET_PACKET_SKIP 6
25
31762eaa
AY
26#define VNET_MAXCOOKIES (VNET_MAXPACKET / PAGE_SIZE + 1)
27
28#define VNET_MAX_TXQS 16
42db672d 29
4c521e42 30struct vnet_tx_entry {
8e845f4c 31 struct sk_buff *skb;
4c521e42 32 unsigned int ncookies;
42db672d 33 struct ldc_trans_cookie cookies[VNET_MAXCOOKIES];
4c521e42
DM
34};
35
36struct vnet;
67d0719f
AY
37
38/* Structure to describe a vnet-port or vsw-port in the MD.
39 * If the vsw bit is set, this structure represents a vswitch
40 * port, and the net_device can be found from ->dev. If the
41 * vsw bit is not set, the net_device is available from ->vp->dev.
42 * See the VNET_PORT_TO_NET_DEVICE macro below.
43 */
4c521e42
DM
44struct vnet_port {
45 struct vio_driver_state vio;
46
47 struct hlist_node hash;
48 u8 raddr[ETH_ALEN];
368e36ed
DS
49 unsigned switch_port:1;
50 unsigned tso:1;
67d0719f
AY
51 unsigned vsw:1;
52 unsigned __pad:13;
4c521e42
DM
53
54 struct vnet *vp;
67d0719f 55 struct net_device *dev;
4c521e42
DM
56
57 struct vnet_tx_entry tx_bufs[VNET_TX_RING_SIZE];
58
59 struct list_head list;
d1015645
SV
60
61 u32 stop_rx_idx;
62 bool stop_rx;
63 bool start_cons;
e4defc77 64
8e845f4c
DS
65 struct timer_list clean_timer;
66
e4defc77 67 u64 rmtu;
368e36ed 68 u16 tsolen;
69088822
SV
69
70 struct napi_struct napi;
71 u32 napi_stop_idx;
72 bool napi_resume;
73 int rx_event;
d51bffd1 74 u16 q_index;
4c521e42
DM
75};
76
77static inline struct vnet_port *to_vnet_port(struct vio_driver_state *vio)
78{
79 return container_of(vio, struct vnet_port, vio);
80}
81
82#define VNET_PORT_HASH_SIZE 16
83#define VNET_PORT_HASH_MASK (VNET_PORT_HASH_SIZE - 1)
84
85static inline unsigned int vnet_hashfn(u8 *mac)
86{
87 unsigned int val = mac[4] ^ mac[5];
88
89 return val & (VNET_PORT_HASH_MASK);
90}
91
028ebff2
DM
92struct vnet_mcast_entry {
93 u8 addr[ETH_ALEN];
94 u8 sent;
95 u8 hit;
96 struct vnet_mcast_entry *next;
97};
98
4c521e42
DM
99struct vnet {
100 /* Protects port_list and port_hash. */
101 spinlock_t lock;
102
103 struct net_device *dev;
104
105 u32 msg_enable;
4c521e42
DM
106
107 struct list_head port_list;
108
109 struct hlist_head port_hash[VNET_PORT_HASH_SIZE];
9184a046 110
028ebff2
DM
111 struct vnet_mcast_entry *mcast_list;
112
9184a046
DM
113 struct list_head list;
114 u64 local_mac;
1d311ad2 115
d51bffd1 116 int nports;
4c521e42
DM
117};
118
67d0719f
AY
119/* Def used by common code to get the net_device from the proper location */
120#define VNET_PORT_TO_NET_DEVICE(__port) \
121 ((__port)->vsw ? (__port)->dev : (__port)->vp->dev)
122
31762eaa
AY
123/* Common funcs */
124void sunvnet_clean_timer_expire_common(unsigned long port0);
125int sunvnet_open_common(struct net_device *dev);
126int sunvnet_close_common(struct net_device *dev);
67d0719f 127void sunvnet_set_rx_mode_common(struct net_device *dev, struct vnet *vp);
31762eaa
AY
128int sunvnet_set_mac_addr_common(struct net_device *dev, void *p);
129void sunvnet_tx_timeout_common(struct net_device *dev);
67d0719f
AY
130int sunvnet_start_xmit_common(struct sk_buff *skb, struct net_device *dev,
131 struct vnet_port *(*vnet_tx_port)
132 (struct sk_buff *, struct net_device *));
31762eaa 133#ifdef CONFIG_NET_POLL_CONTROLLER
67d0719f 134void sunvnet_poll_controller_common(struct net_device *dev, struct vnet *vp);
31762eaa
AY
135#endif
136void sunvnet_event_common(void *arg, int event);
137int sunvnet_send_attr_common(struct vio_driver_state *vio);
138int sunvnet_handle_attr_common(struct vio_driver_state *vio, void *arg);
139void sunvnet_handshake_complete_common(struct vio_driver_state *vio);
140int sunvnet_poll_common(struct napi_struct *napi, int budget);
141void sunvnet_port_free_tx_bufs_common(struct vnet_port *port);
67d0719f 142bool sunvnet_port_is_up_common(struct vnet_port *vnet);
31762eaa
AY
143void sunvnet_port_add_txq_common(struct vnet_port *port);
144void sunvnet_port_rm_txq_common(struct vnet_port *port);
145
146#endif /* _SUNVNETCOMMON_H */