3 #include <linux/interrupt.h>
4 #include <linux/netdevice.h>
5 #include <linux/skbuff.h>
6 #include <linux/workqueue.h>
7 #include <asm/ccwdev.h>
9 #define LCS_DBF_TEXT(level, name, text) \
11 debug_text_event(lcs_dbf_##name, level, text); \
14 #define LCS_DBF_HEX(level,name,addr,len) \
16 debug_event(lcs_dbf_##name,level,(void*)(addr),len); \
19 #define LCS_DBF_TEXT_(level,name,text...) \
21 sprintf(debug_buffer, text); \
22 debug_text_event(lcs_dbf_##name,level, debug_buffer);\
26 * some more definitions for debug or output stuff
28 #define PRINTK_HEADER " lcs: "
33 #define CARD_FROM_DEV(cdev) \
35 ((struct ccwgroup_device *)cdev->dev.driver_data)->dev.driver_data;
37 * CCW commands used in this driver
39 #define LCS_CCW_WRITE 0x01
40 #define LCS_CCW_READ 0x02
41 #define LCS_CCW_TRANSFER 0x08
44 * LCS device status primitives
46 #define LCS_CMD_STARTLAN 0x01
47 #define LCS_CMD_STOPLAN 0x02
48 #define LCS_CMD_LANSTAT 0x04
49 #define LCS_CMD_STARTUP 0x07
50 #define LCS_CMD_SHUTDOWN 0x08
51 #define LCS_CMD_QIPASSIST 0xb2
52 #define LCS_CMD_SETIPM 0xb4
53 #define LCS_CMD_DELIPM 0xb5
55 #define LCS_INITIATOR_TCPIP 0x00
56 #define LCS_INITIATOR_LGW 0x01
57 #define LCS_STD_CMD_SIZE 16
58 #define LCS_MULTICAST_CMD_SIZE 404
61 * LCS IPASSIST MASKS,only used when multicast is switched on
63 /* Not supported by LCS */
64 #define LCS_IPASS_ARP_PROCESSING 0x0001
65 #define LCS_IPASS_IN_CHECKSUM_SUPPORT 0x0002
66 #define LCS_IPASS_OUT_CHECKSUM_SUPPORT 0x0004
67 #define LCS_IPASS_IP_FRAG_REASSEMBLY 0x0008
68 #define LCS_IPASS_IP_FILTERING 0x0010
69 /* Supported by lcs 3172 */
70 #define LCS_IPASS_IPV6_SUPPORT 0x0020
71 #define LCS_IPASS_MULTICAST_SUPPORT 0x0040
74 * LCS sense byte definitions
76 #define LCS_SENSE_BYTE_0 0
77 #define LCS_SENSE_BYTE_1 1
78 #define LCS_SENSE_BYTE_2 2
79 #define LCS_SENSE_BYTE_3 3
80 #define LCS_SENSE_INTERFACE_DISCONNECT 0x01
81 #define LCS_SENSE_EQUIPMENT_CHECK 0x10
82 #define LCS_SENSE_BUS_OUT_CHECK 0x20
83 #define LCS_SENSE_INTERVENTION_REQUIRED 0x40
84 #define LCS_SENSE_CMD_REJECT 0x80
85 #define LCS_SENSE_RESETTING_EVENT 0x80
86 #define LCS_SENSE_DEVICE_ONLINE 0x20
89 * LCS packet type definitions
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
98 * some more definitions,we will sort them later
100 #define LCS_ILLEGAL_OFFSET 0xffff
101 #define LCS_IOBUFFERSIZE 0x5000
102 #define LCS_NUM_BUFFS 32 /* needs to be power of 2 */
103 #define LCS_MAC_LENGTH 6
104 #define LCS_INVALID_PORT_NO -1
105 #define LCS_LANCMD_TIMEOUT_DEFAULT 5
110 #define LCS_IPM_STATE_SET_REQUIRED 0
111 #define LCS_IPM_STATE_DEL_REQUIRED 1
112 #define LCS_IPM_STATE_ON_CARD 2
115 * LCS IP Assist declarations
116 * seems to be only used for multicast
118 #define LCS_IPASS_ARP_PROCESSING 0x0001
119 #define LCS_IPASS_INBOUND_CSUM_SUPP 0x0002
120 #define LCS_IPASS_OUTBOUND_CSUM_SUPP 0x0004
121 #define LCS_IPASS_IP_FRAG_REASSEMBLY 0x0008
122 #define LCS_IPASS_IP_FILTERING 0x0010
123 #define LCS_IPASS_IPV6_SUPPORT 0x0020
124 #define LCS_IPASS_MULTICAST_SUPPORT 0x0040
129 enum lcs_buffer_states {
130 BUF_STATE_EMPTY, /* buffer is empty */
131 BUF_STATE_LOCKED, /* buffer is locked, don't touch */
132 BUF_STATE_READY, /* buffer is ready for read/write */
137 * LCS Channel State Machine declarations
139 enum lcs_channel_states {
149 * LCS device state machine
151 enum lcs_dev_states {
158 LCS_SET_MC_THREAD = 1,
159 LCS_RECOVERY_THREAD = 2,
163 * LCS struct declarations
169 } __attribute__ ((packed));
171 struct lcs_ip_mac_pair {
173 __u8 mac_addr[LCS_MAC_LENGTH];
175 } __attribute__ ((packed));
177 struct lcs_ipm_list {
178 struct list_head list;
179 struct lcs_ip_mac_pair ipm;
195 __u16 parameter_count;
196 __u8 operator_flags[3];
208 __u8 mac_addr[LCS_MAC_LENGTH];
209 __u32 num_packets_deblocked;
210 __u32 num_packets_blocked;
211 __u32 num_packets_tx_on_lan;
212 __u32 num_tx_errors_detected;
213 __u32 num_tx_packets_disgarded;
214 __u32 num_packets_rx_from_lan;
215 __u32 num_rx_errors_detected;
216 __u32 num_rx_discarded_nobuffs_avail;
217 __u32 num_rx_packets_too_large;
219 #ifdef CONFIG_IP_MULTICAST
224 __u16 ip_assists_supported;
225 __u16 ip_assists_enabled;
228 struct lcs_ip_mac_pair
231 } lcs_ipass_ctlmsg __attribute ((packed));
232 } lcs_qipassist __attribute__ ((packed));
233 #endif /*CONFIG_IP_MULTICAST */
234 } cmd __attribute__ ((packed));
235 } __attribute__ ((packed));
238 * Forward declarations.
244 * Definition of an lcs buffer.
247 enum lcs_buffer_states state;
250 /* Callback for completion notification. */
251 void (*callback)(struct lcs_channel *, struct lcs_buffer *);
255 struct list_head list;
258 /* Callback for completion notification. */
259 void (*callback)(struct lcs_card *, struct lcs_cmd *);
260 wait_queue_head_t wait_q;
261 struct lcs_card *card;
267 * Definition of an lcs channel
270 enum lcs_channel_states state;
271 struct ccw_device *ccwdev;
272 struct ccw1 ccws[LCS_NUM_BUFFS + 1];
273 wait_queue_head_t wait_q;
274 struct tasklet_struct irq_tasklet;
275 struct lcs_buffer iob[LCS_NUM_BUFFS];
282 * definition of the lcs card
287 enum lcs_dev_states state;
288 struct net_device *dev;
289 struct net_device_stats stats;
290 unsigned short (*lan_type_trans)(struct sk_buff *skb,
291 struct net_device *dev);
292 struct ccwgroup_device *gdev;
293 struct lcs_channel read;
294 struct lcs_channel write;
295 struct lcs_buffer *tx_buffer;
297 struct list_head lancmd_waiters;
300 struct work_struct kernel_thread_starter;
301 spinlock_t mask_lock;
302 unsigned long thread_start_mask;
303 unsigned long thread_running_mask;
304 unsigned long thread_allowed_mask;
305 wait_queue_head_t wait_q;
307 #ifdef CONFIG_IP_MULTICAST
308 struct list_head ipm_list;
310 __u8 mac[LCS_MAC_LENGTH];
311 __u16 ip_assists_supported;
312 __u16 ip_assists_enabled;
317 /* Some info copied from probeinfo */
321 s16 port_protocol_no;
322 } __attribute__ ((aligned(8)));