1 /*
2  * linux/drivers/s390/net/qeth.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  *
9  */
10 
11 #ifndef __QETH_H__
12 #define __QETH_H__
13 
14 #include <asm/qdio.h>
15 
16 #define QETH_NAME " qeth"
17 
18 #define VERSION_QETH_H "$Revision: 1.113.4.8 $"
19 
20 /******************** CONFIG STUFF ***********************/
21 //#define QETH_DBF_LIKE_HELL
22 
23 #ifdef CONFIG_QETH_IPV6
24 #define QETH_IPV6
25 #define QETH_VERSION_IPV6 ":IPv6"
26 #else
27 #define QETH_VERSION_IPV6 ""
28 #endif /* CONFIG_QETH_IPV6 */
29 
30 #ifdef CONFIG_QETH_VLAN
31 #define QETH_VLAN
32 #define QETH_VERSION_VLAN ":VLAN"
33 #else
34 #define QETH_VERSION_VLAN ""
35 #endif /* CONFIG_QETH_VLAN */
36 
37 /* these values match CHECKSUM_* in include/linux/skbuff.h */
38 #define SW_CHECKSUMMING 0
39 #define HW_CHECKSUMMING 1
40 #define NO_CHECKSUMMING 2
41 
42 #define QETH_CHECKSUM_DEFAULT NO_CHECKSUMMING
43 
44 #define QETH_DEFAULT_QUEUE 2
45 
46 /******************** CONFIG STUFF END ***********************/
47 /********************* TUNING STUFF **************************/
48 #define HIGH_WATERMARK_PACK		5
49 #define LOW_WATERMARK_PACK		2
50 #define WATERMARK_FUZZ			1
51 
52 #define QETH_MAX_INPUT_THRESHOLD 500
53 #define QETH_MAX_OUTPUT_THRESHOLD 300 /* ? */
54 
55 /* only the MAX values are used */
56 #define QETH_MIN_INPUT_THRESHOLD 1
57 #define QETH_MIN_OUTPUT_THRESHOLD 1
58 
59 #define QETH_REQUEUE_THRESHOLD (card->options.inbound_buffer_count/4)
60 
61 #ifdef CONFIG_QETH_PERF_STATS
62 #define QETH_PERFORMANCE_STATS
63 #endif /* CONFIG_QETH_PERF_STATS */
64 
65 #define QETH_VERBOSE_LEVEL 7
66 
67 #define PCI_THRESHOLD_A (card->options.inbound_buffer_count+1) /* buffers we have to be behind
68 			     before we get a PCI */
69 #define PCI_THRESHOLD_B 0 /* enqueued free buffers left before we get a PCI */
70 #define PCI_TIMER_VALUE 3 /* not used, unless the microcode gets patched */
71 
72 #define DEFAULT_SPARE_BUFFERS 0
73 #define MAX_SPARE_BUFFERS 1024
74 #define SPAREBUF_MASK 65536
75 #define MAX_PORTNO 15
76 
77 #define QETH_PROCFILE_NAME "qeth"
78 #define QETH_PERF_PROCFILE_NAME "qeth_perf"
79 #define QETH_IPA_PROCFILE_NAME "qeth_ipa_takeover"
80 
81 #define SEND_RETRIES_ALLOWED 5
82 #define QETH_ROUTING_ATTEMPTS 2
83 
84 #define QETH_HARDSETUP_LAPS 5
85 #define QETH_HARDSETUP_CLEAR_LAPS 3
86 #define QETH_RECOVERY_HARDSETUP_RETRY 2
87 
88 /* the worst case stack usage is:
89  * qeth_hard_start_xmit
90  * do_QDIO
91  * qeth_qdio_output_handler
92  * do_QDIO
93  * qeth_qdio_output_handler
94  * (no more recursion as we have called netif_stop_queue)
95  */
96 #ifdef CONFIG_ARCH_S390X
97 #define STACK_PTR_MASK 0x3fff
98 #define WORST_CASE_STACK_USAGE 1100
99 #else /* CONFIG_ARCH_S390X */
100 #define STACK_PTR_MASK 0x1fff
101 #define WORST_CASE_STACK_USAGE 800
102 #endif /* CONFIG_ARCH_S390X */
103 
104 /************************* DEBUG FACILITY STUFF *********************/
105 
106 #define QETH_DBF_HEX(ex,name,level,addr,len) \
107         do { \
108         if (ex) \
109                 debug_exception(qeth_dbf_##name,level,(void*)addr,len); \
110         else \
111                 debug_event(qeth_dbf_##name,level,(void*)addr,len); \
112         } while (0)
113 #define QETH_DBF_TEXT(ex,name,level,text) \
114         do { \
115         if (ex) \
116                 debug_text_exception(qeth_dbf_##name,level,text); \
117         else \
118                 debug_text_event(qeth_dbf_##name,level,text); \
119         } while (0)
120 
121 #define QETH_DBF_HEX0(ex,name,addr,len) QETH_DBF_HEX(ex,name,0,addr,len)
122 #define QETH_DBF_HEX1(ex,name,addr,len) QETH_DBF_HEX(ex,name,1,addr,len)
123 #define QETH_DBF_HEX2(ex,name,addr,len) QETH_DBF_HEX(ex,name,2,addr,len)
124 #define QETH_DBF_HEX3(ex,name,addr,len) QETH_DBF_HEX(ex,name,3,addr,len)
125 #define QETH_DBF_HEX4(ex,name,addr,len) QETH_DBF_HEX(ex,name,4,addr,len)
126 #define QETH_DBF_HEX5(ex,name,addr,len) QETH_DBF_HEX(ex,name,5,addr,len)
127 #define QETH_DBF_HEX6(ex,name,addr,len) QETH_DBF_HEX(ex,name,6,addr,len)
128 #ifdef QETH_DBF_LIKE_HELL
129 #endif /* QETH_DBF_LIKE_HELL */
130 
131 #define QETH_DBF_TEXT0(ex,name,text) QETH_DBF_TEXT(ex,name,0,text)
132 #define QETH_DBF_TEXT1(ex,name,text) QETH_DBF_TEXT(ex,name,1,text)
133 #define QETH_DBF_TEXT2(ex,name,text) QETH_DBF_TEXT(ex,name,2,text)
134 #define QETH_DBF_TEXT3(ex,name,text) QETH_DBF_TEXT(ex,name,3,text)
135 #define QETH_DBF_TEXT4(ex,name,text) QETH_DBF_TEXT(ex,name,4,text)
136 #define QETH_DBF_TEXT5(ex,name,text) QETH_DBF_TEXT(ex,name,5,text)
137 #define QETH_DBF_TEXT6(ex,name,text) QETH_DBF_TEXT(ex,name,6,text)
138 #ifdef QETH_DBF_LIKE_HELL
139 #endif /* QETH_DBF_LIKE_HELL */
140 
141 #define QETH_DBF_SETUP_NAME "qeth_setup"
142 #define QETH_DBF_SETUP_LEN 8
143 #define QETH_DBF_SETUP_INDEX 3
144 #define QETH_DBF_SETUP_NR_AREAS 1
145 #ifdef QETH_DBF_LIKE_HELL
146 #define QETH_DBF_SETUP_LEVEL 6
147 #else /* QETH_DBF_LIKE_HELL */
148 #define QETH_DBF_SETUP_LEVEL 3
149 #endif /* QETH_DBF_LIKE_HELL */
150 
151 #define QETH_DBF_MISC_NAME "qeth_misc"
152 #define QETH_DBF_MISC_LEN 128
153 #define QETH_DBF_MISC_INDEX 1
154 #define QETH_DBF_MISC_NR_AREAS 1
155 #ifdef QETH_DBF_LIKE_HELL
156 #define QETH_DBF_MISC_LEVEL 6
157 #else /* QETH_DBF_LIKE_HELL */
158 #define QETH_DBF_MISC_LEVEL 2
159 #endif /* QETH_DBF_LIKE_HELL */
160 
161 #define QETH_DBF_DATA_NAME "qeth_data"
162 #define QETH_DBF_DATA_LEN 96
163 #define QETH_DBF_DATA_INDEX 3
164 #define QETH_DBF_DATA_NR_AREAS 1
165 #ifdef QETH_DBF_LIKE_HELL
166 #define QETH_DBF_DATA_LEVEL 6
167 #else /* QETH_DBF_LIKE_HELL */
168 #define QETH_DBF_DATA_LEVEL 2
169 #endif /* QETH_DBF_LIKE_HELL */
170 
171 #define QETH_DBF_CONTROL_NAME "qeth_control"
172 /* buffers are 255 bytes long, but no prob */
173 #define QETH_DBF_CONTROL_LEN 256
174 #define QETH_DBF_CONTROL_INDEX 3
175 #define QETH_DBF_CONTROL_NR_AREAS 2
176 #ifdef QETH_DBF_LIKE_HELL
177 #define QETH_DBF_CONTROL_LEVEL 6
178 #else /* QETH_DBF_LIKE_HELL */
179 #define QETH_DBF_CONTROL_LEVEL 2
180 #endif /* QETH_DBF_LIKE_HELL */
181 
182 #define QETH_DBF_TRACE_NAME "qeth_trace"
183 #define QETH_DBF_TRACE_LEN 8
184 #ifdef QETH_DBF_LIKE_HELL
185 #define QETH_DBF_TRACE_INDEX 3
186 #else /* QETH_DBF_LIKE_HELL */
187 #define QETH_DBF_TRACE_INDEX 2
188 #endif /* QETH_DBF_LIKE_HELL */
189 #define QETH_DBF_TRACE_NR_AREAS 2
190 #ifdef QETH_DBF_LIKE_HELL
191 #define QETH_DBF_TRACE_LEVEL 6
192 #else /* QETH_DBF_LIKE_HELL */
193 #define QETH_DBF_TRACE_LEVEL 2
194 #endif /* QETH_DBF_LIKE_HELL */
195 
196 #define QETH_DBF_SENSE_NAME "qeth_sense"
197 #define QETH_DBF_SENSE_LEN 64
198 #define QETH_DBF_SENSE_INDEX 1
199 #define QETH_DBF_SENSE_NR_AREAS 1
200 #ifdef QETH_DBF_LIKE_HELL
201 #define QETH_DBF_SENSE_LEVEL 6
202 #else /* QETH_DBF_LIKE_HELL */
203 #define QETH_DBF_SENSE_LEVEL 2
204 #endif /* QETH_DBF_LIKE_HELL */
205 
206 
207 #define QETH_DBF_QERR_NAME "qeth_qerr"
208 #define QETH_DBF_QERR_LEN 8
209 #define QETH_DBF_QERR_INDEX 1
210 #define QETH_DBF_QERR_NR_AREAS 2
211 #ifdef QETH_DBF_LIKE_HELL
212 #define QETH_DBF_QERR_LEVEL 6
213 #else /* QETH_DBF_LIKE_HELL */
214 #define QETH_DBF_QERR_LEVEL 2
215 #endif /* QETH_DBF_LIKE_HELL */
216 /****************** END OF DEBUG FACILITY STUFF *********************/
217 
218 /********************* CARD DATA STUFF **************************/
219 
220 #define QETH_MAX_PARAMS 150
221 
222 #define QETH_CARD_TYPE_UNKNOWN	0
223 #define QETH_CARD_TYPE_OSAE	10
224 #define QETH_CARD_TYPE_IQD	1234
225 
226 #define QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT 0x0101
227 #define QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT 0x0101
228 /* as soon as steve is ready:
229 #define QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT 0x4101
230 #define QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT 0x5101
231 */
232 #define QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT 0x4108
233 #define QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT 0x5108
234 
235 #define QETH_MAX_QUEUES 4
236 
237 #define UNIQUE_ID_IF_CREATE_ADDR_FAILED 0xfffe
238 #define UNIQUE_ID_NOT_BY_CARD 0x10000
239 
240 /* CU type & model, Dev type & model, card_type, odd_even_restriction, func level, no of queues, multicast is different (multicast-queue_no + 0x100) */
241 #define QETH_MODELLIST_ARRAY \
242 	{{0x1731,0x01,0x1732,0x01,QETH_CARD_TYPE_OSAE,1, \
243 	  QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT, \
244 	  QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT, \
245 	  QETH_MAX_QUEUES,0}, \
246 	 {0x1731,0x05,0x1732,0x05,QETH_CARD_TYPE_IQD,0, \
247 	  QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT, \
248 	  QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT, \
249 	  QETH_MAX_QUEUES,0x103}, \
250 	 {0,0,0,0,0,0,0,0,0}}
251 
252 #define QETH_MPC_DIFINFO_LEN_INDICATES_LINK_TYPE 0x18
253  /* only the first two bytes are looked at in qeth_get_cardname_short */
254 #define QETH_MPC_LINK_TYPE_FAST_ETHERNET 0x01
255 #define QETH_MPC_LINK_TYPE_HSTR 0x02
256 #define QETH_MPC_LINK_TYPE_GIGABIT_ETHERNET 0x03
257 #define QETH_MPC_LINK_TYPE_LANE_ETH100 0x81
258 #define QETH_MPC_LINK_TYPE_LANE_TR 0x82
259 #define QETH_MPC_LINK_TYPE_LANE_ETH1000 0x83
260 #define QETH_MPC_LINK_TYPE_LANE 0x88
261 
262 #define DEFAULT_ADD_HHLEN 0
263 #define MAX_ADD_HHLEN 1024
264 
265 #define QETH_HEADER_SIZE	32
266 #define QETH_IP_HEADER_SIZE	40
267 #define QETH_HEADER_LEN_POS	8
268 /* flags for the header: */
269 #define QETH_HEADER_PASSTHRU	0x10
270 #define QETH_HEADER_IPV6	0x80
271 
272 #define QETH_ETH_MAC_V4      0x0100 /* like v4 */
273 #define QETH_ETH_MAC_V6      0x3333 /* like v6 */
274 /* tr mc mac is longer, but that will be enough to detect mc frames */
275 #define QETH_TR_MAC_NC       0xc000 /* non-canonical */
276 #define QETH_TR_MAC_C        0x0300 /* canonical */
277 
278 #define QETH_CAST_FLAGS		0x07
279 #define QETH_CAST_UNICAST	6
280 #define QETH_CAST_MULTICAST	4
281 #define QETH_CAST_BROADCAST	5
282 #define QETH_CAST_ANYCAST	7
283 #define QETH_CAST_NOCAST	0
284 
285 /* VLAN defines */
286 #define QETH_EXT_HEADER_VLAN_FRAME	  0x01
287 #define QETH_EXT_HEADER_TOKEN_ID	  0x02
288 #define QETH_EXT_HEADER_INCLUDE_VLAN_TAG  0x04
289 
290 #define QETH_EXT_HEADER_SRC_MAC_ADDRESS   0x08
291 #define QETH_EXT_HEADER_CSUM_HDR_REQ      0x10
292 #define QETH_EXT_HEADER_CSUM_TRANSP_REQ   0x20
293 #define QETH_EXT_HEADER_CSUM_TRANSP_FRAME_TYPE   0x40
294 
295 #define QETH_UDP_CSUM_OFFSET	6
296 #define QETH_TCP_CSUM_OFFSET	16
297 
298 #define QETH_VERIFY_IS_REAL_DEV               1
299 #define QETH_VERIFY_IS_VLAN_DEV               2
300 
qeth_get_ipa_timeout(int cardtype)301 inline static unsigned int qeth_get_ipa_timeout(int cardtype)
302 {
303 	switch (cardtype) {
304 	case QETH_CARD_TYPE_IQD: return 2000;
305 	default: return 20000;
306 	}
307 }
308 
qeth_get_additional_dev_flags(int cardtype)309 inline static unsigned short qeth_get_additional_dev_flags(int cardtype)
310 {
311 	switch (cardtype) {
312 	case QETH_CARD_TYPE_IQD: return IFF_NOARP;
313 #ifdef QETH_IPV6
314 	default: return 0;
315 #else /* QETH_IPV6 */
316 	default: return IFF_NOARP;
317 #endif /* QETH_IPV6 */
318 	}
319 }
320 
qeth_get_hlen(__u8 link_type)321 inline static int qeth_get_hlen(__u8 link_type)
322 {
323 #ifdef QETH_IPV6
324 	switch (link_type) {
325 	case QETH_MPC_LINK_TYPE_HSTR:
326 	case QETH_MPC_LINK_TYPE_LANE_TR:
327 		return QETH_HEADER_SIZE+TR_HLEN;
328 	default:
329 #ifdef QETH_VLAN
330 		return QETH_HEADER_SIZE+VLAN_ETH_HLEN;
331 #else
332 		return QETH_HEADER_SIZE+ETH_HLEN;
333 #endif
334 	}
335 #else /* QETH_IPV6 */
336 #ifdef QETH_VLAN
337 	return QETH_HEADER_SIZE+VLAN_HLEN;
338 #else
339 	return QETH_HEADER_SIZE;
340 #endif
341 
342 #endif /* QETH_IPV6 */
343 }
344 
345 int (*qeth_my_eth_header)(struct sk_buff *,struct net_device *,
346 	unsigned short,void *,void *,unsigned);
347 int (*qeth_my_tr_header)(struct sk_buff *,struct net_device *,
348 	unsigned short,void *,void *,unsigned);
349 int (*qeth_my_eth_rebuild_header)(struct sk_buff *);
350 int (*qeth_my_tr_rebuild_header)(struct sk_buff *);
351 int (*qeth_my_eth_header_cache)(struct neighbour *,struct hh_cache *);
352 void (*qeth_my_eth_header_cache_update)(struct hh_cache *,struct net_device *,
353 	 unsigned char *);
354 
355 #ifdef QETH_IPV6
356 typedef int (*__qeth_temp1)(struct sk_buff *,struct net_device *,
357 	unsigned short,void *,void *,unsigned);
qeth_get_hard_header(__u8 link_type)358 inline static __qeth_temp1 qeth_get_hard_header(__u8 link_type)
359 {
360 	switch (link_type) {
361 #ifdef CONFIG_TR
362 	case QETH_MPC_LINK_TYPE_HSTR:
363 	case QETH_MPC_LINK_TYPE_LANE_TR:
364 		return qeth_my_tr_header;
365 #endif /* CONFIG_TR */
366 	default:
367 		return qeth_my_eth_header;
368 	}
369 }
370 
371 typedef int (*__qeth_temp2)(struct sk_buff *);
qeth_get_rebuild_header(__u8 link_type)372 inline static __qeth_temp2 qeth_get_rebuild_header(__u8 link_type)
373 {
374 	switch (link_type) {
375 #ifdef CONFIG_TR
376 	case QETH_MPC_LINK_TYPE_HSTR:
377 	case QETH_MPC_LINK_TYPE_LANE_TR:
378 		return qeth_my_tr_rebuild_header;
379 #endif /* CONFIG_TR */
380 	default:
381 		return qeth_my_eth_rebuild_header;
382 	}
383 }
384 
385 typedef int (*__qeth_temp3)(struct neighbour *,struct hh_cache *);
qeth_get_hard_header_cache(__u8 link_type)386 inline static __qeth_temp3 qeth_get_hard_header_cache(__u8 link_type)
387 {
388 	switch (link_type) {
389 	case QETH_MPC_LINK_TYPE_HSTR:
390 	case QETH_MPC_LINK_TYPE_LANE_TR:
391 		return NULL;
392 	default:
393 		return qeth_my_eth_header_cache;
394 	}
395 }
396 
397 typedef void (*__qeth_temp4)(struct hh_cache *,struct net_device *,
398 	 unsigned char *);
qeth_get_header_cache_update(__u8 link_type)399 inline static __qeth_temp4 qeth_get_header_cache_update(__u8 link_type)
400 {
401 	switch (link_type) {
402 	case QETH_MPC_LINK_TYPE_HSTR:
403 	case QETH_MPC_LINK_TYPE_LANE_TR:
404 		return NULL;
405 	default:
406 		return qeth_my_eth_header_cache_update;
407 	}
408 }
409 
qeth_eth_type_trans(struct sk_buff * skb,struct net_device * dev)410 static unsigned short qeth_eth_type_trans(struct sk_buff *skb,
411 					  struct net_device *dev)
412 {
413 	struct ethhdr *eth;
414 
415 	skb->mac.raw=skb->data;
416 	skb_pull(skb,ETH_ALEN*2+sizeof(short));
417 	eth=skb->mac.ethernet;
418 
419 	if(*eth->h_dest&1) {
420 		if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0)
421 			skb->pkt_type=PACKET_BROADCAST;
422 		else
423 			skb->pkt_type=PACKET_MULTICAST;
424    	} else {
425 		skb->pkt_type=PACKET_OTHERHOST;
426 	}
427 	if (ntohs(eth->h_proto)>=1536) return eth->h_proto;
428 	if (*(unsigned short *)(skb->data) == 0xFFFF)
429 		return htons(ETH_P_802_3);
430 	return htons(ETH_P_802_2);
431 }
432 
433 typedef unsigned short (*__qeth_temp5)(struct sk_buff *,struct net_device *);
qeth_get_type_trans(__u8 link_type)434 inline static __qeth_temp5 qeth_get_type_trans(__u8 link_type)
435 {
436 	switch (link_type) {
437 	case QETH_MPC_LINK_TYPE_HSTR:
438 	case QETH_MPC_LINK_TYPE_LANE_TR:
439 		return tr_type_trans;
440 	default:
441 		return qeth_eth_type_trans;
442 	}
443 }
444 #endif /* QETH_IPV6 */
445 
qeth_get_link_type_name(int cardtype,__u8 linktype)446 inline static const char *qeth_get_link_type_name(int cardtype,__u8 linktype)
447 {
448 	switch (cardtype) {
449 	case QETH_CARD_TYPE_UNKNOWN: return "unknown";
450 	case QETH_CARD_TYPE_OSAE:
451 		switch (linktype) {
452 		case QETH_MPC_LINK_TYPE_FAST_ETHERNET: return "Fast Eth";
453 		case QETH_MPC_LINK_TYPE_HSTR: return "HSTR";
454 		case QETH_MPC_LINK_TYPE_GIGABIT_ETHERNET: return "Gigabit Eth";
455 		case QETH_MPC_LINK_TYPE_LANE_ETH100: return "LANE Eth100";
456 		case QETH_MPC_LINK_TYPE_LANE_TR: return "LANE TR";
457 		case QETH_MPC_LINK_TYPE_LANE_ETH1000: return "LANE Eth1000";
458 		default: return "unknown";
459 		}
460 	case QETH_CARD_TYPE_IQD: return "magic";
461 	default: return "unknown";
462 	}
463 }
464 
qeth_get_dev_basename(int cardtype,__u8 link_type)465 inline static const char* qeth_get_dev_basename(int cardtype,__u8 link_type)
466 {
467 	switch (cardtype) {
468 	case QETH_CARD_TYPE_UNKNOWN: return "eth";
469 	case QETH_CARD_TYPE_OSAE: switch (link_type) {
470 				  case QETH_MPC_LINK_TYPE_LANE_TR:
471 					  /* fallthrough */
472 				  case QETH_MPC_LINK_TYPE_HSTR: return "tr";
473 				  default: return "eth";
474 				  }
475 	case QETH_CARD_TYPE_IQD: return "hsi";
476 	default: return "eth";
477 	}
478 }
479 
480 /* inbound: */
481 #define DEFAULT_BUFFER_SIZE 65536
482 #define DEFAULT_BUFFER_COUNT 128
483 #define BUFCNT_MIN 8
484 #define BUFCNT_MAX 128
485 #define BUFFER_SIZE (card->inbound_buffer_size)
486 #define BUFFER_MAX_ELEMENTS (BUFFER_SIZE>>12)
487 	/* 8k for each pair header-buffer: */
488 
qeth_sbal_packing_on_card(int cardtype)489 inline static int qeth_sbal_packing_on_card(int cardtype)
490 {
491 	switch (cardtype) {
492 	case QETH_CARD_TYPE_IQD: return 0;
493 	default: return 1;
494 	}
495 }
496 
497 /* do it this way round -> __MODULE_STRING needs with */
498 /* QETH_PRIO_NICE_LEVELS a single number */
499 #define QETH_MAX_PRIO_QUEUES QETH_PRIO_NICE_LEVELS+1
500 
qeth_sbalf15_in_retrieable_range(int sbalf15)501 static inline int qeth_sbalf15_in_retrieable_range(int sbalf15)
502 {
503 	return ( (sbalf15>=15) && (sbalf15<=31) );
504 }
505 
506 #define INBOUND_BUFFER_POS(card,bufno,sbale) \
507 	( (bufno&SPAREBUF_MASK)? \
508 	  ( \
509 	    (sparebufs[bufno&(~SPAREBUF_MASK)].buf+ \
510 	     PAGE_SIZE*sbale) \
511 	  ):( \
512 	      (card->inbound_buffer_pool_entry[card-> \
513 	       inbound_buffer_entry_no[bufno]][sbale]) \
514 	    ) )
515 
516 #define SPAREBUF_UNAVAIL 0
517 #define SPAREBUF_FREE 1
518 #define SPAREBUF_USED 2
519 
520 typedef struct sparebufs_t {
521 	char *buf;
522 	atomic_t status;
523 } sparebufs_t;
524 
525 #define SEND_STATE_INACTIVE		0
526 #define SEND_STATE_DONT_PACK		1
527 #define SEND_STATE_PACK			2
528 
529 #define QETH_LOCK_UNLOCKED 0
530 #define QETH_LOCK_NORMAL 1
531 #define QETH_LOCK_FLUSH 2
532 
533 #define QETH_MAX_DEVICES 16
534 	/* DEPENDENCY ON QETH_MAX_DEVICES.
535 	 *__MOUDLE_STRING expects simple literals */
536 #define QETH_MAX_DEVICES_TIMES_4 64
537 #define QETH_MAX_DEVNAMES 16
538 #define QETH_DEVNAME "eth"
539 
540 #define QETH_TX_TIMEOUT 100*HZ /* 100 seconds */
541 
542 #define QETH_REMOVE_WAIT_TIME 200
543 #define QETH_WAIT_FOR_THREAD_TIME 20
544 #define QETH_IDLE_WAIT_TIME 10
545 #define QETH_WAIT_BEFORE_2ND_DOIO 1000
546 
547 #define QETH_MAX_PARM_LEN 128
548 
549 #define QETH_FAKE_LL_LEN ETH_HLEN /* 14 */
550 #define QETH_FAKE_LL_PROT_LEN 2
551 #define QETH_FAKE_LL_ADDR_LEN ETH_ALEN /* 6 */
552 #define QETH_FAKE_LL_DEST_MAC_POS 0
553 #define QETH_FAKE_LL_SRC_MAC_POS 6
554 #define QETH_FAKE_LL_SRC_MAC_POS_IN_QDIO_HDR 18
555 #define QETH_FAKE_LL_PROT_POS 12
556 #define QETH_FAKE_LL_V4_ADDR_POS 16
557 #define QETH_FAKE_LL_V6_ADDR_POS 24
558 
559 #define DEV_NAME_LEN 16
560 #define IOCTL_MAX_TRANSFER_SIZE 65535
561 
562 #define IP_TOS_LOWDELAY 0x10
563 #define IP_TOS_HIGHTHROUGHPUT 0x08
564 #define IP_TOS_HIGHRELIABILITY 0x04
565 #define IP_TOS_NOTIMPORTANT 0x02
566 
567 #define QETH_RCD_LENGTH 128
568 
569 #define __max(a,b) ( ((a)>(b))?(a):(b) )
570 #define __min(a,b) ( ((a)<(b))?(a):(b) )
571 #define QETH_BUFSIZE __max(__max(IPA_PDU_HEADER_SIZE+ \
572 				 sizeof(arp_cmd_t),IPA_PDU_HEADER_SIZE+ \
573 				 sizeof(ipa_cmd_t)),QETH_RCD_LENGTH)
574 
575 #define QETH_FINAL_STATUS_TIMEOUT 1500
576 #define QETH_CLEAR_TIMEOUT 1500
577 #define QETH_RCD_TIMEOUT 1500
578 #define QETH_NOP_TIMEOUT 1500
579 #define QETH_QUIESCE_NETDEV_TIME 300
580 #define QETH_QUIESCE_WAIT_BEFORE_CLEAR 4000
581 #define QETH_QUIESCE_WAIT_AFTER_CLEAR 4000
582 
583 #define NOP_STATE 0x1001
584 #define READ_CONF_DATA_STATE 0x1002
585 #define IDX_ACTIVATE_READ_STATE 0x1003
586 #define IDX_ACTIVATE_WRITE_STATE 0x1004
587 #define MPC_SETUP_STATE 0x1005
588 #define CLEAR_STATE 0x1006
589 #define IPA_CMD_STATE 0x1007
590 #define IPA_IOCTL_STATE 0x1009
591 #define IPA_SETIP_FLAG 0x100000
592 
593 #define QETH_REMOVE_CARD_PROPER 1
594 #define QETH_REMOVE_CARD_QUICK 2
595 
596 #define PARSE_AUTO 0
597 #define PARSE_ROUTING_TYPE 1
598 #define PARSE_CHECKSUMMING 2
599 #define PARSE_PRIO_QUEUEING 3
600 #define PARSE_STAYINMEM 4
601 #define PARSE_BUFFERCOUNT 5
602 #define PARSE_PORTNAME 6
603 #define PARSE_POLLTIME 7
604 #define PARSE_SPARE_BUFFERCOUNT 8
605 #define PARSE_PORTNO 9
606 #define PARSE_BROADCAST_MODE 10
607 #define PARSE_MACADDR_MODE 11
608 #define PARSE_MEMUSAGE 12
609 #define PARSE_ENA_IPAT 13
610 #define PARSE_FAKE_BROADCAST 14
611 #define PARSE_ADD_HHLEN 15
612 #define PARSE_ROUTING_TYPE4 16
613 #define PARSE_ROUTING_TYPE6 17
614 #define PARSE_FAKE_LL 18
615 #define PARSE_ASYNC_IQD 19
616 
617 #define PARSE_COUNT 20
618 
619 #define NO_PRIO_QUEUEING 0
620 #define PRIO_QUEUEING_PREC 1
621 #define PRIO_QUEUEING_TOS 2
622 #define NO_ROUTER 0
623 #define PRIMARY_ROUTER 1
624 #define SECONDARY_ROUTER 2
625 #define MULTICAST_ROUTER 3
626 #define PRIMARY_CONNECTOR 4
627 #define SECONDARY_CONNECTOR 5
628 #define ROUTER_MASK 0xf /* used to remove RESET_ROUTING_FLAG
629 			   from routing_type */
630 #define RESET_ROUTING_FLAG 0x10 /* used to indicate, that setting
631 				   the routing type is desired */
632 #define BROADCAST_ALLRINGS 0
633 #define BROADCAST_LOCAL 1
634 #define MACADDR_NONCANONICAL 0
635 #define MACADDR_CANONICAL 1
636 #define MEMUSAGE_DISCONTIG 0
637 #define MEMUSAGE_CONTIG 1
638 #define ENABLE_TAKEOVER 0
639 #define DISABLE_TAKEOVER 1
640 #define FAKE_BROADCAST 0
641 #define DONT_FAKE_BROADCAST 1
642 #define FAKE_LL 0
643 #define DONT_FAKE_LL 1
644 #define SYNC_IQD 0
645 #define ASYNC_IQD 1
646 
647 #define QETH_BREAKOUT_LEAVE 1
648 #define QETH_BREAKOUT_AGAIN 2
649 
650 #define QETH_WAIT_FOR_LOCK 0
651 #define QETH_DONT_WAIT_FOR_LOCK 1
652 #define QETH_LOCK_ALREADY_HELD 2
653 
654 #define BROADCAST_WITH_ECHO 1
655 #define BROADCAST_WITHOUT_ECHO 2
656 
657 #define PROBLEM_CARD_HAS_STARTLANED 1
658 #define PROBLEM_RECEIVED_IDX_TERMINATE 2
659 #define PROBLEM_ACTIVATE_CHECK_CONDITION 3
660 #define PROBLEM_RESETTING_EVENT_INDICATOR 4
661 #define PROBLEM_COMMAND_REJECT 5
662 #define PROBLEM_ZERO_SENSE_DATA 6
663 #define PROBLEM_GENERAL_CHECK 7
664 #define PROBLEM_BAD_SIGA_RESULT 8
665 #define PROBLEM_USER_TRIGGERED_RECOVERY 9
666 #define PROBLEM_AFFE 10
667 #define PROBLEM_MACHINE_CHECK 11
668 #define PROBLEM_TX_TIMEOUT 12
669 
670 #define SENSE_COMMAND_REJECT_BYTE 0
671 #define SENSE_COMMAND_REJECT_FLAG 0x80
672 #define SENSE_RESETTING_EVENT_BYTE 1
673 #define SENSE_RESETTING_EVENT_FLAG 0x80
674 
675 #define DEFAULT_RCD_CMD 0x72
676 #define DEFAULT_RCD_COUNT 0x80
677 
678 #define BUFFER_USED 1
679 #define BUFFER_UNUSED -1
680 
681 /*typedef struct wait_queue* wait_queue_head_t; already typedefed in qdio.h */
682 
683 typedef int (*reg_notifier_t)(struct notifier_block*);
684 
685 typedef struct ipato_entry_t {
686 	int version;
687 	__u8 addr[16];
688 	int mask_bits;
689 	char dev_name[DEV_NAME_LEN];
690 	struct ipato_entry_t *next;
691 } ipato_entry_t;
692 
693 typedef struct qeth_vipa_entry_t {
694 	int version;
695 	__u8 ip[16];
696 	int flag;
697 	volatile int state;
698 	struct qeth_vipa_entry_t *next;
699 } qeth_vipa_entry_t;
700 
701 typedef struct ip_state_t {
702 	struct in_ifaddr *ip_ifa;	/* pointer to IPv4 adresses */
703 	struct inet6_ifaddr *ip6_ifa;
704 } ip_state_t;
705 
706 struct qeth_ipm_mac {
707 	__u8 mac[ETH_ALEN];
708 	__u8 ip[16];
709 	struct qeth_ipm_mac *next;
710 };
711 
712 typedef struct ip_mc_state_t {
713 	struct qeth_ipm_mac *ipm_ifa;
714 	struct qeth_ipm_mac *ipm6_ifa;
715 } ip_mc_state_t;
716 
717 struct qeth_card_options {
718 	char devname[DEV_NAME_LEN];
719 	volatile int routing_type4;
720 #ifdef QETH_IPV6
721 	volatile int routing_type6;
722 #endif /* QETH_IPV6 */
723 	int checksum_type;
724 	int do_prio_queueing;
725 	int default_queue;
726 	int already_parsed[PARSE_COUNT];
727 	int inbound_buffer_count;
728 	__s32 memory_usage_in_k;
729 	int polltime;
730 	char portname[9];
731 	int portno;
732 	int memusage;
733 	int broadcast_mode;
734 	int macaddr_mode;
735 	int ena_ipat;
736 	int fake_broadcast;
737 	int add_hhlen;
738 	int fake_ll;
739 	int async_iqd;
740 };
741 
742 typedef struct qeth_hdr_t {
743 	__u8 id;
744 	__u8 flags;
745 	__u16 inbound_checksum;
746 	__u32 token;
747 	__u16 length;
748 	__u8 vlan_prio;
749 	__u8 ext_flags;
750 	__u16 vlan_id;
751 	__u16 frame_offset;
752 	__u8 dest_addr[16];
753 } qeth_hdr_t;
754 
755 typedef struct qeth_ringbuffer_element_t {
756 	struct sk_buff_head skb_list;
757 	int next_element_to_fill;
758 } __attribute__ ((packed)) qeth_ringbuffer_element_t;
759 
760 typedef struct qeth_ringbuffer_t {
761 	qdio_buffer_t buffer[QDIO_MAX_BUFFERS_PER_Q];
762 	qeth_ringbuffer_element_t ringbuf_element[QDIO_MAX_BUFFERS_PER_Q];
763 } qeth_ringbuffer_t __attribute__ ((packed,aligned(PAGE_SIZE)));
764 
765 typedef struct qeth_dma_stuff_t {
766 	unsigned char *sendbuf;
767 	unsigned char *recbuf;
768 	ccw1_t read_ccw;
769 	ccw1_t write_ccw;
770 } qeth_dma_stuff_t __attribute__ ((packed,aligned(PAGE_SIZE)));
771 
772 typedef struct qeth_perf_stats_t {
773 	unsigned int skbs_rec;
774 	unsigned int bufs_rec;
775 
776 	unsigned int skbs_sent;
777 	unsigned int bufs_sent;
778 
779 	unsigned int skbs_sent_dont_pack;
780 	unsigned int bufs_sent_dont_pack;
781 	unsigned int skbs_sent_pack;
782 	unsigned int bufs_sent_pack;
783 	unsigned int skbs_sent_pack_better;
784 	unsigned int bufs_sent_pack_better;
785 
786 	unsigned int sc_dp_p;
787 	unsigned int sc_p_dp;
788 
789 	__u64 inbound_start_time;
790 	unsigned int inbound_cnt;
791 	unsigned int inbound_time;
792 	__u64 outbound_start_time;
793 	unsigned int outbound_cnt;
794 	unsigned int outbound_time;
795 } qeth_perf_stats_t;
796 
797 /* ugly. I know. */
798 typedef struct qeth_card_t {			/* pointed to by dev->priv */
799 	int easy_copy_cap;
800 
801 	/* pointer to options (defaults + parameters) */
802 	struct qeth_card_options options;
803 
804  	atomic_t is_startlaned; /* card did not get a stoplan */
805 				/* also 0 when card is gone after a
806 				   machine check */
807 
808 	__u8 link_type;
809 
810 	int is_guest_lan;
811 	int do_pfix; /* to avoid doing diag98 for vm guest lan devices */
812 
813 	/* inbound buffer management */
814 	atomic_t inbound_buffer_refcnt[QDIO_MAX_BUFFERS_PER_Q];
815 	qdio_buffer_t inbound_qdio_buffers[QDIO_MAX_BUFFERS_PER_Q];
816 	void *real_inb_buffer_addr[QDIO_MAX_BUFFERS_PER_Q]
817 		[QDIO_MAX_ELEMENTS_PER_BUFFER];
818 
819 	/* inbound data area */
820 	void *inbound_buffer_pool_entry[QDIO_MAX_BUFFERS_PER_Q]
821 		[QDIO_MAX_ELEMENTS_PER_BUFFER];
822 	volatile int inbound_buffer_pool_entry_used[QDIO_MAX_BUFFERS_PER_Q];
823 	int inbound_buffer_entry_no[QDIO_MAX_BUFFERS_PER_Q];
824 
825 	/* for requeueing of buffers */
826 	spinlock_t requeue_input_lock;
827 	atomic_t requeue_position;
828 	atomic_t requeue_counter;
829 
830 	/* outbound QDIO stuff */
831 	volatile int send_state[QETH_MAX_QUEUES];
832 	volatile int outbound_first_free_buffer[QETH_MAX_QUEUES];
833 	atomic_t outbound_used_buffers[QETH_MAX_QUEUES];
834 	int outbound_buffer_send_state[QETH_MAX_QUEUES]
835 		[QDIO_MAX_BUFFERS_PER_Q];
836 	int send_retries[QETH_MAX_QUEUES][QDIO_MAX_BUFFERS_PER_Q];
837 	volatile int outbound_bytes_in_buffer[QETH_MAX_QUEUES];
838 	qeth_ringbuffer_t *outbound_ringbuffer[QETH_MAX_QUEUES];
839 	atomic_t outbound_ringbuffer_lock[QETH_MAX_QUEUES];
840 	atomic_t last_pci_pos[QETH_MAX_QUEUES];
841 
842 #ifdef QETH_IPV6
843 	int (*hard_header)(struct sk_buff *,struct net_device *,
844 			   unsigned short,void *,void *,unsigned);
845 	int (*rebuild_header)(struct sk_buff *);
846 	int (*hard_header_cache)(struct neighbour *,struct hh_cache *);
847 	void (*header_cache_update)(struct hh_cache *,struct net_device *,
848 				    unsigned char *);
849 	unsigned short (*type_trans)(struct sk_buff *,struct net_device *);
850 	int type_trans_correction;
851 #endif /* QETH_IPV6 */
852 
853 #ifdef QETH_VLAN
854         struct vlan_group *vlangrp;
855         spinlock_t vlan_lock;
856 
857 #endif
858 	char dev_name[DEV_NAME_LEN];		/* pointed to by dev->name */
859 	char dev_basename[DEV_NAME_LEN];
860 	struct net_device *dev;
861 	struct net_device_stats *stats;
862 
863 	int no_queues;
864 
865 #ifdef QETH_PERFORMANCE_STATS
866 	qeth_perf_stats_t perf_stats;
867 #endif /* QETH_PERFORMANCE_STATS */
868 
869 	/* our state */
870 	atomic_t is_registered;		/* card registered as netdev? */
871 	atomic_t is_hardsetup;		/* card has gone through hardsetup */
872 	atomic_t is_softsetup;		/* card is setup by softsetup */
873 	atomic_t is_open;		/* card is in use */
874 	atomic_t is_gone;               /* after a msck */
875 
876 	int has_irq;			/* once a request_irq was successful */
877 
878 	/* prevents deadlocks :-O */
879 	spinlock_t softsetup_lock;
880 	spinlock_t hardsetup_lock;
881 	struct semaphore ioctl_sem;
882 	atomic_t softsetup_thread_is_running;
883 	struct semaphore softsetup_thread_sem;
884 	struct tq_struct tqueue_sst;
885 
886 	atomic_t escape_softsetup;	/* active, when recovery has to
887 					   wait for softsetup */
888 	struct semaphore reinit_thread_sem;
889 	atomic_t in_recovery;
890 	atomic_t reinit_counter;
891 
892 	/* problem management */
893 	atomic_t break_out;
894 	atomic_t problem;
895 	struct tq_struct tqueue;
896 
897 	struct {
898 		__u32 trans_hdr;
899 		__u32 pdu_hdr;
900 		__u32 pdu_hdr_ack;
901 		__u32 ipa;
902 	} seqno;
903 
904 	struct {
905 		__u32 issuer_rm_w;
906 		__u32 issuer_rm_r;
907 		__u32 cm_filter_w;
908 		__u32 cm_filter_r;
909 		__u32 cm_connection_w;
910 		__u32 cm_connection_r;
911 		__u32 ulp_filter_w;
912 		__u32 ulp_filter_r;
913 		__u32 ulp_connection_w;
914 		__u32 ulp_connection_r;
915 	} token;
916 
917 	/* this is card-related */
918 	int type;
919 	__u16 func_level;
920 	int initial_mtu;
921 	int max_mtu;
922 	int inbound_buffer_size;
923 
924 	int is_multicast_different; /* if multicast traffic is to be sent
925 				       on a different queue, this is the
926 				       queue+no_queues */
927 	int can_do_async_iqd; /* 1 only on IQD that provides async
928 		      		 unicast sigas */
929 
930 	__u32 ipa_supported;
931 	__u32 ipa_enabled;
932 	__u32 ipa6_supported;
933 	__u32 ipa6_enabled;
934 	__u32 adp_supported;
935 
936 	__u32 csum_enable_mask;
937 
938 	atomic_t startlan_attempts;
939 	atomic_t enable_routing_attempts4;
940 	atomic_t rt4fld;
941 #ifdef QETH_IPV6
942 	atomic_t enable_routing_attempts6;
943 	atomic_t rt6fld;
944 #endif /* QETH_IPV6 */
945 	int unique_id;
946 
947 	/* device and I/O data */
948 	int devno0;
949 	int devno1;
950 	int devno2;
951 	int irq0;
952 	int irq1;
953 	int irq2;
954 	unsigned short unit_addr2;
955 	unsigned short cula;
956 	unsigned short dev_type;
957 	unsigned char dev_model;
958 	unsigned short chpid;
959 	devstat_t *devstat0;
960 	devstat_t *devstat1;
961 	devstat_t *devstat2;
962 
963 	unsigned char ipa_buf[QETH_BUFSIZE];
964 	unsigned char send_buf[QETH_BUFSIZE];
965 
966 /* IOCTL Stuff */
967 	unsigned char *ioctl_data_buffer;
968 	unsigned char *ioctl_buffer_pointer;
969 	int ioctl_returncode;
970 	int ioctl_buffersize;
971 	int number_of_entries;
972 
973 
974 	atomic_t ioctl_data_has_arrived;
975 	wait_queue_head_t ioctl_wait_q;
976 	atomic_t ioctl_wait_q_active;
977 	spinlock_t ioctl_wait_q_lock;
978 
979 /* stuff under 2 gb */
980 	qeth_dma_stuff_t *dma_stuff;
981 
982 	unsigned int ipa_timeout;
983 
984 	atomic_t write_busy;
985 
986 	int read_state; /* only modified and read in the int handler */
987 
988 	/* vipa stuff */
989 	rwlock_t vipa_list_lock;
990 	qeth_vipa_entry_t *vipa_list;
991 
992 	/* state information when doing I/O */
993 	atomic_t shutdown_phase;
994 	volatile int save_state_flag;
995 	atomic_t data_has_arrived;
996 	wait_queue_head_t wait_q;
997 	atomic_t wait_q_active;
998 	spinlock_t wait_q_lock; /* for wait_q_active and wait_q */
999 
1000 	atomic_t final_status0;
1001 	atomic_t final_status1;
1002 	atomic_t final_status2;
1003 	atomic_t clear_succeeded0;
1004 	atomic_t clear_succeeded1;
1005 	atomic_t clear_succeeded2;
1006 
1007 	/* bookkeeping of IP and multicast addresses */
1008 	ip_state_t ip_current_state;
1009 	ip_state_t ip_new_state;
1010 
1011 #ifdef CONFIG_IP_MULTICAST
1012 	ip_mc_state_t ip_mc_current_state;
1013 	ip_mc_state_t ip_mc_new_state;
1014 #endif /* CONFIG_IF_MULTICAST */
1015 
1016 	int broadcast_capable;
1017 	int portname_required;
1018 
1019 	int realloc_message;
1020 
1021 	char level[QETH_MCL_LENGTH+1];
1022 
1023 	volatile int saved_dev_flags;
1024 
1025 	/* for our linked list */
1026 	struct qeth_card_t *next;
1027 } qeth_card_t;
1028 
1029 typedef struct mydevreg_t {
1030 	devreg_t devreg;
1031 	struct mydevreg_t *next;
1032 	struct mydevreg_t *prev;
1033 } mydevreg_t;
1034 
1035 /*user process notification stuff */
1036 spinlock_t notify_lock;
1037 struct list_head notify_list;
1038 struct qeth_notify_list {
1039 	struct list_head list;
1040 	struct task_struct *task;
1041 	int signum;
1042 };
1043 
qeth_get_arphrd_type(int cardtype,int linktype)1044 inline static int qeth_get_arphrd_type(int cardtype,int linktype)
1045 {
1046 	switch (cardtype) {
1047 	case QETH_CARD_TYPE_OSAE: switch (linktype) {
1048 				  case QETH_MPC_LINK_TYPE_LANE_TR:
1049 					  /* fallthrough */
1050 				  case QETH_MPC_LINK_TYPE_HSTR:
1051 					  return ARPHRD_IEEE802_TR;
1052 				  default: return ARPHRD_ETHER;
1053 				  }
1054 	case QETH_CARD_TYPE_IQD: return ARPHRD_ETHER;
1055 	default: return ARPHRD_ETHER;
1056 	}
1057 }
1058 
qeth_determine_easy_copy_cap(int cardtype)1059 inline static int qeth_determine_easy_copy_cap(int cardtype)
1060 {
1061 	switch (cardtype) {
1062 	case QETH_CARD_TYPE_UNKNOWN: return 0; /* better be cautious */
1063 	case QETH_CARD_TYPE_OSAE: return 1;
1064 	case QETH_CARD_TYPE_IQD: return 0;
1065 	default: return 0; /* ?? */
1066 	}
1067 }
qeth_get_adapter_type_for_ipa(int link_type)1068 inline static __u8 qeth_get_adapter_type_for_ipa(int link_type)
1069 {
1070 	switch (link_type) {
1071 	case QETH_MPC_LINK_TYPE_HSTR: return 2;
1072 	default: return 1;
1073 	}
1074 }
1075 
qeth_get_cardname(int cardtype,int is_guest_lan)1076 inline static const char *qeth_get_cardname(int cardtype,int is_guest_lan)
1077 {
1078 	if (is_guest_lan) {
1079 		switch (cardtype) {
1080 		case QETH_CARD_TYPE_UNKNOWN: return "n unknown";
1081 		case QETH_CARD_TYPE_OSAE: return " Guest LAN QDIO";
1082 		case QETH_CARD_TYPE_IQD: return " Guest LAN Hiper";
1083 		default: return " strange";
1084 		}
1085 	} else {
1086 		switch (cardtype) {
1087 		case QETH_CARD_TYPE_UNKNOWN: return "n unknown";
1088 		case QETH_CARD_TYPE_OSAE: return "n OSD Express";
1089 		case QETH_CARD_TYPE_IQD: return " HiperSockets";
1090 		default: return " strange";
1091 		}
1092 	}
1093 }
1094 
1095 /* max length to be returned: 14 */
qeth_get_cardname_short(int cardtype,__u8 link_type,int is_guest_lan)1096 inline static const char *qeth_get_cardname_short(int cardtype,__u8 link_type,int is_guest_lan)
1097 {
1098 	switch (cardtype) {
1099 	case QETH_CARD_TYPE_UNKNOWN: return "unknown";
1100 	case QETH_CARD_TYPE_OSAE: if (is_guest_lan)
1101 					  return "GuestLAN QDIO";
1102 				  switch (link_type) {
1103 			      	  case QETH_MPC_LINK_TYPE_FAST_ETHERNET:
1104 		     			  return "OSD_100";
1105 			      	  case QETH_MPC_LINK_TYPE_HSTR:
1106 		     			  return "HSTR";
1107 	     			  case QETH_MPC_LINK_TYPE_GIGABIT_ETHERNET:
1108      					  return "OSD_1000";
1109 				  case QETH_MPC_LINK_TYPE_LANE_ETH100:
1110      					  return "OSD_FE_LANE";
1111 				  case QETH_MPC_LINK_TYPE_LANE_TR:
1112      					  return "OSD_TR_LANE";
1113 				  case QETH_MPC_LINK_TYPE_LANE_ETH1000:
1114      					  return "OSD_GbE_LANE";
1115 				  case QETH_MPC_LINK_TYPE_LANE:
1116      					  return "OSD_ATM_LANE";
1117 				  default: return "OSD_Express";
1118 				  }
1119 	case QETH_CARD_TYPE_IQD: return (is_guest_lan)?"GuestLAN Hiper":"HiperSockets";
1120 	default: return " strange";
1121 	}
1122 }
1123 
qeth_mtu_is_valid(qeth_card_t * card,int mtu)1124 inline static int qeth_mtu_is_valid(qeth_card_t *card,int mtu)
1125 {
1126 	switch (card->type) {
1127 	case QETH_CARD_TYPE_UNKNOWN: return 1;
1128 	case QETH_CARD_TYPE_OSAE: return ( (mtu>=576) && (mtu<=61440) );
1129 	case QETH_CARD_TYPE_IQD: return ( (mtu>=576) &&
1130 					    (mtu<=card->max_mtu+4096-32) );
1131 	default: return 1;
1132 	}
1133 }
1134 
qeth_get_initial_mtu_for_card(qeth_card_t * card)1135 inline static int qeth_get_initial_mtu_for_card(qeth_card_t *card)
1136 {
1137 	switch (card->type) {
1138 	case QETH_CARD_TYPE_UNKNOWN: return 1500;
1139 	case QETH_CARD_TYPE_IQD: return card->max_mtu;
1140 	case QETH_CARD_TYPE_OSAE:
1141 		switch (card->link_type) {
1142 		case QETH_MPC_LINK_TYPE_HSTR:
1143 		case QETH_MPC_LINK_TYPE_LANE_TR:
1144 			return 2000;
1145 		default:
1146 			return 1492;
1147 		}
1148 	default: return 1500;
1149 	}
1150 }
1151 
qeth_get_max_mtu_for_card(int cardtype)1152 inline static int qeth_get_max_mtu_for_card(int cardtype)
1153 {
1154 	switch (cardtype) {
1155 	case QETH_CARD_TYPE_UNKNOWN: return 61440;
1156 	case QETH_CARD_TYPE_OSAE: return 61440;
1157 	case QETH_CARD_TYPE_IQD: return 57344;
1158 	default: return 1500;
1159 	}
1160 }
1161 
qeth_get_mtu_out_of_mpc(int cardtype)1162 inline static int qeth_get_mtu_out_of_mpc(int cardtype)
1163 {
1164 	switch (cardtype) {
1165 	case QETH_CARD_TYPE_IQD: return 1;
1166 	default: return 0;
1167 	}
1168 }
1169 
qeth_get_mtu_outof_framesize(int framesize)1170 inline static int qeth_get_mtu_outof_framesize(int framesize)
1171 {
1172 	switch (framesize) {
1173 	case 0x4000: return 8192;
1174 	case 0x6000: return 16384;
1175 	case 0xa000: return 32768;
1176 	case 0xffff: return 57344;
1177 	default: return 0;
1178 	}
1179 }
1180 
qeth_get_buffersize_for_card(int cardtype)1181 inline static int qeth_get_buffersize_for_card(int cardtype)
1182 {
1183 	switch (cardtype) {
1184 	case QETH_CARD_TYPE_UNKNOWN: return 65536;
1185 	case QETH_CARD_TYPE_OSAE: return 65536;
1186 	case QETH_CARD_TYPE_IQD: return 16384;
1187 	default: return 65536;
1188 	}
1189 }
1190 
qeth_get_min_number_of_buffers(int cardtype)1191 inline static int qeth_get_min_number_of_buffers(int cardtype)
1192 {
1193 	switch (cardtype) {
1194 	case QETH_CARD_TYPE_UNKNOWN: return 32;
1195 	case QETH_CARD_TYPE_OSAE: return 32;
1196 	case QETH_CARD_TYPE_IQD: return 64;
1197 	default: return 64;
1198 	}
1199 }
1200 
qeth_get_q_format(int cardtype)1201 inline static int qeth_get_q_format(int cardtype)
1202 {
1203 	switch (cardtype) {
1204 	case QETH_CARD_TYPE_IQD: return 2;
1205 	default: return 0;
1206 	}
1207 }
1208 
qeth_get_device_tx_q_len(int cardtype)1209 inline static int qeth_get_device_tx_q_len(int cardtype)
1210 {
1211 	return 100;
1212 }
1213 
qeth_get_max_number_of_buffers(int cardtype)1214 inline static int qeth_get_max_number_of_buffers(int cardtype)
1215 {
1216 	return 127;
1217 }
1218 
1219 /******************** OUTPUT FACILITIES **************************/
1220 
1221 #ifdef PRINT_INFO
1222 #undef PRINTK_HEADER
1223 #undef PRINT_STUPID
1224 #undef PRINT_ALL
1225 #undef PRINT_INFO
1226 #undef PRINT_WARN
1227 #undef PRINT_ERR
1228 #undef PRINT_CRIT
1229 #undef PRINT_ALERT
1230 #undef PRINT_EMERG
1231 #endif /* PRINT_INFO */
1232 
1233 #define PRINTK_HEADER QETH_NAME ": "
1234 
1235 #if QETH_VERBOSE_LEVEL>8
1236 #define PRINT_STUPID(x...) printk( KERN_DEBUG PRINTK_HEADER x)
1237 #else
1238 #define PRINT_STUPID(x...)
1239 #endif
1240 
1241 #if QETH_VERBOSE_LEVEL>7
1242 #define PRINT_ALL(x...) printk( KERN_DEBUG PRINTK_HEADER x)
1243 #else
1244 #define PRINT_ALL(x...)
1245 #endif
1246 
1247 #if QETH_VERBOSE_LEVEL>6
1248 #define PRINT_INFO(x...) printk( KERN_INFO PRINTK_HEADER x)
1249 #else
1250 #define PRINT_INFO(x...)
1251 #endif
1252 
1253 #if QETH_VERBOSE_LEVEL>5
1254 #define PRINT_WARN(x...) printk( KERN_WARNING PRINTK_HEADER x)
1255 #else
1256 #define PRINT_WARN(x...)
1257 #endif
1258 
1259 #if QETH_VERBOSE_LEVEL>4
1260 #define PRINT_ERR(x...) printk( KERN_ERR PRINTK_HEADER x)
1261 #else
1262 #define PRINT_ERR(x...)
1263 #endif
1264 
1265 #if QETH_VERBOSE_LEVEL>3
1266 #define PRINT_CRIT(x...) printk( KERN_CRIT PRINTK_HEADER x)
1267 #else
1268 #define PRINT_CRIT(x...)
1269 #endif
1270 
1271 #if QETH_VERBOSE_LEVEL>2
1272 #define PRINT_ALERT(x...) printk( KERN_ALERT PRINTK_HEADER x)
1273 #else
1274 #define PRINT_ALERT(x...)
1275 #endif
1276 
1277 #if QETH_VERBOSE_LEVEL>1
1278 #define PRINT_EMERG(x...) printk( KERN_EMERG PRINTK_HEADER x)
1279 #else
1280 #define PRINT_EMERG(x...)
1281 #endif
1282 
1283 #endif /* __QETH_H__ */
1284