stream_config.h

Reference Documentation

product_line_custom
Napatech SmartNIC
category
Reference Information

Go to the documentation of this file.

1/* 2 * %nt_SOFTWARE_LICENSE% 3 */ 4 5/** 6 * @file 7 * 8 * This header file is the STREAMTYPE_CONFIG interface 9 * 10 */ 11#ifndef __STREAM_CONFIG_H__ 12#define __STREAM_CONFIG_H__ 13 14#if !defined(__NT_H__) 15 #error: My interface file is 'nt.h'. Please include that via #include "nt.h" directly. 16#endif 17 18/** @addtogroup ConfigStream 19 * @{ 20 * 21 * Configuration streams are used to read and write configuration data 22 * and to set the filter configuration using NTPL commands. This 23 * includes everything that can be changed on the fly. All static 24 * configuration is done in the <tt>ntservice.ini</tt> file. 25 * 26 * All configuration parameters are organized in a parameter tree 27 * structure @ref NtConfig_t where some parameters are read only (static 28 * configuration parameters) and some parameters are read and write 29 * (dynamic configuration parameters). 30 * 31 * To open a configuration stream call @ref NT_ConfigOpen. Once the 32 * configuration stream is open use @ref NT_ConfigRead and @ref 33 * NT_ConfigWrite with the @ref NtConfig_t structure to retrieve and 34 * change the configuration. When done, call @ref NT_ConfigClose to close 35 * the stream. 36 * 37 * @note Changing a configuration setting will trigger an @ref 38 * NtEventSource_e::NT_EVENT_SOURCE_CONFIG 39 * "NT_EVENT_SOURCE_CONFIG" when the changes have been made. 40 * 41 * The configuration parameter types currently supported are: 42 * @li <tt>Port settings</tt> - retrieves or changes link speed, IFG, MDI mode 43 * @li <tt>Time stamp type</tt> Retrieves or changes time stamp configuration 44 * @li <tt>Time synchronization</tt> Retrieves or changes time synchronization configuration 45 * @li <tt>Sensor min/max alarm settings</tt> Retrieves or changes sensor min/max alarm limits configuration 46 * @li <tt>Coordinated time synchronized transmit</tt> Sets the coordinated time synchronized transmit configuration 47 * 48 * To set up or change filter configuration using NTPL commands use 49 * the @ref NT_NTPL function call on an open configuration stream. For 50 * a complete description of the NTPL syntax see @ref 51 * NtplOverview "NTPL Overview". 52 * 53 * For an example of using the configuration stream see @ref 54 * config/config_example.c "config/config_example.c". 55 * 56 * @note The config stream is not thread-safe. If the same stream handle is to be used by multiple threads, 57 * it must be mutex protected in the application. 58 * 59 */ 60#include "ntapi/commontypes.h" 61 62/** 63 * Configuration parameters 64 */ 65enum NtConfigParm_e { 66 NT_CONFIG_PARM_UNKNOWN=0, //!< Unknown command 67 NT_CONFIG_PARM_PORT_COMPAT_0 = 1, //!< Port settings configuration parameter - defined in stream_config_compat.h 68 NT_CONFIG_PARM_ADAPTER_TIMESTAMP, //!< Time stamp configuration parameter - use @ref NtConfigTimestampRead_s or @ref NtConfigTimestampWrite_s 69 NT_CONFIG_PARM_ADAPTER_TIMESYNC, //!< Time synchronization configuration parameter - use @ref NtConfigTimesyncWrite_s 70 NT_CONFIG_PARM_SENSOR, //!< Sensor configuration parameter - use @ref NtConfigSensor_s 71 NT_CONFIG_PARM_RESERVED_0, //!< Reserved 72 NT_CONFIG_PARM_BYPASS_ADAPTER, //!< Bypass adapter settings configuration parameter - use @ref NtConfigBypass_s 73 NT_CONFIG_PARM_BYPASS_PORT, //!< Bypass port settings configuration parameter - use @ref NtConfigBypass_s 74 NT_CONFIG_PARM_BYPASS_ADAPTER_WATCHDOG_TIMEOUT, //!< Bypass watchdog timeout setup configuration parameter - use @ref NtConfigBypassWatchdogTimeout_s 75 NT_CONFIG_PARM_BYPASS_PORT_WATCHDOG_TIMEOUT, //!< Bypass adapter port watchdog timeout setup configuration parameter - use @ref NtConfigBypassWatchdogTimeout_s 76 NT_CONFIG_PARM_BYPASS_ADAPTER_WATCHDOG_TIMER, //!< Bypass adapter watchdog settings configuration parameter - use @ref NtConfigBypassWatchdogTimer_s 77 NT_CONFIG_PARM_BYPASS_PORT_WATCHDOG_TIMER, //!< Bypass port watchdog settings configuration parameter - use @ref NtConfigBypassWatchdogTimer_s 78 NT_CONFIG_PARM_ADAPTER_GLOBAL_SYNC, //!< Enable/disable GlobalSync on the adapter - use @ref NtConfigGlobalSyncWrite_s 79 NT_CONFIG_PARM_NIM_ACCESS, //!< NIM data access for a Port - use @ref NtConfigNimAccess_s 80 NT_CONFIG_PARM_VPD, //!< VPD data access. - use @ref NtVpd_s 81 NT_CONFIG_PARM_PTP_PORT, //!< PTP port on PTP adapter - defined in stream_config_compat.h 82 NT_CONFIG_PARM_ADAPTER_TIMESYNC_RESET, //!< Timesync hard reset and PTP stat reset - use @ref NtConfigTimesyncReset_s 83 NT_CONFIG_PARM_ADAPTER_PTP_IMPL_CFG, //!< PTP configuration settings - use @ref NtConfigPtpImpl_s 84 NT_CONFIG_PARM_PORT_COMPAT_1, //!< Port settings configuration parameter - defined in stream_config_compat.h 85 NT_CONFIG_PARM_ADAPTER_MONITOR, //!< AdapterMonitor configuration parameter - use @ref NtConfigAdapterMonitor_s 86 NT_CONFIG_PARM_PORT_TRANSMIT_ON_TIMESTAMP, //!< Port TX time delta - use @ref NtConfigTransmitOnTimestamp_s 87 NT_CONFIG_PARM_PORT_SETTINGS_V2 //!< Port settings configuration parameter - use @ref NtConfigPort_v2_s 88}; 89 90/** 91 * Configuration stream handle 92 */ 93typedef struct NtConfigStream_s* NtConfigStream_t; 94 95/** 96 * Array of manual port setting parameters 97 */ 98struct NtPortSettingsManual_s { 99 enum NtLinkSpeed_e speed; //!< The interface speed - this is in effect if @ref NtLinkAutoNeg_e "autoNegotiation" = @ref NT_LINK_AUTONEG_MANUAL 100 enum NtLinkDuplex_e duplex; //!< The duplex mode - this is in effect if @ref NtLinkAutoNeg_e "autoNegotiation" = @ref NT_LINK_AUTONEG_MANUAL 101}; 102 103/** 104 * Array of parameters to be advertised when autonegotiation is enabled 105 */ 106struct NtPortSettingsAdvertise_s { 107 uint32_t halfDuplexMask; //!< Available half duplex (uses @ref NtLinkSpeed_e as bitmask) 108 uint32_t fullDuplexMask; //!< Available full duplex (uses @ref NtLinkSpeed_e as bitmask) 109}; 110 111 112/** 113 * The settings reflect how the interface should be configured. 114 * The advertise section tells what should be advertised when 115 * autonegotiation is enabled. 116 * halfDuplexMask=0. 117 * fullDuplexMask=NT_LINK_SPEED_100M. 118 * 119 * When a parameter does not apply on a particular adapter, then this parameter is ignored. 120 * 121 * @internal 122 * Note: This is part of the NTDS structure. Changing this requires the service to be recompiled. 123 */ 124struct NtPortSettings_v2_s { 125 int enable; //!< 0 = Disable interface, 1 = Enable interface. If disabled, the port will still be visible, but has status link down. 126#ifndef DOXYGEN_IGNORE 127 // Not supported 128 int flow; //!< 0 = No flow control, 1 = Flow control 129#endif 130 enum NtLinkMDI_e mdi; //!< MDI mode 131 /** 132 * NOTE: Cannot be set on optical NIM interfaces 133 */ 134 enum NtLinkAutoNeg_e autoNegotiation; //!< Link speed negotiation mode (manual or auto). 135 /** 136 * NOTE: Cannot be set on optical NIM interfaces 137 */ 138 struct NtPortSettingsManual_s manual; //!< Array of manual port setting parameters 139 /** 140 * NOTE: Cannot be set on optical NIM interfaces 141 */ 142 struct NtPortSettingsAdvertise_s advertise; //!< Array of parameters to be advertised when autonegotiation is enabled 143 144 uint32_t minIFG; //!< Depending on the IfgMode parameter in ntservice.ini the minimum interframe-gap is either interpreted as 10 ns steps or bytes. If IfgMode is set to NS the value will be rounded up or down to the nearest HW-supported value, which depends on the link speed. The default minimum gap is 0 ns. If the IfgMode is set to BYTE the value is written directly to the HW. 145 uint32_t maxIFG; //!< Depending on the IfgMode parameter in ntservice.ini the maximum interframe-gap is either interpreted as 10 ns steps or bytes. If the IfgMode is set to NS the value will be rounded up or down to the nearest HW-supported value, which depends on the link speed. The default maximum gap is the maximum HW-supported value. If the IfgMode is set to BYTE the value will be written directly to the HW. Setting the maximum interframe gap to 0, corresponds to disabling the check for maximum IFG. 146 147 enum NtTxPower_e TxPower; //!< TX power state on read and command on write. Controls laser power on/off on fiber SFP, XFP, SFP+ and QSFP+ modules. Note that not all modules support enable/disable of the laser. An error code is returned if not supported. 148 int hostLoopback; //!< Host loopback position.\n 149 //!< Applying host loopback has the effect that data sent from the host is looped 150 //!< back to the host on the same port regardless of, if a NIM (Network Interface 151 //!< Module) has been plugged in, and if a physical loopback has been applied. 152 //!< The link will therefore be reported as up despite that no NIM is present 153 //!< or that no physical link is present.\n 154 //!< In general simultaneous host and line loopback is not allowed.\n 155 //!< The available loopback positions are adapter dependent and applying a loopback 156 //!< position that is not supported will result in a returned error code by the API 157 //!< function. In general only the following values @ref NtHostLoopback_e should be 158 //!< used.\n 159 //!< Applying loopback along with settings that require PHY setup changes or 160 //!< applying these settings when already in loopback mode represents a conflict 161 //!< and will not be carried out. A returned error code will indicate this. In order 162 //!< to avoid conflicts, it is in general recommended to enable loopback separately.\n 163 //!< When applying loopback special settings are used and for trispeed modules 164 //!< this means that the link speed is changed to maximum. The original settings 165 //!< are restored when loopback is removed. 166 167 int lineLoopback; //!< Line loopback position.\n 168 //!< Applying line loopback has the effect that data sent from the line is looped 169 //!< back to the line on the same port. This requires that a NIM (Network Interface 170 //!< Module) has been plugged in. 171 //!< The link will in general be reported as up and traffic can be received by 172 //!< the host but any traffic transmitted by the host will be replaced by the 173 //!< traffic looped back. 174 //!< In general simultaneous host and line loopback is NOT allowed.\n 175 //!< The available loopback positions are adapter dependent and applying a loopback 176 //!< position that is not supported will result in a returned error code by the API 177 //!< function. In general only the following values @ref NtLineLoopback_e should be 178 //!< used.\n 179 //!< Applying loopback along with settings that require PHY setup changes or 180 //!< applying these settings when already in loopback mode represents a conflict 181 //!< and will not be carried out. A returned error code will indicate this. In order 182 //!< to avoid conflicts, it is in general recommended to enable loopback separately.\n 183 //!< When applying loopback special settings are used and for trispeed modules 184 //!< this means that the link speed is changed to maximum. The original settings 185 //!< are restored when loopback is removed. 186 enum NtPortId_e PortId; //!< Port identification state. 187 //!< Turns the port identification feature on/off. An error code is returned if 188 //!< not supported. 189 //!< When enabled the port led will start to blink regardless if the link is up 190 //!< or the port receives data or not. 191 int wisModeEnable; //!< 0 = Wismode disabled on port, 1 = Enable Wismode enabled on port. 192 int txReplicatePort; //!< Set TX port replication.\n 193 //!< An error code is returned if not supported or the configuration 194 //!< is invalid. 195 //!< When set to a different port it will replicate all TX traffic from that port. It will 196 //!< not be possible to transmit on this port when replication is activated. It is not 197 //!< possible to change the replication configuration while TX traffic is active on this port 198 //!< or the port it is replicating from. 199 uint64_t txPortRateLimit; //!< Set Tx port rate limit in bits per second.\n 200 //!< A value of zero disables the Tx port rate limit. 201 //!< The resulting ports speed will be an aproximated value close to the specified value. 202 //!< An error code is returned if not supported or the configuration is invalid. 203 //!< Special case: a value in the range of 1 to 100 specifies a limit as percentage of the link speed. 204}; 205 206/*********************************************************************** 207 * Config read and write port settings - NT_CONFIG_PARM_PORT_SETTINGS_V2 * 208 ***********************************************************************/ 209struct NtConfigPort_v2_s { 210 uint8_t portNo; //!< Port number to read from 211 uint8_t Reserved1[3]; 212 struct NtPortSettings_v2_s data; //!< Port settings 213}; 214 215/************************************************************ 216 * Config read timestamp - NT_CONFIG_PARM_ADAPTER_TIMESTAMP * 217 ************************************************************/ 218struct NtConfigTimestampRead_s { 219 uint8_t adapter; //!< Adapter number to read from 220 uint8_t Reserved1[3]; 221 struct NtConfigTimestampReadData_s { 222 uint64_t ts; //!< The time stamp 223 uint64_t nativeUnixTs; //!< Value converted to native Unix (read only) 224 enum NtTimestampType_e tsType; //!< The time stamp type used by the adapter 225 } data; 226}; 227 228/************************************************************* 229 * Config write timestamp - NT_CONFIG_PARM_ADAPTER_TIMESTAMP * 230 *************************************************************/ 231struct NtConfigTimestampWrite_s { 232 uint8_t adapter; //!< Adapter number to write to 233 uint8_t Reserved1[3]; 234 struct NtConfigTimestampWriteData_s { 235 uint64_t ts; //!< The time stamp 236 uint32_t bCurrent; //!< Uses current OS time 237 } data; 238}; 239 240/**************************************************************** 241 * Config write timesync data - NT_CONFIG_PARM_ADAPTER_TIMESYNC * 242 ****************************************************************/ 243struct NtConfigTimesyncWrite_s { 244 uint8_t adapter; //!< Adapter number to write to 245 uint8_t Reserved1[3]; 246 struct NtConfigTimesyncWriteData_s { 247 uint32_t action; //!< 0 = Reference time, 1 = Enable PPS, 2 = Disable PPS 248 uint64_t refTime; //!< PPS reference time 249 } data; 250}; 251 252 253 254/** 255 * TimeSync Reset commands 256 */ 257enum NtTimeSyncReset_e { 258 NT_TIMESYNC_RESET_INVALID = 0, 259 NT_TIMESYNC_RESET_COMPAT_0, //!< Command for backward compatibility - defined in stream_config_compat.h 260 NT_TIMESYNC_RESET_PTP_PORT_STAT, //!< Reset PTP port statistics 261 NT_TIMESYNC_RESET_HARD_RESET_TIME_TO_REF, //!< Hard reset Time to reference clock (temporary time jumps allowed) 262 NT_TIMESYNC_RESET_TS_STATISTICS //!< Reset global time sync statistics 263}; 264 265/***************************************************************** 266 * Config timesync reset - NT_CONFIG_PARM_ADAPTER_TIMESYNC_RESET * 267 *****************************************************************/ 268struct NtConfigTimesyncReset_s { 269 uint8_t adapter; //!< Adapter number to write to 270 uint8_t Reserved1[3]; 271 enum NtTimeSyncReset_e resetCmd; //!< Timesync reset command 272}; 273 274 275 276 277/***************************************************************** 278 * PTP configuration - NT_CONFIG_PARM_ADAPTER_PTP_IMPL_CFG * 279 *****************************************************************/ 280typedef struct NtConfigPtpImplData_s { 281 int32_t PTPDelayAsymmetry; //!< The PTP delay asymmetry compensation to set 282} NtConfigPtpImplData_t; 283 284struct NtConfigPtpImpl_s { 285 uint8_t adapter; //!< Adapter number to write to 286 uint8_t Reserved1[3]; 287 NtConfigPtpImplData_t data; 288}; 289 290 291 292/************************************************************ 293 * Config read or write sensor data - NT_CONFIG_PARM_SENSOR * 294 ************************************************************/ 295struct NtConfigSensor_s { 296 enum NtSensorSource_e source; //!< The source of the sensor - either a port or an adapter sensor 297 uint32_t sourceIndex; //!< The source index - either adapter number or port number on which the sensor resides 298 uint32_t sensorIndex; //!< The sensor index within the sensor group, see @ref MainDocMainFeaturesInfo_Sensors 299 struct NtConfigSensorData_s { 300 int32_t limitLow; //!< The minimum sensor value before an alarm is triggered 301 int32_t limitHigh; //!< The maximum sensor value before an alarm is triggered 302 } data; 303}; 304 305 306/************************************************************** 307 * Config globalsync - NT_CONFIG_PARM_ADAPTER_GLOBAL_SYNC * 308 **************************************************************/ 309 310struct NtConfigGlobalSyncWrite_s { 311 uint8_t adapterNo; //!< Adapter number to write to 312 uint8_t Reserved1[3]; 313 struct NtConfigWriteGlobalSyncData_s { 314 uint32_t portEnableMask; //!< Enable coordinated time synchronized transmit on port bit mask 315 uint64_t timeSynchronizedTxOffset; //!< Time offset between time stamp in first frame and adapter time 316 int timeSynchronizedTxOffsetUpdate; //!< Set to 1 to update the offset value 317 } data; 318}; 319 320/******************************************************** 321 * Structure for bypass related port settings 322 * 323 * cmd parm: NT_CONFIG_PARM_BYPASS_PORT 324 * NT_CONFIG_PARM_BYPASS_ADAPTER 325 ********************************************************/ 326typedef struct NtConfigBypassData_s { 327 enum NtBypassTrigger_e bypassTriggerModes; //!< Bypass triggers that affect bypass states using @ref NtBypassTrigger_e 328 enum NtBypassPortState_e currentBypassPortState; //!< Current (live) bypass state using @ref NtBypassPortState_e 329 enum NtBypassPortState_e onInitBypassPortState; //!< onInit bypass state using @ref NtBypassPortState_e 330 enum NtBypassPortState_e onPowerFailBypassPortState; //!< onPowerFail bypass state using @ref NtBypassPortState_e 331 enum NtBypassPortState_e onWatchdogFailBypassPortState; //!< onWatchdogFail bypass state using @ref NtBypassPortState_e 332 uint32_t onPowerFailBypassSwitchDelay; //!< onPowerFail bypass switch delay (msec) 333} NtConfigBypassData_t; 334 335struct NtConfigBypass_s { 336 union NtConfigBypassParam_u { //!< Input key parameter union 337 uint8_t adapterNo; //!< Adapter number to read from or write to 338 uint8_t portNo; //!< port number to read from or write to 339 uint32_t Reserved; 340 } u; 341 NtConfigBypassData_t data; 342}; 343 344 345/******************************************************** 346 * Structure for bypass watchdog timer pings "heartbeat" 347 * 348 * cmd parm: NT_CONFIG_PARM_BYPASS_PORT_WATCHDOG_TIMER 349 * NT_CONFIG_PARM_BYPASS_ADAPTER_WATCHDOG_TIMER 350 ********************************************************/ 351typedef struct NtConfigBypassWatchdogTimerData_s { 352 // 353 uint32_t bypassWatchdogTimeout; //!< Bypass watchdog timeout in msec. 354 uint32_t bypassWatchdogTimeRemaining; //!< Bypass watchdog remaining time before timeout (msec) 355} NtConfigBypassWatchdogTimerData_t; 356 357struct NtConfigBypassWatchdogTimer_s { 358 union NtConfigBypassWatchdogTimerParam_u { //!< Input key parameter union 359 uint8_t adapterNo; //!< Adapter number to read from or write to 360 uint8_t portNo; //!< port number to read from or write to 361 uint32_t Reserved; 362 } u; 363 NtConfigBypassWatchdogTimerData_t data; 364}; 365 366/******************************************************** 367 * Structure for bypass port watchdog timer setup 368 * 369 * cmd parm: NT_CONFIG_PARM_BYPASS_PORT_WATCHDOG_TIMEOUT 370 * NT_CONFIG_PARM_BYPASS_ADAPTER_WATCHDOG_TIMEOUT 371 ********************************************************/ 372typedef struct NtConfigBypassWatchdogTimeoutData_s { 373 uint32_t bypassWatchdogTimeout; //!< Bypass watchdog timeout (msec) 374} NtConfigBypassWatchdogTimeoutData_t; 375 376struct NtConfigBypassWatchdogTimeout_s { 377 union NtConfigBypassWatchdogTimeoutParam_u { //!< Input key parameter union 378 uint8_t adapterNo; //!< Adapter number to read from or write to 379 uint8_t portNo; //!< port number to read from or write to 380 uint32_t Reserved; 381 } u; 382 NtConfigBypassWatchdogTimeoutData_t data; 383}; 384 385struct NtConfigAdapterMonitor_s { 386 uint8_t adapter; //!< Adapter number to write to 387 unsigned portCtrlInterval; //!< Number of milliseconds between each scan 388 bool run; //!< Indicate if the thread should run 389}; 390 391/******************************************************** 392 * Structure to configure transmit on timestamp 393 * 394 * cmd parm: NT_CONFIG_PARM_PORT_TRANSMIT_ON_TIMESTAMP 395 * 396 ********************************************************/ 397struct NtConfigTransmitOnTimestamp_s { 398 uint8_t portNo; //!< Port to configure transmit on timestamp for 399 uint8_t Reserved[3]; 400 struct NtConfigTransmitOnTimestampData_s { 401 uint64_t timeDelta; //!< Delta in nanoseconds to add to packet time before comparing to adapter time 402 bool enable; //!< Enable transmit on timestamp 403 bool forceTxOnTs; //!< Force transmit on timestamp 404 uint64_t timeDeltaAdjust; //!< Delta in nanoseconds added by adapter to timeDelta whenever a TXSETCLOCK packet is encountered 405 } data; 406}; 407 408//***************************************************************************** 409//Structures and enums for accessing NIM via the config stream. 410//***************************************************************************** 411enum NtNimAccessType_e { 412 NT_NIM_READ_DATA_LIN, //!< Read NIM data using linear address convention 413//@G-- 414#ifdef DEBUG 415 NT_NIM_WRITE_DATA_LIN, //!< Write NIM data using linear address convention 416#endif 417//@G++ 418}; 419 420struct NtNimRawData_s { 421 uint16_t linAddr; 422 uint16_t length; 423 uint8_t data[512]; 424}; 425 426struct NtConfigNimAccess_s { 427 enum NtNimAccessType_e accessType; 428 uint8_t portNo; 429 uint8_t Reserved1[3]; 430 431 union NtNimAccess_u { 432 struct NtNimRawData_s rawData; 433 } u; 434}; 435 436typedef struct NtConfigNimAccess_s* NtConfigNimAccess_p; 437 438 439struct NtConfigPtpPortData_s { 440 /** @brief PTP active flag. 441 442On read: 0 = PTP is not active, 1 = PTP is active. 443On Write: Value is ignored. */ 444 int enable; 445 /** @brief PTP port enable flag. 446 447On read: 0 = PTP port is not enabled, 1 = PTP port is enabled. 448On Write: 0 = disable PTP port, 1 = enable PTP port. 449 450 A PTP port must be enabled to achieve link up. */ 451 int port_enable; 452 /** @brief Manual or auto negotiation of link speed and duplex mode. 453 454 This field specifies whether link speed and duplex mode of the 455PTP port is set manually or auto negotiated. */ 456 enum NtLinkAutoNeg_e autoNegotiation; 457 /** @brief Bit mask of manual port setting parameters. 458 459This field specifies the manually configured link speed and 460duplex mode of the PTP port. These values are ignored when 461auto negotiation is enabled.*/ 462 struct NtPortSettingsManual_s manual; 463 /** @brief The speeds to advertise during auto negotiation. 464 465This field is a bit mask of the speeds that are advertised 466during auto negotiation. These values are ignored when auto 467negotiation is disabled. */ 468 struct NtPortSettingsAdvertise_s advertise; 469}; 470typedef struct NtConfigPtpPortData_s NtConfigPtpPortData_t; 471 472 473/************************************************************************* 474 * Config read or write PTP port configuration - NT_CONFIG_PARM_PTP_PORT * 475 *************************************************************************/ 476struct NtConfigPtpPort_s { 477 uint8_t adapterNo; //!< Number of adapter with PTP functionality. 478 /** @brief PTP port number. 479 480 On Read: Always 0 (zero), currently. 481 On Write: Must be 0 (zero), currently. */ 482 uint8_t portNo; 483 uint8_t reserved[2]; //!< Reserved for future use. 484 NtConfigPtpPortData_t data; 485}; 486typedef struct NtConfigPtpPort_s NtConfigPtpPort_t; 487 488 489/****************************************************************/ 490/* NTPL Info data structures */ 491/****************************************************************/ 492/** 493 * NTPL command execution mode 494 */ 495enum NtNTPLCommands_e { 496 NT_NTPL_PARSER_VALIDATE_NORMAL, //!< NTPL expression is validated and executed 497 NT_NTPL_PARSER_VALIDATE_PARSE_ONLY, //!< NTPL expression is only validated and has no effect 498}; 499 500/** 501 * NTPL parser error description and error code 502 */ 503struct NtNtplParserErrorData_s { 504#define NT_MAX_NTPL_BUFFER_SIZE (4*1024) //!< NTPL maximum buffer size 505 char errBuffer[3][NT_MAX_NTPL_BUFFER_SIZE]; //!< NTPL error description 506 int32_t errCode; //!< NTPL error code 507}; 508 509#ifndef DOXYGEN_INTERNAL_ONLY 510/** 511 * NTPL filter counters. Deprecated. Use info stream instead. 512 */ 513struct NtNtplFilterCounters_s { 514 uint8_t sizeCount; //!< Number of frame length filters used 515 uint8_t protocolCount; //!< Number of protocol filters used 516 uint8_t errorCount; //!< Number of error filters used 517 uint8_t patternCount; //!< Number of data filters used 518 uint8_t dynOffsetCount; //!< Number of dynamic offsets used 519 uint8_t group4PlusCount; //!< Number of group filters used combining 4 patterns with 4 different dynamic offsets 520 uint8_t group8Count; //!< Number of group filters used combining 8 patterns with 2 different dynamic offsets 521}; 522#endif 523 524/** 525 * NTPL return values 526 */ 527enum NtNTPLReturnType_e { 528 NT_NTPL_PARSER_NORMAL, //!< No error data returned 529 NT_NTPL_PARSER_ERROR_DATA, //!< Error data returned - errorData is filled 530#ifndef DOXYGEN_INTERNAL_ONLY 531 NT_NTPL_PARSER_FILTERINFO, //!< Filter info data returned, see @ref NtNtplFilterCounters_s 532//@G-- 533 NT_NTPL_PARSER_TEXT_BUFFER=1000, //!< Filter info debug data returned 534//@G++ 535#endif 536}; 537 538/** 539 * NTPL Info 540 */ 541typedef struct NtNtplInfo_s { 542 enum NtNTPLReturnType_e eType; //!< Returned status 543 uint32_t ntplId; //!< ID of the NTPL command 544 int streamId; //!< The selected stream ID 545 uint64_t ts; //!< Time when the NTPL command is in effect 546 enum NtTimestampType_e timestampType; //!< The time stamp type of NtNtplInfo_t::ts 547 /** 548 * NTPL return data. 549 * Error or filter information. 550 */ 551#ifndef DOXYGEN_INTERNAL_ONLY 552 uint32_t reserved[50]; 553#endif 554 union NtplReturnData_u { 555 struct NtNtplParserErrorData_s errorData; //!< Error code and error text 556#ifndef DOXYGEN_INTERNAL_ONLY 557 struct NtNtplFilterCounters_s aFilterInfo[10]; // Deprecated. Use info stream instead 558//@G-- 559#define NT_NTPL_TEXT_BUFFER_SIZE 3*4*1024 560 char textBuffer[NT_NTPL_TEXT_BUFFER_SIZE]; //!< Text buffer for ntpl debug info 561//@G++ 562#endif 563 } u; 564} NtNtplInfo_t; 565 566 567/* Include commands for backward compatibility */ 568#if !defined(_NT_NTAPI_NO_COMPAT) 569#include "stream_config_compat.h" 570#endif 571 572/******************************************************** 573 * Structure for vpd access 574 ********************************************************/ 575#define VPD_USER_SIZE 400 576 577/** 578 * VPD commands 579 */ 580enum NtVpdCommands_e { 581 NT_VPD_USER_DATA 582}; 583 584typedef struct NtVpd_s { 585 uint8_t adapterNo; //!< Adapter number to write to 586 uint16_t length; //!< Length of data 587 enum NtVpdCommands_e vpdCommand; //!< VPD command using command @ref NtVpdCommands_e. 588 union data_u { 589 uint8_t userData[VPD_USER_SIZE]; //!< Userdata section of VPD 590 } u; 591} NtVpd_t; 592 593 594/************************************************************** 595 * Config change information 596 **************************************************************/ 597typedef struct NtConfig_s { 598 enum NtConfigParm_e parm; //!<Configuration parameter 599 union NtConfig_u { 600 struct NtConfigPort_v2_s portSettings_v2; //!< Port setting struct is used when reading or writing using command @ref NT_CONFIG_PARM_PORT_SETTINGS_V2 601#if !defined(_NT_NTAPI_NO_COMPAT) 602 struct NtConfigPort_v1_s portSettings_v1; //!< Port setting struct is used when reading or writing using command @ref NT_CONFIG_PARM_PORT_SETTINGS_V1 603#endif 604 struct NtConfigTimestampRead_s timestampRead; //!< Time stamp read struct is used when reading using command @ref NT_CONFIG_PARM_ADAPTER_TIMESTAMP 605 struct NtConfigTimestampWrite_s timestampWrite; //!< Time stamp write struct is used when writing using command @ref NT_CONFIG_PARM_ADAPTER_TIMESTAMP 606 struct NtConfigTimesyncWrite_s timesyncWrite; //!< Time sync write struct is used when writing using command @ref NT_CONFIG_PARM_ADAPTER_TIMESYNC 607 struct NtConfigSensor_s sensor; //!< Sensor read and write struct is used to read or write sensor alarm limits using command @ref NT_CONFIG_PARM_SENSOR 608 struct NtConfigGlobalSyncWrite_s globalSyncWrite; //!< Stream write struct is used when writing using command @ref NT_CONFIG_PARM_ADAPTER_GLOBAL_SYNC 609 struct NtConfigBypass_s bypassConfig; //!< Bypass adapter and port setting struct is used when reading or writing using commands @ref NT_CONFIG_PARM_BYPASS_PORT @ref NT_CONFIG_PARM_BYPASS_ADAPTER 610 struct NtConfigBypassWatchdogTimer_s bypassWatchdogTimer; //!< Bypass watchdog reading or writing using commands @ref NT_CONFIG_PARM_BYPASS_PORT_WATCHDOG_TIMER @ref NT_CONFIG_PARM_BYPASS_ADAPTER_WATCHDOG_TIMER 611 struct NtConfigBypassWatchdogTimeout_s bypassWatchdogTimeout; //!< Bypass watchdog reading or writing using commands @ref NT_CONFIG_PARM_BYPASS_PORT_WATCHDOG_TIMEOUT @ref NT_CONFIG_PARM_BYPASS_ADAPTER_WATCHDOG_TIMEOUT 612 struct NtConfigNimAccess_s nimAccess; //!< NIM data access using command @ref NT_CONFIG_PARM_NIM_ACCESS 613#if !defined(_NT_NTAPI_NO_COMPAT) 614 struct NtConfigSensor_s sensorWrite; //!< Sensor write struct is used when writing using command @ref NT_CONFIG_PARM_SENSOR 615#endif 616 struct NtVpd_s vpdData; //!< VPD write structure @ref NT_CONFIG_PARM_VPD 617 struct NtConfigPtpPort_s ptpPort; //!< PTP port configuation @ref NT_CONFIG_PARM_PTP_PORT 618 struct NtConfigTimesyncReset_s timesyncReset; //!< Time sync hard reset time command 619 struct NtConfigPtpImpl_s ptpImplCfg; //!< PTP configuration settings 620#if !defined(_NT_NTAPI_NO_COMPAT) 621 struct NtConfigPort_s portSettings; //!< Port setting struct defined in stream_config_compat.h 622#endif 623 struct NtConfigAdapterMonitor_s adapterMonitorSettings; //!< Adapter Monitor settings 624 struct NtConfigTransmitOnTimestamp_s transmitOnTimestamp; //!< Port transmit on timestamp settings 625 } u; 626} NtConfig_t; 627 628/** 629 * @brief Opens a configuration stream 630 * 631 * This function is called to retrieve a handle to a configuration stream 632 * 633 * @param[out] hStream Reference to an NtConfigStream_t stream pointer 634 * @param[in] name Stream friendly name - used in, for example, logging statements 635 * 636 * @retval 0 Success 637 * @retval !=0 Error 638 */ 639int NT_ConfigOpen(NtConfigStream_t *hStream, const char *name); 640 641/** 642 * @brief Closes a configuration stream 643 * 644 * This function is called to close a configuration stream 645 * 646 * @param[in] hStream Reference to a NtConfigStream_t stream pointer 647 * 648 * @retval 0 Success 649 * @retval !=0 Error 650 */ 651int NT_ConfigClose(NtConfigStream_t hStream); 652 653/** 654 * @brief Reads data from a configuration stream 655 * 656 * Returns configuration data 657 * 658 * @param[in] hStream NtSystemStream_t handle 659 * @param[in,out] data NtConfig_t structure containing configuration query and serving as output buffer for data 660 * 661 * @retval 0 Success 662 * @retval !=0 Error 663 */ 664int NT_ConfigRead(NtConfigStream_t hStream, NtConfig_t *data); 665 666/** 667 * @brief Writes data to a configuration stream 668 * 669 * Writes configuration data 670 * 671 * @param[in] hStream NtSystemStream_t handle 672 * @param[in,out] data NtConfig_t structure containing the configuration to write 673 * 674 * @retval 0 Success 675 * @retval !=0 Error 676 */ 677int NT_ConfigWrite(NtConfigStream_t hStream, NtConfig_t *data); 678 679/** 680 * @brief Sends an NTPL line buffer to the parser 681 * 682 * This function is used to send an NTPL line buffer to the 683 * parser. The config stream is defined by the hStream stream 684 * handle. 685 * 686 * When using validate mode no data is written to the adapter. The 687 * different modes define how far down the parsing is done. 688 * 689 * Note: Return data is stored in the stream handle and must be 690 * read by the HAL functions. 691 * 692 * @param[in] hStream Config stream for the NTPL 693 * @param[in] ntplBuffer NTPL line buffer containing NTPL code 694 * @param[in] info NTPL Info 695 * @param[in] validate Set parsing mode to validate. See @ref NtNTPLCommands_e 696 * 697 * @retval NT_SUCCESS NTPL command has been succesfully executed 698 * @retval NT_ERROR_WRONG_STREAM_TYPE The stream is not a config stream 699 * @retval NT_ERROR_NT_SERVICE_NOT_STARTED NT service is not started 700 * @retval NT_ERROR_INVALID_STREAM_POINTER Stream handle is a NULL pointer 701 * @retval NT_ERROR_INVALID_STREAM_HANDLE Stream handle is not a valid handle 702 * @retval NT_STATUS_TRYAGAIN Host buffers are temporarily unavailable - please try again 703 */ 704int NT_NTPL(NtConfigStream_t hStream, const char *ntplBuffer, NtNtplInfo_t *info, uint32_t validate); 705 706/** @} */ 707 708#endif // __STREAM_CONFIG_H__