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 VERSION_LCS_H "$Revision: 1.18 $"
11 #define LCS_DBF_TEXT(level, name, text) \
13 debug_text_event(lcs_dbf_##name, level, text); \
16 #define LCS_DBF_HEX(level,name,addr,len) \
18 debug_event(lcs_dbf_##name,level,(void*)(addr),len); \
21 #define LCS_DBF_TEXT_(level,name,text...) \
23 sprintf(debug_buffer, text); \
24 debug_text_event(lcs_dbf_##name,level, debug_buffer);\
28 * some more definitions for debug or output stuff
30 #define PRINTK_HEADER " lcs: "
35 #define CARD_FROM_DEV(cdev) \
37 ((struct ccwgroup_device *)cdev->dev.driver_data)->dev.driver_data;
39 * CCW commands used in this driver
41 #define LCS_CCW_WRITE 0x01
42 #define LCS_CCW_READ 0x02
43 #define LCS_CCW_TRANSFER 0x08
46 * LCS device status primitives
48 #define LCS_CMD_STARTLAN 0x01
49 #define LCS_CMD_STOPLAN 0x02
50 #define LCS_CMD_LANSTAT 0x04
51 #define LCS_CMD_STARTUP 0x07
52 #define LCS_CMD_SHUTDOWN 0x08
53 #define LCS_CMD_QIPASSIST 0xb2
54 #define LCS_CMD_SETIPM 0xb4
55 #define LCS_CMD_DELIPM 0xb5
57 #define LCS_INITIATOR_TCPIP 0x00
58 #define LCS_INITIATOR_LGW 0x01
59 #define LCS_STD_CMD_SIZE 16
60 #define LCS_MULTICAST_CMD_SIZE 404
63 * LCS IPASSIST MASKS,only used when multicast is switched on
65 /* Not supported by LCS */
66 #define LCS_IPASS_ARP_PROCESSING 0x0001
67 #define LCS_IPASS_IN_CHECKSUM_SUPPORT 0x0002
68 #define LCS_IPASS_OUT_CHECKSUM_SUPPORT 0x0004
69 #define LCS_IPASS_IP_FRAG_REASSEMBLY 0x0008
70 #define LCS_IPASS_IP_FILTERING 0x0010
71 /* Supported by lcs 3172 */
72 #define LCS_IPASS_IPV6_SUPPORT 0x0020
73 #define LCS_IPASS_MULTICAST_SUPPORT 0x0040
76 * LCS sense byte definitions
78 #define LCS_SENSE_INTERFACE_DISCONNECT 0x01
79 #define LCS_SENSE_EQUIPMENT_CHECK 0x10
80 #define LCS_SENSE_BUS_OUT_CHECK 0x20
81 #define LCS_SENSE_INTERVENTION_REQUIRED 0x40
82 #define LCS_SENSE_CMD_REJECT 0x80
83 #define LCS_SENSE_RESETTING_EVENT 0x0080
84 #define LCS_SENSE_DEVICE_ONLINE 0x0020
87 * LCS packet type definitions
89 #define LCS_FRAME_TYPE_CONTROL 0
90 #define LCS_FRAME_TYPE_ENET 1
91 #define LCS_FRAME_TYPE_TR 2
92 #define LCS_FRAME_TYPE_FDDI 7
93 #define LCS_FRAME_TYPE_AUTO -1
96 * some more definitions,we will sort them later
98 #define LCS_ILLEGAL_OFFSET 0xffff
99 #define LCS_IOBUFFERSIZE 0x5000
100 #define LCS_NUM_BUFFS 8 /* needs to be power of 2 */
101 #define LCS_MAC_LENGTH 6
102 #define LCS_INVALID_PORT_NO -1
103 #define LCS_LANCMD_TIMEOUT_DEFAULT 5
108 #define LCS_IPM_STATE_SET_REQUIRED 0
109 #define LCS_IPM_STATE_DEL_REQUIRED 1
110 #define LCS_IPM_STATE_ON_CARD 2
113 * LCS IP Assist declarations
114 * seems to be only used for multicast
116 #define LCS_IPASS_ARP_PROCESSING 0x0001
117 #define LCS_IPASS_INBOUND_CSUM_SUPP 0x0002
118 #define LCS_IPASS_OUTBOUND_CSUM_SUPP 0x0004
119 #define LCS_IPASS_IP_FRAG_REASSEMBLY 0x0008
120 #define LCS_IPASS_IP_FILTERING 0x0010
121 #define LCS_IPASS_IPV6_SUPPORT 0x0020
122 #define LCS_IPASS_MULTICAST_SUPPORT 0x0040
127 enum lcs_buffer_states
{
128 BUF_STATE_EMPTY
, /* buffer is empty */
129 BUF_STATE_LOCKED
, /* buffer is locked, don't touch */
130 BUF_STATE_READY
, /* buffer is ready for read/write */
135 * LCS Channel State Machine declarations
137 enum lcs_channel_states
{
147 * LCS device state machine
149 enum lcs_dev_states
{
156 LCS_SET_MC_THREAD
= 1,
157 LCS_STARTLAN_THREAD
= 2,
158 LCS_STOPLAN_THREAD
= 4,
159 LCS_STARTUP_THREAD
= 8,
162 * LCS struct declarations
168 } __attribute__ ((packed
));
170 struct lcs_ip_mac_pair
{
172 __u8 mac_addr
[LCS_MAC_LENGTH
];
174 } __attribute__ ((packed
));
176 struct lcs_ipm_list
{
177 struct list_head list
;
178 struct lcs_ip_mac_pair ipm
;
194 __u16 parameter_count
;
195 __u8 operator_flags
[3];
207 __u8 mac_addr
[LCS_MAC_LENGTH
];
208 __u32 num_packets_deblocked
;
209 __u32 num_packets_blocked
;
210 __u32 num_packets_tx_on_lan
;
211 __u32 num_tx_errors_detected
;
212 __u32 num_tx_packets_disgarded
;
213 __u32 num_packets_rx_from_lan
;
214 __u32 num_rx_errors_detected
;
215 __u32 num_rx_discarded_nobuffs_avail
;
216 __u32 num_rx_packets_too_large
;
218 #ifdef CONFIG_IP_MULTICAST
223 __u16 ip_assists_supported
;
224 __u16 ip_assists_enabled
;
227 struct lcs_ip_mac_pair
230 } lcs_ipass_ctlmsg
__attribute ((packed
));
231 } lcs_qipassist
__attribute__ ((packed
));
232 #endif /*CONFIG_IP_MULTICAST */
233 } cmd
__attribute__ ((packed
));
234 } __attribute__ ((packed
));
237 * Forward declarations.
243 * Definition of an lcs buffer.
246 enum lcs_buffer_states state
;
249 /* Callback for completion notification. */
250 void (*callback
)(struct lcs_channel
*, struct lcs_buffer
*);
254 struct list_head list
;
257 /* Callback for completion notification. */
258 void (*callback
)(struct lcs_card
*, struct lcs_cmd
*);
259 wait_queue_head_t wait_q
;
260 struct lcs_card
*card
;
266 * Definition of an lcs channel
269 enum lcs_channel_states state
;
270 struct ccw_device
*ccwdev
;
271 struct ccw1 ccws
[LCS_NUM_BUFFS
+ 1];
272 wait_queue_head_t wait_q
;
273 struct tasklet_struct irq_tasklet
;
274 struct lcs_buffer iob
[LCS_NUM_BUFFS
];
281 * definition of the lcs card
286 enum lcs_dev_states state
;
287 struct net_device
*dev
;
288 struct net_device_stats stats
;
289 unsigned short (*lan_type_trans
)(struct sk_buff
*skb
,
290 struct net_device
*dev
);
291 struct lcs_channel read
;
292 struct lcs_channel write
;
293 struct lcs_buffer
*tx_buffer
;
295 struct list_head lancmd_waiters
;
298 struct work_struct kernel_thread_starter
;
299 spinlock_t mask_lock
;
300 unsigned long thread_start_mask
;
301 unsigned long thread_running_mask
;
302 unsigned long thread_allowed_mask
;
303 wait_queue_head_t wait_q
;
305 #ifdef CONFIG_IP_MULTICAST
306 struct list_head ipm_list
;
308 __u8 mac
[LCS_MAC_LENGTH
];
309 __u16 ip_assists_supported
;
310 __u16 ip_assists_enabled
;
314 /* Some info copied from probeinfo */
318 s16 port_protocol_no
;
319 } __attribute__ ((aligned(8)));