[2053] | 1 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 2 | // Copyright (c) 2004 Xilinx, Inc. All rights reserved. |
---|
| 3 | // |
---|
| 4 | // Xilinx, Inc. |
---|
| 5 | // XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A |
---|
| 6 | // COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS |
---|
| 7 | // ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR |
---|
| 8 | // STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION |
---|
| 9 | // IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE |
---|
| 10 | // FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. |
---|
| 11 | // XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO |
---|
| 12 | // THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO |
---|
| 13 | // ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE |
---|
| 14 | // FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY |
---|
| 15 | // AND FITNESS FOR A PARTICULAR PURPOSE. |
---|
| 16 | // |
---|
| 17 | // File : eth.h |
---|
| 18 | // Date : 2002, March 20. |
---|
| 19 | // Author : Sathya Thammanur |
---|
| 20 | // Company: Xilinx |
---|
| 21 | // Group : Emerging Software Technologies |
---|
| 22 | // |
---|
| 23 | // Summary: |
---|
| 24 | // Header file for Ethernet layer |
---|
| 25 | // |
---|
| 26 | // $Id: eth.h,v 1.2.8.6 2005/11/15 23:41:10 salindac Exp $ |
---|
| 27 | // |
---|
| 28 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 29 | |
---|
| 30 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 31 | // see copyright.txt for Rice University/Mango Communications modifications |
---|
| 32 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | #ifndef _ETH_H |
---|
| 36 | #define _ETH_H |
---|
| 37 | |
---|
| 38 | #ifdef __cplusplus |
---|
| 39 | extern "C" { |
---|
| 40 | #endif |
---|
| 41 | |
---|
| 42 | #include <xilnet_ip.h> |
---|
| 43 | |
---|
| 44 | #define ETH_ADDR_LEN 6 /* len of eth addr */ |
---|
| 45 | #define ETH_HDR_LEN 14 /* eth hdr len */ |
---|
| 46 | #define ETH_MIN_FRAME_LEN 60 /* Min Eth Frame Payload */ |
---|
| 47 | |
---|
| 48 | //#define ETH_MAX_FRAME_LEN 1500 /* Max Eth Frame Payload */ |
---|
| 49 | //#define ETH_FRAME_LEN 1514 /* Max Eth Frame Size */ |
---|
| 50 | |
---|
| 51 | #define ETH_MAX_FRAME_LEN 9000 /* Max Eth Frame Payload */ // TODO: MAY NEED TO FIX |
---|
| 52 | #define ETH_FRAME_LEN 9014 /* Max Eth Frame Size */ // TODO: MAY NEED TO FIX |
---|
| 53 | |
---|
| 54 | /* |
---|
| 55 | * Protocol vals in eth hdr |
---|
| 56 | */ |
---|
| 57 | #define ETH_PROTO_IP 0x0800 /* IP packet */ |
---|
| 58 | #define ETH_PROTO_ARP 0x0806 /* ARP packet */ |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | /* |
---|
| 62 | * Ethernet Header |
---|
| 63 | */ |
---|
| 64 | struct xilnet_eth_hdr { |
---|
| 65 | unsigned char dest_addr[ETH_ADDR_LEN]; /* destination eth addr */ |
---|
| 66 | unsigned char src_addr[ETH_ADDR_LEN]; /* source eth addr */ |
---|
| 67 | unsigned short type; /* protocol type */ |
---|
| 68 | }; |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | /* |
---|
| 72 | * HW Address Table |
---|
| 73 | */ |
---|
| 74 | #define HW_ADDR_TBL_ENTRIES 5 * XILNET_NUM_ETH_DEVICES |
---|
| 75 | #define HW_ADDR_ENTRY_IS_TRUE 1 |
---|
| 76 | #define HW_ADDR_ENTRY_IS_FALSE 0 |
---|
| 77 | #define HW_ADDR_TBL_MAXAGE 2 |
---|
| 78 | |
---|
| 79 | struct xilnet_hw_addr_table |
---|
| 80 | { |
---|
| 81 | unsigned char ip_addr[IP_VERSION]; |
---|
| 82 | unsigned char hw_addr[ETH_ADDR_LEN]; |
---|
| 83 | unsigned char flag; |
---|
[2057] | 84 | unsigned int age; |
---|
[2053] | 85 | }; |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | // Ethernet device structure |
---|
| 90 | typedef struct { |
---|
| 91 | // Ethernet interface type: FIFO, DMA |
---|
| 92 | unsigned char inf_type; // XILNET_AXI_DMA_INF, XILNET_AXI_FIFO_INF |
---|
[2057] | 93 | |
---|
[2053] | 94 | unsigned int inf_id; // XPAR ID for interface |
---|
[2057] | 95 | void * inf_ref; // Pointer to interface instance |
---|
| 96 | void * inf_cfg_ref; // Pointer to interface config instance -- ONLY USED BY DMA |
---|
[2053] | 97 | |
---|
[2057] | 98 | unsigned int inf_dma_id; // XPAR ID for interface dma (for case where both FIFO and Central DMA are used) -- ONLY USED BY WARP V2 |
---|
| 99 | void * inf_dma_ref; // Pointer to interface dma instance (for case where both FIFO and Central DMA are used) -- ONLY USED BY WARP V2 |
---|
| 100 | void * inf_dma_cfg_ref; // Pointer to interface dma config instance (for case where both FIFO and Central DMA are used) -- ONLY USED BY WARP V2 |
---|
[2053] | 101 | |
---|
[2057] | 102 | void * dma_rx_ring_ref; // Pointer to RX ring -- ONLY USED BY DMA |
---|
| 103 | void * dma_tx_ring_ref; // Pointer to TX ring -- ONLY USED BY DMA |
---|
| 104 | void * dma_rx_bd_ref; // Pointer to RX buffer descriptor -- ONLY USED BY DMA |
---|
| 105 | void * dma_tx_bd_ref; // Pointer to TX buffer descriptor -- ONLY USED BY DMA |
---|
| 106 | int dma_rx_bd_cnt; // Number of RX buffer descriptors -- ONLY USED BY DMA |
---|
| 107 | int dma_tx_bd_cnt; // Number of TX buffer descriptors -- ONLY USED BY DMA |
---|
| 108 | |
---|
| 109 | |
---|
[2053] | 110 | // Flags / Control Variables |
---|
| 111 | int xilsock_status_flag; |
---|
| 112 | unsigned char sync_IP_octet; |
---|
| 113 | |
---|
| 114 | // Ethernet device information |
---|
| 115 | unsigned char node_ip_addr[IP_VERSION]; |
---|
| 116 | unsigned char node_hw_addr[ETH_ADDR_LEN]; |
---|
| 117 | |
---|
| 118 | // Socket information |
---|
| 119 | unsigned char is_xilsock_init; |
---|
| 120 | void * xilsock_sockets; |
---|
| 121 | unsigned char is_udp_init; |
---|
| 122 | void * xilnet_udp_conns; |
---|
| 123 | |
---|
| 124 | // HW Address Table |
---|
| 125 | void * xilnet_hw_tbl; // TODO: Unused. Currently using single global table; placed here for future work |
---|
| 126 | |
---|
| 127 | // Buffers for sending / recieving data |
---|
| 128 | // NOTE: Buffers are allocated based on the configuration in the BSP. The following options will be used to |
---|
| 129 | // determine the buffer size: |
---|
| 130 | // recvbuf[XILNET_ETH_*_BUF_SIZE * XILNET_ETH_*_NUM_RECV_BUF] |
---|
| 131 | // sendbuf[XILNET_ETH_*_BUF_SIZE] |
---|
| 132 | // For DMA interfaces, it is recommended to set XILNET_ETH_*_NUM_RECV_BUF = 2 so that the AXI DMA can use a |
---|
| 133 | // ping pong buffer scheme. |
---|
| 134 | // |
---|
| 135 | unsigned int buf_size; |
---|
| 136 | unsigned int num_recvbuf; |
---|
| 137 | unsigned int * recvbuf; |
---|
| 138 | unsigned int * sendbuf; |
---|
| 139 | } xilnet_eth_device; |
---|
| 140 | |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | #ifdef __cplusplus |
---|
| 144 | } |
---|
| 145 | #endif |
---|
| 146 | |
---|
| 147 | #endif /* _ETH_H */ |
---|