diff options
Diffstat (limited to 'drivers/s390')
-rw-r--r-- | drivers/s390/net/qeth.h | 1253 | ||||
-rw-r--r-- | drivers/s390/net/qeth_eddp.c | 634 | ||||
-rw-r--r-- | drivers/s390/net/qeth_eddp.h | 84 | ||||
-rw-r--r-- | drivers/s390/net/qeth_fs.h | 168 | ||||
-rw-r--r-- | drivers/s390/net/qeth_main.c | 8956 | ||||
-rw-r--r-- | drivers/s390/net/qeth_mpc.c | 269 | ||||
-rw-r--r-- | drivers/s390/net/qeth_mpc.h | 583 | ||||
-rw-r--r-- | drivers/s390/net/qeth_proc.c | 316 | ||||
-rw-r--r-- | drivers/s390/net/qeth_sys.c | 1858 | ||||
-rw-r--r-- | drivers/s390/net/qeth_tso.h | 148 |
10 files changed, 0 insertions, 14269 deletions
diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h deleted file mode 100644 index 8c6b72d05b1d..000000000000 --- a/drivers/s390/net/qeth.h +++ /dev/null | |||
@@ -1,1253 +0,0 @@ | |||
1 | #ifndef __QETH_H__ | ||
2 | #define __QETH_H__ | ||
3 | |||
4 | #include <linux/if.h> | ||
5 | #include <linux/if_arp.h> | ||
6 | |||
7 | #include <linux/if_tr.h> | ||
8 | #include <linux/trdevice.h> | ||
9 | #include <linux/etherdevice.h> | ||
10 | #include <linux/if_vlan.h> | ||
11 | #include <linux/ctype.h> | ||
12 | |||
13 | #include <net/ipv6.h> | ||
14 | #include <linux/in6.h> | ||
15 | #include <net/if_inet6.h> | ||
16 | #include <net/addrconf.h> | ||
17 | |||
18 | |||
19 | #include <linux/bitops.h> | ||
20 | |||
21 | #include <asm/debug.h> | ||
22 | #include <asm/qdio.h> | ||
23 | #include <asm/ccwdev.h> | ||
24 | #include <asm/ccwgroup.h> | ||
25 | |||
26 | #include "qeth_mpc.h" | ||
27 | |||
28 | #ifdef CONFIG_QETH_IPV6 | ||
29 | #define QETH_VERSION_IPV6 ":IPv6" | ||
30 | #else | ||
31 | #define QETH_VERSION_IPV6 "" | ||
32 | #endif | ||
33 | #ifdef CONFIG_QETH_VLAN | ||
34 | #define QETH_VERSION_VLAN ":VLAN" | ||
35 | #else | ||
36 | #define QETH_VERSION_VLAN "" | ||
37 | #endif | ||
38 | |||
39 | /** | ||
40 | * Debug Facility stuff | ||
41 | */ | ||
42 | #define QETH_DBF_SETUP_NAME "qeth_setup" | ||
43 | #define QETH_DBF_SETUP_LEN 8 | ||
44 | #define QETH_DBF_SETUP_PAGES 8 | ||
45 | #define QETH_DBF_SETUP_NR_AREAS 1 | ||
46 | #define QETH_DBF_SETUP_LEVEL 5 | ||
47 | |||
48 | #define QETH_DBF_MISC_NAME "qeth_misc" | ||
49 | #define QETH_DBF_MISC_LEN 128 | ||
50 | #define QETH_DBF_MISC_PAGES 2 | ||
51 | #define QETH_DBF_MISC_NR_AREAS 1 | ||
52 | #define QETH_DBF_MISC_LEVEL 2 | ||
53 | |||
54 | #define QETH_DBF_DATA_NAME "qeth_data" | ||
55 | #define QETH_DBF_DATA_LEN 96 | ||
56 | #define QETH_DBF_DATA_PAGES 8 | ||
57 | #define QETH_DBF_DATA_NR_AREAS 1 | ||
58 | #define QETH_DBF_DATA_LEVEL 2 | ||
59 | |||
60 | #define QETH_DBF_CONTROL_NAME "qeth_control" | ||
61 | #define QETH_DBF_CONTROL_LEN 256 | ||
62 | #define QETH_DBF_CONTROL_PAGES 8 | ||
63 | #define QETH_DBF_CONTROL_NR_AREAS 2 | ||
64 | #define QETH_DBF_CONTROL_LEVEL 5 | ||
65 | |||
66 | #define QETH_DBF_TRACE_NAME "qeth_trace" | ||
67 | #define QETH_DBF_TRACE_LEN 8 | ||
68 | #define QETH_DBF_TRACE_PAGES 4 | ||
69 | #define QETH_DBF_TRACE_NR_AREAS 2 | ||
70 | #define QETH_DBF_TRACE_LEVEL 3 | ||
71 | extern debug_info_t *qeth_dbf_trace; | ||
72 | |||
73 | #define QETH_DBF_SENSE_NAME "qeth_sense" | ||
74 | #define QETH_DBF_SENSE_LEN 64 | ||
75 | #define QETH_DBF_SENSE_PAGES 2 | ||
76 | #define QETH_DBF_SENSE_NR_AREAS 1 | ||
77 | #define QETH_DBF_SENSE_LEVEL 2 | ||
78 | |||
79 | #define QETH_DBF_QERR_NAME "qeth_qerr" | ||
80 | #define QETH_DBF_QERR_LEN 8 | ||
81 | #define QETH_DBF_QERR_PAGES 2 | ||
82 | #define QETH_DBF_QERR_NR_AREAS 2 | ||
83 | #define QETH_DBF_QERR_LEVEL 2 | ||
84 | |||
85 | #define QETH_DBF_TEXT(name,level,text) \ | ||
86 | do { \ | ||
87 | debug_text_event(qeth_dbf_##name,level,text); \ | ||
88 | } while (0) | ||
89 | |||
90 | #define QETH_DBF_HEX(name,level,addr,len) \ | ||
91 | do { \ | ||
92 | debug_event(qeth_dbf_##name,level,(void*)(addr),len); \ | ||
93 | } while (0) | ||
94 | |||
95 | DECLARE_PER_CPU(char[256], qeth_dbf_txt_buf); | ||
96 | |||
97 | #define QETH_DBF_TEXT_(name,level,text...) \ | ||
98 | do { \ | ||
99 | char* dbf_txt_buf = get_cpu_var(qeth_dbf_txt_buf); \ | ||
100 | sprintf(dbf_txt_buf, text); \ | ||
101 | debug_text_event(qeth_dbf_##name,level,dbf_txt_buf); \ | ||
102 | put_cpu_var(qeth_dbf_txt_buf); \ | ||
103 | } while (0) | ||
104 | |||
105 | #define QETH_DBF_SPRINTF(name,level,text...) \ | ||
106 | do { \ | ||
107 | debug_sprintf_event(qeth_dbf_trace, level, ##text ); \ | ||
108 | debug_sprintf_event(qeth_dbf_trace, level, text ); \ | ||
109 | } while (0) | ||
110 | |||
111 | /** | ||
112 | * some more debug stuff | ||
113 | */ | ||
114 | #define PRINTK_HEADER "qeth: " | ||
115 | |||
116 | #define HEXDUMP16(importance,header,ptr) \ | ||
117 | PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \ | ||
118 | "%02x %02x %02x %02x %02x %02x %02x %02x\n", \ | ||
119 | *(((char*)ptr)),*(((char*)ptr)+1),*(((char*)ptr)+2), \ | ||
120 | *(((char*)ptr)+3),*(((char*)ptr)+4),*(((char*)ptr)+5), \ | ||
121 | *(((char*)ptr)+6),*(((char*)ptr)+7),*(((char*)ptr)+8), \ | ||
122 | *(((char*)ptr)+9),*(((char*)ptr)+10),*(((char*)ptr)+11), \ | ||
123 | *(((char*)ptr)+12),*(((char*)ptr)+13), \ | ||
124 | *(((char*)ptr)+14),*(((char*)ptr)+15)); \ | ||
125 | PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \ | ||
126 | "%02x %02x %02x %02x %02x %02x %02x %02x\n", \ | ||
127 | *(((char*)ptr)+16),*(((char*)ptr)+17), \ | ||
128 | *(((char*)ptr)+18),*(((char*)ptr)+19), \ | ||
129 | *(((char*)ptr)+20),*(((char*)ptr)+21), \ | ||
130 | *(((char*)ptr)+22),*(((char*)ptr)+23), \ | ||
131 | *(((char*)ptr)+24),*(((char*)ptr)+25), \ | ||
132 | *(((char*)ptr)+26),*(((char*)ptr)+27), \ | ||
133 | *(((char*)ptr)+28),*(((char*)ptr)+29), \ | ||
134 | *(((char*)ptr)+30),*(((char*)ptr)+31)); | ||
135 | |||
136 | static inline void | ||
137 | qeth_hex_dump(unsigned char *buf, size_t len) | ||
138 | { | ||
139 | size_t i; | ||
140 | |||
141 | for (i = 0; i < len; i++) { | ||
142 | if (i && !(i % 16)) | ||
143 | printk("\n"); | ||
144 | printk("%02x ", *(buf + i)); | ||
145 | } | ||
146 | printk("\n"); | ||
147 | } | ||
148 | |||
149 | #define SENSE_COMMAND_REJECT_BYTE 0 | ||
150 | #define SENSE_COMMAND_REJECT_FLAG 0x80 | ||
151 | #define SENSE_RESETTING_EVENT_BYTE 1 | ||
152 | #define SENSE_RESETTING_EVENT_FLAG 0x80 | ||
153 | |||
154 | /* | ||
155 | * Common IO related definitions | ||
156 | */ | ||
157 | extern struct device *qeth_root_dev; | ||
158 | extern struct ccw_driver qeth_ccw_driver; | ||
159 | extern struct ccwgroup_driver qeth_ccwgroup_driver; | ||
160 | |||
161 | #define CARD_RDEV(card) card->read.ccwdev | ||
162 | #define CARD_WDEV(card) card->write.ccwdev | ||
163 | #define CARD_DDEV(card) card->data.ccwdev | ||
164 | #define CARD_BUS_ID(card) card->gdev->dev.bus_id | ||
165 | #define CARD_RDEV_ID(card) card->read.ccwdev->dev.bus_id | ||
166 | #define CARD_WDEV_ID(card) card->write.ccwdev->dev.bus_id | ||
167 | #define CARD_DDEV_ID(card) card->data.ccwdev->dev.bus_id | ||
168 | #define CHANNEL_ID(channel) channel->ccwdev->dev.bus_id | ||
169 | |||
170 | #define CARD_FROM_CDEV(cdev) (struct qeth_card *) \ | ||
171 | ((struct ccwgroup_device *)cdev->dev.driver_data)\ | ||
172 | ->dev.driver_data; | ||
173 | |||
174 | /** | ||
175 | * card stuff | ||
176 | */ | ||
177 | struct qeth_perf_stats { | ||
178 | unsigned int bufs_rec; | ||
179 | unsigned int bufs_sent; | ||
180 | |||
181 | unsigned int skbs_sent_pack; | ||
182 | unsigned int bufs_sent_pack; | ||
183 | |||
184 | unsigned int sc_dp_p; | ||
185 | unsigned int sc_p_dp; | ||
186 | /* qdio_input_handler: number of times called, time spent in */ | ||
187 | __u64 inbound_start_time; | ||
188 | unsigned int inbound_cnt; | ||
189 | unsigned int inbound_time; | ||
190 | /* qeth_send_packet: number of times called, time spent in */ | ||
191 | __u64 outbound_start_time; | ||
192 | unsigned int outbound_cnt; | ||
193 | unsigned int outbound_time; | ||
194 | /* qdio_output_handler: number of times called, time spent in */ | ||
195 | __u64 outbound_handler_start_time; | ||
196 | unsigned int outbound_handler_cnt; | ||
197 | unsigned int outbound_handler_time; | ||
198 | /* number of calls to and time spent in do_QDIO for inbound queue */ | ||
199 | __u64 inbound_do_qdio_start_time; | ||
200 | unsigned int inbound_do_qdio_cnt; | ||
201 | unsigned int inbound_do_qdio_time; | ||
202 | /* number of calls to and time spent in do_QDIO for outbound queues */ | ||
203 | __u64 outbound_do_qdio_start_time; | ||
204 | unsigned int outbound_do_qdio_cnt; | ||
205 | unsigned int outbound_do_qdio_time; | ||
206 | /* eddp data */ | ||
207 | unsigned int large_send_bytes; | ||
208 | unsigned int large_send_cnt; | ||
209 | unsigned int sg_skbs_sent; | ||
210 | unsigned int sg_frags_sent; | ||
211 | /* initial values when measuring starts */ | ||
212 | unsigned long initial_rx_packets; | ||
213 | unsigned long initial_tx_packets; | ||
214 | /* inbound scatter gather data */ | ||
215 | unsigned int sg_skbs_rx; | ||
216 | unsigned int sg_frags_rx; | ||
217 | unsigned int sg_alloc_page_rx; | ||
218 | }; | ||
219 | |||
220 | /* Routing stuff */ | ||
221 | struct qeth_routing_info { | ||
222 | enum qeth_routing_types type; | ||
223 | }; | ||
224 | |||
225 | /* IPA stuff */ | ||
226 | struct qeth_ipa_info { | ||
227 | __u32 supported_funcs; | ||
228 | __u32 enabled_funcs; | ||
229 | }; | ||
230 | |||
231 | static inline int | ||
232 | qeth_is_ipa_supported(struct qeth_ipa_info *ipa, enum qeth_ipa_funcs func) | ||
233 | { | ||
234 | return (ipa->supported_funcs & func); | ||
235 | } | ||
236 | |||
237 | static inline int | ||
238 | qeth_is_ipa_enabled(struct qeth_ipa_info *ipa, enum qeth_ipa_funcs func) | ||
239 | { | ||
240 | return (ipa->supported_funcs & ipa->enabled_funcs & func); | ||
241 | } | ||
242 | |||
243 | #define qeth_adp_supported(c,f) \ | ||
244 | qeth_is_ipa_supported(&c->options.adp, f) | ||
245 | #define qeth_adp_enabled(c,f) \ | ||
246 | qeth_is_ipa_enabled(&c->options.adp, f) | ||
247 | #define qeth_is_supported(c,f) \ | ||
248 | qeth_is_ipa_supported(&c->options.ipa4, f) | ||
249 | #define qeth_is_enabled(c,f) \ | ||
250 | qeth_is_ipa_enabled(&c->options.ipa4, f) | ||
251 | #ifdef CONFIG_QETH_IPV6 | ||
252 | #define qeth_is_supported6(c,f) \ | ||
253 | qeth_is_ipa_supported(&c->options.ipa6, f) | ||
254 | #define qeth_is_enabled6(c,f) \ | ||
255 | qeth_is_ipa_enabled(&c->options.ipa6, f) | ||
256 | #else /* CONFIG_QETH_IPV6 */ | ||
257 | #define qeth_is_supported6(c,f) 0 | ||
258 | #define qeth_is_enabled6(c,f) 0 | ||
259 | #endif /* CONFIG_QETH_IPV6 */ | ||
260 | #define qeth_is_ipafunc_supported(c,prot,f) \ | ||
261 | (prot==QETH_PROT_IPV6)? qeth_is_supported6(c,f):qeth_is_supported(c,f) | ||
262 | #define qeth_is_ipafunc_enabled(c,prot,f) \ | ||
263 | (prot==QETH_PROT_IPV6)? qeth_is_enabled6(c,f):qeth_is_enabled(c,f) | ||
264 | |||
265 | |||
266 | #define QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT 0x0101 | ||
267 | #define QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT 0x0101 | ||
268 | #define QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT 0x4108 | ||
269 | #define QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT 0x5108 | ||
270 | |||
271 | #define QETH_MODELLIST_ARRAY \ | ||
272 | {{0x1731,0x01,0x1732,0x01,QETH_CARD_TYPE_OSAE,1, \ | ||
273 | QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT, \ | ||
274 | QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT, \ | ||
275 | QETH_MAX_QUEUES,0}, \ | ||
276 | {0x1731,0x05,0x1732,0x05,QETH_CARD_TYPE_IQD,0, \ | ||
277 | QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT, \ | ||
278 | QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT, \ | ||
279 | QETH_MAX_QUEUES,0x103}, \ | ||
280 | {0x1731,0x06,0x1732,0x06,QETH_CARD_TYPE_OSN,0, \ | ||
281 | QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT, \ | ||
282 | QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT, \ | ||
283 | QETH_MAX_QUEUES,0}, \ | ||
284 | {0,0,0,0,0,0,0,0,0}} | ||
285 | |||
286 | #define QETH_REAL_CARD 1 | ||
287 | #define QETH_VLAN_CARD 2 | ||
288 | #define QETH_BUFSIZE 4096 | ||
289 | |||
290 | /** | ||
291 | * some more defs | ||
292 | */ | ||
293 | #define IF_NAME_LEN 16 | ||
294 | #define QETH_TX_TIMEOUT 100 * HZ | ||
295 | #define QETH_RCD_TIMEOUT 60 * HZ | ||
296 | #define QETH_HEADER_SIZE 32 | ||
297 | #define MAX_PORTNO 15 | ||
298 | #define QETH_FAKE_LL_LEN_ETH ETH_HLEN | ||
299 | #define QETH_FAKE_LL_LEN_TR (sizeof(struct trh_hdr)-TR_MAXRIFLEN+sizeof(struct trllc)) | ||
300 | #define QETH_FAKE_LL_V6_ADDR_POS 24 | ||
301 | |||
302 | /*IPv6 address autoconfiguration stuff*/ | ||
303 | #define UNIQUE_ID_IF_CREATE_ADDR_FAILED 0xfffe | ||
304 | #define UNIQUE_ID_NOT_BY_CARD 0x10000 | ||
305 | |||
306 | /*****************************************************************************/ | ||
307 | /* QDIO queue and buffer handling */ | ||
308 | /*****************************************************************************/ | ||
309 | #define QETH_MAX_QUEUES 4 | ||
310 | #define QETH_IN_BUF_SIZE_DEFAULT 65536 | ||
311 | #define QETH_IN_BUF_COUNT_DEFAULT 16 | ||
312 | #define QETH_IN_BUF_COUNT_MIN 8 | ||
313 | #define QETH_IN_BUF_COUNT_MAX 128 | ||
314 | #define QETH_MAX_BUFFER_ELEMENTS(card) ((card)->qdio.in_buf_size >> 12) | ||
315 | #define QETH_IN_BUF_REQUEUE_THRESHOLD(card) \ | ||
316 | ((card)->qdio.in_buf_pool.buf_count / 2) | ||
317 | |||
318 | /* buffers we have to be behind before we get a PCI */ | ||
319 | #define QETH_PCI_THRESHOLD_A(card) ((card)->qdio.in_buf_pool.buf_count+1) | ||
320 | /*enqueued free buffers left before we get a PCI*/ | ||
321 | #define QETH_PCI_THRESHOLD_B(card) 0 | ||
322 | /*not used unless the microcode gets patched*/ | ||
323 | #define QETH_PCI_TIMER_VALUE(card) 3 | ||
324 | |||
325 | #define QETH_MIN_INPUT_THRESHOLD 1 | ||
326 | #define QETH_MAX_INPUT_THRESHOLD 500 | ||
327 | #define QETH_MIN_OUTPUT_THRESHOLD 1 | ||
328 | #define QETH_MAX_OUTPUT_THRESHOLD 300 | ||
329 | |||
330 | /* priority queing */ | ||
331 | #define QETH_PRIOQ_DEFAULT QETH_NO_PRIO_QUEUEING | ||
332 | #define QETH_DEFAULT_QUEUE 2 | ||
333 | #define QETH_NO_PRIO_QUEUEING 0 | ||
334 | #define QETH_PRIO_Q_ING_PREC 1 | ||
335 | #define QETH_PRIO_Q_ING_TOS 2 | ||
336 | #define IP_TOS_LOWDELAY 0x10 | ||
337 | #define IP_TOS_HIGHTHROUGHPUT 0x08 | ||
338 | #define IP_TOS_HIGHRELIABILITY 0x04 | ||
339 | #define IP_TOS_NOTIMPORTANT 0x02 | ||
340 | |||
341 | /* Packing */ | ||
342 | #define QETH_LOW_WATERMARK_PACK 2 | ||
343 | #define QETH_HIGH_WATERMARK_PACK 5 | ||
344 | #define QETH_WATERMARK_PACK_FUZZ 1 | ||
345 | |||
346 | #define QETH_IP_HEADER_SIZE 40 | ||
347 | |||
348 | /* large receive scatter gather copy break */ | ||
349 | #define QETH_RX_SG_CB (PAGE_SIZE >> 1) | ||
350 | |||
351 | struct qeth_hdr_layer3 { | ||
352 | __u8 id; | ||
353 | __u8 flags; | ||
354 | __u16 inbound_checksum; /*TSO:__u16 seqno */ | ||
355 | __u32 token; /*TSO: __u32 reserved */ | ||
356 | __u16 length; | ||
357 | __u8 vlan_prio; | ||
358 | __u8 ext_flags; | ||
359 | __u16 vlan_id; | ||
360 | __u16 frame_offset; | ||
361 | __u8 dest_addr[16]; | ||
362 | } __attribute__ ((packed)); | ||
363 | |||
364 | struct qeth_hdr_layer2 { | ||
365 | __u8 id; | ||
366 | __u8 flags[3]; | ||
367 | __u8 port_no; | ||
368 | __u8 hdr_length; | ||
369 | __u16 pkt_length; | ||
370 | __u16 seq_no; | ||
371 | __u16 vlan_id; | ||
372 | __u32 reserved; | ||
373 | __u8 reserved2[16]; | ||
374 | } __attribute__ ((packed)); | ||
375 | |||
376 | struct qeth_hdr_osn { | ||
377 | __u8 id; | ||
378 | __u8 reserved; | ||
379 | __u16 seq_no; | ||
380 | __u16 reserved2; | ||
381 | __u16 control_flags; | ||
382 | __u16 pdu_length; | ||
383 | __u8 reserved3[18]; | ||
384 | __u32 ccid; | ||
385 | } __attribute__ ((packed)); | ||
386 | |||
387 | struct qeth_hdr { | ||
388 | union { | ||
389 | struct qeth_hdr_layer2 l2; | ||
390 | struct qeth_hdr_layer3 l3; | ||
391 | struct qeth_hdr_osn osn; | ||
392 | } hdr; | ||
393 | } __attribute__ ((packed)); | ||
394 | |||
395 | /*TCP Segmentation Offload header*/ | ||
396 | struct qeth_hdr_ext_tso { | ||
397 | __u16 hdr_tot_len; | ||
398 | __u8 imb_hdr_no; | ||
399 | __u8 reserved; | ||
400 | __u8 hdr_type; | ||
401 | __u8 hdr_version; | ||
402 | __u16 hdr_len; | ||
403 | __u32 payload_len; | ||
404 | __u16 mss; | ||
405 | __u16 dg_hdr_len; | ||
406 | __u8 padding[16]; | ||
407 | } __attribute__ ((packed)); | ||
408 | |||
409 | struct qeth_hdr_tso { | ||
410 | struct qeth_hdr hdr; /*hdr->hdr.l3.xxx*/ | ||
411 | struct qeth_hdr_ext_tso ext; | ||
412 | } __attribute__ ((packed)); | ||
413 | |||
414 | |||
415 | /* flags for qeth_hdr.flags */ | ||
416 | #define QETH_HDR_PASSTHRU 0x10 | ||
417 | #define QETH_HDR_IPV6 0x80 | ||
418 | #define QETH_HDR_CAST_MASK 0x07 | ||
419 | enum qeth_cast_flags { | ||
420 | QETH_CAST_UNICAST = 0x06, | ||
421 | QETH_CAST_MULTICAST = 0x04, | ||
422 | QETH_CAST_BROADCAST = 0x05, | ||
423 | QETH_CAST_ANYCAST = 0x07, | ||
424 | QETH_CAST_NOCAST = 0x00, | ||
425 | }; | ||
426 | |||
427 | enum qeth_layer2_frame_flags { | ||
428 | QETH_LAYER2_FLAG_MULTICAST = 0x01, | ||
429 | QETH_LAYER2_FLAG_BROADCAST = 0x02, | ||
430 | QETH_LAYER2_FLAG_UNICAST = 0x04, | ||
431 | QETH_LAYER2_FLAG_VLAN = 0x10, | ||
432 | }; | ||
433 | |||
434 | enum qeth_header_ids { | ||
435 | QETH_HEADER_TYPE_LAYER3 = 0x01, | ||
436 | QETH_HEADER_TYPE_LAYER2 = 0x02, | ||
437 | QETH_HEADER_TYPE_TSO = 0x03, | ||
438 | QETH_HEADER_TYPE_OSN = 0x04, | ||
439 | }; | ||
440 | /* flags for qeth_hdr.ext_flags */ | ||
441 | #define QETH_HDR_EXT_VLAN_FRAME 0x01 | ||
442 | #define QETH_HDR_EXT_TOKEN_ID 0x02 | ||
443 | #define QETH_HDR_EXT_INCLUDE_VLAN_TAG 0x04 | ||
444 | #define QETH_HDR_EXT_SRC_MAC_ADDR 0x08 | ||
445 | #define QETH_HDR_EXT_CSUM_HDR_REQ 0x10 | ||
446 | #define QETH_HDR_EXT_CSUM_TRANSP_REQ 0x20 | ||
447 | #define QETH_HDR_EXT_UDP_TSO 0x40 /*bit off for TCP*/ | ||
448 | |||
449 | static inline int | ||
450 | qeth_is_last_sbale(struct qdio_buffer_element *sbale) | ||
451 | { | ||
452 | return (sbale->flags & SBAL_FLAGS_LAST_ENTRY); | ||
453 | } | ||
454 | |||
455 | enum qeth_qdio_buffer_states { | ||
456 | /* | ||
457 | * inbound: read out by driver; owned by hardware in order to be filled | ||
458 | * outbound: owned by driver in order to be filled | ||
459 | */ | ||
460 | QETH_QDIO_BUF_EMPTY, | ||
461 | /* | ||
462 | * inbound: filled by hardware; owned by driver in order to be read out | ||
463 | * outbound: filled by driver; owned by hardware in order to be sent | ||
464 | */ | ||
465 | QETH_QDIO_BUF_PRIMED, | ||
466 | }; | ||
467 | |||
468 | enum qeth_qdio_info_states { | ||
469 | QETH_QDIO_UNINITIALIZED, | ||
470 | QETH_QDIO_ALLOCATED, | ||
471 | QETH_QDIO_ESTABLISHED, | ||
472 | QETH_QDIO_CLEANING | ||
473 | }; | ||
474 | |||
475 | struct qeth_buffer_pool_entry { | ||
476 | struct list_head list; | ||
477 | struct list_head init_list; | ||
478 | void *elements[QDIO_MAX_ELEMENTS_PER_BUFFER]; | ||
479 | }; | ||
480 | |||
481 | struct qeth_qdio_buffer_pool { | ||
482 | struct list_head entry_list; | ||
483 | int buf_count; | ||
484 | }; | ||
485 | |||
486 | struct qeth_qdio_buffer { | ||
487 | struct qdio_buffer *buffer; | ||
488 | volatile enum qeth_qdio_buffer_states state; | ||
489 | /* the buffer pool entry currently associated to this buffer */ | ||
490 | struct qeth_buffer_pool_entry *pool_entry; | ||
491 | }; | ||
492 | |||
493 | struct qeth_qdio_q { | ||
494 | struct qdio_buffer qdio_bufs[QDIO_MAX_BUFFERS_PER_Q]; | ||
495 | struct qeth_qdio_buffer bufs[QDIO_MAX_BUFFERS_PER_Q]; | ||
496 | /* | ||
497 | * buf_to_init means "buffer must be initialized by driver and must | ||
498 | * be made available for hardware" -> state is set to EMPTY | ||
499 | */ | ||
500 | volatile int next_buf_to_init; | ||
501 | } __attribute__ ((aligned(256))); | ||
502 | |||
503 | /* possible types of qeth large_send support */ | ||
504 | enum qeth_large_send_types { | ||
505 | QETH_LARGE_SEND_NO, | ||
506 | QETH_LARGE_SEND_EDDP, | ||
507 | QETH_LARGE_SEND_TSO, | ||
508 | }; | ||
509 | |||
510 | struct qeth_qdio_out_buffer { | ||
511 | struct qdio_buffer *buffer; | ||
512 | atomic_t state; | ||
513 | volatile int next_element_to_fill; | ||
514 | struct sk_buff_head skb_list; | ||
515 | struct list_head ctx_list; | ||
516 | }; | ||
517 | |||
518 | struct qeth_card; | ||
519 | |||
520 | enum qeth_out_q_states { | ||
521 | QETH_OUT_Q_UNLOCKED, | ||
522 | QETH_OUT_Q_LOCKED, | ||
523 | QETH_OUT_Q_LOCKED_FLUSH, | ||
524 | }; | ||
525 | |||
526 | struct qeth_qdio_out_q { | ||
527 | struct qdio_buffer qdio_bufs[QDIO_MAX_BUFFERS_PER_Q]; | ||
528 | struct qeth_qdio_out_buffer bufs[QDIO_MAX_BUFFERS_PER_Q]; | ||
529 | int queue_no; | ||
530 | struct qeth_card *card; | ||
531 | atomic_t state; | ||
532 | volatile int do_pack; | ||
533 | /* | ||
534 | * index of buffer to be filled by driver; state EMPTY or PACKING | ||
535 | */ | ||
536 | volatile int next_buf_to_fill; | ||
537 | /* | ||
538 | * number of buffers that are currently filled (PRIMED) | ||
539 | * -> these buffers are hardware-owned | ||
540 | */ | ||
541 | atomic_t used_buffers; | ||
542 | /* indicates whether PCI flag must be set (or if one is outstanding) */ | ||
543 | atomic_t set_pci_flags_count; | ||
544 | } __attribute__ ((aligned(256))); | ||
545 | |||
546 | struct qeth_qdio_info { | ||
547 | atomic_t state; | ||
548 | /* input */ | ||
549 | struct qeth_qdio_q *in_q; | ||
550 | struct qeth_qdio_buffer_pool in_buf_pool; | ||
551 | struct qeth_qdio_buffer_pool init_pool; | ||
552 | int in_buf_size; | ||
553 | |||
554 | /* output */ | ||
555 | int no_out_queues; | ||
556 | struct qeth_qdio_out_q **out_qs; | ||
557 | |||
558 | /* priority queueing */ | ||
559 | int do_prio_queueing; | ||
560 | int default_out_queue; | ||
561 | }; | ||
562 | |||
563 | enum qeth_send_errors { | ||
564 | QETH_SEND_ERROR_NONE, | ||
565 | QETH_SEND_ERROR_LINK_FAILURE, | ||
566 | QETH_SEND_ERROR_RETRY, | ||
567 | QETH_SEND_ERROR_KICK_IT, | ||
568 | }; | ||
569 | |||
570 | #define QETH_ETH_MAC_V4 0x0100 /* like v4 */ | ||
571 | #define QETH_ETH_MAC_V6 0x3333 /* like v6 */ | ||
572 | /* tr mc mac is longer, but that will be enough to detect mc frames */ | ||
573 | #define QETH_TR_MAC_NC 0xc000 /* non-canonical */ | ||
574 | #define QETH_TR_MAC_C 0x0300 /* canonical */ | ||
575 | |||
576 | #define DEFAULT_ADD_HHLEN 0 | ||
577 | #define MAX_ADD_HHLEN 1024 | ||
578 | |||
579 | /** | ||
580 | * buffer stuff for read channel | ||
581 | */ | ||
582 | #define QETH_CMD_BUFFER_NO 8 | ||
583 | |||
584 | /** | ||
585 | * channel state machine | ||
586 | */ | ||
587 | enum qeth_channel_states { | ||
588 | CH_STATE_UP, | ||
589 | CH_STATE_DOWN, | ||
590 | CH_STATE_ACTIVATING, | ||
591 | CH_STATE_HALTED, | ||
592 | CH_STATE_STOPPED, | ||
593 | CH_STATE_RCD, | ||
594 | CH_STATE_RCD_DONE, | ||
595 | }; | ||
596 | /** | ||
597 | * card state machine | ||
598 | */ | ||
599 | enum qeth_card_states { | ||
600 | CARD_STATE_DOWN, | ||
601 | CARD_STATE_HARDSETUP, | ||
602 | CARD_STATE_SOFTSETUP, | ||
603 | CARD_STATE_UP, | ||
604 | CARD_STATE_RECOVER, | ||
605 | }; | ||
606 | |||
607 | /** | ||
608 | * Protocol versions | ||
609 | */ | ||
610 | enum qeth_prot_versions { | ||
611 | QETH_PROT_IPV4 = 0x0004, | ||
612 | QETH_PROT_IPV6 = 0x0006, | ||
613 | }; | ||
614 | |||
615 | enum qeth_ip_types { | ||
616 | QETH_IP_TYPE_NORMAL, | ||
617 | QETH_IP_TYPE_VIPA, | ||
618 | QETH_IP_TYPE_RXIP, | ||
619 | QETH_IP_TYPE_DEL_ALL_MC, | ||
620 | }; | ||
621 | |||
622 | enum qeth_cmd_buffer_state { | ||
623 | BUF_STATE_FREE, | ||
624 | BUF_STATE_LOCKED, | ||
625 | BUF_STATE_PROCESSED, | ||
626 | }; | ||
627 | /** | ||
628 | * IP address and multicast list | ||
629 | */ | ||
630 | struct qeth_ipaddr { | ||
631 | struct list_head entry; | ||
632 | enum qeth_ip_types type; | ||
633 | enum qeth_ipa_setdelip_flags set_flags; | ||
634 | enum qeth_ipa_setdelip_flags del_flags; | ||
635 | int is_multicast; | ||
636 | volatile int users; | ||
637 | enum qeth_prot_versions proto; | ||
638 | unsigned char mac[OSA_ADDR_LEN]; | ||
639 | union { | ||
640 | struct { | ||
641 | unsigned int addr; | ||
642 | unsigned int mask; | ||
643 | } a4; | ||
644 | struct { | ||
645 | struct in6_addr addr; | ||
646 | unsigned int pfxlen; | ||
647 | } a6; | ||
648 | } u; | ||
649 | }; | ||
650 | |||
651 | struct qeth_ipato_entry { | ||
652 | struct list_head entry; | ||
653 | enum qeth_prot_versions proto; | ||
654 | char addr[16]; | ||
655 | int mask_bits; | ||
656 | }; | ||
657 | |||
658 | struct qeth_ipato { | ||
659 | int enabled; | ||
660 | int invert4; | ||
661 | int invert6; | ||
662 | struct list_head entries; | ||
663 | }; | ||
664 | |||
665 | struct qeth_channel; | ||
666 | |||
667 | struct qeth_cmd_buffer { | ||
668 | enum qeth_cmd_buffer_state state; | ||
669 | struct qeth_channel *channel; | ||
670 | unsigned char *data; | ||
671 | int rc; | ||
672 | void (*callback) (struct qeth_channel *, struct qeth_cmd_buffer *); | ||
673 | }; | ||
674 | |||
675 | |||
676 | /** | ||
677 | * definition of a qeth channel, used for read and write | ||
678 | */ | ||
679 | struct qeth_channel { | ||
680 | enum qeth_channel_states state; | ||
681 | struct ccw1 ccw; | ||
682 | spinlock_t iob_lock; | ||
683 | wait_queue_head_t wait_q; | ||
684 | struct tasklet_struct irq_tasklet; | ||
685 | struct ccw_device *ccwdev; | ||
686 | /*command buffer for control data*/ | ||
687 | struct qeth_cmd_buffer iob[QETH_CMD_BUFFER_NO]; | ||
688 | atomic_t irq_pending; | ||
689 | volatile int io_buf_no; | ||
690 | volatile int buf_no; | ||
691 | }; | ||
692 | |||
693 | /** | ||
694 | * OSA card related definitions | ||
695 | */ | ||
696 | struct qeth_token { | ||
697 | __u32 issuer_rm_w; | ||
698 | __u32 issuer_rm_r; | ||
699 | __u32 cm_filter_w; | ||
700 | __u32 cm_filter_r; | ||
701 | __u32 cm_connection_w; | ||
702 | __u32 cm_connection_r; | ||
703 | __u32 ulp_filter_w; | ||
704 | __u32 ulp_filter_r; | ||
705 | __u32 ulp_connection_w; | ||
706 | __u32 ulp_connection_r; | ||
707 | }; | ||
708 | |||
709 | struct qeth_seqno { | ||
710 | __u32 trans_hdr; | ||
711 | __u32 pdu_hdr; | ||
712 | __u32 pdu_hdr_ack; | ||
713 | __u16 ipa; | ||
714 | __u32 pkt_seqno; | ||
715 | }; | ||
716 | |||
717 | struct qeth_reply { | ||
718 | struct list_head list; | ||
719 | wait_queue_head_t wait_q; | ||
720 | int (*callback)(struct qeth_card *,struct qeth_reply *,unsigned long); | ||
721 | u32 seqno; | ||
722 | unsigned long offset; | ||
723 | atomic_t received; | ||
724 | int rc; | ||
725 | void *param; | ||
726 | struct qeth_card *card; | ||
727 | atomic_t refcnt; | ||
728 | }; | ||
729 | |||
730 | |||
731 | struct qeth_card_blkt { | ||
732 | int time_total; | ||
733 | int inter_packet; | ||
734 | int inter_packet_jumbo; | ||
735 | }; | ||
736 | |||
737 | #define QETH_BROADCAST_WITH_ECHO 0x01 | ||
738 | #define QETH_BROADCAST_WITHOUT_ECHO 0x02 | ||
739 | #define QETH_LAYER2_MAC_READ 0x01 | ||
740 | #define QETH_LAYER2_MAC_REGISTERED 0x02 | ||
741 | struct qeth_card_info { | ||
742 | unsigned short unit_addr2; | ||
743 | unsigned short cula; | ||
744 | unsigned short chpid; | ||
745 | __u16 func_level; | ||
746 | char mcl_level[QETH_MCL_LENGTH + 1]; | ||
747 | int guestlan; | ||
748 | int mac_bits; | ||
749 | int portname_required; | ||
750 | int portno; | ||
751 | char portname[9]; | ||
752 | enum qeth_card_types type; | ||
753 | enum qeth_link_types link_type; | ||
754 | int is_multicast_different; | ||
755 | int initial_mtu; | ||
756 | int max_mtu; | ||
757 | int broadcast_capable; | ||
758 | int unique_id; | ||
759 | struct qeth_card_blkt blkt; | ||
760 | __u32 csum_mask; | ||
761 | enum qeth_ipa_promisc_modes promisc_mode; | ||
762 | }; | ||
763 | |||
764 | struct qeth_card_options { | ||
765 | struct qeth_routing_info route4; | ||
766 | struct qeth_ipa_info ipa4; | ||
767 | struct qeth_ipa_info adp; /*Adapter parameters*/ | ||
768 | #ifdef CONFIG_QETH_IPV6 | ||
769 | struct qeth_routing_info route6; | ||
770 | struct qeth_ipa_info ipa6; | ||
771 | #endif /* QETH_IPV6 */ | ||
772 | enum qeth_checksum_types checksum_type; | ||
773 | int broadcast_mode; | ||
774 | int macaddr_mode; | ||
775 | int fake_broadcast; | ||
776 | int add_hhlen; | ||
777 | int fake_ll; | ||
778 | int layer2; | ||
779 | enum qeth_large_send_types large_send; | ||
780 | int performance_stats; | ||
781 | int rx_sg_cb; | ||
782 | }; | ||
783 | |||
784 | /* | ||
785 | * thread bits for qeth_card thread masks | ||
786 | */ | ||
787 | enum qeth_threads { | ||
788 | QETH_SET_IP_THREAD = 1, | ||
789 | QETH_RECOVER_THREAD = 2, | ||
790 | QETH_SET_PROMISC_MODE_THREAD = 4, | ||
791 | }; | ||
792 | |||
793 | struct qeth_osn_info { | ||
794 | int (*assist_cb)(struct net_device *dev, void *data); | ||
795 | int (*data_cb)(struct sk_buff *skb); | ||
796 | }; | ||
797 | |||
798 | struct qeth_card { | ||
799 | struct list_head list; | ||
800 | enum qeth_card_states state; | ||
801 | int lan_online; | ||
802 | spinlock_t lock; | ||
803 | /*hardware and sysfs stuff*/ | ||
804 | struct ccwgroup_device *gdev; | ||
805 | struct qeth_channel read; | ||
806 | struct qeth_channel write; | ||
807 | struct qeth_channel data; | ||
808 | |||
809 | struct net_device *dev; | ||
810 | struct net_device_stats stats; | ||
811 | |||
812 | struct qeth_card_info info; | ||
813 | struct qeth_token token; | ||
814 | struct qeth_seqno seqno; | ||
815 | struct qeth_card_options options; | ||
816 | |||
817 | wait_queue_head_t wait_q; | ||
818 | #ifdef CONFIG_QETH_VLAN | ||
819 | spinlock_t vlanlock; | ||
820 | struct vlan_group *vlangrp; | ||
821 | #endif | ||
822 | struct work_struct kernel_thread_starter; | ||
823 | spinlock_t thread_mask_lock; | ||
824 | volatile unsigned long thread_start_mask; | ||
825 | volatile unsigned long thread_allowed_mask; | ||
826 | volatile unsigned long thread_running_mask; | ||
827 | spinlock_t ip_lock; | ||
828 | struct list_head ip_list; | ||
829 | struct list_head *ip_tbd_list; | ||
830 | struct qeth_ipato ipato; | ||
831 | struct list_head cmd_waiter_list; | ||
832 | /* QDIO buffer handling */ | ||
833 | struct qeth_qdio_info qdio; | ||
834 | struct qeth_perf_stats perf_stats; | ||
835 | int use_hard_stop; | ||
836 | const struct header_ops *orig_header_ops; | ||
837 | struct qeth_osn_info osn_info; | ||
838 | atomic_t force_alloc_skb; | ||
839 | }; | ||
840 | |||
841 | struct qeth_card_list_struct { | ||
842 | struct list_head list; | ||
843 | rwlock_t rwlock; | ||
844 | }; | ||
845 | |||
846 | extern struct qeth_card_list_struct qeth_card_list; | ||
847 | |||
848 | /*notifier list */ | ||
849 | struct qeth_notify_list_struct { | ||
850 | struct list_head list; | ||
851 | struct task_struct *task; | ||
852 | int signum; | ||
853 | }; | ||
854 | extern spinlock_t qeth_notify_lock; | ||
855 | extern struct list_head qeth_notify_list; | ||
856 | |||
857 | /*some helper functions*/ | ||
858 | |||
859 | #define QETH_CARD_IFNAME(card) (((card)->dev)? (card)->dev->name : "") | ||
860 | |||
861 | static inline __u8 | ||
862 | qeth_get_ipa_adp_type(enum qeth_link_types link_type) | ||
863 | { | ||
864 | switch (link_type) { | ||
865 | case QETH_LINK_TYPE_HSTR: | ||
866 | return 2; | ||
867 | default: | ||
868 | return 1; | ||
869 | } | ||
870 | } | ||
871 | |||
872 | static inline struct sk_buff * | ||
873 | qeth_realloc_headroom(struct qeth_card *card, struct sk_buff *skb, int size) | ||
874 | { | ||
875 | struct sk_buff *new_skb = skb; | ||
876 | |||
877 | if (skb_headroom(skb) >= size) | ||
878 | return skb; | ||
879 | new_skb = skb_realloc_headroom(skb, size); | ||
880 | if (!new_skb) | ||
881 | PRINT_ERR("Could not realloc headroom for qeth_hdr " | ||
882 | "on interface %s", QETH_CARD_IFNAME(card)); | ||
883 | return new_skb; | ||
884 | } | ||
885 | |||
886 | static inline struct sk_buff * | ||
887 | qeth_pskb_unshare(struct sk_buff *skb, gfp_t pri) | ||
888 | { | ||
889 | struct sk_buff *nskb; | ||
890 | if (!skb_cloned(skb)) | ||
891 | return skb; | ||
892 | nskb = skb_copy(skb, pri); | ||
893 | return nskb; | ||
894 | } | ||
895 | |||
896 | static inline void * | ||
897 | qeth_push_skb(struct qeth_card *card, struct sk_buff *skb, int size) | ||
898 | { | ||
899 | void *hdr; | ||
900 | |||
901 | hdr = (void *) skb_push(skb, size); | ||
902 | /* | ||
903 | * sanity check, the Linux memory allocation scheme should | ||
904 | * never present us cases like this one (the qdio header size plus | ||
905 | * the first 40 bytes of the paket cross a 4k boundary) | ||
906 | */ | ||
907 | if ((((unsigned long) hdr) & (~(PAGE_SIZE - 1))) != | ||
908 | (((unsigned long) hdr + size + | ||
909 | QETH_IP_HEADER_SIZE) & (~(PAGE_SIZE - 1)))) { | ||
910 | PRINT_ERR("Misaligned packet on interface %s. Discarded.", | ||
911 | QETH_CARD_IFNAME(card)); | ||
912 | return NULL; | ||
913 | } | ||
914 | return hdr; | ||
915 | } | ||
916 | |||
917 | |||
918 | static inline int | ||
919 | qeth_get_hlen(__u8 link_type) | ||
920 | { | ||
921 | #ifdef CONFIG_QETH_IPV6 | ||
922 | switch (link_type) { | ||
923 | case QETH_LINK_TYPE_HSTR: | ||
924 | case QETH_LINK_TYPE_LANE_TR: | ||
925 | return sizeof(struct qeth_hdr_tso) + TR_HLEN; | ||
926 | default: | ||
927 | #ifdef CONFIG_QETH_VLAN | ||
928 | return sizeof(struct qeth_hdr_tso) + VLAN_ETH_HLEN; | ||
929 | #else | ||
930 | return sizeof(struct qeth_hdr_tso) + ETH_HLEN; | ||
931 | #endif | ||
932 | } | ||
933 | #else /* CONFIG_QETH_IPV6 */ | ||
934 | #ifdef CONFIG_QETH_VLAN | ||
935 | return sizeof(struct qeth_hdr_tso) + VLAN_HLEN; | ||
936 | #else | ||
937 | return sizeof(struct qeth_hdr_tso); | ||
938 | #endif | ||
939 | #endif /* CONFIG_QETH_IPV6 */ | ||
940 | } | ||
941 | |||
942 | static inline unsigned short | ||
943 | qeth_get_netdev_flags(struct qeth_card *card) | ||
944 | { | ||
945 | if (card->options.layer2 && | ||
946 | (card->info.type == QETH_CARD_TYPE_OSAE)) | ||
947 | return 0; | ||
948 | switch (card->info.type) { | ||
949 | case QETH_CARD_TYPE_IQD: | ||
950 | case QETH_CARD_TYPE_OSN: | ||
951 | return IFF_NOARP; | ||
952 | #ifdef CONFIG_QETH_IPV6 | ||
953 | default: | ||
954 | return 0; | ||
955 | #else | ||
956 | default: | ||
957 | return IFF_NOARP; | ||
958 | #endif | ||
959 | } | ||
960 | } | ||
961 | |||
962 | static inline int | ||
963 | qeth_get_initial_mtu_for_card(struct qeth_card * card) | ||
964 | { | ||
965 | switch (card->info.type) { | ||
966 | case QETH_CARD_TYPE_UNKNOWN: | ||
967 | return 1500; | ||
968 | case QETH_CARD_TYPE_IQD: | ||
969 | return card->info.max_mtu; | ||
970 | case QETH_CARD_TYPE_OSAE: | ||
971 | switch (card->info.link_type) { | ||
972 | case QETH_LINK_TYPE_HSTR: | ||
973 | case QETH_LINK_TYPE_LANE_TR: | ||
974 | return 2000; | ||
975 | default: | ||
976 | return 1492; | ||
977 | } | ||
978 | default: | ||
979 | return 1500; | ||
980 | } | ||
981 | } | ||
982 | |||
983 | static inline int | ||
984 | qeth_get_max_mtu_for_card(int cardtype) | ||
985 | { | ||
986 | switch (cardtype) { | ||
987 | |||
988 | case QETH_CARD_TYPE_UNKNOWN: | ||
989 | case QETH_CARD_TYPE_OSAE: | ||
990 | case QETH_CARD_TYPE_OSN: | ||
991 | return 61440; | ||
992 | case QETH_CARD_TYPE_IQD: | ||
993 | return 57344; | ||
994 | default: | ||
995 | return 1500; | ||
996 | } | ||
997 | } | ||
998 | |||
999 | static inline int | ||
1000 | qeth_get_mtu_out_of_mpc(int cardtype) | ||
1001 | { | ||
1002 | switch (cardtype) { | ||
1003 | case QETH_CARD_TYPE_IQD: | ||
1004 | return 1; | ||
1005 | default: | ||
1006 | return 0; | ||
1007 | } | ||
1008 | } | ||
1009 | |||
1010 | static inline int | ||
1011 | qeth_get_mtu_outof_framesize(int framesize) | ||
1012 | { | ||
1013 | switch (framesize) { | ||
1014 | case 0x4000: | ||
1015 | return 8192; | ||
1016 | case 0x6000: | ||
1017 | return 16384; | ||
1018 | case 0xa000: | ||
1019 | return 32768; | ||
1020 | case 0xffff: | ||
1021 | return 57344; | ||
1022 | default: | ||
1023 | return 0; | ||
1024 | } | ||
1025 | } | ||
1026 | |||
1027 | static inline int | ||
1028 | qeth_mtu_is_valid(struct qeth_card * card, int mtu) | ||
1029 | { | ||
1030 | switch (card->info.type) { | ||
1031 | case QETH_CARD_TYPE_OSAE: | ||
1032 | return ((mtu >= 576) && (mtu <= 61440)); | ||
1033 | case QETH_CARD_TYPE_IQD: | ||
1034 | return ((mtu >= 576) && | ||
1035 | (mtu <= card->info.max_mtu + 4096 - 32)); | ||
1036 | case QETH_CARD_TYPE_OSN: | ||
1037 | case QETH_CARD_TYPE_UNKNOWN: | ||
1038 | default: | ||
1039 | return 1; | ||
1040 | } | ||
1041 | } | ||
1042 | |||
1043 | static inline int | ||
1044 | qeth_get_arphdr_type(int cardtype, int linktype) | ||
1045 | { | ||
1046 | switch (cardtype) { | ||
1047 | case QETH_CARD_TYPE_OSAE: | ||
1048 | case QETH_CARD_TYPE_OSN: | ||
1049 | switch (linktype) { | ||
1050 | case QETH_LINK_TYPE_LANE_TR: | ||
1051 | case QETH_LINK_TYPE_HSTR: | ||
1052 | return ARPHRD_IEEE802_TR; | ||
1053 | default: | ||
1054 | return ARPHRD_ETHER; | ||
1055 | } | ||
1056 | case QETH_CARD_TYPE_IQD: | ||
1057 | default: | ||
1058 | return ARPHRD_ETHER; | ||
1059 | } | ||
1060 | } | ||
1061 | |||
1062 | static inline int | ||
1063 | qeth_get_micros(void) | ||
1064 | { | ||
1065 | return (int) (get_clock() >> 12); | ||
1066 | } | ||
1067 | |||
1068 | static inline int | ||
1069 | qeth_get_qdio_q_format(struct qeth_card *card) | ||
1070 | { | ||
1071 | switch (card->info.type) { | ||
1072 | case QETH_CARD_TYPE_IQD: | ||
1073 | return 2; | ||
1074 | default: | ||
1075 | return 0; | ||
1076 | } | ||
1077 | } | ||
1078 | |||
1079 | static inline int | ||
1080 | qeth_isxdigit(char * buf) | ||
1081 | { | ||
1082 | while (*buf) { | ||
1083 | if (!isxdigit(*buf++)) | ||
1084 | return 0; | ||
1085 | } | ||
1086 | return 1; | ||
1087 | } | ||
1088 | |||
1089 | static inline void | ||
1090 | qeth_ipaddr4_to_string(const __u8 *addr, char *buf) | ||
1091 | { | ||
1092 | sprintf(buf, "%i.%i.%i.%i", addr[0], addr[1], addr[2], addr[3]); | ||
1093 | } | ||
1094 | |||
1095 | static inline int | ||
1096 | qeth_string_to_ipaddr4(const char *buf, __u8 *addr) | ||
1097 | { | ||
1098 | int count = 0, rc = 0; | ||
1099 | int in[4]; | ||
1100 | char c; | ||
1101 | |||
1102 | rc = sscanf(buf, "%u.%u.%u.%u%c", | ||
1103 | &in[0], &in[1], &in[2], &in[3], &c); | ||
1104 | if (rc != 4 && (rc != 5 || c != '\n')) | ||
1105 | return -EINVAL; | ||
1106 | for (count = 0; count < 4; count++) { | ||
1107 | if (in[count] > 255) | ||
1108 | return -EINVAL; | ||
1109 | addr[count] = in[count]; | ||
1110 | } | ||
1111 | return 0; | ||
1112 | } | ||
1113 | |||
1114 | static inline void | ||
1115 | qeth_ipaddr6_to_string(const __u8 *addr, char *buf) | ||
1116 | { | ||
1117 | sprintf(buf, "%02x%02x:%02x%02x:%02x%02x:%02x%02x" | ||
1118 | ":%02x%02x:%02x%02x:%02x%02x:%02x%02x", | ||
1119 | addr[0], addr[1], addr[2], addr[3], | ||
1120 | addr[4], addr[5], addr[6], addr[7], | ||
1121 | addr[8], addr[9], addr[10], addr[11], | ||
1122 | addr[12], addr[13], addr[14], addr[15]); | ||
1123 | } | ||
1124 | |||
1125 | static inline int | ||
1126 | qeth_string_to_ipaddr6(const char *buf, __u8 *addr) | ||
1127 | { | ||
1128 | const char *end, *end_tmp, *start; | ||
1129 | __u16 *in; | ||
1130 | char num[5]; | ||
1131 | int num2, cnt, out, found, save_cnt; | ||
1132 | unsigned short in_tmp[8] = {0, }; | ||
1133 | |||
1134 | cnt = out = found = save_cnt = num2 = 0; | ||
1135 | end = start = buf; | ||
1136 | in = (__u16 *) addr; | ||
1137 | memset(in, 0, 16); | ||
1138 | while (*end) { | ||
1139 | end = strchr(start,':'); | ||
1140 | if (end == NULL) { | ||
1141 | end = buf + strlen(buf); | ||
1142 | if ((end_tmp = strchr(start, '\n')) != NULL) | ||
1143 | end = end_tmp; | ||
1144 | out = 1; | ||
1145 | } | ||
1146 | if ((end - start)) { | ||
1147 | memset(num, 0, 5); | ||
1148 | if ((end - start) > 4) | ||
1149 | return -EINVAL; | ||
1150 | memcpy(num, start, end - start); | ||
1151 | if (!qeth_isxdigit(num)) | ||
1152 | return -EINVAL; | ||
1153 | sscanf(start, "%x", &num2); | ||
1154 | if (found) | ||
1155 | in_tmp[save_cnt++] = num2; | ||
1156 | else | ||
1157 | in[cnt++] = num2; | ||
1158 | if (out) | ||
1159 | break; | ||
1160 | } else { | ||
1161 | if (found) | ||
1162 | return -EINVAL; | ||
1163 | found = 1; | ||
1164 | } | ||
1165 | start = ++end; | ||
1166 | } | ||
1167 | if (cnt + save_cnt > 8) | ||
1168 | return -EINVAL; | ||
1169 | cnt = 7; | ||
1170 | while (save_cnt) | ||
1171 | in[cnt--] = in_tmp[--save_cnt]; | ||
1172 | return 0; | ||
1173 | } | ||
1174 | |||
1175 | static inline void | ||
1176 | qeth_ipaddr_to_string(enum qeth_prot_versions proto, const __u8 *addr, | ||
1177 | char *buf) | ||
1178 | { | ||
1179 | if (proto == QETH_PROT_IPV4) | ||
1180 | qeth_ipaddr4_to_string(addr, buf); | ||
1181 | else if (proto == QETH_PROT_IPV6) | ||
1182 | qeth_ipaddr6_to_string(addr, buf); | ||
1183 | } | ||
1184 | |||
1185 | static inline int | ||
1186 | qeth_string_to_ipaddr(const char *buf, enum qeth_prot_versions proto, | ||
1187 | __u8 *addr) | ||
1188 | { | ||
1189 | if (proto == QETH_PROT_IPV4) | ||
1190 | return qeth_string_to_ipaddr4(buf, addr); | ||
1191 | else if (proto == QETH_PROT_IPV6) | ||
1192 | return qeth_string_to_ipaddr6(buf, addr); | ||
1193 | else | ||
1194 | return -EINVAL; | ||
1195 | } | ||
1196 | |||
1197 | extern int | ||
1198 | qeth_setrouting_v4(struct qeth_card *); | ||
1199 | extern int | ||
1200 | qeth_setrouting_v6(struct qeth_card *); | ||
1201 | |||
1202 | extern int | ||
1203 | qeth_add_ipato_entry(struct qeth_card *, struct qeth_ipato_entry *); | ||
1204 | |||
1205 | extern void | ||
1206 | qeth_del_ipato_entry(struct qeth_card *, enum qeth_prot_versions, u8 *, int); | ||
1207 | |||
1208 | extern int | ||
1209 | qeth_add_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *); | ||
1210 | |||
1211 | extern void | ||
1212 | qeth_del_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *); | ||
1213 | |||
1214 | extern int | ||
1215 | qeth_add_rxip(struct qeth_card *, enum qeth_prot_versions, const u8 *); | ||
1216 | |||
1217 | extern void | ||
1218 | qeth_del_rxip(struct qeth_card *, enum qeth_prot_versions, const u8 *); | ||
1219 | |||
1220 | extern int | ||
1221 | qeth_notifier_register(struct task_struct *, int ); | ||
1222 | |||
1223 | extern int | ||
1224 | qeth_notifier_unregister(struct task_struct * ); | ||
1225 | |||
1226 | extern void | ||
1227 | qeth_schedule_recovery(struct qeth_card *); | ||
1228 | |||
1229 | extern int | ||
1230 | qeth_realloc_buffer_pool(struct qeth_card *, int); | ||
1231 | |||
1232 | extern int | ||
1233 | qeth_set_large_send(struct qeth_card *, enum qeth_large_send_types); | ||
1234 | |||
1235 | extern void | ||
1236 | qeth_fill_header(struct qeth_card *, struct qeth_hdr *, | ||
1237 | struct sk_buff *, int, int); | ||
1238 | extern void | ||
1239 | qeth_flush_buffers(struct qeth_qdio_out_q *, int, int, int); | ||
1240 | |||
1241 | extern int | ||
1242 | qeth_osn_assist(struct net_device *, void *, int); | ||
1243 | |||
1244 | extern int | ||
1245 | qeth_osn_register(unsigned char *read_dev_no, | ||
1246 | struct net_device **, | ||
1247 | int (*assist_cb)(struct net_device *, void *), | ||
1248 | int (*data_cb)(struct sk_buff *)); | ||
1249 | |||
1250 | extern void | ||
1251 | qeth_osn_deregister(struct net_device *); | ||
1252 | |||
1253 | #endif /* __QETH_H__ */ | ||
diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_eddp.c deleted file mode 100644 index e3c268cfbffe..000000000000 --- a/drivers/s390/net/qeth_eddp.c +++ /dev/null | |||
@@ -1,634 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/s390/net/qeth_eddp.c | ||
3 | * | ||
4 | * Enhanced Device Driver Packing (EDDP) support for the qeth driver. | ||
5 | * | ||
6 | * Copyright 2004 IBM Corporation | ||
7 | * | ||
8 | * Author(s): Thomas Spatzier <tspat@de.ibm.com> | ||
9 | * | ||
10 | */ | ||
11 | #include <linux/errno.h> | ||
12 | #include <linux/ip.h> | ||
13 | #include <linux/inetdevice.h> | ||
14 | #include <linux/netdevice.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/tcp.h> | ||
17 | #include <net/tcp.h> | ||
18 | #include <linux/skbuff.h> | ||
19 | |||
20 | #include <net/ip.h> | ||
21 | |||
22 | #include "qeth.h" | ||
23 | #include "qeth_mpc.h" | ||
24 | #include "qeth_eddp.h" | ||
25 | |||
26 | int | ||
27 | qeth_eddp_check_buffers_for_context(struct qeth_qdio_out_q *queue, | ||
28 | struct qeth_eddp_context *ctx) | ||
29 | { | ||
30 | int index = queue->next_buf_to_fill; | ||
31 | int elements_needed = ctx->num_elements; | ||
32 | int elements_in_buffer; | ||
33 | int skbs_in_buffer; | ||
34 | int buffers_needed = 0; | ||
35 | |||
36 | QETH_DBF_TEXT(trace, 5, "eddpcbfc"); | ||
37 | while(elements_needed > 0) { | ||
38 | buffers_needed++; | ||
39 | if (atomic_read(&queue->bufs[index].state) != | ||
40 | QETH_QDIO_BUF_EMPTY) | ||
41 | return -EBUSY; | ||
42 | |||
43 | elements_in_buffer = QETH_MAX_BUFFER_ELEMENTS(queue->card) - | ||
44 | queue->bufs[index].next_element_to_fill; | ||
45 | skbs_in_buffer = elements_in_buffer / ctx->elements_per_skb; | ||
46 | elements_needed -= skbs_in_buffer * ctx->elements_per_skb; | ||
47 | index = (index + 1) % QDIO_MAX_BUFFERS_PER_Q; | ||
48 | } | ||
49 | return buffers_needed; | ||
50 | } | ||
51 | |||
52 | static void | ||
53 | qeth_eddp_free_context(struct qeth_eddp_context *ctx) | ||
54 | { | ||
55 | int i; | ||
56 | |||
57 | QETH_DBF_TEXT(trace, 5, "eddpfctx"); | ||
58 | for (i = 0; i < ctx->num_pages; ++i) | ||
59 | free_page((unsigned long)ctx->pages[i]); | ||
60 | kfree(ctx->pages); | ||
61 | kfree(ctx->elements); | ||
62 | kfree(ctx); | ||
63 | } | ||
64 | |||
65 | |||
66 | static inline void | ||
67 | qeth_eddp_get_context(struct qeth_eddp_context *ctx) | ||
68 | { | ||
69 | atomic_inc(&ctx->refcnt); | ||
70 | } | ||
71 | |||
72 | void | ||
73 | qeth_eddp_put_context(struct qeth_eddp_context *ctx) | ||
74 | { | ||
75 | if (atomic_dec_return(&ctx->refcnt) == 0) | ||
76 | qeth_eddp_free_context(ctx); | ||
77 | } | ||
78 | |||
79 | void | ||
80 | qeth_eddp_buf_release_contexts(struct qeth_qdio_out_buffer *buf) | ||
81 | { | ||
82 | struct qeth_eddp_context_reference *ref; | ||
83 | |||
84 | QETH_DBF_TEXT(trace, 6, "eddprctx"); | ||
85 | while (!list_empty(&buf->ctx_list)){ | ||
86 | ref = list_entry(buf->ctx_list.next, | ||
87 | struct qeth_eddp_context_reference, list); | ||
88 | qeth_eddp_put_context(ref->ctx); | ||
89 | list_del(&ref->list); | ||
90 | kfree(ref); | ||
91 | } | ||
92 | } | ||
93 | |||
94 | static int | ||
95 | qeth_eddp_buf_ref_context(struct qeth_qdio_out_buffer *buf, | ||
96 | struct qeth_eddp_context *ctx) | ||
97 | { | ||
98 | struct qeth_eddp_context_reference *ref; | ||
99 | |||
100 | QETH_DBF_TEXT(trace, 6, "eddprfcx"); | ||
101 | ref = kmalloc(sizeof(struct qeth_eddp_context_reference), GFP_ATOMIC); | ||
102 | if (ref == NULL) | ||
103 | return -ENOMEM; | ||
104 | qeth_eddp_get_context(ctx); | ||
105 | ref->ctx = ctx; | ||
106 | list_add_tail(&ref->list, &buf->ctx_list); | ||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | int | ||
111 | qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue, | ||
112 | struct qeth_eddp_context *ctx, | ||
113 | int index) | ||
114 | { | ||
115 | struct qeth_qdio_out_buffer *buf = NULL; | ||
116 | struct qdio_buffer *buffer; | ||
117 | int elements = ctx->num_elements; | ||
118 | int element = 0; | ||
119 | int flush_cnt = 0; | ||
120 | int must_refcnt = 1; | ||
121 | int i; | ||
122 | |||
123 | QETH_DBF_TEXT(trace, 5, "eddpfibu"); | ||
124 | while (elements > 0) { | ||
125 | buf = &queue->bufs[index]; | ||
126 | if (atomic_read(&buf->state) != QETH_QDIO_BUF_EMPTY){ | ||
127 | /* normally this should not happen since we checked for | ||
128 | * available elements in qeth_check_elements_for_context | ||
129 | */ | ||
130 | if (element == 0) | ||
131 | return -EBUSY; | ||
132 | else { | ||
133 | PRINT_WARN("could only partially fill eddp " | ||
134 | "buffer!\n"); | ||
135 | goto out; | ||
136 | } | ||
137 | } | ||
138 | /* check if the whole next skb fits into current buffer */ | ||
139 | if ((QETH_MAX_BUFFER_ELEMENTS(queue->card) - | ||
140 | buf->next_element_to_fill) | ||
141 | < ctx->elements_per_skb){ | ||
142 | /* no -> go to next buffer */ | ||
143 | atomic_set(&buf->state, QETH_QDIO_BUF_PRIMED); | ||
144 | index = (index + 1) % QDIO_MAX_BUFFERS_PER_Q; | ||
145 | flush_cnt++; | ||
146 | /* new buffer, so we have to add ctx to buffer'ctx_list | ||
147 | * and increment ctx's refcnt */ | ||
148 | must_refcnt = 1; | ||
149 | continue; | ||
150 | } | ||
151 | if (must_refcnt){ | ||
152 | must_refcnt = 0; | ||
153 | if (qeth_eddp_buf_ref_context(buf, ctx)){ | ||
154 | PRINT_WARN("no memory to create eddp context " | ||
155 | "reference\n"); | ||
156 | goto out_check; | ||
157 | } | ||
158 | } | ||
159 | buffer = buf->buffer; | ||
160 | /* fill one skb into buffer */ | ||
161 | for (i = 0; i < ctx->elements_per_skb; ++i){ | ||
162 | if (ctx->elements[element].length != 0) { | ||
163 | buffer->element[buf->next_element_to_fill]. | ||
164 | addr = ctx->elements[element].addr; | ||
165 | buffer->element[buf->next_element_to_fill]. | ||
166 | length = ctx->elements[element].length; | ||
167 | buffer->element[buf->next_element_to_fill]. | ||
168 | flags = ctx->elements[element].flags; | ||
169 | buf->next_element_to_fill++; | ||
170 | } | ||
171 | element++; | ||
172 | elements--; | ||
173 | } | ||
174 | } | ||
175 | out_check: | ||
176 | if (!queue->do_pack) { | ||
177 | QETH_DBF_TEXT(trace, 6, "fillbfnp"); | ||
178 | /* set state to PRIMED -> will be flushed */ | ||
179 | if (buf->next_element_to_fill > 0){ | ||
180 | atomic_set(&buf->state, QETH_QDIO_BUF_PRIMED); | ||
181 | flush_cnt++; | ||
182 | } | ||
183 | } else { | ||
184 | if (queue->card->options.performance_stats) | ||
185 | queue->card->perf_stats.skbs_sent_pack++; | ||
186 | QETH_DBF_TEXT(trace, 6, "fillbfpa"); | ||
187 | if (buf->next_element_to_fill >= | ||
188 | QETH_MAX_BUFFER_ELEMENTS(queue->card)) { | ||
189 | /* | ||
190 | * packed buffer if full -> set state PRIMED | ||
191 | * -> will be flushed | ||
192 | */ | ||
193 | atomic_set(&buf->state, QETH_QDIO_BUF_PRIMED); | ||
194 | flush_cnt++; | ||
195 | } | ||
196 | } | ||
197 | out: | ||
198 | return flush_cnt; | ||
199 | } | ||
200 | |||
201 | static void | ||
202 | qeth_eddp_create_segment_hdrs(struct qeth_eddp_context *ctx, | ||
203 | struct qeth_eddp_data *eddp, int data_len) | ||
204 | { | ||
205 | u8 *page; | ||
206 | int page_remainder; | ||
207 | int page_offset; | ||
208 | int pkt_len; | ||
209 | struct qeth_eddp_element *element; | ||
210 | |||
211 | QETH_DBF_TEXT(trace, 5, "eddpcrsh"); | ||
212 | page = ctx->pages[ctx->offset >> PAGE_SHIFT]; | ||
213 | page_offset = ctx->offset % PAGE_SIZE; | ||
214 | element = &ctx->elements[ctx->num_elements]; | ||
215 | pkt_len = eddp->nhl + eddp->thl + data_len; | ||
216 | /* FIXME: layer2 and VLAN !!! */ | ||
217 | if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2) | ||
218 | pkt_len += ETH_HLEN; | ||
219 | if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q)) | ||
220 | pkt_len += VLAN_HLEN; | ||
221 | /* does complete packet fit in current page ? */ | ||
222 | page_remainder = PAGE_SIZE - page_offset; | ||
223 | if (page_remainder < (sizeof(struct qeth_hdr) + pkt_len)){ | ||
224 | /* no -> go to start of next page */ | ||
225 | ctx->offset += page_remainder; | ||
226 | page = ctx->pages[ctx->offset >> PAGE_SHIFT]; | ||
227 | page_offset = 0; | ||
228 | } | ||
229 | memcpy(page + page_offset, &eddp->qh, sizeof(struct qeth_hdr)); | ||
230 | element->addr = page + page_offset; | ||
231 | element->length = sizeof(struct qeth_hdr); | ||
232 | ctx->offset += sizeof(struct qeth_hdr); | ||
233 | page_offset += sizeof(struct qeth_hdr); | ||
234 | /* add mac header (?) */ | ||
235 | if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2){ | ||
236 | memcpy(page + page_offset, &eddp->mac, ETH_HLEN); | ||
237 | element->length += ETH_HLEN; | ||
238 | ctx->offset += ETH_HLEN; | ||
239 | page_offset += ETH_HLEN; | ||
240 | } | ||
241 | /* add VLAN tag */ | ||
242 | if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q)){ | ||
243 | memcpy(page + page_offset, &eddp->vlan, VLAN_HLEN); | ||
244 | element->length += VLAN_HLEN; | ||
245 | ctx->offset += VLAN_HLEN; | ||
246 | page_offset += VLAN_HLEN; | ||
247 | } | ||
248 | /* add network header */ | ||
249 | memcpy(page + page_offset, (u8 *)&eddp->nh, eddp->nhl); | ||
250 | element->length += eddp->nhl; | ||
251 | eddp->nh_in_ctx = page + page_offset; | ||
252 | ctx->offset += eddp->nhl; | ||
253 | page_offset += eddp->nhl; | ||
254 | /* add transport header */ | ||
255 | memcpy(page + page_offset, (u8 *)&eddp->th, eddp->thl); | ||
256 | element->length += eddp->thl; | ||
257 | eddp->th_in_ctx = page + page_offset; | ||
258 | ctx->offset += eddp->thl; | ||
259 | } | ||
260 | |||
261 | static void | ||
262 | qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len, | ||
263 | __wsum *hcsum) | ||
264 | { | ||
265 | struct skb_frag_struct *frag; | ||
266 | int left_in_frag; | ||
267 | int copy_len; | ||
268 | u8 *src; | ||
269 | |||
270 | QETH_DBF_TEXT(trace, 5, "eddpcdtc"); | ||
271 | if (skb_shinfo(eddp->skb)->nr_frags == 0) { | ||
272 | skb_copy_from_linear_data_offset(eddp->skb, eddp->skb_offset, | ||
273 | dst, len); | ||
274 | *hcsum = csum_partial(eddp->skb->data + eddp->skb_offset, len, | ||
275 | *hcsum); | ||
276 | eddp->skb_offset += len; | ||
277 | } else { | ||
278 | while (len > 0) { | ||
279 | if (eddp->frag < 0) { | ||
280 | /* we're in skb->data */ | ||
281 | left_in_frag = (eddp->skb->len - eddp->skb->data_len) | ||
282 | - eddp->skb_offset; | ||
283 | src = eddp->skb->data + eddp->skb_offset; | ||
284 | } else { | ||
285 | frag = &skb_shinfo(eddp->skb)-> | ||
286 | frags[eddp->frag]; | ||
287 | left_in_frag = frag->size - eddp->frag_offset; | ||
288 | src = (u8 *)( | ||
289 | (page_to_pfn(frag->page) << PAGE_SHIFT)+ | ||
290 | frag->page_offset + eddp->frag_offset); | ||
291 | } | ||
292 | if (left_in_frag <= 0) { | ||
293 | eddp->frag++; | ||
294 | eddp->frag_offset = 0; | ||
295 | continue; | ||
296 | } | ||
297 | copy_len = min(left_in_frag, len); | ||
298 | memcpy(dst, src, copy_len); | ||
299 | *hcsum = csum_partial(src, copy_len, *hcsum); | ||
300 | dst += copy_len; | ||
301 | eddp->frag_offset += copy_len; | ||
302 | eddp->skb_offset += copy_len; | ||
303 | len -= copy_len; | ||
304 | } | ||
305 | } | ||
306 | } | ||
307 | |||
308 | static void | ||
309 | qeth_eddp_create_segment_data_tcp(struct qeth_eddp_context *ctx, | ||
310 | struct qeth_eddp_data *eddp, int data_len, | ||
311 | __wsum hcsum) | ||
312 | { | ||
313 | u8 *page; | ||
314 | int page_remainder; | ||
315 | int page_offset; | ||
316 | struct qeth_eddp_element *element; | ||
317 | int first_lap = 1; | ||
318 | |||
319 | QETH_DBF_TEXT(trace, 5, "eddpcsdt"); | ||
320 | page = ctx->pages[ctx->offset >> PAGE_SHIFT]; | ||
321 | page_offset = ctx->offset % PAGE_SIZE; | ||
322 | element = &ctx->elements[ctx->num_elements]; | ||
323 | while (data_len){ | ||
324 | page_remainder = PAGE_SIZE - page_offset; | ||
325 | if (page_remainder < data_len){ | ||
326 | qeth_eddp_copy_data_tcp(page + page_offset, eddp, | ||
327 | page_remainder, &hcsum); | ||
328 | element->length += page_remainder; | ||
329 | if (first_lap) | ||
330 | element->flags = SBAL_FLAGS_FIRST_FRAG; | ||
331 | else | ||
332 | element->flags = SBAL_FLAGS_MIDDLE_FRAG; | ||
333 | ctx->num_elements++; | ||
334 | element++; | ||
335 | data_len -= page_remainder; | ||
336 | ctx->offset += page_remainder; | ||
337 | page = ctx->pages[ctx->offset >> PAGE_SHIFT]; | ||
338 | page_offset = 0; | ||
339 | element->addr = page + page_offset; | ||
340 | } else { | ||
341 | qeth_eddp_copy_data_tcp(page + page_offset, eddp, | ||
342 | data_len, &hcsum); | ||
343 | element->length += data_len; | ||
344 | if (!first_lap) | ||
345 | element->flags = SBAL_FLAGS_LAST_FRAG; | ||
346 | ctx->num_elements++; | ||
347 | ctx->offset += data_len; | ||
348 | data_len = 0; | ||
349 | } | ||
350 | first_lap = 0; | ||
351 | } | ||
352 | ((struct tcphdr *)eddp->th_in_ctx)->check = csum_fold(hcsum); | ||
353 | } | ||
354 | |||
355 | static __wsum | ||
356 | qeth_eddp_check_tcp4_hdr(struct qeth_eddp_data *eddp, int data_len) | ||
357 | { | ||
358 | __wsum phcsum; /* pseudo header checksum */ | ||
359 | |||
360 | QETH_DBF_TEXT(trace, 5, "eddpckt4"); | ||
361 | eddp->th.tcp.h.check = 0; | ||
362 | /* compute pseudo header checksum */ | ||
363 | phcsum = csum_tcpudp_nofold(eddp->nh.ip4.h.saddr, eddp->nh.ip4.h.daddr, | ||
364 | eddp->thl + data_len, IPPROTO_TCP, 0); | ||
365 | /* compute checksum of tcp header */ | ||
366 | return csum_partial((u8 *)&eddp->th, eddp->thl, phcsum); | ||
367 | } | ||
368 | |||
369 | static __wsum | ||
370 | qeth_eddp_check_tcp6_hdr(struct qeth_eddp_data *eddp, int data_len) | ||
371 | { | ||
372 | __be32 proto; | ||
373 | __wsum phcsum; /* pseudo header checksum */ | ||
374 | |||
375 | QETH_DBF_TEXT(trace, 5, "eddpckt6"); | ||
376 | eddp->th.tcp.h.check = 0; | ||
377 | /* compute pseudo header checksum */ | ||
378 | phcsum = csum_partial((u8 *)&eddp->nh.ip6.h.saddr, | ||
379 | sizeof(struct in6_addr), 0); | ||
380 | phcsum = csum_partial((u8 *)&eddp->nh.ip6.h.daddr, | ||
381 | sizeof(struct in6_addr), phcsum); | ||
382 | proto = htonl(IPPROTO_TCP); | ||
383 | phcsum = csum_partial((u8 *)&proto, sizeof(u32), phcsum); | ||
384 | return phcsum; | ||
385 | } | ||
386 | |||
387 | static struct qeth_eddp_data * | ||
388 | qeth_eddp_create_eddp_data(struct qeth_hdr *qh, u8 *nh, u8 nhl, u8 *th, u8 thl) | ||
389 | { | ||
390 | struct qeth_eddp_data *eddp; | ||
391 | |||
392 | QETH_DBF_TEXT(trace, 5, "eddpcrda"); | ||
393 | eddp = kzalloc(sizeof(struct qeth_eddp_data), GFP_ATOMIC); | ||
394 | if (eddp){ | ||
395 | eddp->nhl = nhl; | ||
396 | eddp->thl = thl; | ||
397 | memcpy(&eddp->qh, qh, sizeof(struct qeth_hdr)); | ||
398 | memcpy(&eddp->nh, nh, nhl); | ||
399 | memcpy(&eddp->th, th, thl); | ||
400 | eddp->frag = -1; /* initially we're in skb->data */ | ||
401 | } | ||
402 | return eddp; | ||
403 | } | ||
404 | |||
405 | static void | ||
406 | __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx, | ||
407 | struct qeth_eddp_data *eddp) | ||
408 | { | ||
409 | struct tcphdr *tcph; | ||
410 | int data_len; | ||
411 | __wsum hcsum; | ||
412 | |||
413 | QETH_DBF_TEXT(trace, 5, "eddpftcp"); | ||
414 | eddp->skb_offset = sizeof(struct qeth_hdr) + eddp->nhl + eddp->thl; | ||
415 | if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2) { | ||
416 | eddp->skb_offset += sizeof(struct ethhdr); | ||
417 | #ifdef CONFIG_QETH_VLAN | ||
418 | if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q)) | ||
419 | eddp->skb_offset += VLAN_HLEN; | ||
420 | #endif /* CONFIG_QETH_VLAN */ | ||
421 | } | ||
422 | tcph = tcp_hdr(eddp->skb); | ||
423 | while (eddp->skb_offset < eddp->skb->len) { | ||
424 | data_len = min((int)skb_shinfo(eddp->skb)->gso_size, | ||
425 | (int)(eddp->skb->len - eddp->skb_offset)); | ||
426 | /* prepare qdio hdr */ | ||
427 | if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2){ | ||
428 | eddp->qh.hdr.l2.pkt_length = data_len + ETH_HLEN + | ||
429 | eddp->nhl + eddp->thl; | ||
430 | #ifdef CONFIG_QETH_VLAN | ||
431 | if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q)) | ||
432 | eddp->qh.hdr.l2.pkt_length += VLAN_HLEN; | ||
433 | #endif /* CONFIG_QETH_VLAN */ | ||
434 | } else | ||
435 | eddp->qh.hdr.l3.length = data_len + eddp->nhl + | ||
436 | eddp->thl; | ||
437 | /* prepare ip hdr */ | ||
438 | if (eddp->skb->protocol == htons(ETH_P_IP)){ | ||
439 | eddp->nh.ip4.h.tot_len = htons(data_len + eddp->nhl + | ||
440 | eddp->thl); | ||
441 | eddp->nh.ip4.h.check = 0; | ||
442 | eddp->nh.ip4.h.check = | ||
443 | ip_fast_csum((u8 *)&eddp->nh.ip4.h, | ||
444 | eddp->nh.ip4.h.ihl); | ||
445 | } else | ||
446 | eddp->nh.ip6.h.payload_len = htons(data_len + eddp->thl); | ||
447 | /* prepare tcp hdr */ | ||
448 | if (data_len == (eddp->skb->len - eddp->skb_offset)){ | ||
449 | /* last segment -> set FIN and PSH flags */ | ||
450 | eddp->th.tcp.h.fin = tcph->fin; | ||
451 | eddp->th.tcp.h.psh = tcph->psh; | ||
452 | } | ||
453 | if (eddp->skb->protocol == htons(ETH_P_IP)) | ||
454 | hcsum = qeth_eddp_check_tcp4_hdr(eddp, data_len); | ||
455 | else | ||
456 | hcsum = qeth_eddp_check_tcp6_hdr(eddp, data_len); | ||
457 | /* fill the next segment into the context */ | ||
458 | qeth_eddp_create_segment_hdrs(ctx, eddp, data_len); | ||
459 | qeth_eddp_create_segment_data_tcp(ctx, eddp, data_len, hcsum); | ||
460 | if (eddp->skb_offset >= eddp->skb->len) | ||
461 | break; | ||
462 | /* prepare headers for next round */ | ||
463 | if (eddp->skb->protocol == htons(ETH_P_IP)) | ||
464 | eddp->nh.ip4.h.id = htons(ntohs(eddp->nh.ip4.h.id) + 1); | ||
465 | eddp->th.tcp.h.seq = htonl(ntohl(eddp->th.tcp.h.seq) + data_len); | ||
466 | } | ||
467 | } | ||
468 | |||
469 | static int | ||
470 | qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx, | ||
471 | struct sk_buff *skb, struct qeth_hdr *qhdr) | ||
472 | { | ||
473 | struct qeth_eddp_data *eddp = NULL; | ||
474 | |||
475 | QETH_DBF_TEXT(trace, 5, "eddpficx"); | ||
476 | /* create our segmentation headers and copy original headers */ | ||
477 | if (skb->protocol == htons(ETH_P_IP)) | ||
478 | eddp = qeth_eddp_create_eddp_data(qhdr, | ||
479 | skb_network_header(skb), | ||
480 | ip_hdrlen(skb), | ||
481 | skb_transport_header(skb), | ||
482 | tcp_hdrlen(skb)); | ||
483 | else | ||
484 | eddp = qeth_eddp_create_eddp_data(qhdr, | ||
485 | skb_network_header(skb), | ||
486 | sizeof(struct ipv6hdr), | ||
487 | skb_transport_header(skb), | ||
488 | tcp_hdrlen(skb)); | ||
489 | |||
490 | if (eddp == NULL) { | ||
491 | QETH_DBF_TEXT(trace, 2, "eddpfcnm"); | ||
492 | return -ENOMEM; | ||
493 | } | ||
494 | if (qhdr->hdr.l2.id == QETH_HEADER_TYPE_LAYER2) { | ||
495 | skb_set_mac_header(skb, sizeof(struct qeth_hdr)); | ||
496 | memcpy(&eddp->mac, eth_hdr(skb), ETH_HLEN); | ||
497 | #ifdef CONFIG_QETH_VLAN | ||
498 | if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q)) { | ||
499 | eddp->vlan[0] = skb->protocol; | ||
500 | eddp->vlan[1] = htons(vlan_tx_tag_get(skb)); | ||
501 | } | ||
502 | #endif /* CONFIG_QETH_VLAN */ | ||
503 | } | ||
504 | /* the next flags will only be set on the last segment */ | ||
505 | eddp->th.tcp.h.fin = 0; | ||
506 | eddp->th.tcp.h.psh = 0; | ||
507 | eddp->skb = skb; | ||
508 | /* begin segmentation and fill context */ | ||
509 | __qeth_eddp_fill_context_tcp(ctx, eddp); | ||
510 | kfree(eddp); | ||
511 | return 0; | ||
512 | } | ||
513 | |||
514 | static void | ||
515 | qeth_eddp_calc_num_pages(struct qeth_eddp_context *ctx, struct sk_buff *skb, | ||
516 | int hdr_len) | ||
517 | { | ||
518 | int skbs_per_page; | ||
519 | |||
520 | QETH_DBF_TEXT(trace, 5, "eddpcanp"); | ||
521 | /* can we put multiple skbs in one page? */ | ||
522 | skbs_per_page = PAGE_SIZE / (skb_shinfo(skb)->gso_size + hdr_len); | ||
523 | if (skbs_per_page > 1){ | ||
524 | ctx->num_pages = (skb_shinfo(skb)->gso_segs + 1) / | ||
525 | skbs_per_page + 1; | ||
526 | ctx->elements_per_skb = 1; | ||
527 | } else { | ||
528 | /* no -> how many elements per skb? */ | ||
529 | ctx->elements_per_skb = (skb_shinfo(skb)->gso_size + hdr_len + | ||
530 | PAGE_SIZE) >> PAGE_SHIFT; | ||
531 | ctx->num_pages = ctx->elements_per_skb * | ||
532 | (skb_shinfo(skb)->gso_segs + 1); | ||
533 | } | ||
534 | ctx->num_elements = ctx->elements_per_skb * | ||
535 | (skb_shinfo(skb)->gso_segs + 1); | ||
536 | } | ||
537 | |||
538 | static struct qeth_eddp_context * | ||
539 | qeth_eddp_create_context_generic(struct qeth_card *card, struct sk_buff *skb, | ||
540 | int hdr_len) | ||
541 | { | ||
542 | struct qeth_eddp_context *ctx = NULL; | ||
543 | u8 *addr; | ||
544 | int i; | ||
545 | |||
546 | QETH_DBF_TEXT(trace, 5, "creddpcg"); | ||
547 | /* create the context and allocate pages */ | ||
548 | ctx = kzalloc(sizeof(struct qeth_eddp_context), GFP_ATOMIC); | ||
549 | if (ctx == NULL){ | ||
550 | QETH_DBF_TEXT(trace, 2, "ceddpcn1"); | ||
551 | return NULL; | ||
552 | } | ||
553 | ctx->type = QETH_LARGE_SEND_EDDP; | ||
554 | qeth_eddp_calc_num_pages(ctx, skb, hdr_len); | ||
555 | if (ctx->elements_per_skb > QETH_MAX_BUFFER_ELEMENTS(card)){ | ||
556 | QETH_DBF_TEXT(trace, 2, "ceddpcis"); | ||
557 | kfree(ctx); | ||
558 | return NULL; | ||
559 | } | ||
560 | ctx->pages = kcalloc(ctx->num_pages, sizeof(u8 *), GFP_ATOMIC); | ||
561 | if (ctx->pages == NULL){ | ||
562 | QETH_DBF_TEXT(trace, 2, "ceddpcn2"); | ||
563 | kfree(ctx); | ||
564 | return NULL; | ||
565 | } | ||
566 | for (i = 0; i < ctx->num_pages; ++i){ | ||
567 | addr = (u8 *)__get_free_page(GFP_ATOMIC); | ||
568 | if (addr == NULL){ | ||
569 | QETH_DBF_TEXT(trace, 2, "ceddpcn3"); | ||
570 | ctx->num_pages = i; | ||
571 | qeth_eddp_free_context(ctx); | ||
572 | return NULL; | ||
573 | } | ||
574 | memset(addr, 0, PAGE_SIZE); | ||
575 | ctx->pages[i] = addr; | ||
576 | } | ||
577 | ctx->elements = kcalloc(ctx->num_elements, | ||
578 | sizeof(struct qeth_eddp_element), GFP_ATOMIC); | ||
579 | if (ctx->elements == NULL){ | ||
580 | QETH_DBF_TEXT(trace, 2, "ceddpcn4"); | ||
581 | qeth_eddp_free_context(ctx); | ||
582 | return NULL; | ||
583 | } | ||
584 | /* reset num_elements; will be incremented again in fill_buffer to | ||
585 | * reflect number of actually used elements */ | ||
586 | ctx->num_elements = 0; | ||
587 | return ctx; | ||
588 | } | ||
589 | |||
590 | static struct qeth_eddp_context * | ||
591 | qeth_eddp_create_context_tcp(struct qeth_card *card, struct sk_buff *skb, | ||
592 | struct qeth_hdr *qhdr) | ||
593 | { | ||
594 | struct qeth_eddp_context *ctx = NULL; | ||
595 | |||
596 | QETH_DBF_TEXT(trace, 5, "creddpct"); | ||
597 | if (skb->protocol == htons(ETH_P_IP)) | ||
598 | ctx = qeth_eddp_create_context_generic(card, skb, | ||
599 | (sizeof(struct qeth_hdr) + | ||
600 | ip_hdrlen(skb) + | ||
601 | tcp_hdrlen(skb))); | ||
602 | else if (skb->protocol == htons(ETH_P_IPV6)) | ||
603 | ctx = qeth_eddp_create_context_generic(card, skb, | ||
604 | sizeof(struct qeth_hdr) + sizeof(struct ipv6hdr) + | ||
605 | tcp_hdrlen(skb)); | ||
606 | else | ||
607 | QETH_DBF_TEXT(trace, 2, "cetcpinv"); | ||
608 | |||
609 | if (ctx == NULL) { | ||
610 | QETH_DBF_TEXT(trace, 2, "creddpnl"); | ||
611 | return NULL; | ||
612 | } | ||
613 | if (qeth_eddp_fill_context_tcp(ctx, skb, qhdr)){ | ||
614 | QETH_DBF_TEXT(trace, 2, "ceddptfe"); | ||
615 | qeth_eddp_free_context(ctx); | ||
616 | return NULL; | ||
617 | } | ||
618 | atomic_set(&ctx->refcnt, 1); | ||
619 | return ctx; | ||
620 | } | ||
621 | |||
622 | struct qeth_eddp_context * | ||
623 | qeth_eddp_create_context(struct qeth_card *card, struct sk_buff *skb, | ||
624 | struct qeth_hdr *qhdr, unsigned char sk_protocol) | ||
625 | { | ||
626 | QETH_DBF_TEXT(trace, 5, "creddpc"); | ||
627 | switch (sk_protocol) { | ||
628 | case IPPROTO_TCP: | ||
629 | return qeth_eddp_create_context_tcp(card, skb, qhdr); | ||
630 | default: | ||
631 | QETH_DBF_TEXT(trace, 2, "eddpinvp"); | ||
632 | } | ||
633 | return NULL; | ||
634 | } | ||
diff --git a/drivers/s390/net/qeth_eddp.h b/drivers/s390/net/qeth_eddp.h deleted file mode 100644 index 52910c9252c0..000000000000 --- a/drivers/s390/net/qeth_eddp.h +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/s390/net/qeth_eddp.h | ||
3 | * | ||
4 | * Header file for qeth enhanced device driver packing. | ||
5 | * | ||
6 | * Copyright 2004 IBM Corporation | ||
7 | * | ||
8 | * Author(s): Thomas Spatzier <tspat@de.ibm.com> | ||
9 | * | ||
10 | */ | ||
11 | #ifndef __QETH_EDDP_H__ | ||
12 | #define __QETH_EDDP_H__ | ||
13 | |||
14 | struct qeth_eddp_element { | ||
15 | u32 flags; | ||
16 | u32 length; | ||
17 | void *addr; | ||
18 | }; | ||
19 | |||
20 | struct qeth_eddp_context { | ||
21 | atomic_t refcnt; | ||
22 | enum qeth_large_send_types type; | ||
23 | int num_pages; /* # of allocated pages */ | ||
24 | u8 **pages; /* pointers to pages */ | ||
25 | int offset; /* offset in ctx during creation */ | ||
26 | int num_elements; /* # of required 'SBALEs' */ | ||
27 | struct qeth_eddp_element *elements; /* array of 'SBALEs' */ | ||
28 | int elements_per_skb; /* # of 'SBALEs' per skb **/ | ||
29 | }; | ||
30 | |||
31 | struct qeth_eddp_context_reference { | ||
32 | struct list_head list; | ||
33 | struct qeth_eddp_context *ctx; | ||
34 | }; | ||
35 | |||
36 | extern struct qeth_eddp_context * | ||
37 | qeth_eddp_create_context(struct qeth_card *,struct sk_buff *, | ||
38 | struct qeth_hdr *, unsigned char); | ||
39 | |||
40 | extern void | ||
41 | qeth_eddp_put_context(struct qeth_eddp_context *); | ||
42 | |||
43 | extern int | ||
44 | qeth_eddp_fill_buffer(struct qeth_qdio_out_q *,struct qeth_eddp_context *,int); | ||
45 | |||
46 | extern void | ||
47 | qeth_eddp_buf_release_contexts(struct qeth_qdio_out_buffer *); | ||
48 | |||
49 | extern int | ||
50 | qeth_eddp_check_buffers_for_context(struct qeth_qdio_out_q *, | ||
51 | struct qeth_eddp_context *); | ||
52 | /* | ||
53 | * Data used for fragmenting a IP packet. | ||
54 | */ | ||
55 | struct qeth_eddp_data { | ||
56 | struct qeth_hdr qh; | ||
57 | struct ethhdr mac; | ||
58 | __be16 vlan[2]; | ||
59 | union { | ||
60 | struct { | ||
61 | struct iphdr h; | ||
62 | u8 options[40]; | ||
63 | } ip4; | ||
64 | struct { | ||
65 | struct ipv6hdr h; | ||
66 | } ip6; | ||
67 | } nh; | ||
68 | u8 nhl; | ||
69 | void *nh_in_ctx; /* address of nh within the ctx */ | ||
70 | union { | ||
71 | struct { | ||
72 | struct tcphdr h; | ||
73 | u8 options[40]; | ||
74 | } tcp; | ||
75 | } th; | ||
76 | u8 thl; | ||
77 | void *th_in_ctx; /* address of th within the ctx */ | ||
78 | struct sk_buff *skb; | ||
79 | int skb_offset; | ||
80 | int frag; | ||
81 | int frag_offset; | ||
82 | } __attribute__ ((packed)); | ||
83 | |||
84 | #endif /* __QETH_EDDP_H__ */ | ||
diff --git a/drivers/s390/net/qeth_fs.h b/drivers/s390/net/qeth_fs.h deleted file mode 100644 index 61faf05517d6..000000000000 --- a/drivers/s390/net/qeth_fs.h +++ /dev/null | |||
@@ -1,168 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/s390/net/qeth_fs.h | ||
3 | * | ||
4 | * Linux on zSeries OSA Express and HiperSockets support. | ||
5 | * | ||
6 | * This header file contains definitions related to sysfs and procfs. | ||
7 | * | ||
8 | * Copyright 2000,2003 IBM Corporation | ||
9 | * Author(s): Thomas Spatzier <tspat@de.ibm.com> | ||
10 | * | ||
11 | */ | ||
12 | #ifndef __QETH_FS_H__ | ||
13 | #define __QETH_FS_H__ | ||
14 | |||
15 | #ifdef CONFIG_PROC_FS | ||
16 | extern int | ||
17 | qeth_create_procfs_entries(void); | ||
18 | |||
19 | extern void | ||
20 | qeth_remove_procfs_entries(void); | ||
21 | #else | ||
22 | static inline int | ||
23 | qeth_create_procfs_entries(void) | ||
24 | { | ||
25 | return 0; | ||
26 | } | ||
27 | |||
28 | static inline void | ||
29 | qeth_remove_procfs_entries(void) | ||
30 | { | ||
31 | } | ||
32 | #endif /* CONFIG_PROC_FS */ | ||
33 | |||
34 | extern int | ||
35 | qeth_create_device_attributes(struct device *dev); | ||
36 | |||
37 | extern void | ||
38 | qeth_remove_device_attributes(struct device *dev); | ||
39 | |||
40 | extern int | ||
41 | qeth_create_device_attributes_osn(struct device *dev); | ||
42 | |||
43 | extern void | ||
44 | qeth_remove_device_attributes_osn(struct device *dev); | ||
45 | |||
46 | extern int | ||
47 | qeth_create_driver_attributes(void); | ||
48 | |||
49 | extern void | ||
50 | qeth_remove_driver_attributes(void); | ||
51 | |||
52 | /* | ||
53 | * utility functions used in qeth_proc.c and qeth_sys.c | ||
54 | */ | ||
55 | |||
56 | static inline const char * | ||
57 | qeth_get_checksum_str(struct qeth_card *card) | ||
58 | { | ||
59 | if (card->options.checksum_type == SW_CHECKSUMMING) | ||
60 | return "sw"; | ||
61 | else if (card->options.checksum_type == HW_CHECKSUMMING) | ||
62 | return "hw"; | ||
63 | else | ||
64 | return "no"; | ||
65 | } | ||
66 | |||
67 | static inline const char * | ||
68 | qeth_get_prioq_str(struct qeth_card *card, char *buf) | ||
69 | { | ||
70 | if (card->qdio.do_prio_queueing == QETH_NO_PRIO_QUEUEING) | ||
71 | sprintf(buf, "always_q_%i", card->qdio.default_out_queue); | ||
72 | else | ||
73 | strcpy(buf, (card->qdio.do_prio_queueing == | ||
74 | QETH_PRIO_Q_ING_PREC)? | ||
75 | "by_prec." : "by_ToS"); | ||
76 | return buf; | ||
77 | } | ||
78 | |||
79 | static inline const char * | ||
80 | qeth_get_bufsize_str(struct qeth_card *card) | ||
81 | { | ||
82 | if (card->qdio.in_buf_size == 16384) | ||
83 | return "16k"; | ||
84 | else if (card->qdio.in_buf_size == 24576) | ||
85 | return "24k"; | ||
86 | else if (card->qdio.in_buf_size == 32768) | ||
87 | return "32k"; | ||
88 | else if (card->qdio.in_buf_size == 40960) | ||
89 | return "40k"; | ||
90 | else | ||
91 | return "64k"; | ||
92 | } | ||
93 | |||
94 | static inline const char * | ||
95 | qeth_get_cardname(struct qeth_card *card) | ||
96 | { | ||
97 | if (card->info.guestlan) { | ||
98 | switch (card->info.type) { | ||
99 | case QETH_CARD_TYPE_OSAE: | ||
100 | return " Guest LAN QDIO"; | ||
101 | case QETH_CARD_TYPE_IQD: | ||
102 | return " Guest LAN Hiper"; | ||
103 | default: | ||
104 | return " unknown"; | ||
105 | } | ||
106 | } else { | ||
107 | switch (card->info.type) { | ||
108 | case QETH_CARD_TYPE_OSAE: | ||
109 | return " OSD Express"; | ||
110 | case QETH_CARD_TYPE_IQD: | ||
111 | return " HiperSockets"; | ||
112 | case QETH_CARD_TYPE_OSN: | ||
113 | return " OSN QDIO"; | ||
114 | default: | ||
115 | return " unknown"; | ||
116 | } | ||
117 | } | ||
118 | return " n/a"; | ||
119 | } | ||
120 | |||
121 | /* max length to be returned: 14 */ | ||
122 | static inline const char * | ||
123 | qeth_get_cardname_short(struct qeth_card *card) | ||
124 | { | ||
125 | if (card->info.guestlan){ | ||
126 | switch (card->info.type){ | ||
127 | case QETH_CARD_TYPE_OSAE: | ||
128 | return "GuestLAN QDIO"; | ||
129 | case QETH_CARD_TYPE_IQD: | ||
130 | return "GuestLAN Hiper"; | ||
131 | default: | ||
132 | return "unknown"; | ||
133 | } | ||
134 | } else { | ||
135 | switch (card->info.type) { | ||
136 | case QETH_CARD_TYPE_OSAE: | ||
137 | switch (card->info.link_type) { | ||
138 | case QETH_LINK_TYPE_FAST_ETH: | ||
139 | return "OSD_100"; | ||
140 | case QETH_LINK_TYPE_HSTR: | ||
141 | return "HSTR"; | ||
142 | case QETH_LINK_TYPE_GBIT_ETH: | ||
143 | return "OSD_1000"; | ||
144 | case QETH_LINK_TYPE_10GBIT_ETH: | ||
145 | return "OSD_10GIG"; | ||
146 | case QETH_LINK_TYPE_LANE_ETH100: | ||
147 | return "OSD_FE_LANE"; | ||
148 | case QETH_LINK_TYPE_LANE_TR: | ||
149 | return "OSD_TR_LANE"; | ||
150 | case QETH_LINK_TYPE_LANE_ETH1000: | ||
151 | return "OSD_GbE_LANE"; | ||
152 | case QETH_LINK_TYPE_LANE: | ||
153 | return "OSD_ATM_LANE"; | ||
154 | default: | ||
155 | return "OSD_Express"; | ||
156 | } | ||
157 | case QETH_CARD_TYPE_IQD: | ||
158 | return "HiperSockets"; | ||
159 | case QETH_CARD_TYPE_OSN: | ||
160 | return "OSN"; | ||
161 | default: | ||
162 | return "unknown"; | ||
163 | } | ||
164 | } | ||
165 | return "n/a"; | ||
166 | } | ||
167 | |||
168 | #endif /* __QETH_FS_H__ */ | ||
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c deleted file mode 100644 index 62606ce26e55..000000000000 --- a/drivers/s390/net/qeth_main.c +++ /dev/null | |||
@@ -1,8956 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/s390/net/qeth_main.c | ||
3 | * | ||
4 | * Linux on zSeries OSA Express and HiperSockets support | ||
5 | * | ||
6 | * Copyright 2000,2003 IBM Corporation | ||
7 | * | ||
8 | * Author(s): Original Code written by | ||
9 | * Utz Bacher (utz.bacher@de.ibm.com) | ||
10 | * Rewritten by | ||
11 | * Frank Pavlic (fpavlic@de.ibm.com) and | ||
12 | * Thomas Spatzier <tspat@de.ibm.com> | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License as published by | ||
16 | * the Free Software Foundation; either version 2, or (at your option) | ||
17 | * any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
27 | */ | ||
28 | |||
29 | |||
30 | #include <linux/module.h> | ||
31 | #include <linux/moduleparam.h> | ||
32 | #include <linux/string.h> | ||
33 | #include <linux/errno.h> | ||
34 | #include <linux/mm.h> | ||
35 | #include <linux/ip.h> | ||
36 | #include <linux/inetdevice.h> | ||
37 | #include <linux/netdevice.h> | ||
38 | #include <linux/sched.h> | ||
39 | #include <linux/workqueue.h> | ||
40 | #include <linux/kernel.h> | ||
41 | #include <linux/slab.h> | ||
42 | #include <linux/interrupt.h> | ||
43 | #include <linux/tcp.h> | ||
44 | #include <linux/icmp.h> | ||
45 | #include <linux/skbuff.h> | ||
46 | #include <linux/in.h> | ||
47 | #include <linux/igmp.h> | ||
48 | #include <linux/init.h> | ||
49 | #include <linux/reboot.h> | ||
50 | #include <linux/mii.h> | ||
51 | #include <linux/rcupdate.h> | ||
52 | #include <linux/ethtool.h> | ||
53 | |||
54 | #include <net/arp.h> | ||
55 | #include <net/ip.h> | ||
56 | #include <net/route.h> | ||
57 | |||
58 | #include <asm/ebcdic.h> | ||
59 | #include <asm/io.h> | ||
60 | #include <asm/qeth.h> | ||
61 | #include <asm/timex.h> | ||
62 | #include <asm/semaphore.h> | ||
63 | #include <asm/uaccess.h> | ||
64 | #include <asm/s390_rdev.h> | ||
65 | |||
66 | #include "qeth.h" | ||
67 | #include "qeth_mpc.h" | ||
68 | #include "qeth_fs.h" | ||
69 | #include "qeth_eddp.h" | ||
70 | #include "qeth_tso.h" | ||
71 | |||
72 | static const char *version = "qeth S/390 OSA-Express driver"; | ||
73 | |||
74 | /** | ||
75 | * Debug Facility Stuff | ||
76 | */ | ||
77 | static debug_info_t *qeth_dbf_setup = NULL; | ||
78 | static debug_info_t *qeth_dbf_data = NULL; | ||
79 | static debug_info_t *qeth_dbf_misc = NULL; | ||
80 | static debug_info_t *qeth_dbf_control = NULL; | ||
81 | debug_info_t *qeth_dbf_trace = NULL; | ||
82 | static debug_info_t *qeth_dbf_sense = NULL; | ||
83 | static debug_info_t *qeth_dbf_qerr = NULL; | ||
84 | |||
85 | DEFINE_PER_CPU(char[256], qeth_dbf_txt_buf); | ||
86 | |||
87 | static struct lock_class_key qdio_out_skb_queue_key; | ||
88 | |||
89 | /** | ||
90 | * some more definitions and declarations | ||
91 | */ | ||
92 | static unsigned int known_devices[][10] = QETH_MODELLIST_ARRAY; | ||
93 | |||
94 | /* list of our cards */ | ||
95 | struct qeth_card_list_struct qeth_card_list; | ||
96 | /*process list want to be notified*/ | ||
97 | spinlock_t qeth_notify_lock; | ||
98 | struct list_head qeth_notify_list; | ||
99 | |||
100 | static void qeth_send_control_data_cb(struct qeth_channel *, | ||
101 | struct qeth_cmd_buffer *); | ||
102 | |||
103 | /** | ||
104 | * here we go with function implementation | ||
105 | */ | ||
106 | static void | ||
107 | qeth_init_qdio_info(struct qeth_card *card); | ||
108 | |||
109 | static int | ||
110 | qeth_init_qdio_queues(struct qeth_card *card); | ||
111 | |||
112 | static int | ||
113 | qeth_alloc_qdio_buffers(struct qeth_card *card); | ||
114 | |||
115 | static void | ||
116 | qeth_free_qdio_buffers(struct qeth_card *); | ||
117 | |||
118 | static void | ||
119 | qeth_clear_qdio_buffers(struct qeth_card *); | ||
120 | |||
121 | static void | ||
122 | qeth_clear_ip_list(struct qeth_card *, int, int); | ||
123 | |||
124 | static void | ||
125 | qeth_clear_ipacmd_list(struct qeth_card *); | ||
126 | |||
127 | static int | ||
128 | qeth_qdio_clear_card(struct qeth_card *, int); | ||
129 | |||
130 | static void | ||
131 | qeth_clear_working_pool_list(struct qeth_card *); | ||
132 | |||
133 | static void | ||
134 | qeth_clear_cmd_buffers(struct qeth_channel *); | ||
135 | |||
136 | static int | ||
137 | qeth_stop(struct net_device *); | ||
138 | |||
139 | static void | ||
140 | qeth_clear_ipato_list(struct qeth_card *); | ||
141 | |||
142 | static int | ||
143 | qeth_is_addr_covered_by_ipato(struct qeth_card *, struct qeth_ipaddr *); | ||
144 | |||
145 | static void | ||
146 | qeth_irq_tasklet(unsigned long); | ||
147 | |||
148 | static int | ||
149 | qeth_set_online(struct ccwgroup_device *); | ||
150 | |||
151 | static int | ||
152 | __qeth_set_online(struct ccwgroup_device *gdev, int recovery_mode); | ||
153 | |||
154 | static struct qeth_ipaddr * | ||
155 | qeth_get_addr_buffer(enum qeth_prot_versions); | ||
156 | |||
157 | static void | ||
158 | qeth_set_multicast_list(struct net_device *); | ||
159 | |||
160 | static void | ||
161 | qeth_setadp_promisc_mode(struct qeth_card *); | ||
162 | |||
163 | static int | ||
164 | qeth_hard_header_parse(const struct sk_buff *skb, unsigned char *haddr); | ||
165 | |||
166 | static void | ||
167 | qeth_notify_processes(void) | ||
168 | { | ||
169 | /*notify all registered processes */ | ||
170 | struct qeth_notify_list_struct *n_entry; | ||
171 | |||
172 | QETH_DBF_TEXT(trace,3,"procnoti"); | ||
173 | spin_lock(&qeth_notify_lock); | ||
174 | list_for_each_entry(n_entry, &qeth_notify_list, list) { | ||
175 | send_sig(n_entry->signum, n_entry->task, 1); | ||
176 | } | ||
177 | spin_unlock(&qeth_notify_lock); | ||
178 | |||
179 | } | ||
180 | int | ||
181 | qeth_notifier_unregister(struct task_struct *p) | ||
182 | { | ||
183 | struct qeth_notify_list_struct *n_entry, *tmp; | ||
184 | |||
185 | QETH_DBF_TEXT(trace, 2, "notunreg"); | ||
186 | spin_lock(&qeth_notify_lock); | ||
187 | list_for_each_entry_safe(n_entry, tmp, &qeth_notify_list, list) { | ||
188 | if (n_entry->task == p) { | ||
189 | list_del(&n_entry->list); | ||
190 | kfree(n_entry); | ||
191 | goto out; | ||
192 | } | ||
193 | } | ||
194 | out: | ||
195 | spin_unlock(&qeth_notify_lock); | ||
196 | return 0; | ||
197 | } | ||
198 | int | ||
199 | qeth_notifier_register(struct task_struct *p, int signum) | ||
200 | { | ||
201 | struct qeth_notify_list_struct *n_entry; | ||
202 | |||
203 | /*check first if entry already exists*/ | ||
204 | spin_lock(&qeth_notify_lock); | ||
205 | list_for_each_entry(n_entry, &qeth_notify_list, list) { | ||
206 | if (n_entry->task == p) { | ||
207 | n_entry->signum = signum; | ||
208 | spin_unlock(&qeth_notify_lock); | ||
209 | return 0; | ||
210 | } | ||
211 | } | ||
212 | spin_unlock(&qeth_notify_lock); | ||
213 | |||
214 | n_entry = (struct qeth_notify_list_struct *) | ||
215 | kmalloc(sizeof(struct qeth_notify_list_struct),GFP_KERNEL); | ||
216 | if (!n_entry) | ||
217 | return -ENOMEM; | ||
218 | n_entry->task = p; | ||
219 | n_entry->signum = signum; | ||
220 | spin_lock(&qeth_notify_lock); | ||
221 | list_add(&n_entry->list,&qeth_notify_list); | ||
222 | spin_unlock(&qeth_notify_lock); | ||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | |||
227 | /** | ||
228 | * free channel command buffers | ||
229 | */ | ||
230 | static void | ||
231 | qeth_clean_channel(struct qeth_channel *channel) | ||
232 | { | ||
233 | int cnt; | ||
234 | |||
235 | QETH_DBF_TEXT(setup, 2, "freech"); | ||
236 | for (cnt = 0; cnt < QETH_CMD_BUFFER_NO; cnt++) | ||
237 | kfree(channel->iob[cnt].data); | ||
238 | } | ||
239 | |||
240 | /** | ||
241 | * free card | ||
242 | */ | ||
243 | static void | ||
244 | qeth_free_card(struct qeth_card *card) | ||
245 | { | ||
246 | |||
247 | QETH_DBF_TEXT(setup, 2, "freecrd"); | ||
248 | QETH_DBF_HEX(setup, 2, &card, sizeof(void *)); | ||
249 | qeth_clean_channel(&card->read); | ||
250 | qeth_clean_channel(&card->write); | ||
251 | if (card->dev) | ||
252 | free_netdev(card->dev); | ||
253 | qeth_clear_ip_list(card, 0, 0); | ||
254 | qeth_clear_ipato_list(card); | ||
255 | kfree(card->ip_tbd_list); | ||
256 | qeth_free_qdio_buffers(card); | ||
257 | kfree(card); | ||
258 | } | ||
259 | |||
260 | /** | ||
261 | * alloc memory for command buffer per channel | ||
262 | */ | ||
263 | static int | ||
264 | qeth_setup_channel(struct qeth_channel *channel) | ||
265 | { | ||
266 | int cnt; | ||
267 | |||
268 | QETH_DBF_TEXT(setup, 2, "setupch"); | ||
269 | for (cnt=0; cnt < QETH_CMD_BUFFER_NO; cnt++) { | ||
270 | channel->iob[cnt].data = (char *) | ||
271 | kmalloc(QETH_BUFSIZE, GFP_DMA|GFP_KERNEL); | ||
272 | if (channel->iob[cnt].data == NULL) | ||
273 | break; | ||
274 | channel->iob[cnt].state = BUF_STATE_FREE; | ||
275 | channel->iob[cnt].channel = channel; | ||
276 | channel->iob[cnt].callback = qeth_send_control_data_cb; | ||
277 | channel->iob[cnt].rc = 0; | ||
278 | } | ||
279 | if (cnt < QETH_CMD_BUFFER_NO) { | ||
280 | while (cnt-- > 0) | ||
281 | kfree(channel->iob[cnt].data); | ||
282 | return -ENOMEM; | ||
283 | } | ||
284 | channel->buf_no = 0; | ||
285 | channel->io_buf_no = 0; | ||
286 | atomic_set(&channel->irq_pending, 0); | ||
287 | spin_lock_init(&channel->iob_lock); | ||
288 | |||
289 | init_waitqueue_head(&channel->wait_q); | ||
290 | channel->irq_tasklet.data = (unsigned long) channel; | ||
291 | channel->irq_tasklet.func = qeth_irq_tasklet; | ||
292 | return 0; | ||
293 | } | ||
294 | |||
295 | /** | ||
296 | * alloc memory for card structure | ||
297 | */ | ||
298 | static struct qeth_card * | ||
299 | qeth_alloc_card(void) | ||
300 | { | ||
301 | struct qeth_card *card; | ||
302 | |||
303 | QETH_DBF_TEXT(setup, 2, "alloccrd"); | ||
304 | card = kzalloc(sizeof(struct qeth_card), GFP_DMA|GFP_KERNEL); | ||
305 | if (!card) | ||
306 | return NULL; | ||
307 | QETH_DBF_HEX(setup, 2, &card, sizeof(void *)); | ||
308 | if (qeth_setup_channel(&card->read)) { | ||
309 | kfree(card); | ||
310 | return NULL; | ||
311 | } | ||
312 | if (qeth_setup_channel(&card->write)) { | ||
313 | qeth_clean_channel(&card->read); | ||
314 | kfree(card); | ||
315 | return NULL; | ||
316 | } | ||
317 | return card; | ||
318 | } | ||
319 | |||
320 | static long | ||
321 | __qeth_check_irb_error(struct ccw_device *cdev, unsigned long intparm, | ||
322 | struct irb *irb) | ||
323 | { | ||
324 | if (!IS_ERR(irb)) | ||
325 | return 0; | ||
326 | |||
327 | switch (PTR_ERR(irb)) { | ||
328 | case -EIO: | ||
329 | PRINT_WARN("i/o-error on device %s\n", cdev->dev.bus_id); | ||
330 | QETH_DBF_TEXT(trace, 2, "ckirberr"); | ||
331 | QETH_DBF_TEXT_(trace, 2, " rc%d", -EIO); | ||
332 | break; | ||
333 | case -ETIMEDOUT: | ||
334 | PRINT_WARN("timeout on device %s\n", cdev->dev.bus_id); | ||
335 | QETH_DBF_TEXT(trace, 2, "ckirberr"); | ||
336 | QETH_DBF_TEXT_(trace, 2, " rc%d", -ETIMEDOUT); | ||
337 | if (intparm == QETH_RCD_PARM) { | ||
338 | struct qeth_card *card = CARD_FROM_CDEV(cdev); | ||
339 | |||
340 | if (card && (card->data.ccwdev == cdev)) { | ||
341 | card->data.state = CH_STATE_DOWN; | ||
342 | wake_up(&card->wait_q); | ||
343 | } | ||
344 | } | ||
345 | break; | ||
346 | default: | ||
347 | PRINT_WARN("unknown error %ld on device %s\n", PTR_ERR(irb), | ||
348 | cdev->dev.bus_id); | ||
349 | QETH_DBF_TEXT(trace, 2, "ckirberr"); | ||
350 | QETH_DBF_TEXT(trace, 2, " rc???"); | ||
351 | } | ||
352 | return PTR_ERR(irb); | ||
353 | } | ||
354 | |||
355 | static int | ||
356 | qeth_get_problem(struct ccw_device *cdev, struct irb *irb) | ||
357 | { | ||
358 | int dstat,cstat; | ||
359 | char *sense; | ||
360 | |||
361 | sense = (char *) irb->ecw; | ||
362 | cstat = irb->scsw.cstat; | ||
363 | dstat = irb->scsw.dstat; | ||
364 | |||
365 | if (cstat & (SCHN_STAT_CHN_CTRL_CHK | SCHN_STAT_INTF_CTRL_CHK | | ||
366 | SCHN_STAT_CHN_DATA_CHK | SCHN_STAT_CHAIN_CHECK | | ||
367 | SCHN_STAT_PROT_CHECK | SCHN_STAT_PROG_CHECK)) { | ||
368 | QETH_DBF_TEXT(trace,2, "CGENCHK"); | ||
369 | PRINT_WARN("check on device %s, dstat=x%x, cstat=x%x ", | ||
370 | cdev->dev.bus_id, dstat, cstat); | ||
371 | HEXDUMP16(WARN, "irb: ", irb); | ||
372 | HEXDUMP16(WARN, "irb: ", ((char *) irb) + 32); | ||
373 | return 1; | ||
374 | } | ||
375 | |||
376 | if (dstat & DEV_STAT_UNIT_CHECK) { | ||
377 | if (sense[SENSE_RESETTING_EVENT_BYTE] & | ||
378 | SENSE_RESETTING_EVENT_FLAG) { | ||
379 | QETH_DBF_TEXT(trace,2,"REVIND"); | ||
380 | return 1; | ||
381 | } | ||
382 | if (sense[SENSE_COMMAND_REJECT_BYTE] & | ||
383 | SENSE_COMMAND_REJECT_FLAG) { | ||
384 | QETH_DBF_TEXT(trace,2,"CMDREJi"); | ||
385 | return 0; | ||
386 | } | ||
387 | if ((sense[2] == 0xaf) && (sense[3] == 0xfe)) { | ||
388 | QETH_DBF_TEXT(trace,2,"AFFE"); | ||
389 | return 1; | ||
390 | } | ||
391 | if ((!sense[0]) && (!sense[1]) && (!sense[2]) && (!sense[3])) { | ||
392 | QETH_DBF_TEXT(trace,2,"ZEROSEN"); | ||
393 | return 0; | ||
394 | } | ||
395 | QETH_DBF_TEXT(trace,2,"DGENCHK"); | ||
396 | return 1; | ||
397 | } | ||
398 | return 0; | ||
399 | } | ||
400 | static int qeth_issue_next_read(struct qeth_card *); | ||
401 | |||
402 | /** | ||
403 | * interrupt handler | ||
404 | */ | ||
405 | static void | ||
406 | qeth_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb) | ||
407 | { | ||
408 | int rc; | ||
409 | int cstat,dstat; | ||
410 | struct qeth_cmd_buffer *buffer; | ||
411 | struct qeth_channel *channel; | ||
412 | struct qeth_card *card; | ||
413 | |||
414 | QETH_DBF_TEXT(trace,5,"irq"); | ||
415 | |||
416 | if (__qeth_check_irb_error(cdev, intparm, irb)) | ||
417 | return; | ||
418 | cstat = irb->scsw.cstat; | ||
419 | dstat = irb->scsw.dstat; | ||
420 | |||
421 | card = CARD_FROM_CDEV(cdev); | ||
422 | if (!card) | ||
423 | return; | ||
424 | |||
425 | if (card->read.ccwdev == cdev){ | ||
426 | channel = &card->read; | ||
427 | QETH_DBF_TEXT(trace,5,"read"); | ||
428 | } else if (card->write.ccwdev == cdev) { | ||
429 | channel = &card->write; | ||
430 | QETH_DBF_TEXT(trace,5,"write"); | ||
431 | } else { | ||
432 | channel = &card->data; | ||
433 | QETH_DBF_TEXT(trace,5,"data"); | ||
434 | } | ||
435 | atomic_set(&channel->irq_pending, 0); | ||
436 | |||
437 | if (irb->scsw.fctl & (SCSW_FCTL_CLEAR_FUNC)) | ||
438 | channel->state = CH_STATE_STOPPED; | ||
439 | |||
440 | if (irb->scsw.fctl & (SCSW_FCTL_HALT_FUNC)) | ||
441 | channel->state = CH_STATE_HALTED; | ||
442 | |||
443 | /*let's wake up immediately on data channel*/ | ||
444 | if ((channel == &card->data) && (intparm != 0) && | ||
445 | (intparm != QETH_RCD_PARM)) | ||
446 | goto out; | ||
447 | |||
448 | if (intparm == QETH_CLEAR_CHANNEL_PARM) { | ||
449 | QETH_DBF_TEXT(trace, 6, "clrchpar"); | ||
450 | /* we don't have to handle this further */ | ||
451 | intparm = 0; | ||
452 | } | ||
453 | if (intparm == QETH_HALT_CHANNEL_PARM) { | ||
454 | QETH_DBF_TEXT(trace, 6, "hltchpar"); | ||
455 | /* we don't have to handle this further */ | ||
456 | intparm = 0; | ||
457 | } | ||
458 | if ((dstat & DEV_STAT_UNIT_EXCEP) || | ||
459 | (dstat & DEV_STAT_UNIT_CHECK) || | ||
460 | (cstat)) { | ||
461 | if (irb->esw.esw0.erw.cons) { | ||
462 | /* TODO: we should make this s390dbf */ | ||
463 | PRINT_WARN("sense data available on channel %s.\n", | ||
464 | CHANNEL_ID(channel)); | ||
465 | PRINT_WARN(" cstat 0x%X\n dstat 0x%X\n", cstat, dstat); | ||
466 | HEXDUMP16(WARN,"irb: ",irb); | ||
467 | HEXDUMP16(WARN,"sense data: ",irb->ecw); | ||
468 | } | ||
469 | if (intparm == QETH_RCD_PARM) { | ||
470 | channel->state = CH_STATE_DOWN; | ||
471 | goto out; | ||
472 | } | ||
473 | rc = qeth_get_problem(cdev,irb); | ||
474 | if (rc) { | ||
475 | qeth_schedule_recovery(card); | ||
476 | goto out; | ||
477 | } | ||
478 | } | ||
479 | |||
480 | if (intparm == QETH_RCD_PARM) { | ||
481 | channel->state = CH_STATE_RCD_DONE; | ||
482 | goto out; | ||
483 | } | ||
484 | if (intparm) { | ||
485 | buffer = (struct qeth_cmd_buffer *) __va((addr_t)intparm); | ||
486 | buffer->state = BUF_STATE_PROCESSED; | ||
487 | } | ||
488 | if (channel == &card->data) | ||
489 | return; | ||
490 | |||
491 | if (channel == &card->read && | ||
492 | channel->state == CH_STATE_UP) | ||
493 | qeth_issue_next_read(card); | ||
494 | |||
495 | qeth_irq_tasklet((unsigned long)channel); | ||
496 | return; | ||
497 | out: | ||
498 | wake_up(&card->wait_q); | ||
499 | } | ||
500 | |||
501 | /** | ||
502 | * tasklet function scheduled from irq handler | ||
503 | */ | ||
504 | static void | ||
505 | qeth_irq_tasklet(unsigned long data) | ||
506 | { | ||
507 | struct qeth_card *card; | ||
508 | struct qeth_channel *channel; | ||
509 | struct qeth_cmd_buffer *iob; | ||
510 | __u8 index; | ||
511 | |||
512 | QETH_DBF_TEXT(trace,5,"irqtlet"); | ||
513 | channel = (struct qeth_channel *) data; | ||
514 | iob = channel->iob; | ||
515 | index = channel->buf_no; | ||
516 | card = CARD_FROM_CDEV(channel->ccwdev); | ||
517 | while (iob[index].state == BUF_STATE_PROCESSED) { | ||
518 | if (iob[index].callback !=NULL) { | ||
519 | iob[index].callback(channel,iob + index); | ||
520 | } | ||
521 | index = (index + 1) % QETH_CMD_BUFFER_NO; | ||
522 | } | ||
523 | channel->buf_no = index; | ||
524 | wake_up(&card->wait_q); | ||
525 | } | ||
526 | |||
527 | static int qeth_stop_card(struct qeth_card *, int); | ||
528 | |||
529 | static int | ||
530 | __qeth_set_offline(struct ccwgroup_device *cgdev, int recovery_mode) | ||
531 | { | ||
532 | struct qeth_card *card = (struct qeth_card *) cgdev->dev.driver_data; | ||
533 | int rc = 0, rc2 = 0, rc3 = 0; | ||
534 | enum qeth_card_states recover_flag; | ||
535 | |||
536 | QETH_DBF_TEXT(setup, 3, "setoffl"); | ||
537 | QETH_DBF_HEX(setup, 3, &card, sizeof(void *)); | ||
538 | |||
539 | if (card->dev && netif_carrier_ok(card->dev)) | ||
540 | netif_carrier_off(card->dev); | ||
541 | recover_flag = card->state; | ||
542 | if (qeth_stop_card(card, recovery_mode) == -ERESTARTSYS){ | ||
543 | PRINT_WARN("Stopping card %s interrupted by user!\n", | ||
544 | CARD_BUS_ID(card)); | ||
545 | return -ERESTARTSYS; | ||
546 | } | ||
547 | rc = ccw_device_set_offline(CARD_DDEV(card)); | ||
548 | rc2 = ccw_device_set_offline(CARD_WDEV(card)); | ||
549 | rc3 = ccw_device_set_offline(CARD_RDEV(card)); | ||
550 | if (!rc) | ||
551 | rc = (rc2) ? rc2 : rc3; | ||
552 | if (rc) | ||
553 | QETH_DBF_TEXT_(setup, 2, "1err%d", rc); | ||
554 | if (recover_flag == CARD_STATE_UP) | ||
555 | card->state = CARD_STATE_RECOVER; | ||
556 | qeth_notify_processes(); | ||
557 | return 0; | ||
558 | } | ||
559 | |||
560 | static int | ||
561 | qeth_set_offline(struct ccwgroup_device *cgdev) | ||
562 | { | ||
563 | return __qeth_set_offline(cgdev, 0); | ||
564 | } | ||
565 | |||
566 | static int | ||
567 | qeth_threads_running(struct qeth_card *card, unsigned long threads); | ||
568 | |||
569 | |||
570 | static void | ||
571 | qeth_remove_device(struct ccwgroup_device *cgdev) | ||
572 | { | ||
573 | struct qeth_card *card = (struct qeth_card *) cgdev->dev.driver_data; | ||
574 | unsigned long flags; | ||
575 | |||
576 | QETH_DBF_TEXT(setup, 3, "rmdev"); | ||
577 | QETH_DBF_HEX(setup, 3, &card, sizeof(void *)); | ||
578 | |||
579 | if (!card) | ||
580 | return; | ||
581 | |||
582 | wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); | ||
583 | |||
584 | if (cgdev->state == CCWGROUP_ONLINE){ | ||
585 | card->use_hard_stop = 1; | ||
586 | qeth_set_offline(cgdev); | ||
587 | } | ||
588 | /* remove form our internal list */ | ||
589 | write_lock_irqsave(&qeth_card_list.rwlock, flags); | ||
590 | list_del(&card->list); | ||
591 | write_unlock_irqrestore(&qeth_card_list.rwlock, flags); | ||
592 | if (card->dev) | ||
593 | unregister_netdev(card->dev); | ||
594 | qeth_remove_device_attributes(&cgdev->dev); | ||
595 | qeth_free_card(card); | ||
596 | cgdev->dev.driver_data = NULL; | ||
597 | put_device(&cgdev->dev); | ||
598 | } | ||
599 | |||
600 | static int | ||
601 | qeth_register_addr_entry(struct qeth_card *, struct qeth_ipaddr *); | ||
602 | static int | ||
603 | qeth_deregister_addr_entry(struct qeth_card *, struct qeth_ipaddr *); | ||
604 | |||
605 | /** | ||
606 | * Add/remove address to/from card's ip list, i.e. try to add or remove | ||
607 | * reference to/from an IP address that is already registered on the card. | ||
608 | * Returns: | ||
609 | * 0 address was on card and its reference count has been adjusted, | ||
610 | * but is still > 0, so nothing has to be done | ||
611 | * also returns 0 if card was not on card and the todo was to delete | ||
612 | * the address -> there is also nothing to be done | ||
613 | * 1 address was not on card and the todo is to add it to the card's ip | ||
614 | * list | ||
615 | * -1 address was on card and its reference count has been decremented | ||
616 | * to <= 0 by the todo -> address must be removed from card | ||
617 | */ | ||
618 | static int | ||
619 | __qeth_ref_ip_on_card(struct qeth_card *card, struct qeth_ipaddr *todo, | ||
620 | struct qeth_ipaddr **__addr) | ||
621 | { | ||
622 | struct qeth_ipaddr *addr; | ||
623 | int found = 0; | ||
624 | |||
625 | list_for_each_entry(addr, &card->ip_list, entry) { | ||
626 | if (card->options.layer2) { | ||
627 | if ((addr->type == todo->type) && | ||
628 | (memcmp(&addr->mac, &todo->mac, | ||
629 | OSA_ADDR_LEN) == 0)) { | ||
630 | found = 1; | ||
631 | break; | ||
632 | } | ||
633 | continue; | ||
634 | } | ||
635 | if ((addr->proto == QETH_PROT_IPV4) && | ||
636 | (todo->proto == QETH_PROT_IPV4) && | ||
637 | (addr->type == todo->type) && | ||
638 | (addr->u.a4.addr == todo->u.a4.addr) && | ||
639 | (addr->u.a4.mask == todo->u.a4.mask)) { | ||
640 | found = 1; | ||
641 | break; | ||
642 | } | ||
643 | if ((addr->proto == QETH_PROT_IPV6) && | ||
644 | (todo->proto == QETH_PROT_IPV6) && | ||
645 | (addr->type == todo->type) && | ||
646 | (addr->u.a6.pfxlen == todo->u.a6.pfxlen) && | ||
647 | (memcmp(&addr->u.a6.addr, &todo->u.a6.addr, | ||
648 | sizeof(struct in6_addr)) == 0)) { | ||
649 | found = 1; | ||
650 | break; | ||
651 | } | ||
652 | } | ||
653 | if (found) { | ||
654 | addr->users += todo->users; | ||
655 | if (addr->users <= 0){ | ||
656 | *__addr = addr; | ||
657 | return -1; | ||
658 | } else { | ||
659 | /* for VIPA and RXIP limit refcount to 1 */ | ||
660 | if (addr->type != QETH_IP_TYPE_NORMAL) | ||
661 | addr->users = 1; | ||
662 | return 0; | ||
663 | } | ||
664 | } | ||
665 | if (todo->users > 0) { | ||
666 | /* for VIPA and RXIP limit refcount to 1 */ | ||
667 | if (todo->type != QETH_IP_TYPE_NORMAL) | ||
668 | todo->users = 1; | ||
669 | return 1; | ||
670 | } else | ||
671 | return 0; | ||
672 | } | ||
673 | |||
674 | static int | ||
675 | __qeth_address_exists_in_list(struct list_head *list, struct qeth_ipaddr *addr, | ||
676 | int same_type) | ||
677 | { | ||
678 | struct qeth_ipaddr *tmp; | ||
679 | |||
680 | list_for_each_entry(tmp, list, entry) { | ||
681 | if ((tmp->proto == QETH_PROT_IPV4) && | ||
682 | (addr->proto == QETH_PROT_IPV4) && | ||
683 | ((same_type && (tmp->type == addr->type)) || | ||
684 | (!same_type && (tmp->type != addr->type)) ) && | ||
685 | (tmp->u.a4.addr == addr->u.a4.addr) ){ | ||
686 | return 1; | ||
687 | } | ||
688 | if ((tmp->proto == QETH_PROT_IPV6) && | ||
689 | (addr->proto == QETH_PROT_IPV6) && | ||
690 | ((same_type && (tmp->type == addr->type)) || | ||
691 | (!same_type && (tmp->type != addr->type)) ) && | ||
692 | (memcmp(&tmp->u.a6.addr, &addr->u.a6.addr, | ||
693 | sizeof(struct in6_addr)) == 0) ) { | ||
694 | return 1; | ||
695 | } | ||
696 | } | ||
697 | return 0; | ||
698 | } | ||
699 | |||
700 | /* | ||
701 | * Add IP to be added to todo list. If there is already an "add todo" | ||
702 | * in this list we just incremenent the reference count. | ||
703 | * Returns 0 if we just incremented reference count. | ||
704 | */ | ||
705 | static int | ||
706 | __qeth_insert_ip_todo(struct qeth_card *card, struct qeth_ipaddr *addr, int add) | ||
707 | { | ||
708 | struct qeth_ipaddr *tmp, *t; | ||
709 | int found = 0; | ||
710 | |||
711 | list_for_each_entry_safe(tmp, t, card->ip_tbd_list, entry) { | ||
712 | if ((addr->type == QETH_IP_TYPE_DEL_ALL_MC) && | ||
713 | (tmp->type == QETH_IP_TYPE_DEL_ALL_MC)) | ||
714 | return 0; | ||
715 | if (card->options.layer2) { | ||
716 | if ((tmp->type == addr->type) && | ||
717 | (tmp->is_multicast == addr->is_multicast) && | ||
718 | (memcmp(&tmp->mac, &addr->mac, | ||
719 | OSA_ADDR_LEN) == 0)) { | ||
720 | found = 1; | ||
721 | break; | ||
722 | } | ||
723 | continue; | ||
724 | } | ||
725 | if ((tmp->proto == QETH_PROT_IPV4) && | ||
726 | (addr->proto == QETH_PROT_IPV4) && | ||
727 | (tmp->type == addr->type) && | ||
728 | (tmp->is_multicast == addr->is_multicast) && | ||
729 | (tmp->u.a4.addr == addr->u.a4.addr) && | ||
730 | (tmp->u.a4.mask == addr->u.a4.mask)) { | ||
731 | found = 1; | ||
732 | break; | ||
733 | } | ||
734 | if ((tmp->proto == QETH_PROT_IPV6) && | ||
735 | (addr->proto == QETH_PROT_IPV6) && | ||
736 | (tmp->type == addr->type) && | ||
737 | (tmp->is_multicast == addr->is_multicast) && | ||
738 | (tmp->u.a6.pfxlen == addr->u.a6.pfxlen) && | ||
739 | (memcmp(&tmp->u.a6.addr, &addr->u.a6.addr, | ||
740 | sizeof(struct in6_addr)) == 0)) { | ||
741 | found = 1; | ||
742 | break; | ||
743 | } | ||
744 | } | ||
745 | if (found){ | ||
746 | if (addr->users != 0) | ||
747 | tmp->users += addr->users; | ||
748 | else | ||
749 | tmp->users += add? 1:-1; | ||
750 | if (tmp->users == 0) { | ||
751 | list_del(&tmp->entry); | ||
752 | kfree(tmp); | ||
753 | } | ||
754 | return 0; | ||
755 | } else { | ||
756 | if (addr->type == QETH_IP_TYPE_DEL_ALL_MC) | ||
757 | list_add(&addr->entry, card->ip_tbd_list); | ||
758 | else { | ||
759 | if (addr->users == 0) | ||
760 | addr->users += add? 1:-1; | ||
761 | if (add && (addr->type == QETH_IP_TYPE_NORMAL) && | ||
762 | qeth_is_addr_covered_by_ipato(card, addr)){ | ||
763 | QETH_DBF_TEXT(trace, 2, "tkovaddr"); | ||
764 | addr->set_flags |= QETH_IPA_SETIP_TAKEOVER_FLAG; | ||
765 | } | ||
766 | list_add_tail(&addr->entry, card->ip_tbd_list); | ||
767 | } | ||
768 | return 1; | ||
769 | } | ||
770 | } | ||
771 | |||
772 | /** | ||
773 | * Remove IP address from list | ||
774 | */ | ||
775 | static int | ||
776 | qeth_delete_ip(struct qeth_card *card, struct qeth_ipaddr *addr) | ||
777 | { | ||
778 | unsigned long flags; | ||
779 | int rc = 0; | ||
780 | |||
781 | QETH_DBF_TEXT(trace, 4, "delip"); | ||
782 | |||
783 | if (card->options.layer2) | ||
784 | QETH_DBF_HEX(trace, 4, &addr->mac, 6); | ||
785 | else if (addr->proto == QETH_PROT_IPV4) | ||
786 | QETH_DBF_HEX(trace, 4, &addr->u.a4.addr, 4); | ||
787 | else { | ||
788 | QETH_DBF_HEX(trace, 4, &addr->u.a6.addr, 8); | ||
789 | QETH_DBF_HEX(trace, 4, ((char *)&addr->u.a6.addr) + 8, 8); | ||
790 | } | ||
791 | spin_lock_irqsave(&card->ip_lock, flags); | ||
792 | rc = __qeth_insert_ip_todo(card, addr, 0); | ||
793 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
794 | return rc; | ||
795 | } | ||
796 | |||
797 | static int | ||
798 | qeth_add_ip(struct qeth_card *card, struct qeth_ipaddr *addr) | ||
799 | { | ||
800 | unsigned long flags; | ||
801 | int rc = 0; | ||
802 | |||
803 | QETH_DBF_TEXT(trace, 4, "addip"); | ||
804 | if (card->options.layer2) | ||
805 | QETH_DBF_HEX(trace, 4, &addr->mac, 6); | ||
806 | else if (addr->proto == QETH_PROT_IPV4) | ||
807 | QETH_DBF_HEX(trace, 4, &addr->u.a4.addr, 4); | ||
808 | else { | ||
809 | QETH_DBF_HEX(trace, 4, &addr->u.a6.addr, 8); | ||
810 | QETH_DBF_HEX(trace, 4, ((char *)&addr->u.a6.addr) + 8, 8); | ||
811 | } | ||
812 | spin_lock_irqsave(&card->ip_lock, flags); | ||
813 | rc = __qeth_insert_ip_todo(card, addr, 1); | ||
814 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
815 | return rc; | ||
816 | } | ||
817 | |||
818 | static void | ||
819 | __qeth_delete_all_mc(struct qeth_card *card, unsigned long *flags) | ||
820 | { | ||
821 | struct qeth_ipaddr *addr, *tmp; | ||
822 | int rc; | ||
823 | again: | ||
824 | list_for_each_entry_safe(addr, tmp, &card->ip_list, entry) { | ||
825 | if (addr->is_multicast) { | ||
826 | list_del(&addr->entry); | ||
827 | spin_unlock_irqrestore(&card->ip_lock, *flags); | ||
828 | rc = qeth_deregister_addr_entry(card, addr); | ||
829 | spin_lock_irqsave(&card->ip_lock, *flags); | ||
830 | if (!rc) { | ||
831 | kfree(addr); | ||
832 | goto again; | ||
833 | } else | ||
834 | list_add(&addr->entry, &card->ip_list); | ||
835 | } | ||
836 | } | ||
837 | } | ||
838 | |||
839 | static void | ||
840 | qeth_set_ip_addr_list(struct qeth_card *card) | ||
841 | { | ||
842 | struct list_head *tbd_list; | ||
843 | struct qeth_ipaddr *todo, *addr; | ||
844 | unsigned long flags; | ||
845 | int rc; | ||
846 | |||
847 | QETH_DBF_TEXT(trace, 2, "sdiplist"); | ||
848 | QETH_DBF_HEX(trace, 2, &card, sizeof(void *)); | ||
849 | |||
850 | spin_lock_irqsave(&card->ip_lock, flags); | ||
851 | tbd_list = card->ip_tbd_list; | ||
852 | card->ip_tbd_list = kmalloc(sizeof(struct list_head), GFP_ATOMIC); | ||
853 | if (!card->ip_tbd_list) { | ||
854 | QETH_DBF_TEXT(trace, 0, "silnomem"); | ||
855 | card->ip_tbd_list = tbd_list; | ||
856 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
857 | return; | ||
858 | } else | ||
859 | INIT_LIST_HEAD(card->ip_tbd_list); | ||
860 | |||
861 | while (!list_empty(tbd_list)){ | ||
862 | todo = list_entry(tbd_list->next, struct qeth_ipaddr, entry); | ||
863 | list_del(&todo->entry); | ||
864 | if (todo->type == QETH_IP_TYPE_DEL_ALL_MC){ | ||
865 | __qeth_delete_all_mc(card, &flags); | ||
866 | kfree(todo); | ||
867 | continue; | ||
868 | } | ||
869 | rc = __qeth_ref_ip_on_card(card, todo, &addr); | ||
870 | if (rc == 0) { | ||
871 | /* nothing to be done; only adjusted refcount */ | ||
872 | kfree(todo); | ||
873 | } else if (rc == 1) { | ||
874 | /* new entry to be added to on-card list */ | ||
875 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
876 | rc = qeth_register_addr_entry(card, todo); | ||
877 | spin_lock_irqsave(&card->ip_lock, flags); | ||
878 | if (!rc) | ||
879 | list_add_tail(&todo->entry, &card->ip_list); | ||
880 | else | ||
881 | kfree(todo); | ||
882 | } else if (rc == -1) { | ||
883 | /* on-card entry to be removed */ | ||
884 | list_del_init(&addr->entry); | ||
885 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
886 | rc = qeth_deregister_addr_entry(card, addr); | ||
887 | spin_lock_irqsave(&card->ip_lock, flags); | ||
888 | if (!rc) | ||
889 | kfree(addr); | ||
890 | else | ||
891 | list_add_tail(&addr->entry, &card->ip_list); | ||
892 | kfree(todo); | ||
893 | } | ||
894 | } | ||
895 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
896 | kfree(tbd_list); | ||
897 | } | ||
898 | |||
899 | static void qeth_delete_mc_addresses(struct qeth_card *); | ||
900 | static void qeth_add_multicast_ipv4(struct qeth_card *); | ||
901 | static void qeth_layer2_add_multicast(struct qeth_card *); | ||
902 | #ifdef CONFIG_QETH_IPV6 | ||
903 | static void qeth_add_multicast_ipv6(struct qeth_card *); | ||
904 | #endif | ||
905 | |||
906 | static int | ||
907 | qeth_set_thread_start_bit(struct qeth_card *card, unsigned long thread) | ||
908 | { | ||
909 | unsigned long flags; | ||
910 | |||
911 | spin_lock_irqsave(&card->thread_mask_lock, flags); | ||
912 | if ( !(card->thread_allowed_mask & thread) || | ||
913 | (card->thread_start_mask & thread) ) { | ||
914 | spin_unlock_irqrestore(&card->thread_mask_lock, flags); | ||
915 | return -EPERM; | ||
916 | } | ||
917 | card->thread_start_mask |= thread; | ||
918 | spin_unlock_irqrestore(&card->thread_mask_lock, flags); | ||
919 | return 0; | ||
920 | } | ||
921 | |||
922 | static void | ||
923 | qeth_clear_thread_start_bit(struct qeth_card *card, unsigned long thread) | ||
924 | { | ||
925 | unsigned long flags; | ||
926 | |||
927 | spin_lock_irqsave(&card->thread_mask_lock, flags); | ||
928 | card->thread_start_mask &= ~thread; | ||
929 | spin_unlock_irqrestore(&card->thread_mask_lock, flags); | ||
930 | wake_up(&card->wait_q); | ||
931 | } | ||
932 | |||
933 | static void | ||
934 | qeth_clear_thread_running_bit(struct qeth_card *card, unsigned long thread) | ||
935 | { | ||
936 | unsigned long flags; | ||
937 | |||
938 | spin_lock_irqsave(&card->thread_mask_lock, flags); | ||
939 | card->thread_running_mask &= ~thread; | ||
940 | spin_unlock_irqrestore(&card->thread_mask_lock, flags); | ||
941 | wake_up(&card->wait_q); | ||
942 | } | ||
943 | |||
944 | static int | ||
945 | __qeth_do_run_thread(struct qeth_card *card, unsigned long thread) | ||
946 | { | ||
947 | unsigned long flags; | ||
948 | int rc = 0; | ||
949 | |||
950 | spin_lock_irqsave(&card->thread_mask_lock, flags); | ||
951 | if (card->thread_start_mask & thread){ | ||
952 | if ((card->thread_allowed_mask & thread) && | ||
953 | !(card->thread_running_mask & thread)){ | ||
954 | rc = 1; | ||
955 | card->thread_start_mask &= ~thread; | ||
956 | card->thread_running_mask |= thread; | ||
957 | } else | ||
958 | rc = -EPERM; | ||
959 | } | ||
960 | spin_unlock_irqrestore(&card->thread_mask_lock, flags); | ||
961 | return rc; | ||
962 | } | ||
963 | |||
964 | static int | ||
965 | qeth_do_run_thread(struct qeth_card *card, unsigned long thread) | ||
966 | { | ||
967 | int rc = 0; | ||
968 | |||
969 | wait_event(card->wait_q, | ||
970 | (rc = __qeth_do_run_thread(card, thread)) >= 0); | ||
971 | return rc; | ||
972 | } | ||
973 | |||
974 | static int | ||
975 | qeth_recover(void *ptr) | ||
976 | { | ||
977 | struct qeth_card *card; | ||
978 | int rc = 0; | ||
979 | |||
980 | card = (struct qeth_card *) ptr; | ||
981 | daemonize("qeth_recover"); | ||
982 | QETH_DBF_TEXT(trace,2,"recover1"); | ||
983 | QETH_DBF_HEX(trace, 2, &card, sizeof(void *)); | ||
984 | if (!qeth_do_run_thread(card, QETH_RECOVER_THREAD)) | ||
985 | return 0; | ||
986 | QETH_DBF_TEXT(trace,2,"recover2"); | ||
987 | PRINT_WARN("Recovery of device %s started ...\n", | ||
988 | CARD_BUS_ID(card)); | ||
989 | card->use_hard_stop = 1; | ||
990 | __qeth_set_offline(card->gdev,1); | ||
991 | rc = __qeth_set_online(card->gdev,1); | ||
992 | /* don't run another scheduled recovery */ | ||
993 | qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD); | ||
994 | qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD); | ||
995 | if (!rc) | ||
996 | PRINT_INFO("Device %s successfully recovered!\n", | ||
997 | CARD_BUS_ID(card)); | ||
998 | else | ||
999 | PRINT_INFO("Device %s could not be recovered!\n", | ||
1000 | CARD_BUS_ID(card)); | ||
1001 | return 0; | ||
1002 | } | ||
1003 | |||
1004 | void | ||
1005 | qeth_schedule_recovery(struct qeth_card *card) | ||
1006 | { | ||
1007 | QETH_DBF_TEXT(trace,2,"startrec"); | ||
1008 | if (qeth_set_thread_start_bit(card, QETH_RECOVER_THREAD) == 0) | ||
1009 | schedule_work(&card->kernel_thread_starter); | ||
1010 | } | ||
1011 | |||
1012 | static int | ||
1013 | qeth_do_start_thread(struct qeth_card *card, unsigned long thread) | ||
1014 | { | ||
1015 | unsigned long flags; | ||
1016 | int rc = 0; | ||
1017 | |||
1018 | spin_lock_irqsave(&card->thread_mask_lock, flags); | ||
1019 | QETH_DBF_TEXT_(trace, 4, " %02x%02x%02x", | ||
1020 | (u8) card->thread_start_mask, | ||
1021 | (u8) card->thread_allowed_mask, | ||
1022 | (u8) card->thread_running_mask); | ||
1023 | rc = (card->thread_start_mask & thread); | ||
1024 | spin_unlock_irqrestore(&card->thread_mask_lock, flags); | ||
1025 | return rc; | ||
1026 | } | ||
1027 | |||
1028 | static void | ||
1029 | qeth_start_kernel_thread(struct work_struct *work) | ||
1030 | { | ||
1031 | struct qeth_card *card = container_of(work, struct qeth_card, kernel_thread_starter); | ||
1032 | QETH_DBF_TEXT(trace , 2, "strthrd"); | ||
1033 | |||
1034 | if (card->read.state != CH_STATE_UP && | ||
1035 | card->write.state != CH_STATE_UP) | ||
1036 | return; | ||
1037 | if (qeth_do_start_thread(card, QETH_RECOVER_THREAD)) | ||
1038 | kernel_thread(qeth_recover, (void *) card, SIGCHLD); | ||
1039 | } | ||
1040 | |||
1041 | |||
1042 | static void | ||
1043 | qeth_set_intial_options(struct qeth_card *card) | ||
1044 | { | ||
1045 | card->options.route4.type = NO_ROUTER; | ||
1046 | #ifdef CONFIG_QETH_IPV6 | ||
1047 | card->options.route6.type = NO_ROUTER; | ||
1048 | #endif /* QETH_IPV6 */ | ||
1049 | card->options.checksum_type = QETH_CHECKSUM_DEFAULT; | ||
1050 | card->options.broadcast_mode = QETH_TR_BROADCAST_ALLRINGS; | ||
1051 | card->options.macaddr_mode = QETH_TR_MACADDR_NONCANONICAL; | ||
1052 | card->options.fake_broadcast = 0; | ||
1053 | card->options.add_hhlen = DEFAULT_ADD_HHLEN; | ||
1054 | card->options.fake_ll = 0; | ||
1055 | if (card->info.type == QETH_CARD_TYPE_OSN) | ||
1056 | card->options.layer2 = 1; | ||
1057 | else | ||
1058 | card->options.layer2 = 0; | ||
1059 | card->options.performance_stats = 0; | ||
1060 | card->options.rx_sg_cb = QETH_RX_SG_CB; | ||
1061 | } | ||
1062 | |||
1063 | /** | ||
1064 | * initialize channels ,card and all state machines | ||
1065 | */ | ||
1066 | static int | ||
1067 | qeth_setup_card(struct qeth_card *card) | ||
1068 | { | ||
1069 | |||
1070 | QETH_DBF_TEXT(setup, 2, "setupcrd"); | ||
1071 | QETH_DBF_HEX(setup, 2, &card, sizeof(void *)); | ||
1072 | |||
1073 | card->read.state = CH_STATE_DOWN; | ||
1074 | card->write.state = CH_STATE_DOWN; | ||
1075 | card->data.state = CH_STATE_DOWN; | ||
1076 | card->state = CARD_STATE_DOWN; | ||
1077 | card->lan_online = 0; | ||
1078 | card->use_hard_stop = 0; | ||
1079 | card->dev = NULL; | ||
1080 | #ifdef CONFIG_QETH_VLAN | ||
1081 | spin_lock_init(&card->vlanlock); | ||
1082 | card->vlangrp = NULL; | ||
1083 | #endif | ||
1084 | spin_lock_init(&card->lock); | ||
1085 | spin_lock_init(&card->ip_lock); | ||
1086 | spin_lock_init(&card->thread_mask_lock); | ||
1087 | card->thread_start_mask = 0; | ||
1088 | card->thread_allowed_mask = 0; | ||
1089 | card->thread_running_mask = 0; | ||
1090 | INIT_WORK(&card->kernel_thread_starter, qeth_start_kernel_thread); | ||
1091 | INIT_LIST_HEAD(&card->ip_list); | ||
1092 | card->ip_tbd_list = kmalloc(sizeof(struct list_head), GFP_KERNEL); | ||
1093 | if (!card->ip_tbd_list) { | ||
1094 | QETH_DBF_TEXT(setup, 0, "iptbdnom"); | ||
1095 | return -ENOMEM; | ||
1096 | } | ||
1097 | INIT_LIST_HEAD(card->ip_tbd_list); | ||
1098 | INIT_LIST_HEAD(&card->cmd_waiter_list); | ||
1099 | init_waitqueue_head(&card->wait_q); | ||
1100 | /* intial options */ | ||
1101 | qeth_set_intial_options(card); | ||
1102 | /* IP address takeover */ | ||
1103 | INIT_LIST_HEAD(&card->ipato.entries); | ||
1104 | card->ipato.enabled = 0; | ||
1105 | card->ipato.invert4 = 0; | ||
1106 | card->ipato.invert6 = 0; | ||
1107 | /* init QDIO stuff */ | ||
1108 | qeth_init_qdio_info(card); | ||
1109 | return 0; | ||
1110 | } | ||
1111 | |||
1112 | static int | ||
1113 | is_1920_device (struct qeth_card *card) | ||
1114 | { | ||
1115 | int single_queue = 0; | ||
1116 | struct ccw_device *ccwdev; | ||
1117 | struct channelPath_dsc { | ||
1118 | u8 flags; | ||
1119 | u8 lsn; | ||
1120 | u8 desc; | ||
1121 | u8 chpid; | ||
1122 | u8 swla; | ||
1123 | u8 zeroes; | ||
1124 | u8 chla; | ||
1125 | u8 chpp; | ||
1126 | } *chp_dsc; | ||
1127 | |||
1128 | QETH_DBF_TEXT(setup, 2, "chk_1920"); | ||
1129 | |||
1130 | ccwdev = card->data.ccwdev; | ||
1131 | chp_dsc = (struct channelPath_dsc *)ccw_device_get_chp_desc(ccwdev, 0); | ||
1132 | if (chp_dsc != NULL) { | ||
1133 | /* CHPP field bit 6 == 1 -> single queue */ | ||
1134 | single_queue = ((chp_dsc->chpp & 0x02) == 0x02); | ||
1135 | kfree(chp_dsc); | ||
1136 | } | ||
1137 | QETH_DBF_TEXT_(setup, 2, "rc:%x", single_queue); | ||
1138 | return single_queue; | ||
1139 | } | ||
1140 | |||
1141 | static int | ||
1142 | qeth_determine_card_type(struct qeth_card *card) | ||
1143 | { | ||
1144 | int i = 0; | ||
1145 | |||
1146 | QETH_DBF_TEXT(setup, 2, "detcdtyp"); | ||
1147 | |||
1148 | card->qdio.do_prio_queueing = QETH_PRIOQ_DEFAULT; | ||
1149 | card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; | ||
1150 | while (known_devices[i][4]) { | ||
1151 | if ((CARD_RDEV(card)->id.dev_type == known_devices[i][2]) && | ||
1152 | (CARD_RDEV(card)->id.dev_model == known_devices[i][3])) { | ||
1153 | card->info.type = known_devices[i][4]; | ||
1154 | card->qdio.no_out_queues = known_devices[i][8]; | ||
1155 | card->info.is_multicast_different = known_devices[i][9]; | ||
1156 | if (is_1920_device(card)) { | ||
1157 | PRINT_INFO("Priority Queueing not able " | ||
1158 | "due to hardware limitations!\n"); | ||
1159 | card->qdio.no_out_queues = 1; | ||
1160 | card->qdio.default_out_queue = 0; | ||
1161 | } | ||
1162 | return 0; | ||
1163 | } | ||
1164 | i++; | ||
1165 | } | ||
1166 | card->info.type = QETH_CARD_TYPE_UNKNOWN; | ||
1167 | PRINT_ERR("unknown card type on device %s\n", CARD_BUS_ID(card)); | ||
1168 | return -ENOENT; | ||
1169 | } | ||
1170 | |||
1171 | static int | ||
1172 | qeth_probe_device(struct ccwgroup_device *gdev) | ||
1173 | { | ||
1174 | struct qeth_card *card; | ||
1175 | struct device *dev; | ||
1176 | unsigned long flags; | ||
1177 | int rc; | ||
1178 | |||
1179 | QETH_DBF_TEXT(setup, 2, "probedev"); | ||
1180 | |||
1181 | dev = &gdev->dev; | ||
1182 | if (!get_device(dev)) | ||
1183 | return -ENODEV; | ||
1184 | |||
1185 | QETH_DBF_TEXT_(setup, 2, "%s", gdev->dev.bus_id); | ||
1186 | |||
1187 | card = qeth_alloc_card(); | ||
1188 | if (!card) { | ||
1189 | put_device(dev); | ||
1190 | QETH_DBF_TEXT_(setup, 2, "1err%d", -ENOMEM); | ||
1191 | return -ENOMEM; | ||
1192 | } | ||
1193 | card->read.ccwdev = gdev->cdev[0]; | ||
1194 | card->write.ccwdev = gdev->cdev[1]; | ||
1195 | card->data.ccwdev = gdev->cdev[2]; | ||
1196 | gdev->dev.driver_data = card; | ||
1197 | card->gdev = gdev; | ||
1198 | gdev->cdev[0]->handler = qeth_irq; | ||
1199 | gdev->cdev[1]->handler = qeth_irq; | ||
1200 | gdev->cdev[2]->handler = qeth_irq; | ||
1201 | |||
1202 | if ((rc = qeth_determine_card_type(card))){ | ||
1203 | PRINT_WARN("%s: not a valid card type\n", __func__); | ||
1204 | QETH_DBF_TEXT_(setup, 2, "3err%d", rc); | ||
1205 | put_device(dev); | ||
1206 | qeth_free_card(card); | ||
1207 | return rc; | ||
1208 | } | ||
1209 | if ((rc = qeth_setup_card(card))){ | ||
1210 | QETH_DBF_TEXT_(setup, 2, "2err%d", rc); | ||
1211 | put_device(dev); | ||
1212 | qeth_free_card(card); | ||
1213 | return rc; | ||
1214 | } | ||
1215 | rc = qeth_create_device_attributes(dev); | ||
1216 | if (rc) { | ||
1217 | put_device(dev); | ||
1218 | qeth_free_card(card); | ||
1219 | return rc; | ||
1220 | } | ||
1221 | /* insert into our internal list */ | ||
1222 | write_lock_irqsave(&qeth_card_list.rwlock, flags); | ||
1223 | list_add_tail(&card->list, &qeth_card_list.list); | ||
1224 | write_unlock_irqrestore(&qeth_card_list.rwlock, flags); | ||
1225 | return rc; | ||
1226 | } | ||
1227 | |||
1228 | |||
1229 | static int qeth_read_conf_data(struct qeth_card *card, void **buffer, | ||
1230 | int *length) | ||
1231 | { | ||
1232 | struct ciw *ciw; | ||
1233 | char *rcd_buf; | ||
1234 | int ret; | ||
1235 | struct qeth_channel *channel = &card->data; | ||
1236 | unsigned long flags; | ||
1237 | |||
1238 | /* | ||
1239 | * scan for RCD command in extended SenseID data | ||
1240 | */ | ||
1241 | ciw = ccw_device_get_ciw(channel->ccwdev, CIW_TYPE_RCD); | ||
1242 | if (!ciw || ciw->cmd == 0) | ||
1243 | return -EOPNOTSUPP; | ||
1244 | rcd_buf = kzalloc(ciw->count, GFP_KERNEL | GFP_DMA); | ||
1245 | if (!rcd_buf) | ||
1246 | return -ENOMEM; | ||
1247 | |||
1248 | channel->ccw.cmd_code = ciw->cmd; | ||
1249 | channel->ccw.cda = (__u32) __pa (rcd_buf); | ||
1250 | channel->ccw.count = ciw->count; | ||
1251 | channel->ccw.flags = CCW_FLAG_SLI; | ||
1252 | channel->state = CH_STATE_RCD; | ||
1253 | spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); | ||
1254 | ret = ccw_device_start_timeout(channel->ccwdev, &channel->ccw, | ||
1255 | QETH_RCD_PARM, LPM_ANYPATH, 0, | ||
1256 | QETH_RCD_TIMEOUT); | ||
1257 | spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags); | ||
1258 | if (!ret) | ||
1259 | wait_event(card->wait_q, | ||
1260 | (channel->state == CH_STATE_RCD_DONE || | ||
1261 | channel->state == CH_STATE_DOWN)); | ||
1262 | if (channel->state == CH_STATE_DOWN) | ||
1263 | ret = -EIO; | ||
1264 | else | ||
1265 | channel->state = CH_STATE_DOWN; | ||
1266 | if (ret) { | ||
1267 | kfree(rcd_buf); | ||
1268 | *buffer = NULL; | ||
1269 | *length = 0; | ||
1270 | } else { | ||
1271 | *length = ciw->count; | ||
1272 | *buffer = rcd_buf; | ||
1273 | } | ||
1274 | return ret; | ||
1275 | } | ||
1276 | |||
1277 | static int | ||
1278 | qeth_get_unitaddr(struct qeth_card *card) | ||
1279 | { | ||
1280 | int length; | ||
1281 | char *prcd; | ||
1282 | int rc; | ||
1283 | |||
1284 | QETH_DBF_TEXT(setup, 2, "getunit"); | ||
1285 | rc = qeth_read_conf_data(card, (void **) &prcd, &length); | ||
1286 | if (rc) { | ||
1287 | PRINT_ERR("qeth_read_conf_data for device %s returned %i\n", | ||
1288 | CARD_DDEV_ID(card), rc); | ||
1289 | return rc; | ||
1290 | } | ||
1291 | card->info.chpid = prcd[30]; | ||
1292 | card->info.unit_addr2 = prcd[31]; | ||
1293 | card->info.cula = prcd[63]; | ||
1294 | card->info.guestlan = ((prcd[0x10] == _ascebc['V']) && | ||
1295 | (prcd[0x11] == _ascebc['M'])); | ||
1296 | kfree(prcd); | ||
1297 | return 0; | ||
1298 | } | ||
1299 | |||
1300 | static void | ||
1301 | qeth_init_tokens(struct qeth_card *card) | ||
1302 | { | ||
1303 | card->token.issuer_rm_w = 0x00010103UL; | ||
1304 | card->token.cm_filter_w = 0x00010108UL; | ||
1305 | card->token.cm_connection_w = 0x0001010aUL; | ||
1306 | card->token.ulp_filter_w = 0x0001010bUL; | ||
1307 | card->token.ulp_connection_w = 0x0001010dUL; | ||
1308 | } | ||
1309 | |||
1310 | static inline __u16 | ||
1311 | raw_devno_from_bus_id(char *id) | ||
1312 | { | ||
1313 | id += (strlen(id) - 4); | ||
1314 | return (__u16) simple_strtoul(id, &id, 16); | ||
1315 | } | ||
1316 | /** | ||
1317 | * setup channel | ||
1318 | */ | ||
1319 | static void | ||
1320 | qeth_setup_ccw(struct qeth_channel *channel,unsigned char *iob, __u32 len) | ||
1321 | { | ||
1322 | struct qeth_card *card; | ||
1323 | |||
1324 | QETH_DBF_TEXT(trace, 4, "setupccw"); | ||
1325 | card = CARD_FROM_CDEV(channel->ccwdev); | ||
1326 | if (channel == &card->read) | ||
1327 | memcpy(&channel->ccw, READ_CCW, sizeof(struct ccw1)); | ||
1328 | else | ||
1329 | memcpy(&channel->ccw, WRITE_CCW, sizeof(struct ccw1)); | ||
1330 | channel->ccw.count = len; | ||
1331 | channel->ccw.cda = (__u32) __pa(iob); | ||
1332 | } | ||
1333 | |||
1334 | /** | ||
1335 | * get free buffer for ccws (IDX activation, lancmds,ipassists...) | ||
1336 | */ | ||
1337 | static struct qeth_cmd_buffer * | ||
1338 | __qeth_get_buffer(struct qeth_channel *channel) | ||
1339 | { | ||
1340 | __u8 index; | ||
1341 | |||
1342 | QETH_DBF_TEXT(trace, 6, "getbuff"); | ||
1343 | index = channel->io_buf_no; | ||
1344 | do { | ||
1345 | if (channel->iob[index].state == BUF_STATE_FREE) { | ||
1346 | channel->iob[index].state = BUF_STATE_LOCKED; | ||
1347 | channel->io_buf_no = (channel->io_buf_no + 1) % | ||
1348 | QETH_CMD_BUFFER_NO; | ||
1349 | memset(channel->iob[index].data, 0, QETH_BUFSIZE); | ||
1350 | return channel->iob + index; | ||
1351 | } | ||
1352 | index = (index + 1) % QETH_CMD_BUFFER_NO; | ||
1353 | } while(index != channel->io_buf_no); | ||
1354 | |||
1355 | return NULL; | ||
1356 | } | ||
1357 | |||
1358 | /** | ||
1359 | * release command buffer | ||
1360 | */ | ||
1361 | static void | ||
1362 | qeth_release_buffer(struct qeth_channel *channel, struct qeth_cmd_buffer *iob) | ||
1363 | { | ||
1364 | unsigned long flags; | ||
1365 | |||
1366 | QETH_DBF_TEXT(trace, 6, "relbuff"); | ||
1367 | spin_lock_irqsave(&channel->iob_lock, flags); | ||
1368 | memset(iob->data, 0, QETH_BUFSIZE); | ||
1369 | iob->state = BUF_STATE_FREE; | ||
1370 | iob->callback = qeth_send_control_data_cb; | ||
1371 | iob->rc = 0; | ||
1372 | spin_unlock_irqrestore(&channel->iob_lock, flags); | ||
1373 | } | ||
1374 | |||
1375 | static struct qeth_cmd_buffer * | ||
1376 | qeth_get_buffer(struct qeth_channel *channel) | ||
1377 | { | ||
1378 | struct qeth_cmd_buffer *buffer = NULL; | ||
1379 | unsigned long flags; | ||
1380 | |||
1381 | spin_lock_irqsave(&channel->iob_lock, flags); | ||
1382 | buffer = __qeth_get_buffer(channel); | ||
1383 | spin_unlock_irqrestore(&channel->iob_lock, flags); | ||
1384 | return buffer; | ||
1385 | } | ||
1386 | |||
1387 | static struct qeth_cmd_buffer * | ||
1388 | qeth_wait_for_buffer(struct qeth_channel *channel) | ||
1389 | { | ||
1390 | struct qeth_cmd_buffer *buffer; | ||
1391 | wait_event(channel->wait_q, | ||
1392 | ((buffer = qeth_get_buffer(channel)) != NULL)); | ||
1393 | return buffer; | ||
1394 | } | ||
1395 | |||
1396 | static void | ||
1397 | qeth_clear_cmd_buffers(struct qeth_channel *channel) | ||
1398 | { | ||
1399 | int cnt; | ||
1400 | |||
1401 | for (cnt=0; cnt < QETH_CMD_BUFFER_NO; cnt++) | ||
1402 | qeth_release_buffer(channel,&channel->iob[cnt]); | ||
1403 | channel->buf_no = 0; | ||
1404 | channel->io_buf_no = 0; | ||
1405 | } | ||
1406 | |||
1407 | /** | ||
1408 | * start IDX for read and write channel | ||
1409 | */ | ||
1410 | static int | ||
1411 | qeth_idx_activate_get_answer(struct qeth_channel *channel, | ||
1412 | void (*idx_reply_cb)(struct qeth_channel *, | ||
1413 | struct qeth_cmd_buffer *)) | ||
1414 | { | ||
1415 | struct qeth_cmd_buffer *iob; | ||
1416 | unsigned long flags; | ||
1417 | int rc; | ||
1418 | struct qeth_card *card; | ||
1419 | |||
1420 | QETH_DBF_TEXT(setup, 2, "idxanswr"); | ||
1421 | card = CARD_FROM_CDEV(channel->ccwdev); | ||
1422 | iob = qeth_get_buffer(channel); | ||
1423 | iob->callback = idx_reply_cb; | ||
1424 | memcpy(&channel->ccw, READ_CCW, sizeof(struct ccw1)); | ||
1425 | channel->ccw.count = QETH_BUFSIZE; | ||
1426 | channel->ccw.cda = (__u32) __pa(iob->data); | ||
1427 | |||
1428 | wait_event(card->wait_q, | ||
1429 | atomic_cmpxchg(&channel->irq_pending, 0, 1) == 0); | ||
1430 | QETH_DBF_TEXT(setup, 6, "noirqpnd"); | ||
1431 | spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); | ||
1432 | rc = ccw_device_start(channel->ccwdev, | ||
1433 | &channel->ccw,(addr_t) iob, 0, 0); | ||
1434 | spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags); | ||
1435 | |||
1436 | if (rc) { | ||
1437 | PRINT_ERR("qeth: Error2 in activating channel rc=%d\n",rc); | ||
1438 | QETH_DBF_TEXT_(setup, 2, "2err%d", rc); | ||
1439 | atomic_set(&channel->irq_pending, 0); | ||
1440 | wake_up(&card->wait_q); | ||
1441 | return rc; | ||
1442 | } | ||
1443 | rc = wait_event_interruptible_timeout(card->wait_q, | ||
1444 | channel->state == CH_STATE_UP, QETH_TIMEOUT); | ||
1445 | if (rc == -ERESTARTSYS) | ||
1446 | return rc; | ||
1447 | if (channel->state != CH_STATE_UP){ | ||
1448 | rc = -ETIME; | ||
1449 | QETH_DBF_TEXT_(setup, 2, "3err%d", rc); | ||
1450 | qeth_clear_cmd_buffers(channel); | ||
1451 | } else | ||
1452 | rc = 0; | ||
1453 | return rc; | ||
1454 | } | ||
1455 | |||
1456 | static int | ||
1457 | qeth_idx_activate_channel(struct qeth_channel *channel, | ||
1458 | void (*idx_reply_cb)(struct qeth_channel *, | ||
1459 | struct qeth_cmd_buffer *)) | ||
1460 | { | ||
1461 | struct qeth_card *card; | ||
1462 | struct qeth_cmd_buffer *iob; | ||
1463 | unsigned long flags; | ||
1464 | __u16 temp; | ||
1465 | int rc; | ||
1466 | |||
1467 | card = CARD_FROM_CDEV(channel->ccwdev); | ||
1468 | |||
1469 | QETH_DBF_TEXT(setup, 2, "idxactch"); | ||
1470 | |||
1471 | iob = qeth_get_buffer(channel); | ||
1472 | iob->callback = idx_reply_cb; | ||
1473 | memcpy(&channel->ccw, WRITE_CCW, sizeof(struct ccw1)); | ||
1474 | channel->ccw.count = IDX_ACTIVATE_SIZE; | ||
1475 | channel->ccw.cda = (__u32) __pa(iob->data); | ||
1476 | if (channel == &card->write) { | ||
1477 | memcpy(iob->data, IDX_ACTIVATE_WRITE, IDX_ACTIVATE_SIZE); | ||
1478 | memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob->data), | ||
1479 | &card->seqno.trans_hdr, QETH_SEQ_NO_LENGTH); | ||
1480 | card->seqno.trans_hdr++; | ||
1481 | } else { | ||
1482 | memcpy(iob->data, IDX_ACTIVATE_READ, IDX_ACTIVATE_SIZE); | ||
1483 | memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob->data), | ||
1484 | &card->seqno.trans_hdr, QETH_SEQ_NO_LENGTH); | ||
1485 | } | ||
1486 | memcpy(QETH_IDX_ACT_ISSUER_RM_TOKEN(iob->data), | ||
1487 | &card->token.issuer_rm_w,QETH_MPC_TOKEN_LENGTH); | ||
1488 | memcpy(QETH_IDX_ACT_FUNC_LEVEL(iob->data), | ||
1489 | &card->info.func_level,sizeof(__u16)); | ||
1490 | temp = raw_devno_from_bus_id(CARD_DDEV_ID(card)); | ||
1491 | memcpy(QETH_IDX_ACT_QDIO_DEV_CUA(iob->data), &temp, 2); | ||
1492 | temp = (card->info.cula << 8) + card->info.unit_addr2; | ||
1493 | memcpy(QETH_IDX_ACT_QDIO_DEV_REALADDR(iob->data), &temp, 2); | ||
1494 | |||
1495 | wait_event(card->wait_q, | ||
1496 | atomic_cmpxchg(&channel->irq_pending, 0, 1) == 0); | ||
1497 | QETH_DBF_TEXT(setup, 6, "noirqpnd"); | ||
1498 | spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); | ||
1499 | rc = ccw_device_start(channel->ccwdev, | ||
1500 | &channel->ccw,(addr_t) iob, 0, 0); | ||
1501 | spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags); | ||
1502 | |||
1503 | if (rc) { | ||
1504 | PRINT_ERR("qeth: Error1 in activating channel. rc=%d\n",rc); | ||
1505 | QETH_DBF_TEXT_(setup, 2, "1err%d", rc); | ||
1506 | atomic_set(&channel->irq_pending, 0); | ||
1507 | wake_up(&card->wait_q); | ||
1508 | return rc; | ||
1509 | } | ||
1510 | rc = wait_event_interruptible_timeout(card->wait_q, | ||
1511 | channel->state == CH_STATE_ACTIVATING, QETH_TIMEOUT); | ||
1512 | if (rc == -ERESTARTSYS) | ||
1513 | return rc; | ||
1514 | if (channel->state != CH_STATE_ACTIVATING) { | ||
1515 | PRINT_WARN("qeth: IDX activate timed out!\n"); | ||
1516 | QETH_DBF_TEXT_(setup, 2, "2err%d", -ETIME); | ||
1517 | qeth_clear_cmd_buffers(channel); | ||
1518 | return -ETIME; | ||
1519 | } | ||
1520 | return qeth_idx_activate_get_answer(channel,idx_reply_cb); | ||
1521 | } | ||
1522 | |||
1523 | static int | ||
1524 | qeth_peer_func_level(int level) | ||
1525 | { | ||
1526 | if ((level & 0xff) == 8) | ||
1527 | return (level & 0xff) + 0x400; | ||
1528 | if (((level >> 8) & 3) == 1) | ||
1529 | return (level & 0xff) + 0x200; | ||
1530 | return level; | ||
1531 | } | ||
1532 | |||
1533 | static void | ||
1534 | qeth_idx_write_cb(struct qeth_channel *channel, struct qeth_cmd_buffer *iob) | ||
1535 | { | ||
1536 | struct qeth_card *card; | ||
1537 | __u16 temp; | ||
1538 | |||
1539 | QETH_DBF_TEXT(setup ,2, "idxwrcb"); | ||
1540 | |||
1541 | if (channel->state == CH_STATE_DOWN) { | ||
1542 | channel->state = CH_STATE_ACTIVATING; | ||
1543 | goto out; | ||
1544 | } | ||
1545 | card = CARD_FROM_CDEV(channel->ccwdev); | ||
1546 | |||
1547 | if (!(QETH_IS_IDX_ACT_POS_REPLY(iob->data))) { | ||
1548 | if (QETH_IDX_ACT_CAUSE_CODE(iob->data) == 0x19) | ||
1549 | PRINT_ERR("IDX_ACTIVATE on write channel device %s: " | ||
1550 | "adapter exclusively used by another host\n", | ||
1551 | CARD_WDEV_ID(card)); | ||
1552 | else | ||
1553 | PRINT_ERR("IDX_ACTIVATE on write channel device %s: " | ||
1554 | "negative reply\n", CARD_WDEV_ID(card)); | ||
1555 | goto out; | ||
1556 | } | ||
1557 | memcpy(&temp, QETH_IDX_ACT_FUNC_LEVEL(iob->data), 2); | ||
1558 | if ((temp & ~0x0100) != qeth_peer_func_level(card->info.func_level)) { | ||
1559 | PRINT_WARN("IDX_ACTIVATE on write channel device %s: " | ||
1560 | "function level mismatch " | ||
1561 | "(sent: 0x%x, received: 0x%x)\n", | ||
1562 | CARD_WDEV_ID(card), card->info.func_level, temp); | ||
1563 | goto out; | ||
1564 | } | ||
1565 | channel->state = CH_STATE_UP; | ||
1566 | out: | ||
1567 | qeth_release_buffer(channel, iob); | ||
1568 | } | ||
1569 | |||
1570 | static int | ||
1571 | qeth_check_idx_response(unsigned char *buffer) | ||
1572 | { | ||
1573 | if (!buffer) | ||
1574 | return 0; | ||
1575 | |||
1576 | QETH_DBF_HEX(control, 2, buffer, QETH_DBF_CONTROL_LEN); | ||
1577 | if ((buffer[2] & 0xc0) == 0xc0) { | ||
1578 | PRINT_WARN("received an IDX TERMINATE " | ||
1579 | "with cause code 0x%02x%s\n", | ||
1580 | buffer[4], | ||
1581 | ((buffer[4] == 0x22) ? | ||
1582 | " -- try another portname" : "")); | ||
1583 | QETH_DBF_TEXT(trace, 2, "ckidxres"); | ||
1584 | QETH_DBF_TEXT(trace, 2, " idxterm"); | ||
1585 | QETH_DBF_TEXT_(trace, 2, " rc%d", -EIO); | ||
1586 | return -EIO; | ||
1587 | } | ||
1588 | return 0; | ||
1589 | } | ||
1590 | |||
1591 | static void | ||
1592 | qeth_idx_read_cb(struct qeth_channel *channel, struct qeth_cmd_buffer *iob) | ||
1593 | { | ||
1594 | struct qeth_card *card; | ||
1595 | __u16 temp; | ||
1596 | |||
1597 | QETH_DBF_TEXT(setup , 2, "idxrdcb"); | ||
1598 | if (channel->state == CH_STATE_DOWN) { | ||
1599 | channel->state = CH_STATE_ACTIVATING; | ||
1600 | goto out; | ||
1601 | } | ||
1602 | |||
1603 | card = CARD_FROM_CDEV(channel->ccwdev); | ||
1604 | if (qeth_check_idx_response(iob->data)) { | ||
1605 | goto out; | ||
1606 | } | ||
1607 | if (!(QETH_IS_IDX_ACT_POS_REPLY(iob->data))) { | ||
1608 | if (QETH_IDX_ACT_CAUSE_CODE(iob->data) == 0x19) | ||
1609 | PRINT_ERR("IDX_ACTIVATE on read channel device %s: " | ||
1610 | "adapter exclusively used by another host\n", | ||
1611 | CARD_RDEV_ID(card)); | ||
1612 | else | ||
1613 | PRINT_ERR("IDX_ACTIVATE on read channel device %s: " | ||
1614 | "negative reply\n", CARD_RDEV_ID(card)); | ||
1615 | goto out; | ||
1616 | } | ||
1617 | |||
1618 | /** | ||
1619 | * temporary fix for microcode bug | ||
1620 | * to revert it,replace OR by AND | ||
1621 | */ | ||
1622 | if ( (!QETH_IDX_NO_PORTNAME_REQUIRED(iob->data)) || | ||
1623 | (card->info.type == QETH_CARD_TYPE_OSAE) ) | ||
1624 | card->info.portname_required = 1; | ||
1625 | |||
1626 | memcpy(&temp, QETH_IDX_ACT_FUNC_LEVEL(iob->data), 2); | ||
1627 | if (temp != qeth_peer_func_level(card->info.func_level)) { | ||
1628 | PRINT_WARN("IDX_ACTIVATE on read channel device %s: function " | ||
1629 | "level mismatch (sent: 0x%x, received: 0x%x)\n", | ||
1630 | CARD_RDEV_ID(card), card->info.func_level, temp); | ||
1631 | goto out; | ||
1632 | } | ||
1633 | memcpy(&card->token.issuer_rm_r, | ||
1634 | QETH_IDX_ACT_ISSUER_RM_TOKEN(iob->data), | ||
1635 | QETH_MPC_TOKEN_LENGTH); | ||
1636 | memcpy(&card->info.mcl_level[0], | ||
1637 | QETH_IDX_REPLY_LEVEL(iob->data), QETH_MCL_LENGTH); | ||
1638 | channel->state = CH_STATE_UP; | ||
1639 | out: | ||
1640 | qeth_release_buffer(channel,iob); | ||
1641 | } | ||
1642 | |||
1643 | static int | ||
1644 | qeth_issue_next_read(struct qeth_card *card) | ||
1645 | { | ||
1646 | int rc; | ||
1647 | struct qeth_cmd_buffer *iob; | ||
1648 | |||
1649 | QETH_DBF_TEXT(trace,5,"issnxrd"); | ||
1650 | if (card->read.state != CH_STATE_UP) | ||
1651 | return -EIO; | ||
1652 | iob = qeth_get_buffer(&card->read); | ||
1653 | if (!iob) { | ||
1654 | PRINT_WARN("issue_next_read failed: no iob available!\n"); | ||
1655 | return -ENOMEM; | ||
1656 | } | ||
1657 | qeth_setup_ccw(&card->read, iob->data, QETH_BUFSIZE); | ||
1658 | QETH_DBF_TEXT(trace, 6, "noirqpnd"); | ||
1659 | rc = ccw_device_start(card->read.ccwdev, &card->read.ccw, | ||
1660 | (addr_t) iob, 0, 0); | ||
1661 | if (rc) { | ||
1662 | PRINT_ERR("Error in starting next read ccw! rc=%i\n", rc); | ||
1663 | atomic_set(&card->read.irq_pending, 0); | ||
1664 | qeth_schedule_recovery(card); | ||
1665 | wake_up(&card->wait_q); | ||
1666 | } | ||
1667 | return rc; | ||
1668 | } | ||
1669 | |||
1670 | static struct qeth_reply * | ||
1671 | qeth_alloc_reply(struct qeth_card *card) | ||
1672 | { | ||
1673 | struct qeth_reply *reply; | ||
1674 | |||
1675 | reply = kzalloc(sizeof(struct qeth_reply), GFP_ATOMIC); | ||
1676 | if (reply){ | ||
1677 | atomic_set(&reply->refcnt, 1); | ||
1678 | atomic_set(&reply->received, 0); | ||
1679 | reply->card = card; | ||
1680 | }; | ||
1681 | return reply; | ||
1682 | } | ||
1683 | |||
1684 | static void | ||
1685 | qeth_get_reply(struct qeth_reply *reply) | ||
1686 | { | ||
1687 | WARN_ON(atomic_read(&reply->refcnt) <= 0); | ||
1688 | atomic_inc(&reply->refcnt); | ||
1689 | } | ||
1690 | |||
1691 | static void | ||
1692 | qeth_put_reply(struct qeth_reply *reply) | ||
1693 | { | ||
1694 | WARN_ON(atomic_read(&reply->refcnt) <= 0); | ||
1695 | if (atomic_dec_and_test(&reply->refcnt)) | ||
1696 | kfree(reply); | ||
1697 | } | ||
1698 | |||
1699 | static void | ||
1700 | qeth_issue_ipa_msg(struct qeth_ipa_cmd *cmd, struct qeth_card *card) | ||
1701 | { | ||
1702 | int rc; | ||
1703 | int com; | ||
1704 | char * ipa_name; | ||
1705 | |||
1706 | com = cmd->hdr.command; | ||
1707 | rc = cmd->hdr.return_code; | ||
1708 | ipa_name = qeth_get_ipa_cmd_name(com); | ||
1709 | |||
1710 | PRINT_ERR("%s(x%X) for %s returned x%X \"%s\"\n", ipa_name, com, | ||
1711 | QETH_CARD_IFNAME(card), rc, qeth_get_ipa_msg(rc)); | ||
1712 | } | ||
1713 | |||
1714 | static struct qeth_ipa_cmd * | ||
1715 | qeth_check_ipa_data(struct qeth_card *card, struct qeth_cmd_buffer *iob) | ||
1716 | { | ||
1717 | struct qeth_ipa_cmd *cmd = NULL; | ||
1718 | |||
1719 | QETH_DBF_TEXT(trace,5,"chkipad"); | ||
1720 | if (IS_IPA(iob->data)){ | ||
1721 | cmd = (struct qeth_ipa_cmd *) PDU_ENCAPSULATION(iob->data); | ||
1722 | if (IS_IPA_REPLY(cmd)) { | ||
1723 | if (cmd->hdr.return_code) | ||
1724 | qeth_issue_ipa_msg(cmd, card); | ||
1725 | return cmd; | ||
1726 | } | ||
1727 | else { | ||
1728 | switch (cmd->hdr.command) { | ||
1729 | case IPA_CMD_STOPLAN: | ||
1730 | PRINT_WARN("Link failure on %s (CHPID 0x%X) - " | ||
1731 | "there is a network problem or " | ||
1732 | "someone pulled the cable or " | ||
1733 | "disabled the port.\n", | ||
1734 | QETH_CARD_IFNAME(card), | ||
1735 | card->info.chpid); | ||
1736 | card->lan_online = 0; | ||
1737 | if (card->dev && netif_carrier_ok(card->dev)) | ||
1738 | netif_carrier_off(card->dev); | ||
1739 | return NULL; | ||
1740 | case IPA_CMD_STARTLAN: | ||
1741 | PRINT_INFO("Link reestablished on %s " | ||
1742 | "(CHPID 0x%X). Scheduling " | ||
1743 | "IP address reset.\n", | ||
1744 | QETH_CARD_IFNAME(card), | ||
1745 | card->info.chpid); | ||
1746 | netif_carrier_on(card->dev); | ||
1747 | qeth_schedule_recovery(card); | ||
1748 | return NULL; | ||
1749 | case IPA_CMD_MODCCID: | ||
1750 | return cmd; | ||
1751 | case IPA_CMD_REGISTER_LOCAL_ADDR: | ||
1752 | QETH_DBF_TEXT(trace,3, "irla"); | ||
1753 | break; | ||
1754 | case IPA_CMD_UNREGISTER_LOCAL_ADDR: | ||
1755 | QETH_DBF_TEXT(trace,3, "urla"); | ||
1756 | break; | ||
1757 | default: | ||
1758 | PRINT_WARN("Received data is IPA " | ||
1759 | "but not a reply!\n"); | ||
1760 | break; | ||
1761 | } | ||
1762 | } | ||
1763 | } | ||
1764 | return cmd; | ||
1765 | } | ||
1766 | |||
1767 | /** | ||
1768 | * wake all waiting ipa commands | ||
1769 | */ | ||
1770 | static void | ||
1771 | qeth_clear_ipacmd_list(struct qeth_card *card) | ||
1772 | { | ||
1773 | struct qeth_reply *reply, *r; | ||
1774 | unsigned long flags; | ||
1775 | |||
1776 | QETH_DBF_TEXT(trace, 4, "clipalst"); | ||
1777 | |||
1778 | spin_lock_irqsave(&card->lock, flags); | ||
1779 | list_for_each_entry_safe(reply, r, &card->cmd_waiter_list, list) { | ||
1780 | qeth_get_reply(reply); | ||
1781 | reply->rc = -EIO; | ||
1782 | atomic_inc(&reply->received); | ||
1783 | list_del_init(&reply->list); | ||
1784 | wake_up(&reply->wait_q); | ||
1785 | qeth_put_reply(reply); | ||
1786 | } | ||
1787 | spin_unlock_irqrestore(&card->lock, flags); | ||
1788 | } | ||
1789 | |||
1790 | static void | ||
1791 | qeth_send_control_data_cb(struct qeth_channel *channel, | ||
1792 | struct qeth_cmd_buffer *iob) | ||
1793 | { | ||
1794 | struct qeth_card *card; | ||
1795 | struct qeth_reply *reply, *r; | ||
1796 | struct qeth_ipa_cmd *cmd; | ||
1797 | unsigned long flags; | ||
1798 | int keep_reply; | ||
1799 | |||
1800 | QETH_DBF_TEXT(trace,4,"sndctlcb"); | ||
1801 | |||
1802 | card = CARD_FROM_CDEV(channel->ccwdev); | ||
1803 | if (qeth_check_idx_response(iob->data)) { | ||
1804 | qeth_clear_ipacmd_list(card); | ||
1805 | qeth_schedule_recovery(card); | ||
1806 | goto out; | ||
1807 | } | ||
1808 | |||
1809 | cmd = qeth_check_ipa_data(card, iob); | ||
1810 | if ((cmd == NULL) && (card->state != CARD_STATE_DOWN)) | ||
1811 | goto out; | ||
1812 | /*in case of OSN : check if cmd is set */ | ||
1813 | if (card->info.type == QETH_CARD_TYPE_OSN && | ||
1814 | cmd && | ||
1815 | cmd->hdr.command != IPA_CMD_STARTLAN && | ||
1816 | card->osn_info.assist_cb != NULL) { | ||
1817 | card->osn_info.assist_cb(card->dev, cmd); | ||
1818 | goto out; | ||
1819 | } | ||
1820 | |||
1821 | spin_lock_irqsave(&card->lock, flags); | ||
1822 | list_for_each_entry_safe(reply, r, &card->cmd_waiter_list, list) { | ||
1823 | if ((reply->seqno == QETH_IDX_COMMAND_SEQNO) || | ||
1824 | ((cmd) && (reply->seqno == cmd->hdr.seqno))) { | ||
1825 | qeth_get_reply(reply); | ||
1826 | list_del_init(&reply->list); | ||
1827 | spin_unlock_irqrestore(&card->lock, flags); | ||
1828 | keep_reply = 0; | ||
1829 | if (reply->callback != NULL) { | ||
1830 | if (cmd) { | ||
1831 | reply->offset = (__u16)((char*)cmd - | ||
1832 | (char *)iob->data); | ||
1833 | keep_reply = reply->callback(card, | ||
1834 | reply, | ||
1835 | (unsigned long)cmd); | ||
1836 | } else | ||
1837 | keep_reply = reply->callback(card, | ||
1838 | reply, | ||
1839 | (unsigned long)iob); | ||
1840 | } | ||
1841 | if (cmd) | ||
1842 | reply->rc = (u16) cmd->hdr.return_code; | ||
1843 | else if (iob->rc) | ||
1844 | reply->rc = iob->rc; | ||
1845 | if (keep_reply) { | ||
1846 | spin_lock_irqsave(&card->lock, flags); | ||
1847 | list_add_tail(&reply->list, | ||
1848 | &card->cmd_waiter_list); | ||
1849 | spin_unlock_irqrestore(&card->lock, flags); | ||
1850 | } else { | ||
1851 | atomic_inc(&reply->received); | ||
1852 | wake_up(&reply->wait_q); | ||
1853 | } | ||
1854 | qeth_put_reply(reply); | ||
1855 | goto out; | ||
1856 | } | ||
1857 | } | ||
1858 | spin_unlock_irqrestore(&card->lock, flags); | ||
1859 | out: | ||
1860 | memcpy(&card->seqno.pdu_hdr_ack, | ||
1861 | QETH_PDU_HEADER_SEQ_NO(iob->data), | ||
1862 | QETH_SEQ_NO_LENGTH); | ||
1863 | qeth_release_buffer(channel,iob); | ||
1864 | } | ||
1865 | |||
1866 | static void | ||
1867 | qeth_prepare_control_data(struct qeth_card *card, int len, | ||
1868 | struct qeth_cmd_buffer *iob) | ||
1869 | { | ||
1870 | qeth_setup_ccw(&card->write,iob->data,len); | ||
1871 | iob->callback = qeth_release_buffer; | ||
1872 | |||
1873 | memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob->data), | ||
1874 | &card->seqno.trans_hdr, QETH_SEQ_NO_LENGTH); | ||
1875 | card->seqno.trans_hdr++; | ||
1876 | memcpy(QETH_PDU_HEADER_SEQ_NO(iob->data), | ||
1877 | &card->seqno.pdu_hdr, QETH_SEQ_NO_LENGTH); | ||
1878 | card->seqno.pdu_hdr++; | ||
1879 | memcpy(QETH_PDU_HEADER_ACK_SEQ_NO(iob->data), | ||
1880 | &card->seqno.pdu_hdr_ack, QETH_SEQ_NO_LENGTH); | ||
1881 | QETH_DBF_HEX(control, 2, iob->data, QETH_DBF_CONTROL_LEN); | ||
1882 | } | ||
1883 | |||
1884 | static int | ||
1885 | qeth_send_control_data(struct qeth_card *card, int len, | ||
1886 | struct qeth_cmd_buffer *iob, | ||
1887 | int (*reply_cb) | ||
1888 | (struct qeth_card *, struct qeth_reply*, unsigned long), | ||
1889 | void *reply_param) | ||
1890 | |||
1891 | { | ||
1892 | int rc; | ||
1893 | unsigned long flags; | ||
1894 | struct qeth_reply *reply = NULL; | ||
1895 | unsigned long timeout; | ||
1896 | |||
1897 | QETH_DBF_TEXT(trace, 2, "sendctl"); | ||
1898 | |||
1899 | reply = qeth_alloc_reply(card); | ||
1900 | if (!reply) { | ||
1901 | PRINT_WARN("Could no alloc qeth_reply!\n"); | ||
1902 | return -ENOMEM; | ||
1903 | } | ||
1904 | reply->callback = reply_cb; | ||
1905 | reply->param = reply_param; | ||
1906 | if (card->state == CARD_STATE_DOWN) | ||
1907 | reply->seqno = QETH_IDX_COMMAND_SEQNO; | ||
1908 | else | ||
1909 | reply->seqno = card->seqno.ipa++; | ||
1910 | init_waitqueue_head(&reply->wait_q); | ||
1911 | spin_lock_irqsave(&card->lock, flags); | ||
1912 | list_add_tail(&reply->list, &card->cmd_waiter_list); | ||
1913 | spin_unlock_irqrestore(&card->lock, flags); | ||
1914 | QETH_DBF_HEX(control, 2, iob->data, QETH_DBF_CONTROL_LEN); | ||
1915 | |||
1916 | while (atomic_cmpxchg(&card->write.irq_pending, 0, 1)) ; | ||
1917 | qeth_prepare_control_data(card, len, iob); | ||
1918 | |||
1919 | if (IS_IPA(iob->data)) | ||
1920 | timeout = jiffies + QETH_IPA_TIMEOUT; | ||
1921 | else | ||
1922 | timeout = jiffies + QETH_TIMEOUT; | ||
1923 | |||
1924 | QETH_DBF_TEXT(trace, 6, "noirqpnd"); | ||
1925 | spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags); | ||
1926 | rc = ccw_device_start(card->write.ccwdev, &card->write.ccw, | ||
1927 | (addr_t) iob, 0, 0); | ||
1928 | spin_unlock_irqrestore(get_ccwdev_lock(card->write.ccwdev), flags); | ||
1929 | if (rc){ | ||
1930 | PRINT_WARN("qeth_send_control_data: " | ||
1931 | "ccw_device_start rc = %i\n", rc); | ||
1932 | QETH_DBF_TEXT_(trace, 2, " err%d", rc); | ||
1933 | spin_lock_irqsave(&card->lock, flags); | ||
1934 | list_del_init(&reply->list); | ||
1935 | qeth_put_reply(reply); | ||
1936 | spin_unlock_irqrestore(&card->lock, flags); | ||
1937 | qeth_release_buffer(iob->channel, iob); | ||
1938 | atomic_set(&card->write.irq_pending, 0); | ||
1939 | wake_up(&card->wait_q); | ||
1940 | return rc; | ||
1941 | } | ||
1942 | while (!atomic_read(&reply->received)) { | ||
1943 | if (time_after(jiffies, timeout)) { | ||
1944 | spin_lock_irqsave(&reply->card->lock, flags); | ||
1945 | list_del_init(&reply->list); | ||
1946 | spin_unlock_irqrestore(&reply->card->lock, flags); | ||
1947 | reply->rc = -ETIME; | ||
1948 | atomic_inc(&reply->received); | ||
1949 | wake_up(&reply->wait_q); | ||
1950 | } | ||
1951 | cpu_relax(); | ||
1952 | }; | ||
1953 | rc = reply->rc; | ||
1954 | qeth_put_reply(reply); | ||
1955 | return rc; | ||
1956 | } | ||
1957 | |||
1958 | static int | ||
1959 | qeth_osn_send_control_data(struct qeth_card *card, int len, | ||
1960 | struct qeth_cmd_buffer *iob) | ||
1961 | { | ||
1962 | unsigned long flags; | ||
1963 | int rc = 0; | ||
1964 | |||
1965 | QETH_DBF_TEXT(trace, 5, "osndctrd"); | ||
1966 | |||
1967 | wait_event(card->wait_q, | ||
1968 | atomic_cmpxchg(&card->write.irq_pending, 0, 1) == 0); | ||
1969 | qeth_prepare_control_data(card, len, iob); | ||
1970 | QETH_DBF_TEXT(trace, 6, "osnoirqp"); | ||
1971 | spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags); | ||
1972 | rc = ccw_device_start(card->write.ccwdev, &card->write.ccw, | ||
1973 | (addr_t) iob, 0, 0); | ||
1974 | spin_unlock_irqrestore(get_ccwdev_lock(card->write.ccwdev), flags); | ||
1975 | if (rc){ | ||
1976 | PRINT_WARN("qeth_osn_send_control_data: " | ||
1977 | "ccw_device_start rc = %i\n", rc); | ||
1978 | QETH_DBF_TEXT_(trace, 2, " err%d", rc); | ||
1979 | qeth_release_buffer(iob->channel, iob); | ||
1980 | atomic_set(&card->write.irq_pending, 0); | ||
1981 | wake_up(&card->wait_q); | ||
1982 | } | ||
1983 | return rc; | ||
1984 | } | ||
1985 | |||
1986 | static inline void | ||
1987 | qeth_prepare_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob, | ||
1988 | char prot_type) | ||
1989 | { | ||
1990 | memcpy(iob->data, IPA_PDU_HEADER, IPA_PDU_HEADER_SIZE); | ||
1991 | memcpy(QETH_IPA_CMD_PROT_TYPE(iob->data),&prot_type,1); | ||
1992 | memcpy(QETH_IPA_CMD_DEST_ADDR(iob->data), | ||
1993 | &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH); | ||
1994 | } | ||
1995 | |||
1996 | static int | ||
1997 | qeth_osn_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob, | ||
1998 | int data_len) | ||
1999 | { | ||
2000 | u16 s1, s2; | ||
2001 | |||
2002 | QETH_DBF_TEXT(trace,4,"osndipa"); | ||
2003 | |||
2004 | qeth_prepare_ipa_cmd(card, iob, QETH_PROT_OSN2); | ||
2005 | s1 = (u16)(IPA_PDU_HEADER_SIZE + data_len); | ||
2006 | s2 = (u16)data_len; | ||
2007 | memcpy(QETH_IPA_PDU_LEN_TOTAL(iob->data), &s1, 2); | ||
2008 | memcpy(QETH_IPA_PDU_LEN_PDU1(iob->data), &s2, 2); | ||
2009 | memcpy(QETH_IPA_PDU_LEN_PDU2(iob->data), &s2, 2); | ||
2010 | memcpy(QETH_IPA_PDU_LEN_PDU3(iob->data), &s2, 2); | ||
2011 | return qeth_osn_send_control_data(card, s1, iob); | ||
2012 | } | ||
2013 | |||
2014 | static int | ||
2015 | qeth_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob, | ||
2016 | int (*reply_cb) | ||
2017 | (struct qeth_card *,struct qeth_reply*, unsigned long), | ||
2018 | void *reply_param) | ||
2019 | { | ||
2020 | int rc; | ||
2021 | char prot_type; | ||
2022 | |||
2023 | QETH_DBF_TEXT(trace,4,"sendipa"); | ||
2024 | |||
2025 | if (card->options.layer2) | ||
2026 | if (card->info.type == QETH_CARD_TYPE_OSN) | ||
2027 | prot_type = QETH_PROT_OSN2; | ||
2028 | else | ||
2029 | prot_type = QETH_PROT_LAYER2; | ||
2030 | else | ||
2031 | prot_type = QETH_PROT_TCPIP; | ||
2032 | qeth_prepare_ipa_cmd(card,iob,prot_type); | ||
2033 | rc = qeth_send_control_data(card, IPA_CMD_LENGTH, iob, | ||
2034 | reply_cb, reply_param); | ||
2035 | return rc; | ||
2036 | } | ||
2037 | |||
2038 | |||
2039 | static int | ||
2040 | qeth_cm_enable_cb(struct qeth_card *card, struct qeth_reply *reply, | ||
2041 | unsigned long data) | ||
2042 | { | ||
2043 | struct qeth_cmd_buffer *iob; | ||
2044 | |||
2045 | QETH_DBF_TEXT(setup, 2, "cmenblcb"); | ||
2046 | |||
2047 | iob = (struct qeth_cmd_buffer *) data; | ||
2048 | memcpy(&card->token.cm_filter_r, | ||
2049 | QETH_CM_ENABLE_RESP_FILTER_TOKEN(iob->data), | ||
2050 | QETH_MPC_TOKEN_LENGTH); | ||
2051 | QETH_DBF_TEXT_(setup, 2, " rc%d", iob->rc); | ||
2052 | return 0; | ||
2053 | } | ||
2054 | |||
2055 | static int | ||
2056 | qeth_cm_enable(struct qeth_card *card) | ||
2057 | { | ||
2058 | int rc; | ||
2059 | struct qeth_cmd_buffer *iob; | ||
2060 | |||
2061 | QETH_DBF_TEXT(setup,2,"cmenable"); | ||
2062 | |||
2063 | iob = qeth_wait_for_buffer(&card->write); | ||
2064 | memcpy(iob->data, CM_ENABLE, CM_ENABLE_SIZE); | ||
2065 | memcpy(QETH_CM_ENABLE_ISSUER_RM_TOKEN(iob->data), | ||
2066 | &card->token.issuer_rm_r, QETH_MPC_TOKEN_LENGTH); | ||
2067 | memcpy(QETH_CM_ENABLE_FILTER_TOKEN(iob->data), | ||
2068 | &card->token.cm_filter_w, QETH_MPC_TOKEN_LENGTH); | ||
2069 | |||
2070 | rc = qeth_send_control_data(card, CM_ENABLE_SIZE, iob, | ||
2071 | qeth_cm_enable_cb, NULL); | ||
2072 | return rc; | ||
2073 | } | ||
2074 | |||
2075 | static int | ||
2076 | qeth_cm_setup_cb(struct qeth_card *card, struct qeth_reply *reply, | ||
2077 | unsigned long data) | ||
2078 | { | ||
2079 | |||
2080 | struct qeth_cmd_buffer *iob; | ||
2081 | |||
2082 | QETH_DBF_TEXT(setup, 2, "cmsetpcb"); | ||
2083 | |||
2084 | iob = (struct qeth_cmd_buffer *) data; | ||
2085 | memcpy(&card->token.cm_connection_r, | ||
2086 | QETH_CM_SETUP_RESP_DEST_ADDR(iob->data), | ||
2087 | QETH_MPC_TOKEN_LENGTH); | ||
2088 | QETH_DBF_TEXT_(setup, 2, " rc%d", iob->rc); | ||
2089 | return 0; | ||
2090 | } | ||
2091 | |||
2092 | static int | ||
2093 | qeth_cm_setup(struct qeth_card *card) | ||
2094 | { | ||
2095 | int rc; | ||
2096 | struct qeth_cmd_buffer *iob; | ||
2097 | |||
2098 | QETH_DBF_TEXT(setup,2,"cmsetup"); | ||
2099 | |||
2100 | iob = qeth_wait_for_buffer(&card->write); | ||
2101 | memcpy(iob->data, CM_SETUP, CM_SETUP_SIZE); | ||
2102 | memcpy(QETH_CM_SETUP_DEST_ADDR(iob->data), | ||
2103 | &card->token.issuer_rm_r, QETH_MPC_TOKEN_LENGTH); | ||
2104 | memcpy(QETH_CM_SETUP_CONNECTION_TOKEN(iob->data), | ||
2105 | &card->token.cm_connection_w, QETH_MPC_TOKEN_LENGTH); | ||
2106 | memcpy(QETH_CM_SETUP_FILTER_TOKEN(iob->data), | ||
2107 | &card->token.cm_filter_r, QETH_MPC_TOKEN_LENGTH); | ||
2108 | rc = qeth_send_control_data(card, CM_SETUP_SIZE, iob, | ||
2109 | qeth_cm_setup_cb, NULL); | ||
2110 | return rc; | ||
2111 | |||
2112 | } | ||
2113 | |||
2114 | static int | ||
2115 | qeth_ulp_enable_cb(struct qeth_card *card, struct qeth_reply *reply, | ||
2116 | unsigned long data) | ||
2117 | { | ||
2118 | |||
2119 | __u16 mtu, framesize; | ||
2120 | __u16 len; | ||
2121 | __u8 link_type; | ||
2122 | struct qeth_cmd_buffer *iob; | ||
2123 | |||
2124 | QETH_DBF_TEXT(setup, 2, "ulpenacb"); | ||
2125 | |||
2126 | iob = (struct qeth_cmd_buffer *) data; | ||
2127 | memcpy(&card->token.ulp_filter_r, | ||
2128 | QETH_ULP_ENABLE_RESP_FILTER_TOKEN(iob->data), | ||
2129 | QETH_MPC_TOKEN_LENGTH); | ||
2130 | if (qeth_get_mtu_out_of_mpc(card->info.type)) { | ||
2131 | memcpy(&framesize, QETH_ULP_ENABLE_RESP_MAX_MTU(iob->data), 2); | ||
2132 | mtu = qeth_get_mtu_outof_framesize(framesize); | ||
2133 | if (!mtu) { | ||
2134 | iob->rc = -EINVAL; | ||
2135 | QETH_DBF_TEXT_(setup, 2, " rc%d", iob->rc); | ||
2136 | return 0; | ||
2137 | } | ||
2138 | card->info.max_mtu = mtu; | ||
2139 | card->info.initial_mtu = mtu; | ||
2140 | card->qdio.in_buf_size = mtu + 2 * PAGE_SIZE; | ||
2141 | } else { | ||
2142 | card->info.initial_mtu = qeth_get_initial_mtu_for_card(card); | ||
2143 | card->info.max_mtu = qeth_get_max_mtu_for_card(card->info.type); | ||
2144 | card->qdio.in_buf_size = QETH_IN_BUF_SIZE_DEFAULT; | ||
2145 | } | ||
2146 | |||
2147 | memcpy(&len, QETH_ULP_ENABLE_RESP_DIFINFO_LEN(iob->data), 2); | ||
2148 | if (len >= QETH_MPC_DIFINFO_LEN_INDICATES_LINK_TYPE) { | ||
2149 | memcpy(&link_type, | ||
2150 | QETH_ULP_ENABLE_RESP_LINK_TYPE(iob->data), 1); | ||
2151 | card->info.link_type = link_type; | ||
2152 | } else | ||
2153 | card->info.link_type = 0; | ||
2154 | QETH_DBF_TEXT_(setup, 2, " rc%d", iob->rc); | ||
2155 | return 0; | ||
2156 | } | ||
2157 | |||
2158 | static int | ||
2159 | qeth_ulp_enable(struct qeth_card *card) | ||
2160 | { | ||
2161 | int rc; | ||
2162 | char prot_type; | ||
2163 | struct qeth_cmd_buffer *iob; | ||
2164 | |||
2165 | /*FIXME: trace view callbacks*/ | ||
2166 | QETH_DBF_TEXT(setup,2,"ulpenabl"); | ||
2167 | |||
2168 | iob = qeth_wait_for_buffer(&card->write); | ||
2169 | memcpy(iob->data, ULP_ENABLE, ULP_ENABLE_SIZE); | ||
2170 | |||
2171 | *(QETH_ULP_ENABLE_LINKNUM(iob->data)) = | ||
2172 | (__u8) card->info.portno; | ||
2173 | if (card->options.layer2) | ||
2174 | if (card->info.type == QETH_CARD_TYPE_OSN) | ||
2175 | prot_type = QETH_PROT_OSN2; | ||
2176 | else | ||
2177 | prot_type = QETH_PROT_LAYER2; | ||
2178 | else | ||
2179 | prot_type = QETH_PROT_TCPIP; | ||
2180 | |||
2181 | memcpy(QETH_ULP_ENABLE_PROT_TYPE(iob->data),&prot_type,1); | ||
2182 | memcpy(QETH_ULP_ENABLE_DEST_ADDR(iob->data), | ||
2183 | &card->token.cm_connection_r, QETH_MPC_TOKEN_LENGTH); | ||
2184 | memcpy(QETH_ULP_ENABLE_FILTER_TOKEN(iob->data), | ||
2185 | &card->token.ulp_filter_w, QETH_MPC_TOKEN_LENGTH); | ||
2186 | memcpy(QETH_ULP_ENABLE_PORTNAME_AND_LL(iob->data), | ||
2187 | card->info.portname, 9); | ||
2188 | rc = qeth_send_control_data(card, ULP_ENABLE_SIZE, iob, | ||
2189 | qeth_ulp_enable_cb, NULL); | ||
2190 | return rc; | ||
2191 | |||
2192 | } | ||
2193 | |||
2194 | static int | ||
2195 | qeth_ulp_setup_cb(struct qeth_card *card, struct qeth_reply *reply, | ||
2196 | unsigned long data) | ||
2197 | { | ||
2198 | struct qeth_cmd_buffer *iob; | ||
2199 | |||
2200 | QETH_DBF_TEXT(setup, 2, "ulpstpcb"); | ||
2201 | |||
2202 | iob = (struct qeth_cmd_buffer *) data; | ||
2203 | memcpy(&card->token.ulp_connection_r, | ||
2204 | QETH_ULP_SETUP_RESP_CONNECTION_TOKEN(iob->data), | ||
2205 | QETH_MPC_TOKEN_LENGTH); | ||
2206 | QETH_DBF_TEXT_(setup, 2, " rc%d", iob->rc); | ||
2207 | return 0; | ||
2208 | } | ||
2209 | |||
2210 | static int | ||
2211 | qeth_ulp_setup(struct qeth_card *card) | ||
2212 | { | ||
2213 | int rc; | ||
2214 | __u16 temp; | ||
2215 | struct qeth_cmd_buffer *iob; | ||
2216 | struct ccw_dev_id dev_id; | ||
2217 | |||
2218 | QETH_DBF_TEXT(setup,2,"ulpsetup"); | ||
2219 | |||
2220 | iob = qeth_wait_for_buffer(&card->write); | ||
2221 | memcpy(iob->data, ULP_SETUP, ULP_SETUP_SIZE); | ||
2222 | |||
2223 | memcpy(QETH_ULP_SETUP_DEST_ADDR(iob->data), | ||
2224 | &card->token.cm_connection_r, QETH_MPC_TOKEN_LENGTH); | ||
2225 | memcpy(QETH_ULP_SETUP_CONNECTION_TOKEN(iob->data), | ||
2226 | &card->token.ulp_connection_w, QETH_MPC_TOKEN_LENGTH); | ||
2227 | memcpy(QETH_ULP_SETUP_FILTER_TOKEN(iob->data), | ||
2228 | &card->token.ulp_filter_r, QETH_MPC_TOKEN_LENGTH); | ||
2229 | |||
2230 | ccw_device_get_id(CARD_DDEV(card), &dev_id); | ||
2231 | memcpy(QETH_ULP_SETUP_CUA(iob->data), &dev_id.devno, 2); | ||
2232 | temp = (card->info.cula << 8) + card->info.unit_addr2; | ||
2233 | memcpy(QETH_ULP_SETUP_REAL_DEVADDR(iob->data), &temp, 2); | ||
2234 | rc = qeth_send_control_data(card, ULP_SETUP_SIZE, iob, | ||
2235 | qeth_ulp_setup_cb, NULL); | ||
2236 | return rc; | ||
2237 | } | ||
2238 | |||
2239 | static inline int | ||
2240 | qeth_check_qdio_errors(struct qdio_buffer *buf, unsigned int qdio_error, | ||
2241 | unsigned int siga_error, const char *dbftext) | ||
2242 | { | ||
2243 | if (qdio_error || siga_error) { | ||
2244 | QETH_DBF_TEXT(trace, 2, dbftext); | ||
2245 | QETH_DBF_TEXT(qerr, 2, dbftext); | ||
2246 | QETH_DBF_TEXT_(qerr, 2, " F15=%02X", | ||
2247 | buf->element[15].flags & 0xff); | ||
2248 | QETH_DBF_TEXT_(qerr, 2, " F14=%02X", | ||
2249 | buf->element[14].flags & 0xff); | ||
2250 | QETH_DBF_TEXT_(qerr, 2, " qerr=%X", qdio_error); | ||
2251 | QETH_DBF_TEXT_(qerr, 2, " serr=%X", siga_error); | ||
2252 | return 1; | ||
2253 | } | ||
2254 | return 0; | ||
2255 | } | ||
2256 | |||
2257 | static struct sk_buff * | ||
2258 | qeth_get_skb(unsigned int length, struct qeth_hdr *hdr) | ||
2259 | { | ||
2260 | struct sk_buff* skb; | ||
2261 | int add_len; | ||
2262 | |||
2263 | add_len = 0; | ||
2264 | if (hdr->hdr.osn.id == QETH_HEADER_TYPE_OSN) | ||
2265 | add_len = sizeof(struct qeth_hdr); | ||
2266 | #ifdef CONFIG_QETH_VLAN | ||
2267 | else | ||
2268 | add_len = VLAN_HLEN; | ||
2269 | #endif | ||
2270 | skb = dev_alloc_skb(length + add_len); | ||
2271 | if (skb && add_len) | ||
2272 | skb_reserve(skb, add_len); | ||
2273 | return skb; | ||
2274 | } | ||
2275 | |||
2276 | static inline int | ||
2277 | qeth_create_skb_frag(struct qdio_buffer_element *element, | ||
2278 | struct sk_buff **pskb, | ||
2279 | int offset, int *pfrag, int data_len) | ||
2280 | { | ||
2281 | struct page *page = virt_to_page(element->addr); | ||
2282 | if (*pfrag == 0) { | ||
2283 | /* the upper protocol layers assume that there is data in the | ||
2284 | * skb itself. Copy a small amount (64 bytes) to make them | ||
2285 | * happy. */ | ||
2286 | *pskb = dev_alloc_skb(64 + QETH_FAKE_LL_LEN_ETH); | ||
2287 | if (!(*pskb)) | ||
2288 | return -ENOMEM; | ||
2289 | skb_reserve(*pskb, QETH_FAKE_LL_LEN_ETH); | ||
2290 | if (data_len <= 64) { | ||
2291 | memcpy(skb_put(*pskb, data_len), element->addr + offset, | ||
2292 | data_len); | ||
2293 | } else { | ||
2294 | get_page(page); | ||
2295 | memcpy(skb_put(*pskb, 64), element->addr + offset, 64); | ||
2296 | skb_fill_page_desc(*pskb, *pfrag, page, offset + 64, | ||
2297 | data_len - 64); | ||
2298 | (*pskb)->data_len += data_len - 64; | ||
2299 | (*pskb)->len += data_len - 64; | ||
2300 | (*pskb)->truesize += data_len - 64; | ||
2301 | } | ||
2302 | } else { | ||
2303 | get_page(page); | ||
2304 | skb_fill_page_desc(*pskb, *pfrag, page, offset, data_len); | ||
2305 | (*pskb)->data_len += data_len; | ||
2306 | (*pskb)->len += data_len; | ||
2307 | (*pskb)->truesize += data_len; | ||
2308 | } | ||
2309 | (*pfrag)++; | ||
2310 | return 0; | ||
2311 | } | ||
2312 | |||
2313 | static inline struct qeth_buffer_pool_entry * | ||
2314 | qeth_find_free_buffer_pool_entry(struct qeth_card *card) | ||
2315 | { | ||
2316 | struct list_head *plh; | ||
2317 | struct qeth_buffer_pool_entry *entry; | ||
2318 | int i, free; | ||
2319 | struct page *page; | ||
2320 | |||
2321 | if (list_empty(&card->qdio.in_buf_pool.entry_list)) | ||
2322 | return NULL; | ||
2323 | |||
2324 | list_for_each(plh, &card->qdio.in_buf_pool.entry_list) { | ||
2325 | entry = list_entry(plh, struct qeth_buffer_pool_entry, list); | ||
2326 | free = 1; | ||
2327 | for (i = 0; i < QETH_MAX_BUFFER_ELEMENTS(card); ++i) { | ||
2328 | if (page_count(virt_to_page(entry->elements[i])) > 1) { | ||
2329 | free = 0; | ||
2330 | break; | ||
2331 | } | ||
2332 | } | ||
2333 | if (free) { | ||
2334 | list_del_init(&entry->list); | ||
2335 | return entry; | ||
2336 | } | ||
2337 | } | ||
2338 | |||
2339 | /* no free buffer in pool so take first one and swap pages */ | ||
2340 | entry = list_entry(card->qdio.in_buf_pool.entry_list.next, | ||
2341 | struct qeth_buffer_pool_entry, list); | ||
2342 | for (i = 0; i < QETH_MAX_BUFFER_ELEMENTS(card); ++i) { | ||
2343 | if (page_count(virt_to_page(entry->elements[i])) > 1) { | ||
2344 | page = alloc_page(GFP_ATOMIC|GFP_DMA); | ||
2345 | if (!page) { | ||
2346 | return NULL; | ||
2347 | } else { | ||
2348 | free_page((unsigned long)entry->elements[i]); | ||
2349 | entry->elements[i] = page_address(page); | ||
2350 | if (card->options.performance_stats) | ||
2351 | card->perf_stats.sg_alloc_page_rx++; | ||
2352 | } | ||
2353 | } | ||
2354 | } | ||
2355 | list_del_init(&entry->list); | ||
2356 | return entry; | ||
2357 | } | ||
2358 | |||
2359 | static struct sk_buff * | ||
2360 | qeth_get_next_skb(struct qeth_card *card, struct qdio_buffer *buffer, | ||
2361 | struct qdio_buffer_element **__element, int *__offset, | ||
2362 | struct qeth_hdr **hdr) | ||
2363 | { | ||
2364 | struct qdio_buffer_element *element = *__element; | ||
2365 | int offset = *__offset; | ||
2366 | struct sk_buff *skb = NULL; | ||
2367 | int skb_len; | ||
2368 | void *data_ptr; | ||
2369 | int data_len; | ||
2370 | int use_rx_sg = 0; | ||
2371 | int frag = 0; | ||
2372 | |||
2373 | QETH_DBF_TEXT(trace,6,"nextskb"); | ||
2374 | /* qeth_hdr must not cross element boundaries */ | ||
2375 | if (element->length < offset + sizeof(struct qeth_hdr)){ | ||
2376 | if (qeth_is_last_sbale(element)) | ||
2377 | return NULL; | ||
2378 | element++; | ||
2379 | offset = 0; | ||
2380 | if (element->length < sizeof(struct qeth_hdr)) | ||
2381 | return NULL; | ||
2382 | } | ||
2383 | *hdr = element->addr + offset; | ||
2384 | |||
2385 | offset += sizeof(struct qeth_hdr); | ||
2386 | if (card->options.layer2) | ||
2387 | if (card->info.type == QETH_CARD_TYPE_OSN) | ||
2388 | skb_len = (*hdr)->hdr.osn.pdu_length; | ||
2389 | else | ||
2390 | skb_len = (*hdr)->hdr.l2.pkt_length; | ||
2391 | else | ||
2392 | skb_len = (*hdr)->hdr.l3.length; | ||
2393 | |||
2394 | if (!skb_len) | ||
2395 | return NULL; | ||
2396 | if ((skb_len >= card->options.rx_sg_cb) && | ||
2397 | (!(card->info.type == QETH_CARD_TYPE_OSN)) && | ||
2398 | (!atomic_read(&card->force_alloc_skb))) { | ||
2399 | use_rx_sg = 1; | ||
2400 | } else { | ||
2401 | if (card->options.fake_ll) { | ||
2402 | if (card->dev->type == ARPHRD_IEEE802_TR) { | ||
2403 | if (!(skb = qeth_get_skb(skb_len + | ||
2404 | QETH_FAKE_LL_LEN_TR, *hdr))) | ||
2405 | goto no_mem; | ||
2406 | skb_reserve(skb, QETH_FAKE_LL_LEN_TR); | ||
2407 | } else { | ||
2408 | if (!(skb = qeth_get_skb(skb_len + | ||
2409 | QETH_FAKE_LL_LEN_ETH, *hdr))) | ||
2410 | goto no_mem; | ||
2411 | skb_reserve(skb, QETH_FAKE_LL_LEN_ETH); | ||
2412 | } | ||
2413 | } else { | ||
2414 | skb = qeth_get_skb(skb_len, *hdr); | ||
2415 | if (!skb) | ||
2416 | goto no_mem; | ||
2417 | } | ||
2418 | } | ||
2419 | |||
2420 | data_ptr = element->addr + offset; | ||
2421 | while (skb_len) { | ||
2422 | data_len = min(skb_len, (int)(element->length - offset)); | ||
2423 | if (data_len) { | ||
2424 | if (use_rx_sg) { | ||
2425 | if (qeth_create_skb_frag(element, &skb, offset, | ||
2426 | &frag, data_len)) | ||
2427 | goto no_mem; | ||
2428 | } else { | ||
2429 | memcpy(skb_put(skb, data_len), data_ptr, | ||
2430 | data_len); | ||
2431 | } | ||
2432 | } | ||
2433 | skb_len -= data_len; | ||
2434 | if (skb_len){ | ||
2435 | if (qeth_is_last_sbale(element)){ | ||
2436 | QETH_DBF_TEXT(trace,4,"unexeob"); | ||
2437 | QETH_DBF_TEXT_(trace,4,"%s",CARD_BUS_ID(card)); | ||
2438 | QETH_DBF_TEXT(qerr,2,"unexeob"); | ||
2439 | QETH_DBF_TEXT_(qerr,2,"%s",CARD_BUS_ID(card)); | ||
2440 | QETH_DBF_HEX(misc,4,buffer,sizeof(*buffer)); | ||
2441 | dev_kfree_skb_any(skb); | ||
2442 | card->stats.rx_errors++; | ||
2443 | return NULL; | ||
2444 | } | ||
2445 | element++; | ||
2446 | offset = 0; | ||
2447 | data_ptr = element->addr; | ||
2448 | } else { | ||
2449 | offset += data_len; | ||
2450 | } | ||
2451 | } | ||
2452 | *__element = element; | ||
2453 | *__offset = offset; | ||
2454 | if (use_rx_sg && card->options.performance_stats) { | ||
2455 | card->perf_stats.sg_skbs_rx++; | ||
2456 | card->perf_stats.sg_frags_rx += skb_shinfo(skb)->nr_frags; | ||
2457 | } | ||
2458 | return skb; | ||
2459 | no_mem: | ||
2460 | if (net_ratelimit()){ | ||
2461 | PRINT_WARN("No memory for packet received on %s.\n", | ||
2462 | QETH_CARD_IFNAME(card)); | ||
2463 | QETH_DBF_TEXT(trace,2,"noskbmem"); | ||
2464 | QETH_DBF_TEXT_(trace,2,"%s",CARD_BUS_ID(card)); | ||
2465 | } | ||
2466 | card->stats.rx_dropped++; | ||
2467 | return NULL; | ||
2468 | } | ||
2469 | |||
2470 | static __be16 | ||
2471 | qeth_type_trans(struct sk_buff *skb, struct net_device *dev) | ||
2472 | { | ||
2473 | struct qeth_card *card; | ||
2474 | struct ethhdr *eth; | ||
2475 | |||
2476 | QETH_DBF_TEXT(trace,6,"typtrans"); | ||
2477 | |||
2478 | card = (struct qeth_card *)dev->priv; | ||
2479 | #ifdef CONFIG_TR | ||
2480 | if ((card->info.link_type == QETH_LINK_TYPE_HSTR) || | ||
2481 | (card->info.link_type == QETH_LINK_TYPE_LANE_TR)) | ||
2482 | return tr_type_trans(skb,dev); | ||
2483 | #endif /* CONFIG_TR */ | ||
2484 | skb_reset_mac_header(skb); | ||
2485 | skb_pull(skb, ETH_HLEN ); | ||
2486 | eth = eth_hdr(skb); | ||
2487 | |||
2488 | if (*eth->h_dest & 1) { | ||
2489 | if (memcmp(eth->h_dest, dev->broadcast, ETH_ALEN) == 0) | ||
2490 | skb->pkt_type = PACKET_BROADCAST; | ||
2491 | else | ||
2492 | skb->pkt_type = PACKET_MULTICAST; | ||
2493 | } else if (memcmp(eth->h_dest, dev->dev_addr, ETH_ALEN)) | ||
2494 | skb->pkt_type = PACKET_OTHERHOST; | ||
2495 | |||
2496 | if (ntohs(eth->h_proto) >= 1536) | ||
2497 | return eth->h_proto; | ||
2498 | if (*(unsigned short *) (skb->data) == 0xFFFF) | ||
2499 | return htons(ETH_P_802_3); | ||
2500 | return htons(ETH_P_802_2); | ||
2501 | } | ||
2502 | |||
2503 | static void | ||
2504 | qeth_rebuild_skb_fake_ll_tr(struct qeth_card *card, struct sk_buff *skb, | ||
2505 | struct qeth_hdr *hdr) | ||
2506 | { | ||
2507 | struct trh_hdr *fake_hdr; | ||
2508 | struct trllc *fake_llc; | ||
2509 | struct iphdr *ip_hdr; | ||
2510 | |||
2511 | QETH_DBF_TEXT(trace,5,"skbfktr"); | ||
2512 | skb_set_mac_header(skb, (int)-QETH_FAKE_LL_LEN_TR); | ||
2513 | /* this is a fake ethernet header */ | ||
2514 | fake_hdr = tr_hdr(skb); | ||
2515 | |||
2516 | /* the destination MAC address */ | ||
2517 | switch (skb->pkt_type){ | ||
2518 | case PACKET_MULTICAST: | ||
2519 | switch (skb->protocol){ | ||
2520 | #ifdef CONFIG_QETH_IPV6 | ||
2521 | case __constant_htons(ETH_P_IPV6): | ||
2522 | ndisc_mc_map((struct in6_addr *) | ||
2523 | skb->data + QETH_FAKE_LL_V6_ADDR_POS, | ||
2524 | fake_hdr->daddr, card->dev, 0); | ||
2525 | break; | ||
2526 | #endif /* CONFIG_QETH_IPV6 */ | ||
2527 | case __constant_htons(ETH_P_IP): | ||
2528 | ip_hdr = (struct iphdr *)skb->data; | ||
2529 | ip_tr_mc_map(ip_hdr->daddr, fake_hdr->daddr); | ||
2530 | break; | ||
2531 | default: | ||
2532 | memcpy(fake_hdr->daddr, card->dev->dev_addr, TR_ALEN); | ||
2533 | } | ||
2534 | break; | ||
2535 | case PACKET_BROADCAST: | ||
2536 | memset(fake_hdr->daddr, 0xff, TR_ALEN); | ||
2537 | break; | ||
2538 | default: | ||
2539 | memcpy(fake_hdr->daddr, card->dev->dev_addr, TR_ALEN); | ||
2540 | } | ||
2541 | /* the source MAC address */ | ||
2542 | if (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_SRC_MAC_ADDR) | ||
2543 | memcpy(fake_hdr->saddr, &hdr->hdr.l3.dest_addr[2], TR_ALEN); | ||
2544 | else | ||
2545 | memset(fake_hdr->saddr, 0, TR_ALEN); | ||
2546 | fake_hdr->rcf=0; | ||
2547 | fake_llc = (struct trllc*)&(fake_hdr->rcf); | ||
2548 | fake_llc->dsap = EXTENDED_SAP; | ||
2549 | fake_llc->ssap = EXTENDED_SAP; | ||
2550 | fake_llc->llc = UI_CMD; | ||
2551 | fake_llc->protid[0] = 0; | ||
2552 | fake_llc->protid[1] = 0; | ||
2553 | fake_llc->protid[2] = 0; | ||
2554 | fake_llc->ethertype = ETH_P_IP; | ||
2555 | } | ||
2556 | |||
2557 | static void | ||
2558 | qeth_rebuild_skb_fake_ll_eth(struct qeth_card *card, struct sk_buff *skb, | ||
2559 | struct qeth_hdr *hdr) | ||
2560 | { | ||
2561 | struct ethhdr *fake_hdr; | ||
2562 | struct iphdr *ip_hdr; | ||
2563 | |||
2564 | QETH_DBF_TEXT(trace,5,"skbfketh"); | ||
2565 | skb_set_mac_header(skb, -QETH_FAKE_LL_LEN_ETH); | ||
2566 | /* this is a fake ethernet header */ | ||
2567 | fake_hdr = eth_hdr(skb); | ||
2568 | |||
2569 | /* the destination MAC address */ | ||
2570 | switch (skb->pkt_type){ | ||
2571 | case PACKET_MULTICAST: | ||
2572 | switch (skb->protocol){ | ||
2573 | #ifdef CONFIG_QETH_IPV6 | ||
2574 | case __constant_htons(ETH_P_IPV6): | ||
2575 | ndisc_mc_map((struct in6_addr *) | ||
2576 | skb->data + QETH_FAKE_LL_V6_ADDR_POS, | ||
2577 | fake_hdr->h_dest, card->dev, 0); | ||
2578 | break; | ||
2579 | #endif /* CONFIG_QETH_IPV6 */ | ||
2580 | case __constant_htons(ETH_P_IP): | ||
2581 | ip_hdr = (struct iphdr *)skb->data; | ||
2582 | ip_eth_mc_map(ip_hdr->daddr, fake_hdr->h_dest); | ||
2583 | break; | ||
2584 | default: | ||
2585 | memcpy(fake_hdr->h_dest, card->dev->dev_addr, ETH_ALEN); | ||
2586 | } | ||
2587 | break; | ||
2588 | case PACKET_BROADCAST: | ||
2589 | memset(fake_hdr->h_dest, 0xff, ETH_ALEN); | ||
2590 | break; | ||
2591 | default: | ||
2592 | memcpy(fake_hdr->h_dest, card->dev->dev_addr, ETH_ALEN); | ||
2593 | } | ||
2594 | /* the source MAC address */ | ||
2595 | if (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_SRC_MAC_ADDR) | ||
2596 | memcpy(fake_hdr->h_source, &hdr->hdr.l3.dest_addr[2], ETH_ALEN); | ||
2597 | else | ||
2598 | memset(fake_hdr->h_source, 0, ETH_ALEN); | ||
2599 | /* the protocol */ | ||
2600 | fake_hdr->h_proto = skb->protocol; | ||
2601 | } | ||
2602 | |||
2603 | static inline void | ||
2604 | qeth_rebuild_skb_fake_ll(struct qeth_card *card, struct sk_buff *skb, | ||
2605 | struct qeth_hdr *hdr) | ||
2606 | { | ||
2607 | if (card->dev->type == ARPHRD_IEEE802_TR) | ||
2608 | qeth_rebuild_skb_fake_ll_tr(card, skb, hdr); | ||
2609 | else | ||
2610 | qeth_rebuild_skb_fake_ll_eth(card, skb, hdr); | ||
2611 | } | ||
2612 | |||
2613 | static inline void | ||
2614 | qeth_layer2_rebuild_skb(struct qeth_card *card, struct sk_buff *skb, | ||
2615 | struct qeth_hdr *hdr) | ||
2616 | { | ||
2617 | skb->pkt_type = PACKET_HOST; | ||
2618 | skb->protocol = qeth_type_trans(skb, skb->dev); | ||
2619 | if (card->options.checksum_type == NO_CHECKSUMMING) | ||
2620 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
2621 | else | ||
2622 | skb->ip_summed = CHECKSUM_NONE; | ||
2623 | *((__u32 *)skb->cb) = ++card->seqno.pkt_seqno; | ||
2624 | } | ||
2625 | |||
2626 | static __u16 | ||
2627 | qeth_rebuild_skb(struct qeth_card *card, struct sk_buff *skb, | ||
2628 | struct qeth_hdr *hdr) | ||
2629 | { | ||
2630 | unsigned short vlan_id = 0; | ||
2631 | #ifdef CONFIG_QETH_IPV6 | ||
2632 | if (hdr->hdr.l3.flags & QETH_HDR_PASSTHRU) { | ||
2633 | skb->pkt_type = PACKET_HOST; | ||
2634 | skb->protocol = qeth_type_trans(skb, card->dev); | ||
2635 | return 0; | ||
2636 | } | ||
2637 | #endif /* CONFIG_QETH_IPV6 */ | ||
2638 | skb->protocol = htons((hdr->hdr.l3.flags & QETH_HDR_IPV6)? ETH_P_IPV6 : | ||
2639 | ETH_P_IP); | ||
2640 | switch (hdr->hdr.l3.flags & QETH_HDR_CAST_MASK){ | ||
2641 | case QETH_CAST_UNICAST: | ||
2642 | skb->pkt_type = PACKET_HOST; | ||
2643 | break; | ||
2644 | case QETH_CAST_MULTICAST: | ||
2645 | skb->pkt_type = PACKET_MULTICAST; | ||
2646 | card->stats.multicast++; | ||
2647 | break; | ||
2648 | case QETH_CAST_BROADCAST: | ||
2649 | skb->pkt_type = PACKET_BROADCAST; | ||
2650 | card->stats.multicast++; | ||
2651 | break; | ||
2652 | case QETH_CAST_ANYCAST: | ||
2653 | case QETH_CAST_NOCAST: | ||
2654 | default: | ||
2655 | skb->pkt_type = PACKET_HOST; | ||
2656 | } | ||
2657 | |||
2658 | if (hdr->hdr.l3.ext_flags & | ||
2659 | (QETH_HDR_EXT_VLAN_FRAME | QETH_HDR_EXT_INCLUDE_VLAN_TAG)) { | ||
2660 | vlan_id = (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_VLAN_FRAME)? | ||
2661 | hdr->hdr.l3.vlan_id : *((u16 *)&hdr->hdr.l3.dest_addr[12]); | ||
2662 | } | ||
2663 | |||
2664 | if (card->options.fake_ll) | ||
2665 | qeth_rebuild_skb_fake_ll(card, skb, hdr); | ||
2666 | else | ||
2667 | skb_reset_mac_header(skb); | ||
2668 | skb->ip_summed = card->options.checksum_type; | ||
2669 | if (card->options.checksum_type == HW_CHECKSUMMING){ | ||
2670 | if ( (hdr->hdr.l3.ext_flags & | ||
2671 | (QETH_HDR_EXT_CSUM_HDR_REQ | | ||
2672 | QETH_HDR_EXT_CSUM_TRANSP_REQ)) == | ||
2673 | (QETH_HDR_EXT_CSUM_HDR_REQ | | ||
2674 | QETH_HDR_EXT_CSUM_TRANSP_REQ) ) | ||
2675 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
2676 | else | ||
2677 | skb->ip_summed = SW_CHECKSUMMING; | ||
2678 | } | ||
2679 | return vlan_id; | ||
2680 | } | ||
2681 | |||
2682 | static void | ||
2683 | qeth_process_inbound_buffer(struct qeth_card *card, | ||
2684 | struct qeth_qdio_buffer *buf, int index) | ||
2685 | { | ||
2686 | struct qdio_buffer_element *element; | ||
2687 | struct sk_buff *skb; | ||
2688 | struct qeth_hdr *hdr; | ||
2689 | int offset; | ||
2690 | int rxrc; | ||
2691 | __u16 vlan_tag = 0; | ||
2692 | |||
2693 | /* get first element of current buffer */ | ||
2694 | element = (struct qdio_buffer_element *)&buf->buffer->element[0]; | ||
2695 | offset = 0; | ||
2696 | if (card->options.performance_stats) | ||
2697 | card->perf_stats.bufs_rec++; | ||
2698 | while((skb = qeth_get_next_skb(card, buf->buffer, &element, | ||
2699 | &offset, &hdr))) { | ||
2700 | skb->dev = card->dev; | ||
2701 | if (hdr->hdr.l2.id == QETH_HEADER_TYPE_LAYER2) | ||
2702 | qeth_layer2_rebuild_skb(card, skb, hdr); | ||
2703 | else if (hdr->hdr.l3.id == QETH_HEADER_TYPE_LAYER3) | ||
2704 | vlan_tag = qeth_rebuild_skb(card, skb, hdr); | ||
2705 | else if (hdr->hdr.osn.id == QETH_HEADER_TYPE_OSN) { | ||
2706 | skb_push(skb, sizeof(struct qeth_hdr)); | ||
2707 | skb_copy_to_linear_data(skb, hdr, | ||
2708 | sizeof(struct qeth_hdr)); | ||
2709 | } else { /* unknown header type */ | ||
2710 | dev_kfree_skb_any(skb); | ||
2711 | QETH_DBF_TEXT(trace, 3, "inbunkno"); | ||
2712 | QETH_DBF_HEX(control, 3, hdr, QETH_DBF_CONTROL_LEN); | ||
2713 | continue; | ||
2714 | } | ||
2715 | /* is device UP ? */ | ||
2716 | if (!(card->dev->flags & IFF_UP)){ | ||
2717 | dev_kfree_skb_any(skb); | ||
2718 | continue; | ||
2719 | } | ||
2720 | if (card->info.type == QETH_CARD_TYPE_OSN) | ||
2721 | rxrc = card->osn_info.data_cb(skb); | ||
2722 | else | ||
2723 | #ifdef CONFIG_QETH_VLAN | ||
2724 | if (vlan_tag) | ||
2725 | if (card->vlangrp) | ||
2726 | vlan_hwaccel_rx(skb, card->vlangrp, vlan_tag); | ||
2727 | else { | ||
2728 | dev_kfree_skb_any(skb); | ||
2729 | continue; | ||
2730 | } | ||
2731 | else | ||
2732 | #endif | ||
2733 | rxrc = netif_rx(skb); | ||
2734 | card->dev->last_rx = jiffies; | ||
2735 | card->stats.rx_packets++; | ||
2736 | card->stats.rx_bytes += skb->len; | ||
2737 | } | ||
2738 | } | ||
2739 | |||
2740 | static int | ||
2741 | qeth_init_input_buffer(struct qeth_card *card, struct qeth_qdio_buffer *buf) | ||
2742 | { | ||
2743 | struct qeth_buffer_pool_entry *pool_entry; | ||
2744 | int i; | ||
2745 | |||
2746 | pool_entry = qeth_find_free_buffer_pool_entry(card); | ||
2747 | if (!pool_entry) | ||
2748 | return 1; | ||
2749 | /* | ||
2750 | * since the buffer is accessed only from the input_tasklet | ||
2751 | * there shouldn't be a need to synchronize; also, since we use | ||
2752 | * the QETH_IN_BUF_REQUEUE_THRESHOLD we should never run out off | ||
2753 | * buffers | ||
2754 | */ | ||
2755 | BUG_ON(!pool_entry); | ||
2756 | |||
2757 | buf->pool_entry = pool_entry; | ||
2758 | for(i = 0; i < QETH_MAX_BUFFER_ELEMENTS(card); ++i){ | ||
2759 | buf->buffer->element[i].length = PAGE_SIZE; | ||
2760 | buf->buffer->element[i].addr = pool_entry->elements[i]; | ||
2761 | if (i == QETH_MAX_BUFFER_ELEMENTS(card) - 1) | ||
2762 | buf->buffer->element[i].flags = SBAL_FLAGS_LAST_ENTRY; | ||
2763 | else | ||
2764 | buf->buffer->element[i].flags = 0; | ||
2765 | } | ||
2766 | buf->state = QETH_QDIO_BUF_EMPTY; | ||
2767 | return 0; | ||
2768 | } | ||
2769 | |||
2770 | static void | ||
2771 | qeth_clear_output_buffer(struct qeth_qdio_out_q *queue, | ||
2772 | struct qeth_qdio_out_buffer *buf) | ||
2773 | { | ||
2774 | int i; | ||
2775 | struct sk_buff *skb; | ||
2776 | |||
2777 | /* is PCI flag set on buffer? */ | ||
2778 | if (buf->buffer->element[0].flags & 0x40) | ||
2779 | atomic_dec(&queue->set_pci_flags_count); | ||
2780 | |||
2781 | while ((skb = skb_dequeue(&buf->skb_list))){ | ||
2782 | atomic_dec(&skb->users); | ||
2783 | dev_kfree_skb_any(skb); | ||
2784 | } | ||
2785 | qeth_eddp_buf_release_contexts(buf); | ||
2786 | for(i = 0; i < QETH_MAX_BUFFER_ELEMENTS(queue->card); ++i){ | ||
2787 | buf->buffer->element[i].length = 0; | ||
2788 | buf->buffer->element[i].addr = NULL; | ||
2789 | buf->buffer->element[i].flags = 0; | ||
2790 | } | ||
2791 | buf->next_element_to_fill = 0; | ||
2792 | atomic_set(&buf->state, QETH_QDIO_BUF_EMPTY); | ||
2793 | } | ||
2794 | |||
2795 | static void | ||
2796 | qeth_queue_input_buffer(struct qeth_card *card, int index) | ||
2797 | { | ||
2798 | struct qeth_qdio_q *queue = card->qdio.in_q; | ||
2799 | int count; | ||
2800 | int i; | ||
2801 | int rc; | ||
2802 | int newcount = 0; | ||
2803 | |||
2804 | QETH_DBF_TEXT(trace,6,"queinbuf"); | ||
2805 | count = (index < queue->next_buf_to_init)? | ||
2806 | card->qdio.in_buf_pool.buf_count - | ||
2807 | (queue->next_buf_to_init - index) : | ||
2808 | card->qdio.in_buf_pool.buf_count - | ||
2809 | (queue->next_buf_to_init + QDIO_MAX_BUFFERS_PER_Q - index); | ||
2810 | /* only requeue at a certain threshold to avoid SIGAs */ | ||
2811 | if (count >= QETH_IN_BUF_REQUEUE_THRESHOLD(card)){ | ||
2812 | for (i = queue->next_buf_to_init; | ||
2813 | i < queue->next_buf_to_init + count; ++i) { | ||
2814 | if (qeth_init_input_buffer(card, | ||
2815 | &queue->bufs[i % QDIO_MAX_BUFFERS_PER_Q])) { | ||
2816 | break; | ||
2817 | } else { | ||
2818 | newcount++; | ||
2819 | } | ||
2820 | } | ||
2821 | |||
2822 | if (newcount < count) { | ||
2823 | /* we are in memory shortage so we switch back to | ||
2824 | traditional skb allocation and drop packages */ | ||
2825 | if (!atomic_read(&card->force_alloc_skb) && | ||
2826 | net_ratelimit()) | ||
2827 | PRINT_WARN("Switch to alloc skb\n"); | ||
2828 | atomic_set(&card->force_alloc_skb, 3); | ||
2829 | count = newcount; | ||
2830 | } else { | ||
2831 | if ((atomic_read(&card->force_alloc_skb) == 1) && | ||
2832 | net_ratelimit()) | ||
2833 | PRINT_WARN("Switch to sg\n"); | ||
2834 | atomic_add_unless(&card->force_alloc_skb, -1, 0); | ||
2835 | } | ||
2836 | |||
2837 | /* | ||
2838 | * according to old code it should be avoided to requeue all | ||
2839 | * 128 buffers in order to benefit from PCI avoidance. | ||
2840 | * this function keeps at least one buffer (the buffer at | ||
2841 | * 'index') un-requeued -> this buffer is the first buffer that | ||
2842 | * will be requeued the next time | ||
2843 | */ | ||
2844 | if (card->options.performance_stats) { | ||
2845 | card->perf_stats.inbound_do_qdio_cnt++; | ||
2846 | card->perf_stats.inbound_do_qdio_start_time = | ||
2847 | qeth_get_micros(); | ||
2848 | } | ||
2849 | rc = do_QDIO(CARD_DDEV(card), | ||
2850 | QDIO_FLAG_SYNC_INPUT | QDIO_FLAG_UNDER_INTERRUPT, | ||
2851 | 0, queue->next_buf_to_init, count, NULL); | ||
2852 | if (card->options.performance_stats) | ||
2853 | card->perf_stats.inbound_do_qdio_time += | ||
2854 | qeth_get_micros() - | ||
2855 | card->perf_stats.inbound_do_qdio_start_time; | ||
2856 | if (rc){ | ||
2857 | PRINT_WARN("qeth_queue_input_buffer's do_QDIO " | ||
2858 | "return %i (device %s).\n", | ||
2859 | rc, CARD_DDEV_ID(card)); | ||
2860 | QETH_DBF_TEXT(trace,2,"qinberr"); | ||
2861 | QETH_DBF_TEXT_(trace,2,"%s",CARD_BUS_ID(card)); | ||
2862 | } | ||
2863 | queue->next_buf_to_init = (queue->next_buf_to_init + count) % | ||
2864 | QDIO_MAX_BUFFERS_PER_Q; | ||
2865 | } | ||
2866 | } | ||
2867 | |||
2868 | static inline void | ||
2869 | qeth_put_buffer_pool_entry(struct qeth_card *card, | ||
2870 | struct qeth_buffer_pool_entry *entry) | ||
2871 | { | ||
2872 | QETH_DBF_TEXT(trace, 6, "ptbfplen"); | ||
2873 | list_add_tail(&entry->list, &card->qdio.in_buf_pool.entry_list); | ||
2874 | } | ||
2875 | |||
2876 | static void | ||
2877 | qeth_qdio_input_handler(struct ccw_device * ccwdev, unsigned int status, | ||
2878 | unsigned int qdio_err, unsigned int siga_err, | ||
2879 | unsigned int queue, int first_element, int count, | ||
2880 | unsigned long card_ptr) | ||
2881 | { | ||
2882 | struct net_device *net_dev; | ||
2883 | struct qeth_card *card; | ||
2884 | struct qeth_qdio_buffer *buffer; | ||
2885 | int index; | ||
2886 | int i; | ||
2887 | |||
2888 | QETH_DBF_TEXT(trace, 6, "qdinput"); | ||
2889 | card = (struct qeth_card *) card_ptr; | ||
2890 | net_dev = card->dev; | ||
2891 | if (card->options.performance_stats) { | ||
2892 | card->perf_stats.inbound_cnt++; | ||
2893 | card->perf_stats.inbound_start_time = qeth_get_micros(); | ||
2894 | } | ||
2895 | if (status & QDIO_STATUS_LOOK_FOR_ERROR) { | ||
2896 | if (status & QDIO_STATUS_ACTIVATE_CHECK_CONDITION){ | ||
2897 | QETH_DBF_TEXT(trace, 1,"qdinchk"); | ||
2898 | QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card)); | ||
2899 | QETH_DBF_TEXT_(trace,1,"%04X%04X",first_element,count); | ||
2900 | QETH_DBF_TEXT_(trace,1,"%04X%04X", queue, status); | ||
2901 | qeth_schedule_recovery(card); | ||
2902 | return; | ||
2903 | } | ||
2904 | } | ||
2905 | for (i = first_element; i < (first_element + count); ++i) { | ||
2906 | index = i % QDIO_MAX_BUFFERS_PER_Q; | ||
2907 | buffer = &card->qdio.in_q->bufs[index]; | ||
2908 | if (!((status & QDIO_STATUS_LOOK_FOR_ERROR) && | ||
2909 | qeth_check_qdio_errors(buffer->buffer, | ||
2910 | qdio_err, siga_err,"qinerr"))) | ||
2911 | qeth_process_inbound_buffer(card, buffer, index); | ||
2912 | /* clear buffer and give back to hardware */ | ||
2913 | qeth_put_buffer_pool_entry(card, buffer->pool_entry); | ||
2914 | qeth_queue_input_buffer(card, index); | ||
2915 | } | ||
2916 | if (card->options.performance_stats) | ||
2917 | card->perf_stats.inbound_time += qeth_get_micros() - | ||
2918 | card->perf_stats.inbound_start_time; | ||
2919 | } | ||
2920 | |||
2921 | static int | ||
2922 | qeth_handle_send_error(struct qeth_card *card, | ||
2923 | struct qeth_qdio_out_buffer *buffer, | ||
2924 | unsigned int qdio_err, unsigned int siga_err) | ||
2925 | { | ||
2926 | int sbalf15 = buffer->buffer->element[15].flags & 0xff; | ||
2927 | int cc = siga_err & 3; | ||
2928 | |||
2929 | QETH_DBF_TEXT(trace, 6, "hdsnderr"); | ||
2930 | qeth_check_qdio_errors(buffer->buffer, qdio_err, siga_err, "qouterr"); | ||
2931 | switch (cc) { | ||
2932 | case 0: | ||
2933 | if (qdio_err){ | ||
2934 | QETH_DBF_TEXT(trace, 1,"lnkfail"); | ||
2935 | QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card)); | ||
2936 | QETH_DBF_TEXT_(trace,1,"%04x %02x", | ||
2937 | (u16)qdio_err, (u8)sbalf15); | ||
2938 | return QETH_SEND_ERROR_LINK_FAILURE; | ||
2939 | } | ||
2940 | return QETH_SEND_ERROR_NONE; | ||
2941 | case 2: | ||
2942 | if (siga_err & QDIO_SIGA_ERROR_B_BIT_SET) { | ||
2943 | QETH_DBF_TEXT(trace, 1, "SIGAcc2B"); | ||
2944 | QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card)); | ||
2945 | return QETH_SEND_ERROR_KICK_IT; | ||
2946 | } | ||
2947 | if ((sbalf15 >= 15) && (sbalf15 <= 31)) | ||
2948 | return QETH_SEND_ERROR_RETRY; | ||
2949 | return QETH_SEND_ERROR_LINK_FAILURE; | ||
2950 | /* look at qdio_error and sbalf 15 */ | ||
2951 | case 1: | ||
2952 | QETH_DBF_TEXT(trace, 1, "SIGAcc1"); | ||
2953 | QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card)); | ||
2954 | return QETH_SEND_ERROR_LINK_FAILURE; | ||
2955 | case 3: | ||
2956 | default: | ||
2957 | QETH_DBF_TEXT(trace, 1, "SIGAcc3"); | ||
2958 | QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card)); | ||
2959 | return QETH_SEND_ERROR_KICK_IT; | ||
2960 | } | ||
2961 | } | ||
2962 | |||
2963 | void | ||
2964 | qeth_flush_buffers(struct qeth_qdio_out_q *queue, int under_int, | ||
2965 | int index, int count) | ||
2966 | { | ||
2967 | struct qeth_qdio_out_buffer *buf; | ||
2968 | int rc; | ||
2969 | int i; | ||
2970 | unsigned int qdio_flags; | ||
2971 | |||
2972 | QETH_DBF_TEXT(trace, 6, "flushbuf"); | ||
2973 | |||
2974 | for (i = index; i < index + count; ++i) { | ||
2975 | buf = &queue->bufs[i % QDIO_MAX_BUFFERS_PER_Q]; | ||
2976 | buf->buffer->element[buf->next_element_to_fill - 1].flags |= | ||
2977 | SBAL_FLAGS_LAST_ENTRY; | ||
2978 | |||
2979 | if (queue->card->info.type == QETH_CARD_TYPE_IQD) | ||
2980 | continue; | ||
2981 | |||
2982 | if (!queue->do_pack){ | ||
2983 | if ((atomic_read(&queue->used_buffers) >= | ||
2984 | (QETH_HIGH_WATERMARK_PACK - | ||
2985 | QETH_WATERMARK_PACK_FUZZ)) && | ||
2986 | !atomic_read(&queue->set_pci_flags_count)){ | ||
2987 | /* it's likely that we'll go to packing | ||
2988 | * mode soon */ | ||
2989 | atomic_inc(&queue->set_pci_flags_count); | ||
2990 | buf->buffer->element[0].flags |= 0x40; | ||
2991 | } | ||
2992 | } else { | ||
2993 | if (!atomic_read(&queue->set_pci_flags_count)){ | ||
2994 | /* | ||
2995 | * there's no outstanding PCI any more, so we | ||
2996 | * have to request a PCI to be sure that the PCI | ||
2997 | * will wake at some time in the future then we | ||
2998 | * can flush packed buffers that might still be | ||
2999 | * hanging around, which can happen if no | ||
3000 | * further send was requested by the stack | ||
3001 | */ | ||
3002 | atomic_inc(&queue->set_pci_flags_count); | ||
3003 | buf->buffer->element[0].flags |= 0x40; | ||
3004 | } | ||
3005 | } | ||
3006 | } | ||
3007 | |||
3008 | queue->card->dev->trans_start = jiffies; | ||
3009 | if (queue->card->options.performance_stats) { | ||
3010 | queue->card->perf_stats.outbound_do_qdio_cnt++; | ||
3011 | queue->card->perf_stats.outbound_do_qdio_start_time = | ||
3012 | qeth_get_micros(); | ||
3013 | } | ||
3014 | qdio_flags = QDIO_FLAG_SYNC_OUTPUT; | ||
3015 | if (under_int) | ||
3016 | qdio_flags |= QDIO_FLAG_UNDER_INTERRUPT; | ||
3017 | if (atomic_read(&queue->set_pci_flags_count)) | ||
3018 | qdio_flags |= QDIO_FLAG_PCI_OUT; | ||
3019 | rc = do_QDIO(CARD_DDEV(queue->card), qdio_flags, | ||
3020 | queue->queue_no, index, count, NULL); | ||
3021 | if (queue->card->options.performance_stats) | ||
3022 | queue->card->perf_stats.outbound_do_qdio_time += | ||
3023 | qeth_get_micros() - | ||
3024 | queue->card->perf_stats.outbound_do_qdio_start_time; | ||
3025 | if (rc){ | ||
3026 | QETH_DBF_TEXT(trace, 2, "flushbuf"); | ||
3027 | QETH_DBF_TEXT_(trace, 2, " err%d", rc); | ||
3028 | QETH_DBF_TEXT_(trace, 2, "%s", CARD_DDEV_ID(queue->card)); | ||
3029 | queue->card->stats.tx_errors += count; | ||
3030 | /* this must not happen under normal circumstances. if it | ||
3031 | * happens something is really wrong -> recover */ | ||
3032 | qeth_schedule_recovery(queue->card); | ||
3033 | return; | ||
3034 | } | ||
3035 | atomic_add(count, &queue->used_buffers); | ||
3036 | if (queue->card->options.performance_stats) | ||
3037 | queue->card->perf_stats.bufs_sent += count; | ||
3038 | } | ||
3039 | |||
3040 | /* | ||
3041 | * Switched to packing state if the number of used buffers on a queue | ||
3042 | * reaches a certain limit. | ||
3043 | */ | ||
3044 | static void | ||
3045 | qeth_switch_to_packing_if_needed(struct qeth_qdio_out_q *queue) | ||
3046 | { | ||
3047 | if (!queue->do_pack) { | ||
3048 | if (atomic_read(&queue->used_buffers) | ||
3049 | >= QETH_HIGH_WATERMARK_PACK){ | ||
3050 | /* switch non-PACKING -> PACKING */ | ||
3051 | QETH_DBF_TEXT(trace, 6, "np->pack"); | ||
3052 | if (queue->card->options.performance_stats) | ||
3053 | queue->card->perf_stats.sc_dp_p++; | ||
3054 | queue->do_pack = 1; | ||
3055 | } | ||
3056 | } | ||
3057 | } | ||
3058 | |||
3059 | /* | ||
3060 | * Switches from packing to non-packing mode. If there is a packing | ||
3061 | * buffer on the queue this buffer will be prepared to be flushed. | ||
3062 | * In that case 1 is returned to inform the caller. If no buffer | ||
3063 | * has to be flushed, zero is returned. | ||
3064 | */ | ||
3065 | static int | ||
3066 | qeth_switch_to_nonpacking_if_needed(struct qeth_qdio_out_q *queue) | ||
3067 | { | ||
3068 | struct qeth_qdio_out_buffer *buffer; | ||
3069 | int flush_count = 0; | ||
3070 | |||
3071 | if (queue->do_pack) { | ||
3072 | if (atomic_read(&queue->used_buffers) | ||
3073 | <= QETH_LOW_WATERMARK_PACK) { | ||
3074 | /* switch PACKING -> non-PACKING */ | ||
3075 | QETH_DBF_TEXT(trace, 6, "pack->np"); | ||
3076 | if (queue->card->options.performance_stats) | ||
3077 | queue->card->perf_stats.sc_p_dp++; | ||
3078 | queue->do_pack = 0; | ||
3079 | /* flush packing buffers */ | ||
3080 | buffer = &queue->bufs[queue->next_buf_to_fill]; | ||
3081 | if ((atomic_read(&buffer->state) == | ||
3082 | QETH_QDIO_BUF_EMPTY) && | ||
3083 | (buffer->next_element_to_fill > 0)) { | ||
3084 | atomic_set(&buffer->state,QETH_QDIO_BUF_PRIMED); | ||
3085 | flush_count++; | ||
3086 | queue->next_buf_to_fill = | ||
3087 | (queue->next_buf_to_fill + 1) % | ||
3088 | QDIO_MAX_BUFFERS_PER_Q; | ||
3089 | } | ||
3090 | } | ||
3091 | } | ||
3092 | return flush_count; | ||
3093 | } | ||
3094 | |||
3095 | /* | ||
3096 | * Called to flush a packing buffer if no more pci flags are on the queue. | ||
3097 | * Checks if there is a packing buffer and prepares it to be flushed. | ||
3098 | * In that case returns 1, otherwise zero. | ||
3099 | */ | ||
3100 | static int | ||
3101 | qeth_flush_buffers_on_no_pci(struct qeth_qdio_out_q *queue) | ||
3102 | { | ||
3103 | struct qeth_qdio_out_buffer *buffer; | ||
3104 | |||
3105 | buffer = &queue->bufs[queue->next_buf_to_fill]; | ||
3106 | if((atomic_read(&buffer->state) == QETH_QDIO_BUF_EMPTY) && | ||
3107 | (buffer->next_element_to_fill > 0)){ | ||
3108 | /* it's a packing buffer */ | ||
3109 | atomic_set(&buffer->state, QETH_QDIO_BUF_PRIMED); | ||
3110 | queue->next_buf_to_fill = | ||
3111 | (queue->next_buf_to_fill + 1) % QDIO_MAX_BUFFERS_PER_Q; | ||
3112 | return 1; | ||
3113 | } | ||
3114 | return 0; | ||
3115 | } | ||
3116 | |||
3117 | static void | ||
3118 | qeth_check_outbound_queue(struct qeth_qdio_out_q *queue) | ||
3119 | { | ||
3120 | int index; | ||
3121 | int flush_cnt = 0; | ||
3122 | int q_was_packing = 0; | ||
3123 | |||
3124 | /* | ||
3125 | * check if weed have to switch to non-packing mode or if | ||
3126 | * we have to get a pci flag out on the queue | ||
3127 | */ | ||
3128 | if ((atomic_read(&queue->used_buffers) <= QETH_LOW_WATERMARK_PACK) || | ||
3129 | !atomic_read(&queue->set_pci_flags_count)){ | ||
3130 | if (atomic_xchg(&queue->state, QETH_OUT_Q_LOCKED_FLUSH) == | ||
3131 | QETH_OUT_Q_UNLOCKED) { | ||
3132 | /* | ||
3133 | * If we get in here, there was no action in | ||
3134 | * do_send_packet. So, we check if there is a | ||
3135 | * packing buffer to be flushed here. | ||
3136 | */ | ||
3137 | netif_stop_queue(queue->card->dev); | ||
3138 | index = queue->next_buf_to_fill; | ||
3139 | q_was_packing = queue->do_pack; | ||
3140 | flush_cnt += qeth_switch_to_nonpacking_if_needed(queue); | ||
3141 | if (!flush_cnt && | ||
3142 | !atomic_read(&queue->set_pci_flags_count)) | ||
3143 | flush_cnt += | ||
3144 | qeth_flush_buffers_on_no_pci(queue); | ||
3145 | if (queue->card->options.performance_stats && | ||
3146 | q_was_packing) | ||
3147 | queue->card->perf_stats.bufs_sent_pack += | ||
3148 | flush_cnt; | ||
3149 | if (flush_cnt) | ||
3150 | qeth_flush_buffers(queue, 1, index, flush_cnt); | ||
3151 | atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); | ||
3152 | } | ||
3153 | } | ||
3154 | } | ||
3155 | |||
3156 | static void | ||
3157 | qeth_qdio_output_handler(struct ccw_device * ccwdev, unsigned int status, | ||
3158 | unsigned int qdio_error, unsigned int siga_error, | ||
3159 | unsigned int __queue, int first_element, int count, | ||
3160 | unsigned long card_ptr) | ||
3161 | { | ||
3162 | struct qeth_card *card = (struct qeth_card *) card_ptr; | ||
3163 | struct qeth_qdio_out_q *queue = card->qdio.out_qs[__queue]; | ||
3164 | struct qeth_qdio_out_buffer *buffer; | ||
3165 | int i; | ||
3166 | |||
3167 | QETH_DBF_TEXT(trace, 6, "qdouhdl"); | ||
3168 | if (status & QDIO_STATUS_LOOK_FOR_ERROR) { | ||
3169 | if (status & QDIO_STATUS_ACTIVATE_CHECK_CONDITION){ | ||
3170 | QETH_DBF_TEXT(trace, 2, "achkcond"); | ||
3171 | QETH_DBF_TEXT_(trace, 2, "%s", CARD_BUS_ID(card)); | ||
3172 | QETH_DBF_TEXT_(trace, 2, "%08x", status); | ||
3173 | netif_stop_queue(card->dev); | ||
3174 | qeth_schedule_recovery(card); | ||
3175 | return; | ||
3176 | } | ||
3177 | } | ||
3178 | if (card->options.performance_stats) { | ||
3179 | card->perf_stats.outbound_handler_cnt++; | ||
3180 | card->perf_stats.outbound_handler_start_time = | ||
3181 | qeth_get_micros(); | ||
3182 | } | ||
3183 | for(i = first_element; i < (first_element + count); ++i){ | ||
3184 | buffer = &queue->bufs[i % QDIO_MAX_BUFFERS_PER_Q]; | ||
3185 | /*we only handle the KICK_IT error by doing a recovery */ | ||
3186 | if (qeth_handle_send_error(card, buffer, | ||
3187 | qdio_error, siga_error) | ||
3188 | == QETH_SEND_ERROR_KICK_IT){ | ||
3189 | netif_stop_queue(card->dev); | ||
3190 | qeth_schedule_recovery(card); | ||
3191 | return; | ||
3192 | } | ||
3193 | qeth_clear_output_buffer(queue, buffer); | ||
3194 | } | ||
3195 | atomic_sub(count, &queue->used_buffers); | ||
3196 | /* check if we need to do something on this outbound queue */ | ||
3197 | if (card->info.type != QETH_CARD_TYPE_IQD) | ||
3198 | qeth_check_outbound_queue(queue); | ||
3199 | |||
3200 | netif_wake_queue(queue->card->dev); | ||
3201 | if (card->options.performance_stats) | ||
3202 | card->perf_stats.outbound_handler_time += qeth_get_micros() - | ||
3203 | card->perf_stats.outbound_handler_start_time; | ||
3204 | } | ||
3205 | |||
3206 | static void | ||
3207 | qeth_create_qib_param_field(struct qeth_card *card, char *param_field) | ||
3208 | { | ||
3209 | |||
3210 | param_field[0] = _ascebc['P']; | ||
3211 | param_field[1] = _ascebc['C']; | ||
3212 | param_field[2] = _ascebc['I']; | ||
3213 | param_field[3] = _ascebc['T']; | ||
3214 | *((unsigned int *) (¶m_field[4])) = QETH_PCI_THRESHOLD_A(card); | ||
3215 | *((unsigned int *) (¶m_field[8])) = QETH_PCI_THRESHOLD_B(card); | ||
3216 | *((unsigned int *) (¶m_field[12])) = QETH_PCI_TIMER_VALUE(card); | ||
3217 | } | ||
3218 | |||
3219 | static void | ||
3220 | qeth_create_qib_param_field_blkt(struct qeth_card *card, char *param_field) | ||
3221 | { | ||
3222 | param_field[16] = _ascebc['B']; | ||
3223 | param_field[17] = _ascebc['L']; | ||
3224 | param_field[18] = _ascebc['K']; | ||
3225 | param_field[19] = _ascebc['T']; | ||
3226 | *((unsigned int *) (¶m_field[20])) = card->info.blkt.time_total; | ||
3227 | *((unsigned int *) (¶m_field[24])) = card->info.blkt.inter_packet; | ||
3228 | *((unsigned int *) (¶m_field[28])) = card->info.blkt.inter_packet_jumbo; | ||
3229 | } | ||
3230 | |||
3231 | static void | ||
3232 | qeth_initialize_working_pool_list(struct qeth_card *card) | ||
3233 | { | ||
3234 | struct qeth_buffer_pool_entry *entry; | ||
3235 | |||
3236 | QETH_DBF_TEXT(trace,5,"inwrklst"); | ||
3237 | |||
3238 | list_for_each_entry(entry, | ||
3239 | &card->qdio.init_pool.entry_list, init_list) { | ||
3240 | qeth_put_buffer_pool_entry(card,entry); | ||
3241 | } | ||
3242 | } | ||
3243 | |||
3244 | static void | ||
3245 | qeth_clear_working_pool_list(struct qeth_card *card) | ||
3246 | { | ||
3247 | struct qeth_buffer_pool_entry *pool_entry, *tmp; | ||
3248 | |||
3249 | QETH_DBF_TEXT(trace,5,"clwrklst"); | ||
3250 | list_for_each_entry_safe(pool_entry, tmp, | ||
3251 | &card->qdio.in_buf_pool.entry_list, list){ | ||
3252 | list_del(&pool_entry->list); | ||
3253 | } | ||
3254 | } | ||
3255 | |||
3256 | static void | ||
3257 | qeth_free_buffer_pool(struct qeth_card *card) | ||
3258 | { | ||
3259 | struct qeth_buffer_pool_entry *pool_entry, *tmp; | ||
3260 | int i=0; | ||
3261 | QETH_DBF_TEXT(trace,5,"freepool"); | ||
3262 | list_for_each_entry_safe(pool_entry, tmp, | ||
3263 | &card->qdio.init_pool.entry_list, init_list){ | ||
3264 | for (i = 0; i < QETH_MAX_BUFFER_ELEMENTS(card); ++i) | ||
3265 | free_page((unsigned long)pool_entry->elements[i]); | ||
3266 | list_del(&pool_entry->init_list); | ||
3267 | kfree(pool_entry); | ||
3268 | } | ||
3269 | } | ||
3270 | |||
3271 | static int | ||
3272 | qeth_alloc_buffer_pool(struct qeth_card *card) | ||
3273 | { | ||
3274 | struct qeth_buffer_pool_entry *pool_entry; | ||
3275 | void *ptr; | ||
3276 | int i, j; | ||
3277 | |||
3278 | QETH_DBF_TEXT(trace,5,"alocpool"); | ||
3279 | for (i = 0; i < card->qdio.init_pool.buf_count; ++i){ | ||
3280 | pool_entry = kmalloc(sizeof(*pool_entry), GFP_KERNEL); | ||
3281 | if (!pool_entry){ | ||
3282 | qeth_free_buffer_pool(card); | ||
3283 | return -ENOMEM; | ||
3284 | } | ||
3285 | for(j = 0; j < QETH_MAX_BUFFER_ELEMENTS(card); ++j){ | ||
3286 | ptr = (void *) __get_free_page(GFP_KERNEL|GFP_DMA); | ||
3287 | if (!ptr) { | ||
3288 | while (j > 0) | ||
3289 | free_page((unsigned long) | ||
3290 | pool_entry->elements[--j]); | ||
3291 | kfree(pool_entry); | ||
3292 | qeth_free_buffer_pool(card); | ||
3293 | return -ENOMEM; | ||
3294 | } | ||
3295 | pool_entry->elements[j] = ptr; | ||
3296 | } | ||
3297 | list_add(&pool_entry->init_list, | ||
3298 | &card->qdio.init_pool.entry_list); | ||
3299 | } | ||
3300 | return 0; | ||
3301 | } | ||
3302 | |||
3303 | int | ||
3304 | qeth_realloc_buffer_pool(struct qeth_card *card, int bufcnt) | ||
3305 | { | ||
3306 | QETH_DBF_TEXT(trace, 2, "realcbp"); | ||
3307 | |||
3308 | if ((card->state != CARD_STATE_DOWN) && | ||
3309 | (card->state != CARD_STATE_RECOVER)) | ||
3310 | return -EPERM; | ||
3311 | |||
3312 | /* TODO: steel/add buffers from/to a running card's buffer pool (?) */ | ||
3313 | qeth_clear_working_pool_list(card); | ||
3314 | qeth_free_buffer_pool(card); | ||
3315 | card->qdio.in_buf_pool.buf_count = bufcnt; | ||
3316 | card->qdio.init_pool.buf_count = bufcnt; | ||
3317 | return qeth_alloc_buffer_pool(card); | ||
3318 | } | ||
3319 | |||
3320 | static int | ||
3321 | qeth_alloc_qdio_buffers(struct qeth_card *card) | ||
3322 | { | ||
3323 | int i, j; | ||
3324 | |||
3325 | QETH_DBF_TEXT(setup, 2, "allcqdbf"); | ||
3326 | |||
3327 | if (atomic_cmpxchg(&card->qdio.state, QETH_QDIO_UNINITIALIZED, | ||
3328 | QETH_QDIO_ALLOCATED) != QETH_QDIO_UNINITIALIZED) | ||
3329 | return 0; | ||
3330 | |||
3331 | card->qdio.in_q = kmalloc(sizeof(struct qeth_qdio_q), | ||
3332 | GFP_KERNEL|GFP_DMA); | ||
3333 | if (!card->qdio.in_q) | ||
3334 | goto out_nomem; | ||
3335 | QETH_DBF_TEXT(setup, 2, "inq"); | ||
3336 | QETH_DBF_HEX(setup, 2, &card->qdio.in_q, sizeof(void *)); | ||
3337 | memset(card->qdio.in_q, 0, sizeof(struct qeth_qdio_q)); | ||
3338 | /* give inbound qeth_qdio_buffers their qdio_buffers */ | ||
3339 | for (i = 0; i < QDIO_MAX_BUFFERS_PER_Q; ++i) | ||
3340 | card->qdio.in_q->bufs[i].buffer = | ||
3341 | &card->qdio.in_q->qdio_bufs[i]; | ||
3342 | /* inbound buffer pool */ | ||
3343 | if (qeth_alloc_buffer_pool(card)) | ||
3344 | goto out_freeinq; | ||
3345 | /* outbound */ | ||
3346 | card->qdio.out_qs = | ||
3347 | kmalloc(card->qdio.no_out_queues * | ||
3348 | sizeof(struct qeth_qdio_out_q *), GFP_KERNEL); | ||
3349 | if (!card->qdio.out_qs) | ||
3350 | goto out_freepool; | ||
3351 | for (i = 0; i < card->qdio.no_out_queues; ++i) { | ||
3352 | card->qdio.out_qs[i] = kmalloc(sizeof(struct qeth_qdio_out_q), | ||
3353 | GFP_KERNEL|GFP_DMA); | ||
3354 | if (!card->qdio.out_qs[i]) | ||
3355 | goto out_freeoutq; | ||
3356 | QETH_DBF_TEXT_(setup, 2, "outq %i", i); | ||
3357 | QETH_DBF_HEX(setup, 2, &card->qdio.out_qs[i], sizeof(void *)); | ||
3358 | memset(card->qdio.out_qs[i], 0, sizeof(struct qeth_qdio_out_q)); | ||
3359 | card->qdio.out_qs[i]->queue_no = i; | ||
3360 | /* give outbound qeth_qdio_buffers their qdio_buffers */ | ||
3361 | for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j){ | ||
3362 | card->qdio.out_qs[i]->bufs[j].buffer = | ||
3363 | &card->qdio.out_qs[i]->qdio_bufs[j]; | ||
3364 | skb_queue_head_init(&card->qdio.out_qs[i]->bufs[j]. | ||
3365 | skb_list); | ||
3366 | lockdep_set_class( | ||
3367 | &card->qdio.out_qs[i]->bufs[j].skb_list.lock, | ||
3368 | &qdio_out_skb_queue_key); | ||
3369 | INIT_LIST_HEAD(&card->qdio.out_qs[i]->bufs[j].ctx_list); | ||
3370 | } | ||
3371 | } | ||
3372 | return 0; | ||
3373 | |||
3374 | out_freeoutq: | ||
3375 | while (i > 0) | ||
3376 | kfree(card->qdio.out_qs[--i]); | ||
3377 | kfree(card->qdio.out_qs); | ||
3378 | card->qdio.out_qs = NULL; | ||
3379 | out_freepool: | ||
3380 | qeth_free_buffer_pool(card); | ||
3381 | out_freeinq: | ||
3382 | kfree(card->qdio.in_q); | ||
3383 | card->qdio.in_q = NULL; | ||
3384 | out_nomem: | ||
3385 | atomic_set(&card->qdio.state, QETH_QDIO_UNINITIALIZED); | ||
3386 | return -ENOMEM; | ||
3387 | } | ||
3388 | |||
3389 | static void | ||
3390 | qeth_free_qdio_buffers(struct qeth_card *card) | ||
3391 | { | ||
3392 | int i, j; | ||
3393 | |||
3394 | QETH_DBF_TEXT(trace, 2, "freeqdbf"); | ||
3395 | if (atomic_xchg(&card->qdio.state, QETH_QDIO_UNINITIALIZED) == | ||
3396 | QETH_QDIO_UNINITIALIZED) | ||
3397 | return; | ||
3398 | kfree(card->qdio.in_q); | ||
3399 | card->qdio.in_q = NULL; | ||
3400 | /* inbound buffer pool */ | ||
3401 | qeth_free_buffer_pool(card); | ||
3402 | /* free outbound qdio_qs */ | ||
3403 | if (card->qdio.out_qs) { | ||
3404 | for (i = 0; i < card->qdio.no_out_queues; ++i) { | ||
3405 | for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j) | ||
3406 | qeth_clear_output_buffer(card->qdio.out_qs[i], | ||
3407 | &card->qdio.out_qs[i]->bufs[j]); | ||
3408 | kfree(card->qdio.out_qs[i]); | ||
3409 | } | ||
3410 | kfree(card->qdio.out_qs); | ||
3411 | card->qdio.out_qs = NULL; | ||
3412 | } | ||
3413 | } | ||
3414 | |||
3415 | static void | ||
3416 | qeth_clear_qdio_buffers(struct qeth_card *card) | ||
3417 | { | ||
3418 | int i, j; | ||
3419 | |||
3420 | QETH_DBF_TEXT(trace, 2, "clearqdbf"); | ||
3421 | /* clear outbound buffers to free skbs */ | ||
3422 | for (i = 0; i < card->qdio.no_out_queues; ++i) | ||
3423 | if (card->qdio.out_qs && card->qdio.out_qs[i]) { | ||
3424 | for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j) | ||
3425 | qeth_clear_output_buffer(card->qdio.out_qs[i], | ||
3426 | &card->qdio.out_qs[i]->bufs[j]); | ||
3427 | } | ||
3428 | } | ||
3429 | |||
3430 | static void | ||
3431 | qeth_init_qdio_info(struct qeth_card *card) | ||
3432 | { | ||
3433 | QETH_DBF_TEXT(setup, 4, "intqdinf"); | ||
3434 | atomic_set(&card->qdio.state, QETH_QDIO_UNINITIALIZED); | ||
3435 | /* inbound */ | ||
3436 | card->qdio.in_buf_size = QETH_IN_BUF_SIZE_DEFAULT; | ||
3437 | card->qdio.init_pool.buf_count = QETH_IN_BUF_COUNT_DEFAULT; | ||
3438 | card->qdio.in_buf_pool.buf_count = card->qdio.init_pool.buf_count; | ||
3439 | INIT_LIST_HEAD(&card->qdio.in_buf_pool.entry_list); | ||
3440 | INIT_LIST_HEAD(&card->qdio.init_pool.entry_list); | ||
3441 | } | ||
3442 | |||
3443 | static int | ||
3444 | qeth_init_qdio_queues(struct qeth_card *card) | ||
3445 | { | ||
3446 | int i, j; | ||
3447 | int rc; | ||
3448 | |||
3449 | QETH_DBF_TEXT(setup, 2, "initqdqs"); | ||
3450 | |||
3451 | /* inbound queue */ | ||
3452 | memset(card->qdio.in_q->qdio_bufs, 0, | ||
3453 | QDIO_MAX_BUFFERS_PER_Q * sizeof(struct qdio_buffer)); | ||
3454 | qeth_initialize_working_pool_list(card); | ||
3455 | /*give only as many buffers to hardware as we have buffer pool entries*/ | ||
3456 | for (i = 0; i < card->qdio.in_buf_pool.buf_count - 1; ++i) | ||
3457 | qeth_init_input_buffer(card, &card->qdio.in_q->bufs[i]); | ||
3458 | card->qdio.in_q->next_buf_to_init = card->qdio.in_buf_pool.buf_count - 1; | ||
3459 | rc = do_QDIO(CARD_DDEV(card), QDIO_FLAG_SYNC_INPUT, 0, 0, | ||
3460 | card->qdio.in_buf_pool.buf_count - 1, NULL); | ||
3461 | if (rc) { | ||
3462 | QETH_DBF_TEXT_(setup, 2, "1err%d", rc); | ||
3463 | return rc; | ||
3464 | } | ||
3465 | rc = qdio_synchronize(CARD_DDEV(card), QDIO_FLAG_SYNC_INPUT, 0); | ||
3466 | if (rc) { | ||
3467 | QETH_DBF_TEXT_(setup, 2, "2err%d", rc); | ||
3468 | return rc; | ||
3469 | } | ||
3470 | /* outbound queue */ | ||
3471 | for (i = 0; i < card->qdio.no_out_queues; ++i){ | ||
3472 | memset(card->qdio.out_qs[i]->qdio_bufs, 0, | ||
3473 | QDIO_MAX_BUFFERS_PER_Q * sizeof(struct qdio_buffer)); | ||
3474 | for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j){ | ||
3475 | qeth_clear_output_buffer(card->qdio.out_qs[i], | ||
3476 | &card->qdio.out_qs[i]->bufs[j]); | ||
3477 | } | ||
3478 | card->qdio.out_qs[i]->card = card; | ||
3479 | card->qdio.out_qs[i]->next_buf_to_fill = 0; | ||
3480 | card->qdio.out_qs[i]->do_pack = 0; | ||
3481 | atomic_set(&card->qdio.out_qs[i]->used_buffers,0); | ||
3482 | atomic_set(&card->qdio.out_qs[i]->set_pci_flags_count, 0); | ||
3483 | atomic_set(&card->qdio.out_qs[i]->state, | ||
3484 | QETH_OUT_Q_UNLOCKED); | ||
3485 | } | ||
3486 | return 0; | ||
3487 | } | ||
3488 | |||
3489 | static int | ||
3490 | qeth_qdio_establish(struct qeth_card *card) | ||
3491 | { | ||
3492 | struct qdio_initialize init_data; | ||
3493 | char *qib_param_field; | ||
3494 | struct qdio_buffer **in_sbal_ptrs; | ||
3495 | struct qdio_buffer **out_sbal_ptrs; | ||
3496 | int i, j, k; | ||
3497 | int rc = 0; | ||
3498 | |||
3499 | QETH_DBF_TEXT(setup, 2, "qdioest"); | ||
3500 | |||
3501 | qib_param_field = kzalloc(QDIO_MAX_BUFFERS_PER_Q * sizeof(char), | ||
3502 | GFP_KERNEL); | ||
3503 | if (!qib_param_field) | ||
3504 | return -ENOMEM; | ||
3505 | |||
3506 | qeth_create_qib_param_field(card, qib_param_field); | ||
3507 | qeth_create_qib_param_field_blkt(card, qib_param_field); | ||
3508 | |||
3509 | in_sbal_ptrs = kmalloc(QDIO_MAX_BUFFERS_PER_Q * sizeof(void *), | ||
3510 | GFP_KERNEL); | ||
3511 | if (!in_sbal_ptrs) { | ||
3512 | kfree(qib_param_field); | ||
3513 | return -ENOMEM; | ||
3514 | } | ||
3515 | for(i = 0; i < QDIO_MAX_BUFFERS_PER_Q; ++i) | ||
3516 | in_sbal_ptrs[i] = (struct qdio_buffer *) | ||
3517 | virt_to_phys(card->qdio.in_q->bufs[i].buffer); | ||
3518 | |||
3519 | out_sbal_ptrs = | ||
3520 | kmalloc(card->qdio.no_out_queues * QDIO_MAX_BUFFERS_PER_Q * | ||
3521 | sizeof(void *), GFP_KERNEL); | ||
3522 | if (!out_sbal_ptrs) { | ||
3523 | kfree(in_sbal_ptrs); | ||
3524 | kfree(qib_param_field); | ||
3525 | return -ENOMEM; | ||
3526 | } | ||
3527 | for(i = 0, k = 0; i < card->qdio.no_out_queues; ++i) | ||
3528 | for(j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j, ++k){ | ||
3529 | out_sbal_ptrs[k] = (struct qdio_buffer *) | ||
3530 | virt_to_phys(card->qdio.out_qs[i]-> | ||
3531 | bufs[j].buffer); | ||
3532 | } | ||
3533 | |||
3534 | memset(&init_data, 0, sizeof(struct qdio_initialize)); | ||
3535 | init_data.cdev = CARD_DDEV(card); | ||
3536 | init_data.q_format = qeth_get_qdio_q_format(card); | ||
3537 | init_data.qib_param_field_format = 0; | ||
3538 | init_data.qib_param_field = qib_param_field; | ||
3539 | init_data.min_input_threshold = QETH_MIN_INPUT_THRESHOLD; | ||
3540 | init_data.max_input_threshold = QETH_MAX_INPUT_THRESHOLD; | ||
3541 | init_data.min_output_threshold = QETH_MIN_OUTPUT_THRESHOLD; | ||
3542 | init_data.max_output_threshold = QETH_MAX_OUTPUT_THRESHOLD; | ||
3543 | init_data.no_input_qs = 1; | ||
3544 | init_data.no_output_qs = card->qdio.no_out_queues; | ||
3545 | init_data.input_handler = (qdio_handler_t *) | ||
3546 | qeth_qdio_input_handler; | ||
3547 | init_data.output_handler = (qdio_handler_t *) | ||
3548 | qeth_qdio_output_handler; | ||
3549 | init_data.int_parm = (unsigned long) card; | ||
3550 | init_data.flags = QDIO_INBOUND_0COPY_SBALS | | ||
3551 | QDIO_OUTBOUND_0COPY_SBALS | | ||
3552 | QDIO_USE_OUTBOUND_PCIS; | ||
3553 | init_data.input_sbal_addr_array = (void **) in_sbal_ptrs; | ||
3554 | init_data.output_sbal_addr_array = (void **) out_sbal_ptrs; | ||
3555 | |||
3556 | if (atomic_cmpxchg(&card->qdio.state, QETH_QDIO_ALLOCATED, | ||
3557 | QETH_QDIO_ESTABLISHED) == QETH_QDIO_ALLOCATED) | ||
3558 | if ((rc = qdio_initialize(&init_data))) | ||
3559 | atomic_set(&card->qdio.state, QETH_QDIO_ALLOCATED); | ||
3560 | |||
3561 | kfree(out_sbal_ptrs); | ||
3562 | kfree(in_sbal_ptrs); | ||
3563 | kfree(qib_param_field); | ||
3564 | return rc; | ||
3565 | } | ||
3566 | |||
3567 | static int | ||
3568 | qeth_qdio_activate(struct qeth_card *card) | ||
3569 | { | ||
3570 | QETH_DBF_TEXT(setup,3,"qdioact"); | ||
3571 | return qdio_activate(CARD_DDEV(card), 0); | ||
3572 | } | ||
3573 | |||
3574 | static int | ||
3575 | qeth_clear_channel(struct qeth_channel *channel) | ||
3576 | { | ||
3577 | unsigned long flags; | ||
3578 | struct qeth_card *card; | ||
3579 | int rc; | ||
3580 | |||
3581 | QETH_DBF_TEXT(trace,3,"clearch"); | ||
3582 | card = CARD_FROM_CDEV(channel->ccwdev); | ||
3583 | spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); | ||
3584 | rc = ccw_device_clear(channel->ccwdev, QETH_CLEAR_CHANNEL_PARM); | ||
3585 | spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags); | ||
3586 | |||
3587 | if (rc) | ||
3588 | return rc; | ||
3589 | rc = wait_event_interruptible_timeout(card->wait_q, | ||
3590 | channel->state==CH_STATE_STOPPED, QETH_TIMEOUT); | ||
3591 | if (rc == -ERESTARTSYS) | ||
3592 | return rc; | ||
3593 | if (channel->state != CH_STATE_STOPPED) | ||
3594 | return -ETIME; | ||
3595 | channel->state = CH_STATE_DOWN; | ||
3596 | return 0; | ||
3597 | } | ||
3598 | |||
3599 | static int | ||
3600 | qeth_halt_channel(struct qeth_channel *channel) | ||
3601 | { | ||
3602 | unsigned long flags; | ||
3603 | struct qeth_card *card; | ||
3604 | int rc; | ||
3605 | |||
3606 | QETH_DBF_TEXT(trace,3,"haltch"); | ||
3607 | card = CARD_FROM_CDEV(channel->ccwdev); | ||
3608 | spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); | ||
3609 | rc = ccw_device_halt(channel->ccwdev, QETH_HALT_CHANNEL_PARM); | ||
3610 | spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags); | ||
3611 | |||
3612 | if (rc) | ||
3613 | return rc; | ||
3614 | rc = wait_event_interruptible_timeout(card->wait_q, | ||
3615 | channel->state==CH_STATE_HALTED, QETH_TIMEOUT); | ||
3616 | if (rc == -ERESTARTSYS) | ||
3617 | return rc; | ||
3618 | if (channel->state != CH_STATE_HALTED) | ||
3619 | return -ETIME; | ||
3620 | return 0; | ||
3621 | } | ||
3622 | |||
3623 | static int | ||
3624 | qeth_halt_channels(struct qeth_card *card) | ||
3625 | { | ||
3626 | int rc1 = 0, rc2=0, rc3 = 0; | ||
3627 | |||
3628 | QETH_DBF_TEXT(trace,3,"haltchs"); | ||
3629 | rc1 = qeth_halt_channel(&card->read); | ||
3630 | rc2 = qeth_halt_channel(&card->write); | ||
3631 | rc3 = qeth_halt_channel(&card->data); | ||
3632 | if (rc1) | ||
3633 | return rc1; | ||
3634 | if (rc2) | ||
3635 | return rc2; | ||
3636 | return rc3; | ||
3637 | } | ||
3638 | static int | ||
3639 | qeth_clear_channels(struct qeth_card *card) | ||
3640 | { | ||
3641 | int rc1 = 0, rc2=0, rc3 = 0; | ||
3642 | |||
3643 | QETH_DBF_TEXT(trace,3,"clearchs"); | ||
3644 | rc1 = qeth_clear_channel(&card->read); | ||
3645 | rc2 = qeth_clear_channel(&card->write); | ||
3646 | rc3 = qeth_clear_channel(&card->data); | ||
3647 | if (rc1) | ||
3648 | return rc1; | ||
3649 | if (rc2) | ||
3650 | return rc2; | ||
3651 | return rc3; | ||
3652 | } | ||
3653 | |||
3654 | static int | ||
3655 | qeth_clear_halt_card(struct qeth_card *card, int halt) | ||
3656 | { | ||
3657 | int rc = 0; | ||
3658 | |||
3659 | QETH_DBF_TEXT(trace,3,"clhacrd"); | ||
3660 | QETH_DBF_HEX(trace, 3, &card, sizeof(void *)); | ||
3661 | |||
3662 | if (halt) | ||
3663 | rc = qeth_halt_channels(card); | ||
3664 | if (rc) | ||
3665 | return rc; | ||
3666 | return qeth_clear_channels(card); | ||
3667 | } | ||
3668 | |||
3669 | static int | ||
3670 | qeth_qdio_clear_card(struct qeth_card *card, int use_halt) | ||
3671 | { | ||
3672 | int rc = 0; | ||
3673 | |||
3674 | QETH_DBF_TEXT(trace,3,"qdioclr"); | ||
3675 | switch (atomic_cmpxchg(&card->qdio.state, QETH_QDIO_ESTABLISHED, | ||
3676 | QETH_QDIO_CLEANING)) { | ||
3677 | case QETH_QDIO_ESTABLISHED: | ||
3678 | if ((rc = qdio_cleanup(CARD_DDEV(card), | ||
3679 | (card->info.type == QETH_CARD_TYPE_IQD) ? | ||
3680 | QDIO_FLAG_CLEANUP_USING_HALT : | ||
3681 | QDIO_FLAG_CLEANUP_USING_CLEAR))) | ||
3682 | QETH_DBF_TEXT_(trace, 3, "1err%d", rc); | ||
3683 | atomic_set(&card->qdio.state, QETH_QDIO_ALLOCATED); | ||
3684 | break; | ||
3685 | case QETH_QDIO_CLEANING: | ||
3686 | return rc; | ||
3687 | default: | ||
3688 | break; | ||
3689 | } | ||
3690 | if ((rc = qeth_clear_halt_card(card, use_halt))) | ||
3691 | QETH_DBF_TEXT_(trace, 3, "2err%d", rc); | ||
3692 | card->state = CARD_STATE_DOWN; | ||
3693 | return rc; | ||
3694 | } | ||
3695 | |||
3696 | static int | ||
3697 | qeth_dm_act(struct qeth_card *card) | ||
3698 | { | ||
3699 | int rc; | ||
3700 | struct qeth_cmd_buffer *iob; | ||
3701 | |||
3702 | QETH_DBF_TEXT(setup,2,"dmact"); | ||
3703 | |||
3704 | iob = qeth_wait_for_buffer(&card->write); | ||
3705 | memcpy(iob->data, DM_ACT, DM_ACT_SIZE); | ||
3706 | |||
3707 | memcpy(QETH_DM_ACT_DEST_ADDR(iob->data), | ||
3708 | &card->token.cm_connection_r, QETH_MPC_TOKEN_LENGTH); | ||
3709 | memcpy(QETH_DM_ACT_CONNECTION_TOKEN(iob->data), | ||
3710 | &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH); | ||
3711 | rc = qeth_send_control_data(card, DM_ACT_SIZE, iob, NULL, NULL); | ||
3712 | return rc; | ||
3713 | } | ||
3714 | |||
3715 | static int | ||
3716 | qeth_mpc_initialize(struct qeth_card *card) | ||
3717 | { | ||
3718 | int rc; | ||
3719 | |||
3720 | QETH_DBF_TEXT(setup,2,"mpcinit"); | ||
3721 | |||
3722 | if ((rc = qeth_issue_next_read(card))){ | ||
3723 | QETH_DBF_TEXT_(setup, 2, "1err%d", rc); | ||
3724 | return rc; | ||
3725 | } | ||
3726 | if ((rc = qeth_cm_enable(card))){ | ||
3727 | QETH_DBF_TEXT_(setup, 2, "2err%d", rc); | ||
3728 | goto out_qdio; | ||
3729 | } | ||
3730 | if ((rc = qeth_cm_setup(card))){ | ||
3731 | QETH_DBF_TEXT_(setup, 2, "3err%d", rc); | ||
3732 | goto out_qdio; | ||
3733 | } | ||
3734 | if ((rc = qeth_ulp_enable(card))){ | ||
3735 | QETH_DBF_TEXT_(setup, 2, "4err%d", rc); | ||
3736 | goto out_qdio; | ||
3737 | } | ||
3738 | if ((rc = qeth_ulp_setup(card))){ | ||
3739 | QETH_DBF_TEXT_(setup, 2, "5err%d", rc); | ||
3740 | goto out_qdio; | ||
3741 | } | ||
3742 | if ((rc = qeth_alloc_qdio_buffers(card))){ | ||
3743 | QETH_DBF_TEXT_(setup, 2, "5err%d", rc); | ||
3744 | goto out_qdio; | ||
3745 | } | ||
3746 | if ((rc = qeth_qdio_establish(card))){ | ||
3747 | QETH_DBF_TEXT_(setup, 2, "6err%d", rc); | ||
3748 | qeth_free_qdio_buffers(card); | ||
3749 | goto out_qdio; | ||
3750 | } | ||
3751 | if ((rc = qeth_qdio_activate(card))){ | ||
3752 | QETH_DBF_TEXT_(setup, 2, "7err%d", rc); | ||
3753 | goto out_qdio; | ||
3754 | } | ||
3755 | if ((rc = qeth_dm_act(card))){ | ||
3756 | QETH_DBF_TEXT_(setup, 2, "8err%d", rc); | ||
3757 | goto out_qdio; | ||
3758 | } | ||
3759 | |||
3760 | return 0; | ||
3761 | out_qdio: | ||
3762 | qeth_qdio_clear_card(card, card->info.type!=QETH_CARD_TYPE_IQD); | ||
3763 | return rc; | ||
3764 | } | ||
3765 | |||
3766 | static struct net_device * | ||
3767 | qeth_get_netdevice(enum qeth_card_types type, enum qeth_link_types linktype) | ||
3768 | { | ||
3769 | struct net_device *dev = NULL; | ||
3770 | |||
3771 | switch (type) { | ||
3772 | case QETH_CARD_TYPE_OSAE: | ||
3773 | switch (linktype) { | ||
3774 | case QETH_LINK_TYPE_LANE_TR: | ||
3775 | case QETH_LINK_TYPE_HSTR: | ||
3776 | #ifdef CONFIG_TR | ||
3777 | dev = alloc_trdev(0); | ||
3778 | #endif /* CONFIG_TR */ | ||
3779 | break; | ||
3780 | default: | ||
3781 | dev = alloc_etherdev(0); | ||
3782 | } | ||
3783 | break; | ||
3784 | case QETH_CARD_TYPE_IQD: | ||
3785 | dev = alloc_netdev(0, "hsi%d", ether_setup); | ||
3786 | break; | ||
3787 | case QETH_CARD_TYPE_OSN: | ||
3788 | dev = alloc_netdev(0, "osn%d", ether_setup); | ||
3789 | break; | ||
3790 | default: | ||
3791 | dev = alloc_etherdev(0); | ||
3792 | } | ||
3793 | return dev; | ||
3794 | } | ||
3795 | |||
3796 | /*hard_header fake function; used in case fake_ll is set */ | ||
3797 | static int | ||
3798 | qeth_fake_header(struct sk_buff *skb, struct net_device *dev, | ||
3799 | unsigned short type, const void *daddr, const void *saddr, | ||
3800 | unsigned len) | ||
3801 | { | ||
3802 | if(dev->type == ARPHRD_IEEE802_TR){ | ||
3803 | struct trh_hdr *hdr; | ||
3804 | hdr = (struct trh_hdr *)skb_push(skb, QETH_FAKE_LL_LEN_TR); | ||
3805 | memcpy(hdr->saddr, dev->dev_addr, TR_ALEN); | ||
3806 | memcpy(hdr->daddr, "FAKELL", TR_ALEN); | ||
3807 | return QETH_FAKE_LL_LEN_TR; | ||
3808 | |||
3809 | } else { | ||
3810 | struct ethhdr *hdr; | ||
3811 | hdr = (struct ethhdr *)skb_push(skb, QETH_FAKE_LL_LEN_ETH); | ||
3812 | memcpy(hdr->h_source, dev->dev_addr, ETH_ALEN); | ||
3813 | memcpy(hdr->h_dest, "FAKELL", ETH_ALEN); | ||
3814 | if (type != ETH_P_802_3) | ||
3815 | hdr->h_proto = htons(type); | ||
3816 | else | ||
3817 | hdr->h_proto = htons(len); | ||
3818 | return QETH_FAKE_LL_LEN_ETH; | ||
3819 | |||
3820 | } | ||
3821 | } | ||
3822 | |||
3823 | static const struct header_ops qeth_fake_ops = { | ||
3824 | .create = qeth_fake_header, | ||
3825 | .parse = qeth_hard_header_parse, | ||
3826 | }; | ||
3827 | |||
3828 | static int | ||
3829 | qeth_send_packet(struct qeth_card *, struct sk_buff *); | ||
3830 | |||
3831 | static int | ||
3832 | qeth_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | ||
3833 | { | ||
3834 | int rc; | ||
3835 | struct qeth_card *card; | ||
3836 | |||
3837 | QETH_DBF_TEXT(trace, 6, "hrdstxmi"); | ||
3838 | card = (struct qeth_card *)dev->priv; | ||
3839 | if (skb==NULL) { | ||
3840 | card->stats.tx_dropped++; | ||
3841 | card->stats.tx_errors++; | ||
3842 | /* return OK; otherwise ksoftirqd goes to 100% */ | ||
3843 | return NETDEV_TX_OK; | ||
3844 | } | ||
3845 | if ((card->state != CARD_STATE_UP) || !card->lan_online) { | ||
3846 | card->stats.tx_dropped++; | ||
3847 | card->stats.tx_errors++; | ||
3848 | card->stats.tx_carrier_errors++; | ||
3849 | dev_kfree_skb_any(skb); | ||
3850 | /* return OK; otherwise ksoftirqd goes to 100% */ | ||
3851 | return NETDEV_TX_OK; | ||
3852 | } | ||
3853 | if (card->options.performance_stats) { | ||
3854 | card->perf_stats.outbound_cnt++; | ||
3855 | card->perf_stats.outbound_start_time = qeth_get_micros(); | ||
3856 | } | ||
3857 | netif_stop_queue(dev); | ||
3858 | if ((rc = qeth_send_packet(card, skb))) { | ||
3859 | if (rc == -EBUSY) { | ||
3860 | return NETDEV_TX_BUSY; | ||
3861 | } else { | ||
3862 | card->stats.tx_errors++; | ||
3863 | card->stats.tx_dropped++; | ||
3864 | dev_kfree_skb_any(skb); | ||
3865 | /*set to OK; otherwise ksoftirqd goes to 100% */ | ||
3866 | rc = NETDEV_TX_OK; | ||
3867 | } | ||
3868 | } | ||
3869 | netif_wake_queue(dev); | ||
3870 | if (card->options.performance_stats) | ||
3871 | card->perf_stats.outbound_time += qeth_get_micros() - | ||
3872 | card->perf_stats.outbound_start_time; | ||
3873 | return rc; | ||
3874 | } | ||
3875 | |||
3876 | static int | ||
3877 | qeth_verify_vlan_dev(struct net_device *dev, struct qeth_card *card) | ||
3878 | { | ||
3879 | int rc = 0; | ||
3880 | #ifdef CONFIG_QETH_VLAN | ||
3881 | struct vlan_group *vg; | ||
3882 | int i; | ||
3883 | |||
3884 | if (!(vg = card->vlangrp)) | ||
3885 | return rc; | ||
3886 | |||
3887 | for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++){ | ||
3888 | if (vlan_group_get_device(vg, i) == dev){ | ||
3889 | rc = QETH_VLAN_CARD; | ||
3890 | break; | ||
3891 | } | ||
3892 | } | ||
3893 | if (rc && !(vlan_dev_info(dev)->real_dev->priv == (void *)card)) | ||
3894 | return 0; | ||
3895 | |||
3896 | #endif | ||
3897 | return rc; | ||
3898 | } | ||
3899 | |||
3900 | static int | ||
3901 | qeth_verify_dev(struct net_device *dev) | ||
3902 | { | ||
3903 | struct qeth_card *card; | ||
3904 | unsigned long flags; | ||
3905 | int rc = 0; | ||
3906 | |||
3907 | read_lock_irqsave(&qeth_card_list.rwlock, flags); | ||
3908 | list_for_each_entry(card, &qeth_card_list.list, list){ | ||
3909 | if (card->dev == dev){ | ||
3910 | rc = QETH_REAL_CARD; | ||
3911 | break; | ||
3912 | } | ||
3913 | rc = qeth_verify_vlan_dev(dev, card); | ||
3914 | if (rc) | ||
3915 | break; | ||
3916 | } | ||
3917 | read_unlock_irqrestore(&qeth_card_list.rwlock, flags); | ||
3918 | |||
3919 | return rc; | ||
3920 | } | ||
3921 | |||
3922 | static struct qeth_card * | ||
3923 | qeth_get_card_from_dev(struct net_device *dev) | ||
3924 | { | ||
3925 | struct qeth_card *card = NULL; | ||
3926 | int rc; | ||
3927 | |||
3928 | rc = qeth_verify_dev(dev); | ||
3929 | if (rc == QETH_REAL_CARD) | ||
3930 | card = (struct qeth_card *)dev->priv; | ||
3931 | else if (rc == QETH_VLAN_CARD) | ||
3932 | card = (struct qeth_card *) | ||
3933 | vlan_dev_info(dev)->real_dev->priv; | ||
3934 | |||
3935 | QETH_DBF_TEXT_(trace, 4, "%d", rc); | ||
3936 | return card ; | ||
3937 | } | ||
3938 | |||
3939 | static void | ||
3940 | qeth_tx_timeout(struct net_device *dev) | ||
3941 | { | ||
3942 | struct qeth_card *card; | ||
3943 | |||
3944 | card = (struct qeth_card *) dev->priv; | ||
3945 | card->stats.tx_errors++; | ||
3946 | qeth_schedule_recovery(card); | ||
3947 | } | ||
3948 | |||
3949 | static int | ||
3950 | qeth_open(struct net_device *dev) | ||
3951 | { | ||
3952 | struct qeth_card *card; | ||
3953 | |||
3954 | QETH_DBF_TEXT(trace, 4, "qethopen"); | ||
3955 | |||
3956 | card = (struct qeth_card *) dev->priv; | ||
3957 | |||
3958 | if (card->state != CARD_STATE_SOFTSETUP) | ||
3959 | return -ENODEV; | ||
3960 | |||
3961 | if ( (card->info.type != QETH_CARD_TYPE_OSN) && | ||
3962 | (card->options.layer2) && | ||
3963 | (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED))) { | ||
3964 | QETH_DBF_TEXT(trace,4,"nomacadr"); | ||
3965 | return -EPERM; | ||
3966 | } | ||
3967 | card->data.state = CH_STATE_UP; | ||
3968 | card->state = CARD_STATE_UP; | ||
3969 | card->dev->flags |= IFF_UP; | ||
3970 | netif_start_queue(dev); | ||
3971 | |||
3972 | if (!card->lan_online && netif_carrier_ok(dev)) | ||
3973 | netif_carrier_off(dev); | ||
3974 | return 0; | ||
3975 | } | ||
3976 | |||
3977 | static int | ||
3978 | qeth_stop(struct net_device *dev) | ||
3979 | { | ||
3980 | struct qeth_card *card; | ||
3981 | |||
3982 | QETH_DBF_TEXT(trace, 4, "qethstop"); | ||
3983 | |||
3984 | card = (struct qeth_card *) dev->priv; | ||
3985 | |||
3986 | netif_tx_disable(dev); | ||
3987 | card->dev->flags &= ~IFF_UP; | ||
3988 | if (card->state == CARD_STATE_UP) | ||
3989 | card->state = CARD_STATE_SOFTSETUP; | ||
3990 | return 0; | ||
3991 | } | ||
3992 | |||
3993 | static int | ||
3994 | qeth_get_cast_type(struct qeth_card *card, struct sk_buff *skb) | ||
3995 | { | ||
3996 | int cast_type = RTN_UNSPEC; | ||
3997 | |||
3998 | if (card->info.type == QETH_CARD_TYPE_OSN) | ||
3999 | return cast_type; | ||
4000 | |||
4001 | if (skb->dst && skb->dst->neighbour){ | ||
4002 | cast_type = skb->dst->neighbour->type; | ||
4003 | if ((cast_type == RTN_BROADCAST) || | ||
4004 | (cast_type == RTN_MULTICAST) || | ||
4005 | (cast_type == RTN_ANYCAST)) | ||
4006 | return cast_type; | ||
4007 | else | ||
4008 | return RTN_UNSPEC; | ||
4009 | } | ||
4010 | /* try something else */ | ||
4011 | if (skb->protocol == ETH_P_IPV6) | ||
4012 | return (skb_network_header(skb)[24] == 0xff) ? | ||
4013 | RTN_MULTICAST : 0; | ||
4014 | else if (skb->protocol == ETH_P_IP) | ||
4015 | return ((skb_network_header(skb)[16] & 0xf0) == 0xe0) ? | ||
4016 | RTN_MULTICAST : 0; | ||
4017 | /* ... */ | ||
4018 | if (!memcmp(skb->data, skb->dev->broadcast, 6)) | ||
4019 | return RTN_BROADCAST; | ||
4020 | else { | ||
4021 | u16 hdr_mac; | ||
4022 | |||
4023 | hdr_mac = *((u16 *)skb->data); | ||
4024 | /* tr multicast? */ | ||
4025 | switch (card->info.link_type) { | ||
4026 | case QETH_LINK_TYPE_HSTR: | ||
4027 | case QETH_LINK_TYPE_LANE_TR: | ||
4028 | if ((hdr_mac == QETH_TR_MAC_NC) || | ||
4029 | (hdr_mac == QETH_TR_MAC_C)) | ||
4030 | return RTN_MULTICAST; | ||
4031 | break; | ||
4032 | /* eth or so multicast? */ | ||
4033 | default: | ||
4034 | if ((hdr_mac == QETH_ETH_MAC_V4) || | ||
4035 | (hdr_mac == QETH_ETH_MAC_V6)) | ||
4036 | return RTN_MULTICAST; | ||
4037 | } | ||
4038 | } | ||
4039 | return cast_type; | ||
4040 | } | ||
4041 | |||
4042 | static int | ||
4043 | qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb, | ||
4044 | int ipv, int cast_type) | ||
4045 | { | ||
4046 | if (!ipv && (card->info.type == QETH_CARD_TYPE_OSAE)) | ||
4047 | return card->qdio.default_out_queue; | ||
4048 | switch (card->qdio.no_out_queues) { | ||
4049 | case 4: | ||
4050 | if (cast_type && card->info.is_multicast_different) | ||
4051 | return card->info.is_multicast_different & | ||
4052 | (card->qdio.no_out_queues - 1); | ||
4053 | if (card->qdio.do_prio_queueing && (ipv == 4)) { | ||
4054 | const u8 tos = ip_hdr(skb)->tos; | ||
4055 | |||
4056 | if (card->qdio.do_prio_queueing==QETH_PRIO_Q_ING_TOS){ | ||
4057 | if (tos & IP_TOS_NOTIMPORTANT) | ||
4058 | return 3; | ||
4059 | if (tos & IP_TOS_HIGHRELIABILITY) | ||
4060 | return 2; | ||
4061 | if (tos & IP_TOS_HIGHTHROUGHPUT) | ||
4062 | return 1; | ||
4063 | if (tos & IP_TOS_LOWDELAY) | ||
4064 | return 0; | ||
4065 | } | ||
4066 | if (card->qdio.do_prio_queueing==QETH_PRIO_Q_ING_PREC) | ||
4067 | return 3 - (tos >> 6); | ||
4068 | } else if (card->qdio.do_prio_queueing && (ipv == 6)) { | ||
4069 | /* TODO: IPv6!!! */ | ||
4070 | } | ||
4071 | return card->qdio.default_out_queue; | ||
4072 | case 1: /* fallthrough for single-out-queue 1920-device */ | ||
4073 | default: | ||
4074 | return card->qdio.default_out_queue; | ||
4075 | } | ||
4076 | } | ||
4077 | |||
4078 | static inline int | ||
4079 | qeth_get_ip_version(struct sk_buff *skb) | ||
4080 | { | ||
4081 | switch (skb->protocol) { | ||
4082 | case ETH_P_IPV6: | ||
4083 | return 6; | ||
4084 | case ETH_P_IP: | ||
4085 | return 4; | ||
4086 | default: | ||
4087 | return 0; | ||
4088 | } | ||
4089 | } | ||
4090 | |||
4091 | static struct qeth_hdr * | ||
4092 | __qeth_prepare_skb(struct qeth_card *card, struct sk_buff *skb, int ipv) | ||
4093 | { | ||
4094 | #ifdef CONFIG_QETH_VLAN | ||
4095 | u16 *tag; | ||
4096 | if (card->vlangrp && vlan_tx_tag_present(skb) && | ||
4097 | ((ipv == 6) || card->options.layer2) ) { | ||
4098 | /* | ||
4099 | * Move the mac addresses (6 bytes src, 6 bytes dest) | ||
4100 | * to the beginning of the new header. We are using three | ||
4101 | * memcpys instead of one memmove to save cycles. | ||
4102 | */ | ||
4103 | skb_push(skb, VLAN_HLEN); | ||
4104 | skb_copy_to_linear_data(skb, skb->data + 4, 4); | ||
4105 | skb_copy_to_linear_data_offset(skb, 4, skb->data + 8, 4); | ||
4106 | skb_copy_to_linear_data_offset(skb, 8, skb->data + 12, 4); | ||
4107 | tag = (u16 *)(skb->data + 12); | ||
4108 | /* | ||
4109 | * first two bytes = ETH_P_8021Q (0x8100) | ||
4110 | * second two bytes = VLANID | ||
4111 | */ | ||
4112 | *tag = __constant_htons(ETH_P_8021Q); | ||
4113 | *(tag + 1) = htons(vlan_tx_tag_get(skb)); | ||
4114 | } | ||
4115 | #endif | ||
4116 | return ((struct qeth_hdr *) | ||
4117 | qeth_push_skb(card, skb, sizeof(struct qeth_hdr))); | ||
4118 | } | ||
4119 | |||
4120 | static void | ||
4121 | __qeth_free_new_skb(struct sk_buff *orig_skb, struct sk_buff *new_skb) | ||
4122 | { | ||
4123 | if (orig_skb != new_skb) | ||
4124 | dev_kfree_skb_any(new_skb); | ||
4125 | } | ||
4126 | |||
4127 | static struct sk_buff * | ||
4128 | qeth_prepare_skb(struct qeth_card *card, struct sk_buff *skb, | ||
4129 | struct qeth_hdr **hdr, int ipv) | ||
4130 | { | ||
4131 | struct sk_buff *new_skb, *new_skb2; | ||
4132 | |||
4133 | QETH_DBF_TEXT(trace, 6, "prepskb"); | ||
4134 | new_skb = skb; | ||
4135 | new_skb = qeth_pskb_unshare(skb, GFP_ATOMIC); | ||
4136 | if (!new_skb) | ||
4137 | return NULL; | ||
4138 | new_skb2 = qeth_realloc_headroom(card, new_skb, | ||
4139 | sizeof(struct qeth_hdr)); | ||
4140 | if (!new_skb2) { | ||
4141 | __qeth_free_new_skb(skb, new_skb); | ||
4142 | return NULL; | ||
4143 | } | ||
4144 | if (new_skb != skb) | ||
4145 | __qeth_free_new_skb(new_skb2, new_skb); | ||
4146 | new_skb = new_skb2; | ||
4147 | *hdr = __qeth_prepare_skb(card, new_skb, ipv); | ||
4148 | if (*hdr == NULL) { | ||
4149 | __qeth_free_new_skb(skb, new_skb); | ||
4150 | return NULL; | ||
4151 | } | ||
4152 | return new_skb; | ||
4153 | } | ||
4154 | |||
4155 | static inline u8 | ||
4156 | qeth_get_qeth_hdr_flags4(int cast_type) | ||
4157 | { | ||
4158 | if (cast_type == RTN_MULTICAST) | ||
4159 | return QETH_CAST_MULTICAST; | ||
4160 | if (cast_type == RTN_BROADCAST) | ||
4161 | return QETH_CAST_BROADCAST; | ||
4162 | return QETH_CAST_UNICAST; | ||
4163 | } | ||
4164 | |||
4165 | static inline u8 | ||
4166 | qeth_get_qeth_hdr_flags6(int cast_type) | ||
4167 | { | ||
4168 | u8 ct = QETH_HDR_PASSTHRU | QETH_HDR_IPV6; | ||
4169 | if (cast_type == RTN_MULTICAST) | ||
4170 | return ct | QETH_CAST_MULTICAST; | ||
4171 | if (cast_type == RTN_ANYCAST) | ||
4172 | return ct | QETH_CAST_ANYCAST; | ||
4173 | if (cast_type == RTN_BROADCAST) | ||
4174 | return ct | QETH_CAST_BROADCAST; | ||
4175 | return ct | QETH_CAST_UNICAST; | ||
4176 | } | ||
4177 | |||
4178 | static void | ||
4179 | qeth_layer2_get_packet_type(struct qeth_card *card, struct qeth_hdr *hdr, | ||
4180 | struct sk_buff *skb) | ||
4181 | { | ||
4182 | __u16 hdr_mac; | ||
4183 | |||
4184 | if (!memcmp(skb->data+QETH_HEADER_SIZE, | ||
4185 | skb->dev->broadcast,6)) { /* broadcast? */ | ||
4186 | *(__u32 *)hdr->hdr.l2.flags |= | ||
4187 | QETH_LAYER2_FLAG_BROADCAST << 8; | ||
4188 | return; | ||
4189 | } | ||
4190 | hdr_mac=*((__u16*)skb->data); | ||
4191 | /* tr multicast? */ | ||
4192 | switch (card->info.link_type) { | ||
4193 | case QETH_LINK_TYPE_HSTR: | ||
4194 | case QETH_LINK_TYPE_LANE_TR: | ||
4195 | if ((hdr_mac == QETH_TR_MAC_NC) || | ||
4196 | (hdr_mac == QETH_TR_MAC_C) ) | ||
4197 | *(__u32 *)hdr->hdr.l2.flags |= | ||
4198 | QETH_LAYER2_FLAG_MULTICAST << 8; | ||
4199 | else | ||
4200 | *(__u32 *)hdr->hdr.l2.flags |= | ||
4201 | QETH_LAYER2_FLAG_UNICAST << 8; | ||
4202 | break; | ||
4203 | /* eth or so multicast? */ | ||
4204 | default: | ||
4205 | if ( (hdr_mac==QETH_ETH_MAC_V4) || | ||
4206 | (hdr_mac==QETH_ETH_MAC_V6) ) | ||
4207 | *(__u32 *)hdr->hdr.l2.flags |= | ||
4208 | QETH_LAYER2_FLAG_MULTICAST << 8; | ||
4209 | else | ||
4210 | *(__u32 *)hdr->hdr.l2.flags |= | ||
4211 | QETH_LAYER2_FLAG_UNICAST << 8; | ||
4212 | } | ||
4213 | } | ||
4214 | |||
4215 | static void | ||
4216 | qeth_layer2_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, | ||
4217 | struct sk_buff *skb, int cast_type) | ||
4218 | { | ||
4219 | memset(hdr, 0, sizeof(struct qeth_hdr)); | ||
4220 | hdr->hdr.l2.id = QETH_HEADER_TYPE_LAYER2; | ||
4221 | |||
4222 | /* set byte 0 to "0x02" and byte 3 to casting flags */ | ||
4223 | if (cast_type==RTN_MULTICAST) | ||
4224 | *(__u32 *)hdr->hdr.l2.flags |= QETH_LAYER2_FLAG_MULTICAST << 8; | ||
4225 | else if (cast_type==RTN_BROADCAST) | ||
4226 | *(__u32 *)hdr->hdr.l2.flags |= QETH_LAYER2_FLAG_BROADCAST << 8; | ||
4227 | else | ||
4228 | qeth_layer2_get_packet_type(card, hdr, skb); | ||
4229 | |||
4230 | hdr->hdr.l2.pkt_length = skb->len-QETH_HEADER_SIZE; | ||
4231 | #ifdef CONFIG_QETH_VLAN | ||
4232 | /* VSWITCH relies on the VLAN | ||
4233 | * information to be present in | ||
4234 | * the QDIO header */ | ||
4235 | if ((card->vlangrp != NULL) && | ||
4236 | vlan_tx_tag_present(skb)) { | ||
4237 | *(__u32 *)hdr->hdr.l2.flags |= QETH_LAYER2_FLAG_VLAN << 8; | ||
4238 | hdr->hdr.l2.vlan_id = vlan_tx_tag_get(skb); | ||
4239 | } | ||
4240 | #endif | ||
4241 | } | ||
4242 | |||
4243 | void | ||
4244 | qeth_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, | ||
4245 | struct sk_buff *skb, int ipv, int cast_type) | ||
4246 | { | ||
4247 | QETH_DBF_TEXT(trace, 6, "fillhdr"); | ||
4248 | |||
4249 | memset(hdr, 0, sizeof(struct qeth_hdr)); | ||
4250 | if (card->options.layer2) { | ||
4251 | qeth_layer2_fill_header(card, hdr, skb, cast_type); | ||
4252 | return; | ||
4253 | } | ||
4254 | hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3; | ||
4255 | hdr->hdr.l3.ext_flags = 0; | ||
4256 | #ifdef CONFIG_QETH_VLAN | ||
4257 | /* | ||
4258 | * before we're going to overwrite this location with next hop ip. | ||
4259 | * v6 uses passthrough, v4 sets the tag in the QDIO header. | ||
4260 | */ | ||
4261 | if (card->vlangrp && vlan_tx_tag_present(skb)) { | ||
4262 | hdr->hdr.l3.ext_flags = (ipv == 4) ? | ||
4263 | QETH_HDR_EXT_VLAN_FRAME : | ||
4264 | QETH_HDR_EXT_INCLUDE_VLAN_TAG; | ||
4265 | hdr->hdr.l3.vlan_id = vlan_tx_tag_get(skb); | ||
4266 | } | ||
4267 | #endif /* CONFIG_QETH_VLAN */ | ||
4268 | hdr->hdr.l3.length = skb->len - sizeof(struct qeth_hdr); | ||
4269 | if (ipv == 4) { /* IPv4 */ | ||
4270 | hdr->hdr.l3.flags = qeth_get_qeth_hdr_flags4(cast_type); | ||
4271 | memset(hdr->hdr.l3.dest_addr, 0, 12); | ||
4272 | if ((skb->dst) && (skb->dst->neighbour)) { | ||
4273 | *((u32 *) (&hdr->hdr.l3.dest_addr[12])) = | ||
4274 | *((u32 *) skb->dst->neighbour->primary_key); | ||
4275 | } else { | ||
4276 | /* fill in destination address used in ip header */ | ||
4277 | *((u32 *)(&hdr->hdr.l3.dest_addr[12])) = | ||
4278 | ip_hdr(skb)->daddr; | ||
4279 | } | ||
4280 | } else if (ipv == 6) { /* IPv6 or passthru */ | ||
4281 | hdr->hdr.l3.flags = qeth_get_qeth_hdr_flags6(cast_type); | ||
4282 | if ((skb->dst) && (skb->dst->neighbour)) { | ||
4283 | memcpy(hdr->hdr.l3.dest_addr, | ||
4284 | skb->dst->neighbour->primary_key, 16); | ||
4285 | } else { | ||
4286 | /* fill in destination address used in ip header */ | ||
4287 | memcpy(hdr->hdr.l3.dest_addr, | ||
4288 | &ipv6_hdr(skb)->daddr, 16); | ||
4289 | } | ||
4290 | } else { /* passthrough */ | ||
4291 | if((skb->dev->type == ARPHRD_IEEE802_TR) && | ||
4292 | !memcmp(skb->data + sizeof(struct qeth_hdr) + | ||
4293 | sizeof(__u16), skb->dev->broadcast, 6)) { | ||
4294 | hdr->hdr.l3.flags = QETH_CAST_BROADCAST | | ||
4295 | QETH_HDR_PASSTHRU; | ||
4296 | } else if (!memcmp(skb->data + sizeof(struct qeth_hdr), | ||
4297 | skb->dev->broadcast, 6)) { /* broadcast? */ | ||
4298 | hdr->hdr.l3.flags = QETH_CAST_BROADCAST | | ||
4299 | QETH_HDR_PASSTHRU; | ||
4300 | } else { | ||
4301 | hdr->hdr.l3.flags = (cast_type == RTN_MULTICAST) ? | ||
4302 | QETH_CAST_MULTICAST | QETH_HDR_PASSTHRU : | ||
4303 | QETH_CAST_UNICAST | QETH_HDR_PASSTHRU; | ||
4304 | } | ||
4305 | } | ||
4306 | } | ||
4307 | |||
4308 | static void | ||
4309 | __qeth_fill_buffer(struct sk_buff *skb, struct qdio_buffer *buffer, | ||
4310 | int is_tso, int *next_element_to_fill) | ||
4311 | { | ||
4312 | int length = skb->len; | ||
4313 | int length_here; | ||
4314 | int element; | ||
4315 | char *data; | ||
4316 | int first_lap ; | ||
4317 | |||
4318 | element = *next_element_to_fill; | ||
4319 | data = skb->data; | ||
4320 | first_lap = (is_tso == 0 ? 1 : 0); | ||
4321 | |||
4322 | while (length > 0) { | ||
4323 | /* length_here is the remaining amount of data in this page */ | ||
4324 | length_here = PAGE_SIZE - ((unsigned long) data % PAGE_SIZE); | ||
4325 | if (length < length_here) | ||
4326 | length_here = length; | ||
4327 | |||
4328 | buffer->element[element].addr = data; | ||
4329 | buffer->element[element].length = length_here; | ||
4330 | length -= length_here; | ||
4331 | if (!length) { | ||
4332 | if (first_lap) | ||
4333 | buffer->element[element].flags = 0; | ||
4334 | else | ||
4335 | buffer->element[element].flags = | ||
4336 | SBAL_FLAGS_LAST_FRAG; | ||
4337 | } else { | ||
4338 | if (first_lap) | ||
4339 | buffer->element[element].flags = | ||
4340 | SBAL_FLAGS_FIRST_FRAG; | ||
4341 | else | ||
4342 | buffer->element[element].flags = | ||
4343 | SBAL_FLAGS_MIDDLE_FRAG; | ||
4344 | } | ||
4345 | data += length_here; | ||
4346 | element++; | ||
4347 | first_lap = 0; | ||
4348 | } | ||
4349 | *next_element_to_fill = element; | ||
4350 | } | ||
4351 | |||
4352 | static int | ||
4353 | qeth_fill_buffer(struct qeth_qdio_out_q *queue, | ||
4354 | struct qeth_qdio_out_buffer *buf, | ||
4355 | struct sk_buff *skb) | ||
4356 | { | ||
4357 | struct qdio_buffer *buffer; | ||
4358 | struct qeth_hdr_tso *hdr; | ||
4359 | int flush_cnt = 0, hdr_len, large_send = 0; | ||
4360 | |||
4361 | QETH_DBF_TEXT(trace, 6, "qdfillbf"); | ||
4362 | |||
4363 | buffer = buf->buffer; | ||
4364 | atomic_inc(&skb->users); | ||
4365 | skb_queue_tail(&buf->skb_list, skb); | ||
4366 | |||
4367 | hdr = (struct qeth_hdr_tso *) skb->data; | ||
4368 | /*check first on TSO ....*/ | ||
4369 | if (hdr->hdr.hdr.l3.id == QETH_HEADER_TYPE_TSO) { | ||
4370 | int element = buf->next_element_to_fill; | ||
4371 | |||
4372 | hdr_len = sizeof(struct qeth_hdr_tso) + hdr->ext.dg_hdr_len; | ||
4373 | /*fill first buffer entry only with header information */ | ||
4374 | buffer->element[element].addr = skb->data; | ||
4375 | buffer->element[element].length = hdr_len; | ||
4376 | buffer->element[element].flags = SBAL_FLAGS_FIRST_FRAG; | ||
4377 | buf->next_element_to_fill++; | ||
4378 | skb->data += hdr_len; | ||
4379 | skb->len -= hdr_len; | ||
4380 | large_send = 1; | ||
4381 | } | ||
4382 | if (skb_shinfo(skb)->nr_frags == 0) | ||
4383 | __qeth_fill_buffer(skb, buffer, large_send, | ||
4384 | (int *)&buf->next_element_to_fill); | ||
4385 | else | ||
4386 | __qeth_fill_buffer_frag(skb, buffer, large_send, | ||
4387 | (int *)&buf->next_element_to_fill); | ||
4388 | |||
4389 | if (!queue->do_pack) { | ||
4390 | QETH_DBF_TEXT(trace, 6, "fillbfnp"); | ||
4391 | /* set state to PRIMED -> will be flushed */ | ||
4392 | atomic_set(&buf->state, QETH_QDIO_BUF_PRIMED); | ||
4393 | flush_cnt = 1; | ||
4394 | } else { | ||
4395 | QETH_DBF_TEXT(trace, 6, "fillbfpa"); | ||
4396 | if (queue->card->options.performance_stats) | ||
4397 | queue->card->perf_stats.skbs_sent_pack++; | ||
4398 | if (buf->next_element_to_fill >= | ||
4399 | QETH_MAX_BUFFER_ELEMENTS(queue->card)) { | ||
4400 | /* | ||
4401 | * packed buffer if full -> set state PRIMED | ||
4402 | * -> will be flushed | ||
4403 | */ | ||
4404 | atomic_set(&buf->state, QETH_QDIO_BUF_PRIMED); | ||
4405 | flush_cnt = 1; | ||
4406 | } | ||
4407 | } | ||
4408 | return flush_cnt; | ||
4409 | } | ||
4410 | |||
4411 | static int | ||
4412 | qeth_do_send_packet_fast(struct qeth_card *card, struct qeth_qdio_out_q *queue, | ||
4413 | struct sk_buff *skb, struct qeth_hdr *hdr, | ||
4414 | int elements_needed, | ||
4415 | struct qeth_eddp_context *ctx) | ||
4416 | { | ||
4417 | struct qeth_qdio_out_buffer *buffer; | ||
4418 | int buffers_needed = 0; | ||
4419 | int flush_cnt = 0; | ||
4420 | int index; | ||
4421 | |||
4422 | QETH_DBF_TEXT(trace, 6, "dosndpfa"); | ||
4423 | |||
4424 | /* spin until we get the queue ... */ | ||
4425 | while (atomic_cmpxchg(&queue->state, QETH_OUT_Q_UNLOCKED, | ||
4426 | QETH_OUT_Q_LOCKED) != QETH_OUT_Q_UNLOCKED); | ||
4427 | /* ... now we've got the queue */ | ||
4428 | index = queue->next_buf_to_fill; | ||
4429 | buffer = &queue->bufs[queue->next_buf_to_fill]; | ||
4430 | /* | ||
4431 | * check if buffer is empty to make sure that we do not 'overtake' | ||
4432 | * ourselves and try to fill a buffer that is already primed | ||
4433 | */ | ||
4434 | if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY) | ||
4435 | goto out; | ||
4436 | if (ctx == NULL) | ||
4437 | queue->next_buf_to_fill = (queue->next_buf_to_fill + 1) % | ||
4438 | QDIO_MAX_BUFFERS_PER_Q; | ||
4439 | else { | ||
4440 | buffers_needed = qeth_eddp_check_buffers_for_context(queue,ctx); | ||
4441 | if (buffers_needed < 0) | ||
4442 | goto out; | ||
4443 | queue->next_buf_to_fill = | ||
4444 | (queue->next_buf_to_fill + buffers_needed) % | ||
4445 | QDIO_MAX_BUFFERS_PER_Q; | ||
4446 | } | ||
4447 | atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); | ||
4448 | if (ctx == NULL) { | ||
4449 | qeth_fill_buffer(queue, buffer, skb); | ||
4450 | qeth_flush_buffers(queue, 0, index, 1); | ||
4451 | } else { | ||
4452 | flush_cnt = qeth_eddp_fill_buffer(queue, ctx, index); | ||
4453 | WARN_ON(buffers_needed != flush_cnt); | ||
4454 | qeth_flush_buffers(queue, 0, index, flush_cnt); | ||
4455 | } | ||
4456 | return 0; | ||
4457 | out: | ||
4458 | atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); | ||
4459 | return -EBUSY; | ||
4460 | } | ||
4461 | |||
4462 | static int | ||
4463 | qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue, | ||
4464 | struct sk_buff *skb, struct qeth_hdr *hdr, | ||
4465 | int elements_needed, struct qeth_eddp_context *ctx) | ||
4466 | { | ||
4467 | struct qeth_qdio_out_buffer *buffer; | ||
4468 | int start_index; | ||
4469 | int flush_count = 0; | ||
4470 | int do_pack = 0; | ||
4471 | int tmp; | ||
4472 | int rc = 0; | ||
4473 | |||
4474 | QETH_DBF_TEXT(trace, 6, "dosndpkt"); | ||
4475 | |||
4476 | /* spin until we get the queue ... */ | ||
4477 | while (atomic_cmpxchg(&queue->state, QETH_OUT_Q_UNLOCKED, | ||
4478 | QETH_OUT_Q_LOCKED) != QETH_OUT_Q_UNLOCKED); | ||
4479 | start_index = queue->next_buf_to_fill; | ||
4480 | buffer = &queue->bufs[queue->next_buf_to_fill]; | ||
4481 | /* | ||
4482 | * check if buffer is empty to make sure that we do not 'overtake' | ||
4483 | * ourselves and try to fill a buffer that is already primed | ||
4484 | */ | ||
4485 | if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY) { | ||
4486 | atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); | ||
4487 | return -EBUSY; | ||
4488 | } | ||
4489 | /* check if we need to switch packing state of this queue */ | ||
4490 | qeth_switch_to_packing_if_needed(queue); | ||
4491 | if (queue->do_pack){ | ||
4492 | do_pack = 1; | ||
4493 | if (ctx == NULL) { | ||
4494 | /* does packet fit in current buffer? */ | ||
4495 | if((QETH_MAX_BUFFER_ELEMENTS(card) - | ||
4496 | buffer->next_element_to_fill) < elements_needed){ | ||
4497 | /* ... no -> set state PRIMED */ | ||
4498 | atomic_set(&buffer->state,QETH_QDIO_BUF_PRIMED); | ||
4499 | flush_count++; | ||
4500 | queue->next_buf_to_fill = | ||
4501 | (queue->next_buf_to_fill + 1) % | ||
4502 | QDIO_MAX_BUFFERS_PER_Q; | ||
4503 | buffer = &queue->bufs[queue->next_buf_to_fill]; | ||
4504 | /* we did a step forward, so check buffer state | ||
4505 | * again */ | ||
4506 | if (atomic_read(&buffer->state) != | ||
4507 | QETH_QDIO_BUF_EMPTY){ | ||
4508 | qeth_flush_buffers(queue, 0, start_index, flush_count); | ||
4509 | atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); | ||
4510 | return -EBUSY; | ||
4511 | } | ||
4512 | } | ||
4513 | } else { | ||
4514 | /* check if we have enough elements (including following | ||
4515 | * free buffers) to handle eddp context */ | ||
4516 | if (qeth_eddp_check_buffers_for_context(queue,ctx) < 0){ | ||
4517 | if (net_ratelimit()) | ||
4518 | PRINT_WARN("eddp tx_dropped 1\n"); | ||
4519 | rc = -EBUSY; | ||
4520 | goto out; | ||
4521 | } | ||
4522 | } | ||
4523 | } | ||
4524 | if (ctx == NULL) | ||
4525 | tmp = qeth_fill_buffer(queue, buffer, skb); | ||
4526 | else { | ||
4527 | tmp = qeth_eddp_fill_buffer(queue,ctx,queue->next_buf_to_fill); | ||
4528 | if (tmp < 0) { | ||
4529 | printk("eddp tx_dropped 2\n"); | ||
4530 | rc = - EBUSY; | ||
4531 | goto out; | ||
4532 | } | ||
4533 | } | ||
4534 | queue->next_buf_to_fill = (queue->next_buf_to_fill + tmp) % | ||
4535 | QDIO_MAX_BUFFERS_PER_Q; | ||
4536 | flush_count += tmp; | ||
4537 | out: | ||
4538 | if (flush_count) | ||
4539 | qeth_flush_buffers(queue, 0, start_index, flush_count); | ||
4540 | else if (!atomic_read(&queue->set_pci_flags_count)) | ||
4541 | atomic_xchg(&queue->state, QETH_OUT_Q_LOCKED_FLUSH); | ||
4542 | /* | ||
4543 | * queue->state will go from LOCKED -> UNLOCKED or from | ||
4544 | * LOCKED_FLUSH -> LOCKED if output_handler wanted to 'notify' us | ||
4545 | * (switch packing state or flush buffer to get another pci flag out). | ||
4546 | * In that case we will enter this loop | ||
4547 | */ | ||
4548 | while (atomic_dec_return(&queue->state)){ | ||
4549 | flush_count = 0; | ||
4550 | start_index = queue->next_buf_to_fill; | ||
4551 | /* check if we can go back to non-packing state */ | ||
4552 | flush_count += qeth_switch_to_nonpacking_if_needed(queue); | ||
4553 | /* | ||
4554 | * check if we need to flush a packing buffer to get a pci | ||
4555 | * flag out on the queue | ||
4556 | */ | ||
4557 | if (!flush_count && !atomic_read(&queue->set_pci_flags_count)) | ||
4558 | flush_count += qeth_flush_buffers_on_no_pci(queue); | ||
4559 | if (flush_count) | ||
4560 | qeth_flush_buffers(queue, 0, start_index, flush_count); | ||
4561 | } | ||
4562 | /* at this point the queue is UNLOCKED again */ | ||
4563 | if (queue->card->options.performance_stats && do_pack) | ||
4564 | queue->card->perf_stats.bufs_sent_pack += flush_count; | ||
4565 | |||
4566 | return rc; | ||
4567 | } | ||
4568 | |||
4569 | static int | ||
4570 | qeth_get_elements_no(struct qeth_card *card, void *hdr, | ||
4571 | struct sk_buff *skb, int elems) | ||
4572 | { | ||
4573 | int elements_needed = 0; | ||
4574 | |||
4575 | if (skb_shinfo(skb)->nr_frags > 0) | ||
4576 | elements_needed = (skb_shinfo(skb)->nr_frags + 1); | ||
4577 | if (elements_needed == 0) | ||
4578 | elements_needed = 1 + (((((unsigned long) hdr) % PAGE_SIZE) | ||
4579 | + skb->len) >> PAGE_SHIFT); | ||
4580 | if ((elements_needed + elems) > QETH_MAX_BUFFER_ELEMENTS(card)){ | ||
4581 | PRINT_ERR("Invalid size of IP packet " | ||
4582 | "(Number=%d / Length=%d). Discarded.\n", | ||
4583 | (elements_needed+elems), skb->len); | ||
4584 | return 0; | ||
4585 | } | ||
4586 | return elements_needed; | ||
4587 | } | ||
4588 | |||
4589 | static void qeth_tx_csum(struct sk_buff *skb) | ||
4590 | { | ||
4591 | int tlen; | ||
4592 | |||
4593 | if (skb->protocol == htons(ETH_P_IP)) { | ||
4594 | tlen = ntohs(ip_hdr(skb)->tot_len) - (ip_hdr(skb)->ihl << 2); | ||
4595 | switch (ip_hdr(skb)->protocol) { | ||
4596 | case IPPROTO_TCP: | ||
4597 | tcp_hdr(skb)->check = 0; | ||
4598 | tcp_hdr(skb)->check = csum_tcpudp_magic( | ||
4599 | ip_hdr(skb)->saddr, ip_hdr(skb)->daddr, | ||
4600 | tlen, ip_hdr(skb)->protocol, | ||
4601 | skb_checksum(skb, skb_transport_offset(skb), | ||
4602 | tlen, 0)); | ||
4603 | break; | ||
4604 | case IPPROTO_UDP: | ||
4605 | udp_hdr(skb)->check = 0; | ||
4606 | udp_hdr(skb)->check = csum_tcpudp_magic( | ||
4607 | ip_hdr(skb)->saddr, ip_hdr(skb)->daddr, | ||
4608 | tlen, ip_hdr(skb)->protocol, | ||
4609 | skb_checksum(skb, skb_transport_offset(skb), | ||
4610 | tlen, 0)); | ||
4611 | break; | ||
4612 | } | ||
4613 | } else if (skb->protocol == htons(ETH_P_IPV6)) { | ||
4614 | switch (ipv6_hdr(skb)->nexthdr) { | ||
4615 | case IPPROTO_TCP: | ||
4616 | tcp_hdr(skb)->check = 0; | ||
4617 | tcp_hdr(skb)->check = csum_ipv6_magic( | ||
4618 | &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr, | ||
4619 | ipv6_hdr(skb)->payload_len, | ||
4620 | ipv6_hdr(skb)->nexthdr, | ||
4621 | skb_checksum(skb, skb_transport_offset(skb), | ||
4622 | ipv6_hdr(skb)->payload_len, 0)); | ||
4623 | break; | ||
4624 | case IPPROTO_UDP: | ||
4625 | udp_hdr(skb)->check = 0; | ||
4626 | udp_hdr(skb)->check = csum_ipv6_magic( | ||
4627 | &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr, | ||
4628 | ipv6_hdr(skb)->payload_len, | ||
4629 | ipv6_hdr(skb)->nexthdr, | ||
4630 | skb_checksum(skb, skb_transport_offset(skb), | ||
4631 | ipv6_hdr(skb)->payload_len, 0)); | ||
4632 | break; | ||
4633 | } | ||
4634 | } | ||
4635 | } | ||
4636 | |||
4637 | static int | ||
4638 | qeth_send_packet(struct qeth_card *card, struct sk_buff *skb) | ||
4639 | { | ||
4640 | int ipv = 0; | ||
4641 | int cast_type; | ||
4642 | struct qeth_qdio_out_q *queue; | ||
4643 | struct qeth_hdr *hdr = NULL; | ||
4644 | int elements_needed = 0; | ||
4645 | enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO; | ||
4646 | struct qeth_eddp_context *ctx = NULL; | ||
4647 | int tx_bytes = skb->len; | ||
4648 | unsigned short nr_frags = skb_shinfo(skb)->nr_frags; | ||
4649 | unsigned short tso_size = skb_shinfo(skb)->gso_size; | ||
4650 | struct sk_buff *new_skb, *new_skb2; | ||
4651 | int rc; | ||
4652 | |||
4653 | QETH_DBF_TEXT(trace, 6, "sendpkt"); | ||
4654 | |||
4655 | new_skb = skb; | ||
4656 | if ((card->info.type == QETH_CARD_TYPE_OSN) && | ||
4657 | (skb->protocol == htons(ETH_P_IPV6))) | ||
4658 | return -EPERM; | ||
4659 | cast_type = qeth_get_cast_type(card, skb); | ||
4660 | if ((cast_type == RTN_BROADCAST) && | ||
4661 | (card->info.broadcast_capable == 0)) | ||
4662 | return -EPERM; | ||
4663 | queue = card->qdio.out_qs | ||
4664 | [qeth_get_priority_queue(card, skb, ipv, cast_type)]; | ||
4665 | if (!card->options.layer2) { | ||
4666 | ipv = qeth_get_ip_version(skb); | ||
4667 | if ((card->dev->header_ops == &qeth_fake_ops) && ipv) { | ||
4668 | new_skb = qeth_pskb_unshare(skb, GFP_ATOMIC); | ||
4669 | if (!new_skb) | ||
4670 | return -ENOMEM; | ||
4671 | if(card->dev->type == ARPHRD_IEEE802_TR){ | ||
4672 | skb_pull(new_skb, QETH_FAKE_LL_LEN_TR); | ||
4673 | } else { | ||
4674 | skb_pull(new_skb, QETH_FAKE_LL_LEN_ETH); | ||
4675 | } | ||
4676 | } | ||
4677 | } | ||
4678 | if (skb_is_gso(skb)) | ||
4679 | large_send = card->options.large_send; | ||
4680 | /* check on OSN device*/ | ||
4681 | if (card->info.type == QETH_CARD_TYPE_OSN) | ||
4682 | hdr = (struct qeth_hdr *)new_skb->data; | ||
4683 | /*are we able to do TSO ? */ | ||
4684 | if ((large_send == QETH_LARGE_SEND_TSO) && | ||
4685 | (cast_type == RTN_UNSPEC)) { | ||
4686 | rc = qeth_tso_prepare_packet(card, new_skb, ipv, cast_type); | ||
4687 | if (rc) { | ||
4688 | __qeth_free_new_skb(skb, new_skb); | ||
4689 | return rc; | ||
4690 | } | ||
4691 | elements_needed++; | ||
4692 | } else if (card->info.type != QETH_CARD_TYPE_OSN) { | ||
4693 | new_skb2 = qeth_prepare_skb(card, new_skb, &hdr, ipv); | ||
4694 | if (!new_skb2) { | ||
4695 | __qeth_free_new_skb(skb, new_skb); | ||
4696 | return -EINVAL; | ||
4697 | } | ||
4698 | if (new_skb != skb) | ||
4699 | __qeth_free_new_skb(new_skb2, new_skb); | ||
4700 | new_skb = new_skb2; | ||
4701 | qeth_fill_header(card, hdr, new_skb, ipv, cast_type); | ||
4702 | } | ||
4703 | if (large_send == QETH_LARGE_SEND_EDDP) { | ||
4704 | ctx = qeth_eddp_create_context(card, new_skb, hdr, | ||
4705 | skb->sk->sk_protocol); | ||
4706 | if (ctx == NULL) { | ||
4707 | __qeth_free_new_skb(skb, new_skb); | ||
4708 | PRINT_WARN("could not create eddp context\n"); | ||
4709 | return -EINVAL; | ||
4710 | } | ||
4711 | } else { | ||
4712 | int elems = qeth_get_elements_no(card,(void*) hdr, new_skb, | ||
4713 | elements_needed); | ||
4714 | if (!elems) { | ||
4715 | __qeth_free_new_skb(skb, new_skb); | ||
4716 | return -EINVAL; | ||
4717 | } | ||
4718 | elements_needed += elems; | ||
4719 | } | ||
4720 | |||
4721 | if ((large_send == QETH_LARGE_SEND_NO) && | ||
4722 | (skb->ip_summed == CHECKSUM_PARTIAL)) | ||
4723 | qeth_tx_csum(new_skb); | ||
4724 | |||
4725 | if (card->info.type != QETH_CARD_TYPE_IQD) | ||
4726 | rc = qeth_do_send_packet(card, queue, new_skb, hdr, | ||
4727 | elements_needed, ctx); | ||
4728 | else { | ||
4729 | if ((!card->options.layer2) && | ||
4730 | (ipv == 0)) { | ||
4731 | __qeth_free_new_skb(skb, new_skb); | ||
4732 | return -EPERM; | ||
4733 | } | ||
4734 | rc = qeth_do_send_packet_fast(card, queue, new_skb, hdr, | ||
4735 | elements_needed, ctx); | ||
4736 | } | ||
4737 | if (!rc) { | ||
4738 | card->stats.tx_packets++; | ||
4739 | card->stats.tx_bytes += tx_bytes; | ||
4740 | if (new_skb != skb) | ||
4741 | dev_kfree_skb_any(skb); | ||
4742 | if (card->options.performance_stats) { | ||
4743 | if (tso_size && | ||
4744 | !(large_send == QETH_LARGE_SEND_NO)) { | ||
4745 | card->perf_stats.large_send_bytes += tx_bytes; | ||
4746 | card->perf_stats.large_send_cnt++; | ||
4747 | } | ||
4748 | if (nr_frags > 0) { | ||
4749 | card->perf_stats.sg_skbs_sent++; | ||
4750 | /* nr_frags + skb->data */ | ||
4751 | card->perf_stats.sg_frags_sent += | ||
4752 | nr_frags + 1; | ||
4753 | } | ||
4754 | } | ||
4755 | } else { | ||
4756 | card->stats.tx_dropped++; | ||
4757 | __qeth_free_new_skb(skb, new_skb); | ||
4758 | } | ||
4759 | if (ctx != NULL) { | ||
4760 | /* drop creator's reference */ | ||
4761 | qeth_eddp_put_context(ctx); | ||
4762 | /* free skb; it's not referenced by a buffer */ | ||
4763 | if (!rc) | ||
4764 | dev_kfree_skb_any(new_skb); | ||
4765 | } | ||
4766 | return rc; | ||
4767 | } | ||
4768 | |||
4769 | static int | ||
4770 | qeth_mdio_read(struct net_device *dev, int phy_id, int regnum) | ||
4771 | { | ||
4772 | struct qeth_card *card = (struct qeth_card *) dev->priv; | ||
4773 | int rc = 0; | ||
4774 | |||
4775 | switch(regnum){ | ||
4776 | case MII_BMCR: /* Basic mode control register */ | ||
4777 | rc = BMCR_FULLDPLX; | ||
4778 | if ((card->info.link_type != QETH_LINK_TYPE_GBIT_ETH)&& | ||
4779 | (card->info.link_type != QETH_LINK_TYPE_OSN) && | ||
4780 | (card->info.link_type != QETH_LINK_TYPE_10GBIT_ETH)) | ||
4781 | rc |= BMCR_SPEED100; | ||
4782 | break; | ||
4783 | case MII_BMSR: /* Basic mode status register */ | ||
4784 | rc = BMSR_ERCAP | BMSR_ANEGCOMPLETE | BMSR_LSTATUS | | ||
4785 | BMSR_10HALF | BMSR_10FULL | BMSR_100HALF | BMSR_100FULL | | ||
4786 | BMSR_100BASE4; | ||
4787 | break; | ||
4788 | case MII_PHYSID1: /* PHYS ID 1 */ | ||
4789 | rc = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 8) | | ||
4790 | dev->dev_addr[2]; | ||
4791 | rc = (rc >> 5) & 0xFFFF; | ||
4792 | break; | ||
4793 | case MII_PHYSID2: /* PHYS ID 2 */ | ||
4794 | rc = (dev->dev_addr[2] << 10) & 0xFFFF; | ||
4795 | break; | ||
4796 | case MII_ADVERTISE: /* Advertisement control reg */ | ||
4797 | rc = ADVERTISE_ALL; | ||
4798 | break; | ||
4799 | case MII_LPA: /* Link partner ability reg */ | ||
4800 | rc = LPA_10HALF | LPA_10FULL | LPA_100HALF | LPA_100FULL | | ||
4801 | LPA_100BASE4 | LPA_LPACK; | ||
4802 | break; | ||
4803 | case MII_EXPANSION: /* Expansion register */ | ||
4804 | break; | ||
4805 | case MII_DCOUNTER: /* disconnect counter */ | ||
4806 | break; | ||
4807 | case MII_FCSCOUNTER: /* false carrier counter */ | ||
4808 | break; | ||
4809 | case MII_NWAYTEST: /* N-way auto-neg test register */ | ||
4810 | break; | ||
4811 | case MII_RERRCOUNTER: /* rx error counter */ | ||
4812 | rc = card->stats.rx_errors; | ||
4813 | break; | ||
4814 | case MII_SREVISION: /* silicon revision */ | ||
4815 | break; | ||
4816 | case MII_RESV1: /* reserved 1 */ | ||
4817 | break; | ||
4818 | case MII_LBRERROR: /* loopback, rx, bypass error */ | ||
4819 | break; | ||
4820 | case MII_PHYADDR: /* physical address */ | ||
4821 | break; | ||
4822 | case MII_RESV2: /* reserved 2 */ | ||
4823 | break; | ||
4824 | case MII_TPISTATUS: /* TPI status for 10mbps */ | ||
4825 | break; | ||
4826 | case MII_NCONFIG: /* network interface config */ | ||
4827 | break; | ||
4828 | default: | ||
4829 | break; | ||
4830 | } | ||
4831 | return rc; | ||
4832 | } | ||
4833 | |||
4834 | |||
4835 | static const char * | ||
4836 | qeth_arp_get_error_cause(int *rc) | ||
4837 | { | ||
4838 | switch (*rc) { | ||
4839 | case QETH_IPA_ARP_RC_FAILED: | ||
4840 | *rc = -EIO; | ||
4841 | return "operation failed"; | ||
4842 | case QETH_IPA_ARP_RC_NOTSUPP: | ||
4843 | *rc = -EOPNOTSUPP; | ||
4844 | return "operation not supported"; | ||
4845 | case QETH_IPA_ARP_RC_OUT_OF_RANGE: | ||
4846 | *rc = -EINVAL; | ||
4847 | return "argument out of range"; | ||
4848 | case QETH_IPA_ARP_RC_Q_NOTSUPP: | ||
4849 | *rc = -EOPNOTSUPP; | ||
4850 | return "query operation not supported"; | ||
4851 | case QETH_IPA_ARP_RC_Q_NO_DATA: | ||
4852 | *rc = -ENOENT; | ||
4853 | return "no query data available"; | ||
4854 | default: | ||
4855 | return "unknown error"; | ||
4856 | } | ||
4857 | } | ||
4858 | |||
4859 | static int | ||
4860 | qeth_send_simple_setassparms(struct qeth_card *, enum qeth_ipa_funcs, | ||
4861 | __u16, long); | ||
4862 | |||
4863 | static int | ||
4864 | qeth_arp_set_no_entries(struct qeth_card *card, int no_entries) | ||
4865 | { | ||
4866 | int tmp; | ||
4867 | int rc; | ||
4868 | |||
4869 | QETH_DBF_TEXT(trace,3,"arpstnoe"); | ||
4870 | |||
4871 | /* | ||
4872 | * currently GuestLAN only supports the ARP assist function | ||
4873 | * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_SET_NO_ENTRIES; | ||
4874 | * thus we say EOPNOTSUPP for this ARP function | ||
4875 | */ | ||
4876 | if (card->info.guestlan) | ||
4877 | return -EOPNOTSUPP; | ||
4878 | if (!qeth_is_supported(card,IPA_ARP_PROCESSING)) { | ||
4879 | PRINT_WARN("ARP processing not supported " | ||
4880 | "on %s!\n", QETH_CARD_IFNAME(card)); | ||
4881 | return -EOPNOTSUPP; | ||
4882 | } | ||
4883 | rc = qeth_send_simple_setassparms(card, IPA_ARP_PROCESSING, | ||
4884 | IPA_CMD_ASS_ARP_SET_NO_ENTRIES, | ||
4885 | no_entries); | ||
4886 | if (rc) { | ||
4887 | tmp = rc; | ||
4888 | PRINT_WARN("Could not set number of ARP entries on %s: " | ||
4889 | "%s (0x%x/%d)\n", | ||
4890 | QETH_CARD_IFNAME(card), qeth_arp_get_error_cause(&rc), | ||
4891 | tmp, tmp); | ||
4892 | } | ||
4893 | return rc; | ||
4894 | } | ||
4895 | |||
4896 | static void | ||
4897 | qeth_copy_arp_entries_stripped(struct qeth_arp_query_info *qinfo, | ||
4898 | struct qeth_arp_query_data *qdata, | ||
4899 | int entry_size, int uentry_size) | ||
4900 | { | ||
4901 | char *entry_ptr; | ||
4902 | char *uentry_ptr; | ||
4903 | int i; | ||
4904 | |||
4905 | entry_ptr = (char *)&qdata->data; | ||
4906 | uentry_ptr = (char *)(qinfo->udata + qinfo->udata_offset); | ||
4907 | for (i = 0; i < qdata->no_entries; ++i){ | ||
4908 | /* strip off 32 bytes "media specific information" */ | ||
4909 | memcpy(uentry_ptr, (entry_ptr + 32), entry_size - 32); | ||
4910 | entry_ptr += entry_size; | ||
4911 | uentry_ptr += uentry_size; | ||
4912 | } | ||
4913 | } | ||
4914 | |||
4915 | static int | ||
4916 | qeth_arp_query_cb(struct qeth_card *card, struct qeth_reply *reply, | ||
4917 | unsigned long data) | ||
4918 | { | ||
4919 | struct qeth_ipa_cmd *cmd; | ||
4920 | struct qeth_arp_query_data *qdata; | ||
4921 | struct qeth_arp_query_info *qinfo; | ||
4922 | int entry_size; | ||
4923 | int uentry_size; | ||
4924 | int i; | ||
4925 | |||
4926 | QETH_DBF_TEXT(trace,4,"arpquecb"); | ||
4927 | |||
4928 | qinfo = (struct qeth_arp_query_info *) reply->param; | ||
4929 | cmd = (struct qeth_ipa_cmd *) data; | ||
4930 | if (cmd->hdr.return_code) { | ||
4931 | QETH_DBF_TEXT_(trace,4,"qaer1%i", cmd->hdr.return_code); | ||
4932 | return 0; | ||
4933 | } | ||
4934 | if (cmd->data.setassparms.hdr.return_code) { | ||
4935 | cmd->hdr.return_code = cmd->data.setassparms.hdr.return_code; | ||
4936 | QETH_DBF_TEXT_(trace,4,"qaer2%i", cmd->hdr.return_code); | ||
4937 | return 0; | ||
4938 | } | ||
4939 | qdata = &cmd->data.setassparms.data.query_arp; | ||
4940 | switch(qdata->reply_bits){ | ||
4941 | case 5: | ||
4942 | uentry_size = entry_size = sizeof(struct qeth_arp_qi_entry5); | ||
4943 | if (qinfo->mask_bits & QETH_QARP_STRIP_ENTRIES) | ||
4944 | uentry_size = sizeof(struct qeth_arp_qi_entry5_short); | ||
4945 | break; | ||
4946 | case 7: | ||
4947 | /* fall through to default */ | ||
4948 | default: | ||
4949 | /* tr is the same as eth -> entry7 */ | ||
4950 | uentry_size = entry_size = sizeof(struct qeth_arp_qi_entry7); | ||
4951 | if (qinfo->mask_bits & QETH_QARP_STRIP_ENTRIES) | ||
4952 | uentry_size = sizeof(struct qeth_arp_qi_entry7_short); | ||
4953 | break; | ||
4954 | } | ||
4955 | /* check if there is enough room in userspace */ | ||
4956 | if ((qinfo->udata_len - qinfo->udata_offset) < | ||
4957 | qdata->no_entries * uentry_size){ | ||
4958 | QETH_DBF_TEXT_(trace, 4, "qaer3%i", -ENOMEM); | ||
4959 | cmd->hdr.return_code = -ENOMEM; | ||
4960 | PRINT_WARN("query ARP user space buffer is too small for " | ||
4961 | "the returned number of ARP entries. " | ||
4962 | "Aborting query!\n"); | ||
4963 | goto out_error; | ||
4964 | } | ||
4965 | QETH_DBF_TEXT_(trace, 4, "anore%i", | ||
4966 | cmd->data.setassparms.hdr.number_of_replies); | ||
4967 | QETH_DBF_TEXT_(trace, 4, "aseqn%i", cmd->data.setassparms.hdr.seq_no); | ||
4968 | QETH_DBF_TEXT_(trace, 4, "anoen%i", qdata->no_entries); | ||
4969 | |||
4970 | if (qinfo->mask_bits & QETH_QARP_STRIP_ENTRIES) { | ||
4971 | /* strip off "media specific information" */ | ||
4972 | qeth_copy_arp_entries_stripped(qinfo, qdata, entry_size, | ||
4973 | uentry_size); | ||
4974 | } else | ||
4975 | /*copy entries to user buffer*/ | ||
4976 | memcpy(qinfo->udata + qinfo->udata_offset, | ||
4977 | (char *)&qdata->data, qdata->no_entries*uentry_size); | ||
4978 | |||
4979 | qinfo->no_entries += qdata->no_entries; | ||
4980 | qinfo->udata_offset += (qdata->no_entries*uentry_size); | ||
4981 | /* check if all replies received ... */ | ||
4982 | if (cmd->data.setassparms.hdr.seq_no < | ||
4983 | cmd->data.setassparms.hdr.number_of_replies) | ||
4984 | return 1; | ||
4985 | memcpy(qinfo->udata, &qinfo->no_entries, 4); | ||
4986 | /* keep STRIP_ENTRIES flag so the user program can distinguish | ||
4987 | * stripped entries from normal ones */ | ||
4988 | if (qinfo->mask_bits & QETH_QARP_STRIP_ENTRIES) | ||
4989 | qdata->reply_bits |= QETH_QARP_STRIP_ENTRIES; | ||
4990 | memcpy(qinfo->udata + QETH_QARP_MASK_OFFSET,&qdata->reply_bits,2); | ||
4991 | return 0; | ||
4992 | out_error: | ||
4993 | i = 0; | ||
4994 | memcpy(qinfo->udata, &i, 4); | ||
4995 | return 0; | ||
4996 | } | ||
4997 | |||
4998 | static int | ||
4999 | qeth_send_ipa_arp_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob, | ||
5000 | int len, int (*reply_cb)(struct qeth_card *, | ||
5001 | struct qeth_reply *, | ||
5002 | unsigned long), | ||
5003 | void *reply_param) | ||
5004 | { | ||
5005 | QETH_DBF_TEXT(trace,4,"sendarp"); | ||
5006 | |||
5007 | memcpy(iob->data, IPA_PDU_HEADER, IPA_PDU_HEADER_SIZE); | ||
5008 | memcpy(QETH_IPA_CMD_DEST_ADDR(iob->data), | ||
5009 | &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH); | ||
5010 | return qeth_send_control_data(card, IPA_PDU_HEADER_SIZE + len, iob, | ||
5011 | reply_cb, reply_param); | ||
5012 | } | ||
5013 | |||
5014 | static int | ||
5015 | qeth_send_ipa_snmp_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob, | ||
5016 | int len, int (*reply_cb)(struct qeth_card *, | ||
5017 | struct qeth_reply *, | ||
5018 | unsigned long), | ||
5019 | void *reply_param) | ||
5020 | { | ||
5021 | u16 s1, s2; | ||
5022 | |||
5023 | QETH_DBF_TEXT(trace,4,"sendsnmp"); | ||
5024 | |||
5025 | memcpy(iob->data, IPA_PDU_HEADER, IPA_PDU_HEADER_SIZE); | ||
5026 | memcpy(QETH_IPA_CMD_DEST_ADDR(iob->data), | ||
5027 | &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH); | ||
5028 | /* adjust PDU length fields in IPA_PDU_HEADER */ | ||
5029 | s1 = (u32) IPA_PDU_HEADER_SIZE + len; | ||
5030 | s2 = (u32) len; | ||
5031 | memcpy(QETH_IPA_PDU_LEN_TOTAL(iob->data), &s1, 2); | ||
5032 | memcpy(QETH_IPA_PDU_LEN_PDU1(iob->data), &s2, 2); | ||
5033 | memcpy(QETH_IPA_PDU_LEN_PDU2(iob->data), &s2, 2); | ||
5034 | memcpy(QETH_IPA_PDU_LEN_PDU3(iob->data), &s2, 2); | ||
5035 | return qeth_send_control_data(card, IPA_PDU_HEADER_SIZE + len, iob, | ||
5036 | reply_cb, reply_param); | ||
5037 | } | ||
5038 | |||
5039 | static struct qeth_cmd_buffer * | ||
5040 | qeth_get_setassparms_cmd(struct qeth_card *, enum qeth_ipa_funcs, | ||
5041 | __u16, __u16, enum qeth_prot_versions); | ||
5042 | static int | ||
5043 | qeth_arp_query(struct qeth_card *card, char __user *udata) | ||
5044 | { | ||
5045 | struct qeth_cmd_buffer *iob; | ||
5046 | struct qeth_arp_query_info qinfo = {0, }; | ||
5047 | int tmp; | ||
5048 | int rc; | ||
5049 | |||
5050 | QETH_DBF_TEXT(trace,3,"arpquery"); | ||
5051 | |||
5052 | if (!qeth_is_supported(card,/*IPA_QUERY_ARP_ADDR_INFO*/ | ||
5053 | IPA_ARP_PROCESSING)) { | ||
5054 | PRINT_WARN("ARP processing not supported " | ||
5055 | "on %s!\n", QETH_CARD_IFNAME(card)); | ||
5056 | return -EOPNOTSUPP; | ||
5057 | } | ||
5058 | /* get size of userspace buffer and mask_bits -> 6 bytes */ | ||
5059 | if (copy_from_user(&qinfo, udata, 6)) | ||
5060 | return -EFAULT; | ||
5061 | if (!(qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL))) | ||
5062 | return -ENOMEM; | ||
5063 | qinfo.udata_offset = QETH_QARP_ENTRIES_OFFSET; | ||
5064 | iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, | ||
5065 | IPA_CMD_ASS_ARP_QUERY_INFO, | ||
5066 | sizeof(int),QETH_PROT_IPV4); | ||
5067 | |||
5068 | rc = qeth_send_ipa_arp_cmd(card, iob, | ||
5069 | QETH_SETASS_BASE_LEN+QETH_ARP_CMD_LEN, | ||
5070 | qeth_arp_query_cb, (void *)&qinfo); | ||
5071 | if (rc) { | ||
5072 | tmp = rc; | ||
5073 | PRINT_WARN("Error while querying ARP cache on %s: %s " | ||
5074 | "(0x%x/%d)\n", | ||
5075 | QETH_CARD_IFNAME(card), qeth_arp_get_error_cause(&rc), | ||
5076 | tmp, tmp); | ||
5077 | if (copy_to_user(udata, qinfo.udata, 4)) | ||
5078 | rc = -EFAULT; | ||
5079 | } else { | ||
5080 | if (copy_to_user(udata, qinfo.udata, qinfo.udata_len)) | ||
5081 | rc = -EFAULT; | ||
5082 | } | ||
5083 | kfree(qinfo.udata); | ||
5084 | return rc; | ||
5085 | } | ||
5086 | |||
5087 | /** | ||
5088 | * SNMP command callback | ||
5089 | */ | ||
5090 | static int | ||
5091 | qeth_snmp_command_cb(struct qeth_card *card, struct qeth_reply *reply, | ||
5092 | unsigned long sdata) | ||
5093 | { | ||
5094 | struct qeth_ipa_cmd *cmd; | ||
5095 | struct qeth_arp_query_info *qinfo; | ||
5096 | struct qeth_snmp_cmd *snmp; | ||
5097 | unsigned char *data; | ||
5098 | __u16 data_len; | ||
5099 | |||
5100 | QETH_DBF_TEXT(trace,3,"snpcmdcb"); | ||
5101 | |||
5102 | cmd = (struct qeth_ipa_cmd *) sdata; | ||
5103 | data = (unsigned char *)((char *)cmd - reply->offset); | ||
5104 | qinfo = (struct qeth_arp_query_info *) reply->param; | ||
5105 | snmp = &cmd->data.setadapterparms.data.snmp; | ||
5106 | |||
5107 | if (cmd->hdr.return_code) { | ||
5108 | QETH_DBF_TEXT_(trace,4,"scer1%i", cmd->hdr.return_code); | ||
5109 | return 0; | ||
5110 | } | ||
5111 | if (cmd->data.setadapterparms.hdr.return_code) { | ||
5112 | cmd->hdr.return_code = cmd->data.setadapterparms.hdr.return_code; | ||
5113 | QETH_DBF_TEXT_(trace,4,"scer2%i", cmd->hdr.return_code); | ||
5114 | return 0; | ||
5115 | } | ||
5116 | data_len = *((__u16*)QETH_IPA_PDU_LEN_PDU1(data)); | ||
5117 | if (cmd->data.setadapterparms.hdr.seq_no == 1) | ||
5118 | data_len -= (__u16)((char *)&snmp->data - (char *)cmd); | ||
5119 | else | ||
5120 | data_len -= (__u16)((char*)&snmp->request - (char *)cmd); | ||
5121 | |||
5122 | /* check if there is enough room in userspace */ | ||
5123 | if ((qinfo->udata_len - qinfo->udata_offset) < data_len) { | ||
5124 | QETH_DBF_TEXT_(trace, 4, "scer3%i", -ENOMEM); | ||
5125 | cmd->hdr.return_code = -ENOMEM; | ||
5126 | return 0; | ||
5127 | } | ||
5128 | QETH_DBF_TEXT_(trace, 4, "snore%i", | ||
5129 | cmd->data.setadapterparms.hdr.used_total); | ||
5130 | QETH_DBF_TEXT_(trace, 4, "sseqn%i", cmd->data.setadapterparms.hdr.seq_no); | ||
5131 | /*copy entries to user buffer*/ | ||
5132 | if (cmd->data.setadapterparms.hdr.seq_no == 1) { | ||
5133 | memcpy(qinfo->udata + qinfo->udata_offset, | ||
5134 | (char *)snmp, | ||
5135 | data_len + offsetof(struct qeth_snmp_cmd,data)); | ||
5136 | qinfo->udata_offset += offsetof(struct qeth_snmp_cmd, data); | ||
5137 | } else { | ||
5138 | memcpy(qinfo->udata + qinfo->udata_offset, | ||
5139 | (char *)&snmp->request, data_len); | ||
5140 | } | ||
5141 | qinfo->udata_offset += data_len; | ||
5142 | /* check if all replies received ... */ | ||
5143 | QETH_DBF_TEXT_(trace, 4, "srtot%i", | ||
5144 | cmd->data.setadapterparms.hdr.used_total); | ||
5145 | QETH_DBF_TEXT_(trace, 4, "srseq%i", | ||
5146 | cmd->data.setadapterparms.hdr.seq_no); | ||
5147 | if (cmd->data.setadapterparms.hdr.seq_no < | ||
5148 | cmd->data.setadapterparms.hdr.used_total) | ||
5149 | return 1; | ||
5150 | return 0; | ||
5151 | } | ||
5152 | |||
5153 | static struct qeth_cmd_buffer * | ||
5154 | qeth_get_ipacmd_buffer(struct qeth_card *, enum qeth_ipa_cmds, | ||
5155 | enum qeth_prot_versions ); | ||
5156 | |||
5157 | static struct qeth_cmd_buffer * | ||
5158 | qeth_get_adapter_cmd(struct qeth_card *card, __u32 command, __u32 cmdlen) | ||
5159 | { | ||
5160 | struct qeth_cmd_buffer *iob; | ||
5161 | struct qeth_ipa_cmd *cmd; | ||
5162 | |||
5163 | iob = qeth_get_ipacmd_buffer(card,IPA_CMD_SETADAPTERPARMS, | ||
5164 | QETH_PROT_IPV4); | ||
5165 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); | ||
5166 | cmd->data.setadapterparms.hdr.cmdlength = cmdlen; | ||
5167 | cmd->data.setadapterparms.hdr.command_code = command; | ||
5168 | cmd->data.setadapterparms.hdr.used_total = 1; | ||
5169 | cmd->data.setadapterparms.hdr.seq_no = 1; | ||
5170 | |||
5171 | return iob; | ||
5172 | } | ||
5173 | |||
5174 | /** | ||
5175 | * function to send SNMP commands to OSA-E card | ||
5176 | */ | ||
5177 | static int | ||
5178 | qeth_snmp_command(struct qeth_card *card, char __user *udata) | ||
5179 | { | ||
5180 | struct qeth_cmd_buffer *iob; | ||
5181 | struct qeth_ipa_cmd *cmd; | ||
5182 | struct qeth_snmp_ureq *ureq; | ||
5183 | int req_len; | ||
5184 | struct qeth_arp_query_info qinfo = {0, }; | ||
5185 | int rc = 0; | ||
5186 | |||
5187 | QETH_DBF_TEXT(trace,3,"snmpcmd"); | ||
5188 | |||
5189 | if (card->info.guestlan) | ||
5190 | return -EOPNOTSUPP; | ||
5191 | |||
5192 | if ((!qeth_adp_supported(card,IPA_SETADP_SET_SNMP_CONTROL)) && | ||
5193 | (!card->options.layer2) ) { | ||
5194 | PRINT_WARN("SNMP Query MIBS not supported " | ||
5195 | "on %s!\n", QETH_CARD_IFNAME(card)); | ||
5196 | return -EOPNOTSUPP; | ||
5197 | } | ||
5198 | /* skip 4 bytes (data_len struct member) to get req_len */ | ||
5199 | if (copy_from_user(&req_len, udata + sizeof(int), sizeof(int))) | ||
5200 | return -EFAULT; | ||
5201 | ureq = kmalloc(req_len+sizeof(struct qeth_snmp_ureq_hdr), GFP_KERNEL); | ||
5202 | if (!ureq) { | ||
5203 | QETH_DBF_TEXT(trace, 2, "snmpnome"); | ||
5204 | return -ENOMEM; | ||
5205 | } | ||
5206 | if (copy_from_user(ureq, udata, | ||
5207 | req_len+sizeof(struct qeth_snmp_ureq_hdr))){ | ||
5208 | kfree(ureq); | ||
5209 | return -EFAULT; | ||
5210 | } | ||
5211 | qinfo.udata_len = ureq->hdr.data_len; | ||
5212 | if (!(qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL))){ | ||
5213 | kfree(ureq); | ||
5214 | return -ENOMEM; | ||
5215 | } | ||
5216 | qinfo.udata_offset = sizeof(struct qeth_snmp_ureq_hdr); | ||
5217 | |||
5218 | iob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_SNMP_CONTROL, | ||
5219 | QETH_SNMP_SETADP_CMDLENGTH + req_len); | ||
5220 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); | ||
5221 | memcpy(&cmd->data.setadapterparms.data.snmp, &ureq->cmd, req_len); | ||
5222 | rc = qeth_send_ipa_snmp_cmd(card, iob, QETH_SETADP_BASE_LEN + req_len, | ||
5223 | qeth_snmp_command_cb, (void *)&qinfo); | ||
5224 | if (rc) | ||
5225 | PRINT_WARN("SNMP command failed on %s: (0x%x)\n", | ||
5226 | QETH_CARD_IFNAME(card), rc); | ||
5227 | else { | ||
5228 | if (copy_to_user(udata, qinfo.udata, qinfo.udata_len)) | ||
5229 | rc = -EFAULT; | ||
5230 | } | ||
5231 | |||
5232 | kfree(ureq); | ||
5233 | kfree(qinfo.udata); | ||
5234 | return rc; | ||
5235 | } | ||
5236 | |||
5237 | static int | ||
5238 | qeth_default_setassparms_cb(struct qeth_card *, struct qeth_reply *, | ||
5239 | unsigned long); | ||
5240 | |||
5241 | static int | ||
5242 | qeth_default_setadapterparms_cb(struct qeth_card *card, | ||
5243 | struct qeth_reply *reply, | ||
5244 | unsigned long data); | ||
5245 | static int | ||
5246 | qeth_send_setassparms(struct qeth_card *, struct qeth_cmd_buffer *, | ||
5247 | __u16, long, | ||
5248 | int (*reply_cb) | ||
5249 | (struct qeth_card *, struct qeth_reply *, unsigned long), | ||
5250 | void *reply_param); | ||
5251 | |||
5252 | static int | ||
5253 | qeth_arp_add_entry(struct qeth_card *card, struct qeth_arp_cache_entry *entry) | ||
5254 | { | ||
5255 | struct qeth_cmd_buffer *iob; | ||
5256 | char buf[16]; | ||
5257 | int tmp; | ||
5258 | int rc; | ||
5259 | |||
5260 | QETH_DBF_TEXT(trace,3,"arpadent"); | ||
5261 | |||
5262 | /* | ||
5263 | * currently GuestLAN only supports the ARP assist function | ||
5264 | * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_ADD_ENTRY; | ||
5265 | * thus we say EOPNOTSUPP for this ARP function | ||
5266 | */ | ||
5267 | if (card->info.guestlan) | ||
5268 | return -EOPNOTSUPP; | ||
5269 | if (!qeth_is_supported(card,IPA_ARP_PROCESSING)) { | ||
5270 | PRINT_WARN("ARP processing not supported " | ||
5271 | "on %s!\n", QETH_CARD_IFNAME(card)); | ||
5272 | return -EOPNOTSUPP; | ||
5273 | } | ||
5274 | |||
5275 | iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, | ||
5276 | IPA_CMD_ASS_ARP_ADD_ENTRY, | ||
5277 | sizeof(struct qeth_arp_cache_entry), | ||
5278 | QETH_PROT_IPV4); | ||
5279 | rc = qeth_send_setassparms(card, iob, | ||
5280 | sizeof(struct qeth_arp_cache_entry), | ||
5281 | (unsigned long) entry, | ||
5282 | qeth_default_setassparms_cb, NULL); | ||
5283 | if (rc) { | ||
5284 | tmp = rc; | ||
5285 | qeth_ipaddr4_to_string((u8 *)entry->ipaddr, buf); | ||
5286 | PRINT_WARN("Could not add ARP entry for address %s on %s: " | ||
5287 | "%s (0x%x/%d)\n", | ||
5288 | buf, QETH_CARD_IFNAME(card), | ||
5289 | qeth_arp_get_error_cause(&rc), tmp, tmp); | ||
5290 | } | ||
5291 | return rc; | ||
5292 | } | ||
5293 | |||
5294 | static int | ||
5295 | qeth_arp_remove_entry(struct qeth_card *card, struct qeth_arp_cache_entry *entry) | ||
5296 | { | ||
5297 | struct qeth_cmd_buffer *iob; | ||
5298 | char buf[16] = {0, }; | ||
5299 | int tmp; | ||
5300 | int rc; | ||
5301 | |||
5302 | QETH_DBF_TEXT(trace,3,"arprment"); | ||
5303 | |||
5304 | /* | ||
5305 | * currently GuestLAN only supports the ARP assist function | ||
5306 | * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_REMOVE_ENTRY; | ||
5307 | * thus we say EOPNOTSUPP for this ARP function | ||
5308 | */ | ||
5309 | if (card->info.guestlan) | ||
5310 | return -EOPNOTSUPP; | ||
5311 | if (!qeth_is_supported(card,IPA_ARP_PROCESSING)) { | ||
5312 | PRINT_WARN("ARP processing not supported " | ||
5313 | "on %s!\n", QETH_CARD_IFNAME(card)); | ||
5314 | return -EOPNOTSUPP; | ||
5315 | } | ||
5316 | memcpy(buf, entry, 12); | ||
5317 | iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, | ||
5318 | IPA_CMD_ASS_ARP_REMOVE_ENTRY, | ||
5319 | 12, | ||
5320 | QETH_PROT_IPV4); | ||
5321 | rc = qeth_send_setassparms(card, iob, | ||
5322 | 12, (unsigned long)buf, | ||
5323 | qeth_default_setassparms_cb, NULL); | ||
5324 | if (rc) { | ||
5325 | tmp = rc; | ||
5326 | memset(buf, 0, 16); | ||
5327 | qeth_ipaddr4_to_string((u8 *)entry->ipaddr, buf); | ||
5328 | PRINT_WARN("Could not delete ARP entry for address %s on %s: " | ||
5329 | "%s (0x%x/%d)\n", | ||
5330 | buf, QETH_CARD_IFNAME(card), | ||
5331 | qeth_arp_get_error_cause(&rc), tmp, tmp); | ||
5332 | } | ||
5333 | return rc; | ||
5334 | } | ||
5335 | |||
5336 | static int | ||
5337 | qeth_arp_flush_cache(struct qeth_card *card) | ||
5338 | { | ||
5339 | int rc; | ||
5340 | int tmp; | ||
5341 | |||
5342 | QETH_DBF_TEXT(trace,3,"arpflush"); | ||
5343 | |||
5344 | /* | ||
5345 | * currently GuestLAN only supports the ARP assist function | ||
5346 | * IPA_CMD_ASS_ARP_QUERY_INFO, but not IPA_CMD_ASS_ARP_FLUSH_CACHE; | ||
5347 | * thus we say EOPNOTSUPP for this ARP function | ||
5348 | */ | ||
5349 | if (card->info.guestlan || (card->info.type == QETH_CARD_TYPE_IQD)) | ||
5350 | return -EOPNOTSUPP; | ||
5351 | if (!qeth_is_supported(card,IPA_ARP_PROCESSING)) { | ||
5352 | PRINT_WARN("ARP processing not supported " | ||
5353 | "on %s!\n", QETH_CARD_IFNAME(card)); | ||
5354 | return -EOPNOTSUPP; | ||
5355 | } | ||
5356 | rc = qeth_send_simple_setassparms(card, IPA_ARP_PROCESSING, | ||
5357 | IPA_CMD_ASS_ARP_FLUSH_CACHE, 0); | ||
5358 | if (rc){ | ||
5359 | tmp = rc; | ||
5360 | PRINT_WARN("Could not flush ARP cache on %s: %s (0x%x/%d)\n", | ||
5361 | QETH_CARD_IFNAME(card), qeth_arp_get_error_cause(&rc), | ||
5362 | tmp, tmp); | ||
5363 | } | ||
5364 | return rc; | ||
5365 | } | ||
5366 | |||
5367 | static int | ||
5368 | qeth_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | ||
5369 | { | ||
5370 | struct qeth_card *card = (struct qeth_card *)dev->priv; | ||
5371 | struct qeth_arp_cache_entry arp_entry; | ||
5372 | struct mii_ioctl_data *mii_data; | ||
5373 | int rc = 0; | ||
5374 | |||
5375 | if (!card) | ||
5376 | return -ENODEV; | ||
5377 | |||
5378 | if ((card->state != CARD_STATE_UP) && | ||
5379 | (card->state != CARD_STATE_SOFTSETUP)) | ||
5380 | return -ENODEV; | ||
5381 | |||
5382 | if (card->info.type == QETH_CARD_TYPE_OSN) | ||
5383 | return -EPERM; | ||
5384 | |||
5385 | switch (cmd){ | ||
5386 | case SIOC_QETH_ARP_SET_NO_ENTRIES: | ||
5387 | if ( !capable(CAP_NET_ADMIN) || | ||
5388 | (card->options.layer2) ) { | ||
5389 | rc = -EPERM; | ||
5390 | break; | ||
5391 | } | ||
5392 | rc = qeth_arp_set_no_entries(card, rq->ifr_ifru.ifru_ivalue); | ||
5393 | break; | ||
5394 | case SIOC_QETH_ARP_QUERY_INFO: | ||
5395 | if ( !capable(CAP_NET_ADMIN) || | ||
5396 | (card->options.layer2) ) { | ||
5397 | rc = -EPERM; | ||
5398 | break; | ||
5399 | } | ||
5400 | rc = qeth_arp_query(card, rq->ifr_ifru.ifru_data); | ||
5401 | break; | ||
5402 | case SIOC_QETH_ARP_ADD_ENTRY: | ||
5403 | if ( !capable(CAP_NET_ADMIN) || | ||
5404 | (card->options.layer2) ) { | ||
5405 | rc = -EPERM; | ||
5406 | break; | ||
5407 | } | ||
5408 | if (copy_from_user(&arp_entry, rq->ifr_ifru.ifru_data, | ||
5409 | sizeof(struct qeth_arp_cache_entry))) | ||
5410 | rc = -EFAULT; | ||
5411 | else | ||
5412 | rc = qeth_arp_add_entry(card, &arp_entry); | ||
5413 | break; | ||
5414 | case SIOC_QETH_ARP_REMOVE_ENTRY: | ||
5415 | if ( !capable(CAP_NET_ADMIN) || | ||
5416 | (card->options.layer2) ) { | ||
5417 | rc = -EPERM; | ||
5418 | break; | ||
5419 | } | ||
5420 | if (copy_from_user(&arp_entry, rq->ifr_ifru.ifru_data, | ||
5421 | sizeof(struct qeth_arp_cache_entry))) | ||
5422 | rc = -EFAULT; | ||
5423 | else | ||
5424 | rc = qeth_arp_remove_entry(card, &arp_entry); | ||
5425 | break; | ||
5426 | case SIOC_QETH_ARP_FLUSH_CACHE: | ||
5427 | if ( !capable(CAP_NET_ADMIN) || | ||
5428 | (card->options.layer2) ) { | ||
5429 | rc = -EPERM; | ||
5430 | break; | ||
5431 | } | ||
5432 | rc = qeth_arp_flush_cache(card); | ||
5433 | break; | ||
5434 | case SIOC_QETH_ADP_SET_SNMP_CONTROL: | ||
5435 | rc = qeth_snmp_command(card, rq->ifr_ifru.ifru_data); | ||
5436 | break; | ||
5437 | case SIOC_QETH_GET_CARD_TYPE: | ||
5438 | if ((card->info.type == QETH_CARD_TYPE_OSAE) && | ||
5439 | !card->info.guestlan) | ||
5440 | return 1; | ||
5441 | return 0; | ||
5442 | break; | ||
5443 | case SIOCGMIIPHY: | ||
5444 | mii_data = if_mii(rq); | ||
5445 | mii_data->phy_id = 0; | ||
5446 | break; | ||
5447 | case SIOCGMIIREG: | ||
5448 | mii_data = if_mii(rq); | ||
5449 | if (mii_data->phy_id != 0) | ||
5450 | rc = -EINVAL; | ||
5451 | else | ||
5452 | mii_data->val_out = qeth_mdio_read(dev,mii_data->phy_id, | ||
5453 | mii_data->reg_num); | ||
5454 | break; | ||
5455 | default: | ||
5456 | rc = -EOPNOTSUPP; | ||
5457 | } | ||
5458 | if (rc) | ||
5459 | QETH_DBF_TEXT_(trace, 2, "ioce%d", rc); | ||
5460 | return rc; | ||
5461 | } | ||
5462 | |||
5463 | static struct net_device_stats * | ||
5464 | qeth_get_stats(struct net_device *dev) | ||
5465 | { | ||
5466 | struct qeth_card *card; | ||
5467 | |||
5468 | card = (struct qeth_card *) (dev->priv); | ||
5469 | |||
5470 | QETH_DBF_TEXT(trace,5,"getstat"); | ||
5471 | |||
5472 | return &card->stats; | ||
5473 | } | ||
5474 | |||
5475 | static int | ||
5476 | qeth_change_mtu(struct net_device *dev, int new_mtu) | ||
5477 | { | ||
5478 | struct qeth_card *card; | ||
5479 | char dbf_text[15]; | ||
5480 | |||
5481 | card = (struct qeth_card *) (dev->priv); | ||
5482 | |||
5483 | QETH_DBF_TEXT(trace,4,"chgmtu"); | ||
5484 | sprintf(dbf_text, "%8x", new_mtu); | ||
5485 | QETH_DBF_TEXT(trace,4,dbf_text); | ||
5486 | |||
5487 | if (new_mtu < 64) | ||
5488 | return -EINVAL; | ||
5489 | if (new_mtu > 65535) | ||
5490 | return -EINVAL; | ||
5491 | if ((!qeth_is_supported(card,IPA_IP_FRAGMENTATION)) && | ||
5492 | (!qeth_mtu_is_valid(card, new_mtu))) | ||
5493 | return -EINVAL; | ||
5494 | dev->mtu = new_mtu; | ||
5495 | return 0; | ||
5496 | } | ||
5497 | |||
5498 | #ifdef CONFIG_QETH_VLAN | ||
5499 | static void | ||
5500 | qeth_vlan_rx_register(struct net_device *dev, struct vlan_group *grp) | ||
5501 | { | ||
5502 | struct qeth_card *card; | ||
5503 | unsigned long flags; | ||
5504 | |||
5505 | QETH_DBF_TEXT(trace,4,"vlanreg"); | ||
5506 | |||
5507 | card = (struct qeth_card *) dev->priv; | ||
5508 | spin_lock_irqsave(&card->vlanlock, flags); | ||
5509 | card->vlangrp = grp; | ||
5510 | spin_unlock_irqrestore(&card->vlanlock, flags); | ||
5511 | } | ||
5512 | |||
5513 | static void | ||
5514 | qeth_free_vlan_buffer(struct qeth_card *card, struct qeth_qdio_out_buffer *buf, | ||
5515 | unsigned short vid) | ||
5516 | { | ||
5517 | int i; | ||
5518 | struct sk_buff *skb; | ||
5519 | struct sk_buff_head tmp_list; | ||
5520 | |||
5521 | skb_queue_head_init(&tmp_list); | ||
5522 | lockdep_set_class(&tmp_list.lock, &qdio_out_skb_queue_key); | ||
5523 | for(i = 0; i < QETH_MAX_BUFFER_ELEMENTS(card); ++i){ | ||
5524 | while ((skb = skb_dequeue(&buf->skb_list))){ | ||
5525 | if (vlan_tx_tag_present(skb) && | ||
5526 | (vlan_tx_tag_get(skb) == vid)) { | ||
5527 | atomic_dec(&skb->users); | ||
5528 | dev_kfree_skb(skb); | ||
5529 | } else | ||
5530 | skb_queue_tail(&tmp_list, skb); | ||
5531 | } | ||
5532 | } | ||
5533 | while ((skb = skb_dequeue(&tmp_list))) | ||
5534 | skb_queue_tail(&buf->skb_list, skb); | ||
5535 | } | ||
5536 | |||
5537 | static void | ||
5538 | qeth_free_vlan_skbs(struct qeth_card *card, unsigned short vid) | ||
5539 | { | ||
5540 | int i, j; | ||
5541 | |||
5542 | QETH_DBF_TEXT(trace, 4, "frvlskbs"); | ||
5543 | for (i = 0; i < card->qdio.no_out_queues; ++i){ | ||
5544 | for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; ++j) | ||
5545 | qeth_free_vlan_buffer(card, &card->qdio. | ||
5546 | out_qs[i]->bufs[j], vid); | ||
5547 | } | ||
5548 | } | ||
5549 | |||
5550 | static void | ||
5551 | qeth_free_vlan_addresses4(struct qeth_card *card, unsigned short vid) | ||
5552 | { | ||
5553 | struct in_device *in_dev; | ||
5554 | struct in_ifaddr *ifa; | ||
5555 | struct qeth_ipaddr *addr; | ||
5556 | |||
5557 | QETH_DBF_TEXT(trace, 4, "frvaddr4"); | ||
5558 | |||
5559 | rcu_read_lock(); | ||
5560 | in_dev = __in_dev_get_rcu(vlan_group_get_device(card->vlangrp, vid)); | ||
5561 | if (!in_dev) | ||
5562 | goto out; | ||
5563 | for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { | ||
5564 | addr = qeth_get_addr_buffer(QETH_PROT_IPV4); | ||
5565 | if (addr){ | ||
5566 | addr->u.a4.addr = ifa->ifa_address; | ||
5567 | addr->u.a4.mask = ifa->ifa_mask; | ||
5568 | addr->type = QETH_IP_TYPE_NORMAL; | ||
5569 | if (!qeth_delete_ip(card, addr)) | ||
5570 | kfree(addr); | ||
5571 | } | ||
5572 | } | ||
5573 | out: | ||
5574 | rcu_read_unlock(); | ||
5575 | } | ||
5576 | |||
5577 | static void | ||
5578 | qeth_free_vlan_addresses6(struct qeth_card *card, unsigned short vid) | ||
5579 | { | ||
5580 | #ifdef CONFIG_QETH_IPV6 | ||
5581 | struct inet6_dev *in6_dev; | ||
5582 | struct inet6_ifaddr *ifa; | ||
5583 | struct qeth_ipaddr *addr; | ||
5584 | |||
5585 | QETH_DBF_TEXT(trace, 4, "frvaddr6"); | ||
5586 | |||
5587 | in6_dev = in6_dev_get(vlan_group_get_device(card->vlangrp, vid)); | ||
5588 | if (!in6_dev) | ||
5589 | return; | ||
5590 | for (ifa = in6_dev->addr_list; ifa; ifa = ifa->lst_next){ | ||
5591 | addr = qeth_get_addr_buffer(QETH_PROT_IPV6); | ||
5592 | if (addr){ | ||
5593 | memcpy(&addr->u.a6.addr, &ifa->addr, | ||
5594 | sizeof(struct in6_addr)); | ||
5595 | addr->u.a6.pfxlen = ifa->prefix_len; | ||
5596 | addr->type = QETH_IP_TYPE_NORMAL; | ||
5597 | if (!qeth_delete_ip(card, addr)) | ||
5598 | kfree(addr); | ||
5599 | } | ||
5600 | } | ||
5601 | in6_dev_put(in6_dev); | ||
5602 | #endif /* CONFIG_QETH_IPV6 */ | ||
5603 | } | ||
5604 | |||
5605 | static void | ||
5606 | qeth_free_vlan_addresses(struct qeth_card *card, unsigned short vid) | ||
5607 | { | ||
5608 | if (card->options.layer2 || !card->vlangrp) | ||
5609 | return; | ||
5610 | qeth_free_vlan_addresses4(card, vid); | ||
5611 | qeth_free_vlan_addresses6(card, vid); | ||
5612 | } | ||
5613 | |||
5614 | static int | ||
5615 | qeth_layer2_send_setdelvlan_cb(struct qeth_card *card, | ||
5616 | struct qeth_reply *reply, | ||
5617 | unsigned long data) | ||
5618 | { | ||
5619 | struct qeth_ipa_cmd *cmd; | ||
5620 | |||
5621 | QETH_DBF_TEXT(trace, 2, "L2sdvcb"); | ||
5622 | cmd = (struct qeth_ipa_cmd *) data; | ||
5623 | if (cmd->hdr.return_code) { | ||
5624 | PRINT_ERR("Error in processing VLAN %i on %s: 0x%x. " | ||
5625 | "Continuing\n",cmd->data.setdelvlan.vlan_id, | ||
5626 | QETH_CARD_IFNAME(card), cmd->hdr.return_code); | ||
5627 | QETH_DBF_TEXT_(trace, 2, "L2VL%4x", cmd->hdr.command); | ||
5628 | QETH_DBF_TEXT_(trace, 2, "L2%s", CARD_BUS_ID(card)); | ||
5629 | QETH_DBF_TEXT_(trace, 2, "err%d", cmd->hdr.return_code); | ||
5630 | } | ||
5631 | return 0; | ||
5632 | } | ||
5633 | |||
5634 | static int | ||
5635 | qeth_layer2_send_setdelvlan(struct qeth_card *card, __u16 i, | ||
5636 | enum qeth_ipa_cmds ipacmd) | ||
5637 | { | ||
5638 | struct qeth_ipa_cmd *cmd; | ||
5639 | struct qeth_cmd_buffer *iob; | ||
5640 | |||
5641 | QETH_DBF_TEXT_(trace, 4, "L2sdv%x",ipacmd); | ||
5642 | iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4); | ||
5643 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); | ||
5644 | cmd->data.setdelvlan.vlan_id = i; | ||
5645 | return qeth_send_ipa_cmd(card, iob, | ||
5646 | qeth_layer2_send_setdelvlan_cb, NULL); | ||
5647 | } | ||
5648 | |||
5649 | static void | ||
5650 | qeth_layer2_process_vlans(struct qeth_card *card, int clear) | ||
5651 | { | ||
5652 | unsigned short i; | ||
5653 | |||
5654 | QETH_DBF_TEXT(trace, 3, "L2prcvln"); | ||
5655 | |||
5656 | if (!card->vlangrp) | ||
5657 | return; | ||
5658 | for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) { | ||
5659 | if (vlan_group_get_device(card->vlangrp, i) == NULL) | ||
5660 | continue; | ||
5661 | if (clear) | ||
5662 | qeth_layer2_send_setdelvlan(card, i, IPA_CMD_DELVLAN); | ||
5663 | else | ||
5664 | qeth_layer2_send_setdelvlan(card, i, IPA_CMD_SETVLAN); | ||
5665 | } | ||
5666 | } | ||
5667 | |||
5668 | /*add_vid is layer 2 used only ....*/ | ||
5669 | static void | ||
5670 | qeth_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) | ||
5671 | { | ||
5672 | struct qeth_card *card; | ||
5673 | |||
5674 | QETH_DBF_TEXT_(trace, 4, "aid:%d", vid); | ||
5675 | |||
5676 | card = (struct qeth_card *) dev->priv; | ||
5677 | if (!card->options.layer2) | ||
5678 | return; | ||
5679 | qeth_layer2_send_setdelvlan(card, vid, IPA_CMD_SETVLAN); | ||
5680 | } | ||
5681 | |||
5682 | /*... kill_vid used for both modes*/ | ||
5683 | static void | ||
5684 | qeth_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) | ||
5685 | { | ||
5686 | struct qeth_card *card; | ||
5687 | unsigned long flags; | ||
5688 | |||
5689 | QETH_DBF_TEXT_(trace, 4, "kid:%d", vid); | ||
5690 | |||
5691 | card = (struct qeth_card *) dev->priv; | ||
5692 | /* free all skbs for the vlan device */ | ||
5693 | qeth_free_vlan_skbs(card, vid); | ||
5694 | spin_lock_irqsave(&card->vlanlock, flags); | ||
5695 | /* unregister IP addresses of vlan device */ | ||
5696 | qeth_free_vlan_addresses(card, vid); | ||
5697 | vlan_group_set_device(card->vlangrp, vid, NULL); | ||
5698 | spin_unlock_irqrestore(&card->vlanlock, flags); | ||
5699 | if (card->options.layer2) | ||
5700 | qeth_layer2_send_setdelvlan(card, vid, IPA_CMD_DELVLAN); | ||
5701 | qeth_set_multicast_list(card->dev); | ||
5702 | } | ||
5703 | #endif | ||
5704 | /** | ||
5705 | * Examine hardware response to SET_PROMISC_MODE | ||
5706 | */ | ||
5707 | static int | ||
5708 | qeth_setadp_promisc_mode_cb(struct qeth_card *card, | ||
5709 | struct qeth_reply *reply, | ||
5710 | unsigned long data) | ||
5711 | { | ||
5712 | struct qeth_ipa_cmd *cmd; | ||
5713 | struct qeth_ipacmd_setadpparms *setparms; | ||
5714 | |||
5715 | QETH_DBF_TEXT(trace,4,"prmadpcb"); | ||
5716 | |||
5717 | cmd = (struct qeth_ipa_cmd *) data; | ||
5718 | setparms = &(cmd->data.setadapterparms); | ||
5719 | |||
5720 | qeth_default_setadapterparms_cb(card, reply, (unsigned long)cmd); | ||
5721 | if (cmd->hdr.return_code) { | ||
5722 | QETH_DBF_TEXT_(trace,4,"prmrc%2.2x",cmd->hdr.return_code); | ||
5723 | setparms->data.mode = SET_PROMISC_MODE_OFF; | ||
5724 | } | ||
5725 | card->info.promisc_mode = setparms->data.mode; | ||
5726 | return 0; | ||
5727 | } | ||
5728 | /* | ||
5729 | * Set promiscuous mode (on or off) (SET_PROMISC_MODE command) | ||
5730 | */ | ||
5731 | static void | ||
5732 | qeth_setadp_promisc_mode(struct qeth_card *card) | ||
5733 | { | ||
5734 | enum qeth_ipa_promisc_modes mode; | ||
5735 | struct net_device *dev = card->dev; | ||
5736 | struct qeth_cmd_buffer *iob; | ||
5737 | struct qeth_ipa_cmd *cmd; | ||
5738 | |||
5739 | QETH_DBF_TEXT(trace, 4, "setprom"); | ||
5740 | |||
5741 | if (((dev->flags & IFF_PROMISC) && | ||
5742 | (card->info.promisc_mode == SET_PROMISC_MODE_ON)) || | ||
5743 | (!(dev->flags & IFF_PROMISC) && | ||
5744 | (card->info.promisc_mode == SET_PROMISC_MODE_OFF))) | ||
5745 | return; | ||
5746 | mode = SET_PROMISC_MODE_OFF; | ||
5747 | if (dev->flags & IFF_PROMISC) | ||
5748 | mode = SET_PROMISC_MODE_ON; | ||
5749 | QETH_DBF_TEXT_(trace, 4, "mode:%x", mode); | ||
5750 | |||
5751 | iob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_PROMISC_MODE, | ||
5752 | sizeof(struct qeth_ipacmd_setadpparms)); | ||
5753 | cmd = (struct qeth_ipa_cmd *)(iob->data + IPA_PDU_HEADER_SIZE); | ||
5754 | cmd->data.setadapterparms.data.mode = mode; | ||
5755 | qeth_send_ipa_cmd(card, iob, qeth_setadp_promisc_mode_cb, NULL); | ||
5756 | } | ||
5757 | |||
5758 | /** | ||
5759 | * set multicast address on card | ||
5760 | */ | ||
5761 | static void | ||
5762 | qeth_set_multicast_list(struct net_device *dev) | ||
5763 | { | ||
5764 | struct qeth_card *card = (struct qeth_card *) dev->priv; | ||
5765 | |||
5766 | if (card->info.type == QETH_CARD_TYPE_OSN) | ||
5767 | return ; | ||
5768 | |||
5769 | QETH_DBF_TEXT(trace, 3, "setmulti"); | ||
5770 | qeth_delete_mc_addresses(card); | ||
5771 | if (card->options.layer2) { | ||
5772 | qeth_layer2_add_multicast(card); | ||
5773 | goto out; | ||
5774 | } | ||
5775 | qeth_add_multicast_ipv4(card); | ||
5776 | #ifdef CONFIG_QETH_IPV6 | ||
5777 | qeth_add_multicast_ipv6(card); | ||
5778 | #endif | ||
5779 | out: | ||
5780 | qeth_set_ip_addr_list(card); | ||
5781 | if (!qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) | ||
5782 | return; | ||
5783 | qeth_setadp_promisc_mode(card); | ||
5784 | } | ||
5785 | |||
5786 | static int | ||
5787 | qeth_neigh_setup(struct net_device *dev, struct neigh_parms *np) | ||
5788 | { | ||
5789 | return 0; | ||
5790 | } | ||
5791 | |||
5792 | static void | ||
5793 | qeth_get_mac_for_ipm(__u32 ipm, char *mac, struct net_device *dev) | ||
5794 | { | ||
5795 | if (dev->type == ARPHRD_IEEE802_TR) | ||
5796 | ip_tr_mc_map(ipm, mac); | ||
5797 | else | ||
5798 | ip_eth_mc_map(ipm, mac); | ||
5799 | } | ||
5800 | |||
5801 | static struct qeth_ipaddr * | ||
5802 | qeth_get_addr_buffer(enum qeth_prot_versions prot) | ||
5803 | { | ||
5804 | struct qeth_ipaddr *addr; | ||
5805 | |||
5806 | addr = kzalloc(sizeof(struct qeth_ipaddr), GFP_ATOMIC); | ||
5807 | if (addr == NULL) { | ||
5808 | PRINT_WARN("Not enough memory to add address\n"); | ||
5809 | return NULL; | ||
5810 | } | ||
5811 | addr->type = QETH_IP_TYPE_NORMAL; | ||
5812 | addr->proto = prot; | ||
5813 | return addr; | ||
5814 | } | ||
5815 | |||
5816 | int | ||
5817 | qeth_osn_assist(struct net_device *dev, | ||
5818 | void *data, | ||
5819 | int data_len) | ||
5820 | { | ||
5821 | struct qeth_cmd_buffer *iob; | ||
5822 | struct qeth_card *card; | ||
5823 | int rc; | ||
5824 | |||
5825 | QETH_DBF_TEXT(trace, 2, "osnsdmc"); | ||
5826 | if (!dev) | ||
5827 | return -ENODEV; | ||
5828 | card = (struct qeth_card *)dev->priv; | ||
5829 | if (!card) | ||
5830 | return -ENODEV; | ||
5831 | if ((card->state != CARD_STATE_UP) && | ||
5832 | (card->state != CARD_STATE_SOFTSETUP)) | ||
5833 | return -ENODEV; | ||
5834 | iob = qeth_wait_for_buffer(&card->write); | ||
5835 | memcpy(iob->data+IPA_PDU_HEADER_SIZE, data, data_len); | ||
5836 | rc = qeth_osn_send_ipa_cmd(card, iob, data_len); | ||
5837 | return rc; | ||
5838 | } | ||
5839 | |||
5840 | static struct net_device * | ||
5841 | qeth_netdev_by_devno(unsigned char *read_dev_no) | ||
5842 | { | ||
5843 | struct qeth_card *card; | ||
5844 | struct net_device *ndev; | ||
5845 | unsigned char *readno; | ||
5846 | __u16 temp_dev_no, card_dev_no; | ||
5847 | char *endp; | ||
5848 | unsigned long flags; | ||
5849 | |||
5850 | ndev = NULL; | ||
5851 | memcpy(&temp_dev_no, read_dev_no, 2); | ||
5852 | read_lock_irqsave(&qeth_card_list.rwlock, flags); | ||
5853 | list_for_each_entry(card, &qeth_card_list.list, list) { | ||
5854 | readno = CARD_RDEV_ID(card); | ||
5855 | readno += (strlen(readno) - 4); | ||
5856 | card_dev_no = simple_strtoul(readno, &endp, 16); | ||
5857 | if (card_dev_no == temp_dev_no) { | ||
5858 | ndev = card->dev; | ||
5859 | break; | ||
5860 | } | ||
5861 | } | ||
5862 | read_unlock_irqrestore(&qeth_card_list.rwlock, flags); | ||
5863 | return ndev; | ||
5864 | } | ||
5865 | |||
5866 | int | ||
5867 | qeth_osn_register(unsigned char *read_dev_no, | ||
5868 | struct net_device **dev, | ||
5869 | int (*assist_cb)(struct net_device *, void *), | ||
5870 | int (*data_cb)(struct sk_buff *)) | ||
5871 | { | ||
5872 | struct qeth_card * card; | ||
5873 | |||
5874 | QETH_DBF_TEXT(trace, 2, "osnreg"); | ||
5875 | *dev = qeth_netdev_by_devno(read_dev_no); | ||
5876 | if (*dev == NULL) | ||
5877 | return -ENODEV; | ||
5878 | card = (struct qeth_card *)(*dev)->priv; | ||
5879 | if (!card) | ||
5880 | return -ENODEV; | ||
5881 | if ((assist_cb == NULL) || (data_cb == NULL)) | ||
5882 | return -EINVAL; | ||
5883 | card->osn_info.assist_cb = assist_cb; | ||
5884 | card->osn_info.data_cb = data_cb; | ||
5885 | return 0; | ||
5886 | } | ||
5887 | |||
5888 | void | ||
5889 | qeth_osn_deregister(struct net_device * dev) | ||
5890 | { | ||
5891 | struct qeth_card *card; | ||
5892 | |||
5893 | QETH_DBF_TEXT(trace, 2, "osndereg"); | ||
5894 | if (!dev) | ||
5895 | return; | ||
5896 | card = (struct qeth_card *)dev->priv; | ||
5897 | if (!card) | ||
5898 | return; | ||
5899 | card->osn_info.assist_cb = NULL; | ||
5900 | card->osn_info.data_cb = NULL; | ||
5901 | return; | ||
5902 | } | ||
5903 | |||
5904 | static void | ||
5905 | qeth_delete_mc_addresses(struct qeth_card *card) | ||
5906 | { | ||
5907 | struct qeth_ipaddr *iptodo; | ||
5908 | unsigned long flags; | ||
5909 | |||
5910 | QETH_DBF_TEXT(trace,4,"delmc"); | ||
5911 | iptodo = qeth_get_addr_buffer(QETH_PROT_IPV4); | ||
5912 | if (!iptodo) { | ||
5913 | QETH_DBF_TEXT(trace, 2, "dmcnomem"); | ||
5914 | return; | ||
5915 | } | ||
5916 | iptodo->type = QETH_IP_TYPE_DEL_ALL_MC; | ||
5917 | spin_lock_irqsave(&card->ip_lock, flags); | ||
5918 | if (!__qeth_insert_ip_todo(card, iptodo, 0)) | ||
5919 | kfree(iptodo); | ||
5920 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
5921 | } | ||
5922 | |||
5923 | static void | ||
5924 | qeth_add_mc(struct qeth_card *card, struct in_device *in4_dev) | ||
5925 | { | ||
5926 | struct qeth_ipaddr *ipm; | ||
5927 | struct ip_mc_list *im4; | ||
5928 | char buf[MAX_ADDR_LEN]; | ||
5929 | |||
5930 | QETH_DBF_TEXT(trace,4,"addmc"); | ||
5931 | for (im4 = in4_dev->mc_list; im4; im4 = im4->next) { | ||
5932 | qeth_get_mac_for_ipm(im4->multiaddr, buf, in4_dev->dev); | ||
5933 | ipm = qeth_get_addr_buffer(QETH_PROT_IPV4); | ||
5934 | if (!ipm) | ||
5935 | continue; | ||
5936 | ipm->u.a4.addr = im4->multiaddr; | ||
5937 | memcpy(ipm->mac,buf,OSA_ADDR_LEN); | ||
5938 | ipm->is_multicast = 1; | ||
5939 | if (!qeth_add_ip(card,ipm)) | ||
5940 | kfree(ipm); | ||
5941 | } | ||
5942 | } | ||
5943 | |||
5944 | static inline void | ||
5945 | qeth_add_vlan_mc(struct qeth_card *card) | ||
5946 | { | ||
5947 | #ifdef CONFIG_QETH_VLAN | ||
5948 | struct in_device *in_dev; | ||
5949 | struct vlan_group *vg; | ||
5950 | int i; | ||
5951 | |||
5952 | QETH_DBF_TEXT(trace,4,"addmcvl"); | ||
5953 | if ( ((card->options.layer2 == 0) && | ||
5954 | (!qeth_is_supported(card,IPA_FULL_VLAN))) || | ||
5955 | (card->vlangrp == NULL) ) | ||
5956 | return ; | ||
5957 | |||
5958 | vg = card->vlangrp; | ||
5959 | for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) { | ||
5960 | struct net_device *netdev = vlan_group_get_device(vg, i); | ||
5961 | if (netdev == NULL || | ||
5962 | !(netdev->flags & IFF_UP)) | ||
5963 | continue; | ||
5964 | in_dev = in_dev_get(netdev); | ||
5965 | if (!in_dev) | ||
5966 | continue; | ||
5967 | read_lock(&in_dev->mc_list_lock); | ||
5968 | qeth_add_mc(card,in_dev); | ||
5969 | read_unlock(&in_dev->mc_list_lock); | ||
5970 | in_dev_put(in_dev); | ||
5971 | } | ||
5972 | #endif | ||
5973 | } | ||
5974 | |||
5975 | static void | ||
5976 | qeth_add_multicast_ipv4(struct qeth_card *card) | ||
5977 | { | ||
5978 | struct in_device *in4_dev; | ||
5979 | |||
5980 | QETH_DBF_TEXT(trace,4,"chkmcv4"); | ||
5981 | in4_dev = in_dev_get(card->dev); | ||
5982 | if (in4_dev == NULL) | ||
5983 | return; | ||
5984 | read_lock(&in4_dev->mc_list_lock); | ||
5985 | qeth_add_mc(card, in4_dev); | ||
5986 | qeth_add_vlan_mc(card); | ||
5987 | read_unlock(&in4_dev->mc_list_lock); | ||
5988 | in_dev_put(in4_dev); | ||
5989 | } | ||
5990 | |||
5991 | static void | ||
5992 | qeth_layer2_add_multicast(struct qeth_card *card) | ||
5993 | { | ||
5994 | struct qeth_ipaddr *ipm; | ||
5995 | struct dev_mc_list *dm; | ||
5996 | |||
5997 | QETH_DBF_TEXT(trace,4,"L2addmc"); | ||
5998 | for (dm = card->dev->mc_list; dm; dm = dm->next) { | ||
5999 | ipm = qeth_get_addr_buffer(QETH_PROT_IPV4); | ||
6000 | if (!ipm) | ||
6001 | continue; | ||
6002 | memcpy(ipm->mac,dm->dmi_addr,MAX_ADDR_LEN); | ||
6003 | ipm->is_multicast = 1; | ||
6004 | if (!qeth_add_ip(card, ipm)) | ||
6005 | kfree(ipm); | ||
6006 | } | ||
6007 | } | ||
6008 | |||
6009 | #ifdef CONFIG_QETH_IPV6 | ||
6010 | static void | ||
6011 | qeth_add_mc6(struct qeth_card *card, struct inet6_dev *in6_dev) | ||
6012 | { | ||
6013 | struct qeth_ipaddr *ipm; | ||
6014 | struct ifmcaddr6 *im6; | ||
6015 | char buf[MAX_ADDR_LEN]; | ||
6016 | |||
6017 | QETH_DBF_TEXT(trace,4,"addmc6"); | ||
6018 | for (im6 = in6_dev->mc_list; im6 != NULL; im6 = im6->next) { | ||
6019 | ndisc_mc_map(&im6->mca_addr, buf, in6_dev->dev, 0); | ||
6020 | ipm = qeth_get_addr_buffer(QETH_PROT_IPV6); | ||
6021 | if (!ipm) | ||
6022 | continue; | ||
6023 | ipm->is_multicast = 1; | ||
6024 | memcpy(ipm->mac,buf,OSA_ADDR_LEN); | ||
6025 | memcpy(&ipm->u.a6.addr,&im6->mca_addr.s6_addr, | ||
6026 | sizeof(struct in6_addr)); | ||
6027 | if (!qeth_add_ip(card,ipm)) | ||
6028 | kfree(ipm); | ||
6029 | } | ||
6030 | } | ||
6031 | |||
6032 | static inline void | ||
6033 | qeth_add_vlan_mc6(struct qeth_card *card) | ||
6034 | { | ||
6035 | #ifdef CONFIG_QETH_VLAN | ||
6036 | struct inet6_dev *in_dev; | ||
6037 | struct vlan_group *vg; | ||
6038 | int i; | ||
6039 | |||
6040 | QETH_DBF_TEXT(trace,4,"admc6vl"); | ||
6041 | if ( ((card->options.layer2 == 0) && | ||
6042 | (!qeth_is_supported(card,IPA_FULL_VLAN))) || | ||
6043 | (card->vlangrp == NULL)) | ||
6044 | return ; | ||
6045 | |||
6046 | vg = card->vlangrp; | ||
6047 | for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) { | ||
6048 | struct net_device *netdev = vlan_group_get_device(vg, i); | ||
6049 | if (netdev == NULL || | ||
6050 | !(netdev->flags & IFF_UP)) | ||
6051 | continue; | ||
6052 | in_dev = in6_dev_get(netdev); | ||
6053 | if (!in_dev) | ||
6054 | continue; | ||
6055 | read_lock_bh(&in_dev->lock); | ||
6056 | qeth_add_mc6(card,in_dev); | ||
6057 | read_unlock_bh(&in_dev->lock); | ||
6058 | in6_dev_put(in_dev); | ||
6059 | } | ||
6060 | #endif /* CONFIG_QETH_VLAN */ | ||
6061 | } | ||
6062 | |||
6063 | static void | ||
6064 | qeth_add_multicast_ipv6(struct qeth_card *card) | ||
6065 | { | ||
6066 | struct inet6_dev *in6_dev; | ||
6067 | |||
6068 | QETH_DBF_TEXT(trace,4,"chkmcv6"); | ||
6069 | if (!qeth_is_supported(card, IPA_IPV6)) | ||
6070 | return ; | ||
6071 | in6_dev = in6_dev_get(card->dev); | ||
6072 | if (in6_dev == NULL) | ||
6073 | return; | ||
6074 | read_lock_bh(&in6_dev->lock); | ||
6075 | qeth_add_mc6(card, in6_dev); | ||
6076 | qeth_add_vlan_mc6(card); | ||
6077 | read_unlock_bh(&in6_dev->lock); | ||
6078 | in6_dev_put(in6_dev); | ||
6079 | } | ||
6080 | #endif /* CONFIG_QETH_IPV6 */ | ||
6081 | |||
6082 | static int | ||
6083 | qeth_layer2_send_setdelmac(struct qeth_card *card, __u8 *mac, | ||
6084 | enum qeth_ipa_cmds ipacmd, | ||
6085 | int (*reply_cb) (struct qeth_card *, | ||
6086 | struct qeth_reply*, | ||
6087 | unsigned long)) | ||
6088 | { | ||
6089 | struct qeth_ipa_cmd *cmd; | ||
6090 | struct qeth_cmd_buffer *iob; | ||
6091 | |||
6092 | QETH_DBF_TEXT(trace, 2, "L2sdmac"); | ||
6093 | iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4); | ||
6094 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); | ||
6095 | cmd->data.setdelmac.mac_length = OSA_ADDR_LEN; | ||
6096 | memcpy(&cmd->data.setdelmac.mac, mac, OSA_ADDR_LEN); | ||
6097 | return qeth_send_ipa_cmd(card, iob, reply_cb, NULL); | ||
6098 | } | ||
6099 | |||
6100 | static int | ||
6101 | qeth_layer2_send_setgroupmac_cb(struct qeth_card *card, | ||
6102 | struct qeth_reply *reply, | ||
6103 | unsigned long data) | ||
6104 | { | ||
6105 | struct qeth_ipa_cmd *cmd; | ||
6106 | __u8 *mac; | ||
6107 | |||
6108 | QETH_DBF_TEXT(trace, 2, "L2Sgmacb"); | ||
6109 | cmd = (struct qeth_ipa_cmd *) data; | ||
6110 | mac = &cmd->data.setdelmac.mac[0]; | ||
6111 | /* MAC already registered, needed in couple/uncouple case */ | ||
6112 | if (cmd->hdr.return_code == 0x2005) { | ||
6113 | PRINT_WARN("Group MAC %02x:%02x:%02x:%02x:%02x:%02x " \ | ||
6114 | "already existing on %s \n", | ||
6115 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], | ||
6116 | QETH_CARD_IFNAME(card)); | ||
6117 | cmd->hdr.return_code = 0; | ||
6118 | } | ||
6119 | if (cmd->hdr.return_code) | ||
6120 | PRINT_ERR("Could not set group MAC " \ | ||
6121 | "%02x:%02x:%02x:%02x:%02x:%02x on %s: %x\n", | ||
6122 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], | ||
6123 | QETH_CARD_IFNAME(card),cmd->hdr.return_code); | ||
6124 | return 0; | ||
6125 | } | ||
6126 | |||
6127 | static int | ||
6128 | qeth_layer2_send_setgroupmac(struct qeth_card *card, __u8 *mac) | ||
6129 | { | ||
6130 | QETH_DBF_TEXT(trace, 2, "L2Sgmac"); | ||
6131 | return qeth_layer2_send_setdelmac(card, mac, IPA_CMD_SETGMAC, | ||
6132 | qeth_layer2_send_setgroupmac_cb); | ||
6133 | } | ||
6134 | |||
6135 | static int | ||
6136 | qeth_layer2_send_delgroupmac_cb(struct qeth_card *card, | ||
6137 | struct qeth_reply *reply, | ||
6138 | unsigned long data) | ||
6139 | { | ||
6140 | struct qeth_ipa_cmd *cmd; | ||
6141 | __u8 *mac; | ||
6142 | |||
6143 | QETH_DBF_TEXT(trace, 2, "L2Dgmacb"); | ||
6144 | cmd = (struct qeth_ipa_cmd *) data; | ||
6145 | mac = &cmd->data.setdelmac.mac[0]; | ||
6146 | if (cmd->hdr.return_code) | ||
6147 | PRINT_ERR("Could not delete group MAC " \ | ||
6148 | "%02x:%02x:%02x:%02x:%02x:%02x on %s: %x\n", | ||
6149 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], | ||
6150 | QETH_CARD_IFNAME(card), cmd->hdr.return_code); | ||
6151 | return 0; | ||
6152 | } | ||
6153 | |||
6154 | static int | ||
6155 | qeth_layer2_send_delgroupmac(struct qeth_card *card, __u8 *mac) | ||
6156 | { | ||
6157 | QETH_DBF_TEXT(trace, 2, "L2Dgmac"); | ||
6158 | return qeth_layer2_send_setdelmac(card, mac, IPA_CMD_DELGMAC, | ||
6159 | qeth_layer2_send_delgroupmac_cb); | ||
6160 | } | ||
6161 | |||
6162 | static int | ||
6163 | qeth_layer2_send_setmac_cb(struct qeth_card *card, | ||
6164 | struct qeth_reply *reply, | ||
6165 | unsigned long data) | ||
6166 | { | ||
6167 | struct qeth_ipa_cmd *cmd; | ||
6168 | |||
6169 | QETH_DBF_TEXT(trace, 2, "L2Smaccb"); | ||
6170 | cmd = (struct qeth_ipa_cmd *) data; | ||
6171 | if (cmd->hdr.return_code) { | ||
6172 | QETH_DBF_TEXT_(trace, 2, "L2er%x", cmd->hdr.return_code); | ||
6173 | card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED; | ||
6174 | cmd->hdr.return_code = -EIO; | ||
6175 | } else { | ||
6176 | card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED; | ||
6177 | memcpy(card->dev->dev_addr,cmd->data.setdelmac.mac, | ||
6178 | OSA_ADDR_LEN); | ||
6179 | PRINT_INFO("MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x " | ||
6180 | "successfully registered on device %s\n", | ||
6181 | card->dev->dev_addr[0], card->dev->dev_addr[1], | ||
6182 | card->dev->dev_addr[2], card->dev->dev_addr[3], | ||
6183 | card->dev->dev_addr[4], card->dev->dev_addr[5], | ||
6184 | card->dev->name); | ||
6185 | } | ||
6186 | return 0; | ||
6187 | } | ||
6188 | |||
6189 | static int | ||
6190 | qeth_layer2_send_setmac(struct qeth_card *card, __u8 *mac) | ||
6191 | { | ||
6192 | QETH_DBF_TEXT(trace, 2, "L2Setmac"); | ||
6193 | return qeth_layer2_send_setdelmac(card, mac, IPA_CMD_SETVMAC, | ||
6194 | qeth_layer2_send_setmac_cb); | ||
6195 | } | ||
6196 | |||
6197 | static int | ||
6198 | qeth_layer2_send_delmac_cb(struct qeth_card *card, | ||
6199 | struct qeth_reply *reply, | ||
6200 | unsigned long data) | ||
6201 | { | ||
6202 | struct qeth_ipa_cmd *cmd; | ||
6203 | |||
6204 | QETH_DBF_TEXT(trace, 2, "L2Dmaccb"); | ||
6205 | cmd = (struct qeth_ipa_cmd *) data; | ||
6206 | if (cmd->hdr.return_code) { | ||
6207 | QETH_DBF_TEXT_(trace, 2, "err%d", cmd->hdr.return_code); | ||
6208 | cmd->hdr.return_code = -EIO; | ||
6209 | return 0; | ||
6210 | } | ||
6211 | card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED; | ||
6212 | |||
6213 | return 0; | ||
6214 | } | ||
6215 | static int | ||
6216 | qeth_layer2_send_delmac(struct qeth_card *card, __u8 *mac) | ||
6217 | { | ||
6218 | QETH_DBF_TEXT(trace, 2, "L2Delmac"); | ||
6219 | if (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED)) | ||
6220 | return 0; | ||
6221 | return qeth_layer2_send_setdelmac(card, mac, IPA_CMD_DELVMAC, | ||
6222 | qeth_layer2_send_delmac_cb); | ||
6223 | } | ||
6224 | |||
6225 | static int | ||
6226 | qeth_layer2_set_mac_address(struct net_device *dev, void *p) | ||
6227 | { | ||
6228 | struct sockaddr *addr = p; | ||
6229 | struct qeth_card *card; | ||
6230 | int rc = 0; | ||
6231 | |||
6232 | QETH_DBF_TEXT(trace, 3, "setmac"); | ||
6233 | |||
6234 | if (qeth_verify_dev(dev) != QETH_REAL_CARD) { | ||
6235 | QETH_DBF_TEXT(trace, 3, "setmcINV"); | ||
6236 | return -EOPNOTSUPP; | ||
6237 | } | ||
6238 | card = (struct qeth_card *) dev->priv; | ||
6239 | |||
6240 | if (!card->options.layer2) { | ||
6241 | PRINT_WARN("Setting MAC address on %s is not supported " | ||
6242 | "in Layer 3 mode.\n", dev->name); | ||
6243 | QETH_DBF_TEXT(trace, 3, "setmcLY3"); | ||
6244 | return -EOPNOTSUPP; | ||
6245 | } | ||
6246 | if (card->info.type == QETH_CARD_TYPE_OSN) { | ||
6247 | PRINT_WARN("Setting MAC address on %s is not supported.\n", | ||
6248 | dev->name); | ||
6249 | QETH_DBF_TEXT(trace, 3, "setmcOSN"); | ||
6250 | return -EOPNOTSUPP; | ||
6251 | } | ||
6252 | QETH_DBF_TEXT_(trace, 3, "%s", CARD_BUS_ID(card)); | ||
6253 | QETH_DBF_HEX(trace, 3, addr->sa_data, OSA_ADDR_LEN); | ||
6254 | rc = qeth_layer2_send_delmac(card, &card->dev->dev_addr[0]); | ||
6255 | if (!rc) | ||
6256 | rc = qeth_layer2_send_setmac(card, addr->sa_data); | ||
6257 | return rc; | ||
6258 | } | ||
6259 | |||
6260 | static void | ||
6261 | qeth_fill_ipacmd_header(struct qeth_card *card, struct qeth_ipa_cmd *cmd, | ||
6262 | __u8 command, enum qeth_prot_versions prot) | ||
6263 | { | ||
6264 | memset(cmd, 0, sizeof (struct qeth_ipa_cmd)); | ||
6265 | cmd->hdr.command = command; | ||
6266 | cmd->hdr.initiator = IPA_CMD_INITIATOR_HOST; | ||
6267 | cmd->hdr.seqno = card->seqno.ipa; | ||
6268 | cmd->hdr.adapter_type = qeth_get_ipa_adp_type(card->info.link_type); | ||
6269 | cmd->hdr.rel_adapter_no = (__u8) card->info.portno; | ||
6270 | if (card->options.layer2) | ||
6271 | cmd->hdr.prim_version_no = 2; | ||
6272 | else | ||
6273 | cmd->hdr.prim_version_no = 1; | ||
6274 | cmd->hdr.param_count = 1; | ||
6275 | cmd->hdr.prot_version = prot; | ||
6276 | cmd->hdr.ipa_supported = 0; | ||
6277 | cmd->hdr.ipa_enabled = 0; | ||
6278 | } | ||
6279 | |||
6280 | static struct qeth_cmd_buffer * | ||
6281 | qeth_get_ipacmd_buffer(struct qeth_card *card, enum qeth_ipa_cmds ipacmd, | ||
6282 | enum qeth_prot_versions prot) | ||
6283 | { | ||
6284 | struct qeth_cmd_buffer *iob; | ||
6285 | struct qeth_ipa_cmd *cmd; | ||
6286 | |||
6287 | iob = qeth_wait_for_buffer(&card->write); | ||
6288 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); | ||
6289 | qeth_fill_ipacmd_header(card, cmd, ipacmd, prot); | ||
6290 | |||
6291 | return iob; | ||
6292 | } | ||
6293 | |||
6294 | static int | ||
6295 | qeth_send_setdelmc(struct qeth_card *card, struct qeth_ipaddr *addr, int ipacmd) | ||
6296 | { | ||
6297 | int rc; | ||
6298 | struct qeth_cmd_buffer *iob; | ||
6299 | struct qeth_ipa_cmd *cmd; | ||
6300 | |||
6301 | QETH_DBF_TEXT(trace,4,"setdelmc"); | ||
6302 | |||
6303 | iob = qeth_get_ipacmd_buffer(card, ipacmd, addr->proto); | ||
6304 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); | ||
6305 | memcpy(&cmd->data.setdelipm.mac,addr->mac, OSA_ADDR_LEN); | ||
6306 | if (addr->proto == QETH_PROT_IPV6) | ||
6307 | memcpy(cmd->data.setdelipm.ip6, &addr->u.a6.addr, | ||
6308 | sizeof(struct in6_addr)); | ||
6309 | else | ||
6310 | memcpy(&cmd->data.setdelipm.ip4, &addr->u.a4.addr,4); | ||
6311 | |||
6312 | rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); | ||
6313 | |||
6314 | return rc; | ||
6315 | } | ||
6316 | static void | ||
6317 | qeth_fill_netmask(u8 *netmask, unsigned int len) | ||
6318 | { | ||
6319 | int i,j; | ||
6320 | for (i=0;i<16;i++) { | ||
6321 | j=(len)-(i*8); | ||
6322 | if (j >= 8) | ||
6323 | netmask[i] = 0xff; | ||
6324 | else if (j > 0) | ||
6325 | netmask[i] = (u8)(0xFF00>>j); | ||
6326 | else | ||
6327 | netmask[i] = 0; | ||
6328 | } | ||
6329 | } | ||
6330 | |||
6331 | static int | ||
6332 | qeth_send_setdelip(struct qeth_card *card, struct qeth_ipaddr *addr, | ||
6333 | int ipacmd, unsigned int flags) | ||
6334 | { | ||
6335 | int rc; | ||
6336 | struct qeth_cmd_buffer *iob; | ||
6337 | struct qeth_ipa_cmd *cmd; | ||
6338 | __u8 netmask[16]; | ||
6339 | |||
6340 | QETH_DBF_TEXT(trace,4,"setdelip"); | ||
6341 | QETH_DBF_TEXT_(trace,4,"flags%02X", flags); | ||
6342 | |||
6343 | iob = qeth_get_ipacmd_buffer(card, ipacmd, addr->proto); | ||
6344 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); | ||
6345 | if (addr->proto == QETH_PROT_IPV6) { | ||
6346 | memcpy(cmd->data.setdelip6.ip_addr, &addr->u.a6.addr, | ||
6347 | sizeof(struct in6_addr)); | ||
6348 | qeth_fill_netmask(netmask,addr->u.a6.pfxlen); | ||
6349 | memcpy(cmd->data.setdelip6.mask, netmask, | ||
6350 | sizeof(struct in6_addr)); | ||
6351 | cmd->data.setdelip6.flags = flags; | ||
6352 | } else { | ||
6353 | memcpy(cmd->data.setdelip4.ip_addr, &addr->u.a4.addr, 4); | ||
6354 | memcpy(cmd->data.setdelip4.mask, &addr->u.a4.mask, 4); | ||
6355 | cmd->data.setdelip4.flags = flags; | ||
6356 | } | ||
6357 | |||
6358 | rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); | ||
6359 | |||
6360 | return rc; | ||
6361 | } | ||
6362 | |||
6363 | static int | ||
6364 | qeth_layer2_register_addr_entry(struct qeth_card *card, | ||
6365 | struct qeth_ipaddr *addr) | ||
6366 | { | ||
6367 | if (!addr->is_multicast) | ||
6368 | return 0; | ||
6369 | QETH_DBF_TEXT(trace, 2, "setgmac"); | ||
6370 | QETH_DBF_HEX(trace,3,&addr->mac[0],OSA_ADDR_LEN); | ||
6371 | return qeth_layer2_send_setgroupmac(card, &addr->mac[0]); | ||
6372 | } | ||
6373 | |||
6374 | static int | ||
6375 | qeth_layer2_deregister_addr_entry(struct qeth_card *card, | ||
6376 | struct qeth_ipaddr *addr) | ||
6377 | { | ||
6378 | if (!addr->is_multicast) | ||
6379 | return 0; | ||
6380 | QETH_DBF_TEXT(trace, 2, "delgmac"); | ||
6381 | QETH_DBF_HEX(trace,3,&addr->mac[0],OSA_ADDR_LEN); | ||
6382 | return qeth_layer2_send_delgroupmac(card, &addr->mac[0]); | ||
6383 | } | ||
6384 | |||
6385 | static int | ||
6386 | qeth_layer3_register_addr_entry(struct qeth_card *card, | ||
6387 | struct qeth_ipaddr *addr) | ||
6388 | { | ||
6389 | char buf[50]; | ||
6390 | int rc; | ||
6391 | int cnt = 3; | ||
6392 | |||
6393 | if (addr->proto == QETH_PROT_IPV4) { | ||
6394 | QETH_DBF_TEXT(trace, 2,"setaddr4"); | ||
6395 | QETH_DBF_HEX(trace, 3, &addr->u.a4.addr, sizeof(int)); | ||
6396 | } else if (addr->proto == QETH_PROT_IPV6) { | ||
6397 | QETH_DBF_TEXT(trace, 2, "setaddr6"); | ||
6398 | QETH_DBF_HEX(trace,3,&addr->u.a6.addr,8); | ||
6399 | QETH_DBF_HEX(trace,3,((char *)&addr->u.a6.addr)+8,8); | ||
6400 | } else { | ||
6401 | QETH_DBF_TEXT(trace, 2, "setaddr?"); | ||
6402 | QETH_DBF_HEX(trace, 3, addr, sizeof(struct qeth_ipaddr)); | ||
6403 | } | ||
6404 | do { | ||
6405 | if (addr->is_multicast) | ||
6406 | rc = qeth_send_setdelmc(card, addr, IPA_CMD_SETIPM); | ||
6407 | else | ||
6408 | rc = qeth_send_setdelip(card, addr, IPA_CMD_SETIP, | ||
6409 | addr->set_flags); | ||
6410 | if (rc) | ||
6411 | QETH_DBF_TEXT(trace, 2, "failed"); | ||
6412 | } while ((--cnt > 0) && rc); | ||
6413 | if (rc){ | ||
6414 | QETH_DBF_TEXT(trace, 2, "FAILED"); | ||
6415 | qeth_ipaddr_to_string(addr->proto, (u8 *)&addr->u, buf); | ||
6416 | PRINT_WARN("Could not register IP address %s (rc=0x%x/%d)\n", | ||
6417 | buf, rc, rc); | ||
6418 | } | ||
6419 | return rc; | ||
6420 | } | ||
6421 | |||
6422 | static int | ||
6423 | qeth_layer3_deregister_addr_entry(struct qeth_card *card, | ||
6424 | struct qeth_ipaddr *addr) | ||
6425 | { | ||
6426 | //char buf[50]; | ||
6427 | int rc; | ||
6428 | |||
6429 | if (addr->proto == QETH_PROT_IPV4) { | ||
6430 | QETH_DBF_TEXT(trace, 2,"deladdr4"); | ||
6431 | QETH_DBF_HEX(trace, 3, &addr->u.a4.addr, sizeof(int)); | ||
6432 | } else if (addr->proto == QETH_PROT_IPV6) { | ||
6433 | QETH_DBF_TEXT(trace, 2, "deladdr6"); | ||
6434 | QETH_DBF_HEX(trace,3,&addr->u.a6.addr,8); | ||
6435 | QETH_DBF_HEX(trace,3,((char *)&addr->u.a6.addr)+8,8); | ||
6436 | } else { | ||
6437 | QETH_DBF_TEXT(trace, 2, "deladdr?"); | ||
6438 | QETH_DBF_HEX(trace, 3, addr, sizeof(struct qeth_ipaddr)); | ||
6439 | } | ||
6440 | if (addr->is_multicast) | ||
6441 | rc = qeth_send_setdelmc(card, addr, IPA_CMD_DELIPM); | ||
6442 | else | ||
6443 | rc = qeth_send_setdelip(card, addr, IPA_CMD_DELIP, | ||
6444 | addr->del_flags); | ||
6445 | if (rc) { | ||
6446 | QETH_DBF_TEXT(trace, 2, "failed"); | ||
6447 | /* TODO: re-activate this warning as soon as we have a | ||
6448 | * clean mirco code | ||
6449 | qeth_ipaddr_to_string(addr->proto, (u8 *)&addr->u, buf); | ||
6450 | PRINT_WARN("Could not deregister IP address %s (rc=%x)\n", | ||
6451 | buf, rc); | ||
6452 | */ | ||
6453 | } | ||
6454 | return rc; | ||
6455 | } | ||
6456 | |||
6457 | static int | ||
6458 | qeth_register_addr_entry(struct qeth_card *card, struct qeth_ipaddr *addr) | ||
6459 | { | ||
6460 | if (card->options.layer2) | ||
6461 | return qeth_layer2_register_addr_entry(card, addr); | ||
6462 | |||
6463 | return qeth_layer3_register_addr_entry(card, addr); | ||
6464 | } | ||
6465 | |||
6466 | static int | ||
6467 | qeth_deregister_addr_entry(struct qeth_card *card, struct qeth_ipaddr *addr) | ||
6468 | { | ||
6469 | if (card->options.layer2) | ||
6470 | return qeth_layer2_deregister_addr_entry(card, addr); | ||
6471 | |||
6472 | return qeth_layer3_deregister_addr_entry(card, addr); | ||
6473 | } | ||
6474 | |||
6475 | static u32 | ||
6476 | qeth_ethtool_get_tx_csum(struct net_device *dev) | ||
6477 | { | ||
6478 | return (dev->features & NETIF_F_HW_CSUM) != 0; | ||
6479 | } | ||
6480 | |||
6481 | static int | ||
6482 | qeth_ethtool_set_tx_csum(struct net_device *dev, u32 data) | ||
6483 | { | ||
6484 | if (data) | ||
6485 | dev->features |= NETIF_F_HW_CSUM; | ||
6486 | else | ||
6487 | dev->features &= ~NETIF_F_HW_CSUM; | ||
6488 | |||
6489 | return 0; | ||
6490 | } | ||
6491 | |||
6492 | static u32 | ||
6493 | qeth_ethtool_get_rx_csum(struct net_device *dev) | ||
6494 | { | ||
6495 | struct qeth_card *card = (struct qeth_card *)dev->priv; | ||
6496 | |||
6497 | return (card->options.checksum_type == HW_CHECKSUMMING); | ||
6498 | } | ||
6499 | |||
6500 | static int | ||
6501 | qeth_ethtool_set_rx_csum(struct net_device *dev, u32 data) | ||
6502 | { | ||
6503 | struct qeth_card *card = (struct qeth_card *)dev->priv; | ||
6504 | |||
6505 | if ((card->state != CARD_STATE_DOWN) && | ||
6506 | (card->state != CARD_STATE_RECOVER)) | ||
6507 | return -EPERM; | ||
6508 | if (data) | ||
6509 | card->options.checksum_type = HW_CHECKSUMMING; | ||
6510 | else | ||
6511 | card->options.checksum_type = SW_CHECKSUMMING; | ||
6512 | return 0; | ||
6513 | } | ||
6514 | |||
6515 | static u32 | ||
6516 | qeth_ethtool_get_sg(struct net_device *dev) | ||
6517 | { | ||
6518 | struct qeth_card *card = (struct qeth_card *)dev->priv; | ||
6519 | |||
6520 | return ((card->options.large_send != QETH_LARGE_SEND_NO) && | ||
6521 | (dev->features & NETIF_F_SG)); | ||
6522 | } | ||
6523 | |||
6524 | static int | ||
6525 | qeth_ethtool_set_sg(struct net_device *dev, u32 data) | ||
6526 | { | ||
6527 | struct qeth_card *card = (struct qeth_card *)dev->priv; | ||
6528 | |||
6529 | if (data) { | ||
6530 | if (card->options.large_send != QETH_LARGE_SEND_NO) | ||
6531 | dev->features |= NETIF_F_SG; | ||
6532 | else { | ||
6533 | dev->features &= ~NETIF_F_SG; | ||
6534 | return -EINVAL; | ||
6535 | } | ||
6536 | } else | ||
6537 | dev->features &= ~NETIF_F_SG; | ||
6538 | return 0; | ||
6539 | } | ||
6540 | |||
6541 | static u32 | ||
6542 | qeth_ethtool_get_tso(struct net_device *dev) | ||
6543 | { | ||
6544 | struct qeth_card *card = (struct qeth_card *)dev->priv; | ||
6545 | |||
6546 | return ((card->options.large_send != QETH_LARGE_SEND_NO) && | ||
6547 | (dev->features & NETIF_F_TSO)); | ||
6548 | } | ||
6549 | |||
6550 | static int | ||
6551 | qeth_ethtool_set_tso(struct net_device *dev, u32 data) | ||
6552 | { | ||
6553 | struct qeth_card *card = (struct qeth_card *)dev->priv; | ||
6554 | |||
6555 | if (data) { | ||
6556 | if (card->options.large_send != QETH_LARGE_SEND_NO) | ||
6557 | dev->features |= NETIF_F_TSO; | ||
6558 | else { | ||
6559 | dev->features &= ~NETIF_F_TSO; | ||
6560 | return -EINVAL; | ||
6561 | } | ||
6562 | } else | ||
6563 | dev->features &= ~NETIF_F_TSO; | ||
6564 | return 0; | ||
6565 | } | ||
6566 | |||
6567 | static struct ethtool_ops qeth_ethtool_ops = { | ||
6568 | .get_tx_csum = qeth_ethtool_get_tx_csum, | ||
6569 | .set_tx_csum = qeth_ethtool_set_tx_csum, | ||
6570 | .get_rx_csum = qeth_ethtool_get_rx_csum, | ||
6571 | .set_rx_csum = qeth_ethtool_set_rx_csum, | ||
6572 | .get_sg = qeth_ethtool_get_sg, | ||
6573 | .set_sg = qeth_ethtool_set_sg, | ||
6574 | .get_tso = qeth_ethtool_get_tso, | ||
6575 | .set_tso = qeth_ethtool_set_tso, | ||
6576 | }; | ||
6577 | |||
6578 | static int | ||
6579 | qeth_hard_header_parse(const struct sk_buff *skb, unsigned char *haddr) | ||
6580 | { | ||
6581 | const struct qeth_card *card; | ||
6582 | const struct ethhdr *eth; | ||
6583 | struct net_device *dev = skb->dev; | ||
6584 | |||
6585 | if (dev->type != ARPHRD_IEEE802_TR) | ||
6586 | return 0; | ||
6587 | |||
6588 | card = qeth_get_card_from_dev(dev); | ||
6589 | if (card->options.layer2) | ||
6590 | goto haveheader; | ||
6591 | #ifdef CONFIG_QETH_IPV6 | ||
6592 | /* cause of the manipulated arp constructor and the ARP | ||
6593 | flag for OSAE devices we have some nasty exceptions */ | ||
6594 | if (card->info.type == QETH_CARD_TYPE_OSAE) { | ||
6595 | if (!card->options.fake_ll) { | ||
6596 | if ((skb->pkt_type==PACKET_OUTGOING) && | ||
6597 | (skb->protocol==ETH_P_IPV6)) | ||
6598 | goto haveheader; | ||
6599 | else | ||
6600 | return 0; | ||
6601 | } else { | ||
6602 | if ((skb->pkt_type==PACKET_OUTGOING) && | ||
6603 | (skb->protocol==ETH_P_IP)) | ||
6604 | return 0; | ||
6605 | else | ||
6606 | goto haveheader; | ||
6607 | } | ||
6608 | } | ||
6609 | #endif | ||
6610 | if (!card->options.fake_ll) | ||
6611 | return 0; | ||
6612 | haveheader: | ||
6613 | eth = eth_hdr(skb); | ||
6614 | memcpy(haddr, eth->h_source, ETH_ALEN); | ||
6615 | return ETH_ALEN; | ||
6616 | } | ||
6617 | |||
6618 | static const struct header_ops qeth_null_ops = { | ||
6619 | .parse = qeth_hard_header_parse, | ||
6620 | }; | ||
6621 | |||
6622 | static int | ||
6623 | qeth_netdev_init(struct net_device *dev) | ||
6624 | { | ||
6625 | struct qeth_card *card; | ||
6626 | |||
6627 | card = (struct qeth_card *) dev->priv; | ||
6628 | |||
6629 | QETH_DBF_TEXT(trace,3,"initdev"); | ||
6630 | |||
6631 | dev->tx_timeout = &qeth_tx_timeout; | ||
6632 | dev->watchdog_timeo = QETH_TX_TIMEOUT; | ||
6633 | dev->open = qeth_open; | ||
6634 | dev->stop = qeth_stop; | ||
6635 | dev->hard_start_xmit = qeth_hard_start_xmit; | ||
6636 | dev->do_ioctl = qeth_do_ioctl; | ||
6637 | dev->get_stats = qeth_get_stats; | ||
6638 | dev->change_mtu = qeth_change_mtu; | ||
6639 | dev->neigh_setup = qeth_neigh_setup; | ||
6640 | dev->set_multicast_list = qeth_set_multicast_list; | ||
6641 | #ifdef CONFIG_QETH_VLAN | ||
6642 | dev->vlan_rx_register = qeth_vlan_rx_register; | ||
6643 | dev->vlan_rx_kill_vid = qeth_vlan_rx_kill_vid; | ||
6644 | dev->vlan_rx_add_vid = qeth_vlan_rx_add_vid; | ||
6645 | #endif | ||
6646 | if (qeth_get_netdev_flags(card) & IFF_NOARP) | ||
6647 | dev->header_ops = &qeth_null_ops; | ||
6648 | |||
6649 | #ifdef CONFIG_QETH_IPV6 | ||
6650 | /*IPv6 address autoconfiguration stuff*/ | ||
6651 | if (!(card->info.unique_id & UNIQUE_ID_NOT_BY_CARD)) | ||
6652 | card->dev->dev_id = card->info.unique_id & 0xffff; | ||
6653 | #endif | ||
6654 | if (card->options.fake_ll && | ||
6655 | (qeth_get_netdev_flags(card) & IFF_NOARP)) | ||
6656 | dev->header_ops = &qeth_fake_ops; | ||
6657 | |||
6658 | dev->set_mac_address = qeth_layer2_set_mac_address; | ||
6659 | dev->flags |= qeth_get_netdev_flags(card); | ||
6660 | if ((card->options.fake_broadcast) || | ||
6661 | (card->info.broadcast_capable)) | ||
6662 | dev->flags |= IFF_BROADCAST; | ||
6663 | dev->hard_header_len = | ||
6664 | qeth_get_hlen(card->info.link_type) + card->options.add_hhlen; | ||
6665 | dev->addr_len = OSA_ADDR_LEN; | ||
6666 | dev->mtu = card->info.initial_mtu; | ||
6667 | if (card->info.type != QETH_CARD_TYPE_OSN) | ||
6668 | SET_ETHTOOL_OPS(dev, &qeth_ethtool_ops); | ||
6669 | return 0; | ||
6670 | } | ||
6671 | |||
6672 | static void | ||
6673 | qeth_init_func_level(struct qeth_card *card) | ||
6674 | { | ||
6675 | if (card->ipato.enabled) { | ||
6676 | if (card->info.type == QETH_CARD_TYPE_IQD) | ||
6677 | card->info.func_level = | ||
6678 | QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT; | ||
6679 | else | ||
6680 | card->info.func_level = | ||
6681 | QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT; | ||
6682 | } else { | ||
6683 | if (card->info.type == QETH_CARD_TYPE_IQD) | ||
6684 | /*FIXME:why do we have same values for dis and ena for osae??? */ | ||
6685 | card->info.func_level = | ||
6686 | QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT; | ||
6687 | else | ||
6688 | card->info.func_level = | ||
6689 | QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT; | ||
6690 | } | ||
6691 | } | ||
6692 | |||
6693 | /** | ||
6694 | * hardsetup card, initialize MPC and QDIO stuff | ||
6695 | */ | ||
6696 | static int | ||
6697 | qeth_hardsetup_card(struct qeth_card *card) | ||
6698 | { | ||
6699 | int retries = 3; | ||
6700 | int rc; | ||
6701 | |||
6702 | QETH_DBF_TEXT(setup, 2, "hrdsetup"); | ||
6703 | |||
6704 | atomic_set(&card->force_alloc_skb, 0); | ||
6705 | retry: | ||
6706 | if (retries < 3){ | ||
6707 | PRINT_WARN("Retrying to do IDX activates.\n"); | ||
6708 | ccw_device_set_offline(CARD_DDEV(card)); | ||
6709 | ccw_device_set_offline(CARD_WDEV(card)); | ||
6710 | ccw_device_set_offline(CARD_RDEV(card)); | ||
6711 | ccw_device_set_online(CARD_RDEV(card)); | ||
6712 | ccw_device_set_online(CARD_WDEV(card)); | ||
6713 | ccw_device_set_online(CARD_DDEV(card)); | ||
6714 | } | ||
6715 | rc = qeth_qdio_clear_card(card,card->info.type!=QETH_CARD_TYPE_IQD); | ||
6716 | if (rc == -ERESTARTSYS) { | ||
6717 | QETH_DBF_TEXT(setup, 2, "break1"); | ||
6718 | return rc; | ||
6719 | } else if (rc) { | ||
6720 | QETH_DBF_TEXT_(setup, 2, "1err%d", rc); | ||
6721 | if (--retries < 0) | ||
6722 | goto out; | ||
6723 | else | ||
6724 | goto retry; | ||
6725 | } | ||
6726 | if ((rc = qeth_get_unitaddr(card))){ | ||
6727 | QETH_DBF_TEXT_(setup, 2, "2err%d", rc); | ||
6728 | return rc; | ||
6729 | } | ||
6730 | qeth_init_tokens(card); | ||
6731 | qeth_init_func_level(card); | ||
6732 | rc = qeth_idx_activate_channel(&card->read, qeth_idx_read_cb); | ||
6733 | if (rc == -ERESTARTSYS) { | ||
6734 | QETH_DBF_TEXT(setup, 2, "break2"); | ||
6735 | return rc; | ||
6736 | } else if (rc) { | ||
6737 | QETH_DBF_TEXT_(setup, 2, "3err%d", rc); | ||
6738 | if (--retries < 0) | ||
6739 | goto out; | ||
6740 | else | ||
6741 | goto retry; | ||
6742 | } | ||
6743 | rc = qeth_idx_activate_channel(&card->write, qeth_idx_write_cb); | ||
6744 | if (rc == -ERESTARTSYS) { | ||
6745 | QETH_DBF_TEXT(setup, 2, "break3"); | ||
6746 | return rc; | ||
6747 | } else if (rc) { | ||
6748 | QETH_DBF_TEXT_(setup, 2, "4err%d", rc); | ||
6749 | if (--retries < 0) | ||
6750 | goto out; | ||
6751 | else | ||
6752 | goto retry; | ||
6753 | } | ||
6754 | if ((rc = qeth_mpc_initialize(card))){ | ||
6755 | QETH_DBF_TEXT_(setup, 2, "5err%d", rc); | ||
6756 | goto out; | ||
6757 | } | ||
6758 | /*network device will be recovered*/ | ||
6759 | if (card->dev) { | ||
6760 | card->dev->header_ops = card->orig_header_ops; | ||
6761 | if (card->options.fake_ll && | ||
6762 | (qeth_get_netdev_flags(card) & IFF_NOARP)) | ||
6763 | card->dev->header_ops = &qeth_fake_ops; | ||
6764 | return 0; | ||
6765 | } | ||
6766 | /* at first set_online allocate netdev */ | ||
6767 | card->dev = qeth_get_netdevice(card->info.type, | ||
6768 | card->info.link_type); | ||
6769 | if (!card->dev){ | ||
6770 | qeth_qdio_clear_card(card, card->info.type != | ||
6771 | QETH_CARD_TYPE_IQD); | ||
6772 | rc = -ENODEV; | ||
6773 | QETH_DBF_TEXT_(setup, 2, "6err%d", rc); | ||
6774 | goto out; | ||
6775 | } | ||
6776 | card->dev->priv = card; | ||
6777 | card->orig_header_ops = card->dev->header_ops; | ||
6778 | card->dev->type = qeth_get_arphdr_type(card->info.type, | ||
6779 | card->info.link_type); | ||
6780 | card->dev->init = qeth_netdev_init; | ||
6781 | return 0; | ||
6782 | out: | ||
6783 | PRINT_ERR("Initialization in hardsetup failed! rc=%d\n", rc); | ||
6784 | return rc; | ||
6785 | } | ||
6786 | |||
6787 | static int | ||
6788 | qeth_default_setassparms_cb(struct qeth_card *card, struct qeth_reply *reply, | ||
6789 | unsigned long data) | ||
6790 | { | ||
6791 | struct qeth_ipa_cmd *cmd; | ||
6792 | |||
6793 | QETH_DBF_TEXT(trace,4,"defadpcb"); | ||
6794 | |||
6795 | cmd = (struct qeth_ipa_cmd *) data; | ||
6796 | if (cmd->hdr.return_code == 0){ | ||
6797 | cmd->hdr.return_code = cmd->data.setassparms.hdr.return_code; | ||
6798 | if (cmd->hdr.prot_version == QETH_PROT_IPV4) | ||
6799 | card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled; | ||
6800 | #ifdef CONFIG_QETH_IPV6 | ||
6801 | if (cmd->hdr.prot_version == QETH_PROT_IPV6) | ||
6802 | card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled; | ||
6803 | #endif | ||
6804 | } | ||
6805 | if (cmd->data.setassparms.hdr.assist_no == IPA_INBOUND_CHECKSUM && | ||
6806 | cmd->data.setassparms.hdr.command_code == IPA_CMD_ASS_START) { | ||
6807 | card->info.csum_mask = cmd->data.setassparms.data.flags_32bit; | ||
6808 | QETH_DBF_TEXT_(trace, 3, "csum:%d", card->info.csum_mask); | ||
6809 | } | ||
6810 | return 0; | ||
6811 | } | ||
6812 | |||
6813 | static int | ||
6814 | qeth_default_setadapterparms_cb(struct qeth_card *card, | ||
6815 | struct qeth_reply *reply, | ||
6816 | unsigned long data) | ||
6817 | { | ||
6818 | struct qeth_ipa_cmd *cmd; | ||
6819 | |||
6820 | QETH_DBF_TEXT(trace,4,"defadpcb"); | ||
6821 | |||
6822 | cmd = (struct qeth_ipa_cmd *) data; | ||
6823 | if (cmd->hdr.return_code == 0) | ||
6824 | cmd->hdr.return_code = cmd->data.setadapterparms.hdr.return_code; | ||
6825 | return 0; | ||
6826 | } | ||
6827 | |||
6828 | |||
6829 | |||
6830 | static int | ||
6831 | qeth_query_setadapterparms_cb(struct qeth_card *card, struct qeth_reply *reply, | ||
6832 | unsigned long data) | ||
6833 | { | ||
6834 | struct qeth_ipa_cmd *cmd; | ||
6835 | |||
6836 | QETH_DBF_TEXT(trace,3,"quyadpcb"); | ||
6837 | |||
6838 | cmd = (struct qeth_ipa_cmd *) data; | ||
6839 | if (cmd->data.setadapterparms.data.query_cmds_supp.lan_type & 0x7f) | ||
6840 | card->info.link_type = | ||
6841 | cmd->data.setadapterparms.data.query_cmds_supp.lan_type; | ||
6842 | card->options.adp.supported_funcs = | ||
6843 | cmd->data.setadapterparms.data.query_cmds_supp.supported_cmds; | ||
6844 | return qeth_default_setadapterparms_cb(card, reply, (unsigned long)cmd); | ||
6845 | } | ||
6846 | |||
6847 | static int | ||
6848 | qeth_query_setadapterparms(struct qeth_card *card) | ||
6849 | { | ||
6850 | int rc; | ||
6851 | struct qeth_cmd_buffer *iob; | ||
6852 | |||
6853 | QETH_DBF_TEXT(trace,3,"queryadp"); | ||
6854 | iob = qeth_get_adapter_cmd(card, IPA_SETADP_QUERY_COMMANDS_SUPPORTED, | ||
6855 | sizeof(struct qeth_ipacmd_setadpparms)); | ||
6856 | rc = qeth_send_ipa_cmd(card, iob, qeth_query_setadapterparms_cb, NULL); | ||
6857 | return rc; | ||
6858 | } | ||
6859 | |||
6860 | static int | ||
6861 | qeth_setadpparms_change_macaddr_cb(struct qeth_card *card, | ||
6862 | struct qeth_reply *reply, | ||
6863 | unsigned long data) | ||
6864 | { | ||
6865 | struct qeth_ipa_cmd *cmd; | ||
6866 | |||
6867 | QETH_DBF_TEXT(trace,4,"chgmaccb"); | ||
6868 | |||
6869 | cmd = (struct qeth_ipa_cmd *) data; | ||
6870 | if (!card->options.layer2 || | ||
6871 | !(card->info.mac_bits & QETH_LAYER2_MAC_READ)) { | ||
6872 | memcpy(card->dev->dev_addr, | ||
6873 | &cmd->data.setadapterparms.data.change_addr.addr, | ||
6874 | OSA_ADDR_LEN); | ||
6875 | card->info.mac_bits |= QETH_LAYER2_MAC_READ; | ||
6876 | } | ||
6877 | qeth_default_setadapterparms_cb(card, reply, (unsigned long) cmd); | ||
6878 | return 0; | ||
6879 | } | ||
6880 | |||
6881 | static int | ||
6882 | qeth_setadpparms_change_macaddr(struct qeth_card *card) | ||
6883 | { | ||
6884 | int rc; | ||
6885 | struct qeth_cmd_buffer *iob; | ||
6886 | struct qeth_ipa_cmd *cmd; | ||
6887 | |||
6888 | QETH_DBF_TEXT(trace,4,"chgmac"); | ||
6889 | |||
6890 | iob = qeth_get_adapter_cmd(card,IPA_SETADP_ALTER_MAC_ADDRESS, | ||
6891 | sizeof(struct qeth_ipacmd_setadpparms)); | ||
6892 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); | ||
6893 | cmd->data.setadapterparms.data.change_addr.cmd = CHANGE_ADDR_READ_MAC; | ||
6894 | cmd->data.setadapterparms.data.change_addr.addr_size = OSA_ADDR_LEN; | ||
6895 | memcpy(&cmd->data.setadapterparms.data.change_addr.addr, | ||
6896 | card->dev->dev_addr, OSA_ADDR_LEN); | ||
6897 | rc = qeth_send_ipa_cmd(card, iob, qeth_setadpparms_change_macaddr_cb, | ||
6898 | NULL); | ||
6899 | return rc; | ||
6900 | } | ||
6901 | |||
6902 | static int | ||
6903 | qeth_send_setadp_mode(struct qeth_card *card, __u32 command, __u32 mode) | ||
6904 | { | ||
6905 | int rc; | ||
6906 | struct qeth_cmd_buffer *iob; | ||
6907 | struct qeth_ipa_cmd *cmd; | ||
6908 | |||
6909 | QETH_DBF_TEXT(trace,4,"adpmode"); | ||
6910 | |||
6911 | iob = qeth_get_adapter_cmd(card, command, | ||
6912 | sizeof(struct qeth_ipacmd_setadpparms)); | ||
6913 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); | ||
6914 | cmd->data.setadapterparms.data.mode = mode; | ||
6915 | rc = qeth_send_ipa_cmd(card, iob, qeth_default_setadapterparms_cb, | ||
6916 | NULL); | ||
6917 | return rc; | ||
6918 | } | ||
6919 | |||
6920 | static int | ||
6921 | qeth_setadapter_hstr(struct qeth_card *card) | ||
6922 | { | ||
6923 | int rc; | ||
6924 | |||
6925 | QETH_DBF_TEXT(trace,4,"adphstr"); | ||
6926 | |||
6927 | if (qeth_adp_supported(card,IPA_SETADP_SET_BROADCAST_MODE)) { | ||
6928 | rc = qeth_send_setadp_mode(card, IPA_SETADP_SET_BROADCAST_MODE, | ||
6929 | card->options.broadcast_mode); | ||
6930 | if (rc) | ||
6931 | PRINT_WARN("couldn't set broadcast mode on " | ||
6932 | "device %s: x%x\n", | ||
6933 | CARD_BUS_ID(card), rc); | ||
6934 | rc = qeth_send_setadp_mode(card, IPA_SETADP_ALTER_MAC_ADDRESS, | ||
6935 | card->options.macaddr_mode); | ||
6936 | if (rc) | ||
6937 | PRINT_WARN("couldn't set macaddr mode on " | ||
6938 | "device %s: x%x\n", CARD_BUS_ID(card), rc); | ||
6939 | return rc; | ||
6940 | } | ||
6941 | if (card->options.broadcast_mode == QETH_TR_BROADCAST_LOCAL) | ||
6942 | PRINT_WARN("set adapter parameters not available " | ||
6943 | "to set broadcast mode, using ALLRINGS " | ||
6944 | "on device %s:\n", CARD_BUS_ID(card)); | ||
6945 | if (card->options.macaddr_mode == QETH_TR_MACADDR_CANONICAL) | ||
6946 | PRINT_WARN("set adapter parameters not available " | ||
6947 | "to set macaddr mode, using NONCANONICAL " | ||
6948 | "on device %s:\n", CARD_BUS_ID(card)); | ||
6949 | return 0; | ||
6950 | } | ||
6951 | |||
6952 | static int | ||
6953 | qeth_setadapter_parms(struct qeth_card *card) | ||
6954 | { | ||
6955 | int rc; | ||
6956 | |||
6957 | QETH_DBF_TEXT(setup, 2, "setadprm"); | ||
6958 | |||
6959 | if (!qeth_is_supported(card, IPA_SETADAPTERPARMS)){ | ||
6960 | PRINT_WARN("set adapter parameters not supported " | ||
6961 | "on device %s.\n", | ||
6962 | CARD_BUS_ID(card)); | ||
6963 | QETH_DBF_TEXT(setup, 2, " notsupp"); | ||
6964 | return 0; | ||
6965 | } | ||
6966 | rc = qeth_query_setadapterparms(card); | ||
6967 | if (rc) { | ||
6968 | PRINT_WARN("couldn't set adapter parameters on device %s: " | ||
6969 | "x%x\n", CARD_BUS_ID(card), rc); | ||
6970 | return rc; | ||
6971 | } | ||
6972 | if (qeth_adp_supported(card,IPA_SETADP_ALTER_MAC_ADDRESS)) { | ||
6973 | rc = qeth_setadpparms_change_macaddr(card); | ||
6974 | if (rc) | ||
6975 | PRINT_WARN("couldn't get MAC address on " | ||
6976 | "device %s: x%x\n", | ||
6977 | CARD_BUS_ID(card), rc); | ||
6978 | } | ||
6979 | |||
6980 | if ((card->info.link_type == QETH_LINK_TYPE_HSTR) || | ||
6981 | (card->info.link_type == QETH_LINK_TYPE_LANE_TR)) | ||
6982 | rc = qeth_setadapter_hstr(card); | ||
6983 | |||
6984 | return rc; | ||
6985 | } | ||
6986 | |||
6987 | static int | ||
6988 | qeth_layer2_initialize(struct qeth_card *card) | ||
6989 | { | ||
6990 | int rc = 0; | ||
6991 | |||
6992 | |||
6993 | QETH_DBF_TEXT(setup, 2, "doL2init"); | ||
6994 | QETH_DBF_TEXT_(setup, 2, "doL2%s", CARD_BUS_ID(card)); | ||
6995 | |||
6996 | rc = qeth_query_setadapterparms(card); | ||
6997 | if (rc) { | ||
6998 | PRINT_WARN("could not query adapter parameters on device %s: " | ||
6999 | "x%x\n", CARD_BUS_ID(card), rc); | ||
7000 | } | ||
7001 | |||
7002 | rc = qeth_setadpparms_change_macaddr(card); | ||
7003 | if (rc) { | ||
7004 | PRINT_WARN("couldn't get MAC address on " | ||
7005 | "device %s: x%x\n", | ||
7006 | CARD_BUS_ID(card), rc); | ||
7007 | QETH_DBF_TEXT_(setup, 2,"1err%d",rc); | ||
7008 | return rc; | ||
7009 | } | ||
7010 | QETH_DBF_HEX(setup,2, card->dev->dev_addr, OSA_ADDR_LEN); | ||
7011 | |||
7012 | rc = qeth_layer2_send_setmac(card, &card->dev->dev_addr[0]); | ||
7013 | if (rc) | ||
7014 | QETH_DBF_TEXT_(setup, 2,"2err%d",rc); | ||
7015 | return 0; | ||
7016 | } | ||
7017 | |||
7018 | |||
7019 | static int | ||
7020 | qeth_send_startstoplan(struct qeth_card *card, enum qeth_ipa_cmds ipacmd, | ||
7021 | enum qeth_prot_versions prot) | ||
7022 | { | ||
7023 | int rc; | ||
7024 | struct qeth_cmd_buffer *iob; | ||
7025 | |||
7026 | iob = qeth_get_ipacmd_buffer(card,ipacmd,prot); | ||
7027 | rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); | ||
7028 | |||
7029 | return rc; | ||
7030 | } | ||
7031 | |||
7032 | static int | ||
7033 | qeth_send_startlan(struct qeth_card *card, enum qeth_prot_versions prot) | ||
7034 | { | ||
7035 | int rc; | ||
7036 | |||
7037 | QETH_DBF_TEXT_(setup, 2, "strtlan%i", prot); | ||
7038 | |||
7039 | rc = qeth_send_startstoplan(card, IPA_CMD_STARTLAN, prot); | ||
7040 | return rc; | ||
7041 | } | ||
7042 | |||
7043 | static int | ||
7044 | qeth_send_stoplan(struct qeth_card *card) | ||
7045 | { | ||
7046 | int rc = 0; | ||
7047 | |||
7048 | /* | ||
7049 | * TODO: according to the IPA format document page 14, | ||
7050 | * TCP/IP (we!) never issue a STOPLAN | ||
7051 | * is this right ?!? | ||
7052 | */ | ||
7053 | QETH_DBF_TEXT(trace, 2, "stoplan"); | ||
7054 | |||
7055 | rc = qeth_send_startstoplan(card, IPA_CMD_STOPLAN, QETH_PROT_IPV4); | ||
7056 | return rc; | ||
7057 | } | ||
7058 | |||
7059 | static int | ||
7060 | qeth_query_ipassists_cb(struct qeth_card *card, struct qeth_reply *reply, | ||
7061 | unsigned long data) | ||
7062 | { | ||
7063 | struct qeth_ipa_cmd *cmd; | ||
7064 | |||
7065 | QETH_DBF_TEXT(setup, 2, "qipasscb"); | ||
7066 | |||
7067 | cmd = (struct qeth_ipa_cmd *) data; | ||
7068 | if (cmd->hdr.prot_version == QETH_PROT_IPV4) { | ||
7069 | card->options.ipa4.supported_funcs = cmd->hdr.ipa_supported; | ||
7070 | card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled; | ||
7071 | /* Disable IPV6 support hard coded for Hipersockets */ | ||
7072 | if(card->info.type == QETH_CARD_TYPE_IQD) | ||
7073 | card->options.ipa4.supported_funcs &= ~IPA_IPV6; | ||
7074 | } else { | ||
7075 | #ifdef CONFIG_QETH_IPV6 | ||
7076 | card->options.ipa6.supported_funcs = cmd->hdr.ipa_supported; | ||
7077 | card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled; | ||
7078 | #endif | ||
7079 | } | ||
7080 | QETH_DBF_TEXT(setup, 2, "suppenbl"); | ||
7081 | QETH_DBF_TEXT_(setup, 2, "%x",cmd->hdr.ipa_supported); | ||
7082 | QETH_DBF_TEXT_(setup, 2, "%x",cmd->hdr.ipa_enabled); | ||
7083 | return 0; | ||
7084 | } | ||
7085 | |||
7086 | static int | ||
7087 | qeth_query_ipassists(struct qeth_card *card, enum qeth_prot_versions prot) | ||
7088 | { | ||
7089 | int rc; | ||
7090 | struct qeth_cmd_buffer *iob; | ||
7091 | |||
7092 | QETH_DBF_TEXT_(setup, 2, "qipassi%i", prot); | ||
7093 | if (card->options.layer2) { | ||
7094 | QETH_DBF_TEXT(setup, 2, "noprmly2"); | ||
7095 | return -EPERM; | ||
7096 | } | ||
7097 | |||
7098 | iob = qeth_get_ipacmd_buffer(card,IPA_CMD_QIPASSIST,prot); | ||
7099 | rc = qeth_send_ipa_cmd(card, iob, qeth_query_ipassists_cb, NULL); | ||
7100 | return rc; | ||
7101 | } | ||
7102 | |||
7103 | static struct qeth_cmd_buffer * | ||
7104 | qeth_get_setassparms_cmd(struct qeth_card *card, enum qeth_ipa_funcs ipa_func, | ||
7105 | __u16 cmd_code, __u16 len, | ||
7106 | enum qeth_prot_versions prot) | ||
7107 | { | ||
7108 | struct qeth_cmd_buffer *iob; | ||
7109 | struct qeth_ipa_cmd *cmd; | ||
7110 | |||
7111 | QETH_DBF_TEXT(trace,4,"getasscm"); | ||
7112 | iob = qeth_get_ipacmd_buffer(card,IPA_CMD_SETASSPARMS,prot); | ||
7113 | |||
7114 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); | ||
7115 | cmd->data.setassparms.hdr.assist_no = ipa_func; | ||
7116 | cmd->data.setassparms.hdr.length = 8 + len; | ||
7117 | cmd->data.setassparms.hdr.command_code = cmd_code; | ||
7118 | cmd->data.setassparms.hdr.return_code = 0; | ||
7119 | cmd->data.setassparms.hdr.seq_no = 0; | ||
7120 | |||
7121 | return iob; | ||
7122 | } | ||
7123 | |||
7124 | static int | ||
7125 | qeth_send_setassparms(struct qeth_card *card, struct qeth_cmd_buffer *iob, | ||
7126 | __u16 len, long data, | ||
7127 | int (*reply_cb) | ||
7128 | (struct qeth_card *,struct qeth_reply *,unsigned long), | ||
7129 | void *reply_param) | ||
7130 | { | ||
7131 | int rc; | ||
7132 | struct qeth_ipa_cmd *cmd; | ||
7133 | |||
7134 | QETH_DBF_TEXT(trace,4,"sendassp"); | ||
7135 | |||
7136 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); | ||
7137 | if (len <= sizeof(__u32)) | ||
7138 | cmd->data.setassparms.data.flags_32bit = (__u32) data; | ||
7139 | else /* (len > sizeof(__u32)) */ | ||
7140 | memcpy(&cmd->data.setassparms.data, (void *) data, len); | ||
7141 | |||
7142 | rc = qeth_send_ipa_cmd(card, iob, reply_cb, reply_param); | ||
7143 | return rc; | ||
7144 | } | ||
7145 | |||
7146 | #ifdef CONFIG_QETH_IPV6 | ||
7147 | static int | ||
7148 | qeth_send_simple_setassparms_ipv6(struct qeth_card *card, | ||
7149 | enum qeth_ipa_funcs ipa_func, __u16 cmd_code) | ||
7150 | |||
7151 | { | ||
7152 | int rc; | ||
7153 | struct qeth_cmd_buffer *iob; | ||
7154 | |||
7155 | QETH_DBF_TEXT(trace,4,"simassp6"); | ||
7156 | iob = qeth_get_setassparms_cmd(card, ipa_func, cmd_code, | ||
7157 | 0, QETH_PROT_IPV6); | ||
7158 | rc = qeth_send_setassparms(card, iob, 0, 0, | ||
7159 | qeth_default_setassparms_cb, NULL); | ||
7160 | return rc; | ||
7161 | } | ||
7162 | #endif | ||
7163 | |||
7164 | static int | ||
7165 | qeth_send_simple_setassparms(struct qeth_card *card, | ||
7166 | enum qeth_ipa_funcs ipa_func, | ||
7167 | __u16 cmd_code, long data) | ||
7168 | { | ||
7169 | int rc; | ||
7170 | int length = 0; | ||
7171 | struct qeth_cmd_buffer *iob; | ||
7172 | |||
7173 | QETH_DBF_TEXT(trace,4,"simassp4"); | ||
7174 | if (data) | ||
7175 | length = sizeof(__u32); | ||
7176 | iob = qeth_get_setassparms_cmd(card, ipa_func, cmd_code, | ||
7177 | length, QETH_PROT_IPV4); | ||
7178 | rc = qeth_send_setassparms(card, iob, length, data, | ||
7179 | qeth_default_setassparms_cb, NULL); | ||
7180 | return rc; | ||
7181 | } | ||
7182 | |||
7183 | static int | ||
7184 | qeth_start_ipa_arp_processing(struct qeth_card *card) | ||
7185 | { | ||
7186 | int rc; | ||
7187 | |||
7188 | QETH_DBF_TEXT(trace,3,"ipaarp"); | ||
7189 | |||
7190 | if (!qeth_is_supported(card,IPA_ARP_PROCESSING)) { | ||
7191 | PRINT_WARN("ARP processing not supported " | ||
7192 | "on %s!\n", QETH_CARD_IFNAME(card)); | ||
7193 | return 0; | ||
7194 | } | ||
7195 | rc = qeth_send_simple_setassparms(card,IPA_ARP_PROCESSING, | ||
7196 | IPA_CMD_ASS_START, 0); | ||
7197 | if (rc) { | ||
7198 | PRINT_WARN("Could not start ARP processing " | ||
7199 | "assist on %s: 0x%x\n", | ||
7200 | QETH_CARD_IFNAME(card), rc); | ||
7201 | } | ||
7202 | return rc; | ||
7203 | } | ||
7204 | |||
7205 | static int | ||
7206 | qeth_start_ipa_ip_fragmentation(struct qeth_card *card) | ||
7207 | { | ||
7208 | int rc; | ||
7209 | |||
7210 | QETH_DBF_TEXT(trace,3,"ipaipfrg"); | ||
7211 | |||
7212 | if (!qeth_is_supported(card, IPA_IP_FRAGMENTATION)) { | ||
7213 | PRINT_INFO("Hardware IP fragmentation not supported on %s\n", | ||
7214 | QETH_CARD_IFNAME(card)); | ||
7215 | return -EOPNOTSUPP; | ||
7216 | } | ||
7217 | |||
7218 | rc = qeth_send_simple_setassparms(card, IPA_IP_FRAGMENTATION, | ||
7219 | IPA_CMD_ASS_START, 0); | ||
7220 | if (rc) { | ||
7221 | PRINT_WARN("Could not start Hardware IP fragmentation " | ||
7222 | "assist on %s: 0x%x\n", | ||
7223 | QETH_CARD_IFNAME(card), rc); | ||
7224 | } else | ||
7225 | PRINT_INFO("Hardware IP fragmentation enabled \n"); | ||
7226 | return rc; | ||
7227 | } | ||
7228 | |||
7229 | static int | ||
7230 | qeth_start_ipa_source_mac(struct qeth_card *card) | ||
7231 | { | ||
7232 | int rc; | ||
7233 | |||
7234 | QETH_DBF_TEXT(trace,3,"stsrcmac"); | ||
7235 | |||
7236 | if (!card->options.fake_ll) | ||
7237 | return -EOPNOTSUPP; | ||
7238 | |||
7239 | if (!qeth_is_supported(card, IPA_SOURCE_MAC)) { | ||
7240 | PRINT_INFO("Inbound source address not " | ||
7241 | "supported on %s\n", QETH_CARD_IFNAME(card)); | ||
7242 | return -EOPNOTSUPP; | ||
7243 | } | ||
7244 | |||
7245 | rc = qeth_send_simple_setassparms(card, IPA_SOURCE_MAC, | ||
7246 | IPA_CMD_ASS_START, 0); | ||
7247 | if (rc) | ||
7248 | PRINT_WARN("Could not start inbound source " | ||
7249 | "assist on %s: 0x%x\n", | ||
7250 | QETH_CARD_IFNAME(card), rc); | ||
7251 | return rc; | ||
7252 | } | ||
7253 | |||
7254 | static int | ||
7255 | qeth_start_ipa_vlan(struct qeth_card *card) | ||
7256 | { | ||
7257 | int rc = 0; | ||
7258 | |||
7259 | QETH_DBF_TEXT(trace,3,"strtvlan"); | ||
7260 | |||
7261 | #ifdef CONFIG_QETH_VLAN | ||
7262 | if (!qeth_is_supported(card, IPA_FULL_VLAN)) { | ||
7263 | PRINT_WARN("VLAN not supported on %s\n", QETH_CARD_IFNAME(card)); | ||
7264 | return -EOPNOTSUPP; | ||
7265 | } | ||
7266 | |||
7267 | rc = qeth_send_simple_setassparms(card, IPA_VLAN_PRIO, | ||
7268 | IPA_CMD_ASS_START,0); | ||
7269 | if (rc) { | ||
7270 | PRINT_WARN("Could not start vlan " | ||
7271 | "assist on %s: 0x%x\n", | ||
7272 | QETH_CARD_IFNAME(card), rc); | ||
7273 | } else { | ||
7274 | PRINT_INFO("VLAN enabled \n"); | ||
7275 | card->dev->features |= | ||
7276 | NETIF_F_HW_VLAN_FILTER | | ||
7277 | NETIF_F_HW_VLAN_TX | | ||
7278 | NETIF_F_HW_VLAN_RX; | ||
7279 | } | ||
7280 | #endif /* QETH_VLAN */ | ||
7281 | return rc; | ||
7282 | } | ||
7283 | |||
7284 | static int | ||
7285 | qeth_start_ipa_multicast(struct qeth_card *card) | ||
7286 | { | ||
7287 | int rc; | ||
7288 | |||
7289 | QETH_DBF_TEXT(trace,3,"stmcast"); | ||
7290 | |||
7291 | if (!qeth_is_supported(card, IPA_MULTICASTING)) { | ||
7292 | PRINT_WARN("Multicast not supported on %s\n", | ||
7293 | QETH_CARD_IFNAME(card)); | ||
7294 | return -EOPNOTSUPP; | ||
7295 | } | ||
7296 | |||
7297 | rc = qeth_send_simple_setassparms(card, IPA_MULTICASTING, | ||
7298 | IPA_CMD_ASS_START,0); | ||
7299 | if (rc) { | ||
7300 | PRINT_WARN("Could not start multicast " | ||
7301 | "assist on %s: rc=%i\n", | ||
7302 | QETH_CARD_IFNAME(card), rc); | ||
7303 | } else { | ||
7304 | PRINT_INFO("Multicast enabled\n"); | ||
7305 | card->dev->flags |= IFF_MULTICAST; | ||
7306 | } | ||
7307 | return rc; | ||
7308 | } | ||
7309 | |||
7310 | #ifdef CONFIG_QETH_IPV6 | ||
7311 | static int | ||
7312 | qeth_softsetup_ipv6(struct qeth_card *card) | ||
7313 | { | ||
7314 | int rc; | ||
7315 | |||
7316 | QETH_DBF_TEXT(trace,3,"softipv6"); | ||
7317 | |||
7318 | rc = qeth_send_startlan(card, QETH_PROT_IPV6); | ||
7319 | if (rc) { | ||
7320 | PRINT_ERR("IPv6 startlan failed on %s\n", | ||
7321 | QETH_CARD_IFNAME(card)); | ||
7322 | return rc; | ||
7323 | } | ||
7324 | rc = qeth_query_ipassists(card,QETH_PROT_IPV6); | ||
7325 | if (rc) { | ||
7326 | PRINT_ERR("IPv6 query ipassist failed on %s\n", | ||
7327 | QETH_CARD_IFNAME(card)); | ||
7328 | return rc; | ||
7329 | } | ||
7330 | rc = qeth_send_simple_setassparms(card, IPA_IPV6, | ||
7331 | IPA_CMD_ASS_START, 3); | ||
7332 | if (rc) { | ||
7333 | PRINT_WARN("IPv6 start assist (version 4) failed " | ||
7334 | "on %s: 0x%x\n", | ||
7335 | QETH_CARD_IFNAME(card), rc); | ||
7336 | return rc; | ||
7337 | } | ||
7338 | rc = qeth_send_simple_setassparms_ipv6(card, IPA_IPV6, | ||
7339 | IPA_CMD_ASS_START); | ||
7340 | if (rc) { | ||
7341 | PRINT_WARN("IPV6 start assist (version 6) failed " | ||
7342 | "on %s: 0x%x\n", | ||
7343 | QETH_CARD_IFNAME(card), rc); | ||
7344 | return rc; | ||
7345 | } | ||
7346 | rc = qeth_send_simple_setassparms_ipv6(card, IPA_PASSTHRU, | ||
7347 | IPA_CMD_ASS_START); | ||
7348 | if (rc) { | ||
7349 | PRINT_WARN("Could not enable passthrough " | ||
7350 | "on %s: 0x%x\n", | ||
7351 | QETH_CARD_IFNAME(card), rc); | ||
7352 | return rc; | ||
7353 | } | ||
7354 | PRINT_INFO("IPV6 enabled \n"); | ||
7355 | return 0; | ||
7356 | } | ||
7357 | |||
7358 | #endif | ||
7359 | |||
7360 | static int | ||
7361 | qeth_start_ipa_ipv6(struct qeth_card *card) | ||
7362 | { | ||
7363 | int rc = 0; | ||
7364 | #ifdef CONFIG_QETH_IPV6 | ||
7365 | QETH_DBF_TEXT(trace,3,"strtipv6"); | ||
7366 | |||
7367 | if (!qeth_is_supported(card, IPA_IPV6)) { | ||
7368 | PRINT_WARN("IPv6 not supported on %s\n", | ||
7369 | QETH_CARD_IFNAME(card)); | ||
7370 | return 0; | ||
7371 | } | ||
7372 | rc = qeth_softsetup_ipv6(card); | ||
7373 | #endif | ||
7374 | return rc ; | ||
7375 | } | ||
7376 | |||
7377 | static int | ||
7378 | qeth_start_ipa_broadcast(struct qeth_card *card) | ||
7379 | { | ||
7380 | int rc; | ||
7381 | |||
7382 | QETH_DBF_TEXT(trace,3,"stbrdcst"); | ||
7383 | card->info.broadcast_capable = 0; | ||
7384 | if (!qeth_is_supported(card, IPA_FILTERING)) { | ||
7385 | PRINT_WARN("Broadcast not supported on %s\n", | ||
7386 | QETH_CARD_IFNAME(card)); | ||
7387 | rc = -EOPNOTSUPP; | ||
7388 | goto out; | ||
7389 | } | ||
7390 | rc = qeth_send_simple_setassparms(card, IPA_FILTERING, | ||
7391 | IPA_CMD_ASS_START, 0); | ||
7392 | if (rc) { | ||
7393 | PRINT_WARN("Could not enable broadcasting filtering " | ||
7394 | "on %s: 0x%x\n", | ||
7395 | QETH_CARD_IFNAME(card), rc); | ||
7396 | goto out; | ||
7397 | } | ||
7398 | |||
7399 | rc = qeth_send_simple_setassparms(card, IPA_FILTERING, | ||
7400 | IPA_CMD_ASS_CONFIGURE, 1); | ||
7401 | if (rc) { | ||
7402 | PRINT_WARN("Could not set up broadcast filtering on %s: 0x%x\n", | ||
7403 | QETH_CARD_IFNAME(card), rc); | ||
7404 | goto out; | ||
7405 | } | ||
7406 | card->info.broadcast_capable = QETH_BROADCAST_WITH_ECHO; | ||
7407 | PRINT_INFO("Broadcast enabled \n"); | ||
7408 | rc = qeth_send_simple_setassparms(card, IPA_FILTERING, | ||
7409 | IPA_CMD_ASS_ENABLE, 1); | ||
7410 | if (rc) { | ||
7411 | PRINT_WARN("Could not set up broadcast echo filtering on " | ||
7412 | "%s: 0x%x\n", QETH_CARD_IFNAME(card), rc); | ||
7413 | goto out; | ||
7414 | } | ||
7415 | card->info.broadcast_capable = QETH_BROADCAST_WITHOUT_ECHO; | ||
7416 | out: | ||
7417 | if (card->info.broadcast_capable) | ||
7418 | card->dev->flags |= IFF_BROADCAST; | ||
7419 | else | ||
7420 | card->dev->flags &= ~IFF_BROADCAST; | ||
7421 | return rc; | ||
7422 | } | ||
7423 | |||
7424 | static int | ||
7425 | qeth_send_checksum_command(struct qeth_card *card) | ||
7426 | { | ||
7427 | int rc; | ||
7428 | |||
7429 | rc = qeth_send_simple_setassparms(card, IPA_INBOUND_CHECKSUM, | ||
7430 | IPA_CMD_ASS_START, 0); | ||
7431 | if (rc) { | ||
7432 | PRINT_WARN("Starting Inbound HW Checksumming failed on %s: " | ||
7433 | "0x%x,\ncontinuing using Inbound SW Checksumming\n", | ||
7434 | QETH_CARD_IFNAME(card), rc); | ||
7435 | return rc; | ||
7436 | } | ||
7437 | rc = qeth_send_simple_setassparms(card, IPA_INBOUND_CHECKSUM, | ||
7438 | IPA_CMD_ASS_ENABLE, | ||
7439 | card->info.csum_mask); | ||
7440 | if (rc) { | ||
7441 | PRINT_WARN("Enabling Inbound HW Checksumming failed on %s: " | ||
7442 | "0x%x,\ncontinuing using Inbound SW Checksumming\n", | ||
7443 | QETH_CARD_IFNAME(card), rc); | ||
7444 | return rc; | ||
7445 | } | ||
7446 | return 0; | ||
7447 | } | ||
7448 | |||
7449 | static int | ||
7450 | qeth_start_ipa_checksum(struct qeth_card *card) | ||
7451 | { | ||
7452 | int rc = 0; | ||
7453 | |||
7454 | QETH_DBF_TEXT(trace,3,"strtcsum"); | ||
7455 | |||
7456 | if (card->options.checksum_type == NO_CHECKSUMMING) { | ||
7457 | PRINT_WARN("Using no checksumming on %s.\n", | ||
7458 | QETH_CARD_IFNAME(card)); | ||
7459 | return 0; | ||
7460 | } | ||
7461 | if (card->options.checksum_type == SW_CHECKSUMMING) { | ||
7462 | PRINT_WARN("Using SW checksumming on %s.\n", | ||
7463 | QETH_CARD_IFNAME(card)); | ||
7464 | return 0; | ||
7465 | } | ||
7466 | if (!qeth_is_supported(card, IPA_INBOUND_CHECKSUM)) { | ||
7467 | PRINT_WARN("Inbound HW Checksumming not " | ||
7468 | "supported on %s,\ncontinuing " | ||
7469 | "using Inbound SW Checksumming\n", | ||
7470 | QETH_CARD_IFNAME(card)); | ||
7471 | card->options.checksum_type = SW_CHECKSUMMING; | ||
7472 | return 0; | ||
7473 | } | ||
7474 | rc = qeth_send_checksum_command(card); | ||
7475 | if (!rc) { | ||
7476 | PRINT_INFO("HW Checksumming (inbound) enabled \n"); | ||
7477 | } | ||
7478 | return rc; | ||
7479 | } | ||
7480 | |||
7481 | static int | ||
7482 | qeth_start_ipa_tso(struct qeth_card *card) | ||
7483 | { | ||
7484 | int rc; | ||
7485 | |||
7486 | QETH_DBF_TEXT(trace,3,"sttso"); | ||
7487 | |||
7488 | if (!qeth_is_supported(card, IPA_OUTBOUND_TSO)) { | ||
7489 | PRINT_WARN("Outbound TSO not supported on %s\n", | ||
7490 | QETH_CARD_IFNAME(card)); | ||
7491 | rc = -EOPNOTSUPP; | ||
7492 | } else { | ||
7493 | rc = qeth_send_simple_setassparms(card, IPA_OUTBOUND_TSO, | ||
7494 | IPA_CMD_ASS_START,0); | ||
7495 | if (rc) | ||
7496 | PRINT_WARN("Could not start outbound TSO " | ||
7497 | "assist on %s: rc=%i\n", | ||
7498 | QETH_CARD_IFNAME(card), rc); | ||
7499 | else | ||
7500 | PRINT_INFO("Outbound TSO enabled\n"); | ||
7501 | } | ||
7502 | if (rc && (card->options.large_send == QETH_LARGE_SEND_TSO)){ | ||
7503 | card->options.large_send = QETH_LARGE_SEND_NO; | ||
7504 | card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG | | ||
7505 | NETIF_F_HW_CSUM); | ||
7506 | } | ||
7507 | return rc; | ||
7508 | } | ||
7509 | |||
7510 | static int | ||
7511 | qeth_start_ipassists(struct qeth_card *card) | ||
7512 | { | ||
7513 | QETH_DBF_TEXT(trace,3,"strtipas"); | ||
7514 | qeth_start_ipa_arp_processing(card); /* go on*/ | ||
7515 | qeth_start_ipa_ip_fragmentation(card); /* go on*/ | ||
7516 | qeth_start_ipa_source_mac(card); /* go on*/ | ||
7517 | qeth_start_ipa_vlan(card); /* go on*/ | ||
7518 | qeth_start_ipa_multicast(card); /* go on*/ | ||
7519 | qeth_start_ipa_ipv6(card); /* go on*/ | ||
7520 | qeth_start_ipa_broadcast(card); /* go on*/ | ||
7521 | qeth_start_ipa_checksum(card); /* go on*/ | ||
7522 | qeth_start_ipa_tso(card); /* go on*/ | ||
7523 | return 0; | ||
7524 | } | ||
7525 | |||
7526 | static int | ||
7527 | qeth_send_setrouting(struct qeth_card *card, enum qeth_routing_types type, | ||
7528 | enum qeth_prot_versions prot) | ||
7529 | { | ||
7530 | int rc; | ||
7531 | struct qeth_ipa_cmd *cmd; | ||
7532 | struct qeth_cmd_buffer *iob; | ||
7533 | |||
7534 | QETH_DBF_TEXT(trace,4,"setroutg"); | ||
7535 | iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SETRTG, prot); | ||
7536 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); | ||
7537 | cmd->data.setrtg.type = (type); | ||
7538 | rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); | ||
7539 | |||
7540 | return rc; | ||
7541 | |||
7542 | } | ||
7543 | |||
7544 | static void | ||
7545 | qeth_correct_routing_type(struct qeth_card *card, enum qeth_routing_types *type, | ||
7546 | enum qeth_prot_versions prot) | ||
7547 | { | ||
7548 | if (card->info.type == QETH_CARD_TYPE_IQD) { | ||
7549 | switch (*type) { | ||
7550 | case NO_ROUTER: | ||
7551 | case PRIMARY_CONNECTOR: | ||
7552 | case SECONDARY_CONNECTOR: | ||
7553 | case MULTICAST_ROUTER: | ||
7554 | return; | ||
7555 | default: | ||
7556 | goto out_inval; | ||
7557 | } | ||
7558 | } else { | ||
7559 | switch (*type) { | ||
7560 | case NO_ROUTER: | ||
7561 | case PRIMARY_ROUTER: | ||
7562 | case SECONDARY_ROUTER: | ||
7563 | return; | ||
7564 | case MULTICAST_ROUTER: | ||
7565 | if (qeth_is_ipafunc_supported(card, prot, | ||
7566 | IPA_OSA_MC_ROUTER)) | ||
7567 | return; | ||
7568 | default: | ||
7569 | goto out_inval; | ||
7570 | } | ||
7571 | } | ||
7572 | out_inval: | ||
7573 | PRINT_WARN("Routing type '%s' not supported for interface %s.\n" | ||
7574 | "Router status set to 'no router'.\n", | ||
7575 | ((*type == PRIMARY_ROUTER)? "primary router" : | ||
7576 | (*type == SECONDARY_ROUTER)? "secondary router" : | ||
7577 | (*type == PRIMARY_CONNECTOR)? "primary connector" : | ||
7578 | (*type == SECONDARY_CONNECTOR)? "secondary connector" : | ||
7579 | (*type == MULTICAST_ROUTER)? "multicast router" : | ||
7580 | "unknown"), | ||
7581 | card->dev->name); | ||
7582 | *type = NO_ROUTER; | ||
7583 | } | ||
7584 | |||
7585 | int | ||
7586 | qeth_setrouting_v4(struct qeth_card *card) | ||
7587 | { | ||
7588 | int rc; | ||
7589 | |||
7590 | QETH_DBF_TEXT(trace,3,"setrtg4"); | ||
7591 | |||
7592 | qeth_correct_routing_type(card, &card->options.route4.type, | ||
7593 | QETH_PROT_IPV4); | ||
7594 | |||
7595 | rc = qeth_send_setrouting(card, card->options.route4.type, | ||
7596 | QETH_PROT_IPV4); | ||
7597 | if (rc) { | ||
7598 | card->options.route4.type = NO_ROUTER; | ||
7599 | PRINT_WARN("Error (0x%04x) while setting routing type on %s. " | ||
7600 | "Type set to 'no router'.\n", | ||
7601 | rc, QETH_CARD_IFNAME(card)); | ||
7602 | } | ||
7603 | return rc; | ||
7604 | } | ||
7605 | |||
7606 | int | ||
7607 | qeth_setrouting_v6(struct qeth_card *card) | ||
7608 | { | ||
7609 | int rc = 0; | ||
7610 | |||
7611 | QETH_DBF_TEXT(trace,3,"setrtg6"); | ||
7612 | #ifdef CONFIG_QETH_IPV6 | ||
7613 | |||
7614 | if (!qeth_is_supported(card, IPA_IPV6)) | ||
7615 | return 0; | ||
7616 | qeth_correct_routing_type(card, &card->options.route6.type, | ||
7617 | QETH_PROT_IPV6); | ||
7618 | |||
7619 | rc = qeth_send_setrouting(card, card->options.route6.type, | ||
7620 | QETH_PROT_IPV6); | ||
7621 | if (rc) { | ||
7622 | card->options.route6.type = NO_ROUTER; | ||
7623 | PRINT_WARN("Error (0x%04x) while setting routing type on %s. " | ||
7624 | "Type set to 'no router'.\n", | ||
7625 | rc, QETH_CARD_IFNAME(card)); | ||
7626 | } | ||
7627 | #endif | ||
7628 | return rc; | ||
7629 | } | ||
7630 | |||
7631 | int | ||
7632 | qeth_set_large_send(struct qeth_card *card, enum qeth_large_send_types type) | ||
7633 | { | ||
7634 | int rc = 0; | ||
7635 | |||
7636 | if (card->dev == NULL) { | ||
7637 | card->options.large_send = type; | ||
7638 | return 0; | ||
7639 | } | ||
7640 | if (card->state == CARD_STATE_UP) | ||
7641 | netif_tx_disable(card->dev); | ||
7642 | card->options.large_send = type; | ||
7643 | switch (card->options.large_send) { | ||
7644 | case QETH_LARGE_SEND_EDDP: | ||
7645 | card->dev->features |= NETIF_F_TSO | NETIF_F_SG | | ||
7646 | NETIF_F_HW_CSUM; | ||
7647 | break; | ||
7648 | case QETH_LARGE_SEND_TSO: | ||
7649 | if (qeth_is_supported(card, IPA_OUTBOUND_TSO)){ | ||
7650 | card->dev->features |= NETIF_F_TSO | NETIF_F_SG | | ||
7651 | NETIF_F_HW_CSUM; | ||
7652 | } else { | ||
7653 | PRINT_WARN("TSO not supported on %s. " | ||
7654 | "large_send set to 'no'.\n", | ||
7655 | card->dev->name); | ||
7656 | card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG | | ||
7657 | NETIF_F_HW_CSUM); | ||
7658 | card->options.large_send = QETH_LARGE_SEND_NO; | ||
7659 | rc = -EOPNOTSUPP; | ||
7660 | } | ||
7661 | break; | ||
7662 | default: /* includes QETH_LARGE_SEND_NO */ | ||
7663 | card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG | | ||
7664 | NETIF_F_HW_CSUM); | ||
7665 | break; | ||
7666 | } | ||
7667 | if (card->state == CARD_STATE_UP) | ||
7668 | netif_wake_queue(card->dev); | ||
7669 | return rc; | ||
7670 | } | ||
7671 | |||
7672 | /* | ||
7673 | * softsetup card: init IPA stuff | ||
7674 | */ | ||
7675 | static int | ||
7676 | qeth_softsetup_card(struct qeth_card *card) | ||
7677 | { | ||
7678 | int rc; | ||
7679 | |||
7680 | QETH_DBF_TEXT(setup, 2, "softsetp"); | ||
7681 | |||
7682 | if ((rc = qeth_send_startlan(card, QETH_PROT_IPV4))){ | ||
7683 | QETH_DBF_TEXT_(setup, 2, "1err%d", rc); | ||
7684 | if (rc == 0xe080){ | ||
7685 | PRINT_WARN("LAN on card %s if offline! " | ||
7686 | "Waiting for STARTLAN from card.\n", | ||
7687 | CARD_BUS_ID(card)); | ||
7688 | card->lan_online = 0; | ||
7689 | } | ||
7690 | return rc; | ||
7691 | } else | ||
7692 | card->lan_online = 1; | ||
7693 | if (card->info.type==QETH_CARD_TYPE_OSN) | ||
7694 | goto out; | ||
7695 | qeth_set_large_send(card, card->options.large_send); | ||
7696 | if (card->options.layer2) { | ||
7697 | card->dev->features |= | ||
7698 | NETIF_F_HW_VLAN_FILTER | | ||
7699 | NETIF_F_HW_VLAN_TX | | ||
7700 | NETIF_F_HW_VLAN_RX; | ||
7701 | card->dev->flags|=IFF_MULTICAST|IFF_BROADCAST; | ||
7702 | card->info.broadcast_capable=1; | ||
7703 | if ((rc = qeth_layer2_initialize(card))) { | ||
7704 | QETH_DBF_TEXT_(setup, 2, "L2err%d", rc); | ||
7705 | return rc; | ||
7706 | } | ||
7707 | #ifdef CONFIG_QETH_VLAN | ||
7708 | qeth_layer2_process_vlans(card, 0); | ||
7709 | #endif | ||
7710 | goto out; | ||
7711 | } | ||
7712 | if ((rc = qeth_setadapter_parms(card))) | ||
7713 | QETH_DBF_TEXT_(setup, 2, "2err%d", rc); | ||
7714 | if ((rc = qeth_start_ipassists(card))) | ||
7715 | QETH_DBF_TEXT_(setup, 2, "3err%d", rc); | ||
7716 | if ((rc = qeth_setrouting_v4(card))) | ||
7717 | QETH_DBF_TEXT_(setup, 2, "4err%d", rc); | ||
7718 | if ((rc = qeth_setrouting_v6(card))) | ||
7719 | QETH_DBF_TEXT_(setup, 2, "5err%d", rc); | ||
7720 | out: | ||
7721 | netif_tx_disable(card->dev); | ||
7722 | return 0; | ||
7723 | } | ||
7724 | |||
7725 | #ifdef CONFIG_QETH_IPV6 | ||
7726 | static int | ||
7727 | qeth_get_unique_id_cb(struct qeth_card *card, struct qeth_reply *reply, | ||
7728 | unsigned long data) | ||
7729 | { | ||
7730 | struct qeth_ipa_cmd *cmd; | ||
7731 | |||
7732 | cmd = (struct qeth_ipa_cmd *) data; | ||
7733 | if (cmd->hdr.return_code == 0) | ||
7734 | card->info.unique_id = *((__u16 *) | ||
7735 | &cmd->data.create_destroy_addr.unique_id[6]); | ||
7736 | else { | ||
7737 | card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED | | ||
7738 | UNIQUE_ID_NOT_BY_CARD; | ||
7739 | PRINT_WARN("couldn't get a unique id from the card on device " | ||
7740 | "%s (result=x%x), using default id. ipv6 " | ||
7741 | "autoconfig on other lpars may lead to duplicate " | ||
7742 | "ip addresses. please use manually " | ||
7743 | "configured ones.\n", | ||
7744 | CARD_BUS_ID(card), cmd->hdr.return_code); | ||
7745 | } | ||
7746 | return 0; | ||
7747 | } | ||
7748 | #endif | ||
7749 | |||
7750 | static int | ||
7751 | qeth_put_unique_id(struct qeth_card *card) | ||
7752 | { | ||
7753 | |||
7754 | int rc = 0; | ||
7755 | #ifdef CONFIG_QETH_IPV6 | ||
7756 | struct qeth_cmd_buffer *iob; | ||
7757 | struct qeth_ipa_cmd *cmd; | ||
7758 | |||
7759 | QETH_DBF_TEXT(trace,2,"puniqeid"); | ||
7760 | |||
7761 | if ((card->info.unique_id & UNIQUE_ID_NOT_BY_CARD) == | ||
7762 | UNIQUE_ID_NOT_BY_CARD) | ||
7763 | return -1; | ||
7764 | iob = qeth_get_ipacmd_buffer(card, IPA_CMD_DESTROY_ADDR, | ||
7765 | QETH_PROT_IPV6); | ||
7766 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); | ||
7767 | *((__u16 *) &cmd->data.create_destroy_addr.unique_id[6]) = | ||
7768 | card->info.unique_id; | ||
7769 | memcpy(&cmd->data.create_destroy_addr.unique_id[0], | ||
7770 | card->dev->dev_addr, OSA_ADDR_LEN); | ||
7771 | rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); | ||
7772 | #else | ||
7773 | card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED | | ||
7774 | UNIQUE_ID_NOT_BY_CARD; | ||
7775 | #endif | ||
7776 | return rc; | ||
7777 | } | ||
7778 | |||
7779 | /** | ||
7780 | * Clear IP List | ||
7781 | */ | ||
7782 | static void | ||
7783 | qeth_clear_ip_list(struct qeth_card *card, int clean, int recover) | ||
7784 | { | ||
7785 | struct qeth_ipaddr *addr, *tmp; | ||
7786 | unsigned long flags; | ||
7787 | |||
7788 | QETH_DBF_TEXT(trace,4,"clearip"); | ||
7789 | spin_lock_irqsave(&card->ip_lock, flags); | ||
7790 | /* clear todo list */ | ||
7791 | list_for_each_entry_safe(addr, tmp, card->ip_tbd_list, entry){ | ||
7792 | list_del(&addr->entry); | ||
7793 | kfree(addr); | ||
7794 | } | ||
7795 | |||
7796 | while (!list_empty(&card->ip_list)) { | ||
7797 | addr = list_entry(card->ip_list.next, | ||
7798 | struct qeth_ipaddr, entry); | ||
7799 | list_del_init(&addr->entry); | ||
7800 | if (clean) { | ||
7801 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
7802 | qeth_deregister_addr_entry(card, addr); | ||
7803 | spin_lock_irqsave(&card->ip_lock, flags); | ||
7804 | } | ||
7805 | if (!recover || addr->is_multicast) { | ||
7806 | kfree(addr); | ||
7807 | continue; | ||
7808 | } | ||
7809 | list_add_tail(&addr->entry, card->ip_tbd_list); | ||
7810 | } | ||
7811 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
7812 | } | ||
7813 | |||
7814 | static void | ||
7815 | qeth_set_allowed_threads(struct qeth_card *card, unsigned long threads, | ||
7816 | int clear_start_mask) | ||
7817 | { | ||
7818 | unsigned long flags; | ||
7819 | |||
7820 | spin_lock_irqsave(&card->thread_mask_lock, flags); | ||
7821 | card->thread_allowed_mask = threads; | ||
7822 | if (clear_start_mask) | ||
7823 | card->thread_start_mask &= threads; | ||
7824 | spin_unlock_irqrestore(&card->thread_mask_lock, flags); | ||
7825 | wake_up(&card->wait_q); | ||
7826 | } | ||
7827 | |||
7828 | static int | ||
7829 | qeth_threads_running(struct qeth_card *card, unsigned long threads) | ||
7830 | { | ||
7831 | unsigned long flags; | ||
7832 | int rc = 0; | ||
7833 | |||
7834 | spin_lock_irqsave(&card->thread_mask_lock, flags); | ||
7835 | rc = (card->thread_running_mask & threads); | ||
7836 | spin_unlock_irqrestore(&card->thread_mask_lock, flags); | ||
7837 | return rc; | ||
7838 | } | ||
7839 | |||
7840 | static int | ||
7841 | qeth_wait_for_threads(struct qeth_card *card, unsigned long threads) | ||
7842 | { | ||
7843 | return wait_event_interruptible(card->wait_q, | ||
7844 | qeth_threads_running(card, threads) == 0); | ||
7845 | } | ||
7846 | |||
7847 | static int | ||
7848 | qeth_stop_card(struct qeth_card *card, int recovery_mode) | ||
7849 | { | ||
7850 | int rc = 0; | ||
7851 | |||
7852 | QETH_DBF_TEXT(setup ,2,"stopcard"); | ||
7853 | QETH_DBF_HEX(setup, 2, &card, sizeof(void *)); | ||
7854 | |||
7855 | qeth_set_allowed_threads(card, 0, 1); | ||
7856 | if (qeth_wait_for_threads(card, ~QETH_RECOVER_THREAD)) | ||
7857 | return -ERESTARTSYS; | ||
7858 | if (card->read.state == CH_STATE_UP && | ||
7859 | card->write.state == CH_STATE_UP && | ||
7860 | (card->state == CARD_STATE_UP)) { | ||
7861 | if (recovery_mode && | ||
7862 | card->info.type != QETH_CARD_TYPE_OSN) { | ||
7863 | qeth_stop(card->dev); | ||
7864 | } else { | ||
7865 | rtnl_lock(); | ||
7866 | dev_close(card->dev); | ||
7867 | rtnl_unlock(); | ||
7868 | } | ||
7869 | if (!card->use_hard_stop) { | ||
7870 | __u8 *mac = &card->dev->dev_addr[0]; | ||
7871 | rc = qeth_layer2_send_delmac(card, mac); | ||
7872 | QETH_DBF_TEXT_(setup, 2, "Lerr%d", rc); | ||
7873 | if ((rc = qeth_send_stoplan(card))) | ||
7874 | QETH_DBF_TEXT_(setup, 2, "1err%d", rc); | ||
7875 | } | ||
7876 | card->state = CARD_STATE_SOFTSETUP; | ||
7877 | } | ||
7878 | if (card->state == CARD_STATE_SOFTSETUP) { | ||
7879 | #ifdef CONFIG_QETH_VLAN | ||
7880 | if (card->options.layer2) | ||
7881 | qeth_layer2_process_vlans(card, 1); | ||
7882 | #endif | ||
7883 | qeth_clear_ip_list(card, !card->use_hard_stop, 1); | ||
7884 | qeth_clear_ipacmd_list(card); | ||
7885 | card->state = CARD_STATE_HARDSETUP; | ||
7886 | } | ||
7887 | if (card->state == CARD_STATE_HARDSETUP) { | ||
7888 | if ((!card->use_hard_stop) && | ||
7889 | (!card->options.layer2)) | ||
7890 | if ((rc = qeth_put_unique_id(card))) | ||
7891 | QETH_DBF_TEXT_(setup, 2, "2err%d", rc); | ||
7892 | qeth_qdio_clear_card(card, 0); | ||
7893 | qeth_clear_qdio_buffers(card); | ||
7894 | qeth_clear_working_pool_list(card); | ||
7895 | card->state = CARD_STATE_DOWN; | ||
7896 | } | ||
7897 | if (card->state == CARD_STATE_DOWN) { | ||
7898 | qeth_clear_cmd_buffers(&card->read); | ||
7899 | qeth_clear_cmd_buffers(&card->write); | ||
7900 | } | ||
7901 | card->use_hard_stop = 0; | ||
7902 | return rc; | ||
7903 | } | ||
7904 | |||
7905 | |||
7906 | static int | ||
7907 | qeth_get_unique_id(struct qeth_card *card) | ||
7908 | { | ||
7909 | int rc = 0; | ||
7910 | #ifdef CONFIG_QETH_IPV6 | ||
7911 | struct qeth_cmd_buffer *iob; | ||
7912 | struct qeth_ipa_cmd *cmd; | ||
7913 | |||
7914 | QETH_DBF_TEXT(setup, 2, "guniqeid"); | ||
7915 | |||
7916 | if (!qeth_is_supported(card,IPA_IPV6)) { | ||
7917 | card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED | | ||
7918 | UNIQUE_ID_NOT_BY_CARD; | ||
7919 | return 0; | ||
7920 | } | ||
7921 | |||
7922 | iob = qeth_get_ipacmd_buffer(card, IPA_CMD_CREATE_ADDR, | ||
7923 | QETH_PROT_IPV6); | ||
7924 | cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); | ||
7925 | *((__u16 *) &cmd->data.create_destroy_addr.unique_id[6]) = | ||
7926 | card->info.unique_id; | ||
7927 | |||
7928 | rc = qeth_send_ipa_cmd(card, iob, qeth_get_unique_id_cb, NULL); | ||
7929 | #else | ||
7930 | card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED | | ||
7931 | UNIQUE_ID_NOT_BY_CARD; | ||
7932 | #endif | ||
7933 | return rc; | ||
7934 | } | ||
7935 | static void | ||
7936 | qeth_print_status_with_portname(struct qeth_card *card) | ||
7937 | { | ||
7938 | char dbf_text[15]; | ||
7939 | int i; | ||
7940 | |||
7941 | sprintf(dbf_text, "%s", card->info.portname + 1); | ||
7942 | for (i = 0; i < 8; i++) | ||
7943 | dbf_text[i] = | ||
7944 | (char) _ebcasc[(__u8) dbf_text[i]]; | ||
7945 | dbf_text[8] = 0; | ||
7946 | printk("qeth: Device %s/%s/%s is a%s card%s%s%s\n" | ||
7947 | "with link type %s (portname: %s)\n", | ||
7948 | CARD_RDEV_ID(card), | ||
7949 | CARD_WDEV_ID(card), | ||
7950 | CARD_DDEV_ID(card), | ||
7951 | qeth_get_cardname(card), | ||
7952 | (card->info.mcl_level[0]) ? " (level: " : "", | ||
7953 | (card->info.mcl_level[0]) ? card->info.mcl_level : "", | ||
7954 | (card->info.mcl_level[0]) ? ")" : "", | ||
7955 | qeth_get_cardname_short(card), | ||
7956 | dbf_text); | ||
7957 | |||
7958 | } | ||
7959 | |||
7960 | static void | ||
7961 | qeth_print_status_no_portname(struct qeth_card *card) | ||
7962 | { | ||
7963 | if (card->info.portname[0]) | ||
7964 | printk("qeth: Device %s/%s/%s is a%s " | ||
7965 | "card%s%s%s\nwith link type %s " | ||
7966 | "(no portname needed by interface).\n", | ||
7967 | CARD_RDEV_ID(card), | ||
7968 | CARD_WDEV_ID(card), | ||
7969 | CARD_DDEV_ID(card), | ||
7970 | qeth_get_cardname(card), | ||
7971 | (card->info.mcl_level[0]) ? " (level: " : "", | ||
7972 | (card->info.mcl_level[0]) ? card->info.mcl_level : "", | ||
7973 | (card->info.mcl_level[0]) ? ")" : "", | ||
7974 | qeth_get_cardname_short(card)); | ||
7975 | else | ||
7976 | printk("qeth: Device %s/%s/%s is a%s " | ||
7977 | "card%s%s%s\nwith link type %s.\n", | ||
7978 | CARD_RDEV_ID(card), | ||
7979 | CARD_WDEV_ID(card), | ||
7980 | CARD_DDEV_ID(card), | ||
7981 | qeth_get_cardname(card), | ||
7982 | (card->info.mcl_level[0]) ? " (level: " : "", | ||
7983 | (card->info.mcl_level[0]) ? card->info.mcl_level : "", | ||
7984 | (card->info.mcl_level[0]) ? ")" : "", | ||
7985 | qeth_get_cardname_short(card)); | ||
7986 | } | ||
7987 | |||
7988 | static void | ||
7989 | qeth_print_status_message(struct qeth_card *card) | ||
7990 | { | ||
7991 | switch (card->info.type) { | ||
7992 | case QETH_CARD_TYPE_OSAE: | ||
7993 | /* VM will use a non-zero first character | ||
7994 | * to indicate a HiperSockets like reporting | ||
7995 | * of the level OSA sets the first character to zero | ||
7996 | * */ | ||
7997 | if (!card->info.mcl_level[0]) { | ||
7998 | sprintf(card->info.mcl_level,"%02x%02x", | ||
7999 | card->info.mcl_level[2], | ||
8000 | card->info.mcl_level[3]); | ||
8001 | |||
8002 | card->info.mcl_level[QETH_MCL_LENGTH] = 0; | ||
8003 | break; | ||
8004 | } | ||
8005 | /* fallthrough */ | ||
8006 | case QETH_CARD_TYPE_IQD: | ||
8007 | if (card->info.guestlan) { | ||
8008 | card->info.mcl_level[0] = (char) _ebcasc[(__u8) | ||
8009 | card->info.mcl_level[0]]; | ||
8010 | card->info.mcl_level[1] = (char) _ebcasc[(__u8) | ||
8011 | card->info.mcl_level[1]]; | ||
8012 | card->info.mcl_level[2] = (char) _ebcasc[(__u8) | ||
8013 | card->info.mcl_level[2]]; | ||
8014 | card->info.mcl_level[3] = (char) _ebcasc[(__u8) | ||
8015 | card->info.mcl_level[3]]; | ||
8016 | card->info.mcl_level[QETH_MCL_LENGTH] = 0; | ||
8017 | } | ||
8018 | break; | ||
8019 | default: | ||
8020 | memset(&card->info.mcl_level[0], 0, QETH_MCL_LENGTH + 1); | ||
8021 | } | ||
8022 | if (card->info.portname_required) | ||
8023 | qeth_print_status_with_portname(card); | ||
8024 | else | ||
8025 | qeth_print_status_no_portname(card); | ||
8026 | } | ||
8027 | |||
8028 | static int | ||
8029 | qeth_register_netdev(struct qeth_card *card) | ||
8030 | { | ||
8031 | QETH_DBF_TEXT(setup, 3, "regnetd"); | ||
8032 | if (card->dev->reg_state != NETREG_UNINITIALIZED) | ||
8033 | return 0; | ||
8034 | /* sysfs magic */ | ||
8035 | SET_NETDEV_DEV(card->dev, &card->gdev->dev); | ||
8036 | return register_netdev(card->dev); | ||
8037 | } | ||
8038 | |||
8039 | static void | ||
8040 | qeth_start_again(struct qeth_card *card, int recovery_mode) | ||
8041 | { | ||
8042 | QETH_DBF_TEXT(setup ,2, "startag"); | ||
8043 | |||
8044 | if (recovery_mode && | ||
8045 | card->info.type != QETH_CARD_TYPE_OSN) { | ||
8046 | qeth_open(card->dev); | ||
8047 | } else { | ||
8048 | rtnl_lock(); | ||
8049 | dev_open(card->dev); | ||
8050 | rtnl_unlock(); | ||
8051 | } | ||
8052 | /* this also sets saved unicast addresses */ | ||
8053 | qeth_set_multicast_list(card->dev); | ||
8054 | } | ||
8055 | |||
8056 | |||
8057 | /* Layer 2 specific stuff */ | ||
8058 | #define IGNORE_PARAM_EQ(option,value,reset_value,msg) \ | ||
8059 | if (card->options.option == value) { \ | ||
8060 | PRINT_ERR("%s not supported with layer 2 " \ | ||
8061 | "functionality, ignoring option on read" \ | ||
8062 | "channel device %s .\n",msg,CARD_RDEV_ID(card)); \ | ||
8063 | card->options.option = reset_value; \ | ||
8064 | } | ||
8065 | #define IGNORE_PARAM_NEQ(option,value,reset_value,msg) \ | ||
8066 | if (card->options.option != value) { \ | ||
8067 | PRINT_ERR("%s not supported with layer 2 " \ | ||
8068 | "functionality, ignoring option on read" \ | ||
8069 | "channel device %s .\n",msg,CARD_RDEV_ID(card)); \ | ||
8070 | card->options.option = reset_value; \ | ||
8071 | } | ||
8072 | |||
8073 | |||
8074 | static void qeth_make_parameters_consistent(struct qeth_card *card) | ||
8075 | { | ||
8076 | |||
8077 | if (card->options.layer2 == 0) | ||
8078 | return; | ||
8079 | if (card->info.type == QETH_CARD_TYPE_OSN) | ||
8080 | return; | ||
8081 | if (card->info.type == QETH_CARD_TYPE_IQD) { | ||
8082 | PRINT_ERR("Device %s does not support layer 2 functionality." \ | ||
8083 | " Ignoring layer2 option.\n",CARD_BUS_ID(card)); | ||
8084 | card->options.layer2 = 0; | ||
8085 | return; | ||
8086 | } | ||
8087 | IGNORE_PARAM_NEQ(route4.type, NO_ROUTER, NO_ROUTER, | ||
8088 | "Routing options are"); | ||
8089 | #ifdef CONFIG_QETH_IPV6 | ||
8090 | IGNORE_PARAM_NEQ(route6.type, NO_ROUTER, NO_ROUTER, | ||
8091 | "Routing options are"); | ||
8092 | #endif | ||
8093 | IGNORE_PARAM_EQ(checksum_type, HW_CHECKSUMMING, | ||
8094 | QETH_CHECKSUM_DEFAULT, | ||
8095 | "Checksumming options are"); | ||
8096 | IGNORE_PARAM_NEQ(broadcast_mode, QETH_TR_BROADCAST_ALLRINGS, | ||
8097 | QETH_TR_BROADCAST_ALLRINGS, | ||
8098 | "Broadcast mode options are"); | ||
8099 | IGNORE_PARAM_NEQ(macaddr_mode, QETH_TR_MACADDR_NONCANONICAL, | ||
8100 | QETH_TR_MACADDR_NONCANONICAL, | ||
8101 | "Canonical MAC addr options are"); | ||
8102 | IGNORE_PARAM_NEQ(fake_broadcast, 0, 0, | ||
8103 | "Broadcast faking options are"); | ||
8104 | IGNORE_PARAM_NEQ(add_hhlen, DEFAULT_ADD_HHLEN, | ||
8105 | DEFAULT_ADD_HHLEN,"Option add_hhlen is"); | ||
8106 | IGNORE_PARAM_NEQ(fake_ll, 0, 0,"Option fake_ll is"); | ||
8107 | } | ||
8108 | |||
8109 | |||
8110 | static int | ||
8111 | __qeth_set_online(struct ccwgroup_device *gdev, int recovery_mode) | ||
8112 | { | ||
8113 | struct qeth_card *card = gdev->dev.driver_data; | ||
8114 | int rc = 0; | ||
8115 | enum qeth_card_states recover_flag; | ||
8116 | |||
8117 | BUG_ON(!card); | ||
8118 | QETH_DBF_TEXT(setup ,2, "setonlin"); | ||
8119 | QETH_DBF_HEX(setup, 2, &card, sizeof(void *)); | ||
8120 | |||
8121 | qeth_set_allowed_threads(card, QETH_RECOVER_THREAD, 1); | ||
8122 | if (qeth_wait_for_threads(card, ~QETH_RECOVER_THREAD)){ | ||
8123 | PRINT_WARN("set_online of card %s interrupted by user!\n", | ||
8124 | CARD_BUS_ID(card)); | ||
8125 | return -ERESTARTSYS; | ||
8126 | } | ||
8127 | |||
8128 | recover_flag = card->state; | ||
8129 | if ((rc = ccw_device_set_online(CARD_RDEV(card))) || | ||
8130 | (rc = ccw_device_set_online(CARD_WDEV(card))) || | ||
8131 | (rc = ccw_device_set_online(CARD_DDEV(card)))){ | ||
8132 | QETH_DBF_TEXT_(setup, 2, "1err%d", rc); | ||
8133 | return -EIO; | ||
8134 | } | ||
8135 | |||
8136 | qeth_make_parameters_consistent(card); | ||
8137 | |||
8138 | if ((rc = qeth_hardsetup_card(card))){ | ||
8139 | QETH_DBF_TEXT_(setup, 2, "2err%d", rc); | ||
8140 | goto out_remove; | ||
8141 | } | ||
8142 | card->state = CARD_STATE_HARDSETUP; | ||
8143 | |||
8144 | if (!(rc = qeth_query_ipassists(card,QETH_PROT_IPV4))) | ||
8145 | rc = qeth_get_unique_id(card); | ||
8146 | |||
8147 | if (rc && card->options.layer2 == 0) { | ||
8148 | QETH_DBF_TEXT_(setup, 2, "3err%d", rc); | ||
8149 | goto out_remove; | ||
8150 | } | ||
8151 | qeth_print_status_message(card); | ||
8152 | if ((rc = qeth_register_netdev(card))){ | ||
8153 | QETH_DBF_TEXT_(setup, 2, "4err%d", rc); | ||
8154 | goto out_remove; | ||
8155 | } | ||
8156 | if ((rc = qeth_softsetup_card(card))){ | ||
8157 | QETH_DBF_TEXT_(setup, 2, "5err%d", rc); | ||
8158 | goto out_remove; | ||
8159 | } | ||
8160 | |||
8161 | if ((rc = qeth_init_qdio_queues(card))){ | ||
8162 | QETH_DBF_TEXT_(setup, 2, "6err%d", rc); | ||
8163 | goto out_remove; | ||
8164 | } | ||
8165 | card->state = CARD_STATE_SOFTSETUP; | ||
8166 | netif_carrier_on(card->dev); | ||
8167 | |||
8168 | qeth_set_allowed_threads(card, 0xffffffff, 0); | ||
8169 | if (recover_flag == CARD_STATE_RECOVER) | ||
8170 | qeth_start_again(card, recovery_mode); | ||
8171 | qeth_notify_processes(); | ||
8172 | return 0; | ||
8173 | out_remove: | ||
8174 | card->use_hard_stop = 1; | ||
8175 | qeth_stop_card(card, 0); | ||
8176 | ccw_device_set_offline(CARD_DDEV(card)); | ||
8177 | ccw_device_set_offline(CARD_WDEV(card)); | ||
8178 | ccw_device_set_offline(CARD_RDEV(card)); | ||
8179 | if (recover_flag == CARD_STATE_RECOVER) | ||
8180 | card->state = CARD_STATE_RECOVER; | ||
8181 | else | ||
8182 | card->state = CARD_STATE_DOWN; | ||
8183 | return -ENODEV; | ||
8184 | } | ||
8185 | |||
8186 | static int | ||
8187 | qeth_set_online(struct ccwgroup_device *gdev) | ||
8188 | { | ||
8189 | return __qeth_set_online(gdev, 0); | ||
8190 | } | ||
8191 | |||
8192 | static struct ccw_device_id qeth_ids[] = { | ||
8193 | {CCW_DEVICE(0x1731, 0x01), .driver_info = QETH_CARD_TYPE_OSAE}, | ||
8194 | {CCW_DEVICE(0x1731, 0x05), .driver_info = QETH_CARD_TYPE_IQD}, | ||
8195 | {CCW_DEVICE(0x1731, 0x06), .driver_info = QETH_CARD_TYPE_OSN}, | ||
8196 | {}, | ||
8197 | }; | ||
8198 | MODULE_DEVICE_TABLE(ccw, qeth_ids); | ||
8199 | |||
8200 | struct device *qeth_root_dev = NULL; | ||
8201 | |||
8202 | struct ccwgroup_driver qeth_ccwgroup_driver = { | ||
8203 | .owner = THIS_MODULE, | ||
8204 | .name = "qeth", | ||
8205 | .driver_id = 0xD8C5E3C8, | ||
8206 | .probe = qeth_probe_device, | ||
8207 | .remove = qeth_remove_device, | ||
8208 | .set_online = qeth_set_online, | ||
8209 | .set_offline = qeth_set_offline, | ||
8210 | }; | ||
8211 | |||
8212 | struct ccw_driver qeth_ccw_driver = { | ||
8213 | .name = "qeth", | ||
8214 | .ids = qeth_ids, | ||
8215 | .probe = ccwgroup_probe_ccwdev, | ||
8216 | .remove = ccwgroup_remove_ccwdev, | ||
8217 | }; | ||
8218 | |||
8219 | |||
8220 | static void | ||
8221 | qeth_unregister_dbf_views(void) | ||
8222 | { | ||
8223 | if (qeth_dbf_setup) | ||
8224 | debug_unregister(qeth_dbf_setup); | ||
8225 | if (qeth_dbf_qerr) | ||
8226 | debug_unregister(qeth_dbf_qerr); | ||
8227 | if (qeth_dbf_sense) | ||
8228 | debug_unregister(qeth_dbf_sense); | ||
8229 | if (qeth_dbf_misc) | ||
8230 | debug_unregister(qeth_dbf_misc); | ||
8231 | if (qeth_dbf_data) | ||
8232 | debug_unregister(qeth_dbf_data); | ||
8233 | if (qeth_dbf_control) | ||
8234 | debug_unregister(qeth_dbf_control); | ||
8235 | if (qeth_dbf_trace) | ||
8236 | debug_unregister(qeth_dbf_trace); | ||
8237 | } | ||
8238 | static int | ||
8239 | qeth_register_dbf_views(void) | ||
8240 | { | ||
8241 | qeth_dbf_setup = debug_register(QETH_DBF_SETUP_NAME, | ||
8242 | QETH_DBF_SETUP_PAGES, | ||
8243 | QETH_DBF_SETUP_NR_AREAS, | ||
8244 | QETH_DBF_SETUP_LEN); | ||
8245 | qeth_dbf_misc = debug_register(QETH_DBF_MISC_NAME, | ||
8246 | QETH_DBF_MISC_PAGES, | ||
8247 | QETH_DBF_MISC_NR_AREAS, | ||
8248 | QETH_DBF_MISC_LEN); | ||
8249 | qeth_dbf_data = debug_register(QETH_DBF_DATA_NAME, | ||
8250 | QETH_DBF_DATA_PAGES, | ||
8251 | QETH_DBF_DATA_NR_AREAS, | ||
8252 | QETH_DBF_DATA_LEN); | ||
8253 | qeth_dbf_control = debug_register(QETH_DBF_CONTROL_NAME, | ||
8254 | QETH_DBF_CONTROL_PAGES, | ||
8255 | QETH_DBF_CONTROL_NR_AREAS, | ||
8256 | QETH_DBF_CONTROL_LEN); | ||
8257 | qeth_dbf_sense = debug_register(QETH_DBF_SENSE_NAME, | ||
8258 | QETH_DBF_SENSE_PAGES, | ||
8259 | QETH_DBF_SENSE_NR_AREAS, | ||
8260 | QETH_DBF_SENSE_LEN); | ||
8261 | qeth_dbf_qerr = debug_register(QETH_DBF_QERR_NAME, | ||
8262 | QETH_DBF_QERR_PAGES, | ||
8263 | QETH_DBF_QERR_NR_AREAS, | ||
8264 | QETH_DBF_QERR_LEN); | ||
8265 | qeth_dbf_trace = debug_register(QETH_DBF_TRACE_NAME, | ||
8266 | QETH_DBF_TRACE_PAGES, | ||
8267 | QETH_DBF_TRACE_NR_AREAS, | ||
8268 | QETH_DBF_TRACE_LEN); | ||
8269 | |||
8270 | if ((qeth_dbf_setup == NULL) || (qeth_dbf_misc == NULL) || | ||
8271 | (qeth_dbf_data == NULL) || (qeth_dbf_control == NULL) || | ||
8272 | (qeth_dbf_sense == NULL) || (qeth_dbf_qerr == NULL) || | ||
8273 | (qeth_dbf_trace == NULL)) { | ||
8274 | qeth_unregister_dbf_views(); | ||
8275 | return -ENOMEM; | ||
8276 | } | ||
8277 | debug_register_view(qeth_dbf_setup, &debug_hex_ascii_view); | ||
8278 | debug_set_level(qeth_dbf_setup, QETH_DBF_SETUP_LEVEL); | ||
8279 | |||
8280 | debug_register_view(qeth_dbf_misc, &debug_hex_ascii_view); | ||
8281 | debug_set_level(qeth_dbf_misc, QETH_DBF_MISC_LEVEL); | ||
8282 | |||
8283 | debug_register_view(qeth_dbf_data, &debug_hex_ascii_view); | ||
8284 | debug_set_level(qeth_dbf_data, QETH_DBF_DATA_LEVEL); | ||
8285 | |||
8286 | debug_register_view(qeth_dbf_control, &debug_hex_ascii_view); | ||
8287 | debug_set_level(qeth_dbf_control, QETH_DBF_CONTROL_LEVEL); | ||
8288 | |||
8289 | debug_register_view(qeth_dbf_sense, &debug_hex_ascii_view); | ||
8290 | debug_set_level(qeth_dbf_sense, QETH_DBF_SENSE_LEVEL); | ||
8291 | |||
8292 | debug_register_view(qeth_dbf_qerr, &debug_hex_ascii_view); | ||
8293 | debug_set_level(qeth_dbf_qerr, QETH_DBF_QERR_LEVEL); | ||
8294 | |||
8295 | debug_register_view(qeth_dbf_trace, &debug_hex_ascii_view); | ||
8296 | debug_set_level(qeth_dbf_trace, QETH_DBF_TRACE_LEVEL); | ||
8297 | |||
8298 | return 0; | ||
8299 | } | ||
8300 | |||
8301 | #ifdef CONFIG_QETH_IPV6 | ||
8302 | extern struct neigh_table arp_tbl; | ||
8303 | static struct neigh_ops *arp_direct_ops; | ||
8304 | static int (*qeth_old_arp_constructor) (struct neighbour *); | ||
8305 | |||
8306 | static struct neigh_ops arp_direct_ops_template = { | ||
8307 | .family = AF_INET, | ||
8308 | .solicit = NULL, | ||
8309 | .error_report = NULL, | ||
8310 | .output = dev_queue_xmit, | ||
8311 | .connected_output = dev_queue_xmit, | ||
8312 | .hh_output = dev_queue_xmit, | ||
8313 | .queue_xmit = dev_queue_xmit | ||
8314 | }; | ||
8315 | |||
8316 | static int | ||
8317 | qeth_arp_constructor(struct neighbour *neigh) | ||
8318 | { | ||
8319 | struct net_device *dev = neigh->dev; | ||
8320 | struct in_device *in_dev; | ||
8321 | struct neigh_parms *parms; | ||
8322 | struct qeth_card *card; | ||
8323 | |||
8324 | card = qeth_get_card_from_dev(dev); | ||
8325 | if (card == NULL) | ||
8326 | goto out; | ||
8327 | if((card->options.layer2) || | ||
8328 | (card->dev->header_ops == &qeth_fake_ops)) | ||
8329 | goto out; | ||
8330 | |||
8331 | rcu_read_lock(); | ||
8332 | in_dev = __in_dev_get_rcu(dev); | ||
8333 | if (in_dev == NULL) { | ||
8334 | rcu_read_unlock(); | ||
8335 | return -EINVAL; | ||
8336 | } | ||
8337 | |||
8338 | parms = in_dev->arp_parms; | ||
8339 | __neigh_parms_put(neigh->parms); | ||
8340 | neigh->parms = neigh_parms_clone(parms); | ||
8341 | rcu_read_unlock(); | ||
8342 | |||
8343 | neigh->type = inet_addr_type(&init_net, *(__be32 *) neigh->primary_key); | ||
8344 | neigh->nud_state = NUD_NOARP; | ||
8345 | neigh->ops = arp_direct_ops; | ||
8346 | neigh->output = neigh->ops->queue_xmit; | ||
8347 | return 0; | ||
8348 | out: | ||
8349 | return qeth_old_arp_constructor(neigh); | ||
8350 | } | ||
8351 | #endif /*CONFIG_QETH_IPV6*/ | ||
8352 | |||
8353 | /* | ||
8354 | * IP address takeover related functions | ||
8355 | */ | ||
8356 | static void | ||
8357 | qeth_clear_ipato_list(struct qeth_card *card) | ||
8358 | { | ||
8359 | struct qeth_ipato_entry *ipatoe, *tmp; | ||
8360 | unsigned long flags; | ||
8361 | |||
8362 | spin_lock_irqsave(&card->ip_lock, flags); | ||
8363 | list_for_each_entry_safe(ipatoe, tmp, &card->ipato.entries, entry) { | ||
8364 | list_del(&ipatoe->entry); | ||
8365 | kfree(ipatoe); | ||
8366 | } | ||
8367 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
8368 | } | ||
8369 | |||
8370 | int | ||
8371 | qeth_add_ipato_entry(struct qeth_card *card, struct qeth_ipato_entry *new) | ||
8372 | { | ||
8373 | struct qeth_ipato_entry *ipatoe; | ||
8374 | unsigned long flags; | ||
8375 | int rc = 0; | ||
8376 | |||
8377 | QETH_DBF_TEXT(trace, 2, "addipato"); | ||
8378 | spin_lock_irqsave(&card->ip_lock, flags); | ||
8379 | list_for_each_entry(ipatoe, &card->ipato.entries, entry){ | ||
8380 | if (ipatoe->proto != new->proto) | ||
8381 | continue; | ||
8382 | if (!memcmp(ipatoe->addr, new->addr, | ||
8383 | (ipatoe->proto == QETH_PROT_IPV4)? 4:16) && | ||
8384 | (ipatoe->mask_bits == new->mask_bits)){ | ||
8385 | PRINT_WARN("ipato entry already exists!\n"); | ||
8386 | rc = -EEXIST; | ||
8387 | break; | ||
8388 | } | ||
8389 | } | ||
8390 | if (!rc) { | ||
8391 | list_add_tail(&new->entry, &card->ipato.entries); | ||
8392 | } | ||
8393 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
8394 | return rc; | ||
8395 | } | ||
8396 | |||
8397 | void | ||
8398 | qeth_del_ipato_entry(struct qeth_card *card, enum qeth_prot_versions proto, | ||
8399 | u8 *addr, int mask_bits) | ||
8400 | { | ||
8401 | struct qeth_ipato_entry *ipatoe, *tmp; | ||
8402 | unsigned long flags; | ||
8403 | |||
8404 | QETH_DBF_TEXT(trace, 2, "delipato"); | ||
8405 | spin_lock_irqsave(&card->ip_lock, flags); | ||
8406 | list_for_each_entry_safe(ipatoe, tmp, &card->ipato.entries, entry){ | ||
8407 | if (ipatoe->proto != proto) | ||
8408 | continue; | ||
8409 | if (!memcmp(ipatoe->addr, addr, | ||
8410 | (proto == QETH_PROT_IPV4)? 4:16) && | ||
8411 | (ipatoe->mask_bits == mask_bits)){ | ||
8412 | list_del(&ipatoe->entry); | ||
8413 | kfree(ipatoe); | ||
8414 | } | ||
8415 | } | ||
8416 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
8417 | } | ||
8418 | |||
8419 | static void | ||
8420 | qeth_convert_addr_to_bits(u8 *addr, u8 *bits, int len) | ||
8421 | { | ||
8422 | int i, j; | ||
8423 | u8 octet; | ||
8424 | |||
8425 | for (i = 0; i < len; ++i){ | ||
8426 | octet = addr[i]; | ||
8427 | for (j = 7; j >= 0; --j){ | ||
8428 | bits[i*8 + j] = octet & 1; | ||
8429 | octet >>= 1; | ||
8430 | } | ||
8431 | } | ||
8432 | } | ||
8433 | |||
8434 | static int | ||
8435 | qeth_is_addr_covered_by_ipato(struct qeth_card *card, struct qeth_ipaddr *addr) | ||
8436 | { | ||
8437 | struct qeth_ipato_entry *ipatoe; | ||
8438 | u8 addr_bits[128] = {0, }; | ||
8439 | u8 ipatoe_bits[128] = {0, }; | ||
8440 | int rc = 0; | ||
8441 | |||
8442 | if (!card->ipato.enabled) | ||
8443 | return 0; | ||
8444 | |||
8445 | qeth_convert_addr_to_bits((u8 *) &addr->u, addr_bits, | ||
8446 | (addr->proto == QETH_PROT_IPV4)? 4:16); | ||
8447 | list_for_each_entry(ipatoe, &card->ipato.entries, entry){ | ||
8448 | if (addr->proto != ipatoe->proto) | ||
8449 | continue; | ||
8450 | qeth_convert_addr_to_bits(ipatoe->addr, ipatoe_bits, | ||
8451 | (ipatoe->proto==QETH_PROT_IPV4) ? | ||
8452 | 4:16); | ||
8453 | if (addr->proto == QETH_PROT_IPV4) | ||
8454 | rc = !memcmp(addr_bits, ipatoe_bits, | ||
8455 | min(32, ipatoe->mask_bits)); | ||
8456 | else | ||
8457 | rc = !memcmp(addr_bits, ipatoe_bits, | ||
8458 | min(128, ipatoe->mask_bits)); | ||
8459 | if (rc) | ||
8460 | break; | ||
8461 | } | ||
8462 | /* invert? */ | ||
8463 | if ((addr->proto == QETH_PROT_IPV4) && card->ipato.invert4) | ||
8464 | rc = !rc; | ||
8465 | else if ((addr->proto == QETH_PROT_IPV6) && card->ipato.invert6) | ||
8466 | rc = !rc; | ||
8467 | |||
8468 | return rc; | ||
8469 | } | ||
8470 | |||
8471 | /* | ||
8472 | * VIPA related functions | ||
8473 | */ | ||
8474 | int | ||
8475 | qeth_add_vipa(struct qeth_card *card, enum qeth_prot_versions proto, | ||
8476 | const u8 *addr) | ||
8477 | { | ||
8478 | struct qeth_ipaddr *ipaddr; | ||
8479 | unsigned long flags; | ||
8480 | int rc = 0; | ||
8481 | |||
8482 | ipaddr = qeth_get_addr_buffer(proto); | ||
8483 | if (ipaddr){ | ||
8484 | if (proto == QETH_PROT_IPV4){ | ||
8485 | QETH_DBF_TEXT(trace, 2, "addvipa4"); | ||
8486 | memcpy(&ipaddr->u.a4.addr, addr, 4); | ||
8487 | ipaddr->u.a4.mask = 0; | ||
8488 | #ifdef CONFIG_QETH_IPV6 | ||
8489 | } else if (proto == QETH_PROT_IPV6){ | ||
8490 | QETH_DBF_TEXT(trace, 2, "addvipa6"); | ||
8491 | memcpy(&ipaddr->u.a6.addr, addr, 16); | ||
8492 | ipaddr->u.a6.pfxlen = 0; | ||
8493 | #endif | ||
8494 | } | ||
8495 | ipaddr->type = QETH_IP_TYPE_VIPA; | ||
8496 | ipaddr->set_flags = QETH_IPA_SETIP_VIPA_FLAG; | ||
8497 | ipaddr->del_flags = QETH_IPA_DELIP_VIPA_FLAG; | ||
8498 | } else | ||
8499 | return -ENOMEM; | ||
8500 | spin_lock_irqsave(&card->ip_lock, flags); | ||
8501 | if (__qeth_address_exists_in_list(&card->ip_list, ipaddr, 0) || | ||
8502 | __qeth_address_exists_in_list(card->ip_tbd_list, ipaddr, 0)) | ||
8503 | rc = -EEXIST; | ||
8504 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
8505 | if (rc){ | ||
8506 | PRINT_WARN("Cannot add VIPA. Address already exists!\n"); | ||
8507 | return rc; | ||
8508 | } | ||
8509 | if (!qeth_add_ip(card, ipaddr)) | ||
8510 | kfree(ipaddr); | ||
8511 | qeth_set_ip_addr_list(card); | ||
8512 | return rc; | ||
8513 | } | ||
8514 | |||
8515 | void | ||
8516 | qeth_del_vipa(struct qeth_card *card, enum qeth_prot_versions proto, | ||
8517 | const u8 *addr) | ||
8518 | { | ||
8519 | struct qeth_ipaddr *ipaddr; | ||
8520 | |||
8521 | ipaddr = qeth_get_addr_buffer(proto); | ||
8522 | if (ipaddr){ | ||
8523 | if (proto == QETH_PROT_IPV4){ | ||
8524 | QETH_DBF_TEXT(trace, 2, "delvipa4"); | ||
8525 | memcpy(&ipaddr->u.a4.addr, addr, 4); | ||
8526 | ipaddr->u.a4.mask = 0; | ||
8527 | #ifdef CONFIG_QETH_IPV6 | ||
8528 | } else if (proto == QETH_PROT_IPV6){ | ||
8529 | QETH_DBF_TEXT(trace, 2, "delvipa6"); | ||
8530 | memcpy(&ipaddr->u.a6.addr, addr, 16); | ||
8531 | ipaddr->u.a6.pfxlen = 0; | ||
8532 | #endif | ||
8533 | } | ||
8534 | ipaddr->type = QETH_IP_TYPE_VIPA; | ||
8535 | } else | ||
8536 | return; | ||
8537 | if (!qeth_delete_ip(card, ipaddr)) | ||
8538 | kfree(ipaddr); | ||
8539 | qeth_set_ip_addr_list(card); | ||
8540 | } | ||
8541 | |||
8542 | /* | ||
8543 | * proxy ARP related functions | ||
8544 | */ | ||
8545 | int | ||
8546 | qeth_add_rxip(struct qeth_card *card, enum qeth_prot_versions proto, | ||
8547 | const u8 *addr) | ||
8548 | { | ||
8549 | struct qeth_ipaddr *ipaddr; | ||
8550 | unsigned long flags; | ||
8551 | int rc = 0; | ||
8552 | |||
8553 | ipaddr = qeth_get_addr_buffer(proto); | ||
8554 | if (ipaddr){ | ||
8555 | if (proto == QETH_PROT_IPV4){ | ||
8556 | QETH_DBF_TEXT(trace, 2, "addrxip4"); | ||
8557 | memcpy(&ipaddr->u.a4.addr, addr, 4); | ||
8558 | ipaddr->u.a4.mask = 0; | ||
8559 | #ifdef CONFIG_QETH_IPV6 | ||
8560 | } else if (proto == QETH_PROT_IPV6){ | ||
8561 | QETH_DBF_TEXT(trace, 2, "addrxip6"); | ||
8562 | memcpy(&ipaddr->u.a6.addr, addr, 16); | ||
8563 | ipaddr->u.a6.pfxlen = 0; | ||
8564 | #endif | ||
8565 | } | ||
8566 | ipaddr->type = QETH_IP_TYPE_RXIP; | ||
8567 | ipaddr->set_flags = QETH_IPA_SETIP_TAKEOVER_FLAG; | ||
8568 | ipaddr->del_flags = 0; | ||
8569 | } else | ||
8570 | return -ENOMEM; | ||
8571 | spin_lock_irqsave(&card->ip_lock, flags); | ||
8572 | if (__qeth_address_exists_in_list(&card->ip_list, ipaddr, 0) || | ||
8573 | __qeth_address_exists_in_list(card->ip_tbd_list, ipaddr, 0)) | ||
8574 | rc = -EEXIST; | ||
8575 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
8576 | if (rc){ | ||
8577 | PRINT_WARN("Cannot add RXIP. Address already exists!\n"); | ||
8578 | return rc; | ||
8579 | } | ||
8580 | if (!qeth_add_ip(card, ipaddr)) | ||
8581 | kfree(ipaddr); | ||
8582 | qeth_set_ip_addr_list(card); | ||
8583 | return 0; | ||
8584 | } | ||
8585 | |||
8586 | void | ||
8587 | qeth_del_rxip(struct qeth_card *card, enum qeth_prot_versions proto, | ||
8588 | const u8 *addr) | ||
8589 | { | ||
8590 | struct qeth_ipaddr *ipaddr; | ||
8591 | |||
8592 | ipaddr = qeth_get_addr_buffer(proto); | ||
8593 | if (ipaddr){ | ||
8594 | if (proto == QETH_PROT_IPV4){ | ||
8595 | QETH_DBF_TEXT(trace, 2, "addrxip4"); | ||
8596 | memcpy(&ipaddr->u.a4.addr, addr, 4); | ||
8597 | ipaddr->u.a4.mask = 0; | ||
8598 | #ifdef CONFIG_QETH_IPV6 | ||
8599 | } else if (proto == QETH_PROT_IPV6){ | ||
8600 | QETH_DBF_TEXT(trace, 2, "addrxip6"); | ||
8601 | memcpy(&ipaddr->u.a6.addr, addr, 16); | ||
8602 | ipaddr->u.a6.pfxlen = 0; | ||
8603 | #endif | ||
8604 | } | ||
8605 | ipaddr->type = QETH_IP_TYPE_RXIP; | ||
8606 | } else | ||
8607 | return; | ||
8608 | if (!qeth_delete_ip(card, ipaddr)) | ||
8609 | kfree(ipaddr); | ||
8610 | qeth_set_ip_addr_list(card); | ||
8611 | } | ||
8612 | |||
8613 | /** | ||
8614 | * IP event handler | ||
8615 | */ | ||
8616 | static int | ||
8617 | qeth_ip_event(struct notifier_block *this, | ||
8618 | unsigned long event,void *ptr) | ||
8619 | { | ||
8620 | struct in_ifaddr *ifa = (struct in_ifaddr *)ptr; | ||
8621 | struct net_device *dev =(struct net_device *) ifa->ifa_dev->dev; | ||
8622 | struct qeth_ipaddr *addr; | ||
8623 | struct qeth_card *card; | ||
8624 | |||
8625 | QETH_DBF_TEXT(trace,3,"ipevent"); | ||
8626 | card = qeth_get_card_from_dev(dev); | ||
8627 | if (!card) | ||
8628 | return NOTIFY_DONE; | ||
8629 | if (card->options.layer2) | ||
8630 | return NOTIFY_DONE; | ||
8631 | |||
8632 | addr = qeth_get_addr_buffer(QETH_PROT_IPV4); | ||
8633 | if (addr != NULL) { | ||
8634 | addr->u.a4.addr = ifa->ifa_address; | ||
8635 | addr->u.a4.mask = ifa->ifa_mask; | ||
8636 | addr->type = QETH_IP_TYPE_NORMAL; | ||
8637 | } else | ||
8638 | goto out; | ||
8639 | |||
8640 | switch(event) { | ||
8641 | case NETDEV_UP: | ||
8642 | if (!qeth_add_ip(card, addr)) | ||
8643 | kfree(addr); | ||
8644 | break; | ||
8645 | case NETDEV_DOWN: | ||
8646 | if (!qeth_delete_ip(card, addr)) | ||
8647 | kfree(addr); | ||
8648 | break; | ||
8649 | default: | ||
8650 | break; | ||
8651 | } | ||
8652 | qeth_set_ip_addr_list(card); | ||
8653 | out: | ||
8654 | return NOTIFY_DONE; | ||
8655 | } | ||
8656 | |||
8657 | static struct notifier_block qeth_ip_notifier = { | ||
8658 | qeth_ip_event, | ||
8659 | NULL, | ||
8660 | }; | ||
8661 | |||
8662 | #ifdef CONFIG_QETH_IPV6 | ||
8663 | /** | ||
8664 | * IPv6 event handler | ||
8665 | */ | ||
8666 | static int | ||
8667 | qeth_ip6_event(struct notifier_block *this, | ||
8668 | unsigned long event,void *ptr) | ||
8669 | { | ||
8670 | |||
8671 | struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr; | ||
8672 | struct net_device *dev = (struct net_device *)ifa->idev->dev; | ||
8673 | struct qeth_ipaddr *addr; | ||
8674 | struct qeth_card *card; | ||
8675 | |||
8676 | QETH_DBF_TEXT(trace,3,"ip6event"); | ||
8677 | |||
8678 | card = qeth_get_card_from_dev(dev); | ||
8679 | if (!card) | ||
8680 | return NOTIFY_DONE; | ||
8681 | if (!qeth_is_supported(card, IPA_IPV6)) | ||
8682 | return NOTIFY_DONE; | ||
8683 | |||
8684 | addr = qeth_get_addr_buffer(QETH_PROT_IPV6); | ||
8685 | if (addr != NULL) { | ||
8686 | memcpy(&addr->u.a6.addr, &ifa->addr, sizeof(struct in6_addr)); | ||
8687 | addr->u.a6.pfxlen = ifa->prefix_len; | ||
8688 | addr->type = QETH_IP_TYPE_NORMAL; | ||
8689 | } else | ||
8690 | goto out; | ||
8691 | |||
8692 | switch(event) { | ||
8693 | case NETDEV_UP: | ||
8694 | if (!qeth_add_ip(card, addr)) | ||
8695 | kfree(addr); | ||
8696 | break; | ||
8697 | case NETDEV_DOWN: | ||
8698 | if (!qeth_delete_ip(card, addr)) | ||
8699 | kfree(addr); | ||
8700 | break; | ||
8701 | default: | ||
8702 | break; | ||
8703 | } | ||
8704 | qeth_set_ip_addr_list(card); | ||
8705 | out: | ||
8706 | return NOTIFY_DONE; | ||
8707 | } | ||
8708 | |||
8709 | static struct notifier_block qeth_ip6_notifier = { | ||
8710 | qeth_ip6_event, | ||
8711 | NULL, | ||
8712 | }; | ||
8713 | #endif | ||
8714 | |||
8715 | static int | ||
8716 | __qeth_reboot_event_card(struct device *dev, void *data) | ||
8717 | { | ||
8718 | struct qeth_card *card; | ||
8719 | |||
8720 | card = (struct qeth_card *) dev->driver_data; | ||
8721 | qeth_clear_ip_list(card, 0, 0); | ||
8722 | qeth_qdio_clear_card(card, 0); | ||
8723 | qeth_clear_qdio_buffers(card); | ||
8724 | return 0; | ||
8725 | } | ||
8726 | |||
8727 | static int | ||
8728 | qeth_reboot_event(struct notifier_block *this, unsigned long event, void *ptr) | ||
8729 | { | ||
8730 | int ret; | ||
8731 | |||
8732 | ret = driver_for_each_device(&qeth_ccwgroup_driver.driver, NULL, NULL, | ||
8733 | __qeth_reboot_event_card); | ||
8734 | return ret ? NOTIFY_BAD : NOTIFY_DONE; | ||
8735 | } | ||
8736 | |||
8737 | |||
8738 | static struct notifier_block qeth_reboot_notifier = { | ||
8739 | qeth_reboot_event, | ||
8740 | NULL, | ||
8741 | }; | ||
8742 | |||
8743 | static int | ||
8744 | qeth_register_notifiers(void) | ||
8745 | { | ||
8746 | int r; | ||
8747 | |||
8748 | QETH_DBF_TEXT(trace,5,"regnotif"); | ||
8749 | if ((r = register_reboot_notifier(&qeth_reboot_notifier))) | ||
8750 | return r; | ||
8751 | if ((r = register_inetaddr_notifier(&qeth_ip_notifier))) | ||
8752 | goto out_reboot; | ||
8753 | #ifdef CONFIG_QETH_IPV6 | ||
8754 | if ((r = register_inet6addr_notifier(&qeth_ip6_notifier))) | ||
8755 | goto out_ipv4; | ||
8756 | #endif | ||
8757 | return 0; | ||
8758 | |||
8759 | #ifdef CONFIG_QETH_IPV6 | ||
8760 | out_ipv4: | ||
8761 | unregister_inetaddr_notifier(&qeth_ip_notifier); | ||
8762 | #endif | ||
8763 | out_reboot: | ||
8764 | unregister_reboot_notifier(&qeth_reboot_notifier); | ||
8765 | return r; | ||
8766 | } | ||
8767 | |||
8768 | /** | ||
8769 | * unregister all event notifiers | ||
8770 | */ | ||
8771 | static void | ||
8772 | qeth_unregister_notifiers(void) | ||
8773 | { | ||
8774 | |||
8775 | QETH_DBF_TEXT(trace,5,"unregnot"); | ||
8776 | BUG_ON(unregister_reboot_notifier(&qeth_reboot_notifier)); | ||
8777 | BUG_ON(unregister_inetaddr_notifier(&qeth_ip_notifier)); | ||
8778 | #ifdef CONFIG_QETH_IPV6 | ||
8779 | BUG_ON(unregister_inet6addr_notifier(&qeth_ip6_notifier)); | ||
8780 | #endif /* QETH_IPV6 */ | ||
8781 | |||
8782 | } | ||
8783 | |||
8784 | #ifdef CONFIG_QETH_IPV6 | ||
8785 | static int | ||
8786 | qeth_ipv6_init(void) | ||
8787 | { | ||
8788 | qeth_old_arp_constructor = arp_tbl.constructor; | ||
8789 | write_lock_bh(&arp_tbl.lock); | ||
8790 | arp_tbl.constructor = qeth_arp_constructor; | ||
8791 | write_unlock_bh(&arp_tbl.lock); | ||
8792 | |||
8793 | arp_direct_ops = (struct neigh_ops*) | ||
8794 | kmalloc(sizeof(struct neigh_ops), GFP_KERNEL); | ||
8795 | if (!arp_direct_ops) | ||
8796 | return -ENOMEM; | ||
8797 | |||
8798 | memcpy(arp_direct_ops, &arp_direct_ops_template, | ||
8799 | sizeof(struct neigh_ops)); | ||
8800 | |||
8801 | return 0; | ||
8802 | } | ||
8803 | |||
8804 | static void | ||
8805 | qeth_ipv6_uninit(void) | ||
8806 | { | ||
8807 | write_lock_bh(&arp_tbl.lock); | ||
8808 | arp_tbl.constructor = qeth_old_arp_constructor; | ||
8809 | write_unlock_bh(&arp_tbl.lock); | ||
8810 | kfree(arp_direct_ops); | ||
8811 | } | ||
8812 | #endif /* CONFIG_QETH_IPV6 */ | ||
8813 | |||
8814 | static void | ||
8815 | qeth_sysfs_unregister(void) | ||
8816 | { | ||
8817 | s390_root_dev_unregister(qeth_root_dev); | ||
8818 | qeth_remove_driver_attributes(); | ||
8819 | ccw_driver_unregister(&qeth_ccw_driver); | ||
8820 | ccwgroup_driver_unregister(&qeth_ccwgroup_driver); | ||
8821 | } | ||
8822 | |||
8823 | /** | ||
8824 | * register qeth at sysfs | ||
8825 | */ | ||
8826 | static int | ||
8827 | qeth_sysfs_register(void) | ||
8828 | { | ||
8829 | int rc; | ||
8830 | |||
8831 | rc = ccwgroup_driver_register(&qeth_ccwgroup_driver); | ||
8832 | if (rc) | ||
8833 | goto out; | ||
8834 | |||
8835 | rc = ccw_driver_register(&qeth_ccw_driver); | ||
8836 | if (rc) | ||
8837 | goto out_ccw_driver; | ||
8838 | |||
8839 | rc = qeth_create_driver_attributes(); | ||
8840 | if (rc) | ||
8841 | goto out_qeth_attr; | ||
8842 | |||
8843 | qeth_root_dev = s390_root_dev_register("qeth"); | ||
8844 | rc = IS_ERR(qeth_root_dev) ? PTR_ERR(qeth_root_dev) : 0; | ||
8845 | if (!rc) | ||
8846 | goto out; | ||
8847 | |||
8848 | qeth_remove_driver_attributes(); | ||
8849 | out_qeth_attr: | ||
8850 | ccw_driver_unregister(&qeth_ccw_driver); | ||
8851 | out_ccw_driver: | ||
8852 | ccwgroup_driver_unregister(&qeth_ccwgroup_driver); | ||
8853 | out: | ||
8854 | return rc; | ||
8855 | } | ||
8856 | |||
8857 | /*** | ||
8858 | * init function | ||
8859 | */ | ||
8860 | static int __init | ||
8861 | qeth_init(void) | ||
8862 | { | ||
8863 | int rc; | ||
8864 | |||
8865 | PRINT_INFO("loading %s\n", version); | ||
8866 | |||
8867 | INIT_LIST_HEAD(&qeth_card_list.list); | ||
8868 | INIT_LIST_HEAD(&qeth_notify_list); | ||
8869 | spin_lock_init(&qeth_notify_lock); | ||
8870 | rwlock_init(&qeth_card_list.rwlock); | ||
8871 | |||
8872 | rc = qeth_register_dbf_views(); | ||
8873 | if (rc) | ||
8874 | goto out_err; | ||
8875 | |||
8876 | rc = qeth_sysfs_register(); | ||
8877 | if (rc) | ||
8878 | goto out_dbf; | ||
8879 | |||
8880 | #ifdef CONFIG_QETH_IPV6 | ||
8881 | rc = qeth_ipv6_init(); | ||
8882 | if (rc) { | ||
8883 | PRINT_ERR("Out of memory during ipv6 init code = %d\n", rc); | ||
8884 | goto out_sysfs; | ||
8885 | } | ||
8886 | #endif /* QETH_IPV6 */ | ||
8887 | rc = qeth_register_notifiers(); | ||
8888 | if (rc) | ||
8889 | goto out_ipv6; | ||
8890 | rc = qeth_create_procfs_entries(); | ||
8891 | if (rc) | ||
8892 | goto out_notifiers; | ||
8893 | |||
8894 | return rc; | ||
8895 | |||
8896 | out_notifiers: | ||
8897 | qeth_unregister_notifiers(); | ||
8898 | out_ipv6: | ||
8899 | #ifdef CONFIG_QETH_IPV6 | ||
8900 | qeth_ipv6_uninit(); | ||
8901 | out_sysfs: | ||
8902 | #endif /* QETH_IPV6 */ | ||
8903 | qeth_sysfs_unregister(); | ||
8904 | out_dbf: | ||
8905 | qeth_unregister_dbf_views(); | ||
8906 | out_err: | ||
8907 | PRINT_ERR("Initialization failed with code %d\n", rc); | ||
8908 | return rc; | ||
8909 | } | ||
8910 | |||
8911 | static void | ||
8912 | __exit qeth_exit(void) | ||
8913 | { | ||
8914 | struct qeth_card *card, *tmp; | ||
8915 | unsigned long flags; | ||
8916 | |||
8917 | QETH_DBF_TEXT(trace,1, "cleanup."); | ||
8918 | |||
8919 | /* | ||
8920 | * Weed would not need to clean up our devices here, because the | ||
8921 | * common device layer calls qeth_remove_device for each device | ||
8922 | * as soon as we unregister our driver (done in qeth_sysfs_unregister). | ||
8923 | * But we do cleanup here so we can do a "soft" shutdown of our cards. | ||
8924 | * qeth_remove_device called by the common device layer would otherwise | ||
8925 | * do a "hard" shutdown (card->use_hard_stop is set to one in | ||
8926 | * qeth_remove_device). | ||
8927 | */ | ||
8928 | again: | ||
8929 | read_lock_irqsave(&qeth_card_list.rwlock, flags); | ||
8930 | list_for_each_entry_safe(card, tmp, &qeth_card_list.list, list){ | ||
8931 | read_unlock_irqrestore(&qeth_card_list.rwlock, flags); | ||
8932 | qeth_set_offline(card->gdev); | ||
8933 | qeth_remove_device(card->gdev); | ||
8934 | goto again; | ||
8935 | } | ||
8936 | read_unlock_irqrestore(&qeth_card_list.rwlock, flags); | ||
8937 | #ifdef CONFIG_QETH_IPV6 | ||
8938 | qeth_ipv6_uninit(); | ||
8939 | #endif | ||
8940 | qeth_unregister_notifiers(); | ||
8941 | qeth_remove_procfs_entries(); | ||
8942 | qeth_sysfs_unregister(); | ||
8943 | qeth_unregister_dbf_views(); | ||
8944 | printk("qeth: removed\n"); | ||
8945 | } | ||
8946 | |||
8947 | EXPORT_SYMBOL(qeth_osn_register); | ||
8948 | EXPORT_SYMBOL(qeth_osn_deregister); | ||
8949 | EXPORT_SYMBOL(qeth_osn_assist); | ||
8950 | module_init(qeth_init); | ||
8951 | module_exit(qeth_exit); | ||
8952 | MODULE_AUTHOR("Frank Pavlic <fpavlic@de.ibm.com>"); | ||
8953 | MODULE_DESCRIPTION("Linux on zSeries OSA Express and HiperSockets support\n" \ | ||
8954 | "Copyright 2000,2003 IBM Corporation\n"); | ||
8955 | |||
8956 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/s390/net/qeth_mpc.c b/drivers/s390/net/qeth_mpc.c deleted file mode 100644 index f29a4bc4f6f2..000000000000 --- a/drivers/s390/net/qeth_mpc.c +++ /dev/null | |||
@@ -1,269 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/s390/net/qeth_mpc.c | ||
3 | * | ||
4 | * Linux on zSeries OSA Express and HiperSockets support | ||
5 | * | ||
6 | * Copyright 2000,2003 IBM Corporation | ||
7 | * Author(s): Frank Pavlic <fpavlic@de.ibm.com> | ||
8 | * Thomas Spatzier <tspat@de.ibm.com> | ||
9 | * | ||
10 | */ | ||
11 | #include <asm/cio.h> | ||
12 | #include "qeth_mpc.h" | ||
13 | |||
14 | unsigned char IDX_ACTIVATE_READ[]={ | ||
15 | 0x00,0x00,0x80,0x00, 0x00,0x00,0x00,0x00, | ||
16 | 0x19,0x01,0x01,0x80, 0x00,0x00,0x00,0x00, | ||
17 | 0x00,0x00,0x00,0x00, 0x00,0x00,0xc8,0xc1, | ||
18 | 0xd3,0xd3,0xd6,0xd3, 0xc5,0x40,0x00,0x00, | ||
19 | 0x00,0x00 | ||
20 | }; | ||
21 | |||
22 | unsigned char IDX_ACTIVATE_WRITE[]={ | ||
23 | 0x00,0x00,0x80,0x00, 0x00,0x00,0x00,0x00, | ||
24 | 0x15,0x01,0x01,0x80, 0x00,0x00,0x00,0x00, | ||
25 | 0xff,0xff,0x00,0x00, 0x00,0x00,0xc8,0xc1, | ||
26 | 0xd3,0xd3,0xd6,0xd3, 0xc5,0x40,0x00,0x00, | ||
27 | 0x00,0x00 | ||
28 | }; | ||
29 | |||
30 | unsigned char CM_ENABLE[]={ | ||
31 | 0x00,0xe0,0x00,0x00, 0x00,0x00,0x00,0x01, | ||
32 | 0x00,0x00,0x00,0x14, 0x00,0x00,0x00,0x63, | ||
33 | 0x10,0x00,0x00,0x01, | ||
34 | 0x00,0x00,0x00,0x00, | ||
35 | 0x81,0x7e,0x00,0x01, 0x00,0x00,0x00,0x00, | ||
36 | 0x00,0x00,0x00,0x00, 0x00,0x24,0x00,0x23, | ||
37 | 0x00,0x00,0x23,0x05, 0x00,0x00,0x00,0x00, | ||
38 | 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, | ||
39 | 0x01,0x00,0x00,0x23, 0x00,0x00,0x00,0x40, | ||
40 | 0x00,0x0c,0x41,0x02, 0x00,0x17,0x00,0x00, | ||
41 | 0x00,0x00,0x00,0x00, | ||
42 | 0x00,0x0b,0x04,0x01, | ||
43 | 0x7e,0x04,0x05,0x00, 0x01,0x01,0x0f, | ||
44 | 0x00, | ||
45 | 0x0c,0x04,0x02,0xff, 0xff,0xff,0xff,0xff, | ||
46 | 0xff,0xff,0xff | ||
47 | }; | ||
48 | |||
49 | unsigned char CM_SETUP[]={ | ||
50 | 0x00,0xe0,0x00,0x00, 0x00,0x00,0x00,0x02, | ||
51 | 0x00,0x00,0x00,0x14, 0x00,0x00,0x00,0x64, | ||
52 | 0x10,0x00,0x00,0x01, | ||
53 | 0x00,0x00,0x00,0x00, | ||
54 | 0x81,0x7e,0x00,0x01, 0x00,0x00,0x00,0x00, | ||
55 | 0x00,0x00,0x00,0x00, 0x00,0x24,0x00,0x24, | ||
56 | 0x00,0x00,0x24,0x05, 0x00,0x00,0x00,0x00, | ||
57 | 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, | ||
58 | 0x01,0x00,0x00,0x24, 0x00,0x00,0x00,0x40, | ||
59 | 0x00,0x0c,0x41,0x04, 0x00,0x18,0x00,0x00, | ||
60 | 0x00,0x00,0x00,0x00, | ||
61 | 0x00,0x09,0x04,0x04, | ||
62 | 0x05,0x00,0x01,0x01, 0x11, | ||
63 | 0x00,0x09,0x04, | ||
64 | 0x05,0x05,0x00,0x00, 0x00,0x00, | ||
65 | 0x00,0x06, | ||
66 | 0x04,0x06,0xc8,0x00 | ||
67 | }; | ||
68 | |||
69 | unsigned char ULP_ENABLE[]={ | ||
70 | 0x00,0xe0,0x00,0x00, 0x00,0x00,0x00,0x03, | ||
71 | 0x00,0x00,0x00,0x14, 0x00,0x00,0x00,0x6b, | ||
72 | 0x10,0x00,0x00,0x01, | ||
73 | 0x00,0x00,0x00,0x00, | ||
74 | 0x41,0x7e,0x00,0x01, 0x00,0x00,0x00,0x01, | ||
75 | 0x00,0x00,0x00,0x00, 0x00,0x24,0x00,0x2b, | ||
76 | 0x00,0x00,0x2b,0x05, 0x20,0x01,0x00,0x00, | ||
77 | 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, | ||
78 | 0x01,0x00,0x00,0x2b, 0x00,0x00,0x00,0x40, | ||
79 | 0x00,0x0c,0x41,0x02, 0x00,0x1f,0x00,0x00, | ||
80 | 0x00,0x00,0x00,0x00, | ||
81 | 0x00,0x0b,0x04,0x01, | ||
82 | 0x03,0x04,0x05,0x00, 0x01,0x01,0x12, | ||
83 | 0x00, | ||
84 | 0x14,0x04,0x0a,0x00, 0x20,0x00,0x00,0xff, | ||
85 | 0xff,0x00,0x08,0xc8, 0xe8,0xc4,0xf1,0xc7, | ||
86 | 0xf1,0x00,0x00 | ||
87 | }; | ||
88 | |||
89 | unsigned char ULP_SETUP[]={ | ||
90 | 0x00,0xe0,0x00,0x00, 0x00,0x00,0x00,0x04, | ||
91 | 0x00,0x00,0x00,0x14, 0x00,0x00,0x00,0x6c, | ||
92 | 0x10,0x00,0x00,0x01, | ||
93 | 0x00,0x00,0x00,0x00, | ||
94 | 0x41,0x7e,0x00,0x01, 0x00,0x00,0x00,0x02, | ||
95 | 0x00,0x00,0x00,0x01, 0x00,0x24,0x00,0x2c, | ||
96 | 0x00,0x00,0x2c,0x05, 0x20,0x01,0x00,0x00, | ||
97 | 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, | ||
98 | 0x01,0x00,0x00,0x2c, 0x00,0x00,0x00,0x40, | ||
99 | 0x00,0x0c,0x41,0x04, 0x00,0x20,0x00,0x00, | ||
100 | 0x00,0x00,0x00,0x00, | ||
101 | 0x00,0x09,0x04,0x04, | ||
102 | 0x05,0x00,0x01,0x01, 0x14, | ||
103 | 0x00,0x09,0x04, | ||
104 | 0x05,0x05,0x30,0x01, 0x00,0x00, | ||
105 | 0x00,0x06, | ||
106 | 0x04,0x06,0x40,0x00, | ||
107 | 0x00,0x08,0x04,0x0b, | ||
108 | 0x00,0x00,0x00,0x00 | ||
109 | }; | ||
110 | |||
111 | unsigned char DM_ACT[]={ | ||
112 | 0x00,0xe0,0x00,0x00, 0x00,0x00,0x00,0x05, | ||
113 | 0x00,0x00,0x00,0x14, 0x00,0x00,0x00,0x55, | ||
114 | 0x10,0x00,0x00,0x01, | ||
115 | 0x00,0x00,0x00,0x00, | ||
116 | 0x41,0x7e,0x00,0x01, 0x00,0x00,0x00,0x03, | ||
117 | 0x00,0x00,0x00,0x02, 0x00,0x24,0x00,0x15, | ||
118 | 0x00,0x00,0x2c,0x05, 0x20,0x01,0x00,0x00, | ||
119 | 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, | ||
120 | 0x01,0x00,0x00,0x15, 0x00,0x00,0x00,0x40, | ||
121 | 0x00,0x0c,0x43,0x60, 0x00,0x09,0x00,0x00, | ||
122 | 0x00,0x00,0x00,0x00, | ||
123 | 0x00,0x09,0x04,0x04, | ||
124 | 0x05,0x40,0x01,0x01, 0x00 | ||
125 | }; | ||
126 | |||
127 | unsigned char IPA_PDU_HEADER[]={ | ||
128 | 0x00,0xe0,0x00,0x00, 0x77,0x77,0x77,0x77, | ||
129 | 0x00,0x00,0x00,0x14, 0x00,0x00, | ||
130 | (IPA_PDU_HEADER_SIZE+sizeof(struct qeth_ipa_cmd))/256, | ||
131 | (IPA_PDU_HEADER_SIZE+sizeof(struct qeth_ipa_cmd))%256, | ||
132 | 0x10,0x00,0x00,0x01, 0x00,0x00,0x00,0x00, | ||
133 | 0xc1,0x03,0x00,0x01, 0x00,0x00,0x00,0x00, | ||
134 | 0x00,0x00,0x00,0x00, 0x00,0x24, | ||
135 | sizeof(struct qeth_ipa_cmd)/256, | ||
136 | sizeof(struct qeth_ipa_cmd)%256, | ||
137 | 0x00, | ||
138 | sizeof(struct qeth_ipa_cmd)/256, | ||
139 | sizeof(struct qeth_ipa_cmd)%256, | ||
140 | 0x05, | ||
141 | 0x77,0x77,0x77,0x77, | ||
142 | 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, | ||
143 | 0x01,0x00, | ||
144 | sizeof(struct qeth_ipa_cmd)/256, | ||
145 | sizeof(struct qeth_ipa_cmd)%256, | ||
146 | 0x00,0x00,0x00,0x40, | ||
147 | }; | ||
148 | |||
149 | unsigned char WRITE_CCW[]={ | ||
150 | 0x01,CCW_FLAG_SLI,0,0, | ||
151 | 0,0,0,0 | ||
152 | }; | ||
153 | |||
154 | unsigned char READ_CCW[]={ | ||
155 | 0x02,CCW_FLAG_SLI,0,0, | ||
156 | 0,0,0,0 | ||
157 | }; | ||
158 | |||
159 | |||
160 | struct ipa_rc_msg { | ||
161 | enum qeth_ipa_return_codes rc; | ||
162 | char *msg; | ||
163 | }; | ||
164 | |||
165 | static struct ipa_rc_msg qeth_ipa_rc_msg[] = { | ||
166 | {IPA_RC_SUCCESS, "success"}, | ||
167 | {IPA_RC_NOTSUPP, "Command not supported"}, | ||
168 | {IPA_RC_IP_TABLE_FULL, "Add Addr IP Table Full - ipv6"}, | ||
169 | {IPA_RC_UNKNOWN_ERROR, "IPA command failed - reason unknown"}, | ||
170 | {IPA_RC_UNSUPPORTED_COMMAND, "Command not supported"}, | ||
171 | {IPA_RC_DUP_IPV6_REMOTE,"ipv6 address already registered remote"}, | ||
172 | {IPA_RC_DUP_IPV6_HOME, "ipv6 address already registered"}, | ||
173 | {IPA_RC_UNREGISTERED_ADDR, "Address not registered"}, | ||
174 | {IPA_RC_NO_ID_AVAILABLE, "No identifiers available"}, | ||
175 | {IPA_RC_ID_NOT_FOUND, "Identifier not found"}, | ||
176 | {IPA_RC_INVALID_IP_VERSION, "IP version incorrect"}, | ||
177 | {IPA_RC_LAN_FRAME_MISMATCH, "LAN and frame mismatch"}, | ||
178 | {IPA_RC_L2_UNSUPPORTED_CMD, "Unsupported layer 2 command"}, | ||
179 | {IPA_RC_L2_DUP_MAC, "Duplicate MAC address"}, | ||
180 | {IPA_RC_L2_ADDR_TABLE_FULL, "Layer2 address table full"}, | ||
181 | {IPA_RC_L2_DUP_LAYER3_MAC, "Duplicate with layer 3 MAC"}, | ||
182 | {IPA_RC_L2_GMAC_NOT_FOUND, "GMAC not found"}, | ||
183 | {IPA_RC_L2_MAC_NOT_FOUND, "L2 mac address not found"}, | ||
184 | {IPA_RC_L2_INVALID_VLAN_ID, "L2 invalid vlan id"}, | ||
185 | {IPA_RC_L2_DUP_VLAN_ID, "L2 duplicate vlan id"}, | ||
186 | {IPA_RC_L2_VLAN_ID_NOT_FOUND, "L2 vlan id not found"}, | ||
187 | {IPA_RC_DATA_MISMATCH, "Data field mismatch (v4/v6 mixed)"}, | ||
188 | {IPA_RC_INVALID_MTU_SIZE, "Invalid MTU size"}, | ||
189 | {IPA_RC_INVALID_LANTYPE, "Invalid LAN type"}, | ||
190 | {IPA_RC_INVALID_LANNUM, "Invalid LAN num"}, | ||
191 | {IPA_RC_DUPLICATE_IP_ADDRESS, "Address already registered"}, | ||
192 | {IPA_RC_IP_ADDR_TABLE_FULL, "IP address table full"}, | ||
193 | {IPA_RC_LAN_PORT_STATE_ERROR, "LAN port state error"}, | ||
194 | {IPA_RC_SETIP_NO_STARTLAN, "Setip no startlan received"}, | ||
195 | {IPA_RC_SETIP_ALREADY_RECEIVED, "Setip already received"}, | ||
196 | {IPA_RC_IP_ADDR_ALREADY_USED, "IP address already in use on LAN"}, | ||
197 | {IPA_RC_MULTICAST_FULL, "No task available, multicast full"}, | ||
198 | {IPA_RC_SETIP_INVALID_VERSION, "SETIP invalid IP version"}, | ||
199 | {IPA_RC_UNSUPPORTED_SUBCMD, "Unsupported assist subcommand"}, | ||
200 | {IPA_RC_ARP_ASSIST_NO_ENABLE, "Only partial success, no enable"}, | ||
201 | {IPA_RC_PRIMARY_ALREADY_DEFINED,"Primary already defined"}, | ||
202 | {IPA_RC_SECOND_ALREADY_DEFINED, "Secondary already defined"}, | ||
203 | {IPA_RC_INVALID_SETRTG_INDICATOR,"Invalid SETRTG indicator"}, | ||
204 | {IPA_RC_MC_ADDR_ALREADY_DEFINED,"Multicast address already defined"}, | ||
205 | {IPA_RC_LAN_OFFLINE, "STRTLAN_LAN_DISABLED - LAN offline"}, | ||
206 | {IPA_RC_INVALID_IP_VERSION2, "Invalid IP version"}, | ||
207 | {IPA_RC_FFFF, "Unknown Error"} | ||
208 | }; | ||
209 | |||
210 | |||
211 | |||
212 | char * | ||
213 | qeth_get_ipa_msg(enum qeth_ipa_return_codes rc) | ||
214 | { | ||
215 | int x = 0; | ||
216 | qeth_ipa_rc_msg[sizeof(qeth_ipa_rc_msg) / | ||
217 | sizeof(struct ipa_rc_msg) - 1].rc = rc; | ||
218 | while(qeth_ipa_rc_msg[x].rc != rc) | ||
219 | x++; | ||
220 | return qeth_ipa_rc_msg[x].msg; | ||
221 | } | ||
222 | |||
223 | |||
224 | struct ipa_cmd_names { | ||
225 | enum qeth_ipa_cmds cmd; | ||
226 | char *name; | ||
227 | }; | ||
228 | |||
229 | static struct ipa_cmd_names qeth_ipa_cmd_names[] = { | ||
230 | {IPA_CMD_STARTLAN, "startlan"}, | ||
231 | {IPA_CMD_STOPLAN, "stoplan"}, | ||
232 | {IPA_CMD_SETVMAC, "setvmac"}, | ||
233 | {IPA_CMD_DELVMAC, "delvmca"}, | ||
234 | {IPA_CMD_SETGMAC, "setgmac"}, | ||
235 | {IPA_CMD_DELGMAC, "delgmac"}, | ||
236 | {IPA_CMD_SETVLAN, "setvlan"}, | ||
237 | {IPA_CMD_DELVLAN, "delvlan"}, | ||
238 | {IPA_CMD_SETCCID, "setccid"}, | ||
239 | {IPA_CMD_DELCCID, "delccid"}, | ||
240 | {IPA_CMD_MODCCID, "setip"}, | ||
241 | {IPA_CMD_SETIP, "setip"}, | ||
242 | {IPA_CMD_QIPASSIST, "qipassist"}, | ||
243 | {IPA_CMD_SETASSPARMS, "setassparms"}, | ||
244 | {IPA_CMD_SETIPM, "setipm"}, | ||
245 | {IPA_CMD_DELIPM, "delipm"}, | ||
246 | {IPA_CMD_SETRTG, "setrtg"}, | ||
247 | {IPA_CMD_DELIP, "delip"}, | ||
248 | {IPA_CMD_SETADAPTERPARMS, "setadapterparms"}, | ||
249 | {IPA_CMD_SET_DIAG_ASS, "set_diag_ass"}, | ||
250 | {IPA_CMD_CREATE_ADDR, "create_addr"}, | ||
251 | {IPA_CMD_DESTROY_ADDR, "destroy_addr"}, | ||
252 | {IPA_CMD_REGISTER_LOCAL_ADDR, "register_local_addr"}, | ||
253 | {IPA_CMD_UNREGISTER_LOCAL_ADDR, "unregister_local_addr"}, | ||
254 | {IPA_CMD_UNKNOWN, "unknown"}, | ||
255 | }; | ||
256 | |||
257 | char * | ||
258 | qeth_get_ipa_cmd_name(enum qeth_ipa_cmds cmd) | ||
259 | { | ||
260 | int x = 0; | ||
261 | qeth_ipa_cmd_names[ | ||
262 | sizeof(qeth_ipa_cmd_names)/ | ||
263 | sizeof(struct ipa_cmd_names)-1].cmd = cmd; | ||
264 | while(qeth_ipa_cmd_names[x].cmd != cmd) | ||
265 | x++; | ||
266 | return qeth_ipa_cmd_names[x].name; | ||
267 | } | ||
268 | |||
269 | |||
diff --git a/drivers/s390/net/qeth_mpc.h b/drivers/s390/net/qeth_mpc.h deleted file mode 100644 index 6de2da5ed5fd..000000000000 --- a/drivers/s390/net/qeth_mpc.h +++ /dev/null | |||
@@ -1,583 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/s390/net/qeth_mpc.h | ||
3 | * | ||
4 | * Linux on zSeries OSA Express and HiperSockets support | ||
5 | * | ||
6 | * Copyright 2000,2003 IBM Corporation | ||
7 | * Author(s): Utz Bacher <utz.bacher@de.ibm.com> | ||
8 | * Thomas Spatzier <tspat@de.ibm.com> | ||
9 | * Frank Pavlic <fpavlic@de.ibm.com> | ||
10 | * | ||
11 | */ | ||
12 | #ifndef __QETH_MPC_H__ | ||
13 | #define __QETH_MPC_H__ | ||
14 | |||
15 | #include <asm/qeth.h> | ||
16 | |||
17 | #define IPA_PDU_HEADER_SIZE 0x40 | ||
18 | #define QETH_IPA_PDU_LEN_TOTAL(buffer) (buffer+0x0e) | ||
19 | #define QETH_IPA_PDU_LEN_PDU1(buffer) (buffer+0x26) | ||
20 | #define QETH_IPA_PDU_LEN_PDU2(buffer) (buffer+0x29) | ||
21 | #define QETH_IPA_PDU_LEN_PDU3(buffer) (buffer+0x3a) | ||
22 | |||
23 | extern unsigned char IPA_PDU_HEADER[]; | ||
24 | #define QETH_IPA_CMD_DEST_ADDR(buffer) (buffer+0x2c) | ||
25 | |||
26 | #define IPA_CMD_LENGTH (IPA_PDU_HEADER_SIZE + sizeof(struct qeth_ipa_cmd)) | ||
27 | |||
28 | #define QETH_SEQ_NO_LENGTH 4 | ||
29 | #define QETH_MPC_TOKEN_LENGTH 4 | ||
30 | #define QETH_MCL_LENGTH 4 | ||
31 | #define OSA_ADDR_LEN 6 | ||
32 | |||
33 | #define QETH_TIMEOUT (10 * HZ) | ||
34 | #define QETH_IPA_TIMEOUT (45 * HZ) | ||
35 | #define QETH_IDX_COMMAND_SEQNO 0xffff0000 | ||
36 | #define SR_INFO_LEN 16 | ||
37 | |||
38 | #define QETH_CLEAR_CHANNEL_PARM -10 | ||
39 | #define QETH_HALT_CHANNEL_PARM -11 | ||
40 | #define QETH_RCD_PARM -12 | ||
41 | |||
42 | /*****************************************************************************/ | ||
43 | /* IP Assist related definitions */ | ||
44 | /*****************************************************************************/ | ||
45 | #define IPA_CMD_INITIATOR_HOST 0x00 | ||
46 | #define IPA_CMD_INITIATOR_OSA 0x01 | ||
47 | #define IPA_CMD_INITIATOR_HOST_REPLY 0x80 | ||
48 | #define IPA_CMD_INITIATOR_OSA_REPLY 0x81 | ||
49 | #define IPA_CMD_PRIM_VERSION_NO 0x01 | ||
50 | |||
51 | enum qeth_card_types { | ||
52 | QETH_CARD_TYPE_UNKNOWN = 0, | ||
53 | QETH_CARD_TYPE_OSAE = 10, | ||
54 | QETH_CARD_TYPE_IQD = 1234, | ||
55 | QETH_CARD_TYPE_OSN = 11, | ||
56 | }; | ||
57 | |||
58 | #define QETH_MPC_DIFINFO_LEN_INDICATES_LINK_TYPE 0x18 | ||
59 | /* only the first two bytes are looked at in qeth_get_cardname_short */ | ||
60 | enum qeth_link_types { | ||
61 | QETH_LINK_TYPE_FAST_ETH = 0x01, | ||
62 | QETH_LINK_TYPE_HSTR = 0x02, | ||
63 | QETH_LINK_TYPE_GBIT_ETH = 0x03, | ||
64 | QETH_LINK_TYPE_OSN = 0x04, | ||
65 | QETH_LINK_TYPE_10GBIT_ETH = 0x10, | ||
66 | QETH_LINK_TYPE_LANE_ETH100 = 0x81, | ||
67 | QETH_LINK_TYPE_LANE_TR = 0x82, | ||
68 | QETH_LINK_TYPE_LANE_ETH1000 = 0x83, | ||
69 | QETH_LINK_TYPE_LANE = 0x88, | ||
70 | QETH_LINK_TYPE_ATM_NATIVE = 0x90, | ||
71 | }; | ||
72 | |||
73 | enum qeth_tr_macaddr_modes { | ||
74 | QETH_TR_MACADDR_NONCANONICAL = 0, | ||
75 | QETH_TR_MACADDR_CANONICAL = 1, | ||
76 | }; | ||
77 | |||
78 | enum qeth_tr_broadcast_modes { | ||
79 | QETH_TR_BROADCAST_ALLRINGS = 0, | ||
80 | QETH_TR_BROADCAST_LOCAL = 1, | ||
81 | }; | ||
82 | |||
83 | /* these values match CHECKSUM_* in include/linux/skbuff.h */ | ||
84 | enum qeth_checksum_types { | ||
85 | SW_CHECKSUMMING = 0, /* TODO: set to bit flag used in IPA Command */ | ||
86 | HW_CHECKSUMMING = 1, | ||
87 | NO_CHECKSUMMING = 2, | ||
88 | }; | ||
89 | #define QETH_CHECKSUM_DEFAULT SW_CHECKSUMMING | ||
90 | |||
91 | /* | ||
92 | * Routing stuff | ||
93 | */ | ||
94 | #define RESET_ROUTING_FLAG 0x10 /* indicate that routing type shall be set */ | ||
95 | enum qeth_routing_types { | ||
96 | NO_ROUTER = 0, /* TODO: set to bit flag used in IPA Command */ | ||
97 | PRIMARY_ROUTER = 1, | ||
98 | SECONDARY_ROUTER = 2, | ||
99 | MULTICAST_ROUTER = 3, | ||
100 | PRIMARY_CONNECTOR = 4, | ||
101 | SECONDARY_CONNECTOR = 5, | ||
102 | }; | ||
103 | |||
104 | /* IPA Commands */ | ||
105 | enum qeth_ipa_cmds { | ||
106 | IPA_CMD_STARTLAN = 0x01, | ||
107 | IPA_CMD_STOPLAN = 0x02, | ||
108 | IPA_CMD_SETVMAC = 0x21, | ||
109 | IPA_CMD_DELVMAC = 0x22, | ||
110 | IPA_CMD_SETGMAC = 0x23, | ||
111 | IPA_CMD_DELGMAC = 0x24, | ||
112 | IPA_CMD_SETVLAN = 0x25, | ||
113 | IPA_CMD_DELVLAN = 0x26, | ||
114 | IPA_CMD_SETCCID = 0x41, | ||
115 | IPA_CMD_DELCCID = 0x42, | ||
116 | IPA_CMD_MODCCID = 0x43, | ||
117 | IPA_CMD_SETIP = 0xb1, | ||
118 | IPA_CMD_QIPASSIST = 0xb2, | ||
119 | IPA_CMD_SETASSPARMS = 0xb3, | ||
120 | IPA_CMD_SETIPM = 0xb4, | ||
121 | IPA_CMD_DELIPM = 0xb5, | ||
122 | IPA_CMD_SETRTG = 0xb6, | ||
123 | IPA_CMD_DELIP = 0xb7, | ||
124 | IPA_CMD_SETADAPTERPARMS = 0xb8, | ||
125 | IPA_CMD_SET_DIAG_ASS = 0xb9, | ||
126 | IPA_CMD_CREATE_ADDR = 0xc3, | ||
127 | IPA_CMD_DESTROY_ADDR = 0xc4, | ||
128 | IPA_CMD_REGISTER_LOCAL_ADDR = 0xd1, | ||
129 | IPA_CMD_UNREGISTER_LOCAL_ADDR = 0xd2, | ||
130 | IPA_CMD_UNKNOWN = 0x00 | ||
131 | }; | ||
132 | |||
133 | enum qeth_ip_ass_cmds { | ||
134 | IPA_CMD_ASS_START = 0x0001, | ||
135 | IPA_CMD_ASS_STOP = 0x0002, | ||
136 | IPA_CMD_ASS_CONFIGURE = 0x0003, | ||
137 | IPA_CMD_ASS_ENABLE = 0x0004, | ||
138 | }; | ||
139 | |||
140 | enum qeth_arp_process_subcmds { | ||
141 | IPA_CMD_ASS_ARP_SET_NO_ENTRIES = 0x0003, | ||
142 | IPA_CMD_ASS_ARP_QUERY_CACHE = 0x0004, | ||
143 | IPA_CMD_ASS_ARP_ADD_ENTRY = 0x0005, | ||
144 | IPA_CMD_ASS_ARP_REMOVE_ENTRY = 0x0006, | ||
145 | IPA_CMD_ASS_ARP_FLUSH_CACHE = 0x0007, | ||
146 | IPA_CMD_ASS_ARP_QUERY_INFO = 0x0104, | ||
147 | IPA_CMD_ASS_ARP_QUERY_STATS = 0x0204, | ||
148 | }; | ||
149 | |||
150 | |||
151 | /* Return Codes for IPA Commands | ||
152 | * according to OSA card Specs */ | ||
153 | |||
154 | enum qeth_ipa_return_codes { | ||
155 | IPA_RC_SUCCESS = 0x0000, | ||
156 | IPA_RC_NOTSUPP = 0x0001, | ||
157 | IPA_RC_IP_TABLE_FULL = 0x0002, | ||
158 | IPA_RC_UNKNOWN_ERROR = 0x0003, | ||
159 | IPA_RC_UNSUPPORTED_COMMAND = 0x0004, | ||
160 | IPA_RC_DUP_IPV6_REMOTE = 0x0008, | ||
161 | IPA_RC_DUP_IPV6_HOME = 0x0010, | ||
162 | IPA_RC_UNREGISTERED_ADDR = 0x0011, | ||
163 | IPA_RC_NO_ID_AVAILABLE = 0x0012, | ||
164 | IPA_RC_ID_NOT_FOUND = 0x0013, | ||
165 | IPA_RC_INVALID_IP_VERSION = 0x0020, | ||
166 | IPA_RC_LAN_FRAME_MISMATCH = 0x0040, | ||
167 | IPA_RC_L2_UNSUPPORTED_CMD = 0x2003, | ||
168 | IPA_RC_L2_DUP_MAC = 0x2005, | ||
169 | IPA_RC_L2_ADDR_TABLE_FULL = 0x2006, | ||
170 | IPA_RC_L2_DUP_LAYER3_MAC = 0x200a, | ||
171 | IPA_RC_L2_GMAC_NOT_FOUND = 0x200b, | ||
172 | IPA_RC_L2_MAC_NOT_FOUND = 0x2010, | ||
173 | IPA_RC_L2_INVALID_VLAN_ID = 0x2015, | ||
174 | IPA_RC_L2_DUP_VLAN_ID = 0x2016, | ||
175 | IPA_RC_L2_VLAN_ID_NOT_FOUND = 0x2017, | ||
176 | IPA_RC_DATA_MISMATCH = 0xe001, | ||
177 | IPA_RC_INVALID_MTU_SIZE = 0xe002, | ||
178 | IPA_RC_INVALID_LANTYPE = 0xe003, | ||
179 | IPA_RC_INVALID_LANNUM = 0xe004, | ||
180 | IPA_RC_DUPLICATE_IP_ADDRESS = 0xe005, | ||
181 | IPA_RC_IP_ADDR_TABLE_FULL = 0xe006, | ||
182 | IPA_RC_LAN_PORT_STATE_ERROR = 0xe007, | ||
183 | IPA_RC_SETIP_NO_STARTLAN = 0xe008, | ||
184 | IPA_RC_SETIP_ALREADY_RECEIVED = 0xe009, | ||
185 | IPA_RC_IP_ADDR_ALREADY_USED = 0xe00a, | ||
186 | IPA_RC_MULTICAST_FULL = 0xe00b, | ||
187 | IPA_RC_SETIP_INVALID_VERSION = 0xe00d, | ||
188 | IPA_RC_UNSUPPORTED_SUBCMD = 0xe00e, | ||
189 | IPA_RC_ARP_ASSIST_NO_ENABLE = 0xe00f, | ||
190 | IPA_RC_PRIMARY_ALREADY_DEFINED = 0xe010, | ||
191 | IPA_RC_SECOND_ALREADY_DEFINED = 0xe011, | ||
192 | IPA_RC_INVALID_SETRTG_INDICATOR = 0xe012, | ||
193 | IPA_RC_MC_ADDR_ALREADY_DEFINED = 0xe013, | ||
194 | IPA_RC_LAN_OFFLINE = 0xe080, | ||
195 | IPA_RC_INVALID_IP_VERSION2 = 0xf001, | ||
196 | IPA_RC_FFFF = 0xffff | ||
197 | }; | ||
198 | |||
199 | /* IPA function flags; each flag marks availability of respective function */ | ||
200 | enum qeth_ipa_funcs { | ||
201 | IPA_ARP_PROCESSING = 0x00000001L, | ||
202 | IPA_INBOUND_CHECKSUM = 0x00000002L, | ||
203 | IPA_OUTBOUND_CHECKSUM = 0x00000004L, | ||
204 | IPA_IP_FRAGMENTATION = 0x00000008L, | ||
205 | IPA_FILTERING = 0x00000010L, | ||
206 | IPA_IPV6 = 0x00000020L, | ||
207 | IPA_MULTICASTING = 0x00000040L, | ||
208 | IPA_IP_REASSEMBLY = 0x00000080L, | ||
209 | IPA_QUERY_ARP_COUNTERS = 0x00000100L, | ||
210 | IPA_QUERY_ARP_ADDR_INFO = 0x00000200L, | ||
211 | IPA_SETADAPTERPARMS = 0x00000400L, | ||
212 | IPA_VLAN_PRIO = 0x00000800L, | ||
213 | IPA_PASSTHRU = 0x00001000L, | ||
214 | IPA_FLUSH_ARP_SUPPORT = 0x00002000L, | ||
215 | IPA_FULL_VLAN = 0x00004000L, | ||
216 | IPA_INBOUND_PASSTHRU = 0x00008000L, | ||
217 | IPA_SOURCE_MAC = 0x00010000L, | ||
218 | IPA_OSA_MC_ROUTER = 0x00020000L, | ||
219 | IPA_QUERY_ARP_ASSIST = 0x00040000L, | ||
220 | IPA_INBOUND_TSO = 0x00080000L, | ||
221 | IPA_OUTBOUND_TSO = 0x00100000L, | ||
222 | }; | ||
223 | |||
224 | /* SETIP/DELIP IPA Command: ***************************************************/ | ||
225 | enum qeth_ipa_setdelip_flags { | ||
226 | QETH_IPA_SETDELIP_DEFAULT = 0x00L, /* default */ | ||
227 | QETH_IPA_SETIP_VIPA_FLAG = 0x01L, /* no grat. ARP */ | ||
228 | QETH_IPA_SETIP_TAKEOVER_FLAG = 0x02L, /* nofail on grat. ARP */ | ||
229 | QETH_IPA_DELIP_ADDR_2_B_TAKEN_OVER = 0x20L, | ||
230 | QETH_IPA_DELIP_VIPA_FLAG = 0x40L, | ||
231 | QETH_IPA_DELIP_ADDR_NEEDS_SETIP = 0x80L, | ||
232 | }; | ||
233 | |||
234 | /* SETADAPTER IPA Command: ****************************************************/ | ||
235 | enum qeth_ipa_setadp_cmd { | ||
236 | IPA_SETADP_QUERY_COMMANDS_SUPPORTED = 0x01, | ||
237 | IPA_SETADP_ALTER_MAC_ADDRESS = 0x02, | ||
238 | IPA_SETADP_ADD_DELETE_GROUP_ADDRESS = 0x04, | ||
239 | IPA_SETADP_ADD_DELETE_FUNCTIONAL_ADDR = 0x08, | ||
240 | IPA_SETADP_SET_ADDRESSING_MODE = 0x10, | ||
241 | IPA_SETADP_SET_CONFIG_PARMS = 0x20, | ||
242 | IPA_SETADP_SET_CONFIG_PARMS_EXTENDED = 0x40, | ||
243 | IPA_SETADP_SET_BROADCAST_MODE = 0x80, | ||
244 | IPA_SETADP_SEND_OSA_MESSAGE = 0x0100, | ||
245 | IPA_SETADP_SET_SNMP_CONTROL = 0x0200, | ||
246 | IPA_SETADP_QUERY_CARD_INFO = 0x0400, | ||
247 | IPA_SETADP_SET_PROMISC_MODE = 0x0800, | ||
248 | }; | ||
249 | enum qeth_ipa_mac_ops { | ||
250 | CHANGE_ADDR_READ_MAC = 0, | ||
251 | CHANGE_ADDR_REPLACE_MAC = 1, | ||
252 | CHANGE_ADDR_ADD_MAC = 2, | ||
253 | CHANGE_ADDR_DEL_MAC = 4, | ||
254 | CHANGE_ADDR_RESET_MAC = 8, | ||
255 | }; | ||
256 | enum qeth_ipa_addr_ops { | ||
257 | CHANGE_ADDR_READ_ADDR = 0, | ||
258 | CHANGE_ADDR_ADD_ADDR = 1, | ||
259 | CHANGE_ADDR_DEL_ADDR = 2, | ||
260 | CHANGE_ADDR_FLUSH_ADDR_TABLE = 4, | ||
261 | }; | ||
262 | enum qeth_ipa_promisc_modes { | ||
263 | SET_PROMISC_MODE_OFF = 0, | ||
264 | SET_PROMISC_MODE_ON = 1, | ||
265 | }; | ||
266 | |||
267 | /* (SET)DELIP(M) IPA stuff ***************************************************/ | ||
268 | struct qeth_ipacmd_setdelip4 { | ||
269 | __u8 ip_addr[4]; | ||
270 | __u8 mask[4]; | ||
271 | __u32 flags; | ||
272 | } __attribute__ ((packed)); | ||
273 | |||
274 | struct qeth_ipacmd_setdelip6 { | ||
275 | __u8 ip_addr[16]; | ||
276 | __u8 mask[16]; | ||
277 | __u32 flags; | ||
278 | } __attribute__ ((packed)); | ||
279 | |||
280 | struct qeth_ipacmd_setdelipm { | ||
281 | __u8 mac[6]; | ||
282 | __u8 padding[2]; | ||
283 | __u8 ip6[12]; | ||
284 | __u8 ip4[4]; | ||
285 | } __attribute__ ((packed)); | ||
286 | |||
287 | struct qeth_ipacmd_layer2setdelmac { | ||
288 | __u32 mac_length; | ||
289 | __u8 mac[6]; | ||
290 | } __attribute__ ((packed)); | ||
291 | |||
292 | struct qeth_ipacmd_layer2setdelvlan { | ||
293 | __u16 vlan_id; | ||
294 | } __attribute__ ((packed)); | ||
295 | |||
296 | |||
297 | struct qeth_ipacmd_setassparms_hdr { | ||
298 | __u32 assist_no; | ||
299 | __u16 length; | ||
300 | __u16 command_code; | ||
301 | __u16 return_code; | ||
302 | __u8 number_of_replies; | ||
303 | __u8 seq_no; | ||
304 | } __attribute__((packed)); | ||
305 | |||
306 | struct qeth_arp_query_data { | ||
307 | __u16 request_bits; | ||
308 | __u16 reply_bits; | ||
309 | __u32 no_entries; | ||
310 | char data; | ||
311 | } __attribute__((packed)); | ||
312 | |||
313 | /* used as parameter for arp_query reply */ | ||
314 | struct qeth_arp_query_info { | ||
315 | __u32 udata_len; | ||
316 | __u16 mask_bits; | ||
317 | __u32 udata_offset; | ||
318 | __u32 no_entries; | ||
319 | char *udata; | ||
320 | }; | ||
321 | |||
322 | /* SETASSPARMS IPA Command: */ | ||
323 | struct qeth_ipacmd_setassparms { | ||
324 | struct qeth_ipacmd_setassparms_hdr hdr; | ||
325 | union { | ||
326 | __u32 flags_32bit; | ||
327 | struct qeth_arp_cache_entry add_arp_entry; | ||
328 | struct qeth_arp_query_data query_arp; | ||
329 | __u8 ip[16]; | ||
330 | } data; | ||
331 | } __attribute__ ((packed)); | ||
332 | |||
333 | |||
334 | /* SETRTG IPA Command: ****************************************************/ | ||
335 | struct qeth_set_routing { | ||
336 | __u8 type; | ||
337 | }; | ||
338 | |||
339 | /* SETADAPTERPARMS IPA Command: *******************************************/ | ||
340 | struct qeth_query_cmds_supp { | ||
341 | __u32 no_lantypes_supp; | ||
342 | __u8 lan_type; | ||
343 | __u8 reserved1[3]; | ||
344 | __u32 supported_cmds; | ||
345 | __u8 reserved2[8]; | ||
346 | } __attribute__ ((packed)); | ||
347 | |||
348 | struct qeth_change_addr { | ||
349 | __u32 cmd; | ||
350 | __u32 addr_size; | ||
351 | __u32 no_macs; | ||
352 | __u8 addr[OSA_ADDR_LEN]; | ||
353 | } __attribute__ ((packed)); | ||
354 | |||
355 | |||
356 | struct qeth_snmp_cmd { | ||
357 | __u8 token[16]; | ||
358 | __u32 request; | ||
359 | __u32 interface; | ||
360 | __u32 returncode; | ||
361 | __u32 firmwarelevel; | ||
362 | __u32 seqno; | ||
363 | __u8 data; | ||
364 | } __attribute__ ((packed)); | ||
365 | |||
366 | struct qeth_snmp_ureq_hdr { | ||
367 | __u32 data_len; | ||
368 | __u32 req_len; | ||
369 | __u32 reserved1; | ||
370 | __u32 reserved2; | ||
371 | } __attribute__ ((packed)); | ||
372 | |||
373 | struct qeth_snmp_ureq { | ||
374 | struct qeth_snmp_ureq_hdr hdr; | ||
375 | struct qeth_snmp_cmd cmd; | ||
376 | } __attribute__((packed)); | ||
377 | |||
378 | struct qeth_ipacmd_setadpparms_hdr { | ||
379 | __u32 supp_hw_cmds; | ||
380 | __u32 reserved1; | ||
381 | __u16 cmdlength; | ||
382 | __u16 reserved2; | ||
383 | __u32 command_code; | ||
384 | __u16 return_code; | ||
385 | __u8 used_total; | ||
386 | __u8 seq_no; | ||
387 | __u32 reserved3; | ||
388 | } __attribute__ ((packed)); | ||
389 | |||
390 | struct qeth_ipacmd_setadpparms { | ||
391 | struct qeth_ipacmd_setadpparms_hdr hdr; | ||
392 | union { | ||
393 | struct qeth_query_cmds_supp query_cmds_supp; | ||
394 | struct qeth_change_addr change_addr; | ||
395 | struct qeth_snmp_cmd snmp; | ||
396 | __u32 mode; | ||
397 | } data; | ||
398 | } __attribute__ ((packed)); | ||
399 | |||
400 | /* IPFRAME IPA Command: ***************************************************/ | ||
401 | /* TODO: define in analogy to commands define above */ | ||
402 | |||
403 | /* ADD_ADDR_ENTRY IPA Command: ********************************************/ | ||
404 | /* TODO: define in analogy to commands define above */ | ||
405 | |||
406 | /* DELETE_ADDR_ENTRY IPA Command: *****************************************/ | ||
407 | /* TODO: define in analogy to commands define above */ | ||
408 | |||
409 | /* CREATE_ADDR IPA Command: ***********************************************/ | ||
410 | struct qeth_create_destroy_address { | ||
411 | __u8 unique_id[8]; | ||
412 | } __attribute__ ((packed)); | ||
413 | |||
414 | /* REGISTER_LOCAL_ADDR IPA Command: ***************************************/ | ||
415 | /* TODO: define in analogy to commands define above */ | ||
416 | |||
417 | /* UNREGISTER_LOCAL_ADDR IPA Command: *************************************/ | ||
418 | /* TODO: define in analogy to commands define above */ | ||
419 | |||
420 | /* Header for each IPA command */ | ||
421 | struct qeth_ipacmd_hdr { | ||
422 | __u8 command; | ||
423 | __u8 initiator; | ||
424 | __u16 seqno; | ||
425 | __u16 return_code; | ||
426 | __u8 adapter_type; | ||
427 | __u8 rel_adapter_no; | ||
428 | __u8 prim_version_no; | ||
429 | __u8 param_count; | ||
430 | __u16 prot_version; | ||
431 | __u32 ipa_supported; | ||
432 | __u32 ipa_enabled; | ||
433 | } __attribute__ ((packed)); | ||
434 | |||
435 | /* The IPA command itself */ | ||
436 | struct qeth_ipa_cmd { | ||
437 | struct qeth_ipacmd_hdr hdr; | ||
438 | union { | ||
439 | struct qeth_ipacmd_setdelip4 setdelip4; | ||
440 | struct qeth_ipacmd_setdelip6 setdelip6; | ||
441 | struct qeth_ipacmd_setdelipm setdelipm; | ||
442 | struct qeth_ipacmd_setassparms setassparms; | ||
443 | struct qeth_ipacmd_layer2setdelmac setdelmac; | ||
444 | struct qeth_ipacmd_layer2setdelvlan setdelvlan; | ||
445 | struct qeth_create_destroy_address create_destroy_addr; | ||
446 | struct qeth_ipacmd_setadpparms setadapterparms; | ||
447 | struct qeth_set_routing setrtg; | ||
448 | } data; | ||
449 | } __attribute__ ((packed)); | ||
450 | |||
451 | /* | ||
452 | * special command for ARP processing. | ||
453 | * this is not included in setassparms command before, because we get | ||
454 | * problem with the size of struct qeth_ipacmd_setassparms otherwise | ||
455 | */ | ||
456 | enum qeth_ipa_arp_return_codes { | ||
457 | QETH_IPA_ARP_RC_SUCCESS = 0x0000, | ||
458 | QETH_IPA_ARP_RC_FAILED = 0x0001, | ||
459 | QETH_IPA_ARP_RC_NOTSUPP = 0x0002, | ||
460 | QETH_IPA_ARP_RC_OUT_OF_RANGE = 0x0003, | ||
461 | QETH_IPA_ARP_RC_Q_NOTSUPP = 0x0004, | ||
462 | QETH_IPA_ARP_RC_Q_NO_DATA = 0x0008, | ||
463 | }; | ||
464 | |||
465 | |||
466 | extern char * | ||
467 | qeth_get_ipa_msg(enum qeth_ipa_return_codes rc); | ||
468 | extern char * | ||
469 | qeth_get_ipa_cmd_name(enum qeth_ipa_cmds cmd); | ||
470 | |||
471 | #define QETH_SETASS_BASE_LEN (sizeof(struct qeth_ipacmd_hdr) + \ | ||
472 | sizeof(struct qeth_ipacmd_setassparms_hdr)) | ||
473 | #define QETH_IPA_ARP_DATA_POS(buffer) (buffer + IPA_PDU_HEADER_SIZE + \ | ||
474 | QETH_SETASS_BASE_LEN) | ||
475 | #define QETH_SETADP_BASE_LEN (sizeof(struct qeth_ipacmd_hdr) + \ | ||
476 | sizeof(struct qeth_ipacmd_setadpparms_hdr)) | ||
477 | #define QETH_SNMP_SETADP_CMDLENGTH 16 | ||
478 | |||
479 | #define QETH_ARP_DATA_SIZE 3968 | ||
480 | #define QETH_ARP_CMD_LEN (QETH_ARP_DATA_SIZE + 8) | ||
481 | /* Helper functions */ | ||
482 | #define IS_IPA_REPLY(cmd) ((cmd->hdr.initiator == IPA_CMD_INITIATOR_HOST) || \ | ||
483 | (cmd->hdr.initiator == IPA_CMD_INITIATOR_OSA_REPLY)) | ||
484 | |||
485 | /*****************************************************************************/ | ||
486 | /* END OF IP Assist related definitions */ | ||
487 | /*****************************************************************************/ | ||
488 | |||
489 | |||
490 | extern unsigned char WRITE_CCW[]; | ||
491 | extern unsigned char READ_CCW[]; | ||
492 | |||
493 | extern unsigned char CM_ENABLE[]; | ||
494 | #define CM_ENABLE_SIZE 0x63 | ||
495 | #define QETH_CM_ENABLE_ISSUER_RM_TOKEN(buffer) (buffer+0x2c) | ||
496 | #define QETH_CM_ENABLE_FILTER_TOKEN(buffer) (buffer+0x53) | ||
497 | #define QETH_CM_ENABLE_USER_DATA(buffer) (buffer+0x5b) | ||
498 | |||
499 | #define QETH_CM_ENABLE_RESP_FILTER_TOKEN(buffer) \ | ||
500 | (PDU_ENCAPSULATION(buffer)+ 0x13) | ||
501 | |||
502 | |||
503 | extern unsigned char CM_SETUP[]; | ||
504 | #define CM_SETUP_SIZE 0x64 | ||
505 | #define QETH_CM_SETUP_DEST_ADDR(buffer) (buffer+0x2c) | ||
506 | #define QETH_CM_SETUP_CONNECTION_TOKEN(buffer) (buffer+0x51) | ||
507 | #define QETH_CM_SETUP_FILTER_TOKEN(buffer) (buffer+0x5a) | ||
508 | |||
509 | #define QETH_CM_SETUP_RESP_DEST_ADDR(buffer) \ | ||
510 | (PDU_ENCAPSULATION(buffer) + 0x1a) | ||
511 | |||
512 | extern unsigned char ULP_ENABLE[]; | ||
513 | #define ULP_ENABLE_SIZE 0x6b | ||
514 | #define QETH_ULP_ENABLE_LINKNUM(buffer) (buffer+0x61) | ||
515 | #define QETH_ULP_ENABLE_DEST_ADDR(buffer) (buffer+0x2c) | ||
516 | #define QETH_ULP_ENABLE_FILTER_TOKEN(buffer) (buffer+0x53) | ||
517 | #define QETH_ULP_ENABLE_PORTNAME_AND_LL(buffer) (buffer+0x62) | ||
518 | #define QETH_ULP_ENABLE_RESP_FILTER_TOKEN(buffer) \ | ||
519 | (PDU_ENCAPSULATION(buffer) + 0x13) | ||
520 | #define QETH_ULP_ENABLE_RESP_MAX_MTU(buffer) \ | ||
521 | (PDU_ENCAPSULATION(buffer)+ 0x1f) | ||
522 | #define QETH_ULP_ENABLE_RESP_DIFINFO_LEN(buffer) \ | ||
523 | (PDU_ENCAPSULATION(buffer) + 0x17) | ||
524 | #define QETH_ULP_ENABLE_RESP_LINK_TYPE(buffer) \ | ||
525 | (PDU_ENCAPSULATION(buffer)+ 0x2b) | ||
526 | /* Layer 2 defintions */ | ||
527 | #define QETH_PROT_LAYER2 0x08 | ||
528 | #define QETH_PROT_TCPIP 0x03 | ||
529 | #define QETH_PROT_OSN2 0x0a | ||
530 | #define QETH_ULP_ENABLE_PROT_TYPE(buffer) (buffer+0x50) | ||
531 | #define QETH_IPA_CMD_PROT_TYPE(buffer) (buffer+0x19) | ||
532 | |||
533 | extern unsigned char ULP_SETUP[]; | ||
534 | #define ULP_SETUP_SIZE 0x6c | ||
535 | #define QETH_ULP_SETUP_DEST_ADDR(buffer) (buffer+0x2c) | ||
536 | #define QETH_ULP_SETUP_CONNECTION_TOKEN(buffer) (buffer+0x51) | ||
537 | #define QETH_ULP_SETUP_FILTER_TOKEN(buffer) (buffer+0x5a) | ||
538 | #define QETH_ULP_SETUP_CUA(buffer) (buffer+0x68) | ||
539 | #define QETH_ULP_SETUP_REAL_DEVADDR(buffer) (buffer+0x6a) | ||
540 | |||
541 | #define QETH_ULP_SETUP_RESP_CONNECTION_TOKEN(buffer) \ | ||
542 | (PDU_ENCAPSULATION(buffer)+0x1a) | ||
543 | |||
544 | |||
545 | extern unsigned char DM_ACT[]; | ||
546 | #define DM_ACT_SIZE 0x55 | ||
547 | #define QETH_DM_ACT_DEST_ADDR(buffer) (buffer+0x2c) | ||
548 | #define QETH_DM_ACT_CONNECTION_TOKEN(buffer) (buffer+0x51) | ||
549 | |||
550 | |||
551 | |||
552 | #define QETH_TRANSPORT_HEADER_SEQ_NO(buffer) (buffer+4) | ||
553 | #define QETH_PDU_HEADER_SEQ_NO(buffer) (buffer+0x1c) | ||
554 | #define QETH_PDU_HEADER_ACK_SEQ_NO(buffer) (buffer+0x20) | ||
555 | |||
556 | extern unsigned char IDX_ACTIVATE_READ[]; | ||
557 | extern unsigned char IDX_ACTIVATE_WRITE[]; | ||
558 | |||
559 | #define IDX_ACTIVATE_SIZE 0x22 | ||
560 | #define QETH_IDX_ACT_ISSUER_RM_TOKEN(buffer) (buffer+0x0c) | ||
561 | #define QETH_IDX_NO_PORTNAME_REQUIRED(buffer) ((buffer)[0x0b]&0x80) | ||
562 | #define QETH_IDX_ACT_FUNC_LEVEL(buffer) (buffer+0x10) | ||
563 | #define QETH_IDX_ACT_DATASET_NAME(buffer) (buffer+0x16) | ||
564 | #define QETH_IDX_ACT_QDIO_DEV_CUA(buffer) (buffer+0x1e) | ||
565 | #define QETH_IDX_ACT_QDIO_DEV_REALADDR(buffer) (buffer+0x20) | ||
566 | #define QETH_IS_IDX_ACT_POS_REPLY(buffer) (((buffer)[0x08]&3)==2) | ||
567 | #define QETH_IDX_REPLY_LEVEL(buffer) (buffer+0x12) | ||
568 | #define QETH_IDX_ACT_CAUSE_CODE(buffer) (buffer)[0x09] | ||
569 | |||
570 | #define PDU_ENCAPSULATION(buffer) \ | ||
571 | (buffer + *(buffer + (*(buffer+0x0b)) + \ | ||
572 | *(buffer + *(buffer+0x0b)+0x11) +0x07)) | ||
573 | |||
574 | #define IS_IPA(buffer) \ | ||
575 | ((buffer) && \ | ||
576 | ( *(buffer + ((*(buffer+0x0b))+4) )==0xc1) ) | ||
577 | |||
578 | #define ADDR_FRAME_TYPE_DIX 1 | ||
579 | #define ADDR_FRAME_TYPE_802_3 2 | ||
580 | #define ADDR_FRAME_TYPE_TR_WITHOUT_SR 0x10 | ||
581 | #define ADDR_FRAME_TYPE_TR_WITH_SR 0x20 | ||
582 | |||
583 | #endif | ||
diff --git a/drivers/s390/net/qeth_proc.c b/drivers/s390/net/qeth_proc.c deleted file mode 100644 index 46ecd03a597e..000000000000 --- a/drivers/s390/net/qeth_proc.c +++ /dev/null | |||
@@ -1,316 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * linux/drivers/s390/net/qeth_fs.c | ||
4 | * | ||
5 | * Linux on zSeries OSA Express and HiperSockets support | ||
6 | * This file contains code related to procfs. | ||
7 | * | ||
8 | * Copyright 2000,2003 IBM Corporation | ||
9 | * | ||
10 | * Author(s): Thomas Spatzier <tspat@de.ibm.com> | ||
11 | * | ||
12 | */ | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/proc_fs.h> | ||
16 | #include <linux/seq_file.h> | ||
17 | #include <linux/list.h> | ||
18 | #include <linux/rwsem.h> | ||
19 | |||
20 | #include "qeth.h" | ||
21 | #include "qeth_mpc.h" | ||
22 | #include "qeth_fs.h" | ||
23 | |||
24 | /***** /proc/qeth *****/ | ||
25 | #define QETH_PROCFILE_NAME "qeth" | ||
26 | static struct proc_dir_entry *qeth_procfile; | ||
27 | |||
28 | static int | ||
29 | qeth_procfile_seq_match(struct device *dev, void *data) | ||
30 | { | ||
31 | return(dev ? 1 : 0); | ||
32 | } | ||
33 | |||
34 | static void * | ||
35 | qeth_procfile_seq_start(struct seq_file *s, loff_t *offset) | ||
36 | { | ||
37 | struct device *dev = NULL; | ||
38 | loff_t nr = 0; | ||
39 | |||
40 | if (*offset == 0) | ||
41 | return SEQ_START_TOKEN; | ||
42 | while (1) { | ||
43 | dev = driver_find_device(&qeth_ccwgroup_driver.driver, dev, | ||
44 | NULL, qeth_procfile_seq_match); | ||
45 | if (++nr == *offset) | ||
46 | break; | ||
47 | put_device(dev); | ||
48 | } | ||
49 | return dev; | ||
50 | } | ||
51 | |||
52 | static void | ||
53 | qeth_procfile_seq_stop(struct seq_file *s, void* it) | ||
54 | { | ||
55 | } | ||
56 | |||
57 | static void * | ||
58 | qeth_procfile_seq_next(struct seq_file *s, void *it, loff_t *offset) | ||
59 | { | ||
60 | struct device *prev, *next; | ||
61 | |||
62 | if (it == SEQ_START_TOKEN) | ||
63 | prev = NULL; | ||
64 | else | ||
65 | prev = (struct device *) it; | ||
66 | next = driver_find_device(&qeth_ccwgroup_driver.driver, | ||
67 | prev, NULL, qeth_procfile_seq_match); | ||
68 | (*offset)++; | ||
69 | return (void *) next; | ||
70 | } | ||
71 | |||
72 | static inline const char * | ||
73 | qeth_get_router_str(struct qeth_card *card, int ipv) | ||
74 | { | ||
75 | enum qeth_routing_types routing_type = NO_ROUTER; | ||
76 | |||
77 | if (ipv == 4) { | ||
78 | routing_type = card->options.route4.type; | ||
79 | } else { | ||
80 | #ifdef CONFIG_QETH_IPV6 | ||
81 | routing_type = card->options.route6.type; | ||
82 | #else | ||
83 | return "n/a"; | ||
84 | #endif /* CONFIG_QETH_IPV6 */ | ||
85 | } | ||
86 | |||
87 | switch (routing_type){ | ||
88 | case PRIMARY_ROUTER: | ||
89 | return "pri"; | ||
90 | case SECONDARY_ROUTER: | ||
91 | return "sec"; | ||
92 | case MULTICAST_ROUTER: | ||
93 | if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) | ||
94 | return "mc+"; | ||
95 | return "mc"; | ||
96 | case PRIMARY_CONNECTOR: | ||
97 | if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) | ||
98 | return "p+c"; | ||
99 | return "p.c"; | ||
100 | case SECONDARY_CONNECTOR: | ||
101 | if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) | ||
102 | return "s+c"; | ||
103 | return "s.c"; | ||
104 | default: /* NO_ROUTER */ | ||
105 | return "no"; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | static int | ||
110 | qeth_procfile_seq_show(struct seq_file *s, void *it) | ||
111 | { | ||
112 | struct device *device; | ||
113 | struct qeth_card *card; | ||
114 | char tmp[12]; /* for qeth_get_prioq_str */ | ||
115 | |||
116 | if (it == SEQ_START_TOKEN){ | ||
117 | seq_printf(s, "devices CHPID interface " | ||
118 | "cardtype port chksum prio-q'ing rtr4 " | ||
119 | "rtr6 fsz cnt\n"); | ||
120 | seq_printf(s, "-------------------------- ----- ---------- " | ||
121 | "-------------- ---- ------ ---------- ---- " | ||
122 | "---- ----- -----\n"); | ||
123 | } else { | ||
124 | device = (struct device *) it; | ||
125 | card = device->driver_data; | ||
126 | seq_printf(s, "%s/%s/%s x%02X %-10s %-14s %-4i ", | ||
127 | CARD_RDEV_ID(card), | ||
128 | CARD_WDEV_ID(card), | ||
129 | CARD_DDEV_ID(card), | ||
130 | card->info.chpid, | ||
131 | QETH_CARD_IFNAME(card), | ||
132 | qeth_get_cardname_short(card), | ||
133 | card->info.portno); | ||
134 | if (card->lan_online) | ||
135 | seq_printf(s, "%-6s %-10s %-4s %-4s %-5s %-5i\n", | ||
136 | qeth_get_checksum_str(card), | ||
137 | qeth_get_prioq_str(card, tmp), | ||
138 | qeth_get_router_str(card, 4), | ||
139 | qeth_get_router_str(card, 6), | ||
140 | qeth_get_bufsize_str(card), | ||
141 | card->qdio.in_buf_pool.buf_count); | ||
142 | else | ||
143 | seq_printf(s, " +++ LAN OFFLINE +++\n"); | ||
144 | put_device(device); | ||
145 | } | ||
146 | return 0; | ||
147 | } | ||
148 | |||
149 | static const struct seq_operations qeth_procfile_seq_ops = { | ||
150 | .start = qeth_procfile_seq_start, | ||
151 | .stop = qeth_procfile_seq_stop, | ||
152 | .next = qeth_procfile_seq_next, | ||
153 | .show = qeth_procfile_seq_show, | ||
154 | }; | ||
155 | |||
156 | static int | ||
157 | qeth_procfile_open(struct inode *inode, struct file *file) | ||
158 | { | ||
159 | return seq_open(file, &qeth_procfile_seq_ops); | ||
160 | } | ||
161 | |||
162 | static const struct file_operations qeth_procfile_fops = { | ||
163 | .owner = THIS_MODULE, | ||
164 | .open = qeth_procfile_open, | ||
165 | .read = seq_read, | ||
166 | .llseek = seq_lseek, | ||
167 | .release = seq_release, | ||
168 | }; | ||
169 | |||
170 | /***** /proc/qeth_perf *****/ | ||
171 | #define QETH_PERF_PROCFILE_NAME "qeth_perf" | ||
172 | static struct proc_dir_entry *qeth_perf_procfile; | ||
173 | |||
174 | static int | ||
175 | qeth_perf_procfile_seq_show(struct seq_file *s, void *it) | ||
176 | { | ||
177 | struct device *device; | ||
178 | struct qeth_card *card; | ||
179 | |||
180 | |||
181 | if (it == SEQ_START_TOKEN) | ||
182 | return 0; | ||
183 | |||
184 | device = (struct device *) it; | ||
185 | card = device->driver_data; | ||
186 | seq_printf(s, "For card with devnos %s/%s/%s (%s):\n", | ||
187 | CARD_RDEV_ID(card), | ||
188 | CARD_WDEV_ID(card), | ||
189 | CARD_DDEV_ID(card), | ||
190 | QETH_CARD_IFNAME(card) | ||
191 | ); | ||
192 | if (!card->options.performance_stats) | ||
193 | seq_printf(s, "Performance statistics are deactivated.\n"); | ||
194 | seq_printf(s, " Skb's/buffers received : %lu/%u\n" | ||
195 | " Skb's/buffers sent : %lu/%u\n\n", | ||
196 | card->stats.rx_packets - | ||
197 | card->perf_stats.initial_rx_packets, | ||
198 | card->perf_stats.bufs_rec, | ||
199 | card->stats.tx_packets - | ||
200 | card->perf_stats.initial_tx_packets, | ||
201 | card->perf_stats.bufs_sent | ||
202 | ); | ||
203 | seq_printf(s, " Skb's/buffers sent without packing : %lu/%u\n" | ||
204 | " Skb's/buffers sent with packing : %u/%u\n\n", | ||
205 | card->stats.tx_packets - card->perf_stats.initial_tx_packets | ||
206 | - card->perf_stats.skbs_sent_pack, | ||
207 | card->perf_stats.bufs_sent - card->perf_stats.bufs_sent_pack, | ||
208 | card->perf_stats.skbs_sent_pack, | ||
209 | card->perf_stats.bufs_sent_pack | ||
210 | ); | ||
211 | seq_printf(s, " Skbs sent in SG mode : %u\n" | ||
212 | " Skb fragments sent in SG mode : %u\n\n", | ||
213 | card->perf_stats.sg_skbs_sent, | ||
214 | card->perf_stats.sg_frags_sent); | ||
215 | seq_printf(s, " Skbs received in SG mode : %u\n" | ||
216 | " Skb fragments received in SG mode : %u\n" | ||
217 | " Page allocations for rx SG mode : %u\n\n", | ||
218 | card->perf_stats.sg_skbs_rx, | ||
219 | card->perf_stats.sg_frags_rx, | ||
220 | card->perf_stats.sg_alloc_page_rx); | ||
221 | seq_printf(s, " large_send tx (in Kbytes) : %u\n" | ||
222 | " large_send count : %u\n\n", | ||
223 | card->perf_stats.large_send_bytes >> 10, | ||
224 | card->perf_stats.large_send_cnt); | ||
225 | seq_printf(s, " Packing state changes no pkg.->packing : %u/%u\n" | ||
226 | " Watermarks L/H : %i/%i\n" | ||
227 | " Current buffer usage (outbound q's) : " | ||
228 | "%i/%i/%i/%i\n\n", | ||
229 | card->perf_stats.sc_dp_p, card->perf_stats.sc_p_dp, | ||
230 | QETH_LOW_WATERMARK_PACK, QETH_HIGH_WATERMARK_PACK, | ||
231 | atomic_read(&card->qdio.out_qs[0]->used_buffers), | ||
232 | (card->qdio.no_out_queues > 1)? | ||
233 | atomic_read(&card->qdio.out_qs[1]->used_buffers) | ||
234 | : 0, | ||
235 | (card->qdio.no_out_queues > 2)? | ||
236 | atomic_read(&card->qdio.out_qs[2]->used_buffers) | ||
237 | : 0, | ||
238 | (card->qdio.no_out_queues > 3)? | ||
239 | atomic_read(&card->qdio.out_qs[3]->used_buffers) | ||
240 | : 0 | ||
241 | ); | ||
242 | seq_printf(s, " Inbound handler time (in us) : %u\n" | ||
243 | " Inbound handler count : %u\n" | ||
244 | " Inbound do_QDIO time (in us) : %u\n" | ||
245 | " Inbound do_QDIO count : %u\n\n" | ||
246 | " Outbound handler time (in us) : %u\n" | ||
247 | " Outbound handler count : %u\n\n" | ||
248 | " Outbound time (in us, incl QDIO) : %u\n" | ||
249 | " Outbound count : %u\n" | ||
250 | " Outbound do_QDIO time (in us) : %u\n" | ||
251 | " Outbound do_QDIO count : %u\n\n", | ||
252 | card->perf_stats.inbound_time, | ||
253 | card->perf_stats.inbound_cnt, | ||
254 | card->perf_stats.inbound_do_qdio_time, | ||
255 | card->perf_stats.inbound_do_qdio_cnt, | ||
256 | card->perf_stats.outbound_handler_time, | ||
257 | card->perf_stats.outbound_handler_cnt, | ||
258 | card->perf_stats.outbound_time, | ||
259 | card->perf_stats.outbound_cnt, | ||
260 | card->perf_stats.outbound_do_qdio_time, | ||
261 | card->perf_stats.outbound_do_qdio_cnt | ||
262 | ); | ||
263 | put_device(device); | ||
264 | return 0; | ||
265 | } | ||
266 | |||
267 | static const struct seq_operations qeth_perf_procfile_seq_ops = { | ||
268 | .start = qeth_procfile_seq_start, | ||
269 | .stop = qeth_procfile_seq_stop, | ||
270 | .next = qeth_procfile_seq_next, | ||
271 | .show = qeth_perf_procfile_seq_show, | ||
272 | }; | ||
273 | |||
274 | static int | ||
275 | qeth_perf_procfile_open(struct inode *inode, struct file *file) | ||
276 | { | ||
277 | return seq_open(file, &qeth_perf_procfile_seq_ops); | ||
278 | } | ||
279 | |||
280 | static const struct file_operations qeth_perf_procfile_fops = { | ||
281 | .owner = THIS_MODULE, | ||
282 | .open = qeth_perf_procfile_open, | ||
283 | .read = seq_read, | ||
284 | .llseek = seq_lseek, | ||
285 | .release = seq_release, | ||
286 | }; | ||
287 | |||
288 | int __init | ||
289 | qeth_create_procfs_entries(void) | ||
290 | { | ||
291 | qeth_procfile = create_proc_entry(QETH_PROCFILE_NAME, | ||
292 | S_IFREG | 0444, NULL); | ||
293 | if (qeth_procfile) | ||
294 | qeth_procfile->proc_fops = &qeth_procfile_fops; | ||
295 | |||
296 | qeth_perf_procfile = create_proc_entry(QETH_PERF_PROCFILE_NAME, | ||
297 | S_IFREG | 0444, NULL); | ||
298 | if (qeth_perf_procfile) | ||
299 | qeth_perf_procfile->proc_fops = &qeth_perf_procfile_fops; | ||
300 | |||
301 | if (qeth_procfile && | ||
302 | qeth_perf_procfile) | ||
303 | return 0; | ||
304 | else | ||
305 | return -ENOMEM; | ||
306 | } | ||
307 | |||
308 | void __exit | ||
309 | qeth_remove_procfs_entries(void) | ||
310 | { | ||
311 | if (qeth_procfile) | ||
312 | remove_proc_entry(QETH_PROCFILE_NAME, NULL); | ||
313 | if (qeth_perf_procfile) | ||
314 | remove_proc_entry(QETH_PERF_PROCFILE_NAME, NULL); | ||
315 | } | ||
316 | |||
diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c deleted file mode 100644 index 2cc3f3a0e393..000000000000 --- a/drivers/s390/net/qeth_sys.c +++ /dev/null | |||
@@ -1,1858 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * linux/drivers/s390/net/qeth_sys.c | ||
4 | * | ||
5 | * Linux on zSeries OSA Express and HiperSockets support | ||
6 | * This file contains code related to sysfs. | ||
7 | * | ||
8 | * Copyright 2000,2003 IBM Corporation | ||
9 | * | ||
10 | * Author(s): Thomas Spatzier <tspat@de.ibm.com> | ||
11 | * Frank Pavlic <fpavlic@de.ibm.com> | ||
12 | * | ||
13 | */ | ||
14 | #include <linux/list.h> | ||
15 | #include <linux/rwsem.h> | ||
16 | |||
17 | #include <asm/ebcdic.h> | ||
18 | |||
19 | #include "qeth.h" | ||
20 | #include "qeth_mpc.h" | ||
21 | #include "qeth_fs.h" | ||
22 | |||
23 | /*****************************************************************************/ | ||
24 | /* */ | ||
25 | /* /sys-fs stuff UNDER DEVELOPMENT !!! */ | ||
26 | /* */ | ||
27 | /*****************************************************************************/ | ||
28 | //low/high watermark | ||
29 | |||
30 | static ssize_t | ||
31 | qeth_dev_state_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
32 | { | ||
33 | struct qeth_card *card = dev->driver_data; | ||
34 | if (!card) | ||
35 | return -EINVAL; | ||
36 | |||
37 | switch (card->state) { | ||
38 | case CARD_STATE_DOWN: | ||
39 | return sprintf(buf, "DOWN\n"); | ||
40 | case CARD_STATE_HARDSETUP: | ||
41 | return sprintf(buf, "HARDSETUP\n"); | ||
42 | case CARD_STATE_SOFTSETUP: | ||
43 | return sprintf(buf, "SOFTSETUP\n"); | ||
44 | case CARD_STATE_UP: | ||
45 | if (card->lan_online) | ||
46 | return sprintf(buf, "UP (LAN ONLINE)\n"); | ||
47 | else | ||
48 | return sprintf(buf, "UP (LAN OFFLINE)\n"); | ||
49 | case CARD_STATE_RECOVER: | ||
50 | return sprintf(buf, "RECOVER\n"); | ||
51 | default: | ||
52 | return sprintf(buf, "UNKNOWN\n"); | ||
53 | } | ||
54 | } | ||
55 | |||
56 | static DEVICE_ATTR(state, 0444, qeth_dev_state_show, NULL); | ||
57 | |||
58 | static ssize_t | ||
59 | qeth_dev_chpid_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
60 | { | ||
61 | struct qeth_card *card = dev->driver_data; | ||
62 | if (!card) | ||
63 | return -EINVAL; | ||
64 | |||
65 | return sprintf(buf, "%02X\n", card->info.chpid); | ||
66 | } | ||
67 | |||
68 | static DEVICE_ATTR(chpid, 0444, qeth_dev_chpid_show, NULL); | ||
69 | |||
70 | static ssize_t | ||
71 | qeth_dev_if_name_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
72 | { | ||
73 | struct qeth_card *card = dev->driver_data; | ||
74 | if (!card) | ||
75 | return -EINVAL; | ||
76 | return sprintf(buf, "%s\n", QETH_CARD_IFNAME(card)); | ||
77 | } | ||
78 | |||
79 | static DEVICE_ATTR(if_name, 0444, qeth_dev_if_name_show, NULL); | ||
80 | |||
81 | static ssize_t | ||
82 | qeth_dev_card_type_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
83 | { | ||
84 | struct qeth_card *card = dev->driver_data; | ||
85 | if (!card) | ||
86 | return -EINVAL; | ||
87 | |||
88 | return sprintf(buf, "%s\n", qeth_get_cardname_short(card)); | ||
89 | } | ||
90 | |||
91 | static DEVICE_ATTR(card_type, 0444, qeth_dev_card_type_show, NULL); | ||
92 | |||
93 | static ssize_t | ||
94 | qeth_dev_portno_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
95 | { | ||
96 | struct qeth_card *card = dev->driver_data; | ||
97 | if (!card) | ||
98 | return -EINVAL; | ||
99 | |||
100 | return sprintf(buf, "%i\n", card->info.portno); | ||
101 | } | ||
102 | |||
103 | static ssize_t | ||
104 | qeth_dev_portno_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
105 | { | ||
106 | struct qeth_card *card = dev->driver_data; | ||
107 | char *tmp; | ||
108 | unsigned int portno; | ||
109 | |||
110 | if (!card) | ||
111 | return -EINVAL; | ||
112 | |||
113 | if ((card->state != CARD_STATE_DOWN) && | ||
114 | (card->state != CARD_STATE_RECOVER)) | ||
115 | return -EPERM; | ||
116 | |||
117 | portno = simple_strtoul(buf, &tmp, 16); | ||
118 | if (portno > MAX_PORTNO){ | ||
119 | PRINT_WARN("portno 0x%X is out of range\n", portno); | ||
120 | return -EINVAL; | ||
121 | } | ||
122 | |||
123 | card->info.portno = portno; | ||
124 | return count; | ||
125 | } | ||
126 | |||
127 | static DEVICE_ATTR(portno, 0644, qeth_dev_portno_show, qeth_dev_portno_store); | ||
128 | |||
129 | static ssize_t | ||
130 | qeth_dev_portname_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
131 | { | ||
132 | struct qeth_card *card = dev->driver_data; | ||
133 | char portname[9] = {0, }; | ||
134 | |||
135 | if (!card) | ||
136 | return -EINVAL; | ||
137 | |||
138 | if (card->info.portname_required) { | ||
139 | memcpy(portname, card->info.portname + 1, 8); | ||
140 | EBCASC(portname, 8); | ||
141 | return sprintf(buf, "%s\n", portname); | ||
142 | } else | ||
143 | return sprintf(buf, "no portname required\n"); | ||
144 | } | ||
145 | |||
146 | static ssize_t | ||
147 | qeth_dev_portname_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
148 | { | ||
149 | struct qeth_card *card = dev->driver_data; | ||
150 | char *tmp; | ||
151 | int i; | ||
152 | |||
153 | if (!card) | ||
154 | return -EINVAL; | ||
155 | |||
156 | if ((card->state != CARD_STATE_DOWN) && | ||
157 | (card->state != CARD_STATE_RECOVER)) | ||
158 | return -EPERM; | ||
159 | |||
160 | tmp = strsep((char **) &buf, "\n"); | ||
161 | if ((strlen(tmp) > 8) || (strlen(tmp) == 0)) | ||
162 | return -EINVAL; | ||
163 | |||
164 | card->info.portname[0] = strlen(tmp); | ||
165 | /* for beauty reasons */ | ||
166 | for (i = 1; i < 9; i++) | ||
167 | card->info.portname[i] = ' '; | ||
168 | strcpy(card->info.portname + 1, tmp); | ||
169 | ASCEBC(card->info.portname + 1, 8); | ||
170 | |||
171 | return count; | ||
172 | } | ||
173 | |||
174 | static DEVICE_ATTR(portname, 0644, qeth_dev_portname_show, | ||
175 | qeth_dev_portname_store); | ||
176 | |||
177 | static ssize_t | ||
178 | qeth_dev_checksum_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
179 | { | ||
180 | struct qeth_card *card = dev->driver_data; | ||
181 | |||
182 | if (!card) | ||
183 | return -EINVAL; | ||
184 | |||
185 | return sprintf(buf, "%s checksumming\n", qeth_get_checksum_str(card)); | ||
186 | } | ||
187 | |||
188 | static ssize_t | ||
189 | qeth_dev_checksum_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
190 | { | ||
191 | struct qeth_card *card = dev->driver_data; | ||
192 | char *tmp; | ||
193 | |||
194 | if (!card) | ||
195 | return -EINVAL; | ||
196 | |||
197 | if ((card->state != CARD_STATE_DOWN) && | ||
198 | (card->state != CARD_STATE_RECOVER)) | ||
199 | return -EPERM; | ||
200 | |||
201 | tmp = strsep((char **) &buf, "\n"); | ||
202 | if (!strcmp(tmp, "sw_checksumming")) | ||
203 | card->options.checksum_type = SW_CHECKSUMMING; | ||
204 | else if (!strcmp(tmp, "hw_checksumming")) | ||
205 | card->options.checksum_type = HW_CHECKSUMMING; | ||
206 | else if (!strcmp(tmp, "no_checksumming")) | ||
207 | card->options.checksum_type = NO_CHECKSUMMING; | ||
208 | else { | ||
209 | PRINT_WARN("Unknown checksumming type '%s'\n", tmp); | ||
210 | return -EINVAL; | ||
211 | } | ||
212 | return count; | ||
213 | } | ||
214 | |||
215 | static DEVICE_ATTR(checksumming, 0644, qeth_dev_checksum_show, | ||
216 | qeth_dev_checksum_store); | ||
217 | |||
218 | static ssize_t | ||
219 | qeth_dev_prioqing_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
220 | { | ||
221 | struct qeth_card *card = dev->driver_data; | ||
222 | |||
223 | if (!card) | ||
224 | return -EINVAL; | ||
225 | |||
226 | switch (card->qdio.do_prio_queueing) { | ||
227 | case QETH_PRIO_Q_ING_PREC: | ||
228 | return sprintf(buf, "%s\n", "by precedence"); | ||
229 | case QETH_PRIO_Q_ING_TOS: | ||
230 | return sprintf(buf, "%s\n", "by type of service"); | ||
231 | default: | ||
232 | return sprintf(buf, "always queue %i\n", | ||
233 | card->qdio.default_out_queue); | ||
234 | } | ||
235 | } | ||
236 | |||
237 | static ssize_t | ||
238 | qeth_dev_prioqing_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
239 | { | ||
240 | struct qeth_card *card = dev->driver_data; | ||
241 | char *tmp; | ||
242 | |||
243 | if (!card) | ||
244 | return -EINVAL; | ||
245 | |||
246 | if ((card->state != CARD_STATE_DOWN) && | ||
247 | (card->state != CARD_STATE_RECOVER)) | ||
248 | return -EPERM; | ||
249 | |||
250 | /* check if 1920 devices are supported , | ||
251 | * if though we have to permit priority queueing | ||
252 | */ | ||
253 | if (card->qdio.no_out_queues == 1) { | ||
254 | PRINT_WARN("Priority queueing disabled due " | ||
255 | "to hardware limitations!\n"); | ||
256 | card->qdio.do_prio_queueing = QETH_PRIOQ_DEFAULT; | ||
257 | return -EPERM; | ||
258 | } | ||
259 | |||
260 | tmp = strsep((char **) &buf, "\n"); | ||
261 | if (!strcmp(tmp, "prio_queueing_prec")) | ||
262 | card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_PREC; | ||
263 | else if (!strcmp(tmp, "prio_queueing_tos")) | ||
264 | card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_TOS; | ||
265 | else if (!strcmp(tmp, "no_prio_queueing:0")) { | ||
266 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; | ||
267 | card->qdio.default_out_queue = 0; | ||
268 | } else if (!strcmp(tmp, "no_prio_queueing:1")) { | ||
269 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; | ||
270 | card->qdio.default_out_queue = 1; | ||
271 | } else if (!strcmp(tmp, "no_prio_queueing:2")) { | ||
272 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; | ||
273 | card->qdio.default_out_queue = 2; | ||
274 | } else if (!strcmp(tmp, "no_prio_queueing:3")) { | ||
275 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; | ||
276 | card->qdio.default_out_queue = 3; | ||
277 | } else if (!strcmp(tmp, "no_prio_queueing")) { | ||
278 | card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; | ||
279 | card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; | ||
280 | } else { | ||
281 | PRINT_WARN("Unknown queueing type '%s'\n", tmp); | ||
282 | return -EINVAL; | ||
283 | } | ||
284 | return count; | ||
285 | } | ||
286 | |||
287 | static DEVICE_ATTR(priority_queueing, 0644, qeth_dev_prioqing_show, | ||
288 | qeth_dev_prioqing_store); | ||
289 | |||
290 | static ssize_t | ||
291 | qeth_dev_bufcnt_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
292 | { | ||
293 | struct qeth_card *card = dev->driver_data; | ||
294 | |||
295 | if (!card) | ||
296 | return -EINVAL; | ||
297 | |||
298 | return sprintf(buf, "%i\n", card->qdio.in_buf_pool.buf_count); | ||
299 | } | ||
300 | |||
301 | static ssize_t | ||
302 | qeth_dev_bufcnt_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
303 | { | ||
304 | struct qeth_card *card = dev->driver_data; | ||
305 | char *tmp; | ||
306 | int cnt, old_cnt; | ||
307 | int rc; | ||
308 | |||
309 | if (!card) | ||
310 | return -EINVAL; | ||
311 | |||
312 | if ((card->state != CARD_STATE_DOWN) && | ||
313 | (card->state != CARD_STATE_RECOVER)) | ||
314 | return -EPERM; | ||
315 | |||
316 | old_cnt = card->qdio.in_buf_pool.buf_count; | ||
317 | cnt = simple_strtoul(buf, &tmp, 10); | ||
318 | cnt = (cnt < QETH_IN_BUF_COUNT_MIN) ? QETH_IN_BUF_COUNT_MIN : | ||
319 | ((cnt > QETH_IN_BUF_COUNT_MAX) ? QETH_IN_BUF_COUNT_MAX : cnt); | ||
320 | if (old_cnt != cnt) { | ||
321 | if ((rc = qeth_realloc_buffer_pool(card, cnt))) | ||
322 | PRINT_WARN("Error (%d) while setting " | ||
323 | "buffer count.\n", rc); | ||
324 | } | ||
325 | return count; | ||
326 | } | ||
327 | |||
328 | static DEVICE_ATTR(buffer_count, 0644, qeth_dev_bufcnt_show, | ||
329 | qeth_dev_bufcnt_store); | ||
330 | |||
331 | static ssize_t | ||
332 | qeth_dev_route_show(struct qeth_card *card, struct qeth_routing_info *route, | ||
333 | char *buf) | ||
334 | { | ||
335 | switch (route->type) { | ||
336 | case PRIMARY_ROUTER: | ||
337 | return sprintf(buf, "%s\n", "primary router"); | ||
338 | case SECONDARY_ROUTER: | ||
339 | return sprintf(buf, "%s\n", "secondary router"); | ||
340 | case MULTICAST_ROUTER: | ||
341 | if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) | ||
342 | return sprintf(buf, "%s\n", "multicast router+"); | ||
343 | else | ||
344 | return sprintf(buf, "%s\n", "multicast router"); | ||
345 | case PRIMARY_CONNECTOR: | ||
346 | if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) | ||
347 | return sprintf(buf, "%s\n", "primary connector+"); | ||
348 | else | ||
349 | return sprintf(buf, "%s\n", "primary connector"); | ||
350 | case SECONDARY_CONNECTOR: | ||
351 | if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) | ||
352 | return sprintf(buf, "%s\n", "secondary connector+"); | ||
353 | else | ||
354 | return sprintf(buf, "%s\n", "secondary connector"); | ||
355 | default: | ||
356 | return sprintf(buf, "%s\n", "no"); | ||
357 | } | ||
358 | } | ||
359 | |||
360 | static ssize_t | ||
361 | qeth_dev_route4_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
362 | { | ||
363 | struct qeth_card *card = dev->driver_data; | ||
364 | |||
365 | if (!card) | ||
366 | return -EINVAL; | ||
367 | |||
368 | return qeth_dev_route_show(card, &card->options.route4, buf); | ||
369 | } | ||
370 | |||
371 | static ssize_t | ||
372 | qeth_dev_route_store(struct qeth_card *card, struct qeth_routing_info *route, | ||
373 | enum qeth_prot_versions prot, const char *buf, size_t count) | ||
374 | { | ||
375 | enum qeth_routing_types old_route_type = route->type; | ||
376 | char *tmp; | ||
377 | int rc; | ||
378 | |||
379 | tmp = strsep((char **) &buf, "\n"); | ||
380 | |||
381 | if (!strcmp(tmp, "no_router")){ | ||
382 | route->type = NO_ROUTER; | ||
383 | } else if (!strcmp(tmp, "primary_connector")) { | ||
384 | route->type = PRIMARY_CONNECTOR; | ||
385 | } else if (!strcmp(tmp, "secondary_connector")) { | ||
386 | route->type = SECONDARY_CONNECTOR; | ||
387 | } else if (!strcmp(tmp, "primary_router")) { | ||
388 | route->type = PRIMARY_ROUTER; | ||
389 | } else if (!strcmp(tmp, "secondary_router")) { | ||
390 | route->type = SECONDARY_ROUTER; | ||
391 | } else if (!strcmp(tmp, "multicast_router")) { | ||
392 | route->type = MULTICAST_ROUTER; | ||
393 | } else { | ||
394 | PRINT_WARN("Invalid routing type '%s'.\n", tmp); | ||
395 | return -EINVAL; | ||
396 | } | ||
397 | if (((card->state == CARD_STATE_SOFTSETUP) || | ||
398 | (card->state == CARD_STATE_UP)) && | ||
399 | (old_route_type != route->type)){ | ||
400 | if (prot == QETH_PROT_IPV4) | ||
401 | rc = qeth_setrouting_v4(card); | ||
402 | else if (prot == QETH_PROT_IPV6) | ||
403 | rc = qeth_setrouting_v6(card); | ||
404 | } | ||
405 | return count; | ||
406 | } | ||
407 | |||
408 | static ssize_t | ||
409 | qeth_dev_route4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
410 | { | ||
411 | struct qeth_card *card = dev->driver_data; | ||
412 | |||
413 | if (!card) | ||
414 | return -EINVAL; | ||
415 | |||
416 | return qeth_dev_route_store(card, &card->options.route4, | ||
417 | QETH_PROT_IPV4, buf, count); | ||
418 | } | ||
419 | |||
420 | static DEVICE_ATTR(route4, 0644, qeth_dev_route4_show, qeth_dev_route4_store); | ||
421 | |||
422 | #ifdef CONFIG_QETH_IPV6 | ||
423 | static ssize_t | ||
424 | qeth_dev_route6_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
425 | { | ||
426 | struct qeth_card *card = dev->driver_data; | ||
427 | |||
428 | if (!card) | ||
429 | return -EINVAL; | ||
430 | |||
431 | if (!qeth_is_supported(card, IPA_IPV6)) | ||
432 | return sprintf(buf, "%s\n", "n/a"); | ||
433 | |||
434 | return qeth_dev_route_show(card, &card->options.route6, buf); | ||
435 | } | ||
436 | |||
437 | static ssize_t | ||
438 | qeth_dev_route6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
439 | { | ||
440 | struct qeth_card *card = dev->driver_data; | ||
441 | |||
442 | if (!card) | ||
443 | return -EINVAL; | ||
444 | |||
445 | if (!qeth_is_supported(card, IPA_IPV6)){ | ||
446 | PRINT_WARN("IPv6 not supported for interface %s.\n" | ||
447 | "Routing status no changed.\n", | ||
448 | QETH_CARD_IFNAME(card)); | ||
449 | return -ENOTSUPP; | ||
450 | } | ||
451 | |||
452 | return qeth_dev_route_store(card, &card->options.route6, | ||
453 | QETH_PROT_IPV6, buf, count); | ||
454 | } | ||
455 | |||
456 | static DEVICE_ATTR(route6, 0644, qeth_dev_route6_show, qeth_dev_route6_store); | ||
457 | #endif | ||
458 | |||
459 | static ssize_t | ||
460 | qeth_dev_add_hhlen_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
461 | { | ||
462 | struct qeth_card *card = dev->driver_data; | ||
463 | |||
464 | if (!card) | ||
465 | return -EINVAL; | ||
466 | |||
467 | return sprintf(buf, "%i\n", card->options.add_hhlen); | ||
468 | } | ||
469 | |||
470 | static ssize_t | ||
471 | qeth_dev_add_hhlen_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
472 | { | ||
473 | struct qeth_card *card = dev->driver_data; | ||
474 | char *tmp; | ||
475 | int i; | ||
476 | |||
477 | if (!card) | ||
478 | return -EINVAL; | ||
479 | |||
480 | if ((card->state != CARD_STATE_DOWN) && | ||
481 | (card->state != CARD_STATE_RECOVER)) | ||
482 | return -EPERM; | ||
483 | |||
484 | i = simple_strtoul(buf, &tmp, 10); | ||
485 | if ((i < 0) || (i > MAX_ADD_HHLEN)) { | ||
486 | PRINT_WARN("add_hhlen out of range\n"); | ||
487 | return -EINVAL; | ||
488 | } | ||
489 | card->options.add_hhlen = i; | ||
490 | |||
491 | return count; | ||
492 | } | ||
493 | |||
494 | static DEVICE_ATTR(add_hhlen, 0644, qeth_dev_add_hhlen_show, | ||
495 | qeth_dev_add_hhlen_store); | ||
496 | |||
497 | static ssize_t | ||
498 | qeth_dev_fake_ll_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
499 | { | ||
500 | struct qeth_card *card = dev->driver_data; | ||
501 | |||
502 | if (!card) | ||
503 | return -EINVAL; | ||
504 | |||
505 | return sprintf(buf, "%i\n", card->options.fake_ll? 1:0); | ||
506 | } | ||
507 | |||
508 | static ssize_t | ||
509 | qeth_dev_fake_ll_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
510 | { | ||
511 | struct qeth_card *card = dev->driver_data; | ||
512 | char *tmp; | ||
513 | int i; | ||
514 | |||
515 | if (!card) | ||
516 | return -EINVAL; | ||
517 | |||
518 | if ((card->state != CARD_STATE_DOWN) && | ||
519 | (card->state != CARD_STATE_RECOVER)) | ||
520 | return -EPERM; | ||
521 | |||
522 | i = simple_strtoul(buf, &tmp, 16); | ||
523 | if ((i != 0) && (i != 1)) { | ||
524 | PRINT_WARN("fake_ll: write 0 or 1 to this file!\n"); | ||
525 | return -EINVAL; | ||
526 | } | ||
527 | card->options.fake_ll = i; | ||
528 | return count; | ||
529 | } | ||
530 | |||
531 | static DEVICE_ATTR(fake_ll, 0644, qeth_dev_fake_ll_show, | ||
532 | qeth_dev_fake_ll_store); | ||
533 | |||
534 | static ssize_t | ||
535 | qeth_dev_fake_broadcast_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
536 | { | ||
537 | struct qeth_card *card = dev->driver_data; | ||
538 | |||
539 | if (!card) | ||
540 | return -EINVAL; | ||
541 | |||
542 | return sprintf(buf, "%i\n", card->options.fake_broadcast? 1:0); | ||
543 | } | ||
544 | |||
545 | static ssize_t | ||
546 | qeth_dev_fake_broadcast_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
547 | { | ||
548 | struct qeth_card *card = dev->driver_data; | ||
549 | char *tmp; | ||
550 | int i; | ||
551 | |||
552 | if (!card) | ||
553 | return -EINVAL; | ||
554 | |||
555 | if ((card->state != CARD_STATE_DOWN) && | ||
556 | (card->state != CARD_STATE_RECOVER)) | ||
557 | return -EPERM; | ||
558 | |||
559 | i = simple_strtoul(buf, &tmp, 16); | ||
560 | if ((i == 0) || (i == 1)) | ||
561 | card->options.fake_broadcast = i; | ||
562 | else { | ||
563 | PRINT_WARN("fake_broadcast: write 0 or 1 to this file!\n"); | ||
564 | return -EINVAL; | ||
565 | } | ||
566 | return count; | ||
567 | } | ||
568 | |||
569 | static DEVICE_ATTR(fake_broadcast, 0644, qeth_dev_fake_broadcast_show, | ||
570 | qeth_dev_fake_broadcast_store); | ||
571 | |||
572 | static ssize_t | ||
573 | qeth_dev_recover_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
574 | { | ||
575 | struct qeth_card *card = dev->driver_data; | ||
576 | char *tmp; | ||
577 | int i; | ||
578 | |||
579 | if (!card) | ||
580 | return -EINVAL; | ||
581 | |||
582 | if (card->state != CARD_STATE_UP) | ||
583 | return -EPERM; | ||
584 | |||
585 | i = simple_strtoul(buf, &tmp, 16); | ||
586 | if (i == 1) | ||
587 | qeth_schedule_recovery(card); | ||
588 | |||
589 | return count; | ||
590 | } | ||
591 | |||
592 | static DEVICE_ATTR(recover, 0200, NULL, qeth_dev_recover_store); | ||
593 | |||
594 | static ssize_t | ||
595 | qeth_dev_broadcast_mode_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
596 | { | ||
597 | struct qeth_card *card = dev->driver_data; | ||
598 | |||
599 | if (!card) | ||
600 | return -EINVAL; | ||
601 | |||
602 | if (!((card->info.link_type == QETH_LINK_TYPE_HSTR) || | ||
603 | (card->info.link_type == QETH_LINK_TYPE_LANE_TR))) | ||
604 | return sprintf(buf, "n/a\n"); | ||
605 | |||
606 | return sprintf(buf, "%s\n", (card->options.broadcast_mode == | ||
607 | QETH_TR_BROADCAST_ALLRINGS)? | ||
608 | "all rings":"local"); | ||
609 | } | ||
610 | |||
611 | static ssize_t | ||
612 | qeth_dev_broadcast_mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
613 | { | ||
614 | struct qeth_card *card = dev->driver_data; | ||
615 | char *tmp; | ||
616 | |||
617 | if (!card) | ||
618 | return -EINVAL; | ||
619 | |||
620 | if ((card->state != CARD_STATE_DOWN) && | ||
621 | (card->state != CARD_STATE_RECOVER)) | ||
622 | return -EPERM; | ||
623 | |||
624 | if (!((card->info.link_type == QETH_LINK_TYPE_HSTR) || | ||
625 | (card->info.link_type == QETH_LINK_TYPE_LANE_TR))){ | ||
626 | PRINT_WARN("Device is not a tokenring device!\n"); | ||
627 | return -EINVAL; | ||
628 | } | ||
629 | |||
630 | tmp = strsep((char **) &buf, "\n"); | ||
631 | |||
632 | if (!strcmp(tmp, "local")){ | ||
633 | card->options.broadcast_mode = QETH_TR_BROADCAST_LOCAL; | ||
634 | return count; | ||
635 | } else if (!strcmp(tmp, "all_rings")) { | ||
636 | card->options.broadcast_mode = QETH_TR_BROADCAST_ALLRINGS; | ||
637 | return count; | ||
638 | } else { | ||
639 | PRINT_WARN("broadcast_mode: invalid mode %s!\n", | ||
640 | tmp); | ||
641 | return -EINVAL; | ||
642 | } | ||
643 | return count; | ||
644 | } | ||
645 | |||
646 | static DEVICE_ATTR(broadcast_mode, 0644, qeth_dev_broadcast_mode_show, | ||
647 | qeth_dev_broadcast_mode_store); | ||
648 | |||
649 | static ssize_t | ||
650 | qeth_dev_canonical_macaddr_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
651 | { | ||
652 | struct qeth_card *card = dev->driver_data; | ||
653 | |||
654 | if (!card) | ||
655 | return -EINVAL; | ||
656 | |||
657 | if (!((card->info.link_type == QETH_LINK_TYPE_HSTR) || | ||
658 | (card->info.link_type == QETH_LINK_TYPE_LANE_TR))) | ||
659 | return sprintf(buf, "n/a\n"); | ||
660 | |||
661 | return sprintf(buf, "%i\n", (card->options.macaddr_mode == | ||
662 | QETH_TR_MACADDR_CANONICAL)? 1:0); | ||
663 | } | ||
664 | |||
665 | static ssize_t | ||
666 | qeth_dev_canonical_macaddr_store(struct device *dev, struct device_attribute *attr, const char *buf, | ||
667 | size_t count) | ||
668 | { | ||
669 | struct qeth_card *card = dev->driver_data; | ||
670 | char *tmp; | ||
671 | int i; | ||
672 | |||
673 | if (!card) | ||
674 | return -EINVAL; | ||
675 | |||
676 | if ((card->state != CARD_STATE_DOWN) && | ||
677 | (card->state != CARD_STATE_RECOVER)) | ||
678 | return -EPERM; | ||
679 | |||
680 | if (!((card->info.link_type == QETH_LINK_TYPE_HSTR) || | ||
681 | (card->info.link_type == QETH_LINK_TYPE_LANE_TR))){ | ||
682 | PRINT_WARN("Device is not a tokenring device!\n"); | ||
683 | return -EINVAL; | ||
684 | } | ||
685 | |||
686 | i = simple_strtoul(buf, &tmp, 16); | ||
687 | if ((i == 0) || (i == 1)) | ||
688 | card->options.macaddr_mode = i? | ||
689 | QETH_TR_MACADDR_CANONICAL : | ||
690 | QETH_TR_MACADDR_NONCANONICAL; | ||
691 | else { | ||
692 | PRINT_WARN("canonical_macaddr: write 0 or 1 to this file!\n"); | ||
693 | return -EINVAL; | ||
694 | } | ||
695 | return count; | ||
696 | } | ||
697 | |||
698 | static DEVICE_ATTR(canonical_macaddr, 0644, qeth_dev_canonical_macaddr_show, | ||
699 | qeth_dev_canonical_macaddr_store); | ||
700 | |||
701 | static ssize_t | ||
702 | qeth_dev_layer2_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
703 | { | ||
704 | struct qeth_card *card = dev->driver_data; | ||
705 | |||
706 | if (!card) | ||
707 | return -EINVAL; | ||
708 | |||
709 | return sprintf(buf, "%i\n", card->options.layer2 ? 1:0); | ||
710 | } | ||
711 | |||
712 | static ssize_t | ||
713 | qeth_dev_layer2_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
714 | { | ||
715 | struct qeth_card *card = dev->driver_data; | ||
716 | char *tmp; | ||
717 | int i; | ||
718 | |||
719 | if (!card) | ||
720 | return -EINVAL; | ||
721 | if (card->info.type == QETH_CARD_TYPE_IQD) { | ||
722 | PRINT_WARN("Layer2 on Hipersockets is not supported! \n"); | ||
723 | return -EPERM; | ||
724 | } | ||
725 | |||
726 | if (((card->state != CARD_STATE_DOWN) && | ||
727 | (card->state != CARD_STATE_RECOVER))) | ||
728 | return -EPERM; | ||
729 | |||
730 | i = simple_strtoul(buf, &tmp, 16); | ||
731 | if ((i == 0) || (i == 1)) | ||
732 | card->options.layer2 = i; | ||
733 | else { | ||
734 | PRINT_WARN("layer2: write 0 or 1 to this file!\n"); | ||
735 | return -EINVAL; | ||
736 | } | ||
737 | return count; | ||
738 | } | ||
739 | |||
740 | static DEVICE_ATTR(layer2, 0644, qeth_dev_layer2_show, | ||
741 | qeth_dev_layer2_store); | ||
742 | |||
743 | static ssize_t | ||
744 | qeth_dev_performance_stats_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
745 | { | ||
746 | struct qeth_card *card = dev->driver_data; | ||
747 | |||
748 | if (!card) | ||
749 | return -EINVAL; | ||
750 | |||
751 | return sprintf(buf, "%i\n", card->options.performance_stats ? 1:0); | ||
752 | } | ||
753 | |||
754 | static ssize_t | ||
755 | qeth_dev_performance_stats_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
756 | { | ||
757 | struct qeth_card *card = dev->driver_data; | ||
758 | char *tmp; | ||
759 | int i; | ||
760 | |||
761 | if (!card) | ||
762 | return -EINVAL; | ||
763 | |||
764 | i = simple_strtoul(buf, &tmp, 16); | ||
765 | if ((i == 0) || (i == 1)) { | ||
766 | if (i == card->options.performance_stats) | ||
767 | return count; | ||
768 | card->options.performance_stats = i; | ||
769 | if (i == 0) | ||
770 | memset(&card->perf_stats, 0, | ||
771 | sizeof(struct qeth_perf_stats)); | ||
772 | card->perf_stats.initial_rx_packets = card->stats.rx_packets; | ||
773 | card->perf_stats.initial_tx_packets = card->stats.tx_packets; | ||
774 | } else { | ||
775 | PRINT_WARN("performance_stats: write 0 or 1 to this file!\n"); | ||
776 | return -EINVAL; | ||
777 | } | ||
778 | return count; | ||
779 | } | ||
780 | |||
781 | static DEVICE_ATTR(performance_stats, 0644, qeth_dev_performance_stats_show, | ||
782 | qeth_dev_performance_stats_store); | ||
783 | |||
784 | static ssize_t | ||
785 | qeth_dev_large_send_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
786 | { | ||
787 | struct qeth_card *card = dev->driver_data; | ||
788 | |||
789 | if (!card) | ||
790 | return -EINVAL; | ||
791 | |||
792 | switch (card->options.large_send) { | ||
793 | case QETH_LARGE_SEND_NO: | ||
794 | return sprintf(buf, "%s\n", "no"); | ||
795 | case QETH_LARGE_SEND_EDDP: | ||
796 | return sprintf(buf, "%s\n", "EDDP"); | ||
797 | case QETH_LARGE_SEND_TSO: | ||
798 | return sprintf(buf, "%s\n", "TSO"); | ||
799 | default: | ||
800 | return sprintf(buf, "%s\n", "N/A"); | ||
801 | } | ||
802 | } | ||
803 | |||
804 | static ssize_t | ||
805 | qeth_dev_large_send_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
806 | { | ||
807 | struct qeth_card *card = dev->driver_data; | ||
808 | enum qeth_large_send_types type; | ||
809 | int rc = 0; | ||
810 | char *tmp; | ||
811 | |||
812 | if (!card) | ||
813 | return -EINVAL; | ||
814 | tmp = strsep((char **) &buf, "\n"); | ||
815 | if (!strcmp(tmp, "no")){ | ||
816 | type = QETH_LARGE_SEND_NO; | ||
817 | } else if (!strcmp(tmp, "EDDP")) { | ||
818 | type = QETH_LARGE_SEND_EDDP; | ||
819 | } else if (!strcmp(tmp, "TSO")) { | ||
820 | type = QETH_LARGE_SEND_TSO; | ||
821 | } else { | ||
822 | PRINT_WARN("large_send: invalid mode %s!\n", tmp); | ||
823 | return -EINVAL; | ||
824 | } | ||
825 | if (card->options.large_send == type) | ||
826 | return count; | ||
827 | if ((rc = qeth_set_large_send(card, type))) | ||
828 | return rc; | ||
829 | return count; | ||
830 | } | ||
831 | |||
832 | static DEVICE_ATTR(large_send, 0644, qeth_dev_large_send_show, | ||
833 | qeth_dev_large_send_store); | ||
834 | |||
835 | static ssize_t | ||
836 | qeth_dev_blkt_show(char *buf, struct qeth_card *card, int value ) | ||
837 | { | ||
838 | |||
839 | if (!card) | ||
840 | return -EINVAL; | ||
841 | |||
842 | return sprintf(buf, "%i\n", value); | ||
843 | } | ||
844 | |||
845 | static ssize_t | ||
846 | qeth_dev_blkt_store(struct qeth_card *card, const char *buf, size_t count, | ||
847 | int *value, int max_value) | ||
848 | { | ||
849 | char *tmp; | ||
850 | int i; | ||
851 | |||
852 | if (!card) | ||
853 | return -EINVAL; | ||
854 | |||
855 | if ((card->state != CARD_STATE_DOWN) && | ||
856 | (card->state != CARD_STATE_RECOVER)) | ||
857 | return -EPERM; | ||
858 | |||
859 | i = simple_strtoul(buf, &tmp, 10); | ||
860 | if (i <= max_value) { | ||
861 | *value = i; | ||
862 | } else { | ||
863 | PRINT_WARN("blkt total time: write values between" | ||
864 | " 0 and %d to this file!\n", max_value); | ||
865 | return -EINVAL; | ||
866 | } | ||
867 | return count; | ||
868 | } | ||
869 | |||
870 | static ssize_t | ||
871 | qeth_dev_blkt_total_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
872 | { | ||
873 | struct qeth_card *card = dev->driver_data; | ||
874 | |||
875 | return qeth_dev_blkt_show(buf, card, card->info.blkt.time_total); | ||
876 | } | ||
877 | |||
878 | |||
879 | static ssize_t | ||
880 | qeth_dev_blkt_total_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
881 | { | ||
882 | struct qeth_card *card = dev->driver_data; | ||
883 | |||
884 | return qeth_dev_blkt_store(card, buf, count, | ||
885 | &card->info.blkt.time_total,1000); | ||
886 | } | ||
887 | |||
888 | |||
889 | |||
890 | static DEVICE_ATTR(total, 0644, qeth_dev_blkt_total_show, | ||
891 | qeth_dev_blkt_total_store); | ||
892 | |||
893 | static ssize_t | ||
894 | qeth_dev_blkt_inter_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
895 | { | ||
896 | struct qeth_card *card = dev->driver_data; | ||
897 | |||
898 | return qeth_dev_blkt_show(buf, card, card->info.blkt.inter_packet); | ||
899 | } | ||
900 | |||
901 | |||
902 | static ssize_t | ||
903 | qeth_dev_blkt_inter_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
904 | { | ||
905 | struct qeth_card *card = dev->driver_data; | ||
906 | |||
907 | return qeth_dev_blkt_store(card, buf, count, | ||
908 | &card->info.blkt.inter_packet,100); | ||
909 | } | ||
910 | |||
911 | static DEVICE_ATTR(inter, 0644, qeth_dev_blkt_inter_show, | ||
912 | qeth_dev_blkt_inter_store); | ||
913 | |||
914 | static ssize_t | ||
915 | qeth_dev_blkt_inter_jumbo_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
916 | { | ||
917 | struct qeth_card *card = dev->driver_data; | ||
918 | |||
919 | return qeth_dev_blkt_show(buf, card, | ||
920 | card->info.blkt.inter_packet_jumbo); | ||
921 | } | ||
922 | |||
923 | |||
924 | static ssize_t | ||
925 | qeth_dev_blkt_inter_jumbo_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
926 | { | ||
927 | struct qeth_card *card = dev->driver_data; | ||
928 | |||
929 | return qeth_dev_blkt_store(card, buf, count, | ||
930 | &card->info.blkt.inter_packet_jumbo,100); | ||
931 | } | ||
932 | |||
933 | static DEVICE_ATTR(inter_jumbo, 0644, qeth_dev_blkt_inter_jumbo_show, | ||
934 | qeth_dev_blkt_inter_jumbo_store); | ||
935 | |||
936 | static struct device_attribute * qeth_blkt_device_attrs[] = { | ||
937 | &dev_attr_total, | ||
938 | &dev_attr_inter, | ||
939 | &dev_attr_inter_jumbo, | ||
940 | NULL, | ||
941 | }; | ||
942 | |||
943 | static struct attribute_group qeth_device_blkt_group = { | ||
944 | .name = "blkt", | ||
945 | .attrs = (struct attribute **)qeth_blkt_device_attrs, | ||
946 | }; | ||
947 | |||
948 | static struct device_attribute * qeth_device_attrs[] = { | ||
949 | &dev_attr_state, | ||
950 | &dev_attr_chpid, | ||
951 | &dev_attr_if_name, | ||
952 | &dev_attr_card_type, | ||
953 | &dev_attr_portno, | ||
954 | &dev_attr_portname, | ||
955 | &dev_attr_checksumming, | ||
956 | &dev_attr_priority_queueing, | ||
957 | &dev_attr_buffer_count, | ||
958 | &dev_attr_route4, | ||
959 | #ifdef CONFIG_QETH_IPV6 | ||
960 | &dev_attr_route6, | ||
961 | #endif | ||
962 | &dev_attr_add_hhlen, | ||
963 | &dev_attr_fake_ll, | ||
964 | &dev_attr_fake_broadcast, | ||
965 | &dev_attr_recover, | ||
966 | &dev_attr_broadcast_mode, | ||
967 | &dev_attr_canonical_macaddr, | ||
968 | &dev_attr_layer2, | ||
969 | &dev_attr_large_send, | ||
970 | &dev_attr_performance_stats, | ||
971 | NULL, | ||
972 | }; | ||
973 | |||
974 | static struct attribute_group qeth_device_attr_group = { | ||
975 | .attrs = (struct attribute **)qeth_device_attrs, | ||
976 | }; | ||
977 | |||
978 | static struct device_attribute * qeth_osn_device_attrs[] = { | ||
979 | &dev_attr_state, | ||
980 | &dev_attr_chpid, | ||
981 | &dev_attr_if_name, | ||
982 | &dev_attr_card_type, | ||
983 | &dev_attr_buffer_count, | ||
984 | &dev_attr_recover, | ||
985 | NULL, | ||
986 | }; | ||
987 | |||
988 | static struct attribute_group qeth_osn_device_attr_group = { | ||
989 | .attrs = (struct attribute **)qeth_osn_device_attrs, | ||
990 | }; | ||
991 | |||
992 | #define QETH_DEVICE_ATTR(_id,_name,_mode,_show,_store) \ | ||
993 | struct device_attribute dev_attr_##_id = { \ | ||
994 | .attr = {.name=__stringify(_name), .mode=_mode, },\ | ||
995 | .show = _show, \ | ||
996 | .store = _store, \ | ||
997 | }; | ||
998 | |||
999 | static int | ||
1000 | qeth_check_layer2(struct qeth_card *card) | ||
1001 | { | ||
1002 | if (card->options.layer2) | ||
1003 | return -EPERM; | ||
1004 | return 0; | ||
1005 | } | ||
1006 | |||
1007 | |||
1008 | static ssize_t | ||
1009 | qeth_dev_ipato_enable_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
1010 | { | ||
1011 | struct qeth_card *card = dev->driver_data; | ||
1012 | |||
1013 | if (!card) | ||
1014 | return -EINVAL; | ||
1015 | |||
1016 | if (qeth_check_layer2(card)) | ||
1017 | return -EPERM; | ||
1018 | return sprintf(buf, "%i\n", card->ipato.enabled? 1:0); | ||
1019 | } | ||
1020 | |||
1021 | static ssize_t | ||
1022 | qeth_dev_ipato_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1023 | { | ||
1024 | struct qeth_card *card = dev->driver_data; | ||
1025 | char *tmp; | ||
1026 | |||
1027 | if (!card) | ||
1028 | return -EINVAL; | ||
1029 | |||
1030 | if ((card->state != CARD_STATE_DOWN) && | ||
1031 | (card->state != CARD_STATE_RECOVER)) | ||
1032 | return -EPERM; | ||
1033 | |||
1034 | if (qeth_check_layer2(card)) | ||
1035 | return -EPERM; | ||
1036 | |||
1037 | tmp = strsep((char **) &buf, "\n"); | ||
1038 | if (!strcmp(tmp, "toggle")){ | ||
1039 | card->ipato.enabled = (card->ipato.enabled)? 0 : 1; | ||
1040 | } else if (!strcmp(tmp, "1")){ | ||
1041 | card->ipato.enabled = 1; | ||
1042 | } else if (!strcmp(tmp, "0")){ | ||
1043 | card->ipato.enabled = 0; | ||
1044 | } else { | ||
1045 | PRINT_WARN("ipato_enable: write 0, 1 or 'toggle' to " | ||
1046 | "this file\n"); | ||
1047 | return -EINVAL; | ||
1048 | } | ||
1049 | return count; | ||
1050 | } | ||
1051 | |||
1052 | static QETH_DEVICE_ATTR(ipato_enable, enable, 0644, | ||
1053 | qeth_dev_ipato_enable_show, | ||
1054 | qeth_dev_ipato_enable_store); | ||
1055 | |||
1056 | static ssize_t | ||
1057 | qeth_dev_ipato_invert4_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
1058 | { | ||
1059 | struct qeth_card *card = dev->driver_data; | ||
1060 | |||
1061 | if (!card) | ||
1062 | return -EINVAL; | ||
1063 | |||
1064 | if (qeth_check_layer2(card)) | ||
1065 | return -EPERM; | ||
1066 | |||
1067 | return sprintf(buf, "%i\n", card->ipato.invert4? 1:0); | ||
1068 | } | ||
1069 | |||
1070 | static ssize_t | ||
1071 | qeth_dev_ipato_invert4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1072 | { | ||
1073 | struct qeth_card *card = dev->driver_data; | ||
1074 | char *tmp; | ||
1075 | |||
1076 | if (!card) | ||
1077 | return -EINVAL; | ||
1078 | |||
1079 | if (qeth_check_layer2(card)) | ||
1080 | return -EPERM; | ||
1081 | |||
1082 | tmp = strsep((char **) &buf, "\n"); | ||
1083 | if (!strcmp(tmp, "toggle")){ | ||
1084 | card->ipato.invert4 = (card->ipato.invert4)? 0 : 1; | ||
1085 | } else if (!strcmp(tmp, "1")){ | ||
1086 | card->ipato.invert4 = 1; | ||
1087 | } else if (!strcmp(tmp, "0")){ | ||
1088 | card->ipato.invert4 = 0; | ||
1089 | } else { | ||
1090 | PRINT_WARN("ipato_invert4: write 0, 1 or 'toggle' to " | ||
1091 | "this file\n"); | ||
1092 | return -EINVAL; | ||
1093 | } | ||
1094 | return count; | ||
1095 | } | ||
1096 | |||
1097 | static QETH_DEVICE_ATTR(ipato_invert4, invert4, 0644, | ||
1098 | qeth_dev_ipato_invert4_show, | ||
1099 | qeth_dev_ipato_invert4_store); | ||
1100 | |||
1101 | static ssize_t | ||
1102 | qeth_dev_ipato_add_show(char *buf, struct qeth_card *card, | ||
1103 | enum qeth_prot_versions proto) | ||
1104 | { | ||
1105 | struct qeth_ipato_entry *ipatoe; | ||
1106 | unsigned long flags; | ||
1107 | char addr_str[40]; | ||
1108 | int entry_len; /* length of 1 entry string, differs between v4 and v6 */ | ||
1109 | int i = 0; | ||
1110 | |||
1111 | if (qeth_check_layer2(card)) | ||
1112 | return -EPERM; | ||
1113 | |||
1114 | entry_len = (proto == QETH_PROT_IPV4)? 12 : 40; | ||
1115 | /* add strlen for "/<mask>\n" */ | ||
1116 | entry_len += (proto == QETH_PROT_IPV4)? 5 : 6; | ||
1117 | spin_lock_irqsave(&card->ip_lock, flags); | ||
1118 | list_for_each_entry(ipatoe, &card->ipato.entries, entry){ | ||
1119 | if (ipatoe->proto != proto) | ||
1120 | continue; | ||
1121 | /* String must not be longer than PAGE_SIZE. So we check if | ||
1122 | * string length gets near PAGE_SIZE. Then we can savely display | ||
1123 | * the next IPv6 address (worst case, compared to IPv4) */ | ||
1124 | if ((PAGE_SIZE - i) <= entry_len) | ||
1125 | break; | ||
1126 | qeth_ipaddr_to_string(proto, ipatoe->addr, addr_str); | ||
1127 | i += snprintf(buf + i, PAGE_SIZE - i, | ||
1128 | "%s/%i\n", addr_str, ipatoe->mask_bits); | ||
1129 | } | ||
1130 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
1131 | i += snprintf(buf + i, PAGE_SIZE - i, "\n"); | ||
1132 | |||
1133 | return i; | ||
1134 | } | ||
1135 | |||
1136 | static ssize_t | ||
1137 | qeth_dev_ipato_add4_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
1138 | { | ||
1139 | struct qeth_card *card = dev->driver_data; | ||
1140 | |||
1141 | if (!card) | ||
1142 | return -EINVAL; | ||
1143 | |||
1144 | return qeth_dev_ipato_add_show(buf, card, QETH_PROT_IPV4); | ||
1145 | } | ||
1146 | |||
1147 | static int | ||
1148 | qeth_parse_ipatoe(const char* buf, enum qeth_prot_versions proto, | ||
1149 | u8 *addr, int *mask_bits) | ||
1150 | { | ||
1151 | const char *start, *end; | ||
1152 | char *tmp; | ||
1153 | char buffer[40] = {0, }; | ||
1154 | |||
1155 | start = buf; | ||
1156 | /* get address string */ | ||
1157 | end = strchr(start, '/'); | ||
1158 | if (!end || (end - start >= 40)){ | ||
1159 | PRINT_WARN("Invalid format for ipato_addx/delx. " | ||
1160 | "Use <ip addr>/<mask bits>\n"); | ||
1161 | return -EINVAL; | ||
1162 | } | ||
1163 | strncpy(buffer, start, end - start); | ||
1164 | if (qeth_string_to_ipaddr(buffer, proto, addr)){ | ||
1165 | PRINT_WARN("Invalid IP address format!\n"); | ||
1166 | return -EINVAL; | ||
1167 | } | ||
1168 | start = end + 1; | ||
1169 | *mask_bits = simple_strtoul(start, &tmp, 10); | ||
1170 | if (!strlen(start) || | ||
1171 | (tmp == start) || | ||
1172 | (*mask_bits > ((proto == QETH_PROT_IPV4) ? 32 : 128))) { | ||
1173 | PRINT_WARN("Invalid mask bits for ipato_addx/delx !\n"); | ||
1174 | return -EINVAL; | ||
1175 | } | ||
1176 | return 0; | ||
1177 | } | ||
1178 | |||
1179 | static ssize_t | ||
1180 | qeth_dev_ipato_add_store(const char *buf, size_t count, | ||
1181 | struct qeth_card *card, enum qeth_prot_versions proto) | ||
1182 | { | ||
1183 | struct qeth_ipato_entry *ipatoe; | ||
1184 | u8 addr[16]; | ||
1185 | int mask_bits; | ||
1186 | int rc; | ||
1187 | |||
1188 | if (qeth_check_layer2(card)) | ||
1189 | return -EPERM; | ||
1190 | if ((rc = qeth_parse_ipatoe(buf, proto, addr, &mask_bits))) | ||
1191 | return rc; | ||
1192 | |||
1193 | if (!(ipatoe = kzalloc(sizeof(struct qeth_ipato_entry), GFP_KERNEL))){ | ||
1194 | PRINT_WARN("No memory to allocate ipato entry\n"); | ||
1195 | return -ENOMEM; | ||
1196 | } | ||
1197 | ipatoe->proto = proto; | ||
1198 | memcpy(ipatoe->addr, addr, (proto == QETH_PROT_IPV4)? 4:16); | ||
1199 | ipatoe->mask_bits = mask_bits; | ||
1200 | |||
1201 | if ((rc = qeth_add_ipato_entry(card, ipatoe))){ | ||
1202 | kfree(ipatoe); | ||
1203 | return rc; | ||
1204 | } | ||
1205 | |||
1206 | return count; | ||
1207 | } | ||
1208 | |||
1209 | static ssize_t | ||
1210 | qeth_dev_ipato_add4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1211 | { | ||
1212 | struct qeth_card *card = dev->driver_data; | ||
1213 | |||
1214 | if (!card) | ||
1215 | return -EINVAL; | ||
1216 | |||
1217 | return qeth_dev_ipato_add_store(buf, count, card, QETH_PROT_IPV4); | ||
1218 | } | ||
1219 | |||
1220 | static QETH_DEVICE_ATTR(ipato_add4, add4, 0644, | ||
1221 | qeth_dev_ipato_add4_show, | ||
1222 | qeth_dev_ipato_add4_store); | ||
1223 | |||
1224 | static ssize_t | ||
1225 | qeth_dev_ipato_del_store(const char *buf, size_t count, | ||
1226 | struct qeth_card *card, enum qeth_prot_versions proto) | ||
1227 | { | ||
1228 | u8 addr[16]; | ||
1229 | int mask_bits; | ||
1230 | int rc; | ||
1231 | |||
1232 | if (qeth_check_layer2(card)) | ||
1233 | return -EPERM; | ||
1234 | if ((rc = qeth_parse_ipatoe(buf, proto, addr, &mask_bits))) | ||
1235 | return rc; | ||
1236 | |||
1237 | qeth_del_ipato_entry(card, proto, addr, mask_bits); | ||
1238 | |||
1239 | return count; | ||
1240 | } | ||
1241 | |||
1242 | static ssize_t | ||
1243 | qeth_dev_ipato_del4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1244 | { | ||
1245 | struct qeth_card *card = dev->driver_data; | ||
1246 | |||
1247 | if (!card) | ||
1248 | return -EINVAL; | ||
1249 | |||
1250 | return qeth_dev_ipato_del_store(buf, count, card, QETH_PROT_IPV4); | ||
1251 | } | ||
1252 | |||
1253 | static QETH_DEVICE_ATTR(ipato_del4, del4, 0200, NULL, | ||
1254 | qeth_dev_ipato_del4_store); | ||
1255 | |||
1256 | #ifdef CONFIG_QETH_IPV6 | ||
1257 | static ssize_t | ||
1258 | qeth_dev_ipato_invert6_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
1259 | { | ||
1260 | struct qeth_card *card = dev->driver_data; | ||
1261 | |||
1262 | if (!card) | ||
1263 | return -EINVAL; | ||
1264 | |||
1265 | if (qeth_check_layer2(card)) | ||
1266 | return -EPERM; | ||
1267 | |||
1268 | return sprintf(buf, "%i\n", card->ipato.invert6? 1:0); | ||
1269 | } | ||
1270 | |||
1271 | static ssize_t | ||
1272 | qeth_dev_ipato_invert6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1273 | { | ||
1274 | struct qeth_card *card = dev->driver_data; | ||
1275 | char *tmp; | ||
1276 | |||
1277 | if (!card) | ||
1278 | return -EINVAL; | ||
1279 | |||
1280 | if (qeth_check_layer2(card)) | ||
1281 | return -EPERM; | ||
1282 | |||
1283 | tmp = strsep((char **) &buf, "\n"); | ||
1284 | if (!strcmp(tmp, "toggle")){ | ||
1285 | card->ipato.invert6 = (card->ipato.invert6)? 0 : 1; | ||
1286 | } else if (!strcmp(tmp, "1")){ | ||
1287 | card->ipato.invert6 = 1; | ||
1288 | } else if (!strcmp(tmp, "0")){ | ||
1289 | card->ipato.invert6 = 0; | ||
1290 | } else { | ||
1291 | PRINT_WARN("ipato_invert6: write 0, 1 or 'toggle' to " | ||
1292 | "this file\n"); | ||
1293 | return -EINVAL; | ||
1294 | } | ||
1295 | return count; | ||
1296 | } | ||
1297 | |||
1298 | static QETH_DEVICE_ATTR(ipato_invert6, invert6, 0644, | ||
1299 | qeth_dev_ipato_invert6_show, | ||
1300 | qeth_dev_ipato_invert6_store); | ||
1301 | |||
1302 | |||
1303 | static ssize_t | ||
1304 | qeth_dev_ipato_add6_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
1305 | { | ||
1306 | struct qeth_card *card = dev->driver_data; | ||
1307 | |||
1308 | if (!card) | ||
1309 | return -EINVAL; | ||
1310 | |||
1311 | return qeth_dev_ipato_add_show(buf, card, QETH_PROT_IPV6); | ||
1312 | } | ||
1313 | |||
1314 | static ssize_t | ||
1315 | qeth_dev_ipato_add6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1316 | { | ||
1317 | struct qeth_card *card = dev->driver_data; | ||
1318 | |||
1319 | if (!card) | ||
1320 | return -EINVAL; | ||
1321 | |||
1322 | return qeth_dev_ipato_add_store(buf, count, card, QETH_PROT_IPV6); | ||
1323 | } | ||
1324 | |||
1325 | static QETH_DEVICE_ATTR(ipato_add6, add6, 0644, | ||
1326 | qeth_dev_ipato_add6_show, | ||
1327 | qeth_dev_ipato_add6_store); | ||
1328 | |||
1329 | static ssize_t | ||
1330 | qeth_dev_ipato_del6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1331 | { | ||
1332 | struct qeth_card *card = dev->driver_data; | ||
1333 | |||
1334 | if (!card) | ||
1335 | return -EINVAL; | ||
1336 | |||
1337 | return qeth_dev_ipato_del_store(buf, count, card, QETH_PROT_IPV6); | ||
1338 | } | ||
1339 | |||
1340 | static QETH_DEVICE_ATTR(ipato_del6, del6, 0200, NULL, | ||
1341 | qeth_dev_ipato_del6_store); | ||
1342 | #endif /* CONFIG_QETH_IPV6 */ | ||
1343 | |||
1344 | static struct device_attribute * qeth_ipato_device_attrs[] = { | ||
1345 | &dev_attr_ipato_enable, | ||
1346 | &dev_attr_ipato_invert4, | ||
1347 | &dev_attr_ipato_add4, | ||
1348 | &dev_attr_ipato_del4, | ||
1349 | #ifdef CONFIG_QETH_IPV6 | ||
1350 | &dev_attr_ipato_invert6, | ||
1351 | &dev_attr_ipato_add6, | ||
1352 | &dev_attr_ipato_del6, | ||
1353 | #endif | ||
1354 | NULL, | ||
1355 | }; | ||
1356 | |||
1357 | static struct attribute_group qeth_device_ipato_group = { | ||
1358 | .name = "ipa_takeover", | ||
1359 | .attrs = (struct attribute **)qeth_ipato_device_attrs, | ||
1360 | }; | ||
1361 | |||
1362 | static ssize_t | ||
1363 | qeth_dev_vipa_add_show(char *buf, struct qeth_card *card, | ||
1364 | enum qeth_prot_versions proto) | ||
1365 | { | ||
1366 | struct qeth_ipaddr *ipaddr; | ||
1367 | char addr_str[40]; | ||
1368 | int entry_len; /* length of 1 entry string, differs between v4 and v6 */ | ||
1369 | unsigned long flags; | ||
1370 | int i = 0; | ||
1371 | |||
1372 | if (qeth_check_layer2(card)) | ||
1373 | return -EPERM; | ||
1374 | |||
1375 | entry_len = (proto == QETH_PROT_IPV4)? 12 : 40; | ||
1376 | entry_len += 2; /* \n + terminator */ | ||
1377 | spin_lock_irqsave(&card->ip_lock, flags); | ||
1378 | list_for_each_entry(ipaddr, &card->ip_list, entry){ | ||
1379 | if (ipaddr->proto != proto) | ||
1380 | continue; | ||
1381 | if (ipaddr->type != QETH_IP_TYPE_VIPA) | ||
1382 | continue; | ||
1383 | /* String must not be longer than PAGE_SIZE. So we check if | ||
1384 | * string length gets near PAGE_SIZE. Then we can savely display | ||
1385 | * the next IPv6 address (worst case, compared to IPv4) */ | ||
1386 | if ((PAGE_SIZE - i) <= entry_len) | ||
1387 | break; | ||
1388 | qeth_ipaddr_to_string(proto, (const u8 *)&ipaddr->u, addr_str); | ||
1389 | i += snprintf(buf + i, PAGE_SIZE - i, "%s\n", addr_str); | ||
1390 | } | ||
1391 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
1392 | i += snprintf(buf + i, PAGE_SIZE - i, "\n"); | ||
1393 | |||
1394 | return i; | ||
1395 | } | ||
1396 | |||
1397 | static ssize_t | ||
1398 | qeth_dev_vipa_add4_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
1399 | { | ||
1400 | struct qeth_card *card = dev->driver_data; | ||
1401 | |||
1402 | if (!card) | ||
1403 | return -EINVAL; | ||
1404 | |||
1405 | return qeth_dev_vipa_add_show(buf, card, QETH_PROT_IPV4); | ||
1406 | } | ||
1407 | |||
1408 | static int | ||
1409 | qeth_parse_vipae(const char* buf, enum qeth_prot_versions proto, | ||
1410 | u8 *addr) | ||
1411 | { | ||
1412 | if (qeth_string_to_ipaddr(buf, proto, addr)){ | ||
1413 | PRINT_WARN("Invalid IP address format!\n"); | ||
1414 | return -EINVAL; | ||
1415 | } | ||
1416 | return 0; | ||
1417 | } | ||
1418 | |||
1419 | static ssize_t | ||
1420 | qeth_dev_vipa_add_store(const char *buf, size_t count, | ||
1421 | struct qeth_card *card, enum qeth_prot_versions proto) | ||
1422 | { | ||
1423 | u8 addr[16] = {0, }; | ||
1424 | int rc; | ||
1425 | |||
1426 | if (qeth_check_layer2(card)) | ||
1427 | return -EPERM; | ||
1428 | if ((rc = qeth_parse_vipae(buf, proto, addr))) | ||
1429 | return rc; | ||
1430 | |||
1431 | if ((rc = qeth_add_vipa(card, proto, addr))) | ||
1432 | return rc; | ||
1433 | |||
1434 | return count; | ||
1435 | } | ||
1436 | |||
1437 | static ssize_t | ||
1438 | qeth_dev_vipa_add4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1439 | { | ||
1440 | struct qeth_card *card = dev->driver_data; | ||
1441 | |||
1442 | if (!card) | ||
1443 | return -EINVAL; | ||
1444 | |||
1445 | return qeth_dev_vipa_add_store(buf, count, card, QETH_PROT_IPV4); | ||
1446 | } | ||
1447 | |||
1448 | static QETH_DEVICE_ATTR(vipa_add4, add4, 0644, | ||
1449 | qeth_dev_vipa_add4_show, | ||
1450 | qeth_dev_vipa_add4_store); | ||
1451 | |||
1452 | static ssize_t | ||
1453 | qeth_dev_vipa_del_store(const char *buf, size_t count, | ||
1454 | struct qeth_card *card, enum qeth_prot_versions proto) | ||
1455 | { | ||
1456 | u8 addr[16]; | ||
1457 | int rc; | ||
1458 | |||
1459 | if (qeth_check_layer2(card)) | ||
1460 | return -EPERM; | ||
1461 | if ((rc = qeth_parse_vipae(buf, proto, addr))) | ||
1462 | return rc; | ||
1463 | |||
1464 | qeth_del_vipa(card, proto, addr); | ||
1465 | |||
1466 | return count; | ||
1467 | } | ||
1468 | |||
1469 | static ssize_t | ||
1470 | qeth_dev_vipa_del4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1471 | { | ||
1472 | struct qeth_card *card = dev->driver_data; | ||
1473 | |||
1474 | if (!card) | ||
1475 | return -EINVAL; | ||
1476 | |||
1477 | return qeth_dev_vipa_del_store(buf, count, card, QETH_PROT_IPV4); | ||
1478 | } | ||
1479 | |||
1480 | static QETH_DEVICE_ATTR(vipa_del4, del4, 0200, NULL, | ||
1481 | qeth_dev_vipa_del4_store); | ||
1482 | |||
1483 | #ifdef CONFIG_QETH_IPV6 | ||
1484 | static ssize_t | ||
1485 | qeth_dev_vipa_add6_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
1486 | { | ||
1487 | struct qeth_card *card = dev->driver_data; | ||
1488 | |||
1489 | if (!card) | ||
1490 | return -EINVAL; | ||
1491 | |||
1492 | return qeth_dev_vipa_add_show(buf, card, QETH_PROT_IPV6); | ||
1493 | } | ||
1494 | |||
1495 | static ssize_t | ||
1496 | qeth_dev_vipa_add6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1497 | { | ||
1498 | struct qeth_card *card = dev->driver_data; | ||
1499 | |||
1500 | if (!card) | ||
1501 | return -EINVAL; | ||
1502 | |||
1503 | return qeth_dev_vipa_add_store(buf, count, card, QETH_PROT_IPV6); | ||
1504 | } | ||
1505 | |||
1506 | static QETH_DEVICE_ATTR(vipa_add6, add6, 0644, | ||
1507 | qeth_dev_vipa_add6_show, | ||
1508 | qeth_dev_vipa_add6_store); | ||
1509 | |||
1510 | static ssize_t | ||
1511 | qeth_dev_vipa_del6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1512 | { | ||
1513 | struct qeth_card *card = dev->driver_data; | ||
1514 | |||
1515 | if (!card) | ||
1516 | return -EINVAL; | ||
1517 | |||
1518 | if (qeth_check_layer2(card)) | ||
1519 | return -EPERM; | ||
1520 | |||
1521 | return qeth_dev_vipa_del_store(buf, count, card, QETH_PROT_IPV6); | ||
1522 | } | ||
1523 | |||
1524 | static QETH_DEVICE_ATTR(vipa_del6, del6, 0200, NULL, | ||
1525 | qeth_dev_vipa_del6_store); | ||
1526 | #endif /* CONFIG_QETH_IPV6 */ | ||
1527 | |||
1528 | static struct device_attribute * qeth_vipa_device_attrs[] = { | ||
1529 | &dev_attr_vipa_add4, | ||
1530 | &dev_attr_vipa_del4, | ||
1531 | #ifdef CONFIG_QETH_IPV6 | ||
1532 | &dev_attr_vipa_add6, | ||
1533 | &dev_attr_vipa_del6, | ||
1534 | #endif | ||
1535 | NULL, | ||
1536 | }; | ||
1537 | |||
1538 | static struct attribute_group qeth_device_vipa_group = { | ||
1539 | .name = "vipa", | ||
1540 | .attrs = (struct attribute **)qeth_vipa_device_attrs, | ||
1541 | }; | ||
1542 | |||
1543 | static ssize_t | ||
1544 | qeth_dev_rxip_add_show(char *buf, struct qeth_card *card, | ||
1545 | enum qeth_prot_versions proto) | ||
1546 | { | ||
1547 | struct qeth_ipaddr *ipaddr; | ||
1548 | char addr_str[40]; | ||
1549 | int entry_len; /* length of 1 entry string, differs between v4 and v6 */ | ||
1550 | unsigned long flags; | ||
1551 | int i = 0; | ||
1552 | |||
1553 | if (qeth_check_layer2(card)) | ||
1554 | return -EPERM; | ||
1555 | |||
1556 | entry_len = (proto == QETH_PROT_IPV4)? 12 : 40; | ||
1557 | entry_len += 2; /* \n + terminator */ | ||
1558 | spin_lock_irqsave(&card->ip_lock, flags); | ||
1559 | list_for_each_entry(ipaddr, &card->ip_list, entry){ | ||
1560 | if (ipaddr->proto != proto) | ||
1561 | continue; | ||
1562 | if (ipaddr->type != QETH_IP_TYPE_RXIP) | ||
1563 | continue; | ||
1564 | /* String must not be longer than PAGE_SIZE. So we check if | ||
1565 | * string length gets near PAGE_SIZE. Then we can savely display | ||
1566 | * the next IPv6 address (worst case, compared to IPv4) */ | ||
1567 | if ((PAGE_SIZE - i) <= entry_len) | ||
1568 | break; | ||
1569 | qeth_ipaddr_to_string(proto, (const u8 *)&ipaddr->u, addr_str); | ||
1570 | i += snprintf(buf + i, PAGE_SIZE - i, "%s\n", addr_str); | ||
1571 | } | ||
1572 | spin_unlock_irqrestore(&card->ip_lock, flags); | ||
1573 | i += snprintf(buf + i, PAGE_SIZE - i, "\n"); | ||
1574 | |||
1575 | return i; | ||
1576 | } | ||
1577 | |||
1578 | static ssize_t | ||
1579 | qeth_dev_rxip_add4_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
1580 | { | ||
1581 | struct qeth_card *card = dev->driver_data; | ||
1582 | |||
1583 | if (!card) | ||
1584 | return -EINVAL; | ||
1585 | |||
1586 | return qeth_dev_rxip_add_show(buf, card, QETH_PROT_IPV4); | ||
1587 | } | ||
1588 | |||
1589 | static int | ||
1590 | qeth_parse_rxipe(const char* buf, enum qeth_prot_versions proto, | ||
1591 | u8 *addr) | ||
1592 | { | ||
1593 | if (qeth_string_to_ipaddr(buf, proto, addr)){ | ||
1594 | PRINT_WARN("Invalid IP address format!\n"); | ||
1595 | return -EINVAL; | ||
1596 | } | ||
1597 | return 0; | ||
1598 | } | ||
1599 | |||
1600 | static ssize_t | ||
1601 | qeth_dev_rxip_add_store(const char *buf, size_t count, | ||
1602 | struct qeth_card *card, enum qeth_prot_versions proto) | ||
1603 | { | ||
1604 | u8 addr[16] = {0, }; | ||
1605 | int rc; | ||
1606 | |||
1607 | if (qeth_check_layer2(card)) | ||
1608 | return -EPERM; | ||
1609 | if ((rc = qeth_parse_rxipe(buf, proto, addr))) | ||
1610 | return rc; | ||
1611 | |||
1612 | if ((rc = qeth_add_rxip(card, proto, addr))) | ||
1613 | return rc; | ||
1614 | |||
1615 | return count; | ||
1616 | } | ||
1617 | |||
1618 | static ssize_t | ||
1619 | qeth_dev_rxip_add4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1620 | { | ||
1621 | struct qeth_card *card = dev->driver_data; | ||
1622 | |||
1623 | if (!card) | ||
1624 | return -EINVAL; | ||
1625 | |||
1626 | return qeth_dev_rxip_add_store(buf, count, card, QETH_PROT_IPV4); | ||
1627 | } | ||
1628 | |||
1629 | static QETH_DEVICE_ATTR(rxip_add4, add4, 0644, | ||
1630 | qeth_dev_rxip_add4_show, | ||
1631 | qeth_dev_rxip_add4_store); | ||
1632 | |||
1633 | static ssize_t | ||
1634 | qeth_dev_rxip_del_store(const char *buf, size_t count, | ||
1635 | struct qeth_card *card, enum qeth_prot_versions proto) | ||
1636 | { | ||
1637 | u8 addr[16]; | ||
1638 | int rc; | ||
1639 | |||
1640 | if (qeth_check_layer2(card)) | ||
1641 | return -EPERM; | ||
1642 | if ((rc = qeth_parse_rxipe(buf, proto, addr))) | ||
1643 | return rc; | ||
1644 | |||
1645 | qeth_del_rxip(card, proto, addr); | ||
1646 | |||
1647 | return count; | ||
1648 | } | ||
1649 | |||
1650 | static ssize_t | ||
1651 | qeth_dev_rxip_del4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1652 | { | ||
1653 | struct qeth_card *card = dev->driver_data; | ||
1654 | |||
1655 | if (!card) | ||
1656 | return -EINVAL; | ||
1657 | |||
1658 | return qeth_dev_rxip_del_store(buf, count, card, QETH_PROT_IPV4); | ||
1659 | } | ||
1660 | |||
1661 | static QETH_DEVICE_ATTR(rxip_del4, del4, 0200, NULL, | ||
1662 | qeth_dev_rxip_del4_store); | ||
1663 | |||
1664 | #ifdef CONFIG_QETH_IPV6 | ||
1665 | static ssize_t | ||
1666 | qeth_dev_rxip_add6_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
1667 | { | ||
1668 | struct qeth_card *card = dev->driver_data; | ||
1669 | |||
1670 | if (!card) | ||
1671 | return -EINVAL; | ||
1672 | |||
1673 | return qeth_dev_rxip_add_show(buf, card, QETH_PROT_IPV6); | ||
1674 | } | ||
1675 | |||
1676 | static ssize_t | ||
1677 | qeth_dev_rxip_add6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1678 | { | ||
1679 | struct qeth_card *card = dev->driver_data; | ||
1680 | |||
1681 | if (!card) | ||
1682 | return -EINVAL; | ||
1683 | |||
1684 | return qeth_dev_rxip_add_store(buf, count, card, QETH_PROT_IPV6); | ||
1685 | } | ||
1686 | |||
1687 | static QETH_DEVICE_ATTR(rxip_add6, add6, 0644, | ||
1688 | qeth_dev_rxip_add6_show, | ||
1689 | qeth_dev_rxip_add6_store); | ||
1690 | |||
1691 | static ssize_t | ||
1692 | qeth_dev_rxip_del6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
1693 | { | ||
1694 | struct qeth_card *card = dev->driver_data; | ||
1695 | |||
1696 | if (!card) | ||
1697 | return -EINVAL; | ||
1698 | |||
1699 | return qeth_dev_rxip_del_store(buf, count, card, QETH_PROT_IPV6); | ||
1700 | } | ||
1701 | |||
1702 | static QETH_DEVICE_ATTR(rxip_del6, del6, 0200, NULL, | ||
1703 | qeth_dev_rxip_del6_store); | ||
1704 | #endif /* CONFIG_QETH_IPV6 */ | ||
1705 | |||
1706 | static struct device_attribute * qeth_rxip_device_attrs[] = { | ||
1707 | &dev_attr_rxip_add4, | ||
1708 | &dev_attr_rxip_del4, | ||
1709 | #ifdef CONFIG_QETH_IPV6 | ||
1710 | &dev_attr_rxip_add6, | ||
1711 | &dev_attr_rxip_del6, | ||
1712 | #endif | ||
1713 | NULL, | ||
1714 | }; | ||
1715 | |||
1716 | static struct attribute_group qeth_device_rxip_group = { | ||
1717 | .name = "rxip", | ||
1718 | .attrs = (struct attribute **)qeth_rxip_device_attrs, | ||
1719 | }; | ||
1720 | |||
1721 | int | ||
1722 | qeth_create_device_attributes(struct device *dev) | ||
1723 | { | ||
1724 | int ret; | ||
1725 | struct qeth_card *card = dev->driver_data; | ||
1726 | |||
1727 | if (card->info.type == QETH_CARD_TYPE_OSN) | ||
1728 | return sysfs_create_group(&dev->kobj, | ||
1729 | &qeth_osn_device_attr_group); | ||
1730 | |||
1731 | if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_attr_group))) | ||
1732 | return ret; | ||
1733 | if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_ipato_group))){ | ||
1734 | sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); | ||
1735 | return ret; | ||
1736 | } | ||
1737 | if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_vipa_group))){ | ||
1738 | sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); | ||
1739 | sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); | ||
1740 | return ret; | ||
1741 | } | ||
1742 | if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_rxip_group))){ | ||
1743 | sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); | ||
1744 | sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); | ||
1745 | sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group); | ||
1746 | return ret; | ||
1747 | } | ||
1748 | if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_blkt_group))){ | ||
1749 | sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); | ||
1750 | sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); | ||
1751 | sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group); | ||
1752 | sysfs_remove_group(&dev->kobj, &qeth_device_rxip_group); | ||
1753 | return ret; | ||
1754 | } | ||
1755 | return 0; | ||
1756 | } | ||
1757 | |||
1758 | void | ||
1759 | qeth_remove_device_attributes(struct device *dev) | ||
1760 | { | ||
1761 | struct qeth_card *card = dev->driver_data; | ||
1762 | |||
1763 | if (card->info.type == QETH_CARD_TYPE_OSN) { | ||
1764 | sysfs_remove_group(&dev->kobj, &qeth_osn_device_attr_group); | ||
1765 | return; | ||
1766 | } | ||
1767 | sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); | ||
1768 | sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); | ||
1769 | sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group); | ||
1770 | sysfs_remove_group(&dev->kobj, &qeth_device_rxip_group); | ||
1771 | sysfs_remove_group(&dev->kobj, &qeth_device_blkt_group); | ||
1772 | } | ||
1773 | |||
1774 | /**********************/ | ||
1775 | /* DRIVER ATTRIBUTES */ | ||
1776 | /**********************/ | ||
1777 | static ssize_t | ||
1778 | qeth_driver_group_store(struct device_driver *ddrv, const char *buf, | ||
1779 | size_t count) | ||
1780 | { | ||
1781 | const char *start, *end; | ||
1782 | char bus_ids[3][BUS_ID_SIZE], *argv[3]; | ||
1783 | int i; | ||
1784 | int err; | ||
1785 | |||
1786 | start = buf; | ||
1787 | for (i = 0; i < 3; i++) { | ||
1788 | static const char delim[] = { ',', ',', '\n' }; | ||
1789 | int len; | ||
1790 | |||
1791 | if (!(end = strchr(start, delim[i]))) | ||
1792 | return -EINVAL; | ||
1793 | len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start); | ||
1794 | strncpy(bus_ids[i], start, len); | ||
1795 | bus_ids[i][len] = '\0'; | ||
1796 | start = end + 1; | ||
1797 | argv[i] = bus_ids[i]; | ||
1798 | } | ||
1799 | err = ccwgroup_create(qeth_root_dev, qeth_ccwgroup_driver.driver_id, | ||
1800 | &qeth_ccw_driver, 3, argv); | ||
1801 | if (err) | ||
1802 | return err; | ||
1803 | else | ||
1804 | return count; | ||
1805 | } | ||
1806 | |||
1807 | |||
1808 | static DRIVER_ATTR(group, 0200, NULL, qeth_driver_group_store); | ||
1809 | |||
1810 | static ssize_t | ||
1811 | qeth_driver_notifier_register_store(struct device_driver *ddrv, const char *buf, | ||
1812 | size_t count) | ||
1813 | { | ||
1814 | int rc; | ||
1815 | int signum; | ||
1816 | char *tmp, *tmp2; | ||
1817 | |||
1818 | tmp = strsep((char **) &buf, "\n"); | ||
1819 | if (!strncmp(tmp, "unregister", 10)){ | ||
1820 | if ((rc = qeth_notifier_unregister(current))) | ||
1821 | return rc; | ||
1822 | return count; | ||
1823 | } | ||
1824 | |||
1825 | signum = simple_strtoul(tmp, &tmp2, 10); | ||
1826 | if ((signum < 0) || (signum > 32)){ | ||
1827 | PRINT_WARN("Signal number %d is out of range\n", signum); | ||
1828 | return -EINVAL; | ||
1829 | } | ||
1830 | if ((rc = qeth_notifier_register(current, signum))) | ||
1831 | return rc; | ||
1832 | |||
1833 | return count; | ||
1834 | } | ||
1835 | |||
1836 | static DRIVER_ATTR(notifier_register, 0200, NULL, | ||
1837 | qeth_driver_notifier_register_store); | ||
1838 | |||
1839 | int | ||
1840 | qeth_create_driver_attributes(void) | ||
1841 | { | ||
1842 | int rc; | ||
1843 | |||
1844 | if ((rc = driver_create_file(&qeth_ccwgroup_driver.driver, | ||
1845 | &driver_attr_group))) | ||
1846 | return rc; | ||
1847 | return driver_create_file(&qeth_ccwgroup_driver.driver, | ||
1848 | &driver_attr_notifier_register); | ||
1849 | } | ||
1850 | |||
1851 | void | ||
1852 | qeth_remove_driver_attributes(void) | ||
1853 | { | ||
1854 | driver_remove_file(&qeth_ccwgroup_driver.driver, | ||
1855 | &driver_attr_group); | ||
1856 | driver_remove_file(&qeth_ccwgroup_driver.driver, | ||
1857 | &driver_attr_notifier_register); | ||
1858 | } | ||
diff --git a/drivers/s390/net/qeth_tso.h b/drivers/s390/net/qeth_tso.h deleted file mode 100644 index c20e923cf9ad..000000000000 --- a/drivers/s390/net/qeth_tso.h +++ /dev/null | |||
@@ -1,148 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/s390/net/qeth_tso.h | ||
3 | * | ||
4 | * Header file for qeth TCP Segmentation Offload support. | ||
5 | * | ||
6 | * Copyright 2004 IBM Corporation | ||
7 | * | ||
8 | * Author(s): Frank Pavlic <fpavlic@de.ibm.com> | ||
9 | * | ||
10 | */ | ||
11 | #ifndef __QETH_TSO_H__ | ||
12 | #define __QETH_TSO_H__ | ||
13 | |||
14 | #include <linux/skbuff.h> | ||
15 | #include <linux/tcp.h> | ||
16 | #include <linux/ip.h> | ||
17 | #include <linux/ipv6.h> | ||
18 | #include <net/ip6_checksum.h> | ||
19 | #include "qeth.h" | ||
20 | #include "qeth_mpc.h" | ||
21 | |||
22 | |||
23 | static inline struct qeth_hdr_tso * | ||
24 | qeth_tso_prepare_skb(struct qeth_card *card, struct sk_buff **skb) | ||
25 | { | ||
26 | QETH_DBF_TEXT(trace, 5, "tsoprsk"); | ||
27 | return qeth_push_skb(card, *skb, sizeof(struct qeth_hdr_tso)); | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * fill header for a TSO packet | ||
32 | */ | ||
33 | static inline void | ||
34 | qeth_tso_fill_header(struct qeth_card *card, struct sk_buff *skb) | ||
35 | { | ||
36 | struct qeth_hdr_tso *hdr; | ||
37 | struct tcphdr *tcph; | ||
38 | struct iphdr *iph; | ||
39 | |||
40 | QETH_DBF_TEXT(trace, 5, "tsofhdr"); | ||
41 | |||
42 | hdr = (struct qeth_hdr_tso *) skb->data; | ||
43 | iph = ip_hdr(skb); | ||
44 | tcph = tcp_hdr(skb); | ||
45 | /*fix header to TSO values ...*/ | ||
46 | hdr->hdr.hdr.l3.id = QETH_HEADER_TYPE_TSO; | ||
47 | /*set values which are fix for the first approach ...*/ | ||
48 | hdr->ext.hdr_tot_len = (__u16) sizeof(struct qeth_hdr_ext_tso); | ||
49 | hdr->ext.imb_hdr_no = 1; | ||
50 | hdr->ext.hdr_type = 1; | ||
51 | hdr->ext.hdr_version = 1; | ||
52 | hdr->ext.hdr_len = 28; | ||
53 | /*insert non-fix values */ | ||
54 | hdr->ext.mss = skb_shinfo(skb)->gso_size; | ||
55 | hdr->ext.dg_hdr_len = (__u16)(iph->ihl*4 + tcph->doff*4); | ||
56 | hdr->ext.payload_len = (__u16)(skb->len - hdr->ext.dg_hdr_len - | ||
57 | sizeof(struct qeth_hdr_tso)); | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * change some header values as requested by hardware | ||
62 | */ | ||
63 | static inline void | ||
64 | qeth_tso_set_tcpip_header(struct qeth_card *card, struct sk_buff *skb) | ||
65 | { | ||
66 | struct iphdr *iph = ip_hdr(skb); | ||
67 | struct ipv6hdr *ip6h = ipv6_hdr(skb); | ||
68 | struct tcphdr *tcph = tcp_hdr(skb); | ||
69 | |||
70 | tcph->check = 0; | ||
71 | if (skb->protocol == ETH_P_IPV6) { | ||
72 | ip6h->payload_len = 0; | ||
73 | tcph->check = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, | ||
74 | 0, IPPROTO_TCP, 0); | ||
75 | return; | ||
76 | } | ||
77 | /*OSA want us to set these values ...*/ | ||
78 | tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, | ||
79 | 0, IPPROTO_TCP, 0); | ||
80 | iph->tot_len = 0; | ||
81 | iph->check = 0; | ||
82 | } | ||
83 | |||
84 | static inline int | ||
85 | qeth_tso_prepare_packet(struct qeth_card *card, struct sk_buff *skb, | ||
86 | int ipv, int cast_type) | ||
87 | { | ||
88 | struct qeth_hdr_tso *hdr; | ||
89 | |||
90 | QETH_DBF_TEXT(trace, 5, "tsoprep"); | ||
91 | |||
92 | hdr = (struct qeth_hdr_tso *) qeth_tso_prepare_skb(card, &skb); | ||
93 | if (hdr == NULL) { | ||
94 | QETH_DBF_TEXT(trace, 4, "tsoperr"); | ||
95 | return -ENOMEM; | ||
96 | } | ||
97 | memset(hdr, 0, sizeof(struct qeth_hdr_tso)); | ||
98 | /*fill first 32 bytes of qdio header as used | ||
99 | *FIXME: TSO has two struct members | ||
100 | * with different names but same size | ||
101 | * */ | ||
102 | qeth_fill_header(card, &hdr->hdr, skb, ipv, cast_type); | ||
103 | qeth_tso_fill_header(card, skb); | ||
104 | qeth_tso_set_tcpip_header(card, skb); | ||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | static inline void | ||
109 | __qeth_fill_buffer_frag(struct sk_buff *skb, struct qdio_buffer *buffer, | ||
110 | int is_tso, int *next_element_to_fill) | ||
111 | { | ||
112 | struct skb_frag_struct *frag; | ||
113 | int fragno; | ||
114 | unsigned long addr; | ||
115 | int element, cnt, dlen; | ||
116 | |||
117 | fragno = skb_shinfo(skb)->nr_frags; | ||
118 | element = *next_element_to_fill; | ||
119 | dlen = 0; | ||
120 | |||
121 | if (is_tso) | ||
122 | buffer->element[element].flags = | ||
123 | SBAL_FLAGS_MIDDLE_FRAG; | ||
124 | else | ||
125 | buffer->element[element].flags = | ||
126 | SBAL_FLAGS_FIRST_FRAG; | ||
127 | if ( (dlen = (skb->len - skb->data_len)) ) { | ||
128 | buffer->element[element].addr = skb->data; | ||
129 | buffer->element[element].length = dlen; | ||
130 | element++; | ||
131 | } | ||
132 | for (cnt = 0; cnt < fragno; cnt++) { | ||
133 | frag = &skb_shinfo(skb)->frags[cnt]; | ||
134 | addr = (page_to_pfn(frag->page) << PAGE_SHIFT) + | ||
135 | frag->page_offset; | ||
136 | buffer->element[element].addr = (char *)addr; | ||
137 | buffer->element[element].length = frag->size; | ||
138 | if (cnt < (fragno - 1)) | ||
139 | buffer->element[element].flags = | ||
140 | SBAL_FLAGS_MIDDLE_FRAG; | ||
141 | else | ||
142 | buffer->element[element].flags = | ||
143 | SBAL_FLAGS_LAST_FRAG; | ||
144 | element++; | ||
145 | } | ||
146 | *next_element_to_fill = element; | ||
147 | } | ||
148 | #endif /* __QETH_TSO_H__ */ | ||