lcs.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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_INTERFACE_DISCONNECT 0x01
  67. #define LCS_SENSE_EQUIPMENT_CHECK 0x10
  68. #define LCS_SENSE_BUS_OUT_CHECK 0x20
  69. #define LCS_SENSE_INTERVENTION_REQUIRED 0x40
  70. #define LCS_SENSE_CMD_REJECT 0x80
  71. #define LCS_SENSE_RESETTING_EVENT 0x0080
  72. #define LCS_SENSE_DEVICE_ONLINE 0x0020
  73. /**
  74. * LCS packet type definitions
  75. */
  76. #define LCS_FRAME_TYPE_CONTROL 0
  77. #define LCS_FRAME_TYPE_ENET 1
  78. #define LCS_FRAME_TYPE_TR 2
  79. #define LCS_FRAME_TYPE_FDDI 7
  80. #define LCS_FRAME_TYPE_AUTO -1
  81. /**
  82. * some more definitions,we will sort them later
  83. */
  84. #define LCS_ILLEGAL_OFFSET 0xffff
  85. #define LCS_IOBUFFERSIZE 0x5000
  86. #define LCS_NUM_BUFFS 32 /* needs to be power of 2 */
  87. #define LCS_MAC_LENGTH 6
  88. #define LCS_INVALID_PORT_NO -1
  89. #define LCS_LANCMD_TIMEOUT_DEFAULT 5
  90. /**
  91. * Multicast state
  92. */
  93. #define LCS_IPM_STATE_SET_REQUIRED 0
  94. #define LCS_IPM_STATE_DEL_REQUIRED 1
  95. #define LCS_IPM_STATE_ON_CARD 2
  96. /**
  97. * LCS IP Assist declarations
  98. * seems to be only used for multicast
  99. */
  100. #define LCS_IPASS_ARP_PROCESSING 0x0001
  101. #define LCS_IPASS_INBOUND_CSUM_SUPP 0x0002
  102. #define LCS_IPASS_OUTBOUND_CSUM_SUPP 0x0004
  103. #define LCS_IPASS_IP_FRAG_REASSEMBLY 0x0008
  104. #define LCS_IPASS_IP_FILTERING 0x0010
  105. #define LCS_IPASS_IPV6_SUPPORT 0x0020
  106. #define LCS_IPASS_MULTICAST_SUPPORT 0x0040
  107. /**
  108. * LCS Buffer states
  109. */
  110. enum lcs_buffer_states {
  111. BUF_STATE_EMPTY, /* buffer is empty */
  112. BUF_STATE_LOCKED, /* buffer is locked, don't touch */
  113. BUF_STATE_READY, /* buffer is ready for read/write */
  114. BUF_STATE_PROCESSED,
  115. };
  116. /**
  117. * LCS Channel State Machine declarations
  118. */
  119. enum lcs_channel_states {
  120. CH_STATE_INIT,
  121. CH_STATE_HALTED,
  122. CH_STATE_STOPPED,
  123. CH_STATE_RUNNING,
  124. CH_STATE_SUSPENDED,
  125. CH_STATE_CLEARED,
  126. };
  127. /**
  128. * LCS device state machine
  129. */
  130. enum lcs_dev_states {
  131. DEV_STATE_DOWN,
  132. DEV_STATE_UP,
  133. DEV_STATE_RECOVER,
  134. };
  135. enum lcs_threads {
  136. LCS_SET_MC_THREAD = 1,
  137. LCS_STARTLAN_THREAD = 2,
  138. LCS_STOPLAN_THREAD = 4,
  139. LCS_STARTUP_THREAD = 8,
  140. };
  141. /**
  142. * LCS struct declarations
  143. */
  144. struct lcs_header {
  145. __u16 offset;
  146. __u8 type;
  147. __u8 slot;
  148. } __attribute__ ((packed));
  149. struct lcs_ip_mac_pair {
  150. __u32 ip_addr;
  151. __u8 mac_addr[LCS_MAC_LENGTH];
  152. __u8 reserved[2];
  153. } __attribute__ ((packed));
  154. struct lcs_ipm_list {
  155. struct list_head list;
  156. struct lcs_ip_mac_pair ipm;
  157. __u8 ipm_state;
  158. };
  159. struct lcs_cmd {
  160. __u16 offset;
  161. __u8 type;
  162. __u8 slot;
  163. __u8 cmd_code;
  164. __u8 initiator;
  165. __u16 sequence_no;
  166. __u16 return_code;
  167. union {
  168. struct {
  169. __u8 lan_type;
  170. __u8 portno;
  171. __u16 parameter_count;
  172. __u8 operator_flags[3];
  173. __u8 reserved[3];
  174. } lcs_std_cmd;
  175. struct {
  176. __u16 unused1;
  177. __u16 buff_size;
  178. __u8 unused2[6];
  179. } lcs_startup;
  180. struct {
  181. __u8 lan_type;
  182. __u8 portno;
  183. __u8 unused[10];
  184. __u8 mac_addr[LCS_MAC_LENGTH];
  185. __u32 num_packets_deblocked;
  186. __u32 num_packets_blocked;
  187. __u32 num_packets_tx_on_lan;
  188. __u32 num_tx_errors_detected;
  189. __u32 num_tx_packets_disgarded;
  190. __u32 num_packets_rx_from_lan;
  191. __u32 num_rx_errors_detected;
  192. __u32 num_rx_discarded_nobuffs_avail;
  193. __u32 num_rx_packets_too_large;
  194. } lcs_lanstat_cmd;
  195. #ifdef CONFIG_IP_MULTICAST
  196. struct {
  197. __u8 lan_type;
  198. __u8 portno;
  199. __u16 num_ip_pairs;
  200. __u16 ip_assists_supported;
  201. __u16 ip_assists_enabled;
  202. __u16 version;
  203. struct {
  204. struct lcs_ip_mac_pair
  205. ip_mac_pair[32];
  206. __u32 response_data;
  207. } lcs_ipass_ctlmsg __attribute ((packed));
  208. } lcs_qipassist __attribute__ ((packed));
  209. #endif /*CONFIG_IP_MULTICAST */
  210. } cmd __attribute__ ((packed));
  211. } __attribute__ ((packed));
  212. /**
  213. * Forward declarations.
  214. */
  215. struct lcs_card;
  216. struct lcs_channel;
  217. /**
  218. * Definition of an lcs buffer.
  219. */
  220. struct lcs_buffer {
  221. enum lcs_buffer_states state;
  222. void *data;
  223. int count;
  224. /* Callback for completion notification. */
  225. void (*callback)(struct lcs_channel *, struct lcs_buffer *);
  226. };
  227. struct lcs_reply {
  228. struct list_head list;
  229. __u16 sequence_no;
  230. atomic_t refcnt;
  231. /* Callback for completion notification. */
  232. void (*callback)(struct lcs_card *, struct lcs_cmd *);
  233. wait_queue_head_t wait_q;
  234. struct lcs_card *card;
  235. int received;
  236. int rc;
  237. };
  238. /**
  239. * Definition of an lcs channel
  240. */
  241. struct lcs_channel {
  242. enum lcs_channel_states state;
  243. struct ccw_device *ccwdev;
  244. struct ccw1 ccws[LCS_NUM_BUFFS + 1];
  245. wait_queue_head_t wait_q;
  246. struct tasklet_struct irq_tasklet;
  247. struct lcs_buffer iob[LCS_NUM_BUFFS];
  248. int io_idx;
  249. int buf_idx;
  250. };
  251. /**
  252. * definition of the lcs card
  253. */
  254. struct lcs_card {
  255. spinlock_t lock;
  256. spinlock_t ipm_lock;
  257. enum lcs_dev_states state;
  258. struct net_device *dev;
  259. struct net_device_stats stats;
  260. unsigned short (*lan_type_trans)(struct sk_buff *skb,
  261. struct net_device *dev);
  262. struct lcs_channel read;
  263. struct lcs_channel write;
  264. struct lcs_buffer *tx_buffer;
  265. int tx_emitted;
  266. struct list_head lancmd_waiters;
  267. int lancmd_timeout;
  268. struct work_struct kernel_thread_starter;
  269. spinlock_t mask_lock;
  270. unsigned long thread_start_mask;
  271. unsigned long thread_running_mask;
  272. unsigned long thread_allowed_mask;
  273. wait_queue_head_t wait_q;
  274. #ifdef CONFIG_IP_MULTICAST
  275. struct list_head ipm_list;
  276. #endif
  277. __u8 mac[LCS_MAC_LENGTH];
  278. __u16 ip_assists_supported;
  279. __u16 ip_assists_enabled;
  280. __s8 lan_type;
  281. __u32 pkt_seq;
  282. __u16 sequence_no;
  283. __s16 portno;
  284. /* Some info copied from probeinfo */
  285. u8 device_forced;
  286. u8 max_port_no;
  287. u8 hint_port_no;
  288. s16 port_protocol_no;
  289. } __attribute__ ((aligned(8)));