]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - drivers/s390/net/lcs.h
Linux-2.6.12-rc2
[mirror_ubuntu-zesty-kernel.git] / drivers / s390 / net / lcs.h
1 /*lcs.h*/
2
3 #include <linux/interrupt.h>
4 #include <linux/netdevice.h>
5 #include <linux/skbuff.h>
6 #include <linux/workqueue.h>
7 #include <asm/ccwdev.h>
8
9 #define VERSION_LCS_H "$Revision: 1.19 $"
10
11 #define LCS_DBF_TEXT(level, name, text) \
12 do { \
13 debug_text_event(lcs_dbf_##name, level, text); \
14 } while (0)
15
16 #define LCS_DBF_HEX(level,name,addr,len) \
17 do { \
18 debug_event(lcs_dbf_##name,level,(void*)(addr),len); \
19 } while (0)
20
21 #define LCS_DBF_TEXT_(level,name,text...) \
22 do { \
23 sprintf(debug_buffer, text); \
24 debug_text_event(lcs_dbf_##name,level, debug_buffer);\
25 } while (0)
26
27 /**
28 * some more definitions for debug or output stuff
29 */
30 #define PRINTK_HEADER " lcs: "
31
32 /**
33 * sysfs related stuff
34 */
35 #define CARD_FROM_DEV(cdev) \
36 (struct lcs_card *) \
37 ((struct ccwgroup_device *)cdev->dev.driver_data)->dev.driver_data;
38 /**
39 * CCW commands used in this driver
40 */
41 #define LCS_CCW_WRITE 0x01
42 #define LCS_CCW_READ 0x02
43 #define LCS_CCW_TRANSFER 0x08
44
45 /**
46 * LCS device status primitives
47 */
48 #define LCS_CMD_STARTLAN 0x01
49 #define LCS_CMD_STOPLAN 0x02
50 #define LCS_CMD_LANSTAT 0x04
51 #define LCS_CMD_STARTUP 0x07
52 #define LCS_CMD_SHUTDOWN 0x08
53 #define LCS_CMD_QIPASSIST 0xb2
54 #define LCS_CMD_SETIPM 0xb4
55 #define LCS_CMD_DELIPM 0xb5
56
57 #define LCS_INITIATOR_TCPIP 0x00
58 #define LCS_INITIATOR_LGW 0x01
59 #define LCS_STD_CMD_SIZE 16
60 #define LCS_MULTICAST_CMD_SIZE 404
61
62 /**
63 * LCS IPASSIST MASKS,only used when multicast is switched on
64 */
65 /* Not supported by LCS */
66 #define LCS_IPASS_ARP_PROCESSING 0x0001
67 #define LCS_IPASS_IN_CHECKSUM_SUPPORT 0x0002
68 #define LCS_IPASS_OUT_CHECKSUM_SUPPORT 0x0004
69 #define LCS_IPASS_IP_FRAG_REASSEMBLY 0x0008
70 #define LCS_IPASS_IP_FILTERING 0x0010
71 /* Supported by lcs 3172 */
72 #define LCS_IPASS_IPV6_SUPPORT 0x0020
73 #define LCS_IPASS_MULTICAST_SUPPORT 0x0040
74
75 /**
76 * LCS sense byte definitions
77 */
78 #define LCS_SENSE_INTERFACE_DISCONNECT 0x01
79 #define LCS_SENSE_EQUIPMENT_CHECK 0x10
80 #define LCS_SENSE_BUS_OUT_CHECK 0x20
81 #define LCS_SENSE_INTERVENTION_REQUIRED 0x40
82 #define LCS_SENSE_CMD_REJECT 0x80
83 #define LCS_SENSE_RESETTING_EVENT 0x0080
84 #define LCS_SENSE_DEVICE_ONLINE 0x0020
85
86 /**
87 * LCS packet type definitions
88 */
89 #define LCS_FRAME_TYPE_CONTROL 0
90 #define LCS_FRAME_TYPE_ENET 1
91 #define LCS_FRAME_TYPE_TR 2
92 #define LCS_FRAME_TYPE_FDDI 7
93 #define LCS_FRAME_TYPE_AUTO -1
94
95 /**
96 * some more definitions,we will sort them later
97 */
98 #define LCS_ILLEGAL_OFFSET 0xffff
99 #define LCS_IOBUFFERSIZE 0x5000
100 #define LCS_NUM_BUFFS 8 /* needs to be power of 2 */
101 #define LCS_MAC_LENGTH 6
102 #define LCS_INVALID_PORT_NO -1
103 #define LCS_LANCMD_TIMEOUT_DEFAULT 5
104
105 /**
106 * Multicast state
107 */
108 #define LCS_IPM_STATE_SET_REQUIRED 0
109 #define LCS_IPM_STATE_DEL_REQUIRED 1
110 #define LCS_IPM_STATE_ON_CARD 2
111
112 /**
113 * LCS IP Assist declarations
114 * seems to be only used for multicast
115 */
116 #define LCS_IPASS_ARP_PROCESSING 0x0001
117 #define LCS_IPASS_INBOUND_CSUM_SUPP 0x0002
118 #define LCS_IPASS_OUTBOUND_CSUM_SUPP 0x0004
119 #define LCS_IPASS_IP_FRAG_REASSEMBLY 0x0008
120 #define LCS_IPASS_IP_FILTERING 0x0010
121 #define LCS_IPASS_IPV6_SUPPORT 0x0020
122 #define LCS_IPASS_MULTICAST_SUPPORT 0x0040
123
124 /**
125 * LCS Buffer states
126 */
127 enum lcs_buffer_states {
128 BUF_STATE_EMPTY, /* buffer is empty */
129 BUF_STATE_LOCKED, /* buffer is locked, don't touch */
130 BUF_STATE_READY, /* buffer is ready for read/write */
131 BUF_STATE_PROCESSED,
132 };
133
134 /**
135 * LCS Channel State Machine declarations
136 */
137 enum lcs_channel_states {
138 CH_STATE_INIT,
139 CH_STATE_HALTED,
140 CH_STATE_STOPPED,
141 CH_STATE_RUNNING,
142 CH_STATE_SUSPENDED,
143 CH_STATE_CLEARED,
144 };
145
146 /**
147 * LCS device state machine
148 */
149 enum lcs_dev_states {
150 DEV_STATE_DOWN,
151 DEV_STATE_UP,
152 DEV_STATE_RECOVER,
153 };
154
155 enum lcs_threads {
156 LCS_SET_MC_THREAD = 1,
157 LCS_STARTLAN_THREAD = 2,
158 LCS_STOPLAN_THREAD = 4,
159 LCS_STARTUP_THREAD = 8,
160 };
161 /**
162 * LCS struct declarations
163 */
164 struct lcs_header {
165 __u16 offset;
166 __u8 type;
167 __u8 slot;
168 } __attribute__ ((packed));
169
170 struct lcs_ip_mac_pair {
171 __u32 ip_addr;
172 __u8 mac_addr[LCS_MAC_LENGTH];
173 __u8 reserved[2];
174 } __attribute__ ((packed));
175
176 struct lcs_ipm_list {
177 struct list_head list;
178 struct lcs_ip_mac_pair ipm;
179 __u8 ipm_state;
180 };
181
182 struct lcs_cmd {
183 __u16 offset;
184 __u8 type;
185 __u8 slot;
186 __u8 cmd_code;
187 __u8 initiator;
188 __u16 sequence_no;
189 __u16 return_code;
190 union {
191 struct {
192 __u8 lan_type;
193 __u8 portno;
194 __u16 parameter_count;
195 __u8 operator_flags[3];
196 __u8 reserved[3];
197 } lcs_std_cmd;
198 struct {
199 __u16 unused1;
200 __u16 buff_size;
201 __u8 unused2[6];
202 } lcs_startup;
203 struct {
204 __u8 lan_type;
205 __u8 portno;
206 __u8 unused[10];
207 __u8 mac_addr[LCS_MAC_LENGTH];
208 __u32 num_packets_deblocked;
209 __u32 num_packets_blocked;
210 __u32 num_packets_tx_on_lan;
211 __u32 num_tx_errors_detected;
212 __u32 num_tx_packets_disgarded;
213 __u32 num_packets_rx_from_lan;
214 __u32 num_rx_errors_detected;
215 __u32 num_rx_discarded_nobuffs_avail;
216 __u32 num_rx_packets_too_large;
217 } lcs_lanstat_cmd;
218 #ifdef CONFIG_IP_MULTICAST
219 struct {
220 __u8 lan_type;
221 __u8 portno;
222 __u16 num_ip_pairs;
223 __u16 ip_assists_supported;
224 __u16 ip_assists_enabled;
225 __u16 version;
226 struct {
227 struct lcs_ip_mac_pair
228 ip_mac_pair[32];
229 __u32 response_data;
230 } lcs_ipass_ctlmsg __attribute ((packed));
231 } lcs_qipassist __attribute__ ((packed));
232 #endif /*CONFIG_IP_MULTICAST */
233 } cmd __attribute__ ((packed));
234 } __attribute__ ((packed));
235
236 /**
237 * Forward declarations.
238 */
239 struct lcs_card;
240 struct lcs_channel;
241
242 /**
243 * Definition of an lcs buffer.
244 */
245 struct lcs_buffer {
246 enum lcs_buffer_states state;
247 void *data;
248 int count;
249 /* Callback for completion notification. */
250 void (*callback)(struct lcs_channel *, struct lcs_buffer *);
251 };
252
253 struct lcs_reply {
254 struct list_head list;
255 __u16 sequence_no;
256 atomic_t refcnt;
257 /* Callback for completion notification. */
258 void (*callback)(struct lcs_card *, struct lcs_cmd *);
259 wait_queue_head_t wait_q;
260 struct lcs_card *card;
261 int received;
262 int rc;
263 };
264
265 /**
266 * Definition of an lcs channel
267 */
268 struct lcs_channel {
269 enum lcs_channel_states state;
270 struct ccw_device *ccwdev;
271 struct ccw1 ccws[LCS_NUM_BUFFS + 1];
272 wait_queue_head_t wait_q;
273 struct tasklet_struct irq_tasklet;
274 struct lcs_buffer iob[LCS_NUM_BUFFS];
275 int io_idx;
276 int buf_idx;
277 };
278
279
280 /**
281 * definition of the lcs card
282 */
283 struct lcs_card {
284 spinlock_t lock;
285 spinlock_t ipm_lock;
286 enum lcs_dev_states state;
287 struct net_device *dev;
288 struct net_device_stats stats;
289 unsigned short (*lan_type_trans)(struct sk_buff *skb,
290 struct net_device *dev);
291 struct lcs_channel read;
292 struct lcs_channel write;
293 struct lcs_buffer *tx_buffer;
294 int tx_emitted;
295 struct list_head lancmd_waiters;
296 int lancmd_timeout;
297
298 struct work_struct kernel_thread_starter;
299 spinlock_t mask_lock;
300 unsigned long thread_start_mask;
301 unsigned long thread_running_mask;
302 unsigned long thread_allowed_mask;
303 wait_queue_head_t wait_q;
304
305 #ifdef CONFIG_IP_MULTICAST
306 struct list_head ipm_list;
307 #endif
308 __u8 mac[LCS_MAC_LENGTH];
309 __u16 ip_assists_supported;
310 __u16 ip_assists_enabled;
311 __s8 lan_type;
312 __u32 pkt_seq;
313 __u16 sequence_no;
314 __s16 portno;
315 /* Some info copied from probeinfo */
316 u8 device_forced;
317 u8 max_port_no;
318 u8 hint_port_no;
319 s16 port_protocol_no;
320 } __attribute__ ((aligned(8)));
321