qeth_core.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. /*
  2. * drivers/s390/net/qeth_core.h
  3. *
  4. * Copyright IBM Corp. 2007
  5. * Author(s): Utz Bacher <utz.bacher@de.ibm.com>,
  6. * Frank Pavlic <fpavlic@de.ibm.com>,
  7. * Thomas Spatzier <tspat@de.ibm.com>,
  8. * Frank Blaschka <frank.blaschka@de.ibm.com>
  9. */
  10. #ifndef __QETH_CORE_H__
  11. #define __QETH_CORE_H__
  12. #include <linux/if.h>
  13. #include <linux/if_arp.h>
  14. #include <linux/if_tr.h>
  15. #include <linux/trdevice.h>
  16. #include <linux/etherdevice.h>
  17. #include <linux/if_vlan.h>
  18. #include <linux/ctype.h>
  19. #include <linux/in6.h>
  20. #include <linux/bitops.h>
  21. #include <linux/seq_file.h>
  22. #include <linux/ethtool.h>
  23. #include <net/ipv6.h>
  24. #include <net/if_inet6.h>
  25. #include <net/addrconf.h>
  26. #include <asm/debug.h>
  27. #include <asm/qdio.h>
  28. #include <asm/ccwdev.h>
  29. #include <asm/ccwgroup.h>
  30. #include "qeth_core_mpc.h"
  31. #define KMSG_COMPONENT "qeth"
  32. /**
  33. * Debug Facility stuff
  34. */
  35. enum qeth_dbf_names {
  36. QETH_DBF_SETUP,
  37. QETH_DBF_QERR,
  38. QETH_DBF_TRACE,
  39. QETH_DBF_MSG,
  40. QETH_DBF_SENSE,
  41. QETH_DBF_MISC,
  42. QETH_DBF_CTRL,
  43. QETH_DBF_INFOS /* must be last element */
  44. };
  45. struct qeth_dbf_info {
  46. char name[DEBUG_MAX_NAME_LEN];
  47. int pages;
  48. int areas;
  49. int len;
  50. int level;
  51. struct debug_view *view;
  52. debug_info_t *id;
  53. };
  54. #define QETH_DBF_CTRL_LEN 256
  55. #define QETH_DBF_TEXT(name, level, text) \
  56. debug_text_event(qeth_dbf[QETH_DBF_##name].id, level, text)
  57. #define QETH_DBF_HEX(name, level, addr, len) \
  58. debug_event(qeth_dbf[QETH_DBF_##name].id, level, (void *)(addr), len)
  59. #define QETH_DBF_MESSAGE(level, text...) \
  60. debug_sprintf_event(qeth_dbf[QETH_DBF_MSG].id, level, text)
  61. #define QETH_DBF_TEXT_(name, level, text...) \
  62. qeth_dbf_longtext(QETH_DBF_##name, level, text)
  63. /**
  64. * some more debug stuff
  65. */
  66. #define PRINTK_HEADER "qeth: "
  67. #define SENSE_COMMAND_REJECT_BYTE 0
  68. #define SENSE_COMMAND_REJECT_FLAG 0x80
  69. #define SENSE_RESETTING_EVENT_BYTE 1
  70. #define SENSE_RESETTING_EVENT_FLAG 0x80
  71. /*
  72. * Common IO related definitions
  73. */
  74. #define CARD_RDEV(card) card->read.ccwdev
  75. #define CARD_WDEV(card) card->write.ccwdev
  76. #define CARD_DDEV(card) card->data.ccwdev
  77. #define CARD_BUS_ID(card) card->gdev->dev.bus_id
  78. #define CARD_RDEV_ID(card) card->read.ccwdev->dev.bus_id
  79. #define CARD_WDEV_ID(card) card->write.ccwdev->dev.bus_id
  80. #define CARD_DDEV_ID(card) card->data.ccwdev->dev.bus_id
  81. #define CHANNEL_ID(channel) channel->ccwdev->dev.bus_id
  82. /**
  83. * card stuff
  84. */
  85. struct qeth_perf_stats {
  86. unsigned int bufs_rec;
  87. unsigned int bufs_sent;
  88. unsigned int skbs_sent_pack;
  89. unsigned int bufs_sent_pack;
  90. unsigned int sc_dp_p;
  91. unsigned int sc_p_dp;
  92. /* qdio_input_handler: number of times called, time spent in */
  93. __u64 inbound_start_time;
  94. unsigned int inbound_cnt;
  95. unsigned int inbound_time;
  96. /* qeth_send_packet: number of times called, time spent in */
  97. __u64 outbound_start_time;
  98. unsigned int outbound_cnt;
  99. unsigned int outbound_time;
  100. /* qdio_output_handler: number of times called, time spent in */
  101. __u64 outbound_handler_start_time;
  102. unsigned int outbound_handler_cnt;
  103. unsigned int outbound_handler_time;
  104. /* number of calls to and time spent in do_QDIO for inbound queue */
  105. __u64 inbound_do_qdio_start_time;
  106. unsigned int inbound_do_qdio_cnt;
  107. unsigned int inbound_do_qdio_time;
  108. /* number of calls to and time spent in do_QDIO for outbound queues */
  109. __u64 outbound_do_qdio_start_time;
  110. unsigned int outbound_do_qdio_cnt;
  111. unsigned int outbound_do_qdio_time;
  112. /* eddp data */
  113. unsigned int large_send_bytes;
  114. unsigned int large_send_cnt;
  115. unsigned int sg_skbs_sent;
  116. unsigned int sg_frags_sent;
  117. /* initial values when measuring starts */
  118. unsigned long initial_rx_packets;
  119. unsigned long initial_tx_packets;
  120. /* inbound scatter gather data */
  121. unsigned int sg_skbs_rx;
  122. unsigned int sg_frags_rx;
  123. unsigned int sg_alloc_page_rx;
  124. };
  125. /* Routing stuff */
  126. struct qeth_routing_info {
  127. enum qeth_routing_types type;
  128. };
  129. /* IPA stuff */
  130. struct qeth_ipa_info {
  131. __u32 supported_funcs;
  132. __u32 enabled_funcs;
  133. };
  134. static inline int qeth_is_ipa_supported(struct qeth_ipa_info *ipa,
  135. enum qeth_ipa_funcs func)
  136. {
  137. return (ipa->supported_funcs & func);
  138. }
  139. static inline int qeth_is_ipa_enabled(struct qeth_ipa_info *ipa,
  140. enum qeth_ipa_funcs func)
  141. {
  142. return (ipa->supported_funcs & ipa->enabled_funcs & func);
  143. }
  144. #define qeth_adp_supported(c, f) \
  145. qeth_is_ipa_supported(&c->options.adp, f)
  146. #define qeth_adp_enabled(c, f) \
  147. qeth_is_ipa_enabled(&c->options.adp, f)
  148. #define qeth_is_supported(c, f) \
  149. qeth_is_ipa_supported(&c->options.ipa4, f)
  150. #define qeth_is_enabled(c, f) \
  151. qeth_is_ipa_enabled(&c->options.ipa4, f)
  152. #define qeth_is_supported6(c, f) \
  153. qeth_is_ipa_supported(&c->options.ipa6, f)
  154. #define qeth_is_enabled6(c, f) \
  155. qeth_is_ipa_enabled(&c->options.ipa6, f)
  156. #define qeth_is_ipafunc_supported(c, prot, f) \
  157. ((prot == QETH_PROT_IPV6) ? \
  158. qeth_is_supported6(c, f) : qeth_is_supported(c, f))
  159. #define qeth_is_ipafunc_enabled(c, prot, f) \
  160. ((prot == QETH_PROT_IPV6) ? \
  161. qeth_is_enabled6(c, f) : qeth_is_enabled(c, f))
  162. #define QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT 0x0101
  163. #define QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT 0x0101
  164. #define QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT 0x4108
  165. #define QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT 0x5108
  166. #define QETH_MODELLIST_ARRAY \
  167. {{0x1731, 0x01, 0x1732, 0x01, QETH_CARD_TYPE_OSAE, 1, \
  168. QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT, \
  169. QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT, \
  170. QETH_MAX_QUEUES, 0}, \
  171. {0x1731, 0x05, 0x1732, 0x05, QETH_CARD_TYPE_IQD, 0, \
  172. QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT, \
  173. QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT, \
  174. QETH_MAX_QUEUES, 0x103}, \
  175. {0x1731, 0x06, 0x1732, 0x06, QETH_CARD_TYPE_OSN, 0, \
  176. QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT, \
  177. QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT, \
  178. QETH_MAX_QUEUES, 0}, \
  179. {0, 0, 0, 0, 0, 0, 0, 0, 0} }
  180. #define QETH_REAL_CARD 1
  181. #define QETH_VLAN_CARD 2
  182. #define QETH_BUFSIZE 4096
  183. /**
  184. * some more defs
  185. */
  186. #define QETH_TX_TIMEOUT 100 * HZ
  187. #define QETH_RCD_TIMEOUT 60 * HZ
  188. #define QETH_HEADER_SIZE 32
  189. #define QETH_MAX_PORTNO 15
  190. /*IPv6 address autoconfiguration stuff*/
  191. #define UNIQUE_ID_IF_CREATE_ADDR_FAILED 0xfffe
  192. #define UNIQUE_ID_NOT_BY_CARD 0x10000
  193. /*****************************************************************************/
  194. /* QDIO queue and buffer handling */
  195. /*****************************************************************************/
  196. #define QETH_MAX_QUEUES 4
  197. #define QETH_IN_BUF_SIZE_DEFAULT 65536
  198. #define QETH_IN_BUF_COUNT_DEFAULT 16
  199. #define QETH_IN_BUF_COUNT_MIN 8
  200. #define QETH_IN_BUF_COUNT_MAX 128
  201. #define QETH_MAX_BUFFER_ELEMENTS(card) ((card)->qdio.in_buf_size >> 12)
  202. #define QETH_IN_BUF_REQUEUE_THRESHOLD(card) \
  203. ((card)->qdio.in_buf_pool.buf_count / 2)
  204. /* buffers we have to be behind before we get a PCI */
  205. #define QETH_PCI_THRESHOLD_A(card) ((card)->qdio.in_buf_pool.buf_count+1)
  206. /*enqueued free buffers left before we get a PCI*/
  207. #define QETH_PCI_THRESHOLD_B(card) 0
  208. /*not used unless the microcode gets patched*/
  209. #define QETH_PCI_TIMER_VALUE(card) 3
  210. #define QETH_MIN_INPUT_THRESHOLD 1
  211. #define QETH_MAX_INPUT_THRESHOLD 500
  212. #define QETH_MIN_OUTPUT_THRESHOLD 1
  213. #define QETH_MAX_OUTPUT_THRESHOLD 300
  214. /* priority queing */
  215. #define QETH_PRIOQ_DEFAULT QETH_NO_PRIO_QUEUEING
  216. #define QETH_DEFAULT_QUEUE 2
  217. #define QETH_NO_PRIO_QUEUEING 0
  218. #define QETH_PRIO_Q_ING_PREC 1
  219. #define QETH_PRIO_Q_ING_TOS 2
  220. #define IP_TOS_LOWDELAY 0x10
  221. #define IP_TOS_HIGHTHROUGHPUT 0x08
  222. #define IP_TOS_HIGHRELIABILITY 0x04
  223. #define IP_TOS_NOTIMPORTANT 0x02
  224. /* Packing */
  225. #define QETH_LOW_WATERMARK_PACK 2
  226. #define QETH_HIGH_WATERMARK_PACK 5
  227. #define QETH_WATERMARK_PACK_FUZZ 1
  228. #define QETH_IP_HEADER_SIZE 40
  229. /* large receive scatter gather copy break */
  230. #define QETH_RX_SG_CB (PAGE_SIZE >> 1)
  231. struct qeth_hdr_layer3 {
  232. __u8 id;
  233. __u8 flags;
  234. __u16 inbound_checksum; /*TSO:__u16 seqno */
  235. __u32 token; /*TSO: __u32 reserved */
  236. __u16 length;
  237. __u8 vlan_prio;
  238. __u8 ext_flags;
  239. __u16 vlan_id;
  240. __u16 frame_offset;
  241. __u8 dest_addr[16];
  242. } __attribute__ ((packed));
  243. struct qeth_hdr_layer2 {
  244. __u8 id;
  245. __u8 flags[3];
  246. __u8 port_no;
  247. __u8 hdr_length;
  248. __u16 pkt_length;
  249. __u16 seq_no;
  250. __u16 vlan_id;
  251. __u32 reserved;
  252. __u8 reserved2[16];
  253. } __attribute__ ((packed));
  254. struct qeth_hdr_osn {
  255. __u8 id;
  256. __u8 reserved;
  257. __u16 seq_no;
  258. __u16 reserved2;
  259. __u16 control_flags;
  260. __u16 pdu_length;
  261. __u8 reserved3[18];
  262. __u32 ccid;
  263. } __attribute__ ((packed));
  264. struct qeth_hdr {
  265. union {
  266. struct qeth_hdr_layer2 l2;
  267. struct qeth_hdr_layer3 l3;
  268. struct qeth_hdr_osn osn;
  269. } hdr;
  270. } __attribute__ ((packed));
  271. /*TCP Segmentation Offload header*/
  272. struct qeth_hdr_ext_tso {
  273. __u16 hdr_tot_len;
  274. __u8 imb_hdr_no;
  275. __u8 reserved;
  276. __u8 hdr_type;
  277. __u8 hdr_version;
  278. __u16 hdr_len;
  279. __u32 payload_len;
  280. __u16 mss;
  281. __u16 dg_hdr_len;
  282. __u8 padding[16];
  283. } __attribute__ ((packed));
  284. struct qeth_hdr_tso {
  285. struct qeth_hdr hdr; /*hdr->hdr.l3.xxx*/
  286. struct qeth_hdr_ext_tso ext;
  287. } __attribute__ ((packed));
  288. /* flags for qeth_hdr.flags */
  289. #define QETH_HDR_PASSTHRU 0x10
  290. #define QETH_HDR_IPV6 0x80
  291. #define QETH_HDR_CAST_MASK 0x07
  292. enum qeth_cast_flags {
  293. QETH_CAST_UNICAST = 0x06,
  294. QETH_CAST_MULTICAST = 0x04,
  295. QETH_CAST_BROADCAST = 0x05,
  296. QETH_CAST_ANYCAST = 0x07,
  297. QETH_CAST_NOCAST = 0x00,
  298. };
  299. enum qeth_layer2_frame_flags {
  300. QETH_LAYER2_FLAG_MULTICAST = 0x01,
  301. QETH_LAYER2_FLAG_BROADCAST = 0x02,
  302. QETH_LAYER2_FLAG_UNICAST = 0x04,
  303. QETH_LAYER2_FLAG_VLAN = 0x10,
  304. };
  305. enum qeth_header_ids {
  306. QETH_HEADER_TYPE_LAYER3 = 0x01,
  307. QETH_HEADER_TYPE_LAYER2 = 0x02,
  308. QETH_HEADER_TYPE_TSO = 0x03,
  309. QETH_HEADER_TYPE_OSN = 0x04,
  310. };
  311. /* flags for qeth_hdr.ext_flags */
  312. #define QETH_HDR_EXT_VLAN_FRAME 0x01
  313. #define QETH_HDR_EXT_TOKEN_ID 0x02
  314. #define QETH_HDR_EXT_INCLUDE_VLAN_TAG 0x04
  315. #define QETH_HDR_EXT_SRC_MAC_ADDR 0x08
  316. #define QETH_HDR_EXT_CSUM_HDR_REQ 0x10
  317. #define QETH_HDR_EXT_CSUM_TRANSP_REQ 0x20
  318. #define QETH_HDR_EXT_UDP_TSO 0x40 /*bit off for TCP*/
  319. static inline int qeth_is_last_sbale(struct qdio_buffer_element *sbale)
  320. {
  321. return (sbale->flags & SBAL_FLAGS_LAST_ENTRY);
  322. }
  323. enum qeth_qdio_buffer_states {
  324. /*
  325. * inbound: read out by driver; owned by hardware in order to be filled
  326. * outbound: owned by driver in order to be filled
  327. */
  328. QETH_QDIO_BUF_EMPTY,
  329. /*
  330. * inbound: filled by hardware; owned by driver in order to be read out
  331. * outbound: filled by driver; owned by hardware in order to be sent
  332. */
  333. QETH_QDIO_BUF_PRIMED,
  334. };
  335. enum qeth_qdio_info_states {
  336. QETH_QDIO_UNINITIALIZED,
  337. QETH_QDIO_ALLOCATED,
  338. QETH_QDIO_ESTABLISHED,
  339. QETH_QDIO_CLEANING
  340. };
  341. struct qeth_buffer_pool_entry {
  342. struct list_head list;
  343. struct list_head init_list;
  344. void *elements[QDIO_MAX_ELEMENTS_PER_BUFFER];
  345. };
  346. struct qeth_qdio_buffer_pool {
  347. struct list_head entry_list;
  348. int buf_count;
  349. };
  350. struct qeth_qdio_buffer {
  351. struct qdio_buffer *buffer;
  352. /* the buffer pool entry currently associated to this buffer */
  353. struct qeth_buffer_pool_entry *pool_entry;
  354. };
  355. struct qeth_qdio_q {
  356. struct qdio_buffer qdio_bufs[QDIO_MAX_BUFFERS_PER_Q];
  357. struct qeth_qdio_buffer bufs[QDIO_MAX_BUFFERS_PER_Q];
  358. int next_buf_to_init;
  359. } __attribute__ ((aligned(256)));
  360. /* possible types of qeth large_send support */
  361. enum qeth_large_send_types {
  362. QETH_LARGE_SEND_NO,
  363. QETH_LARGE_SEND_EDDP,
  364. QETH_LARGE_SEND_TSO,
  365. };
  366. struct qeth_qdio_out_buffer {
  367. struct qdio_buffer *buffer;
  368. atomic_t state;
  369. int next_element_to_fill;
  370. struct sk_buff_head skb_list;
  371. struct list_head ctx_list;
  372. };
  373. struct qeth_card;
  374. enum qeth_out_q_states {
  375. QETH_OUT_Q_UNLOCKED,
  376. QETH_OUT_Q_LOCKED,
  377. QETH_OUT_Q_LOCKED_FLUSH,
  378. };
  379. struct qeth_qdio_out_q {
  380. struct qdio_buffer qdio_bufs[QDIO_MAX_BUFFERS_PER_Q];
  381. struct qeth_qdio_out_buffer bufs[QDIO_MAX_BUFFERS_PER_Q];
  382. int queue_no;
  383. struct qeth_card *card;
  384. atomic_t state;
  385. int do_pack;
  386. /*
  387. * index of buffer to be filled by driver; state EMPTY or PACKING
  388. */
  389. int next_buf_to_fill;
  390. /*
  391. * number of buffers that are currently filled (PRIMED)
  392. * -> these buffers are hardware-owned
  393. */
  394. atomic_t used_buffers;
  395. /* indicates whether PCI flag must be set (or if one is outstanding) */
  396. atomic_t set_pci_flags_count;
  397. } __attribute__ ((aligned(256)));
  398. struct qeth_qdio_info {
  399. atomic_t state;
  400. /* input */
  401. struct qeth_qdio_q *in_q;
  402. struct qeth_qdio_buffer_pool in_buf_pool;
  403. struct qeth_qdio_buffer_pool init_pool;
  404. int in_buf_size;
  405. /* output */
  406. int no_out_queues;
  407. struct qeth_qdio_out_q **out_qs;
  408. /* priority queueing */
  409. int do_prio_queueing;
  410. int default_out_queue;
  411. };
  412. enum qeth_send_errors {
  413. QETH_SEND_ERROR_NONE,
  414. QETH_SEND_ERROR_LINK_FAILURE,
  415. QETH_SEND_ERROR_RETRY,
  416. QETH_SEND_ERROR_KICK_IT,
  417. };
  418. #define QETH_ETH_MAC_V4 0x0100 /* like v4 */
  419. #define QETH_ETH_MAC_V6 0x3333 /* like v6 */
  420. /* tr mc mac is longer, but that will be enough to detect mc frames */
  421. #define QETH_TR_MAC_NC 0xc000 /* non-canonical */
  422. #define QETH_TR_MAC_C 0x0300 /* canonical */
  423. #define DEFAULT_ADD_HHLEN 0
  424. #define MAX_ADD_HHLEN 1024
  425. /**
  426. * buffer stuff for read channel
  427. */
  428. #define QETH_CMD_BUFFER_NO 8
  429. /**
  430. * channel state machine
  431. */
  432. enum qeth_channel_states {
  433. CH_STATE_UP,
  434. CH_STATE_DOWN,
  435. CH_STATE_ACTIVATING,
  436. CH_STATE_HALTED,
  437. CH_STATE_STOPPED,
  438. CH_STATE_RCD,
  439. CH_STATE_RCD_DONE,
  440. };
  441. /**
  442. * card state machine
  443. */
  444. enum qeth_card_states {
  445. CARD_STATE_DOWN,
  446. CARD_STATE_HARDSETUP,
  447. CARD_STATE_SOFTSETUP,
  448. CARD_STATE_UP,
  449. CARD_STATE_RECOVER,
  450. };
  451. /**
  452. * Protocol versions
  453. */
  454. enum qeth_prot_versions {
  455. QETH_PROT_IPV4 = 0x0004,
  456. QETH_PROT_IPV6 = 0x0006,
  457. };
  458. enum qeth_ip_types {
  459. QETH_IP_TYPE_NORMAL,
  460. QETH_IP_TYPE_VIPA,
  461. QETH_IP_TYPE_RXIP,
  462. QETH_IP_TYPE_DEL_ALL_MC,
  463. };
  464. enum qeth_cmd_buffer_state {
  465. BUF_STATE_FREE,
  466. BUF_STATE_LOCKED,
  467. BUF_STATE_PROCESSED,
  468. };
  469. struct qeth_ipato {
  470. int enabled;
  471. int invert4;
  472. int invert6;
  473. struct list_head entries;
  474. };
  475. struct qeth_channel;
  476. struct qeth_cmd_buffer {
  477. enum qeth_cmd_buffer_state state;
  478. struct qeth_channel *channel;
  479. unsigned char *data;
  480. int rc;
  481. void (*callback) (struct qeth_channel *, struct qeth_cmd_buffer *);
  482. };
  483. /**
  484. * definition of a qeth channel, used for read and write
  485. */
  486. struct qeth_channel {
  487. enum qeth_channel_states state;
  488. struct ccw1 ccw;
  489. spinlock_t iob_lock;
  490. wait_queue_head_t wait_q;
  491. struct tasklet_struct irq_tasklet;
  492. struct ccw_device *ccwdev;
  493. /*command buffer for control data*/
  494. struct qeth_cmd_buffer iob[QETH_CMD_BUFFER_NO];
  495. atomic_t irq_pending;
  496. int io_buf_no;
  497. int buf_no;
  498. };
  499. /**
  500. * OSA card related definitions
  501. */
  502. struct qeth_token {
  503. __u32 issuer_rm_w;
  504. __u32 issuer_rm_r;
  505. __u32 cm_filter_w;
  506. __u32 cm_filter_r;
  507. __u32 cm_connection_w;
  508. __u32 cm_connection_r;
  509. __u32 ulp_filter_w;
  510. __u32 ulp_filter_r;
  511. __u32 ulp_connection_w;
  512. __u32 ulp_connection_r;
  513. };
  514. struct qeth_seqno {
  515. __u32 trans_hdr;
  516. __u32 pdu_hdr;
  517. __u32 pdu_hdr_ack;
  518. __u16 ipa;
  519. __u32 pkt_seqno;
  520. };
  521. struct qeth_reply {
  522. struct list_head list;
  523. wait_queue_head_t wait_q;
  524. int (*callback)(struct qeth_card *, struct qeth_reply *,
  525. unsigned long);
  526. u32 seqno;
  527. unsigned long offset;
  528. atomic_t received;
  529. int rc;
  530. void *param;
  531. struct qeth_card *card;
  532. atomic_t refcnt;
  533. };
  534. struct qeth_card_blkt {
  535. int time_total;
  536. int inter_packet;
  537. int inter_packet_jumbo;
  538. };
  539. #define QETH_BROADCAST_WITH_ECHO 0x01
  540. #define QETH_BROADCAST_WITHOUT_ECHO 0x02
  541. #define QETH_LAYER2_MAC_READ 0x01
  542. #define QETH_LAYER2_MAC_REGISTERED 0x02
  543. struct qeth_card_info {
  544. unsigned short unit_addr2;
  545. unsigned short cula;
  546. unsigned short chpid;
  547. __u16 func_level;
  548. char mcl_level[QETH_MCL_LENGTH + 1];
  549. int guestlan;
  550. int mac_bits;
  551. int portname_required;
  552. int portno;
  553. char portname[9];
  554. enum qeth_card_types type;
  555. enum qeth_link_types link_type;
  556. int is_multicast_different;
  557. int initial_mtu;
  558. int max_mtu;
  559. int broadcast_capable;
  560. int unique_id;
  561. struct qeth_card_blkt blkt;
  562. __u32 csum_mask;
  563. enum qeth_ipa_promisc_modes promisc_mode;
  564. };
  565. struct qeth_card_options {
  566. struct qeth_routing_info route4;
  567. struct qeth_ipa_info ipa4;
  568. struct qeth_ipa_info adp; /*Adapter parameters*/
  569. struct qeth_routing_info route6;
  570. struct qeth_ipa_info ipa6;
  571. enum qeth_checksum_types checksum_type;
  572. int broadcast_mode;
  573. int macaddr_mode;
  574. int fake_broadcast;
  575. int add_hhlen;
  576. int fake_ll;
  577. int layer2;
  578. enum qeth_large_send_types large_send;
  579. int performance_stats;
  580. int rx_sg_cb;
  581. };
  582. /*
  583. * thread bits for qeth_card thread masks
  584. */
  585. enum qeth_threads {
  586. QETH_RECOVER_THREAD = 1,
  587. };
  588. struct qeth_osn_info {
  589. int (*assist_cb)(struct net_device *dev, void *data);
  590. int (*data_cb)(struct sk_buff *skb);
  591. };
  592. enum qeth_discipline_id {
  593. QETH_DISCIPLINE_LAYER3 = 0,
  594. QETH_DISCIPLINE_LAYER2 = 1,
  595. };
  596. struct qeth_discipline {
  597. qdio_handler_t *input_handler;
  598. qdio_handler_t *output_handler;
  599. int (*recover)(void *ptr);
  600. struct ccwgroup_driver *ccwgdriver;
  601. };
  602. struct qeth_vlan_vid {
  603. struct list_head list;
  604. unsigned short vid;
  605. };
  606. struct qeth_mc_mac {
  607. struct list_head list;
  608. __u8 mc_addr[MAX_ADDR_LEN];
  609. unsigned char mc_addrlen;
  610. };
  611. struct qeth_card {
  612. struct list_head list;
  613. enum qeth_card_states state;
  614. int lan_online;
  615. spinlock_t lock;
  616. struct ccwgroup_device *gdev;
  617. struct qeth_channel read;
  618. struct qeth_channel write;
  619. struct qeth_channel data;
  620. struct net_device *dev;
  621. struct net_device_stats stats;
  622. struct qeth_card_info info;
  623. struct qeth_token token;
  624. struct qeth_seqno seqno;
  625. struct qeth_card_options options;
  626. wait_queue_head_t wait_q;
  627. spinlock_t vlanlock;
  628. spinlock_t mclock;
  629. struct vlan_group *vlangrp;
  630. struct list_head vid_list;
  631. struct list_head mc_list;
  632. struct work_struct kernel_thread_starter;
  633. spinlock_t thread_mask_lock;
  634. unsigned long thread_start_mask;
  635. unsigned long thread_allowed_mask;
  636. unsigned long thread_running_mask;
  637. spinlock_t ip_lock;
  638. struct list_head ip_list;
  639. struct list_head *ip_tbd_list;
  640. struct qeth_ipato ipato;
  641. struct list_head cmd_waiter_list;
  642. /* QDIO buffer handling */
  643. struct qeth_qdio_info qdio;
  644. struct qeth_perf_stats perf_stats;
  645. int use_hard_stop;
  646. struct qeth_osn_info osn_info;
  647. struct qeth_discipline discipline;
  648. atomic_t force_alloc_skb;
  649. };
  650. struct qeth_card_list_struct {
  651. struct list_head list;
  652. rwlock_t rwlock;
  653. };
  654. /*some helper functions*/
  655. #define QETH_CARD_IFNAME(card) (((card)->dev)? (card)->dev->name : "")
  656. static inline struct qeth_card *CARD_FROM_CDEV(struct ccw_device *cdev)
  657. {
  658. struct qeth_card *card = dev_get_drvdata(&((struct ccwgroup_device *)
  659. dev_get_drvdata(&cdev->dev))->dev);
  660. return card;
  661. }
  662. static inline int qeth_get_micros(void)
  663. {
  664. return (int) (get_clock() >> 12);
  665. }
  666. static inline int qeth_get_ip_version(struct sk_buff *skb)
  667. {
  668. switch (skb->protocol) {
  669. case ETH_P_IPV6:
  670. return 6;
  671. case ETH_P_IP:
  672. return 4;
  673. default:
  674. return 0;
  675. }
  676. }
  677. static inline void qeth_put_buffer_pool_entry(struct qeth_card *card,
  678. struct qeth_buffer_pool_entry *entry)
  679. {
  680. list_add_tail(&entry->list, &card->qdio.in_buf_pool.entry_list);
  681. }
  682. struct qeth_eddp_context;
  683. extern struct ccwgroup_driver qeth_l2_ccwgroup_driver;
  684. extern struct ccwgroup_driver qeth_l3_ccwgroup_driver;
  685. const char *qeth_get_cardname_short(struct qeth_card *);
  686. int qeth_realloc_buffer_pool(struct qeth_card *, int);
  687. int qeth_core_load_discipline(struct qeth_card *, enum qeth_discipline_id);
  688. void qeth_core_free_discipline(struct qeth_card *);
  689. int qeth_core_create_device_attributes(struct device *);
  690. void qeth_core_remove_device_attributes(struct device *);
  691. int qeth_core_create_osn_attributes(struct device *);
  692. void qeth_core_remove_osn_attributes(struct device *);
  693. /* exports for qeth discipline device drivers */
  694. extern struct qeth_card_list_struct qeth_core_card_list;
  695. extern struct qeth_dbf_info qeth_dbf[QETH_DBF_INFOS];
  696. void qeth_set_allowed_threads(struct qeth_card *, unsigned long , int);
  697. int qeth_threads_running(struct qeth_card *, unsigned long);
  698. int qeth_wait_for_threads(struct qeth_card *, unsigned long);
  699. int qeth_do_run_thread(struct qeth_card *, unsigned long);
  700. void qeth_clear_thread_start_bit(struct qeth_card *, unsigned long);
  701. void qeth_clear_thread_running_bit(struct qeth_card *, unsigned long);
  702. int qeth_core_hardsetup_card(struct qeth_card *);
  703. void qeth_print_status_message(struct qeth_card *);
  704. int qeth_init_qdio_queues(struct qeth_card *);
  705. int qeth_send_startlan(struct qeth_card *);
  706. int qeth_send_stoplan(struct qeth_card *);
  707. int qeth_send_ipa_cmd(struct qeth_card *, struct qeth_cmd_buffer *,
  708. int (*reply_cb)
  709. (struct qeth_card *, struct qeth_reply *, unsigned long),
  710. void *);
  711. struct qeth_cmd_buffer *qeth_get_ipacmd_buffer(struct qeth_card *,
  712. enum qeth_ipa_cmds, enum qeth_prot_versions);
  713. int qeth_query_setadapterparms(struct qeth_card *);
  714. int qeth_check_qdio_errors(struct qdio_buffer *, unsigned int,
  715. unsigned int, const char *);
  716. void qeth_queue_input_buffer(struct qeth_card *, int);
  717. struct sk_buff *qeth_core_get_next_skb(struct qeth_card *,
  718. struct qdio_buffer *, struct qdio_buffer_element **, int *,
  719. struct qeth_hdr **);
  720. void qeth_schedule_recovery(struct qeth_card *);
  721. void qeth_qdio_output_handler(struct ccw_device *, unsigned int,
  722. unsigned int, unsigned int,
  723. unsigned int, int, int,
  724. unsigned long);
  725. void qeth_clear_ipacmd_list(struct qeth_card *);
  726. int qeth_qdio_clear_card(struct qeth_card *, int);
  727. void qeth_clear_working_pool_list(struct qeth_card *);
  728. void qeth_clear_cmd_buffers(struct qeth_channel *);
  729. void qeth_clear_qdio_buffers(struct qeth_card *);
  730. void qeth_setadp_promisc_mode(struct qeth_card *);
  731. struct net_device_stats *qeth_get_stats(struct net_device *);
  732. int qeth_change_mtu(struct net_device *, int);
  733. int qeth_setadpparms_change_macaddr(struct qeth_card *);
  734. void qeth_tx_timeout(struct net_device *);
  735. void qeth_prepare_control_data(struct qeth_card *, int,
  736. struct qeth_cmd_buffer *);
  737. void qeth_release_buffer(struct qeth_channel *, struct qeth_cmd_buffer *);
  738. void qeth_prepare_ipa_cmd(struct qeth_card *, struct qeth_cmd_buffer *, char);
  739. struct qeth_cmd_buffer *qeth_wait_for_buffer(struct qeth_channel *);
  740. int qeth_mdio_read(struct net_device *, int, int);
  741. int qeth_snmp_command(struct qeth_card *, char __user *);
  742. int qeth_set_large_send(struct qeth_card *, enum qeth_large_send_types);
  743. struct qeth_cmd_buffer *qeth_get_adapter_cmd(struct qeth_card *, __u32, __u32);
  744. int qeth_default_setadapterparms_cb(struct qeth_card *, struct qeth_reply *,
  745. unsigned long);
  746. int qeth_send_control_data(struct qeth_card *, int, struct qeth_cmd_buffer *,
  747. int (*reply_cb)(struct qeth_card *, struct qeth_reply*, unsigned long),
  748. void *reply_param);
  749. int qeth_get_cast_type(struct qeth_card *, struct sk_buff *);
  750. int qeth_get_priority_queue(struct qeth_card *, struct sk_buff *, int, int);
  751. int qeth_get_elements_no(struct qeth_card *, void *, struct sk_buff *, int);
  752. int qeth_do_send_packet_fast(struct qeth_card *, struct qeth_qdio_out_q *,
  753. struct sk_buff *, struct qeth_hdr *, int,
  754. struct qeth_eddp_context *);
  755. int qeth_do_send_packet(struct qeth_card *, struct qeth_qdio_out_q *,
  756. struct sk_buff *, struct qeth_hdr *,
  757. int, struct qeth_eddp_context *);
  758. int qeth_core_get_stats_count(struct net_device *);
  759. void qeth_core_get_ethtool_stats(struct net_device *,
  760. struct ethtool_stats *, u64 *);
  761. void qeth_core_get_strings(struct net_device *, u32, u8 *);
  762. void qeth_core_get_drvinfo(struct net_device *, struct ethtool_drvinfo *);
  763. void qeth_dbf_longtext(enum qeth_dbf_names dbf_nix, int level, char *text, ...);
  764. int qeth_core_ethtool_get_settings(struct net_device *, struct ethtool_cmd *);
  765. /* exports for OSN */
  766. int qeth_osn_assist(struct net_device *, void *, int);
  767. int qeth_osn_register(unsigned char *read_dev_no, struct net_device **,
  768. int (*assist_cb)(struct net_device *, void *),
  769. int (*data_cb)(struct sk_buff *));
  770. void qeth_osn_deregister(struct net_device *);
  771. #endif /* __QETH_CORE_H__ */