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.108 $"
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 #define QETH_DBF_TEXT_(name,level,text...) \
96 sprintf(qeth_dbf_text_buf, text); \
97 debug_text_event(qeth_dbf_##name,level,qeth_dbf_text_buf);\
100 #define QETH_DBF_SPRINTF(name,level,text...) \
102 debug_sprintf_event(qeth_dbf_trace, level, ##text ); \
103 debug_sprintf_event(qeth_dbf_trace, level, text ); \
107 * some more debug stuff
109 #define PRINTK_HEADER "qeth: "
111 #define HEXDUMP16(importance,header,ptr) \
112 PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
113 "%02x %02x %02x %02x %02x %02x %02x %02x\n", \
114 *(((char*)ptr)),*(((char*)ptr)+1),*(((char*)ptr)+2), \
115 *(((char*)ptr)+3),*(((char*)ptr)+4),*(((char*)ptr)+5), \
116 *(((char*)ptr)+6),*(((char*)ptr)+7),*(((char*)ptr)+8), \
117 *(((char*)ptr)+9),*(((char*)ptr)+10),*(((char*)ptr)+11), \
118 *(((char*)ptr)+12),*(((char*)ptr)+13), \
119 *(((char*)ptr)+14),*(((char*)ptr)+15)); \
120 PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
121 "%02x %02x %02x %02x %02x %02x %02x %02x\n", \
122 *(((char*)ptr)+16),*(((char*)ptr)+17), \
123 *(((char*)ptr)+18),*(((char*)ptr)+19), \
124 *(((char*)ptr)+20),*(((char*)ptr)+21), \
125 *(((char*)ptr)+22),*(((char*)ptr)+23), \
126 *(((char*)ptr)+24),*(((char*)ptr)+25), \
127 *(((char*)ptr)+26),*(((char*)ptr)+27), \
128 *(((char*)ptr)+28),*(((char*)ptr)+29), \
129 *(((char*)ptr)+30),*(((char*)ptr)+31));
132 qeth_hex_dump(unsigned char *buf, size_t len)
136 for (i = 0; i < len; i++) {
139 printk("%02x ", *(buf + i));
144 #define SENSE_COMMAND_REJECT_BYTE 0
145 #define SENSE_COMMAND_REJECT_FLAG 0x80
146 #define SENSE_RESETTING_EVENT_BYTE 1
147 #define SENSE_RESETTING_EVENT_FLAG 0x80
150 * Common IO related definitions
152 extern struct device *qeth_root_dev;
153 extern struct ccw_driver qeth_ccw_driver;
154 extern struct ccwgroup_driver qeth_ccwgroup_driver;
156 #define CARD_RDEV(card) card->read.ccwdev
157 #define CARD_WDEV(card) card->write.ccwdev
158 #define CARD_DDEV(card) card->data.ccwdev
159 #define CARD_BUS_ID(card) card->gdev->dev.bus_id
160 #define CARD_RDEV_ID(card) card->read.ccwdev->dev.bus_id
161 #define CARD_WDEV_ID(card) card->write.ccwdev->dev.bus_id
162 #define CARD_DDEV_ID(card) card->data.ccwdev->dev.bus_id
163 #define CHANNEL_ID(channel) channel->ccwdev->dev.bus_id
165 #define CARD_FROM_CDEV(cdev) (struct qeth_card *) \
166 ((struct ccwgroup_device *)cdev->dev.driver_data)\
172 #ifdef CONFIG_QETH_PERF_STATS
173 struct qeth_perf_stats {
174 unsigned int bufs_rec;
175 unsigned int bufs_sent;
177 unsigned int skbs_sent_pack;
178 unsigned int bufs_sent_pack;
180 unsigned int sc_dp_p;
181 unsigned int sc_p_dp;
182 /* qdio_input_handler: number of times called, time spent in */
183 __u64 inbound_start_time;
184 unsigned int inbound_cnt;
185 unsigned int inbound_time;
186 /* qeth_send_packet: number of times called, time spent in */
187 __u64 outbound_start_time;
188 unsigned int outbound_cnt;
189 unsigned int outbound_time;
190 /* qdio_output_handler: number of times called, time spent in */
191 __u64 outbound_handler_start_time;
192 unsigned int outbound_handler_cnt;
193 unsigned int outbound_handler_time;
194 /* number of calls to and time spent in do_QDIO for inbound queue */
195 __u64 inbound_do_qdio_start_time;
196 unsigned int inbound_do_qdio_cnt;
197 unsigned int inbound_do_qdio_time;
198 /* number of calls to and time spent in do_QDIO for outbound queues */
199 __u64 outbound_do_qdio_start_time;
200 unsigned int outbound_do_qdio_cnt;
201 unsigned int outbound_do_qdio_time;
203 #endif /* CONFIG_QETH_PERF_STATS */
206 struct qeth_routing_info {
207 enum qeth_routing_types type;
211 struct qeth_ipa_info {
212 __u32 supported_funcs;
217 qeth_is_ipa_supported(struct qeth_ipa_info *ipa, enum qeth_ipa_funcs func)
219 return (ipa->supported_funcs & func);
223 qeth_is_ipa_enabled(struct qeth_ipa_info *ipa, enum qeth_ipa_funcs func)
225 return (ipa->supported_funcs & ipa->enabled_funcs & func);
228 #define qeth_adp_supported(c,f) \
229 qeth_is_ipa_supported(&c->options.adp, f)
230 #define qeth_adp_enabled(c,f) \
231 qeth_is_ipa_enabled(&c->options.adp, f)
232 #define qeth_is_supported(c,f) \
233 qeth_is_ipa_supported(&c->options.ipa4, f)
234 #define qeth_is_enabled(c,f) \
235 qeth_is_ipa_enabled(&c->options.ipa4, f)
236 #ifdef CONFIG_QETH_IPV6
237 #define qeth_is_supported6(c,f) \
238 qeth_is_ipa_supported(&c->options.ipa6, f)
239 #define qeth_is_enabled6(c,f) \
240 qeth_is_ipa_enabled(&c->options.ipa6, f)
241 #else /* CONFIG_QETH_IPV6 */
242 #define qeth_is_supported6(c,f) 0
243 #define qeth_is_enabled6(c,f) 0
244 #endif /* CONFIG_QETH_IPV6 */
245 #define qeth_is_ipafunc_supported(c,prot,f) \
246 (prot==QETH_PROT_IPV6)? qeth_is_supported6(c,f):qeth_is_supported(c,f)
247 #define qeth_is_ipafunc_enabled(c,prot,f) \
248 (prot==QETH_PROT_IPV6)? qeth_is_enabled6(c,f):qeth_is_enabled(c,f)
251 #define QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT 0x0101
252 #define QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT 0x0101
253 #define QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT 0x4108
254 #define QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT 0x5108
256 #define QETH_MODELLIST_ARRAY \
257 {{0x1731,0x01,0x1732,0x01,QETH_CARD_TYPE_OSAE,1, \
258 QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT, \
259 QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT, \
260 QETH_MAX_QUEUES,0}, \
261 {0x1731,0x05,0x1732,0x05,QETH_CARD_TYPE_IQD,0, \
262 QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT, \
263 QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT, \
264 QETH_MAX_QUEUES,0x103}, \
267 #define QETH_REAL_CARD 1
268 #define QETH_VLAN_CARD 2
269 #define QETH_BUFSIZE 4096
274 #define IF_NAME_LEN 16
275 #define QETH_TX_TIMEOUT 100 * HZ
276 #define QETH_HEADER_SIZE 32
277 #define MAX_PORTNO 15
278 #define QETH_FAKE_LL_LEN ETH_HLEN
279 #define QETH_FAKE_LL_V6_ADDR_POS 24
281 /*IPv6 address autoconfiguration stuff*/
282 #define UNIQUE_ID_IF_CREATE_ADDR_FAILED 0xfffe
283 #define UNIQUE_ID_NOT_BY_CARD 0x10000
285 /*****************************************************************************/
286 /* QDIO queue and buffer handling */
287 /*****************************************************************************/
288 #define QETH_MAX_QUEUES 4
289 #define QETH_IN_BUF_SIZE_DEFAULT 65536
290 #define QETH_IN_BUF_COUNT_DEFAULT 16
291 #define QETH_IN_BUF_COUNT_MIN 8
292 #define QETH_IN_BUF_COUNT_MAX 128
293 #define QETH_MAX_BUFFER_ELEMENTS(card) ((card)->qdio.in_buf_size >> 12)
294 #define QETH_IN_BUF_REQUEUE_THRESHOLD(card) \
295 ((card)->qdio.in_buf_pool.buf_count / 2)
297 /* buffers we have to be behind before we get a PCI */
298 #define QETH_PCI_THRESHOLD_A(card) ((card)->qdio.in_buf_pool.buf_count+1)
299 /*enqueued free buffers left before we get a PCI*/
300 #define QETH_PCI_THRESHOLD_B(card) 0
301 /*not used unless the microcode gets patched*/
302 #define QETH_PCI_TIMER_VALUE(card) 3
304 #define QETH_MIN_INPUT_THRESHOLD 1
305 #define QETH_MAX_INPUT_THRESHOLD 500
306 #define QETH_MIN_OUTPUT_THRESHOLD 1
307 #define QETH_MAX_OUTPUT_THRESHOLD 300
309 /* priority queing */
310 #define QETH_PRIOQ_DEFAULT QETH_NO_PRIO_QUEUEING
311 #define QETH_DEFAULT_QUEUE 2
312 #define QETH_NO_PRIO_QUEUEING 0
313 #define QETH_PRIO_Q_ING_PREC 1
314 #define QETH_PRIO_Q_ING_TOS 2
315 #define IP_TOS_LOWDELAY 0x10
316 #define IP_TOS_HIGHTHROUGHPUT 0x08
317 #define IP_TOS_HIGHRELIABILITY 0x04
318 #define IP_TOS_NOTIMPORTANT 0x02
321 #define QETH_LOW_WATERMARK_PACK 2
322 #define QETH_HIGH_WATERMARK_PACK 5
323 #define QETH_WATERMARK_PACK_FUZZ 1
325 #define QETH_IP_HEADER_SIZE 40
327 #define QETH_EXT_HDR_VLAN_FRAME 0x01
328 #define QETH_EXT_HDR_TOKEN_ID 0x02
329 #define QETH_EXT_HDR_INCLUDE_VLAN_TAG 0x04
334 __u16 inbound_checksum;
342 } __attribute__ ((packed));
344 /* flags for qeth_hdr.flags */
345 #define QETH_HDR_PASSTHRU 0x10
346 #define QETH_HDR_IPV6 0x80
347 #define QETH_HDR_CAST_MASK 0x07
348 enum qeth_cast_flags {
349 QETH_CAST_UNICAST = 0x06,
350 QETH_CAST_MULTICAST = 0x04,
351 QETH_CAST_BROADCAST = 0x05,
352 QETH_CAST_ANYCAST = 0x07,
353 QETH_CAST_NOCAST = 0x00,
356 /* flags for qeth_hdr.ext_flags */
357 #define QETH_HDR_EXT_VLAN_FRAME 0x01
358 #define QETH_HDR_EXT_CSUM_HDR_REQ 0x10
359 #define QETH_HDR_EXT_CSUM_TRANSP_REQ 0x20
360 #define QETH_HDR_EXT_SRC_MAC_ADDR 0x08
363 qeth_is_last_sbale(struct qdio_buffer_element *sbale)
365 return (sbale->flags & SBAL_FLAGS_LAST_ENTRY);
368 enum qeth_qdio_buffer_states {
370 * inbound: read out by driver; owned by hardware in order to be filled
371 * outbound: owned by driver in order to be filled
375 * inbound: filled by hardware; owned by driver in order to be read out
376 * outbound: filled by driver; owned by hardware in order to be sent
378 QETH_QDIO_BUF_PRIMED,
380 * inbound only: an error condition has been detected for a buffer
381 * the buffer will be discarded (not read out)
386 enum qeth_qdio_info_states {
387 QETH_QDIO_UNINITIALIZED,
389 QETH_QDIO_ESTABLISHED,
392 struct qeth_buffer_pool_entry {
393 struct list_head list;
394 struct list_head init_list;
395 void *elements[QDIO_MAX_ELEMENTS_PER_BUFFER];
398 struct qeth_qdio_buffer_pool {
399 struct list_head entry_list;
403 struct qeth_qdio_buffer {
404 struct qdio_buffer *buffer;
405 volatile enum qeth_qdio_buffer_states state;
406 /* the buffer pool entry currently associated to this buffer */
407 struct qeth_buffer_pool_entry *pool_entry;
411 struct qdio_buffer qdio_bufs[QDIO_MAX_BUFFERS_PER_Q];
412 struct qeth_qdio_buffer bufs[QDIO_MAX_BUFFERS_PER_Q];
414 * buf_to_init means "buffer must be initialized by driver and must
415 * be made available for hardware" -> state is set to EMPTY
417 volatile int next_buf_to_init;
418 } __attribute__ ((aligned(256)));
420 struct qeth_qdio_out_buffer {
421 struct qdio_buffer *buffer;
422 volatile enum qeth_qdio_buffer_states state;
423 volatile int next_element_to_fill;
424 struct sk_buff_head skb_list;
429 struct qeth_qdio_out_q {
430 struct qdio_buffer qdio_bufs[QDIO_MAX_BUFFERS_PER_Q];
431 struct qeth_qdio_out_buffer bufs[QDIO_MAX_BUFFERS_PER_Q];
433 struct qeth_card *card;
435 volatile int do_pack;
437 * index of buffer to be filled by driver; state EMPTY or PACKING
439 volatile int next_buf_to_fill;
441 * number of buffers that are currently filled (PRIMED)
442 * -> these buffers are hardware-owned
444 atomic_t used_buffers;
445 /* indicates whether PCI flag must be set (or if one is outstanding) */
446 atomic_t set_pci_flags_count;
447 } __attribute__ ((aligned(256)));
449 struct qeth_qdio_info {
450 volatile enum qeth_qdio_info_states state;
452 struct qeth_qdio_q *in_q;
453 struct qeth_qdio_buffer_pool in_buf_pool;
454 struct qeth_qdio_buffer_pool init_pool;
459 struct qeth_qdio_out_q **out_qs;
461 /* priority queueing */
462 int do_prio_queueing;
463 int default_out_queue;
466 enum qeth_send_errors {
467 QETH_SEND_ERROR_NONE,
468 QETH_SEND_ERROR_LINK_FAILURE,
469 QETH_SEND_ERROR_RETRY,
470 QETH_SEND_ERROR_KICK_IT,
473 #define QETH_ETH_MAC_V4 0x0100 /* like v4 */
474 #define QETH_ETH_MAC_V6 0x3333 /* like v6 */
475 /* tr mc mac is longer, but that will be enough to detect mc frames */
476 #define QETH_TR_MAC_NC 0xc000 /* non-canonical */
477 #define QETH_TR_MAC_C 0x0300 /* canonical */
479 #define DEFAULT_ADD_HHLEN 0
480 #define MAX_ADD_HHLEN 1024
483 * buffer stuff for read channel
485 #define QETH_CMD_BUFFER_NO 8
488 * channel state machine
490 enum qeth_channel_states {
500 enum qeth_card_states {
502 CARD_STATE_HARDSETUP,
503 CARD_STATE_SOFTSETUP,
511 enum qeth_prot_versions {
512 QETH_PROT_SNA = 0x0001,
513 QETH_PROT_IPV4 = 0x0004,
514 QETH_PROT_IPV6 = 0x0006,
523 enum qeth_cmd_buffer_state {
529 * IP address and multicast list
532 struct list_head entry;
533 enum qeth_ip_types type;
534 enum qeth_ipa_setdelip_flags set_flags;
535 enum qeth_ipa_setdelip_flags del_flags;
538 enum qeth_prot_versions proto;
539 unsigned char mac[OSA_ADDR_LEN];
546 struct in6_addr addr;
552 struct qeth_ipato_entry {
553 struct list_head entry;
554 enum qeth_prot_versions proto;
563 struct list_head entries;
568 struct qeth_cmd_buffer {
569 enum qeth_cmd_buffer_state state;
570 struct qeth_channel *channel;
573 void (*callback) (struct qeth_channel *, struct qeth_cmd_buffer *);
578 * definition of a qeth channel, used for read and write
580 struct qeth_channel {
581 enum qeth_channel_states state;
584 wait_queue_head_t wait_q;
585 struct tasklet_struct irq_tasklet;
586 struct ccw_device *ccwdev;
587 /*command buffer for control data*/
588 struct qeth_cmd_buffer iob[QETH_CMD_BUFFER_NO];
589 atomic_t irq_pending;
590 volatile int io_buf_no;
595 * OSA card related definitions
602 __u32 cm_connection_w;
603 __u32 cm_connection_r;
606 __u32 ulp_connection_w;
607 __u32 ulp_connection_r;
618 struct list_head list;
619 wait_queue_head_t wait_q;
620 int (*callback)(struct qeth_card *,struct qeth_reply *,unsigned long);
622 unsigned long offset;
626 struct qeth_card *card;
630 #define QETH_BROADCAST_WITH_ECHO 1
631 #define QETH_BROADCAST_WITHOUT_ECHO 2
633 struct qeth_card_info {
634 char if_name[IF_NAME_LEN];
635 unsigned short unit_addr2;
637 unsigned short chpid;
639 char mcl_level[QETH_MCL_LENGTH + 1];
641 int portname_required;
644 enum qeth_card_types type;
645 enum qeth_link_types link_type;
646 int is_multicast_different;
649 int broadcast_capable;
654 struct qeth_card_options {
655 struct qeth_routing_info route4;
656 struct qeth_ipa_info ipa4;
657 struct qeth_ipa_info adp; /*Adapter parameters*/
658 #ifdef CONFIG_QETH_IPV6
659 struct qeth_routing_info route6;
660 struct qeth_ipa_info ipa6;
661 #endif /* QETH_IPV6 */
662 enum qeth_checksum_types checksum_type;
671 * thread bits for qeth_card thread masks
674 QETH_SET_IP_THREAD = 1,
675 QETH_SET_MC_THREAD = 2,
676 QETH_RECOVER_THREAD = 4,
680 struct list_head list;
681 enum qeth_card_states state;
684 /*hardware and sysfs stuff*/
685 struct ccwgroup_device *gdev;
686 struct qeth_channel read;
687 struct qeth_channel write;
688 struct qeth_channel data;
690 struct net_device *dev;
691 struct net_device_stats stats;
693 struct qeth_card_info info;
694 struct qeth_token token;
695 struct qeth_seqno seqno;
696 struct qeth_card_options options;
698 wait_queue_head_t wait_q;
699 #ifdef CONFIG_QETH_VLAN
701 struct vlan_group *vlangrp;
703 struct work_struct kernel_thread_starter;
704 spinlock_t thread_mask_lock;
705 volatile unsigned long thread_start_mask;
706 volatile unsigned long thread_allowed_mask;
707 volatile unsigned long thread_running_mask;
709 struct list_head ip_list;
710 struct list_head ip_tbd_list;
711 struct qeth_ipato ipato;
712 struct list_head cmd_waiter_list;
713 /* QDIO buffer handling */
714 struct qeth_qdio_info qdio;
715 #ifdef CONFIG_QETH_PERF_STATS
716 struct qeth_perf_stats perf_stats;
717 #endif /* CONFIG_QETH_PERF_STATS */
721 struct qeth_card_list_struct {
722 struct list_head list;
726 extern struct qeth_card_list_struct qeth_card_list;
729 struct qeth_notify_list_struct {
730 struct list_head list;
731 struct task_struct *task;
734 extern spinlock_t qeth_notify_lock;
735 extern struct list_head qeth_notify_list;
737 /*some helper functions*/
740 qeth_get_ipa_adp_type(enum qeth_link_types link_type)
743 case QETH_LINK_TYPE_HSTR:
751 qeth_get_hlen(__u8 link_type)
753 #ifdef CONFIG_QETH_IPV6
755 case QETH_LINK_TYPE_HSTR:
756 case QETH_LINK_TYPE_LANE_TR:
757 return sizeof(struct qeth_hdr) + TR_HLEN;
759 #ifdef CONFIG_QETH_VLAN
760 return sizeof(struct qeth_hdr) + VLAN_ETH_HLEN;
762 return sizeof(struct qeth_hdr) + ETH_HLEN;
765 #else /* CONFIG_QETH_IPV6 */
766 #ifdef CONFIG_QETH_VLAN
767 return sizeof(struct qeth_hdr) + VLAN_HLEN;
769 return sizeof(struct qeth_hdr);
771 #endif /* CONFIG_QETH_IPV6 */
774 inline static unsigned short
775 qeth_get_netdev_flags(int cardtype)
778 case QETH_CARD_TYPE_IQD:
780 #ifdef CONFIG_QETH_IPV6
791 qeth_get_initial_mtu_for_card(struct qeth_card * card)
793 switch (card->info.type) {
794 case QETH_CARD_TYPE_UNKNOWN:
796 case QETH_CARD_TYPE_IQD:
797 return card->info.max_mtu;
798 case QETH_CARD_TYPE_OSAE:
799 switch (card->info.link_type) {
800 case QETH_LINK_TYPE_HSTR:
801 case QETH_LINK_TYPE_LANE_TR:
812 qeth_get_max_mtu_for_card(int cardtype)
815 case QETH_CARD_TYPE_UNKNOWN:
817 case QETH_CARD_TYPE_OSAE:
819 case QETH_CARD_TYPE_IQD:
827 qeth_get_mtu_out_of_mpc(int cardtype)
830 case QETH_CARD_TYPE_IQD:
838 qeth_get_mtu_outof_framesize(int framesize)
855 qeth_mtu_is_valid(struct qeth_card * card, int mtu)
857 switch (card->info.type) {
858 case QETH_CARD_TYPE_OSAE:
859 return ((mtu >= 576) && (mtu <= 61440));
860 case QETH_CARD_TYPE_IQD:
861 return ((mtu >= 576) &&
862 (mtu <= card->info.max_mtu + 4096 - 32));
863 case QETH_CARD_TYPE_UNKNOWN:
870 qeth_get_arphdr_type(int cardtype, int linktype)
873 case QETH_CARD_TYPE_OSAE:
875 case QETH_LINK_TYPE_LANE_TR:
876 case QETH_LINK_TYPE_HSTR:
877 return ARPHRD_IEEE802_TR;
881 case QETH_CARD_TYPE_IQD:
887 #ifdef CONFIG_QETH_PERF_STATS
889 qeth_get_micros(void)
891 return (int) (get_clock() >> 12);
896 qeth_get_qdio_q_format(struct qeth_card *card)
898 switch (card->info.type) {
899 case QETH_CARD_TYPE_IQD:
907 qeth_ipaddr4_to_string(const __u8 *addr, char *buf)
909 sprintf(buf, "%i.%i.%i.%i", addr[0], addr[1], addr[2], addr[3]);
913 qeth_string_to_ipaddr4(const char *buf, __u8 *addr)
915 const char *start, *end;
922 for (i = 0; i < 3; i++) {
923 if (!(end = strchr(start, '.')))
927 strncpy(abuf, start, len);
928 addr[i] = simple_strtoul(abuf, &tmp, 10);
933 addr[3] = simple_strtoul(abuf, &tmp, 10);
938 qeth_ipaddr6_to_string(const __u8 *addr, char *buf)
940 sprintf(buf, "%02x%02x:%02x%02x:%02x%02x:%02x%02x"
941 ":%02x%02x:%02x%02x:%02x%02x:%02x%02x",
942 addr[0], addr[1], addr[2], addr[3],
943 addr[4], addr[5], addr[6], addr[7],
944 addr[8], addr[9], addr[10], addr[11],
945 addr[12], addr[13], addr[14], addr[15]);
949 qeth_string_to_ipaddr6(const char *buf, __u8 *addr)
951 const char *start, *end;
958 tmp_addr = (u16 *)addr;
960 for (i = 0; i < 7; i++) {
961 if (!(end = strchr(start, ':')))
965 strncpy(abuf, start, len);
966 tmp_addr[i] = simple_strtoul(abuf, &tmp, 16);
971 tmp_addr[7] = simple_strtoul(abuf, &tmp, 16);
976 qeth_ipaddr_to_string(enum qeth_prot_versions proto, const __u8 *addr,
979 if (proto == QETH_PROT_IPV4)
980 return qeth_ipaddr4_to_string(addr, buf);
981 else if (proto == QETH_PROT_IPV6)
982 return qeth_ipaddr6_to_string(addr, buf);
986 qeth_string_to_ipaddr(const char *buf, enum qeth_prot_versions proto,
989 if (proto == QETH_PROT_IPV4)
990 return qeth_string_to_ipaddr4(buf, addr);
991 else if (proto == QETH_PROT_IPV6)
992 return qeth_string_to_ipaddr6(buf, addr);
998 qeth_setrouting_v4(struct qeth_card *);
1000 qeth_setrouting_v6(struct qeth_card *);
1003 qeth_add_ipato_entry(struct qeth_card *, struct qeth_ipato_entry *);
1006 qeth_del_ipato_entry(struct qeth_card *, enum qeth_prot_versions, u8 *, int);
1009 qeth_add_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *);
1012 qeth_del_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *);
1015 qeth_add_rxip(struct qeth_card *, enum qeth_prot_versions, const u8 *);
1018 qeth_del_rxip(struct qeth_card *, enum qeth_prot_versions, const u8 *);
1021 qeth_notifier_register(struct task_struct *, int );
1024 qeth_notifier_unregister(struct task_struct * );
1027 qeth_schedule_recovery(struct qeth_card *);
1030 qeth_realloc_buffer_pool(struct qeth_card *, int);
1031 #endif /* __QETH_H__ */