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