1 /* SPDX-License-Identifier: GPL-2.0 */
4 #include <linux/interrupt.h>
5 #include <linux/netdevice.h>
6 #include <linux/skbuff.h>
7 #include <linux/workqueue.h>
8 #include <linux/refcount.h>
9 #include <asm/ccwdev.h>
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 if (debug_level_enabled(lcs_dbf_##name, level)) { \
24 sprintf(debug_buffer, text); \
25 debug_text_event(lcs_dbf_##name, level, debug_buffer); \
32 #define CARD_FROM_DEV(cdev) \
33 (struct lcs_card *) dev_get_drvdata( \
34 &((struct ccwgroup_device *)dev_get_drvdata(&cdev->dev))->dev);
37 * Enum for classifying detected devices.
39 enum lcs_channel_types
{
40 /* Device is not a channel */
41 lcs_channel_type_none
,
43 /* Device is a 2216 channel */
44 lcs_channel_type_parallel
,
46 /* Device is a 2216 channel */
47 lcs_channel_type_2216
,
49 /* Device is a OSA2 card */
54 * CCW commands used in this driver
56 #define LCS_CCW_WRITE 0x01
57 #define LCS_CCW_READ 0x02
58 #define LCS_CCW_TRANSFER 0x08
61 * LCS device status primitives
63 #define LCS_CMD_STARTLAN 0x01
64 #define LCS_CMD_STOPLAN 0x02
65 #define LCS_CMD_LANSTAT 0x04
66 #define LCS_CMD_STARTUP 0x07
67 #define LCS_CMD_SHUTDOWN 0x08
68 #define LCS_CMD_QIPASSIST 0xb2
69 #define LCS_CMD_SETIPM 0xb4
70 #define LCS_CMD_DELIPM 0xb5
72 #define LCS_INITIATOR_TCPIP 0x00
73 #define LCS_INITIATOR_LGW 0x01
74 #define LCS_STD_CMD_SIZE 16
75 #define LCS_MULTICAST_CMD_SIZE 404
78 * LCS IPASSIST MASKS,only used when multicast is switched on
80 /* Not supported by LCS */
81 #define LCS_IPASS_ARP_PROCESSING 0x0001
82 #define LCS_IPASS_IN_CHECKSUM_SUPPORT 0x0002
83 #define LCS_IPASS_OUT_CHECKSUM_SUPPORT 0x0004
84 #define LCS_IPASS_IP_FRAG_REASSEMBLY 0x0008
85 #define LCS_IPASS_IP_FILTERING 0x0010
86 /* Supported by lcs 3172 */
87 #define LCS_IPASS_IPV6_SUPPORT 0x0020
88 #define LCS_IPASS_MULTICAST_SUPPORT 0x0040
91 * LCS sense byte definitions
93 #define LCS_SENSE_BYTE_0 0
94 #define LCS_SENSE_BYTE_1 1
95 #define LCS_SENSE_BYTE_2 2
96 #define LCS_SENSE_BYTE_3 3
97 #define LCS_SENSE_INTERFACE_DISCONNECT 0x01
98 #define LCS_SENSE_EQUIPMENT_CHECK 0x10
99 #define LCS_SENSE_BUS_OUT_CHECK 0x20
100 #define LCS_SENSE_INTERVENTION_REQUIRED 0x40
101 #define LCS_SENSE_CMD_REJECT 0x80
102 #define LCS_SENSE_RESETTING_EVENT 0x80
103 #define LCS_SENSE_DEVICE_ONLINE 0x20
106 * LCS packet type definitions
108 #define LCS_FRAME_TYPE_CONTROL 0
109 #define LCS_FRAME_TYPE_ENET 1
110 #define LCS_FRAME_TYPE_TR 2
111 #define LCS_FRAME_TYPE_FDDI 7
112 #define LCS_FRAME_TYPE_AUTO -1
115 * some more definitions,we will sort them later
117 #define LCS_ILLEGAL_OFFSET 0xffff
118 #define LCS_IOBUFFERSIZE 0x5000
119 #define LCS_NUM_BUFFS 32 /* needs to be power of 2 */
120 #define LCS_MAC_LENGTH 6
121 #define LCS_INVALID_PORT_NO -1
122 #define LCS_LANCMD_TIMEOUT_DEFAULT 5
127 #define LCS_IPM_STATE_SET_REQUIRED 0
128 #define LCS_IPM_STATE_DEL_REQUIRED 1
129 #define LCS_IPM_STATE_ON_CARD 2
132 * LCS IP Assist declarations
133 * seems to be only used for multicast
135 #define LCS_IPASS_ARP_PROCESSING 0x0001
136 #define LCS_IPASS_INBOUND_CSUM_SUPP 0x0002
137 #define LCS_IPASS_OUTBOUND_CSUM_SUPP 0x0004
138 #define LCS_IPASS_IP_FRAG_REASSEMBLY 0x0008
139 #define LCS_IPASS_IP_FILTERING 0x0010
140 #define LCS_IPASS_IPV6_SUPPORT 0x0020
141 #define LCS_IPASS_MULTICAST_SUPPORT 0x0040
146 enum lcs_buffer_states
{
147 LCS_BUF_STATE_EMPTY
, /* buffer is empty */
148 LCS_BUF_STATE_LOCKED
, /* buffer is locked, don't touch */
149 LCS_BUF_STATE_READY
, /* buffer is ready for read/write */
150 LCS_BUF_STATE_PROCESSED
,
154 * LCS Channel State Machine declarations
156 enum lcs_channel_states
{
159 LCS_CH_STATE_STOPPED
,
160 LCS_CH_STATE_RUNNING
,
161 LCS_CH_STATE_SUSPENDED
,
162 LCS_CH_STATE_CLEARED
,
167 * LCS device state machine
169 enum lcs_dev_states
{
176 LCS_SET_MC_THREAD
= 1,
177 LCS_RECOVERY_THREAD
= 2,
181 * LCS struct declarations
187 } __attribute__ ((packed
));
189 struct lcs_ip_mac_pair
{
191 __u8 mac_addr
[LCS_MAC_LENGTH
];
193 } __attribute__ ((packed
));
195 struct lcs_ipm_list
{
196 struct list_head list
;
197 struct lcs_ip_mac_pair ipm
;
213 __u16 parameter_count
;
214 __u8 operator_flags
[3];
226 __u8 mac_addr
[LCS_MAC_LENGTH
];
227 __u32 num_packets_deblocked
;
228 __u32 num_packets_blocked
;
229 __u32 num_packets_tx_on_lan
;
230 __u32 num_tx_errors_detected
;
231 __u32 num_tx_packets_disgarded
;
232 __u32 num_packets_rx_from_lan
;
233 __u32 num_rx_errors_detected
;
234 __u32 num_rx_discarded_nobuffs_avail
;
235 __u32 num_rx_packets_too_large
;
237 #ifdef CONFIG_IP_MULTICAST
242 __u16 ip_assists_supported
;
243 __u16 ip_assists_enabled
;
246 struct lcs_ip_mac_pair
249 } lcs_ipass_ctlmsg
__attribute ((packed
));
250 } lcs_qipassist
__attribute__ ((packed
));
251 #endif /*CONFIG_IP_MULTICAST */
252 } cmd
__attribute__ ((packed
));
253 } __attribute__ ((packed
));
256 * Forward declarations.
262 * Definition of an lcs buffer.
265 enum lcs_buffer_states state
;
268 /* Callback for completion notification. */
269 void (*callback
)(struct lcs_channel
*, struct lcs_buffer
*);
273 struct list_head list
;
276 /* Callback for completion notification. */
277 void (*callback
)(struct lcs_card
*, struct lcs_cmd
*);
278 wait_queue_head_t wait_q
;
279 struct lcs_card
*card
;
280 struct timer_list timer
;
286 * Definition of an lcs channel
289 enum lcs_channel_states state
;
290 struct ccw_device
*ccwdev
;
291 struct ccw1 ccws
[LCS_NUM_BUFFS
+ 1];
292 wait_queue_head_t wait_q
;
293 struct tasklet_struct irq_tasklet
;
294 struct lcs_buffer iob
[LCS_NUM_BUFFS
];
301 * definition of the lcs card
306 enum lcs_dev_states state
;
307 struct net_device
*dev
;
308 struct net_device_stats stats
;
309 __be16 (*lan_type_trans
)(struct sk_buff
*skb
,
310 struct net_device
*dev
);
311 struct ccwgroup_device
*gdev
;
312 struct lcs_channel read
;
313 struct lcs_channel write
;
314 struct lcs_buffer
*tx_buffer
;
316 struct list_head lancmd_waiters
;
319 struct work_struct kernel_thread_starter
;
320 spinlock_t mask_lock
;
321 unsigned long thread_start_mask
;
322 unsigned long thread_running_mask
;
323 unsigned long thread_allowed_mask
;
324 wait_queue_head_t wait_q
;
326 #ifdef CONFIG_IP_MULTICAST
327 struct list_head ipm_list
;
329 __u8 mac
[LCS_MAC_LENGTH
];
330 __u16 ip_assists_supported
;
331 __u16 ip_assists_enabled
;
336 /* Some info copied from probeinfo */
340 s16 port_protocol_no
;
341 } __attribute__ ((aligned(8)));