Commit 9144c19e authored by Jon Kåre Hellan's avatar Jon Kåre Hellan
Browse files

Port to modern Napatech API. Debian package 201205-02-1.


git-svn-id: file:///home/svn/mapi/branches/mapi_uninett@1613 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent de79370e
mapi (2.0.uninett.20120502-1) unstable; urgency=low
* Port to modern Napatech API. svn version 1613.
-- Jon K Hellan <jon.kare.hellan@uninett.no> Wed, 02 May 2012 10:12:43 +0200
mapi (2.0.uninett.20120323-1) unstable; urgency=low
* Make LSB init depend on $all so that mapi can't start before monitoring card is ready.
......
......@@ -3,7 +3,7 @@ Section: net
Priority: optional
Maintainer: Jon K Hellan <jon.kare.hellan@uninett.no>
Build-Depends: debhelper (>= 5), libnids-dev
Standards-Version: 3.8.0
Standards-Version: 3.9.1
Package: mapi
Architecture: i386
......
......@@ -22,6 +22,7 @@
#include "flist.h"
#include "debug.h"
#include "mapi_errors.h"
#include "mapinapatechdrv.h"
#define bool_t int
......@@ -119,7 +120,7 @@ int mapidrv_add_device(const char *devname, int file,int devid, global_function_
i->file=file;
// i->th_proc=0;
i->hwinfo.offline=0;
i->hwinfo.devfd=i->napatechhandle;
i->hwinfo.devfd=(int)i->napatechhandle;
i->hwinfo.gflist=gflist;
i->hwinfo.pkt_drop=0;
i->offline_status = olstatus;
......@@ -207,24 +208,24 @@ process_pkts(BufferInformationSectionType1_t* bufferInformation, napatech_instan
// FIXME: Should this not be PacketDescriptorNtSeriesType1_t for NT cards?
// The fields used are the same in both, but the rest is different. Might cause confusion later on.
PacketDescriptorType2_t *descriptor = (PacketDescriptorType2_t *)(((uint8_t*)(i->bufferInfo.bufferBaseAddress)) + bufferInformation->sectionOffset);
PacketDescriptorNtSeriesType1_t *descriptor = (PacketDescriptorNtSeriesType1_t *)(((uint8_t*)(i->bufferInfo.bufferBaseAddress)) + bufferInformation->sectionOffset);
// 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++) {
i->hwinfo.pkts++;
PacketExtDescriptorType05_t *pExtDescr = (PacketExtDescriptorType05_t*)(((uint8_t*)descriptor) + sizeof(PacketDescriptorType2_t));
PacketExtDescriptorType05_t *pExtDescr = (PacketExtDescriptorType05_t*)(((uint8_t*)descriptor) + sizeof(PacketDescriptorNtSeriesType1_t));
frame = ((uint8_t*)descriptor);
printf("timestamp: %llu\n", descriptor->Timestamp);
mhdr.ts = ((4503599*(descriptor->Timestamp>>32))>>20)|(descriptor->Timestamp<<32) ;
mhdr.ifindex = descriptor->Channel;
mhdr.caplen = descriptor->StoredLength;
mhdr.wlen = descriptor->WireLength;
printf("timestamp: %llu\n", descriptor->timestamp);
mhdr.ts = ((4503599*(descriptor->timestamp>>32))>>20)|(descriptor->timestamp<<32) ;
mhdr.ifindex = descriptor->channel;
mhdr.caplen = descriptor->storedLength;
mhdr.wlen = descriptor->wireLength;
// Layer 2 type. (0:EtherII, 1:LLC, 2:SNAP, 3:Novell RAW)
switch(pExtDescr->l2Type) {
......@@ -240,10 +241,10 @@ process_pkts(BufferInformationSectionType1_t* bufferInformation, napatech_instan
}
// ? TODO - modify third argument to pass test_packet_read
mapid_process_pkt(&i->mapidlib, (unsigned char*)frame, frame + sizeof(PacketDescriptorType2_t) + (descriptor->ExtensionLength << 3), &mhdr);
mapid_process_pkt(&i->mapidlib, (unsigned char*)frame, frame + sizeof(PacketDescriptorNtSeriesType1_t) + (descriptor->extensionLength << 3), &mhdr);
/* Avance to the next packet. */
descriptor = (PacketDescriptorType2_t*)((uint8_t*)descriptor + descriptor->StoredLength);
descriptor = (PacketDescriptorNtSeriesType1_t*)((uint8_t*)descriptor + descriptor->storedLength);
}
} else {
for(packet=0; packet < bufferInformation->numDescriptorsAvailable; packet++) {
......@@ -252,24 +253,25 @@ process_pkts(BufferInformationSectionType1_t* bufferInformation, napatech_instan
frame = ((uint8_t*)descriptor);
//Todo: temporary solution.
mhdr.ts = ((4503599*(descriptor->Timestamp>>32))>>20)|(descriptor->Timestamp<<32) ;
mhdr.ifindex = descriptor->Channel;
mhdr.caplen = descriptor->StoredLength;
mhdr.wlen = descriptor->WireLength;
mhdr.ts = ((4503599*(descriptor->timestamp>>32))>>20)|(descriptor->timestamp<<32) ;
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 + sizeof(PacketDescriptorType2_t), &mhdr);
mapid_process_pkt(&i->mapidlib, (unsigned char*)frame, frame + sizeof(PacketDescriptorNtSeriesType1_t), &mhdr);
/* Avance to the next packet. */
descriptor = (PacketDescriptorType2_t*)((uint8_t*)descriptor + descriptor->StoredLength);
descriptor = (PacketDescriptorNtSeriesType1_t*)((uint8_t*)descriptor + descriptor->storedLength);
}
}
return 0;
}
#if 0
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"));
......@@ -278,9 +280,10 @@ process_pkts_offline(void *buf,unsigned len, napatech_instance_t *i)
return 0;
}
#endif
static void
mapidrv_offline_proc_loop(void *arg)
mapidrv_offline_proc_loop(__attribute__((__unused__)) void *arg)
{
DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_offline_proc_loop"));
......@@ -372,11 +375,12 @@ int mapidrv_get_flow_info(int devid,int fd,mapi_flow_info_t *info) {
}
int
mapidrv_create_offline_flow (int devid, int format,int fd,char **devtype)
mapidrv_create_offline_flow (__attribute__((__unused__)) int devid, __attribute__((__unused__)) int format,
__attribute__((__unused__)) int fd, __attribute__((__unused__)) char **devtype)
{
DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_create_offline_flow"));
napatech_instance_t *i=flist_get(devlist,devid);
__attribute__((__unused__)) napatech_instance_t *i=flist_get(devlist,devid);
/* TODO */
......@@ -455,29 +459,24 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
i->hwinfo.link_type=DLT_EN10MB; // TODO
DEBUG_CMD(Debug_Message("mapinapatechdrv: mapidrv_create_flow; NTCI_CardIdentification() = %d", NTCI_CardIdentification(i->napatechhandle)));
if((result = NTCI_GetCapabilities(i->napatechhandle,
CAPID_HARDWARE,
NOT_SUB_CAPABILITIES,
STID_CARD_HARDWARE_CAPABILITIES_TYPE1,
&cardCapabilities)) != NTCI_ERRCODE_SUCCESS) {
DEBUG_CMD(Debug_Message(stderr, "Error finding adapter capabilities: %i\n", result));
DEBUG_CMD(Debug_Message("Error finding adapter capabilities: %i\n", result));
}
channelsBitmask = cardCapabilities.totalChannelsBitmask;
if (NTCI_CardIdentification(i->napatechhandle)==NT_CARD_TYPE) {
/* Check if we need to use NTPL to set up feeds. */
if((result = NTCI_GetCapabilities(i->napatechhandle,
CAPID_VERSION,
NOT_SUB_CAPABILITIES,
STID_CARD_HARDWARE_VERSION_CAPABILITIES_TYPE3,
&data3)) != NTCI_ERRCODE_SUCCESS) {
DEBUG_CMD(Debug_Message(stderr, "Error finding HW capabilities: %i\n", result));
DEBUG_CMD(Debug_Message("Error finding HW capabilities: %i\n", result));
}
switch (data3.AdapterCard.dwInfoType) {
......@@ -513,14 +512,12 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
break;
default:
// DEBUG_MSG(Debug_Message("Unsupported FPGA!")); // ?
return;
return -1;
}
// FIXME: This completely discards the previous MultiFeed check, maybe it (the check) is unnecessary?
channelsBitmask = cardCapabilities.totalChannelsBitmask;
} /* if (NTCI_CardIdentification(i->napatechhandle)==NT_CARD_TYPE) */
i->hwinfo.devtype=MAPI_DEVICE_NAPATECH_NT;
i->hwinfo.devid=i->id;
i->hwinfo.pkts=0;
......@@ -546,22 +543,11 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
/* Create the packet feed.
*
* First, initialise the feedConfig structure */
/* provide packets in sections */
feedConfig.bufferType = BUFFER_SECTION;
/* hardware native timestamps */
feedConfig.timestampType = TIMESTAMP_PCAP_NANOTIME;
/* do not deliver corrupted packets */
feedConfig.dropErroredPacketsFlag = 0;
/* slicing is disabled */
feedConfig.sliceLength = 0;
/* large samples are used: these better handle network
* traffic fluctuations */
feedConfig.bufferBehaviour = SMALL_REGULAR_SAMPLES;
/* Create the packet feed.
*
* PACKET_FEED_SOURCE_SAMPLED is used to specify real time
......@@ -593,6 +579,11 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
return -1;
}
if ((descr.descriptorType != STANDARD_DESCRIPTOR) || (descr.timestampType != TIMESTAMP_PCAP_NANOTIME)) {
DEBUG_CMD(Debug_Message("Feed config should specify %s and %s\n",
"TimeStampFormat=PCAP_NANOTIME", "DescriptorType=STANDARD")); //stderr
return -1;
}
i->packetfeedhandle=descr.handle;
channelsBitmask=descr.channelsBitmask;
......@@ -668,7 +659,7 @@ mapidrv_start_offline_device( int devid)
{
DEBUG_CMD(Debug_Message("napatechdrv: mapidrv_start_offline_device"));
napatech_instance_t *i = flist_get(devlist,devid);
__attribute__((__unused__)) napatech_instance_t *i = flist_get(devlist,devid);
/* TODO */
......
......@@ -14,6 +14,7 @@
#include "mapi_errors.h"
#define bool_t unsigned int
#include <basetype.h>
#include <packetdescriptor.h>
typedef struct {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment