1 | |
---|
2 | |
---|
3 | //WARPnet Stuff |
---|
4 | |
---|
5 | //Number of PPC clk cycles between stats updates |
---|
6 | #define WARPNET_STATSPKT_PERIOD 60000000 |
---|
7 | |
---|
8 | //Index of OFDM PHY pkt buffer used for sending WARPnet Ethernet packets |
---|
9 | #define WARPNET_PKTBUFFINDEX 4 |
---|
10 | #define WARPNET_CHANEST_PKTBUFFINDEX 5 |
---|
11 | |
---|
12 | #define WARPNET_NUMNODES 2 |
---|
13 | |
---|
14 | //The structs/defines below must match the definitions at the WARPNet server! |
---|
15 | |
---|
16 | typedef struct { |
---|
17 | unsigned int val; |
---|
18 | } warpnodeMailbox; |
---|
19 | |
---|
20 | |
---|
21 | //Struct representing raw Ethernet header + packet contents |
---|
22 | typedef struct { |
---|
23 | //Standard 14-byte Ethernet header (dest/src MAC addresses + EtherType) |
---|
24 | unsigned char dstAddr[6]; |
---|
25 | unsigned char srcAddr[6]; |
---|
26 | unsigned short ethType; |
---|
27 | |
---|
28 | //total number of bytes in pkt, including this header |
---|
29 | unsigned short pktLength; |
---|
30 | |
---|
31 | //number of warpnet structs that follow |
---|
32 | unsigned char numStructs; |
---|
33 | |
---|
34 | //Sequence number to match packets to ACKs |
---|
35 | unsigned char seqNum; |
---|
36 | } warpnetEthernetPktHeader; |
---|
37 | |
---|
38 | ///Struct containing node statistics |
---|
39 | typedef struct { |
---|
40 | unsigned char structType; |
---|
41 | unsigned char nodeID; |
---|
42 | unsigned char partnerID; |
---|
43 | ///Reserved Byte |
---|
44 | unsigned char reserved0; |
---|
45 | ///Used to track number of goodPackets |
---|
46 | unsigned int goodPackets; |
---|
47 | ///Used to track number of partnerBadPackets |
---|
48 | unsigned int partnerBadPackets; |
---|
49 | ///Used to track number of otherBadPackets |
---|
50 | unsigned int otherBadPackets; |
---|
51 | unsigned int rxBytes; |
---|
52 | unsigned int txBytes; |
---|
53 | ///Time in clock cycles. Recall PPC405 clock freq is 240000000 HZ. |
---|
54 | unsigned long long time; |
---|
55 | } warpnodeStats; |
---|
56 | |
---|
57 | //Struct containing control parameters for the MAC/PHY |
---|
58 | typedef struct { |
---|
59 | unsigned char structType; |
---|
60 | unsigned char nodeID; |
---|
61 | unsigned char modOrder; |
---|
62 | unsigned char txPower; |
---|
63 | unsigned char coding; |
---|
64 | unsigned char channel; |
---|
65 | } warpnodeControl; |
---|
66 | |
---|
67 | //Struct containing control parameters for the MAC/PHY |
---|
68 | typedef struct { |
---|
69 | unsigned char structType; |
---|
70 | unsigned char nodeID; |
---|
71 | unsigned char partnerID; |
---|
72 | unsigned char antennaID; |
---|
73 | unsigned char agc_RF; |
---|
74 | unsigned char agc_BB; |
---|
75 | unsigned char pktStatus; |
---|
76 | unsigned char reserved0; |
---|
77 | //64*4 bytes must follow in the actual Ethernet packet! |
---|
78 | } warpnodeChanEst; |
---|
79 | |
---|
80 | //Struct containing a command for a node |
---|
81 | typedef struct { |
---|
82 | unsigned char structType; |
---|
83 | unsigned char nodeID; |
---|
84 | unsigned short cmdID; |
---|
85 | unsigned int cmdParam; |
---|
86 | } warpnodeCommand; |
---|
87 | |
---|
88 | //Struct containing just the node's ID (used to initialize node/server connection) |
---|
89 | typedef struct { |
---|
90 | unsigned char structType; |
---|
91 | unsigned char nodeID; |
---|
92 | } warpnodeID; |
---|
93 | |
---|
94 | |
---|
95 | ///Struct containing traffic paramters for a node |
---|
96 | typedef struct { |
---|
97 | unsigned char structType; |
---|
98 | /// |
---|
99 | unsigned char nodeID; |
---|
100 | ///Value of 1 denotes Transmit, Value of 0 denotes Receive |
---|
101 | unsigned char trafficMode; |
---|
102 | ///Reserved Byte |
---|
103 | unsigned char reserved0; |
---|
104 | ///Interval between start of each packet (in usec) |
---|
105 | unsigned int txInterval; |
---|
106 | ///The length of the packet (in bytes) |
---|
107 | unsigned short txPacketLen; |
---|
108 | ///Reserved Short |
---|
109 | unsigned short reserved1; |
---|
110 | } warpnodeTraffic; |
---|
111 | |
---|
112 | |
---|
113 | |
---|
114 | //Struct Types for WARP Node <-> Server Packets |
---|
115 | #define STRUCTID_NODESTATS 0x40 |
---|
116 | #define STRUCTID_NODEID 0x41 |
---|
117 | #define STRUCTID_NODECONTROL 0x42 |
---|
118 | #define STRUCTID_NODECOMMAND 0x43 |
---|
119 | #define STRUCTID_CHANEST 0x44 |
---|
120 | #define STRUCTID_NODETRAFFIC 0x45 |
---|
121 | #define CHAN_EST_NUMBYTES 256 |
---|
122 | |
---|
123 | //Node command codes |
---|
124 | #define NODECMD_RESETSTATS 0x61 |
---|
125 | #define NODECMD_REBOOT 0x62 |
---|
126 | #define NODECMD_NODEACK 0x63 |
---|
127 | #define NODECMD_SENDPACKET 0x64 |
---|
128 | #define NODECMD_SENDSTATS 0x65 |
---|
129 | #define NODECMD_START 0x66 |
---|
130 | #define NODECMD_STOP 0x67 |
---|
131 | #define NODECMC_REQUESTSTATS 0x68 |
---|
132 | |
---|
133 | //Initial node identification stuff |
---|
134 | #define NODEID_UNKNOWN 0xFF |
---|
135 | |
---|
136 | #define WARPNET_ETHTYPE_SVR2NODE 0x9090 |
---|
137 | #define WARPNET_ETHTYPE_NODE2SVR 0x9191 |
---|
138 | |
---|
139 | #define ETHTYPE_IPV4 0x0800 |
---|
140 | #define BROADCAST_NODE 0xFF |
---|
141 | |
---|
142 | //TrafficMode Transmission definitions |
---|
143 | #define TRANSMIT 1 |
---|
144 | #define RECEIVE 0 |
---|
145 | |
---|
146 | |
---|
147 | //Node<->Server mailbox bit masks |
---|
148 | #define MBOX_SERVER_CONTROL_READY 0x0001 //0=server currently updating control struct |
---|
149 | #define MBOX_NODE_CONTROL_READY 0x0002 //0=node currently reading control struct |
---|
150 | #define MBOX_SERVER_CHANEST_READY 0x0004 //0=server currently reading chanEst structs |
---|
151 | #define MBOX_NODE_CHANEST_READY 0x0008 //0=node currently updating chanEst structs |
---|
152 | |
---|
153 | #define MBOX_CMD_RESET_STATS 0x1000 //1=server wants node to reset stats; node clears this bit |
---|
154 | #define MBOX_CMD_MASK 0x1000 //Ones for each command bit |
---|
155 | |
---|
156 | #define NODEID_READY 0x1234 |
---|
157 | |
---|
158 | //Put the WARPnet structs in the last 1KB of the shared BRAM |
---|
159 | //#define WARPNET_STRUCTS_BASEADDR (XPAR_XPS_BRAM_IF_CNTLR_1_HIGHADDR - 1023) |
---|
160 | #define WARPNET_STRUCTS_BASEADDR (XPAR_XPS_BRAM_IF_CNTLR_1_BASEADDR) |
---|
161 | |
---|
162 | #define WARPNET_MAILBOX_CLEAR(addr, mask) (XIo_Out32((unsigned int)addr, XIo_In32((unsigned int)addr) & ~(mask))) |
---|
163 | #define WARPNET_MAILBOX_SET(addr, mask) (XIo_Out32((unsigned int)addr, XIo_In32((unsigned int)addr) | (mask))) |
---|
164 | #define WARPNET_MAILBOX_GET(addr, mask) ((XIo_In32((unsigned int)addr) & mask) > 0) |
---|
165 | |
---|
166 | |
---|
167 | |
---|
168 | |
---|
169 | |
---|
170 | |
---|
171 | |
---|
172 | |
---|
173 | |
---|
174 | |
---|
175 | |
---|