lcs.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /*lcs.h*/
  2. #include <linux/interrupt.h>
  3. #include <linux/netdevice.h>
  4. #include <linux/skbuff.h>
  5. #include <linux/workqueue.h>
  6. #include <asm/ccwdev.h>
  7. #define LCS_DBF_TEXT(level, name, text) \
  8. do { \
  9. debug_text_event(lcs_dbf_##name, level, text); \
  10. } while (0)
  11. #define LCS_DBF_HEX(level,name,addr,len) \
  12. do { \
  13. debug_event(lcs_dbf_##name,level,(void*)(addr),len); \
  14. } while (0)
  15. #define LCS_DBF_TEXT_(level,name,text...) \
  16. do { \
  17. if (debug_level_enabled(lcs_dbf_##name, level)) { \
  18. sprintf(debug_buffer, text); \
  19. debug_text_event(lcs_dbf_##name, level, debug_buffer); \
  20. } \
  21. } while (0)
  22. /**
  23. * sysfs related stuff
  24. */
  25. #define CARD_FROM_DEV(cdev) \
  26. (struct lcs_card *) dev_get_drvdata( \
  27. &((struct ccwgroup_device *)dev_get_drvdata(&cdev->dev))->dev);
  28. /**
  29. * Enum for classifying detected devices.
  30. */
  31. enum lcs_channel_types {
  32. /* Device is not a channel */
  33. lcs_channel_type_none,
  34. /* Device is a 2216 channel */
  35. lcs_channel_type_parallel,
  36. /* Device is a 2216 channel */
  37. lcs_channel_type_2216,
  38. /* Device is a OSA2 card */
  39. lcs_channel_type_osa2
  40. };
  41. /**
  42. * CCW commands used in this driver
  43. */
  44. #define LCS_CCW_WRITE 0x01
  45. #define LCS_CCW_READ 0x02
  46. #define LCS_CCW_TRANSFER 0x08
  47. /**
  48. * LCS device status primitives
  49. */
  50. #define LCS_CMD_STARTLAN 0x01
  51. #define LCS_CMD_STOPLAN 0x02
  52. #define LCS_CMD_LANSTAT 0x04
  53. #define LCS_CMD_STARTUP 0x07
  54. #define LCS_CMD_SHUTDOWN 0x08
  55. #define LCS_CMD_QIPASSIST 0xb2
  56. #define LCS_CMD_SETIPM 0xb4
  57. #define LCS_CMD_DELIPM 0xb5
  58. #define LCS_INITIATOR_TCPIP 0x00
  59. #define LCS_INITIATOR_LGW 0x01
  60. #define LCS_STD_CMD_SIZE 16
  61. #define LCS_MULTICAST_CMD_SIZE 404
  62. /**
  63. * LCS IPASSIST MASKS,only used when multicast is switched on
  64. */
  65. /* Not supported by LCS */
  66. #define LCS_IPASS_ARP_PROCESSING 0x0001
  67. #define LCS_IPASS_IN_CHECKSUM_SUPPORT 0x0002
  68. #define LCS_IPASS_OUT_CHECKSUM_SUPPORT 0x0004
  69. #define LCS_IPASS_IP_FRAG_REASSEMBLY 0x0008
  70. #define LCS_IPASS_IP_FILTERING 0x0010
  71. /* Supported by lcs 3172 */
  72. #define LCS_IPASS_IPV6_SUPPORT 0x0020
  73. #define LCS_IPASS_MULTICAST_SUPPORT 0x0040
  74. /**
  75. * LCS sense byte definitions
  76. */
  77. #define LCS_SENSE_BYTE_0 0
  78. #define LCS_SENSE_BYTE_1 1
  79. #define LCS_SENSE_BYTE_2 2
  80. #define LCS_SENSE_BYTE_3 3
  81. #define LCS_SENSE_INTERFACE_DISCONNECT 0x01
  82. #define LCS_SENSE_EQUIPMENT_CHECK 0x10
  83. #define LCS_SENSE_BUS_OUT_CHECK 0x20
  84. #define LCS_SENSE_INTERVENTION_REQUIRED 0x40
  85. #define LCS_SENSE_CMD_REJECT 0x80
  86. #define LCS_SENSE_RESETTING_EVENT 0x80
  87. #define LCS_SENSE_DEVICE_ONLINE 0x20
  88. /**
  89. * LCS packet type definitions
  90. */
  91. #define LCS_FRAME_TYPE_CONTROL 0
  92. #define LCS_FRAME_TYPE_ENET 1
  93. #define LCS_FRAME_TYPE_TR 2
  94. #define LCS_FRAME_TYPE_FDDI 7
  95. #define LCS_FRAME_TYPE_AUTO -1
  96. /**
  97. * some more definitions,we will sort them later
  98. */
  99. #define LCS_ILLEGAL_OFFSET 0xffff
  100. #define LCS_IOBUFFERSIZE 0x5000
  101. #define LCS_NUM_BUFFS 32 /* needs to be power of 2 */
  102. #define LCS_MAC_LENGTH 6
  103. #define LCS_INVALID_PORT_NO -1
  104. #define LCS_LANCMD_TIMEOUT_DEFAULT 5
  105. /**
  106. * Multicast state
  107. */
  108. #define LCS_IPM_STATE_SET_REQUIRED 0
  109. #define LCS_IPM_STATE_DEL_REQUIRED 1
  110. #define LCS_IPM_STATE_ON_CARD 2
  111. /**
  112. * LCS IP Assist declarations
  113. * seems to be only used for multicast
  114. */
  115. #define LCS_IPASS_ARP_PROCESSING 0x0001
  116. #define LCS_IPASS_INBOUND_CSUM_SUPP 0x0002
  117. #define LCS_IPASS_OUTBOUND_CSUM_SUPP 0x0004
  118. #define LCS_IPASS_IP_FRAG_REASSEMBLY 0x0008
  119. #define LCS_IPASS_IP_FILTERING 0x0010
  120. #define LCS_IPASS_IPV6_SUPPORT 0x0020
  121. #define LCS_IPASS_MULTICAST_SUPPORT 0x0040
  122. /**
  123. * LCS Buffer states
  124. */
  125. enum lcs_buffer_states {
  126. LCS_BUF_STATE_EMPTY, /* buffer is empty */
  127. LCS_BUF_STATE_LOCKED, /* buffer is locked, don't touch */
  128. LCS_BUF_STATE_READY, /* buffer is ready for read/write */
  129. LCS_BUF_STATE_PROCESSED,
  130. };
  131. /**
  132. * LCS Channel State Machine declarations
  133. */
  134. enum lcs_channel_states {
  135. LCS_CH_STATE_INIT,
  136. LCS_CH_STATE_HALTED,
  137. LCS_CH_STATE_STOPPED,
  138. LCS_CH_STATE_RUNNING,
  139. LCS_CH_STATE_SUSPENDED,
  140. LCS_CH_STATE_CLEARED,
  141. LCS_CH_STATE_ERROR,
  142. };
  143. /**
  144. * LCS device state machine
  145. */
  146. enum lcs_dev_states {
  147. DEV_STATE_DOWN,
  148. DEV_STATE_UP,
  149. DEV_STATE_RECOVER,
  150. };
  151. enum lcs_threads {
  152. LCS_SET_MC_THREAD = 1,
  153. LCS_RECOVERY_THREAD = 2,
  154. };
  155. /**
  156. * LCS struct declarations
  157. */
  158. struct lcs_header {
  159. __u16 offset;
  160. __u8 type;
  161. __u8 slot;
  162. } __attribute__ ((packed));
  163. struct lcs_ip_mac_pair {
  164. __be32 ip_addr;
  165. __u8 mac_addr[LCS_MAC_LENGTH];
  166. __u8 reserved[2];
  167. } __attribute__ ((packed));
  168. struct lcs_ipm_list {
  169. struct list_head list;
  170. struct lcs_ip_mac_pair ipm;
  171. __u8 ipm_state;
  172. };
  173. struct lcs_cmd {
  174. __u16 offset;
  175. __u8 type;
  176. __u8 slot;
  177. __u8 cmd_code;
  178. __u8 initiator;
  179. __u16 sequence_no;
  180. __u16 return_code;
  181. union {
  182. struct {
  183. __u8 lan_type;
  184. __u8 portno;
  185. __u16 parameter_count;
  186. __u8 operator_flags[3];
  187. __u8 reserved[3];
  188. } lcs_std_cmd;
  189. struct {
  190. __u16 unused1;
  191. __u16 buff_size;
  192. __u8 unused2[6];
  193. } lcs_startup;
  194. struct {
  195. __u8 lan_type;
  196. __u8 portno;
  197. __u8 unused[10];
  198. __u8 mac_addr[LCS_MAC_LENGTH];
  199. __u32 num_packets_deblocked;
  200. __u32 num_packets_blocked;
  201. __u32 num_packets_tx_on_lan;
  202. __u32 num_tx_errors_detected;
  203. __u32 num_tx_packets_disgarded;
  204. __u32 num_packets_rx_from_lan;
  205. __u32 num_rx_errors_detected;
  206. __u32 num_rx_discarded_nobuffs_avail;
  207. __u32 num_rx_packets_too_large;
  208. } lcs_lanstat_cmd;
  209. #ifdef CONFIG_IP_MULTICAST
  210. struct {
  211. __u8 lan_type;
  212. __u8 portno;
  213. __u16 num_ip_pairs;
  214. __u16 ip_assists_supported;
  215. __u16 ip_assists_enabled;
  216. __u16 version;
  217. struct {
  218. struct lcs_ip_mac_pair
  219. ip_mac_pair[32];
  220. __u32 response_data;
  221. } lcs_ipass_ctlmsg __attribute ((packed));
  222. } lcs_qipassist __attribute__ ((packed));
  223. #endif /*CONFIG_IP_MULTICAST */
  224. } cmd __attribute__ ((packed));
  225. } __attribute__ ((packed));
  226. /**
  227. * Forward declarations.
  228. */
  229. struct lcs_card;
  230. struct lcs_channel;
  231. /**
  232. * Definition of an lcs buffer.
  233. */
  234. struct lcs_buffer {
  235. enum lcs_buffer_states state;
  236. void *data;
  237. int count;
  238. /* Callback for completion notification. */
  239. void (*callback)(struct lcs_channel *, struct lcs_buffer *);
  240. };
  241. struct lcs_reply {
  242. struct list_head list;
  243. __u16 sequence_no;
  244. atomic_t refcnt;
  245. /* Callback for completion notification. */
  246. void (*callback)(struct lcs_card *, struct lcs_cmd *);
  247. wait_queue_head_t wait_q;
  248. struct lcs_card *card;
  249. int received;
  250. int rc;
  251. };
  252. /**
  253. * Definition of an lcs channel
  254. */
  255. struct lcs_channel {
  256. enum lcs_channel_states state;
  257. struct ccw_device *ccwdev;
  258. struct ccw1 ccws[LCS_NUM_BUFFS + 1];
  259. wait_queue_head_t wait_q;
  260. struct tasklet_struct irq_tasklet;
  261. struct lcs_buffer iob[LCS_NUM_BUFFS];
  262. int io_idx;
  263. int buf_idx;
  264. };
  265. /**
  266. * definition of the lcs card
  267. */
  268. struct lcs_card {
  269. spinlock_t lock;
  270. spinlock_t ipm_lock;
  271. enum lcs_dev_states state;
  272. struct net_device *dev;
  273. struct net_device_stats stats;
  274. __be16 (*lan_type_trans)(struct sk_buff *skb,
  275. struct net_device *dev);
  276. struct ccwgroup_device *gdev;
  277. struct lcs_channel read;
  278. struct lcs_channel write;
  279. struct lcs_buffer *tx_buffer;
  280. int tx_emitted;
  281. struct list_head lancmd_waiters;
  282. int lancmd_timeout;
  283. struct work_struct kernel_thread_starter;
  284. spinlock_t mask_lock;
  285. unsigned long thread_start_mask;
  286. unsigned long thread_running_mask;
  287. unsigned long thread_allowed_mask;
  288. wait_queue_head_t wait_q;
  289. #ifdef CONFIG_IP_MULTICAST
  290. struct list_head ipm_list;
  291. #endif
  292. __u8 mac[LCS_MAC_LENGTH];
  293. __u16 ip_assists_supported;
  294. __u16 ip_assists_enabled;
  295. __s8 lan_type;
  296. __u32 pkt_seq;
  297. __u16 sequence_no;
  298. __s16 portno;
  299. /* Some info copied from probeinfo */
  300. u8 device_forced;
  301. u8 max_port_no;
  302. u8 hint_port_no;
  303. s16 port_protocol_no;
  304. } __attribute__ ((aligned(8)));