Linux Audio

Check our new training course

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