summaryrefslogtreecommitdiffstats
path: root/drivers/net/hamradio/6pack.h
blob: ac4ad00521125e654571c6ba6ecd3b0512aa2ae4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 * 6pack.h	Define the 6pack device driver interface and constants.
 *
 * Version:	@(#)6pack.h	0.4.0	03/05/2000
 *
 * Author:	Andreas Könsgen <ajk@iehk.rwth-aachen.de>
 *		Jens David	<dg1kjd@afthd.tu-darmstadt.de>
 *
 *		This file is derived from slip.h, written by
 *		Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
 */

#ifndef _LINUX_6PACK_H
#define _LINUX_6PACK_H

#include <net/ax25dev.h>

#define SIXPACK_VERSION    "Revision: 0.4.0"

#ifdef __KERNEL__

/* sixpack priority commands */
#define SIXP_SEOF			0x40	/* start and end of a 6pack frame */
#define SIXP_TX_URUN			0x48	/* transmit overrun */
#define SIXP_RX_ORUN			0x50	/* receive overrun */
#define SIXP_RX_BUF_OVL			0x58	/* receive buffer overflow */
#define SIXP_CHKSUM			0xFF	/* valid checksum of a 6pack frame */

/* masks to get certain bits out of the status bytes sent by the TNC */
#define SIXP_CMD_MASK			0xC0
#define SIXP_CHN_MASK			0x07
#define SIXP_PRIO_CMD_MASK		0x80
#define SIXP_STD_CMD_MASK		0x40
#define SIXP_PRIO_DATA_MASK		0x38
#define SIXP_TX_MASK			0x20
#define SIXP_RX_MASK			0x10
#define SIXP_RX_DCD_MASK		0x18
#define SIXP_LEDS_ON			0x78
#define SIXP_LEDS_OFF			0x60
#define SIXP_CON			0x08
#define SIXP_STA			0x10
#define SIXP_FOUND_TNC			0xe9
#define SIXP_CON_ON			0x68
#define SIXP_DCD_MASK			0x08
#define SIXP_DAMA_OFF			   0

/* default level 2 parameters */
#define SIXP_TXDELAY			250	/* in ms */
#define SIXP_INIT_RESYNC_TIMEOUT	1500	/* in ms */
#define SIXP_RESYNC_TIMEOUT		5000	/* in ms */

/* 6pack configuration. */
#define SIXP_NRUNIT			256	/* MAX number of 6pack channels */
#define SIXP_MTU			(256+MAX_HEADER)

struct sixpack {
	struct tty_struct	*tty;		/* ptr to TTY structure		*/
	struct net_device	*dev;		/* easy for intr handling	*/
	struct ax25_dev		ax25dev;	/* AX.25 control structure	*/
	struct net_device_stats stats;		/* statistics */

	spinlock_t		lock;

	/* These are pointers to the malloc()ed frame buffers. */
	unsigned char		*rbuff;		/* receiver buffer		*/
	int			rcount;         /* received chars counter       */
	unsigned char		*xbuff;		/* transmitter buffer		*/
	unsigned char		*xhead;         /* pointer to next byte to XMIT */
	int			xleft;          /* bytes left in XMIT queue     */

	unsigned char		raw_buf[4];
	unsigned char		cooked_buf[400];

	unsigned int		rx_count;
	unsigned int		rx_count_cooked;

	int			mtu;		/* Our mtu (to spot changes!) */
	int			buffsize;       /* Max buffers sizes */

	struct {
		int	in_use:1;
		int	error:1;
	} flags;

	unsigned char		mode;		/* 6pack mode */

	/* 6pack stuff */
	unsigned char		led_state;
	unsigned char		status;
	unsigned char		status1;
	unsigned char		status2;
	int			tx_counter;	/* counts "unack'ed" TX packets */
	unsigned char		tx_enable;
	unsigned char		tnc_ok;

	struct timer_list	resync_t;
};

struct sixpack_ctrl_t {
	char			if_name[8];	/* "sp0\0" .. "sp99999\0"	*/
	struct sixpack		ctrl;		/* 6pack things			*/
	struct net_device	dev;		/* the device			*/
};

#endif	/* __KERNEL__ */
#endif	/* _LINUX_6PACK.H */