[2229] | 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 | * Convert Ethernet device number to WARPNet convention (ie ETH A or ETH B) |
---|
| 63 | */ |
---|
| 64 | #define wn_conv_eth_dev_num(x) (char)(((int)'A') + x) |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | /* |
---|
| 68 | * Ethernet Header |
---|
| 69 | */ |
---|
| 70 | struct xilnet_eth_hdr { |
---|
| 71 | unsigned char dest_addr[ETH_ADDR_LEN]; /* destination eth addr */ |
---|
| 72 | unsigned char src_addr[ETH_ADDR_LEN]; /* source eth addr */ |
---|
| 73 | unsigned short type; /* protocol type */ |
---|
| 74 | }; |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | /* |
---|
| 78 | * HW Address Table |
---|
| 79 | */ |
---|
| 80 | #define HW_ADDR_TBL_ENTRIES 5 * XILNET_NUM_ETH_DEVICES |
---|
| 81 | #define HW_ADDR_ENTRY_IS_TRUE 1 |
---|
| 82 | #define HW_ADDR_ENTRY_IS_FALSE 0 |
---|
| 83 | #define HW_ADDR_TBL_MAXAGE 2 |
---|
| 84 | |
---|
| 85 | struct xilnet_hw_addr_table |
---|
| 86 | { |
---|
| 87 | unsigned char ip_addr[IP_VERSION]; |
---|
| 88 | unsigned char hw_addr[ETH_ADDR_LEN]; |
---|
| 89 | unsigned char flag; |
---|
| 90 | unsigned int age; |
---|
| 91 | }; |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | // Ethernet device structure |
---|
| 96 | typedef struct { |
---|
| 97 | unsigned char uses_driver; // Determine if the Ethernet device is uses the Xilnet driver |
---|
| 98 | |
---|
| 99 | // Ethernet interface type: FIFO, DMA |
---|
| 100 | unsigned char inf_type; // XILNET_AXI_DMA_INF, XILNET_AXI_FIFO_INF |
---|
| 101 | |
---|
| 102 | unsigned int inf_id; // XPAR ID for interface |
---|
| 103 | void * inf_ref; // Pointer to interface instance |
---|
| 104 | void * inf_cfg_ref; // Pointer to interface config instance -- ONLY USED BY DMA |
---|
| 105 | |
---|
| 106 | 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 |
---|
| 107 | void * inf_dma_ref; // Pointer to interface dma instance (for case where both FIFO and Central DMA are used) -- ONLY USED BY WARP V2 |
---|
| 108 | 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 |
---|
| 109 | |
---|
| 110 | void * dma_rx_ring_ref; // Pointer to RX ring -- ONLY USED BY DMA |
---|
| 111 | void * dma_tx_ring_ref; // Pointer to TX ring -- ONLY USED BY DMA |
---|
| 112 | void * dma_rx_bd_ref; // Pointer to RX buffer descriptor -- ONLY USED BY DMA |
---|
| 113 | void * dma_tx_bd_ref; // Pointer to TX buffer descriptor -- ONLY USED BY DMA |
---|
| 114 | int dma_rx_bd_cnt; // Number of RX buffer descriptors -- ONLY USED BY DMA |
---|
| 115 | int dma_tx_bd_cnt; // Number of TX buffer descriptors -- ONLY USED BY DMA |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | // Flags / Control Variables |
---|
| 119 | int xilsock_status_flag; |
---|
| 120 | unsigned char sync_IP_octet; |
---|
| 121 | |
---|
| 122 | // Ethernet device information |
---|
| 123 | unsigned char node_ip_addr[IP_VERSION]; |
---|
| 124 | unsigned char node_hw_addr[ETH_ADDR_LEN]; |
---|
| 125 | |
---|
| 126 | // Socket information |
---|
| 127 | unsigned char is_xilsock_init; |
---|
| 128 | void * xilsock_sockets; |
---|
| 129 | unsigned char is_udp_init; |
---|
| 130 | void * xilnet_udp_conns; |
---|
| 131 | |
---|
| 132 | // HW Address Table |
---|
| 133 | void * xilnet_hw_tbl; // TODO: Unused. Currently using single global table; placed here for future work |
---|
| 134 | |
---|
| 135 | // Buffers for sending / recieving data |
---|
| 136 | // NOTE: Buffers are allocated based on the configuration in the BSP. The following options will be used to |
---|
| 137 | // determine the buffer size: |
---|
| 138 | // recvbuf[XILNET_ETH_*_BUF_SIZE * XILNET_ETH_*_NUM_RECV_BUF] |
---|
| 139 | // sendbuf[XILNET_ETH_*_BUF_SIZE] |
---|
| 140 | // For DMA interfaces, it is recommended to set XILNET_ETH_*_NUM_RECV_BUF = 2 so that the AXI DMA can use a |
---|
| 141 | // ping pong buffer scheme. |
---|
| 142 | // |
---|
| 143 | unsigned int buf_size; |
---|
| 144 | unsigned int num_recvbuf; |
---|
| 145 | unsigned int * recvbuf; |
---|
| 146 | unsigned int * sendbuf; |
---|
| 147 | } xilnet_eth_device; |
---|
| 148 | |
---|
| 149 | |
---|
| 150 | |
---|
| 151 | #ifdef __cplusplus |
---|
| 152 | } |
---|
| 153 | #endif |
---|
| 154 | |
---|
| 155 | #endif /* _ETH_H */ |
---|