lcs.h 7.1 KB

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