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>
13 #include <linux/in6.h>
14 #include <net/if_inet6.h>
15 #include <net/addrconf.h>
18 #include <asm/bitops.h>
19 #include <asm/debug.h>
21 #include <asm/ccwdev.h>
22 #include <asm/ccwgroup.h>
26 #define VERSION_QETH_H "$Revision: 1.110 $"
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_INDEX 3
45 #define QETH_DBF_SETUP_NR_AREAS 1
46 #define QETH_DBF_SETUP_LEVEL 3
48 #define QETH_DBF_MISC_NAME "qeth_misc"
49 #define QETH_DBF_MISC_LEN 128
50 #define QETH_DBF_MISC_INDEX 1
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_INDEX 3
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_INDEX 3
63 #define QETH_DBF_CONTROL_NR_AREAS 2
64 #define QETH_DBF_CONTROL_LEVEL 2
66 #define QETH_DBF_TRACE_NAME "qeth_trace"
67 #define QETH_DBF_TRACE_LEN 8
68 #define QETH_DBF_TRACE_INDEX 2
69 #define QETH_DBF_TRACE_NR_AREAS 2
70 #define QETH_DBF_TRACE_LEVEL 3
72 #define QETH_DBF_SENSE_NAME "qeth_sense"
73 #define QETH_DBF_SENSE_LEN 64
74 #define QETH_DBF_SENSE_INDEX 1
75 #define QETH_DBF_SENSE_NR_AREAS 1
76 #define QETH_DBF_SENSE_LEVEL 2
78 #define QETH_DBF_QERR_NAME "qeth_qerr"
79 #define QETH_DBF_QERR_LEN 8
80 #define QETH_DBF_QERR_INDEX 1
81 #define QETH_DBF_QERR_NR_AREAS 2
82 #define QETH_DBF_QERR_LEVEL 2
84 #define QETH_DBF_TEXT(name,level,text) \
86 debug_text_event(qeth_dbf_##name,level,text); \
89 #define QETH_DBF_HEX(name,level,addr,len) \
91 debug_event(qeth_dbf_##name,level,(void*)(addr),len); \
94 extern DEFINE_PER_CPU(char[256], qeth_dbf_txt_buf);
96 #define QETH_DBF_TEXT_(name,level,text...) \
98 char* dbf_txt_buf = get_cpu_var(qeth_dbf_txt_buf); \
99 sprintf(dbf_txt_buf, text); \
100 debug_text_event(qeth_dbf_##name,level,dbf_txt_buf); \
101 put_cpu_var(qeth_dbf_txt_buf); \
104 #define QETH_DBF_SPRINTF(name,level,text...) \
106 debug_sprintf_event(qeth_dbf_trace, level, ##text ); \
107 debug_sprintf_event(qeth_dbf_trace, level, text ); \
111 * some more debug stuff
113 #define PRINTK_HEADER "qeth: "
115 #define HEXDUMP16(importance,header,ptr) \
116 PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
117 "%02x %02x %02x %02x %02x %02x %02x %02x\n", \
118 *(((char*)ptr)),*(((char*)ptr)+1),*(((char*)ptr)+2), \
119 *(((char*)ptr)+3),*(((char*)ptr)+4),*(((char*)ptr)+5), \
120 *(((char*)ptr)+6),*(((char*)ptr)+7),*(((char*)ptr)+8), \
121 *(((char*)ptr)+9),*(((char*)ptr)+10),*(((char*)ptr)+11), \
122 *(((char*)ptr)+12),*(((char*)ptr)+13), \
123 *(((char*)ptr)+14),*(((char*)ptr)+15)); \
124 PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
125 "%02x %02x %02x %02x %02x %02x %02x %02x\n", \
126 *(((char*)ptr)+16),*(((char*)ptr)+17), \
127 *(((char*)ptr)+18),*(((char*)ptr)+19), \
128 *(((char*)ptr)+20),*(((char*)ptr)+21), \
129 *(((char*)ptr)+22),*(((char*)ptr)+23), \
130 *(((char*)ptr)+24),*(((char*)ptr)+25), \
131 *(((char*)ptr)+26),*(((char*)ptr)+27), \
132 *(((char*)ptr)+28),*(((char*)ptr)+29), \
133 *(((char*)ptr)+30),*(((char*)ptr)+31));
136 qeth_hex_dump(unsigned char *buf, size_t len)
140 for (i = 0; i < len; i++) {
143 printk("%02x ", *(buf + i));
148 #define SENSE_COMMAND_REJECT_BYTE 0
149 #define SENSE_COMMAND_REJECT_FLAG 0x80
150 #define SENSE_RESETTING_EVENT_BYTE 1
151 #define SENSE_RESETTING_EVENT_FLAG 0x80
154 * Common IO related definitions
156 extern struct device *qeth_root_dev;
157 extern struct ccw_driver qeth_ccw_driver;
158 extern struct ccwgroup_driver qeth_ccwgroup_driver;
160 #define CARD_RDEV(card) card->read.ccwdev
161 #define CARD_WDEV(card) card->write.ccwdev
162 #define CARD_DDEV(card) card->data.ccwdev
163 #define CARD_BUS_ID(card) card->gdev->dev.bus_id
164 #define CARD_RDEV_ID(card) card->read.ccwdev->dev.bus_id
165 #define CARD_WDEV_ID(card) card->write.ccwdev->dev.bus_id
166 #define CARD_DDEV_ID(card) card->data.ccwdev->dev.bus_id
167 #define CHANNEL_ID(channel) channel->ccwdev->dev.bus_id
169 #define CARD_FROM_CDEV(cdev) (struct qeth_card *) \
170 ((struct ccwgroup_device *)cdev->dev.driver_data)\
176 #ifdef CONFIG_QETH_PERF_STATS
177 struct qeth_perf_stats {
178 unsigned int bufs_rec;
179 unsigned int bufs_sent;
181 unsigned int skbs_sent_pack;
182 unsigned int bufs_sent_pack;
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;
207 #endif /* CONFIG_QETH_PERF_STATS */
210 struct qeth_routing_info {
211 enum qeth_routing_types type;
215 struct qeth_ipa_info {
216 __u32 supported_funcs;
221 qeth_is_ipa_supported(struct qeth_ipa_info *ipa, enum qeth_ipa_funcs func)
223 return (ipa->supported_funcs & func);
227 qeth_is_ipa_enabled(struct qeth_ipa_info *ipa, enum qeth_ipa_funcs func)
229 return (ipa->supported_funcs & ipa->enabled_funcs & func);
232 #define qeth_adp_supported(c,f) \
233 qeth_is_ipa_supported(&c->options.adp, f)
234 #define qeth_adp_enabled(c,f) \
235 qeth_is_ipa_enabled(&c->options.adp, f)
236 #define qeth_is_supported(c,f) \
237 qeth_is_ipa_supported(&c->options.ipa4, f)
238 #define qeth_is_enabled(c,f) \
239 qeth_is_ipa_enabled(&c->options.ipa4, f)
240 #ifdef CONFIG_QETH_IPV6
241 #define qeth_is_supported6(c,f) \
242 qeth_is_ipa_supported(&c->options.ipa6, f)
243 #define qeth_is_enabled6(c,f) \
244 qeth_is_ipa_enabled(&c->options.ipa6, f)
245 #else /* CONFIG_QETH_IPV6 */
246 #define qeth_is_supported6(c,f) 0
247 #define qeth_is_enabled6(c,f) 0
248 #endif /* CONFIG_QETH_IPV6 */
249 #define qeth_is_ipafunc_supported(c,prot,f) \
250 (prot==QETH_PROT_IPV6)? qeth_is_supported6(c,f):qeth_is_supported(c,f)
251 #define qeth_is_ipafunc_enabled(c,prot,f) \
252 (prot==QETH_PROT_IPV6)? qeth_is_enabled6(c,f):qeth_is_enabled(c,f)
255 #define QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT 0x0101
256 #define QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT 0x0101
257 #define QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT 0x4108
258 #define QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT 0x5108
260 #define QETH_MODELLIST_ARRAY \
261 {{0x1731,0x01,0x1732,0x01,QETH_CARD_TYPE_OSAE,1, \
262 QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT, \
263 QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT, \
264 QETH_MAX_QUEUES,0}, \
265 {0x1731,0x05,0x1732,0x05,QETH_CARD_TYPE_IQD,0, \
266 QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT, \
267 QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT, \
268 QETH_MAX_QUEUES,0x103}, \
271 #define QETH_REAL_CARD 1
272 #define QETH_VLAN_CARD 2
273 #define QETH_BUFSIZE 4096
278 #define IF_NAME_LEN 16
279 #define QETH_TX_TIMEOUT 100 * HZ
280 #define QETH_HEADER_SIZE 32
281 #define MAX_PORTNO 15
282 #define QETH_FAKE_LL_LEN ETH_HLEN
283 #define QETH_FAKE_LL_V6_ADDR_POS 24
285 /*IPv6 address autoconfiguration stuff*/
286 #define UNIQUE_ID_IF_CREATE_ADDR_FAILED 0xfffe
287 #define UNIQUE_ID_NOT_BY_CARD 0x10000
289 /*****************************************************************************/
290 /* QDIO queue and buffer handling */
291 /*****************************************************************************/
292 #define QETH_MAX_QUEUES 4
293 #define QETH_IN_BUF_SIZE_DEFAULT 65536
294 #define QETH_IN_BUF_COUNT_DEFAULT 16
295 #define QETH_IN_BUF_COUNT_MIN 8
296 #define QETH_IN_BUF_COUNT_MAX 128
297 #define QETH_MAX_BUFFER_ELEMENTS(card) ((card)->qdio.in_buf_size >> 12)
298 #define QETH_IN_BUF_REQUEUE_THRESHOLD(card) \
299 ((card)->qdio.in_buf_pool.buf_count / 2)
301 /* buffers we have to be behind before we get a PCI */
302 #define QETH_PCI_THRESHOLD_A(card) ((card)->qdio.in_buf_pool.buf_count+1)
303 /*enqueued free buffers left before we get a PCI*/
304 #define QETH_PCI_THRESHOLD_B(card) 0
305 /*not used unless the microcode gets patched*/
306 #define QETH_PCI_TIMER_VALUE(card) 3
308 #define QETH_MIN_INPUT_THRESHOLD 1
309 #define QETH_MAX_INPUT_THRESHOLD 500
310 #define QETH_MIN_OUTPUT_THRESHOLD 1
311 #define QETH_MAX_OUTPUT_THRESHOLD 300
313 /* priority queing */
314 #define QETH_PRIOQ_DEFAULT QETH_NO_PRIO_QUEUEING
315 #define QETH_DEFAULT_QUEUE 2
316 #define QETH_NO_PRIO_QUEUEING 0
317 #define QETH_PRIO_Q_ING_PREC 1
318 #define QETH_PRIO_Q_ING_TOS 2
319 #define IP_TOS_LOWDELAY 0x10
320 #define IP_TOS_HIGHTHROUGHPUT 0x08
321 #define IP_TOS_HIGHRELIABILITY 0x04
322 #define IP_TOS_NOTIMPORTANT 0x02
325 #define QETH_LOW_WATERMARK_PACK 2
326 #define QETH_HIGH_WATERMARK_PACK 5
327 #define QETH_WATERMARK_PACK_FUZZ 1
329 #define QETH_IP_HEADER_SIZE 40
331 #define QETH_EXT_HDR_VLAN_FRAME 0x01
332 #define QETH_EXT_HDR_TOKEN_ID 0x02
333 #define QETH_EXT_HDR_INCLUDE_VLAN_TAG 0x04
338 __u16 inbound_checksum;
346 } __attribute__ ((packed));
348 /* flags for qeth_hdr.flags */
349 #define QETH_HDR_PASSTHRU 0x10
350 #define QETH_HDR_IPV6 0x80
351 #define QETH_HDR_CAST_MASK 0x07
352 enum qeth_cast_flags {
353 QETH_CAST_UNICAST = 0x06,
354 QETH_CAST_MULTICAST = 0x04,
355 QETH_CAST_BROADCAST = 0x05,
356 QETH_CAST_ANYCAST = 0x07,
357 QETH_CAST_NOCAST = 0x00,
360 /* flags for qeth_hdr.ext_flags */
361 #define QETH_HDR_EXT_VLAN_FRAME 0x01
362 #define QETH_HDR_EXT_CSUM_HDR_REQ 0x10
363 #define QETH_HDR_EXT_CSUM_TRANSP_REQ 0x20
364 #define QETH_HDR_EXT_SRC_MAC_ADDR 0x08
367 qeth_is_last_sbale(struct qdio_buffer_element *sbale)
369 return (sbale->flags & SBAL_FLAGS_LAST_ENTRY);
372 enum qeth_qdio_buffer_states {
374 * inbound: read out by driver; owned by hardware in order to be filled
375 * outbound: owned by driver in order to be filled
379 * inbound: filled by hardware; owned by driver in order to be read out
380 * outbound: filled by driver; owned by hardware in order to be sent
382 QETH_QDIO_BUF_PRIMED,
385 enum qeth_qdio_info_states {
386 QETH_QDIO_UNINITIALIZED,
388 QETH_QDIO_ESTABLISHED,
391 struct qeth_buffer_pool_entry {
392 struct list_head list;
393 struct list_head init_list;
394 void *elements[QDIO_MAX_ELEMENTS_PER_BUFFER];
397 struct qeth_qdio_buffer_pool {
398 struct list_head entry_list;
402 struct qeth_qdio_buffer {
403 struct qdio_buffer *buffer;
404 volatile enum qeth_qdio_buffer_states state;
405 /* the buffer pool entry currently associated to this buffer */
406 struct qeth_buffer_pool_entry *pool_entry;
410 struct qdio_buffer qdio_bufs[QDIO_MAX_BUFFERS_PER_Q];
411 struct qeth_qdio_buffer bufs[QDIO_MAX_BUFFERS_PER_Q];
413 * buf_to_init means "buffer must be initialized by driver and must
414 * be made available for hardware" -> state is set to EMPTY
416 volatile int next_buf_to_init;
417 } __attribute__ ((aligned(256)));
419 struct qeth_qdio_out_buffer {
420 struct qdio_buffer *buffer;
422 volatile int next_element_to_fill;
423 struct sk_buff_head skb_list;
428 struct qeth_qdio_out_q {
429 struct qdio_buffer qdio_bufs[QDIO_MAX_BUFFERS_PER_Q];
430 struct qeth_qdio_out_buffer bufs[QDIO_MAX_BUFFERS_PER_Q];
432 struct qeth_card *card;
434 volatile int do_pack;
436 * index of buffer to be filled by driver; state EMPTY or PACKING
438 volatile int next_buf_to_fill;
440 * number of buffers that are currently filled (PRIMED)
441 * -> these buffers are hardware-owned
443 atomic_t used_buffers;
444 /* indicates whether PCI flag must be set (or if one is outstanding) */
445 atomic_t set_pci_flags_count;
446 } __attribute__ ((aligned(256)));
448 struct qeth_qdio_info {
449 volatile enum qeth_qdio_info_states state;
451 struct qeth_qdio_q *in_q;
452 struct qeth_qdio_buffer_pool in_buf_pool;
453 struct qeth_qdio_buffer_pool init_pool;
458 struct qeth_qdio_out_q **out_qs;
460 /* priority queueing */
461 int do_prio_queueing;
462 int default_out_queue;
465 enum qeth_send_errors {
466 QETH_SEND_ERROR_NONE,
467 QETH_SEND_ERROR_LINK_FAILURE,
468 QETH_SEND_ERROR_RETRY,
469 QETH_SEND_ERROR_KICK_IT,
472 #define QETH_ETH_MAC_V4 0x0100 /* like v4 */
473 #define QETH_ETH_MAC_V6 0x3333 /* like v6 */
474 /* tr mc mac is longer, but that will be enough to detect mc frames */
475 #define QETH_TR_MAC_NC 0xc000 /* non-canonical */
476 #define QETH_TR_MAC_C 0x0300 /* canonical */
478 #define DEFAULT_ADD_HHLEN 0
479 #define MAX_ADD_HHLEN 1024
482 * buffer stuff for read channel
484 #define QETH_CMD_BUFFER_NO 8
487 * channel state machine
489 enum qeth_channel_states {
499 enum qeth_card_states {
501 CARD_STATE_HARDSETUP,
502 CARD_STATE_SOFTSETUP,
510 enum qeth_prot_versions {
511 QETH_PROT_SNA = 0x0001,
512 QETH_PROT_IPV4 = 0x0004,
513 QETH_PROT_IPV6 = 0x0006,
522 enum qeth_cmd_buffer_state {
528 * IP address and multicast list
531 struct list_head entry;
532 enum qeth_ip_types type;
533 enum qeth_ipa_setdelip_flags set_flags;
534 enum qeth_ipa_setdelip_flags del_flags;
537 enum qeth_prot_versions proto;
538 unsigned char mac[OSA_ADDR_LEN];
545 struct in6_addr addr;
551 struct qeth_ipato_entry {
552 struct list_head entry;
553 enum qeth_prot_versions proto;
562 struct list_head entries;
567 struct qeth_cmd_buffer {
568 enum qeth_cmd_buffer_state state;
569 struct qeth_channel *channel;
572 void (*callback) (struct qeth_channel *, struct qeth_cmd_buffer *);
577 * definition of a qeth channel, used for read and write
579 struct qeth_channel {
580 enum qeth_channel_states state;
583 wait_queue_head_t wait_q;
584 struct tasklet_struct irq_tasklet;
585 struct ccw_device *ccwdev;
586 /*command buffer for control data*/
587 struct qeth_cmd_buffer iob[QETH_CMD_BUFFER_NO];
588 atomic_t irq_pending;
589 volatile int io_buf_no;
594 * OSA card related definitions
601 __u32 cm_connection_w;
602 __u32 cm_connection_r;
605 __u32 ulp_connection_w;
606 __u32 ulp_connection_r;
617 struct list_head list;
618 wait_queue_head_t wait_q;
619 int (*callback)(struct qeth_card *,struct qeth_reply *,unsigned long);
621 unsigned long offset;
625 struct qeth_card *card;
629 #define QETH_BROADCAST_WITH_ECHO 1
630 #define QETH_BROADCAST_WITHOUT_ECHO 2
632 struct qeth_card_info {
633 char if_name[IF_NAME_LEN];
634 unsigned short unit_addr2;
636 unsigned short chpid;
638 char mcl_level[QETH_MCL_LENGTH + 1];
640 int portname_required;
643 enum qeth_card_types type;
644 enum qeth_link_types link_type;
645 int is_multicast_different;
648 int broadcast_capable;
653 struct qeth_card_options {
654 struct qeth_routing_info route4;
655 struct qeth_ipa_info ipa4;
656 struct qeth_ipa_info adp; /*Adapter parameters*/
657 #ifdef CONFIG_QETH_IPV6
658 struct qeth_routing_info route6;
659 struct qeth_ipa_info ipa6;
660 #endif /* QETH_IPV6 */
661 enum qeth_checksum_types checksum_type;
670 * thread bits for qeth_card thread masks
673 QETH_SET_IP_THREAD = 1,
674 QETH_SET_MC_THREAD = 2,
675 QETH_RECOVER_THREAD = 4,
679 struct list_head list;
680 enum qeth_card_states state;
683 /*hardware and sysfs stuff*/
684 struct ccwgroup_device *gdev;
685 struct qeth_channel read;
686 struct qeth_channel write;
687 struct qeth_channel data;
689 struct net_device *dev;
690 struct net_device_stats stats;
692 struct qeth_card_info info;
693 struct qeth_token token;
694 struct qeth_seqno seqno;
695 struct qeth_card_options options;
697 wait_queue_head_t wait_q;
698 #ifdef CONFIG_QETH_VLAN
700 struct vlan_group *vlangrp;
702 struct work_struct kernel_thread_starter;
703 spinlock_t thread_mask_lock;
704 volatile unsigned long thread_start_mask;
705 volatile unsigned long thread_allowed_mask;
706 volatile unsigned long thread_running_mask;
708 struct list_head ip_list;
709 struct list_head ip_tbd_list;
710 struct qeth_ipato ipato;
711 struct list_head cmd_waiter_list;
712 /* QDIO buffer handling */
713 struct qeth_qdio_info qdio;
714 #ifdef CONFIG_QETH_PERF_STATS
715 struct qeth_perf_stats perf_stats;
716 #endif /* CONFIG_QETH_PERF_STATS */
720 struct qeth_card_list_struct {
721 struct list_head list;
725 extern struct qeth_card_list_struct qeth_card_list;
728 struct qeth_notify_list_struct {
729 struct list_head list;
730 struct task_struct *task;
733 extern spinlock_t qeth_notify_lock;
734 extern struct list_head qeth_notify_list;
736 /*some helper functions*/
739 qeth_get_ipa_adp_type(enum qeth_link_types link_type)
742 case QETH_LINK_TYPE_HSTR:
750 qeth_get_hlen(__u8 link_type)
752 #ifdef CONFIG_QETH_IPV6
754 case QETH_LINK_TYPE_HSTR:
755 case QETH_LINK_TYPE_LANE_TR:
756 return sizeof(struct qeth_hdr) + TR_HLEN;
758 #ifdef CONFIG_QETH_VLAN
759 return sizeof(struct qeth_hdr) + VLAN_ETH_HLEN;
761 return sizeof(struct qeth_hdr) + ETH_HLEN;
764 #else /* CONFIG_QETH_IPV6 */
765 #ifdef CONFIG_QETH_VLAN
766 return sizeof(struct qeth_hdr) + VLAN_HLEN;
768 return sizeof(struct qeth_hdr);
770 #endif /* CONFIG_QETH_IPV6 */
773 inline static unsigned short
774 qeth_get_netdev_flags(int cardtype)
777 case QETH_CARD_TYPE_IQD:
779 #ifdef CONFIG_QETH_IPV6
790 qeth_get_initial_mtu_for_card(struct qeth_card * card)
792 switch (card->info.type) {
793 case QETH_CARD_TYPE_UNKNOWN:
795 case QETH_CARD_TYPE_IQD:
796 return card->info.max_mtu;
797 case QETH_CARD_TYPE_OSAE:
798 switch (card->info.link_type) {
799 case QETH_LINK_TYPE_HSTR:
800 case QETH_LINK_TYPE_LANE_TR:
811 qeth_get_max_mtu_for_card(int cardtype)
814 case QETH_CARD_TYPE_UNKNOWN:
816 case QETH_CARD_TYPE_OSAE:
818 case QETH_CARD_TYPE_IQD:
826 qeth_get_mtu_out_of_mpc(int cardtype)
829 case QETH_CARD_TYPE_IQD:
837 qeth_get_mtu_outof_framesize(int framesize)
854 qeth_mtu_is_valid(struct qeth_card * card, int mtu)
856 switch (card->info.type) {
857 case QETH_CARD_TYPE_OSAE:
858 return ((mtu >= 576) && (mtu <= 61440));
859 case QETH_CARD_TYPE_IQD:
860 return ((mtu >= 576) &&
861 (mtu <= card->info.max_mtu + 4096 - 32));
862 case QETH_CARD_TYPE_UNKNOWN:
869 qeth_get_arphdr_type(int cardtype, int linktype)
872 case QETH_CARD_TYPE_OSAE:
874 case QETH_LINK_TYPE_LANE_TR:
875 case QETH_LINK_TYPE_HSTR:
876 return ARPHRD_IEEE802_TR;
880 case QETH_CARD_TYPE_IQD:
886 #ifdef CONFIG_QETH_PERF_STATS
888 qeth_get_micros(void)
890 return (int) (get_clock() >> 12);
895 qeth_get_qdio_q_format(struct qeth_card *card)
897 switch (card->info.type) {
898 case QETH_CARD_TYPE_IQD:
906 qeth_ipaddr4_to_string(const __u8 *addr, char *buf)
908 sprintf(buf, "%i.%i.%i.%i", addr[0], addr[1], addr[2], addr[3]);
912 qeth_string_to_ipaddr4(const char *buf, __u8 *addr)
914 const char *start, *end;
921 for (i = 0; i < 3; i++) {
922 if (!(end = strchr(start, '.')))
926 strncpy(abuf, start, len);
927 addr[i] = simple_strtoul(abuf, &tmp, 10);
932 addr[3] = simple_strtoul(abuf, &tmp, 10);
937 qeth_ipaddr6_to_string(const __u8 *addr, char *buf)
939 sprintf(buf, "%02x%02x:%02x%02x:%02x%02x:%02x%02x"
940 ":%02x%02x:%02x%02x:%02x%02x:%02x%02x",
941 addr[0], addr[1], addr[2], addr[3],
942 addr[4], addr[5], addr[6], addr[7],
943 addr[8], addr[9], addr[10], addr[11],
944 addr[12], addr[13], addr[14], addr[15]);
948 qeth_string_to_ipaddr6(const char *buf, __u8 *addr)
950 const char *start, *end;
957 tmp_addr = (u16 *)addr;
959 for (i = 0; i < 7; i++) {
960 if (!(end = strchr(start, ':')))
964 strncpy(abuf, start, len);
965 tmp_addr[i] = simple_strtoul(abuf, &tmp, 16);
970 tmp_addr[7] = simple_strtoul(abuf, &tmp, 16);
975 qeth_ipaddr_to_string(enum qeth_prot_versions proto, const __u8 *addr,
978 if (proto == QETH_PROT_IPV4)
979 return qeth_ipaddr4_to_string(addr, buf);
980 else if (proto == QETH_PROT_IPV6)
981 return qeth_ipaddr6_to_string(addr, buf);
985 qeth_string_to_ipaddr(const char *buf, enum qeth_prot_versions proto,
988 if (proto == QETH_PROT_IPV4)
989 return qeth_string_to_ipaddr4(buf, addr);
990 else if (proto == QETH_PROT_IPV6)
991 return qeth_string_to_ipaddr6(buf, addr);
997 qeth_setrouting_v4(struct qeth_card *);
999 qeth_setrouting_v6(struct qeth_card *);
1002 qeth_add_ipato_entry(struct qeth_card *, struct qeth_ipato_entry *);
1005 qeth_del_ipato_entry(struct qeth_card *, enum qeth_prot_versions, u8 *, int);
1008 qeth_add_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *);
1011 qeth_del_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *);
1014 qeth_add_rxip(struct qeth_card *, enum qeth_prot_versions, const u8 *);
1017 qeth_del_rxip(struct qeth_card *, enum qeth_prot_versions, const u8 *);
1020 qeth_notifier_register(struct task_struct *, int );
1023 qeth_notifier_unregister(struct task_struct * );
1026 qeth_schedule_recovery(struct qeth_card *);
1029 qeth_realloc_buffer_pool(struct qeth_card *, int);
1030 #endif /* __QETH_H__ */