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