Commit 01608a97 authored by 's avatar
Browse files

Finished INTERFACE function, sw implemented. Here an interface is an...

Finished INTERFACE function, sw implemented. Here an interface is an equivalent to a channel in nt terminology.


git-svn-id: file:///home/svn/mapi/trunk@1484 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 903a04d2
...@@ -72,7 +72,7 @@ __attribute__ ((destructor)) void fini (); ...@@ -72,7 +72,7 @@ __attribute__ ((destructor)) void fini ();
static flist_t *devlist; static flist_t *devlist;
/* for mapidlib errorcode */ /* for mapidlib errorcode */
int int
mapidrv_get_errno(int devid,int fd) mapidrv_get_errno(int devid,int fd)
{ {
DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_get_errno")); DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_get_errno"));
...@@ -94,13 +94,13 @@ int ...@@ -94,13 +94,13 @@ int
mapidrv_apply_function (int devid,int fd, int flags, char* function, mapiFunctArg *fargs) mapidrv_apply_function (int devid,int fd, int flags, char* function, mapiFunctArg *fargs)
{ {
DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_apply_function")); DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_apply_function"));
DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_apply_function; devid = %d; fd = %d; function = %s", devid, fd, function)); DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_apply_function; devid = %d; fd = %d; function = %s", devid, fd, function));
napatech_instance_t *i=flist_get(devlist,devid); napatech_instance_t *i=flist_get(devlist,devid);
DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_apply_function; &i = %x", (int)i)); DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_apply_function; &i = %x", (int)i));
DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_apply_function; &i->mapidlib = %x", (int)(&i->mapidlib))); DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_apply_function; &i->mapidlib = %x", (int)(&i->mapidlib)));
int _flags = flags; int _flags = flags;
...@@ -131,7 +131,7 @@ int mapidrv_add_device(const char *devname, int file,int devid, global_function_ ...@@ -131,7 +131,7 @@ int mapidrv_add_device(const char *devname, int file,int devid, global_function_
i->offline_status = olstatus; i->offline_status = olstatus;
if(devid<0) if(devid<0)
i->hwinfo.offline = 1; i->hwinfo.offline = 1;
DEBUG_CMD(Debug_Message("Added device %d: %s", devid, devname)); DEBUG_CMD(Debug_Message("Added device %d: %s", devid, devname));
flist_append(devlist,devid,i); flist_append(devlist,devid,i);
...@@ -146,24 +146,24 @@ int mapidrv_delete_device(int devid) ...@@ -146,24 +146,24 @@ int mapidrv_delete_device(int devid)
napatech_instance_t *i=flist_remove(devlist,devid); napatech_instance_t *i=flist_remove(devlist,devid);
uint32_t result; uint32_t result;
if (i!=NULL) { if (i!=NULL) {
int err=0; int err=0;
if (i->th_proc && pthread_equal(i->th_proc, pthread_self())==0) { if (i->th_proc && pthread_equal(i->th_proc, pthread_self())==0) {
DEBUG_CMD(Debug_Message("Calling thread != th_proc (%lu != %lu), cancelling", i->th_proc, pthread_self())); DEBUG_CMD(Debug_Message("Calling thread != th_proc (%lu != %lu), cancelling", i->th_proc, pthread_self()));
fflush(stdout); fflush(stdout);
if ((err=pthread_cancel(i->th_proc))!=0) { if ((err=pthread_cancel(i->th_proc))!=0) {
if (!(i->hwinfo.offline==1 && err==ESRCH)) { if (!(i->hwinfo.offline==1 && err==ESRCH)) {
DEBUG_CMD(Debug_Message("WARNING: Could not cancel thread for devid %d (%s)", devid, strerror(err))); DEBUG_CMD(Debug_Message("WARNING: Could not cancel thread for devid %d (%s)", devid, strerror(err)));
fflush(stdout); fflush(stdout);
} }
} }
} }
if(i->napatechhandle != NULL) { if(i->napatechhandle != NULL) {
if((result = NTCI_DestroyPacketFeed(i->napatechhandle, i->packetfeedhandle)) != NTCI_ERRCODE_SUCCESS) { if((result = NTCI_DestroyPacketFeed(i->napatechhandle, i->packetfeedhandle)) != NTCI_ERRCODE_SUCCESS) {
DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_delete_device; Failed to destroy packet feed! (%i)\n", result)); DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_delete_device; Failed to destroy packet feed! (%i)\n", result));
} }
NTCI_CloseCard(i->napatechhandle); NTCI_CloseCard(i->napatechhandle);
...@@ -177,11 +177,11 @@ int mapidrv_delete_device(int devid) ...@@ -177,11 +177,11 @@ int mapidrv_delete_device(int devid)
free(i); free(i);
} }
return 0; return 0;
} }
static unsigned static unsigned
// process_pkts(void *buf,unsigned len, napatech_instance_t *i) // process_pkts(void *buf,unsigned len, napatech_instance_t *i)
process_pkts(BufferInformationSectionType1_t* bufferInformation, napatech_instance_t *i) process_pkts(BufferInformationSectionType1_t* bufferInformation, napatech_instance_t *i)
{ {
...@@ -192,26 +192,26 @@ process_pkts(BufferInformationSectionType1_t* bufferInformation, napatech_instan ...@@ -192,26 +192,26 @@ process_pkts(BufferInformationSectionType1_t* bufferInformation, napatech_instan
uint32_t packet = 0; uint32_t packet = 0;
uint8_t *frame = NULL; uint8_t *frame = NULL;
PacketDescriptorType2_t *descriptor = (PacketDescriptorType2_t *)(((uint8_t*)(i->bufferInfo.bufferBaseAddress)) + bufferInformation->sectionOffset); PacketDescriptorType2_t *descriptor = (PacketDescriptorType2_t *)(((uint8_t*)(i->bufferInfo.bufferBaseAddress)) + bufferInformation->sectionOffset);
// pNetFlow->flowStat.uiTotalDropped+=bufferInformation.numDroppedFrames; // pNetFlow->flowStat.uiTotalDropped+=bufferInformation.numDroppedFrames;
if(descriptor->ExtensionFormat == EXTENDED_DESCRIPTOR_05_TYPE) { if(descriptor->ExtensionFormat == EXTENDED_DESCRIPTOR_05_TYPE) {
for(packet=0; packet < bufferInformation->numDescriptorsAvailable; packet++) { for(packet=0; packet < bufferInformation->numDescriptorsAvailable; packet++) {
i->hwinfo.pkts++; i->hwinfo.pkts++;
PacketExtDescriptorType05_t *pExtDescr = (PacketExtDescriptorType05_t*)(((uint8_t*)descriptor) + sizeof(PacketDescriptorType2_t));
frame = ((uint8_t*)descriptor) + sizeof(PacketDescriptorType2_t) + (descriptor->ExtensionLength << 3);
mhdr.ts = descriptor->Timestamp; PacketExtDescriptorType05_t *pExtDescr = (PacketExtDescriptorType05_t*)(((uint8_t*)descriptor) + sizeof(PacketDescriptorType2_t));
mhdr.ifindex = 0; // ?
mhdr.caplen = descriptor->StoredLength; frame = ((uint8_t*)descriptor) + sizeof(PacketDescriptorType2_t) + (descriptor->ExtensionLength << 3);
mhdr.wlen = descriptor->WireLength;
mhdr.ts = descriptor->Timestamp;
mhdr.ifindex = descriptor->Channel;
mhdr.caplen = descriptor->StoredLength;
mhdr.wlen = descriptor->WireLength;
// ? TODO - modify third argument to pass test_packet_read // ? TODO - modify third argument to pass test_packet_read
mapid_process_pkt(&i->mapidlib, (unsigned char*)frame, frame + (descriptor->StoredLength - descriptor->WireLength), &mhdr); mapid_process_pkt(&i->mapidlib, (unsigned char*)frame, frame + (descriptor->StoredLength - descriptor->WireLength), &mhdr);
/* Avance to the next packet. */ /* Avance to the next packet. */
descriptor = (PacketDescriptorType2_t*)((uint8_t*)descriptor + descriptor->StoredLength); descriptor = (PacketDescriptorType2_t*)((uint8_t*)descriptor + descriptor->StoredLength);
...@@ -219,26 +219,26 @@ process_pkts(BufferInformationSectionType1_t* bufferInformation, napatech_instan ...@@ -219,26 +219,26 @@ process_pkts(BufferInformationSectionType1_t* bufferInformation, napatech_instan
} else { } else {
for(packet=0; packet < bufferInformation->numDescriptorsAvailable; packet++) { for(packet=0; packet < bufferInformation->numDescriptorsAvailable; packet++) {
i->hwinfo.pkts++; i->hwinfo.pkts++;
frame = ((uint8_t*)descriptor) + sizeof(PacketDescriptorType2_t);
mhdr.ts = descriptor->Timestamp; frame = ((uint8_t*)descriptor) + sizeof(PacketDescriptorType2_t);
mhdr.ifindex = 0; // ?
mhdr.caplen = descriptor->StoredLength;
mhdr.wlen = descriptor->WireLength;
// ? TODO - modify third argument to pass test_packet_read mhdr.ts = descriptor->Timestamp;
mapid_process_pkt(&i->mapidlib, (unsigned char*)frame, frame + (descriptor->StoredLength - descriptor->WireLength), &mhdr); mhdr.ifindex = descriptor->Channel;
mhdr.caplen = descriptor->StoredLength;
mhdr.wlen = descriptor->WireLength;
// ? TODO - modify third argument to pass test_packet_read
mapid_process_pkt(&i->mapidlib, (unsigned char*)frame, frame + (descriptor->StoredLength - descriptor->WireLength), &mhdr);
/* Avance to the next packet. */ /* Avance to the next packet. */
descriptor = (PacketDescriptorType2_t*)((uint8_t*)descriptor + descriptor->StoredLength); descriptor = (PacketDescriptorType2_t*)((uint8_t*)descriptor + descriptor->StoredLength);
} }
} }
return 0; return 0;
} }
static unsigned static unsigned
process_pkts_offline(void *buf,unsigned len, napatech_instance_t *i) process_pkts_offline(void *buf,unsigned len, napatech_instance_t *i)
{ {
DEBUG_CMD(Debug_Message("napatechdrv: process_pkts_offline")); DEBUG_CMD(Debug_Message("napatechdrv: process_pkts_offline"));
...@@ -262,7 +262,7 @@ static void ...@@ -262,7 +262,7 @@ static void
mapidrv_proc_loop (void *arg) mapidrv_proc_loop (void *arg)
{ {
DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_proc_loop")); DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_proc_loop"));
int devid = *(int *)arg; int devid = *(int *)arg;
napatech_instance_t *i=flist_get(devlist,devid); napatech_instance_t *i=flist_get(devlist,devid);
int err; int err;
...@@ -278,7 +278,7 @@ mapidrv_proc_loop (void *arg) ...@@ -278,7 +278,7 @@ mapidrv_proc_loop (void *arg)
DEBUG_CMD(Debug_Message("ERROR: pthread_setcanceltype failed (%s)",strerror(err))); DEBUG_CMD(Debug_Message("ERROR: pthread_setcanceltype failed (%s)",strerror(err)));
return; return;
} }
if ((err=pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL)) != 0) { if ((err=pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL)) != 0) {
DEBUG_CMD(Debug_Message("ERROR: pthread_setcancelstate (%s) failed", strerror(err))); DEBUG_CMD(Debug_Message("ERROR: pthread_setcancelstate (%s) failed", strerror(err)));
return; return;
...@@ -287,22 +287,22 @@ mapidrv_proc_loop (void *arg) ...@@ -287,22 +287,22 @@ mapidrv_proc_loop (void *arg)
while (1) while (1)
{ {
// DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_proc_loop; i->napatechhandle: %d; i->packetfeedhandle: %d", i->napatechhandle, i->packetfeedhandle)); // DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_proc_loop; i->napatechhandle: %d; i->packetfeedhandle: %d", i->napatechhandle, i->packetfeedhandle));
result = NTCI_GetNextBuffer(i->napatechhandle, result = NTCI_GetNextBuffer(i->napatechhandle,
i->packetfeedhandle, i->packetfeedhandle,
STID_BUFFER_REQUEST_SAMPLED_TYPE2, STID_BUFFER_REQUEST_SAMPLED_TYPE2,
&request, &request,
STID_BUFFER_INFORMATION_SECTION_TYPE1, STID_BUFFER_INFORMATION_SECTION_TYPE1,
&bufferInformation); &bufferInformation);
if(result == NTCI_ERRCODE_SUCCESS) { if(result == NTCI_ERRCODE_SUCCESS) {
if(bufferInformation.numDescriptorsAvailable > 0) process_pkts(&bufferInformation, i); if(bufferInformation.numDescriptorsAvailable > 0) process_pkts(&bufferInformation, i);
NTCI_ReleaseBuffer(i->napatechhandle, NTCI_ReleaseBuffer(i->napatechhandle,
i->packetfeedhandle, i->packetfeedhandle,
STID_BUFFER_INFORMATION_SECTION_TYPE1, STID_BUFFER_INFORMATION_SECTION_TYPE1,
&bufferInformation); &bufferInformation);
} else if(result != NTCI_STATUSCODE_NO_PACKETS_AVAILABLE) { } else if(result != NTCI_STATUSCODE_NO_PACKETS_AVAILABLE) {
DEBUG_CMD(Debug_Message("Failed to get buffers. Error code %d\n", result)); //stderr DEBUG_CMD(Debug_Message("Failed to get buffers. Error code %d\n", result)); //stderr
break; break;
...@@ -368,15 +368,15 @@ mapidrv_create_flow (int devid, int fd, char **devtype) ...@@ -368,15 +368,15 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
if(devid < 0) if(devid < 0)
{ {
napatech_instance_t *inst=flist_get(devlist,devid); napatech_instance_t *inst=flist_get(devlist,devid);
*devtype=MAPI_DEVICE_NAPATECH; *devtype=MAPI_DEVICE_NAPATECH;
inst->hwinfo.offline=1; inst->hwinfo.offline=1;
inst->hwinfo.cap_length=1500; inst->hwinfo.cap_length=1500;
inst->hwinfo.devtype=MAPI_DEVICE_NAPATECH; inst->hwinfo.devtype=MAPI_DEVICE_NAPATECH;
inst->hwinfo.devid=inst->id; inst->hwinfo.devid=inst->id;
inst->hwinfo.pkts=0; inst->hwinfo.pkts=0;
DEBUG_CMD(Debug_Message("Reading from trace file: %s", inst->name)); DEBUG_CMD(Debug_Message("Reading from trace file: %s", inst->name));
return mapid_add_flow(&inst->mapidlib,fd,&inst->hwinfo,NULL); return mapid_add_flow(&inst->mapidlib,fd,&inst->hwinfo,NULL);
...@@ -385,9 +385,9 @@ mapidrv_create_flow (int devid, int fd, char **devtype) ...@@ -385,9 +385,9 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
i=flist_get(devlist,devid); i=flist_get(devlist,devid);
i->hwinfo.offline=0; i->hwinfo.offline=0;
*devtype=MAPI_DEVICE_NAPATECH; *devtype=MAPI_DEVICE_NAPATECH;
//Open device if it is not already open //Open device if it is not already open
if (i->napatechhandle == NULL) if (i->napatechhandle == NULL)
{ {
...@@ -396,31 +396,31 @@ mapidrv_create_flow (int devid, int fd, char **devtype) ...@@ -396,31 +396,31 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
DEBUG_CMD(Debug_Message("mapinapatechdrv: mapidrv_create_flow; Trying to open NTCI based adapter #%d\n", i->name[strlen(i->name) - 1] - '0')); DEBUG_CMD(Debug_Message("mapinapatechdrv: mapidrv_create_flow; Trying to open NTCI based adapter #%d\n", i->name[strlen(i->name) - 1] - '0'));
if(strstr(i->name, "xyxs") != NULL) { if(strstr(i->name, "xyxs") != NULL) {
/* X card series. */ /* X card series. */
DEBUG_CMD(Debug_Message("mapinapatechdrv: mapidrv_create_flow; Opening X card series.")); DEBUG_CMD(Debug_Message("mapinapatechdrv: mapidrv_create_flow; Opening X card series."));
i->napatechhandle = NTCI_OpenCard(NTCI_CARD_TYPE_ANY, i->name[strlen(i->name) - 1] - '0'); i->napatechhandle = NTCI_OpenCard(NTCI_CARD_TYPE_ANY, i->name[strlen(i->name) - 1] - '0');
} else if(strstr(i->name, "ntx") != NULL) { } else if(strstr(i->name, "ntx") != NULL) {
DEBUG_CMD(Debug_Message("mapinapatechdrv: mapidrv_create_flow; Opening ntxc card series.")); DEBUG_CMD(Debug_Message("mapinapatechdrv: mapidrv_create_flow; Opening ntxc card series."));
i->napatechhandle = NTCI_OpenCard(NTCI_ANY_NAPATECH_CARD_TYPE, i->name[strlen(i->name) - 1] - '0'); i->napatechhandle = NTCI_OpenCard(NTCI_ANY_NAPATECH_CARD_TYPE, i->name[strlen(i->name) - 1] - '0');
} }
if(i->napatechhandle==NULL) { if(i->napatechhandle==NULL) {
DEBUG_CMD(Debug_Message("mapinapatechdrv: mapidrv_create_flow; Failed to open adapter.\n")); DEBUG_CMD(Debug_Message("mapinapatechdrv: mapidrv_create_flow; Failed to open adapter.\n"));
return NTCI_ERRCODE_NO_DEVICE_OPEN; // TODO return NTCI_ERRCODE_NO_DEVICE_OPEN; // TODO
} }
i->hwinfo.devfd = (int)i->napatechhandle; i->hwinfo.devfd = (int)i->napatechhandle;
i->hwinfo.cap_length=0; i->hwinfo.cap_length=0;
/* TODO cap_length from hw */ /* TODO cap_length from hw */
if (i->hwinfo.cap_length==0) { if (i->hwinfo.cap_length==0) {
DEBUG_CMD(Debug_Message("WARNING: Could not get info hardware-info, using default = 1500")); DEBUG_CMD(Debug_Message("WARNING: Could not get info hardware-info, using default = 1500"));
i->hwinfo.cap_length=1500; i->hwinfo.cap_length=1500;
} }
DEBUG_CMD(Debug_Message("mapinapatechdrv: mapidrv_create_flow; NTCI_CardIdentification() = %d", NTCI_CardIdentification(i->napatechhandle))); DEBUG_CMD(Debug_Message("mapinapatechdrv: mapidrv_create_flow; NTCI_CardIdentification() = %d", NTCI_CardIdentification(i->napatechhandle)));
if((result = NTCI_GetCapabilities(i->napatechhandle, if((result = NTCI_GetCapabilities(i->napatechhandle,
CAPID_HARDWARE, CAPID_HARDWARE,
NOT_SUB_CAPABILITIES, NOT_SUB_CAPABILITIES,
STID_CARD_HARDWARE_CAPABILITIES_TYPE1, STID_CARD_HARDWARE_CAPABILITIES_TYPE1,
...@@ -428,11 +428,11 @@ mapidrv_create_flow (int devid, int fd, char **devtype) ...@@ -428,11 +428,11 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
DEBUG_CMD(Debug_Message(stderr, "Error finding adapter capabilities: %i\n", result)); DEBUG_CMD(Debug_Message(stderr, "Error finding adapter capabilities: %i\n", result));
} }
channelsBitmask = cardCapabilities.totalChannelsBitmask; channelsBitmask = cardCapabilities.totalChannelsBitmask;
if (NTCI_CardIdentification(i->napatechhandle)==NT_CARD_TYPE) { if (NTCI_CardIdentification(i->napatechhandle)==NT_CARD_TYPE) {
/* Check if we need to use NTPL to set up feeds. */ /* Check if we need to use NTPL to set up feeds. */
if((result = NTCI_GetCapabilities(i->napatechhandle, if((result = NTCI_GetCapabilities(i->napatechhandle,
CAPID_VERSION, CAPID_VERSION,
...@@ -463,7 +463,7 @@ mapidrv_create_flow (int devid, int fd, char **devtype) ...@@ -463,7 +463,7 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
} else { } else {
channelsBitmask = 0; channelsBitmask = 0;
} }
} }
break; break;
default: default:
// DEBUG_MSG(Debug_Message("Unsupported FPGA!")); // ? // DEBUG_MSG(Debug_Message("Unsupported FPGA!")); // ?
...@@ -479,10 +479,10 @@ mapidrv_create_flow (int devid, int fd, char **devtype) ...@@ -479,10 +479,10 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
/* Set up the packet feed engine for a single feed. /* Set up the packet feed engine for a single feed.
* *
* The feedPriorities array is used to assign the * The feedPriorities array is used to assign the
* priorities of different feeds when creating multiple * priorities of different feeds when creating multiple
* simultaneous feeds; in this example it is redundant * simultaneous feeds; in this example it is redundant
* as only one entry is required */ * as only one entry is required */
DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_create_flow; NTCI_SetupPacketFeedEngine(%d, %d, %d)", i->napatechhandle, 1, feedPriorities[0])); DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_create_flow; NTCI_SetupPacketFeedEngine(%d, %d, %d)", i->napatechhandle, 1, feedPriorities[0]));
...@@ -492,30 +492,30 @@ mapidrv_create_flow (int devid, int fd, char **devtype) ...@@ -492,30 +492,30 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
return -1; return -1;
} }
/* Create the packet feed. /* Create the packet feed.
* *
* First, initialise the feedConfig structure */ * First, initialise the feedConfig structure */
/* provide packets in sections */ /* provide packets in sections */
feedConfig.bufferType = BUFFER_SECTION; feedConfig.bufferType = BUFFER_SECTION;
/* hardware native timestamps */ /* hardware native timestamps */
feedConfig.timestampType = TIMESTAMP_NATIVE; feedConfig.timestampType = TIMESTAMP_NATIVE;
/* do not deliver corrupted packets */ /* do not deliver corrupted packets */
feedConfig.dropErroredPacketsFlag = 0; feedConfig.dropErroredPacketsFlag = 0;
/* slicing is disabled */ /* slicing is disabled */
feedConfig.sliceLength = 0; feedConfig.sliceLength = 0;
/* large samples are used: these better handle network /* large samples are used: these better handle network
* traffic fluctuations */ * traffic fluctuations */
feedConfig.bufferBehaviour = SMALL_REGULAR_SAMPLES; feedConfig.bufferBehaviour = SMALL_REGULAR_SAMPLES;
/* Create the packet feed. /* Create the packet feed.
* *
* PACKET_FEED_SOURCE_SAMPLED is used to specify real time * PACKET_FEED_SOURCE_SAMPLED is used to specify real time
* sampling of network traffic. */ * sampling of network traffic. */
if((result = NTCI_CreatePacketFeed(i->napatechhandle, if((result = NTCI_CreatePacketFeed(i->napatechhandle,
0, 0,
channelsBitmask, channelsBitmask,
...@@ -526,7 +526,7 @@ mapidrv_create_flow (int devid, int fd, char **devtype) ...@@ -526,7 +526,7 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
&i->packetfeedhandle)) != NTCI_ERRCODE_SUCCESS) { &i->packetfeedhandle)) != NTCI_ERRCODE_SUCCESS) {
DEBUG_CMD(Debug_Message("Failed to create a packet feed (%i)\n", result)); //stderr DEBUG_CMD(Debug_Message("Failed to create a packet feed (%i)\n", result)); //stderr
NTCI_CloseCard(i->napatechhandle); NTCI_CloseCard(i->napatechhandle);
return -1; return -1;
} }
if(channelsBitmask == 0) { if(channelsBitmask == 0) {
...@@ -534,7 +534,7 @@ mapidrv_create_flow (int devid, int fd, char **devtype) ...@@ -534,7 +534,7 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
command.WriteHW = TRUE; command.WriteHW = TRUE;
sprintf(command.achFilterString, "Capture[Priority=0;Feed=0]=ALL"); sprintf(command.achFilterString, "Capture[Priority=0;Feed=0]=ALL");
/* TODO - preclasification ^^^ */ /* TODO - preclasification ^^^ */
if((result = NTCI_PacketClassification(i->napatechhandle, if((result = NTCI_PacketClassification(i->napatechhandle,
STID_PASS_FILTER, STID_PASS_FILTER,
&command)) != NTCI_ERRCODE_SUCCESS) { &command)) != NTCI_ERRCODE_SUCCESS) {
...@@ -542,7 +542,7 @@ mapidrv_create_flow (int devid, int fd, char **devtype) ...@@ -542,7 +542,7 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
result = NTCI_PacketClassification(i->napatechhandle, result = NTCI_PacketClassification(i->napatechhandle,
STID_GET_FILTER_ERROR, STID_GET_FILTER_ERROR,
&error); &error);
DEBUG_CMD(Debug_Message("%s\n",error.achFilterError1)); // stderr DEBUG_CMD(Debug_Message("%s\n",error.achFilterError1)); // stderr
DEBUG_CMD(Debug_Message("%s\n",error.achFilterError2)); // stderr DEBUG_CMD(Debug_Message("%s\n",error.achFilterError2)); // stderr
DEBUG_CMD(Debug_Message("%s\n",error.achFilterError3)); // stderr DEBUG_CMD(Debug_Message("%s\n",error.achFilterError3)); // stderr
...@@ -552,16 +552,16 @@ mapidrv_create_flow (int devid, int fd, char **devtype) ...@@ -552,16 +552,16 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
} }
// i->packetfeedhandle = packetFeedHandle; // i->packetfeedhandle = packetFeedHandle;
if((result = NTCI_StartPacketFeed(i->napatechhandle, i->packetfeedhandle)) != NTCI_ERRCODE_SUCCESS) { if((result = NTCI_StartPacketFeed(i->napatechhandle, i->packetfeedhandle)) != NTCI_ERRCODE_SUCCESS) {
DEBUG_CMD(Debug_Message("Error while starting packet feed (%i)\n", result)); // stderr DEBUG_CMD(Debug_Message("Error while starting packet feed (%i)\n", result)); // stderr
NTCI_CloseCard(i->napatechhandle); NTCI_CloseCard(i->napatechhandle);
return -1; return -1;
} }
/* find the location of the feed buffer where new /* find the location of the feed buffer where new
* data will be stored */ * data will be stored */
if((result = NTCI_GetPacketFeedBuffers(i->napatechhandle, if((result = NTCI_GetPacketFeedBuffers(i->napatechhandle,
i->packetfeedhandle, i->packetfeedhandle,
STID_FEED_BUFFER_INFORMATION_TYPE1, STID_FEED_BUFFER_INFORMATION_TYPE1,
&i->bufferInfo)) != NTCI_ERRCODE_SUCCESS) { &i->bufferInfo)) != NTCI_ERRCODE_SUCCESS) {
...@@ -577,14 +577,14 @@ mapidrv_create_flow (int devid, int fd, char **devtype) ...@@ -577,14 +577,14 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
DEBUG_CMD(Debug_Message("ERROR: pthread_attr_init failed")); DEBUG_CMD(Debug_Message("ERROR: pthread_attr_init failed"));
return DAGDRV_PTHR_ERR; // TODO return DAGDRV_PTHR_ERR; // TODO
} }
if (pthread_create(&i->th_proc, &i->th_attr, (void *) mapidrv_proc_loop, (void *) &(i->id)) != 0) if (pthread_create(&i->th_proc, &i->th_attr, (void *) mapidrv_proc_loop, (void *) &(i->id)) != 0)
{ {
DEBUG_CMD(Debug_Message("ERROR: pthread_create failed")); DEBUG_CMD(Debug_Message("ERROR: pthread_create failed"));
return DAGDRV_PTHR_ERR; // TODO return DAGDRV_PTHR_ERR; // TODO
} }
} }
DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_create_flow_; i->napatechhandle: %d; i->packetfeedhandle: %d", i->napatechhandle, i->packetfeedhandle)); DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_create_flow_; i->napatechhandle: %d; i->packetfeedhandle: %d", i->napatechhandle, i->packetfeedhandle));
return mapid_add_flow(&i->mapidlib,fd,&i->hwinfo,NULL); return mapid_add_flow(&i->mapidlib,fd,&i->hwinfo,NULL);
...@@ -613,18 +613,18 @@ mapidrv_connect (int devid,int fd) ...@@ -613,18 +613,18 @@ mapidrv_connect (int devid,int fd)
{ {
DEBUG_CMD(Debug_Message("ERROR: pthread_create failed")); DEBUG_CMD(Debug_Message("ERROR: pthread_create failed"));
return NICDRV_PTHR_ERR; return NICDRV_PTHR_ERR;
} }
} }
return ret; return ret;
} }
int int
mapidrv_start_offline_device( int devid) mapidrv_start_offline_device( int devid)
{ {
DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_start_offline_device")); DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_start_offline_device"));
napatech_instance_t *i = flist_get(devlist,devid); napatech_instance_t *i = flist_get(devlist,devid);