ctcmain.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /*
  2. * $Id: ctcmain.h,v 1.4 2005/03/24 09:04:17 mschwide Exp $
  3. *
  4. * CTC / ESCON network driver
  5. *
  6. * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
  7. * Author(s): Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com)
  8. Peter Tiedemann (ptiedem@de.ibm.com)
  9. *
  10. *
  11. * Documentation used:
  12. * - Principles of Operation (IBM doc#: SA22-7201-06)
  13. * - Common IO/-Device Commands and Self Description (IBM doc#: SA22-7204-02)
  14. * - Common IO/-Device Commands and Self Description (IBM doc#: SN22-5535)
  15. * - ESCON Channel-to-Channel Adapter (IBM doc#: SA22-7203-00)
  16. * - ESCON I/O Interface (IBM doc#: SA22-7202-029
  17. *
  18. * This program is free software; you can redistribute it and/or modify
  19. * it under the terms of the GNU General Public License as published by
  20. * the Free Software Foundation; either version 2, or (at your option)
  21. * any later version.
  22. *
  23. * This program is distributed in the hope that it will be useful,
  24. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. * GNU General Public License for more details.
  27. *
  28. * You should have received a copy of the GNU General Public License
  29. * along with this program; if not, write to the Free Software
  30. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  31. *
  32. * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.4 $
  33. *
  34. */
  35. #ifndef _CTCMAIN_H_
  36. #define _CTCMAIN_H_
  37. #include <asm/ccwdev.h>
  38. #include <asm/ccwgroup.h>
  39. #include "ctctty.h"
  40. #include "fsm.h"
  41. #include "cu3088.h"
  42. /**
  43. * CCW commands, used in this driver.
  44. */
  45. #define CCW_CMD_WRITE 0x01
  46. #define CCW_CMD_READ 0x02
  47. #define CCW_CMD_SET_EXTENDED 0xc3
  48. #define CCW_CMD_PREPARE 0xe3
  49. #define CTC_PROTO_S390 0
  50. #define CTC_PROTO_LINUX 1
  51. #define CTC_PROTO_LINUX_TTY 2
  52. #define CTC_PROTO_OS390 3
  53. #define CTC_PROTO_MAX 3
  54. #define CTC_BUFSIZE_LIMIT 65535
  55. #define CTC_BUFSIZE_DEFAULT 32768
  56. #define CTC_TIMEOUT_5SEC 5000
  57. #define CTC_INITIAL_BLOCKLEN 2
  58. #define READ 0
  59. #define WRITE 1
  60. #define CTC_ID_SIZE BUS_ID_SIZE+3
  61. struct ctc_profile {
  62. unsigned long maxmulti;
  63. unsigned long maxcqueue;
  64. unsigned long doios_single;
  65. unsigned long doios_multi;
  66. unsigned long txlen;
  67. unsigned long tx_time;
  68. struct timespec send_stamp;
  69. };
  70. /**
  71. * Definition of one channel
  72. */
  73. struct channel {
  74. /**
  75. * Pointer to next channel in list.
  76. */
  77. struct channel *next;
  78. char id[CTC_ID_SIZE];
  79. struct ccw_device *cdev;
  80. /**
  81. * Type of this channel.
  82. * CTC/A or Escon for valid channels.
  83. */
  84. enum channel_types type;
  85. /**
  86. * Misc. flags. See CHANNEL_FLAGS_... below
  87. */
  88. __u32 flags;
  89. /**
  90. * The protocol of this channel
  91. */
  92. __u16 protocol;
  93. /**
  94. * I/O and irq related stuff
  95. */
  96. struct ccw1 *ccw;
  97. struct irb *irb;
  98. /**
  99. * RX/TX buffer size
  100. */
  101. int max_bufsize;
  102. /**
  103. * Transmit/Receive buffer.
  104. */
  105. struct sk_buff *trans_skb;
  106. /**
  107. * Universal I/O queue.
  108. */
  109. struct sk_buff_head io_queue;
  110. /**
  111. * TX queue for collecting skb's during busy.
  112. */
  113. struct sk_buff_head collect_queue;
  114. /**
  115. * Amount of data in collect_queue.
  116. */
  117. int collect_len;
  118. /**
  119. * spinlock for collect_queue and collect_len
  120. */
  121. spinlock_t collect_lock;
  122. /**
  123. * Timer for detecting unresposive
  124. * I/O operations.
  125. */
  126. fsm_timer timer;
  127. /**
  128. * Retry counter for misc. operations.
  129. */
  130. int retry;
  131. /**
  132. * The finite state machine of this channel
  133. */
  134. fsm_instance *fsm;
  135. /**
  136. * The corresponding net_device this channel
  137. * belongs to.
  138. */
  139. struct net_device *netdev;
  140. struct ctc_profile prof;
  141. unsigned char *trans_skb_data;
  142. __u16 logflags;
  143. };
  144. #define CHANNEL_FLAGS_READ 0
  145. #define CHANNEL_FLAGS_WRITE 1
  146. #define CHANNEL_FLAGS_INUSE 2
  147. #define CHANNEL_FLAGS_BUFSIZE_CHANGED 4
  148. #define CHANNEL_FLAGS_FAILED 8
  149. #define CHANNEL_FLAGS_WAITIRQ 16
  150. #define CHANNEL_FLAGS_RWMASK 1
  151. #define CHANNEL_DIRECTION(f) (f & CHANNEL_FLAGS_RWMASK)
  152. #define LOG_FLAG_ILLEGALPKT 1
  153. #define LOG_FLAG_ILLEGALSIZE 2
  154. #define LOG_FLAG_OVERRUN 4
  155. #define LOG_FLAG_NOMEM 8
  156. #define CTC_LOGLEVEL_INFO 1
  157. #define CTC_LOGLEVEL_NOTICE 2
  158. #define CTC_LOGLEVEL_WARN 4
  159. #define CTC_LOGLEVEL_EMERG 8
  160. #define CTC_LOGLEVEL_ERR 16
  161. #define CTC_LOGLEVEL_DEBUG 32
  162. #define CTC_LOGLEVEL_CRIT 64
  163. #define CTC_LOGLEVEL_DEFAULT \
  164. (CTC_LOGLEVEL_INFO | CTC_LOGLEVEL_NOTICE | CTC_LOGLEVEL_WARN | CTC_LOGLEVEL_CRIT)
  165. #define CTC_LOGLEVEL_MAX ((CTC_LOGLEVEL_CRIT<<1)-1)
  166. #define ctc_pr_debug(fmt, arg...) \
  167. do { if (loglevel & CTC_LOGLEVEL_DEBUG) printk(KERN_DEBUG fmt,##arg); } while (0)
  168. #define ctc_pr_info(fmt, arg...) \
  169. do { if (loglevel & CTC_LOGLEVEL_INFO) printk(KERN_INFO fmt,##arg); } while (0)
  170. #define ctc_pr_notice(fmt, arg...) \
  171. do { if (loglevel & CTC_LOGLEVEL_NOTICE) printk(KERN_NOTICE fmt,##arg); } while (0)
  172. #define ctc_pr_warn(fmt, arg...) \
  173. do { if (loglevel & CTC_LOGLEVEL_WARN) printk(KERN_WARNING fmt,##arg); } while (0)
  174. #define ctc_pr_emerg(fmt, arg...) \
  175. do { if (loglevel & CTC_LOGLEVEL_EMERG) printk(KERN_EMERG fmt,##arg); } while (0)
  176. #define ctc_pr_err(fmt, arg...) \
  177. do { if (loglevel & CTC_LOGLEVEL_ERR) printk(KERN_ERR fmt,##arg); } while (0)
  178. #define ctc_pr_crit(fmt, arg...) \
  179. do { if (loglevel & CTC_LOGLEVEL_CRIT) printk(KERN_CRIT fmt,##arg); } while (0)
  180. struct ctc_priv {
  181. struct net_device_stats stats;
  182. unsigned long tbusy;
  183. /**
  184. * The finite state machine of this interface.
  185. */
  186. fsm_instance *fsm;
  187. /**
  188. * The protocol of this device
  189. */
  190. __u16 protocol;
  191. /**
  192. * Timer for restarting after I/O Errors
  193. */
  194. fsm_timer restart_timer;
  195. int buffer_size;
  196. struct channel *channel[2];
  197. };
  198. /**
  199. * Definition of our link level header.
  200. */
  201. struct ll_header {
  202. __u16 length;
  203. __u16 type;
  204. __u16 unused;
  205. };
  206. #define LL_HEADER_LENGTH (sizeof(struct ll_header))
  207. /**
  208. * Compatibility macros for busy handling
  209. * of network devices.
  210. */
  211. static __inline__ void
  212. ctc_clear_busy(struct net_device * dev)
  213. {
  214. clear_bit(0, &(((struct ctc_priv *) dev->priv)->tbusy));
  215. if (((struct ctc_priv *)dev->priv)->protocol != CTC_PROTO_LINUX_TTY)
  216. netif_wake_queue(dev);
  217. }
  218. static __inline__ int
  219. ctc_test_and_set_busy(struct net_device * dev)
  220. {
  221. if (((struct ctc_priv *)dev->priv)->protocol != CTC_PROTO_LINUX_TTY)
  222. netif_stop_queue(dev);
  223. return test_and_set_bit(0, &((struct ctc_priv *) dev->priv)->tbusy);
  224. }
  225. #endif