keymile_hdlc_enet.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  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. #ifndef _KEYMILE_HDLC_ENET_H_
  24. #define _KEYMILE_HDLC_ENET_H_
  25. /* Unfortuantely, we have do this to get the flag defines in the cbd_t */
  26. #ifdef CONFIG_KM8XX
  27. #include <commproc.h>
  28. #endif
  29. #ifdef CONFIG_MGCOGE
  30. #include <mpc8260.h>
  31. #include <asm/cpm_8260.h>
  32. #endif
  33. /*
  34. * Defines for the ICN protocol used for communication over HDLC
  35. * on the backplane between MGSUVDs and MGCOGEs.
  36. */
  37. /*
  38. * MAC which is reserved for communication (0x00 - 0xff in the last byte,
  39. * which is the slot number)
  40. */
  41. /*
  42. * A DLL frame looks like this:
  43. * 8 bit | 8 bit | 8 bit | 8 bit | n * 8 bit| 16 bit| 8 bit
  44. * opening| destination| source | application| data | FCS | closing
  45. * flag | address | address| | | | flag
  46. * (HW) (APP) (APP) (APP) (APP) (HW) (HW)
  47. */
  48. /*
  49. * The opening flag, the FCS and the closing flag are set by the hardware so
  50. * they are not reflected in this struct.
  51. */
  52. struct icn_hdr {
  53. unsigned char dest_addr;
  54. unsigned char src_addr;
  55. unsigned char application;
  56. } __attribute__((packed));
  57. #define ICNHDR_LEN (sizeof(struct icn_hdr))
  58. #define CRC_LEN (sizeof(short))
  59. /* bytes to remove from packet before sending it upstream */
  60. #define REMOVE (ICNHDR_LEN + CRC_LEN)
  61. struct icn_frame {
  62. struct icn_hdr hdr;
  63. unsigned char data[0]; /* a place holder */
  64. } __attribute__((packed));
  65. /* Address field */
  66. #define HDLC_UUA 0x00 /* Unicast Unit Address */
  67. #define HDLC_UUA_MASK 0x3f /* the last 6 bits contain the slot number */
  68. #define SET_HDLC_UUA(x) ((HDLC_UUA | ((x) & HDLC_UUA_MASK)))
  69. #define HDLC_UACUA 0x7f /* Unicast Active Control Unit Address */
  70. #define HDLC_BCAST 0xff /* broadcast */
  71. /* Application field */
  72. #define MGS_UUSP 0x00
  73. #define MGS_UREP 0x01
  74. #define MGS_IUP 0x02
  75. #define MGS_UTA 0x03
  76. #define MGS_MDS 0x04
  77. #define MGS_ITIME 0x05
  78. /* added by DENX */
  79. #define MGS_NETCONS 0x06 /* netconsole */
  80. #define MGS_TFTP 0x07
  81. /* Useful defines for buffer sizes, etc. */
  82. #define HDLC_PKTBUFSRX 32
  83. #define MAX_FRAME_LENGTH 1500 /* ethernet frame size */
  84. /* 14 + 28 */
  85. #define INET_HDR_SIZE (ETHER_HDR_SIZE + IP_HDR_SIZE)
  86. #define INET_HDR_ALIGN (((INET_HDR_SIZE + PKTALIGN - 1) / PKTALIGN) * PKTALIGN)
  87. /* INET_HDR_SIZE is stripped off */
  88. #define PKT_MAXBLR_SIZE (MAX_FRAME_LENGTH + INET_HDR_ALIGN)
  89. /*
  90. * It is too slow to read always the port numbers and IP addresses from the
  91. * string variables.
  92. * cachedNumbers is meant to cache it.
  93. * THIS IS ONLY A SPEED IMPROVEMENT!
  94. */
  95. enum {
  96. IP_ADDR = 0, /* getenv_IPaddr("serverip"); */
  97. IP_SERVER, /* getenv_IPaddr("ipaddr"); */
  98. TFTP_SRC_PORT, /* simple_strtol(getenv("tftpsrcp"), NULL, 10); */
  99. TFTP_DST_PORT, /* simple_strtol(getenv("tftpdstp"), NULL, 10); */
  100. NETCONS_PORT, /* simple_strtol(getenv("ncip"), NULL, 10); */
  101. CACHEDNUMBERS
  102. };
  103. #define WELL_KNOWN_PORT 69 /* Well known TFTP port # */
  104. /* define this to create a test commend (htest) */
  105. #undef TEST_IT
  106. #ifdef TEST_IT
  107. /* have to save a copy of the eth_device for the test command's use */
  108. struct eth_device *seth;
  109. #endif
  110. /* define this for outputting of received packets */
  111. #undef TEST_RX
  112. /* define this for outputting of packets being sent */
  113. #undef TEST_TX
  114. #endif /* _KEYMILE_HDLC_ENET_H_ */