API

Reference Documentation

product_line_custom
Intel® PAC
Napatech SmartNIC
category
Reference Information
Napatech Software Suite: API

Functions

The NT_Init() function is used to determine if the functions in Napatech Software Suite has changed. It NT_Init() fails, you are advised to make code changes to support the current running system.

Each stream utilizes some or all of the following functions:

  • open() - opens a stream and return a stream handle
  • close() - closes a stream
  • read() - reads data from a stream
  • write() - writes data to a stream
  • get() - gets data from a stream and releases it again via the release() function
  • release() - releases data aquired via the get() function

The functions have the following naming convention, NT_<Stream name><Function>() which for example the Event stream is NT_EventOpen().

Note
The number and type of parameters might vary between streams.

Structures

3GD has two types of stream structures - stream handle structures, for example NtEventStream_t whose content is private to libNTAPI, and data structures, for example NtEvent_t.

The data structures are used to exchange data between applications and libNTAPI via the read()/write() variants. The data structures have a common structure:

// Each stream data structure has a enum containing the actions to be performed or parameters to read/write
enum Example_e {
EXAMPLE_UNKNOWN=0,
#ifndef DOXYGEN_DEPRECATED
EXAMPLE_PARMxxx_1,
#endif
EXAMPLE_PARMyyy_1,
EXAMPLE_PARMxxx_2
};
#ifndef DOXYGEN_DEPRECATED
// Example PARMxxx_1 structure (version 1 of xxx)
struct PARMxxx_1_s {
int var0; // These variables determine where and how to get/apply the data inside the data structure
int var1;
int var2;
// The <b>data</b> part of the structure is containing the data to exchange
struct PARMxxxData_1_s {
int data0;
int data1;
int data2;
} data;
};
#endif
// Example PARMyyy_1 structure (version 1 of yyy)
struct PARMyyy_1_s {
int var0;
int var1;
int var2;
struct PARMyyyData_1_s {
int data0;
int data1;
int data2;
} data;
};
// Example PARMxxx_2 structure (version 2 of xxx)
struct PARMxxx_2_s {
int var0;
struct PARMxxxData_2_s {
int data0;
int data1;
} data;
};
// Each stream data structure has the following layout, but not all might have both read and write sections
struct Example_s {
enum Example_e param ; // The action to perform or parameters to read write
// Union grouping the read/write structures
union {
#ifndef DOXYGEN_DEPRECATED
struct PARMxxx_1_s parmxxx1;
#endif
struct PARMyyy_1 s parmyyy1;
struct PARMxxx_2_s parmxxx2;
} u;
};

The structure above has the following benefits:

  1. Backward compability is ensured by adding new enumeration and structures while keeping the old ones in the code but suppressed from documentation.
  2. Only the newest enums and structures are documented, removing the need to choose between a number of enums and structures doing more or less the same thing.

Here is a pseudocode example on usage of the example structure above performing a read-modify-write.

...
struct Example_s example;
example.param = EXAMPLE_PARMxxx_2;
example.u.paramxxx2.var0 = 1;
read(handle, &example);
example.u.paramxxx2.data0 |= 1;
example.u.paramxxx2.data1 |= 2;
write(handle, &example);
...
}