8 #ifndef DESSERPCIE40MAIN_H
9 #define DESSERPCIE40MAIN_H
14 #include <netinet/in.h>
15 #include <netinet/tcp.h>
16 #include <sys/types.h>
17 #include <sys/socket.h>
22 #include <arpa/inet.h>
36 #include <sys/types.h>
39 #include "pcie40_b2dma.h"
40 #include "dma_driverlib.h"
41 #include "pcie40_s_pages.h"
42 #include <rawdata/dataobjects/RawHeader_latest.h>
43 #include <rawdata/dataobjects/RawTrailer_latest.h>
44 #include <rawdata/dataobjects/PreRawCOPPERFormat_latest.h>
45 #include <rawdata/dataobjects/PostRawCOPPERFormat_latest.h>
56 #define NUM_CLIENTS_PER_THREAD 1
57 #define NUM_SENDER_THREADS 5
61 #define NODE_ID_TEST_BENCH 0x99000001
71 #ifdef SPLIT_ECL_ECLTRG
84 #define NW_RAW_HEADER 56
85 #define NW_RAW_TRAILER 4
86 #define NW_REDUCED_B2L_HEADER 2
87 #define NW_REDUCED_B2L_TRAILER 2
88 #define NW_NONREDUCED_B2L_HEADER 6
89 #define NW_NONREDUCED_B2L_TRAILER 3
94 #define NW_SEND_HEADER 6
95 #define NW_SEND_TRAILER 2
101 #define DATACHECK_OK 0
102 #define DATACHECK_NG 1
103 #define DATACHECK_OK_BUT_ERRFLAG_IN_HDR 2
108 #define CTIME_VAL 0x12345601
109 #ifdef DUMMY_REDUCED_DATA
110 #define NW_B2L_HEADER 3
111 #define NW_B2L_TRAILER 2
113 #define NW_B2L_HEADER 7
114 #define NW_B2L_TRAILER 3
117 #ifdef SPLIT_ECL_ECLTRG
118 #define ECLTRG_NODE_ID 0x13000001
127 unsigned int node_id;
128 std::vector< int > valid_ch;
133 #define EVENT_LEN_POS 0+OFFSET_HDR
134 #define MAGIC_7F7F_POS 1+OFFSET_HDR
135 #define RUNNO_POS 2+OFFSET_HDR
136 #define EVENUM_POS 3+OFFSET_HDR
137 #define CTIME_POS 4+OFFSET_HDR
138 #define UTIME_POS 5+OFFSET_HDR
139 #define NODEID_POS 6+OFFSET_HDR
140 #define ERR_POS 7+OFFSET_HDR
141 #define POS_TABLE_POS 8+OFFSET_HDR
142 #define LEN_ROB_HEADER 56
143 #define LEN_ROB_TRAILER 4
145 #define CRC_START_POS 1
146 #define NON_CRC_COUNTS_REDUCED 3
147 #define NON_CRC_COUNTS_NOTREDUCED 4
151 #define LINK_EVE_POS 2
155 #define MAX_EVENT_WORDS 500000
156 #define DMA_HDR_WORDS 8
159 #define DMA_WORDS_OF_256BITS 0
160 #define DMA_HDR_MAGIC 1
161 #define DMA_SIZE_IN_BYTES 2
162 #define MAX_DMA_WORDS_OF_256BITS 0xFF
164 extern "C" int ecs_open(
int dev,
int bar);
165 extern "C" void ecs_close(
int dev,
int bar);
166 extern "C" unsigned ecs_read(
int dev,
int bar,
unsigned add) ;
167 extern "C" int ecs_write(
int dev,
int bar,
unsigned add,
int val);
184 void crc_calc(
unsigned int& crc,
const unsigned int& data);
186 unsigned int get_crc(
unsigned int* data,
int length,
unsigned int initial_value);
188 unsigned short CalcCRC16LittleEndian(
unsigned short crc16,
const int buf[],
int nwords);
193 int getEventNumber(
unsigned int* data);
195 int get1stChannel(
unsigned int*& data);
200 void printHeader(
unsigned int* data);
202 void printTrailer(
unsigned int* data);
204 void printData(
unsigned int* data);
206 void writeToFile(std::ofstream& the_file,
unsigned int* data,
int size);
208 void printLine(
unsigned int* data,
int pos);
210 void printEventData(
unsigned int* data);
212 void printEventData(
unsigned int* data,
int size);
214 void printEventData(
unsigned int* data,
int size,
int sender_id);
216 void printFullData(
unsigned int* data);
218 void printEventNumberError(
unsigned int*& data,
const unsigned int evtnum,
const unsigned int exprun,
const int eve_diff,
219 const int sender_id);
224 void checkUtimeCtimeTRGType(
unsigned int*& data,
const int sender_id);
226 int checkDMAHeader(
unsigned int*& data,
unsigned int& size,
double& dsize,
int& total_pages,
int& index_pages);
230 int checkEventData(
int sender_id,
unsigned int* data,
unsigned int event_nwords,
unsigned int& exprun,
231 unsigned int& evtnum,
unsigned int node_id, std::vector< int > valid_ch);
233 void checkEventGenerator(
unsigned int* data,
int i,
unsigned int size);
238 void reduceHdrTrl(
unsigned int* data,
unsigned int& event_nwords);
240 int fillDataContents(
int* buf,
int nwords_per_fee,
unsigned int node_id,
int ncpr,
int nhslb,
int run);
242 void addEvent(
int* buf,
int nwords_per_fee,
unsigned int event,
int ncpr,
int nhslb);
244 void split_Ecltrg(
int sender_id,
unsigned int* data, std::vector< int > valid_ch,
245 unsigned int* data_main,
unsigned int* data_splitted,
246 int& event_nwords_main,
int& event_nwords_splitted,
247 unsigned int splitted_node_id, std::vector< int > splitted_ch);
249 void* sender(
void* arg);