blob: db1560f97085427eb8b99727dd1a7a4d258538d2 [file] [log] [blame]
Gary Jennejohn135f5532008-11-09 12:36:15 +01001/*
2 * (C) Copyright 2008
3 * Gary Jennejohn, DENX Software Engineering GmbH, garyj@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#ifndef _KEYMILE_HDLC_ENET_H_
25#define _KEYMILE_HDLC_ENET_H_
26
27/* Unfortuantely, we have do this to get the flag defines in the cbd_t */
Heiko Schocherd0449542009-03-12 07:37:28 +010028#ifdef CONFIG_KM8XX
Gary Jennejohn135f5532008-11-09 12:36:15 +010029#include <commproc.h>
30#endif
31#ifdef CONFIG_MGCOGE
32#include <mpc8260.h>
33#include <asm/cpm_8260.h>
34#endif
35
36/*
37 * Defines for the ICN protocol used for communication over HDLC
38 * on the backplane between MGSUVDs and MGCOGEs.
39 */
40
41/*
42 * MAC which is reserved for communication (0x00 - 0xff in the last byte,
43 * which is the slot number)
44 */
45
46/*
47 * A DLL frame looks like this:
48 * 8 bit | 8 bit | 8 bit | 8 bit | n * 8 bit| 16 bit| 8 bit
49 * opening| destination| source | application| data | FCS | closing
50 * flag | address | address| | | | flag
51 * (HW) (APP) (APP) (APP) (APP) (HW) (HW)
52 */
53
54/*
55 * The opening flag, the FCS and the closing flag are set by the hardware so
56 * they are not reflected in this struct.
57 */
58struct icn_hdr {
59 unsigned char dest_addr;
60 unsigned char src_addr;
61 unsigned char application;
62} __attribute__((packed));
63
64#define ICNHDR_LEN (sizeof(struct icn_hdr))
65#define CRC_LEN (sizeof(short))
66/* bytes to remove from packet before sending it upstream */
67#define REMOVE (ICNHDR_LEN + CRC_LEN)
68
69struct icn_frame {
70 struct icn_hdr hdr;
71 unsigned char data[0]; /* a place holder */
72} __attribute__((packed));
73
74/* Address field */
75#define HDLC_UUA 0x00 /* Unicast Unit Address */
76#define HDLC_UUA_MASK 0x3f /* the last 6 bits contain the slot number */
77#define SET_HDLC_UUA(x) ((HDLC_UUA | ((x) & HDLC_UUA_MASK)))
78#define HDLC_UACUA 0x7f /* Unicast Active Control Unit Address */
79#define HDLC_BCAST 0xff /* broadcast */
80
81/* Application field */
82#define MGS_UUSP 0x00
83#define MGS_UREP 0x01
84#define MGS_IUP 0x02
85#define MGS_UTA 0x03
86#define MGS_MDS 0x04
87#define MGS_ITIME 0x05
88/* added by DENX */
89#define MGS_NETCONS 0x06 /* netconsole */
90#define MGS_TFTP 0x07
91
92/* Useful defines for buffer sizes, etc. */
93#define HDLC_PKTBUFSRX 32
94#define MAX_FRAME_LENGTH 1500 /* ethernet frame size */
95 /* 14 + 28 */
96#define INET_HDR_SIZE (ETHER_HDR_SIZE + IP_HDR_SIZE)
97#define INET_HDR_ALIGN (((INET_HDR_SIZE + PKTALIGN - 1) / PKTALIGN) * PKTALIGN)
98/* INET_HDR_SIZE is stripped off */
99#define PKT_MAXBLR_SIZE (MAX_FRAME_LENGTH + INET_HDR_ALIGN)
100
101/*
102 * It is too slow to read always the port numbers and IP addresses from the
103 * string variables.
104 * cachedNumbers is meant to cache it.
105 * THIS IS ONLY A SPEED IMPROVEMENT!
106 */
107enum {
108 IP_ADDR = 0, /* getenv_IPaddr("serverip"); */
109 IP_SERVER, /* getenv_IPaddr("ipaddr"); */
110 TFTP_SRC_PORT, /* simple_strtol(getenv("tftpsrcp"), NULL, 10); */
111 TFTP_DST_PORT, /* simple_strtol(getenv("tftpdstp"), NULL, 10); */
112 NETCONS_PORT, /* simple_strtol(getenv("ncip"), NULL, 10); */
113 CACHEDNUMBERS
114};
115
116#define WELL_KNOWN_PORT 69 /* Well known TFTP port # */
117
118/* define this to create a test commend (htest) */
119#undef TEST_IT
120#ifdef TEST_IT
121/* have to save a copy of the eth_device for the test command's use */
122struct eth_device *seth;
123#endif
124/* define this for outputting of received packets */
125#undef TEST_RX
126/* define this for outputting of packets being sent */
127#undef TEST_TX
128
129#endif /* _KEYMILE_HDLC_ENET_H_ */