lcs.h 7.3 KB

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