summaryrefslogtreecommitdiff
path: root/board/keymile/common/keymile_hdlc_enet.h
blob: db1560f97085427eb8b99727dd1a7a4d258538d2 (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 * (C) Copyright 2008
 * Gary Jennejohn, DENX Software Engineering GmbH, garyj@denx.de.
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#ifndef _KEYMILE_HDLC_ENET_H_
#define _KEYMILE_HDLC_ENET_H_

/* Unfortuantely, we have do this to get the flag defines in the cbd_t */
#ifdef CONFIG_KM8XX
#include <commproc.h>
#endif
#ifdef CONFIG_MGCOGE
#include <mpc8260.h>
#include <asm/cpm_8260.h>
#endif

/*
 * Defines for the ICN protocol used for communication over HDLC
 * on the backplane between MGSUVDs and MGCOGEs.
 */

/*
 * MAC which is reserved for communication (0x00 - 0xff in the last byte,
 * which is the slot number)
 */

/*
 * A DLL frame looks like this:
 *  8 bit  |  8 bit     |  8 bit |  8 bit     | n * 8 bit| 16 bit|  8 bit
 *  opening| destination| source | application|  data    |  FCS  | closing
 *   flag  |  address   | address|            |          |       |  flag
 *  (HW)      (APP)       (APP)      (APP)       (APP)      (HW)   (HW)
 */

/*
 * The opening flag, the FCS and the closing flag are set by the hardware so
 * they are not reflected in this struct.
 */
struct icn_hdr {
	unsigned char dest_addr;
	unsigned char src_addr;
	unsigned char application;
} __attribute__((packed));

#define ICNHDR_LEN	(sizeof(struct icn_hdr))
#define CRC_LEN		(sizeof(short))
/* bytes to remove from packet before sending it upstream */
#define REMOVE		(ICNHDR_LEN + CRC_LEN)

struct icn_frame {
	struct icn_hdr hdr;
	unsigned char data[0];	/* a place holder */
} __attribute__((packed));

/* Address field */
#define HDLC_UUA	0x00 /* Unicast Unit Address */
#define HDLC_UUA_MASK	0x3f /* the last 6 bits contain the slot number */
#define SET_HDLC_UUA(x) ((HDLC_UUA | ((x) & HDLC_UUA_MASK)))
#define HDLC_UACUA	0x7f /* Unicast Active Control Unit Address */
#define HDLC_BCAST	0xff /* broadcast */

/* Application field */
#define MGS_UUSP	0x00
#define MGS_UREP	0x01
#define MGS_IUP		0x02
#define MGS_UTA		0x03
#define MGS_MDS		0x04
#define MGS_ITIME	0x05
/* added by DENX */
#define MGS_NETCONS	0x06	/* netconsole */
#define MGS_TFTP	0x07

/* Useful defines for buffer sizes, etc. */
#define HDLC_PKTBUFSRX		32
#define MAX_FRAME_LENGTH	1500 /* ethernet frame size */
			 /*   14        +    28     */
#define INET_HDR_SIZE	(ETHER_HDR_SIZE + IP_HDR_SIZE)
#define INET_HDR_ALIGN	(((INET_HDR_SIZE + PKTALIGN - 1) / PKTALIGN) * PKTALIGN)
/* INET_HDR_SIZE is stripped off */
#define PKT_MAXBLR_SIZE	(MAX_FRAME_LENGTH + INET_HDR_ALIGN)

/*
 * It is too slow to read always the port numbers and IP addresses from the
 * string variables.
 * cachedNumbers is meant to cache it.
 * THIS IS ONLY A SPEED IMPROVEMENT!
 */
enum {
	IP_ADDR = 0,	/* getenv_IPaddr("serverip"); */
	IP_SERVER,	/* getenv_IPaddr("ipaddr"); */
	TFTP_SRC_PORT,	/* simple_strtol(getenv("tftpsrcp"), NULL, 10); */
	TFTP_DST_PORT,	/* simple_strtol(getenv("tftpdstp"), NULL, 10); */
	NETCONS_PORT,	/* simple_strtol(getenv("ncip"), NULL, 10); */
	CACHEDNUMBERS
};

#define WELL_KNOWN_PORT 69	/* Well known TFTP port # */

/* define this to create a test commend (htest) */
#undef TEST_IT
#ifdef TEST_IT
/* have to save a copy of the eth_device for the test command's use */
struct eth_device *seth;
#endif
/* define this for outputting of received packets */
#undef TEST_RX
/* define this for outputting of packets being sent */
#undef TEST_TX

#endif /* _KEYMILE_HDLC_ENET_H_ */