5 #include <linux/if_arp.h>
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>
14 #include <linux/in6.h>
15 #include <net/if_inet6.h>
16 #include <net/addrconf.h>
19 #include <linux/bitops.h>
21 #include <asm/debug.h>
23 #include <asm/ccwdev.h>
24 #include <asm/ccwgroup.h>
28 #ifdef CONFIG_QETH_IPV6
29 #define QETH_VERSION_IPV6 ":IPv6"
31 #define QETH_VERSION_IPV6 ""
33 #ifdef CONFIG_QETH_VLAN
34 #define QETH_VERSION_VLAN ":VLAN"
36 #define QETH_VERSION_VLAN ""
40 * Debug Facility stuff
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
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
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
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
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;
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
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
85 #define QETH_DBF_TEXT(name,level,text) \
87 debug_text_event(qeth_dbf_##name,level,text); \
90 #define QETH_DBF_HEX(name,level,addr,len) \
92 debug_event(qeth_dbf_##name,level,(void*)(addr),len); \
95 DECLARE_PER_CPU(char[256], qeth_dbf_txt_buf);
97 #define QETH_DBF_TEXT_(name,level,text...) \
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); \
105 #define QETH_DBF_SPRINTF(name,level,text...) \
107 debug_sprintf_event(qeth_dbf_trace, level, ##text ); \
108 debug_sprintf_event(qeth_dbf_trace, level, text ); \
112 * some more debug stuff
114 #define PRINTK_HEADER "qeth: "
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));
137 qeth_hex_dump(unsigned char *buf, size_t len)
141 for (i = 0; i < len; i++) {
144 printk("%02x ", *(buf + i));
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
154 #define atomic_swap(a,b) xchg((int *)a.counter, b)
157 * Common IO related definitions
159 extern struct device *qeth_root_dev;
160 extern struct ccw_driver qeth_ccw_driver;
161 extern struct ccwgroup_driver qeth_ccwgroup_driver;
163 #define CARD_RDEV(card) card->read.ccwdev
164 #define CARD_WDEV(card) card->write.ccwdev
165 #define CARD_DDEV(card) card->data.ccwdev
166 #define CARD_BUS_ID(card) card->gdev->dev.bus_id
167 #define CARD_RDEV_ID(card) card->read.ccwdev->dev.bus_id
168 #define CARD_WDEV_ID(card) card->write.ccwdev->dev.bus_id
169 #define CARD_DDEV_ID(card) card->data.ccwdev->dev.bus_id
170 #define CHANNEL_ID(channel) channel->ccwdev->dev.bus_id
172 #define CARD_FROM_CDEV(cdev) (struct qeth_card *) \
173 ((struct ccwgroup_device *)cdev->dev.driver_data)\
179 #ifdef CONFIG_QETH_PERF_STATS
180 struct qeth_perf_stats {
181 unsigned int bufs_rec;
182 unsigned int bufs_sent;
184 unsigned int skbs_sent_pack;
185 unsigned int bufs_sent_pack;
187 unsigned int sc_dp_p;
188 unsigned int sc_p_dp;
189 /* qdio_input_handler: number of times called, time spent in */
190 __u64 inbound_start_time;
191 unsigned int inbound_cnt;
192 unsigned int inbound_time;
193 /* qeth_send_packet: number of times called, time spent in */
194 __u64 outbound_start_time;
195 unsigned int outbound_cnt;
196 unsigned int outbound_time;
197 /* qdio_output_handler: number of times called, time spent in */
198 __u64 outbound_handler_start_time;
199 unsigned int outbound_handler_cnt;
200 unsigned int outbound_handler_time;
201 /* number of calls to and time spent in do_QDIO for inbound queue */
202 __u64 inbound_do_qdio_start_time;
203 unsigned int inbound_do_qdio_cnt;
204 unsigned int inbound_do_qdio_time;
205 /* number of calls to and time spent in do_QDIO for outbound queues */
206 __u64 outbound_do_qdio_start_time;
207 unsigned int outbound_do_qdio_cnt;
208 unsigned int outbound_do_qdio_time;
210 unsigned int large_send_bytes;
211 unsigned int large_send_cnt;
212 unsigned int sg_skbs_sent;
213 unsigned int sg_frags_sent;
215 #endif /* CONFIG_QETH_PERF_STATS */
218 struct qeth_routing_info {
219 enum qeth_routing_types type;
223 struct qeth_ipa_info {
224 __u32 supported_funcs;
229 qeth_is_ipa_supported(struct qeth_ipa_info *ipa, enum qeth_ipa_funcs func)
231 return (ipa->supported_funcs & func);
235 qeth_is_ipa_enabled(struct qeth_ipa_info *ipa, enum qeth_ipa_funcs func)
237 return (ipa->supported_funcs & ipa->enabled_funcs & func);
240 #define qeth_adp_supported(c,f) \
241 qeth_is_ipa_supported(&c->options.adp, f)
242 #define qeth_adp_enabled(c,f) \
243 qeth_is_ipa_enabled(&c->options.adp, f)
244 #define qeth_is_supported(c,f) \
245 qeth_is_ipa_supported(&c->options.ipa4, f)
246 #define qeth_is_enabled(c,f) \
247 qeth_is_ipa_enabled(&c->options.ipa4, f)
248 #ifdef CONFIG_QETH_IPV6
249 #define qeth_is_supported6(c,f) \
250 qeth_is_ipa_supported(&c->options.ipa6, f)
251 #define qeth_is_enabled6(c,f) \
252 qeth_is_ipa_enabled(&c->options.ipa6, f)
253 #else /* CONFIG_QETH_IPV6 */
254 #define qeth_is_supported6(c,f) 0
255 #define qeth_is_enabled6(c,f) 0
256 #endif /* CONFIG_QETH_IPV6 */
257 #define qeth_is_ipafunc_supported(c,prot,f) \
258 (prot==QETH_PROT_IPV6)? qeth_is_supported6(c,f):qeth_is_supported(c,f)
259 #define qeth_is_ipafunc_enabled(c,prot,f) \
260 (prot==QETH_PROT_IPV6)? qeth_is_enabled6(c,f):qeth_is_enabled(c,f)
263 #define QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT 0x0101
264 #define QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT 0x0101
265 #define QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT 0x4108
266 #define QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT 0x5108
268 #define QETH_MODELLIST_ARRAY \
269 {{0x1731,0x01,0x1732,0x01,QETH_CARD_TYPE_OSAE,1, \
270 QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT, \
271 QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT, \
272 QETH_MAX_QUEUES,0}, \
273 {0x1731,0x05,0x1732,0x05,QETH_CARD_TYPE_IQD,0, \
274 QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT, \
275 QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT, \
276 QETH_MAX_QUEUES,0x103}, \
277 {0x1731,0x06,0x1732,0x06,QETH_CARD_TYPE_OSN,0, \
278 QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT, \
279 QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT, \
280 QETH_MAX_QUEUES,0}, \
283 #define QETH_REAL_CARD 1
284 #define QETH_VLAN_CARD 2
285 #define QETH_BUFSIZE 4096
290 #define IF_NAME_LEN 16
291 #define QETH_TX_TIMEOUT 100 * HZ
292 #define QETH_HEADER_SIZE 32
293 #define MAX_PORTNO 15
294 #define QETH_FAKE_LL_LEN_ETH ETH_HLEN
295 #define QETH_FAKE_LL_LEN_TR (sizeof(struct trh_hdr)-TR_MAXRIFLEN+sizeof(struct trllc))
296 #define QETH_FAKE_LL_V6_ADDR_POS 24
298 /*IPv6 address autoconfiguration stuff*/
299 #define UNIQUE_ID_IF_CREATE_ADDR_FAILED 0xfffe
300 #define UNIQUE_ID_NOT_BY_CARD 0x10000
302 /*****************************************************************************/
303 /* QDIO queue and buffer handling */
304 /*****************************************************************************/
305 #define QETH_MAX_QUEUES 4
306 #define QETH_IN_BUF_SIZE_DEFAULT 65536
307 #define QETH_IN_BUF_COUNT_DEFAULT 16
308 #define QETH_IN_BUF_COUNT_MIN 8
309 #define QETH_IN_BUF_COUNT_MAX 128
310 #define QETH_MAX_BUFFER_ELEMENTS(card) ((card)->qdio.in_buf_size >> 12)
311 #define QETH_IN_BUF_REQUEUE_THRESHOLD(card) \
312 ((card)->qdio.in_buf_pool.buf_count / 2)
314 /* buffers we have to be behind before we get a PCI */
315 #define QETH_PCI_THRESHOLD_A(card) ((card)->qdio.in_buf_pool.buf_count+1)
316 /*enqueued free buffers left before we get a PCI*/
317 #define QETH_PCI_THRESHOLD_B(card) 0
318 /*not used unless the microcode gets patched*/
319 #define QETH_PCI_TIMER_VALUE(card) 3
321 #define QETH_MIN_INPUT_THRESHOLD 1
322 #define QETH_MAX_INPUT_THRESHOLD 500
323 #define QETH_MIN_OUTPUT_THRESHOLD 1
324 #define QETH_MAX_OUTPUT_THRESHOLD 300
326 /* priority queing */
327 #define QETH_PRIOQ_DEFAULT QETH_NO_PRIO_QUEUEING
328 #define QETH_DEFAULT_QUEUE 2
329 #define QETH_NO_PRIO_QUEUEING 0
330 #define QETH_PRIO_Q_ING_PREC 1
331 #define QETH_PRIO_Q_ING_TOS 2
332 #define IP_TOS_LOWDELAY 0x10
333 #define IP_TOS_HIGHTHROUGHPUT 0x08
334 #define IP_TOS_HIGHRELIABILITY 0x04
335 #define IP_TOS_NOTIMPORTANT 0x02
338 #define QETH_LOW_WATERMARK_PACK 2
339 #define QETH_HIGH_WATERMARK_PACK 5
340 #define QETH_WATERMARK_PACK_FUZZ 1
342 #define QETH_IP_HEADER_SIZE 40
344 struct qeth_hdr_layer3 {
347 __u16 inbound_checksum; /*TSO:__u16 seqno */
348 __u32 token; /*TSO: __u32 reserved */
355 } __attribute__ ((packed));
357 struct qeth_hdr_layer2 {
367 } __attribute__ ((packed));
369 struct qeth_hdr_osn {
378 } __attribute__ ((packed));
382 struct qeth_hdr_layer2 l2;
383 struct qeth_hdr_layer3 l3;
384 struct qeth_hdr_osn osn;
386 } __attribute__ ((packed));
388 /*TCP Segmentation Offload header*/
389 struct qeth_hdr_ext_tso {
400 } __attribute__ ((packed));
402 struct qeth_hdr_tso {
403 struct qeth_hdr hdr; /*hdr->hdr.l3.xxx*/
404 struct qeth_hdr_ext_tso ext;
405 } __attribute__ ((packed));
408 /* flags for qeth_hdr.flags */
409 #define QETH_HDR_PASSTHRU 0x10
410 #define QETH_HDR_IPV6 0x80
411 #define QETH_HDR_CAST_MASK 0x07
412 enum qeth_cast_flags {
413 QETH_CAST_UNICAST = 0x06,
414 QETH_CAST_MULTICAST = 0x04,
415 QETH_CAST_BROADCAST = 0x05,
416 QETH_CAST_ANYCAST = 0x07,
417 QETH_CAST_NOCAST = 0x00,
420 enum qeth_layer2_frame_flags {
421 QETH_LAYER2_FLAG_MULTICAST = 0x01,
422 QETH_LAYER2_FLAG_BROADCAST = 0x02,
423 QETH_LAYER2_FLAG_UNICAST = 0x04,
424 QETH_LAYER2_FLAG_VLAN = 0x10,
427 enum qeth_header_ids {
428 QETH_HEADER_TYPE_LAYER3 = 0x01,
429 QETH_HEADER_TYPE_LAYER2 = 0x02,
430 QETH_HEADER_TYPE_TSO = 0x03,
431 QETH_HEADER_TYPE_OSN = 0x04,
433 /* flags for qeth_hdr.ext_flags */
434 #define QETH_HDR_EXT_VLAN_FRAME 0x01
435 #define QETH_HDR_EXT_TOKEN_ID 0x02
436 #define QETH_HDR_EXT_INCLUDE_VLAN_TAG 0x04
437 #define QETH_HDR_EXT_SRC_MAC_ADDR 0x08
438 #define QETH_HDR_EXT_CSUM_HDR_REQ 0x10
439 #define QETH_HDR_EXT_CSUM_TRANSP_REQ 0x20
440 #define QETH_HDR_EXT_UDP_TSO 0x40 /*bit off for TCP*/
443 qeth_is_last_sbale(struct qdio_buffer_element *sbale)
445 return (sbale->flags & SBAL_FLAGS_LAST_ENTRY);
448 enum qeth_qdio_buffer_states {
450 * inbound: read out by driver; owned by hardware in order to be filled
451 * outbound: owned by driver in order to be filled
455 * inbound: filled by hardware; owned by driver in order to be read out
456 * outbound: filled by driver; owned by hardware in order to be sent
458 QETH_QDIO_BUF_PRIMED,
461 enum qeth_qdio_info_states {
462 QETH_QDIO_UNINITIALIZED,
464 QETH_QDIO_ESTABLISHED,
467 struct qeth_buffer_pool_entry {
468 struct list_head list;
469 struct list_head init_list;
470 void *elements[QDIO_MAX_ELEMENTS_PER_BUFFER];
473 struct qeth_qdio_buffer_pool {
474 struct list_head entry_list;
478 struct qeth_qdio_buffer {
479 struct qdio_buffer *buffer;
480 volatile enum qeth_qdio_buffer_states state;
481 /* the buffer pool entry currently associated to this buffer */
482 struct qeth_buffer_pool_entry *pool_entry;
486 struct qdio_buffer qdio_bufs[QDIO_MAX_BUFFERS_PER_Q];
487 struct qeth_qdio_buffer bufs[QDIO_MAX_BUFFERS_PER_Q];
489 * buf_to_init means "buffer must be initialized by driver and must
490 * be made available for hardware" -> state is set to EMPTY
492 volatile int next_buf_to_init;
493 } __attribute__ ((aligned(256)));
495 /* possible types of qeth large_send support */
496 enum qeth_large_send_types {
498 QETH_LARGE_SEND_EDDP,
502 struct qeth_qdio_out_buffer {
503 struct qdio_buffer *buffer;
505 volatile int next_element_to_fill;
506 struct sk_buff_head skb_list;
507 struct list_head ctx_list;
512 enum qeth_out_q_states {
515 QETH_OUT_Q_LOCKED_FLUSH,
518 struct qeth_qdio_out_q {
519 struct qdio_buffer qdio_bufs[QDIO_MAX_BUFFERS_PER_Q];
520 struct qeth_qdio_out_buffer bufs[QDIO_MAX_BUFFERS_PER_Q];
522 struct qeth_card *card;
524 volatile int do_pack;
526 * index of buffer to be filled by driver; state EMPTY or PACKING
528 volatile int next_buf_to_fill;
530 * number of buffers that are currently filled (PRIMED)
531 * -> these buffers are hardware-owned
533 atomic_t used_buffers;
534 /* indicates whether PCI flag must be set (or if one is outstanding) */
535 atomic_t set_pci_flags_count;
536 } __attribute__ ((aligned(256)));
538 struct qeth_qdio_info {
539 volatile enum qeth_qdio_info_states state;
541 struct qeth_qdio_q *in_q;
542 struct qeth_qdio_buffer_pool in_buf_pool;
543 struct qeth_qdio_buffer_pool init_pool;
548 struct qeth_qdio_out_q **out_qs;
550 /* priority queueing */
551 int do_prio_queueing;
552 int default_out_queue;
555 enum qeth_send_errors {
556 QETH_SEND_ERROR_NONE,
557 QETH_SEND_ERROR_LINK_FAILURE,
558 QETH_SEND_ERROR_RETRY,
559 QETH_SEND_ERROR_KICK_IT,
562 #define QETH_ETH_MAC_V4 0x0100 /* like v4 */
563 #define QETH_ETH_MAC_V6 0x3333 /* like v6 */
564 /* tr mc mac is longer, but that will be enough to detect mc frames */
565 #define QETH_TR_MAC_NC 0xc000 /* non-canonical */
566 #define QETH_TR_MAC_C 0x0300 /* canonical */
568 #define DEFAULT_ADD_HHLEN 0
569 #define MAX_ADD_HHLEN 1024
572 * buffer stuff for read channel
574 #define QETH_CMD_BUFFER_NO 8
577 * channel state machine
579 enum qeth_channel_states {
589 enum qeth_card_states {
591 CARD_STATE_HARDSETUP,
592 CARD_STATE_SOFTSETUP,
600 enum qeth_prot_versions {
601 QETH_PROT_IPV4 = 0x0004,
602 QETH_PROT_IPV6 = 0x0006,
609 QETH_IP_TYPE_DEL_ALL_MC,
612 enum qeth_cmd_buffer_state {
618 * IP address and multicast list
621 struct list_head entry;
622 enum qeth_ip_types type;
623 enum qeth_ipa_setdelip_flags set_flags;
624 enum qeth_ipa_setdelip_flags del_flags;
627 enum qeth_prot_versions proto;
628 unsigned char mac[OSA_ADDR_LEN];
635 struct in6_addr addr;
641 struct qeth_ipato_entry {
642 struct list_head entry;
643 enum qeth_prot_versions proto;
652 struct list_head entries;
657 struct qeth_cmd_buffer {
658 enum qeth_cmd_buffer_state state;
659 struct qeth_channel *channel;
662 void (*callback) (struct qeth_channel *, struct qeth_cmd_buffer *);
667 * definition of a qeth channel, used for read and write
669 struct qeth_channel {
670 enum qeth_channel_states state;
673 wait_queue_head_t wait_q;
674 struct tasklet_struct irq_tasklet;
675 struct ccw_device *ccwdev;
676 /*command buffer for control data*/
677 struct qeth_cmd_buffer iob[QETH_CMD_BUFFER_NO];
678 atomic_t irq_pending;
679 volatile int io_buf_no;
684 * OSA card related definitions
691 __u32 cm_connection_w;
692 __u32 cm_connection_r;
695 __u32 ulp_connection_w;
696 __u32 ulp_connection_r;
708 struct list_head list;
709 wait_queue_head_t wait_q;
710 int (*callback)(struct qeth_card *,struct qeth_reply *,unsigned long);
712 unsigned long offset;
716 struct qeth_card *card;
721 struct qeth_card_blkt {
724 int inter_packet_jumbo;
727 #define QETH_BROADCAST_WITH_ECHO 0x01
728 #define QETH_BROADCAST_WITHOUT_ECHO 0x02
729 #define QETH_LAYER2_MAC_READ 0x01
730 #define QETH_LAYER2_MAC_REGISTERED 0x02
731 struct qeth_card_info {
732 unsigned short unit_addr2;
734 unsigned short chpid;
736 char mcl_level[QETH_MCL_LENGTH + 1];
739 int portname_required;
742 enum qeth_card_types type;
743 enum qeth_link_types link_type;
744 int is_multicast_different;
747 int broadcast_capable;
749 struct qeth_card_blkt blkt;
751 enum qeth_ipa_promisc_modes promisc_mode;
754 struct qeth_card_options {
755 struct qeth_routing_info route4;
756 struct qeth_ipa_info ipa4;
757 struct qeth_ipa_info adp; /*Adapter parameters*/
758 #ifdef CONFIG_QETH_IPV6
759 struct qeth_routing_info route6;
760 struct qeth_ipa_info ipa6;
761 #endif /* QETH_IPV6 */
762 enum qeth_checksum_types checksum_type;
769 enum qeth_large_send_types large_send;
773 * thread bits for qeth_card thread masks
776 QETH_SET_IP_THREAD = 1,
777 QETH_RECOVER_THREAD = 2,
778 QETH_SET_PROMISC_MODE_THREAD = 4,
781 struct qeth_osn_info {
782 int (*assist_cb)(struct net_device *dev, void *data);
783 int (*data_cb)(struct sk_buff *skb);
787 struct list_head list;
788 enum qeth_card_states state;
791 /*hardware and sysfs stuff*/
792 struct ccwgroup_device *gdev;
793 struct qeth_channel read;
794 struct qeth_channel write;
795 struct qeth_channel data;
797 struct net_device *dev;
798 struct net_device_stats stats;
800 struct qeth_card_info info;
801 struct qeth_token token;
802 struct qeth_seqno seqno;
803 struct qeth_card_options options;
805 wait_queue_head_t wait_q;
806 #ifdef CONFIG_QETH_VLAN
808 struct vlan_group *vlangrp;
810 struct work_struct kernel_thread_starter;
811 spinlock_t thread_mask_lock;
812 volatile unsigned long thread_start_mask;
813 volatile unsigned long thread_allowed_mask;
814 volatile unsigned long thread_running_mask;
816 struct list_head ip_list;
817 struct list_head *ip_tbd_list;
818 struct qeth_ipato ipato;
819 struct list_head cmd_waiter_list;
820 /* QDIO buffer handling */
821 struct qeth_qdio_info qdio;
822 #ifdef CONFIG_QETH_PERF_STATS
823 struct qeth_perf_stats perf_stats;
824 #endif /* CONFIG_QETH_PERF_STATS */
826 int (*orig_hard_header)(struct sk_buff *,struct net_device *,
827 unsigned short,void *,void *,unsigned);
828 struct qeth_osn_info osn_info;
831 struct qeth_card_list_struct {
832 struct list_head list;
836 extern struct qeth_card_list_struct qeth_card_list;
839 struct qeth_notify_list_struct {
840 struct list_head list;
841 struct task_struct *task;
844 extern spinlock_t qeth_notify_lock;
845 extern struct list_head qeth_notify_list;
847 /*some helper functions*/
849 #define QETH_CARD_IFNAME(card) (((card)->dev)? (card)->dev->name : "")
852 qeth_get_ipa_adp_type(enum qeth_link_types link_type)
855 case QETH_LINK_TYPE_HSTR:
863 qeth_realloc_headroom(struct qeth_card *card, struct sk_buff **skb, int size)
865 struct sk_buff *new_skb = NULL;
867 if (skb_headroom(*skb) < size){
868 new_skb = skb_realloc_headroom(*skb, size);
870 PRINT_ERR("qeth_prepare_skb: could "
871 "not realloc headroom for qeth_hdr "
872 "on interface %s", QETH_CARD_IFNAME(card));
881 static inline struct sk_buff *
882 qeth_pskb_unshare(struct sk_buff *skb, int pri)
884 struct sk_buff *nskb;
885 if (!skb_cloned(skb))
887 nskb = skb_copy(skb, pri);
888 kfree_skb(skb); /* free our shared copy */
893 qeth_push_skb(struct qeth_card *card, struct sk_buff **skb, int size)
897 hdr = (void *) skb_push(*skb, size);
899 * sanity check, the Linux memory allocation scheme should
900 * never present us cases like this one (the qdio header size plus
901 * the first 40 bytes of the paket cross a 4k boundary)
903 if ((((unsigned long) hdr) & (~(PAGE_SIZE - 1))) !=
904 (((unsigned long) hdr + size +
905 QETH_IP_HEADER_SIZE) & (~(PAGE_SIZE - 1)))) {
906 PRINT_ERR("qeth_prepare_skb: misaligned "
907 "packet on interface %s. Discarded.",
908 QETH_CARD_IFNAME(card));
916 qeth_get_hlen(__u8 link_type)
918 #ifdef CONFIG_QETH_IPV6
920 case QETH_LINK_TYPE_HSTR:
921 case QETH_LINK_TYPE_LANE_TR:
922 return sizeof(struct qeth_hdr_tso) + TR_HLEN;
924 #ifdef CONFIG_QETH_VLAN
925 return sizeof(struct qeth_hdr_tso) + VLAN_ETH_HLEN;
927 return sizeof(struct qeth_hdr_tso) + ETH_HLEN;
930 #else /* CONFIG_QETH_IPV6 */
931 #ifdef CONFIG_QETH_VLAN
932 return sizeof(struct qeth_hdr_tso) + VLAN_HLEN;
934 return sizeof(struct qeth_hdr_tso);
936 #endif /* CONFIG_QETH_IPV6 */
939 static inline unsigned short
940 qeth_get_netdev_flags(struct qeth_card *card)
942 if (card->options.layer2 &&
943 (card->info.type == QETH_CARD_TYPE_OSAE))
945 switch (card->info.type) {
946 case QETH_CARD_TYPE_IQD:
947 case QETH_CARD_TYPE_OSN:
949 #ifdef CONFIG_QETH_IPV6
960 qeth_get_initial_mtu_for_card(struct qeth_card * card)
962 switch (card->info.type) {
963 case QETH_CARD_TYPE_UNKNOWN:
965 case QETH_CARD_TYPE_IQD:
966 return card->info.max_mtu;
967 case QETH_CARD_TYPE_OSAE:
968 switch (card->info.link_type) {
969 case QETH_LINK_TYPE_HSTR:
970 case QETH_LINK_TYPE_LANE_TR:
981 qeth_get_max_mtu_for_card(int cardtype)
985 case QETH_CARD_TYPE_UNKNOWN:
986 case QETH_CARD_TYPE_OSAE:
987 case QETH_CARD_TYPE_OSN:
989 case QETH_CARD_TYPE_IQD:
997 qeth_get_mtu_out_of_mpc(int cardtype)
1000 case QETH_CARD_TYPE_IQD:
1008 qeth_get_mtu_outof_framesize(int framesize)
1010 switch (framesize) {
1025 qeth_mtu_is_valid(struct qeth_card * card, int mtu)
1027 switch (card->info.type) {
1028 case QETH_CARD_TYPE_OSAE:
1029 return ((mtu >= 576) && (mtu <= 61440));
1030 case QETH_CARD_TYPE_IQD:
1031 return ((mtu >= 576) &&
1032 (mtu <= card->info.max_mtu + 4096 - 32));
1033 case QETH_CARD_TYPE_OSN:
1034 case QETH_CARD_TYPE_UNKNOWN:
1041 qeth_get_arphdr_type(int cardtype, int linktype)
1044 case QETH_CARD_TYPE_OSAE:
1045 case QETH_CARD_TYPE_OSN:
1047 case QETH_LINK_TYPE_LANE_TR:
1048 case QETH_LINK_TYPE_HSTR:
1049 return ARPHRD_IEEE802_TR;
1051 return ARPHRD_ETHER;
1053 case QETH_CARD_TYPE_IQD:
1055 return ARPHRD_ETHER;
1059 #ifdef CONFIG_QETH_PERF_STATS
1061 qeth_get_micros(void)
1063 return (int) (get_clock() >> 12);
1068 qeth_get_qdio_q_format(struct qeth_card *card)
1070 switch (card->info.type) {
1071 case QETH_CARD_TYPE_IQD:
1079 qeth_isxdigit(char * buf)
1082 if (!isxdigit(*buf++))
1089 qeth_ipaddr4_to_string(const __u8 *addr, char *buf)
1091 sprintf(buf, "%i.%i.%i.%i", addr[0], addr[1], addr[2], addr[3]);
1095 qeth_string_to_ipaddr4(const char *buf, __u8 *addr)
1097 int count = 0, rc = 0;
1100 rc = sscanf(buf, "%d.%d.%d.%d%n",
1101 &in[0], &in[1], &in[2], &in[3], &count);
1102 if (rc != 4 || count)
1104 for (count = 0; count < 4; count++) {
1105 if (in[count] > 255)
1107 addr[count] = in[count];
1113 qeth_ipaddr6_to_string(const __u8 *addr, char *buf)
1115 sprintf(buf, "%02x%02x:%02x%02x:%02x%02x:%02x%02x"
1116 ":%02x%02x:%02x%02x:%02x%02x:%02x%02x",
1117 addr[0], addr[1], addr[2], addr[3],
1118 addr[4], addr[5], addr[6], addr[7],
1119 addr[8], addr[9], addr[10], addr[11],
1120 addr[12], addr[13], addr[14], addr[15]);
1124 qeth_string_to_ipaddr6(const char *buf, __u8 *addr)
1129 int num2, cnt, out, found, save_cnt;
1130 unsigned short in_tmp[8] = {0, };
1132 cnt = out = found = save_cnt = num2 = 0;
1133 end = start = (char *) buf;
1134 in = (__u16 *) addr;
1137 end = strchr(end,':');
1139 end = (char *)buf + (strlen(buf));
1142 if ((end - start)) {
1144 memcpy(num, start, end - start);
1145 if (!qeth_isxdigit(num))
1147 sscanf(start, "%x", &num2);
1149 in_tmp[save_cnt++] = num2;
1163 in[cnt--] = in_tmp[--save_cnt];
1168 qeth_ipaddr_to_string(enum qeth_prot_versions proto, const __u8 *addr,
1171 if (proto == QETH_PROT_IPV4)
1172 return qeth_ipaddr4_to_string(addr, buf);
1173 else if (proto == QETH_PROT_IPV6)
1174 return qeth_ipaddr6_to_string(addr, buf);
1178 qeth_string_to_ipaddr(const char *buf, enum qeth_prot_versions proto,
1181 if (proto == QETH_PROT_IPV4)
1182 return qeth_string_to_ipaddr4(buf, addr);
1183 else if (proto == QETH_PROT_IPV6)
1184 return qeth_string_to_ipaddr6(buf, addr);
1190 qeth_setrouting_v4(struct qeth_card *);
1192 qeth_setrouting_v6(struct qeth_card *);
1195 qeth_add_ipato_entry(struct qeth_card *, struct qeth_ipato_entry *);
1198 qeth_del_ipato_entry(struct qeth_card *, enum qeth_prot_versions, u8 *, int);
1201 qeth_add_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *);
1204 qeth_del_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *);
1207 qeth_add_rxip(struct qeth_card *, enum qeth_prot_versions, const u8 *);
1210 qeth_del_rxip(struct qeth_card *, enum qeth_prot_versions, const u8 *);
1213 qeth_notifier_register(struct task_struct *, int );
1216 qeth_notifier_unregister(struct task_struct * );
1219 qeth_schedule_recovery(struct qeth_card *);
1222 qeth_realloc_buffer_pool(struct qeth_card *, int);
1225 qeth_set_large_send(struct qeth_card *, enum qeth_large_send_types);
1228 qeth_fill_header(struct qeth_card *, struct qeth_hdr *,
1229 struct sk_buff *, int, int);
1231 qeth_flush_buffers(struct qeth_qdio_out_q *, int, int, int);
1234 qeth_osn_assist(struct net_device *, void *, int);
1237 qeth_osn_register(unsigned char *read_dev_no,
1238 struct net_device **,
1239 int (*assist_cb)(struct net_device *, void *),
1240 int (*data_cb)(struct sk_buff *));
1243 qeth_osn_deregister(struct net_device *);
1245 #endif /* __QETH_H__ */