1. Disclaimer
Information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. EXOLIGENT MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Exoligent disclaims all liability arising from this information and its use. Use of Exoligent devices in life support and/or safety applications is entirely at the buyer’s risk, and the buyer agrees to defend, indemnify and hold harmless Exoligent from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Exoligent intellectual property rights unless otherwise stated.
Exoligent SARL
390 rue d’Estienne d’Orves, 92700 Colombes - France
Tel: +33(0) 1 42 42 42 00
Web Site: https://www.exoligent.com/
Copyright © 2022 Exoligent SARL. All rights reserved.
2. Introduction
PowerFIP library is a C API providing a programming interface to the Exoligent’s FIP/WorldFIP coprocessor.
It offers a set of functions for the FIP/WorldFIP network control:
-
Create/Delete FIP objects
-
Node
-
Bus Arbiter macrocycle(s)
-
AE/LE(s) (Application/Layer Entity)
-
MPS variable(s)
-
SM-MPS variable(s)
-
-
-
-
Conduct FIP Exchanges:
-
Periodic MPS variables:
Transfers, reads and writes buffers with ID_DAT/RP_DAT transactions -
Aperiodic MPS variables:
Process buffer transfer requests (RP_DAT_RQx, ID_RQx/RP_RQx) -
Periodic messaging:
Exchanges messages with ID_MSG/RP_MSG_X using periodic channels. -
Aperiodic messaging:
Processes messages sent via aperiodic channel.
Requests are made to bus arbiter using RP_DAT_MSG frames.
-
-
Bus arbiter capability:
-
Start/Stop/Commute macrocycle(s)
-
-
Medium Redundancy
-
Channels control and status
-
-
Attach user callbacks to process FIP events
-
on RP_DAT rx/tx frames
-
on RP_MSG_X rx/tx frames
-
on ID_DAT rx/tx frames [pure event]
-
on RP_RQx tx frames [aperiodic requests]
-
on Bus Arbiter’s change of state
-
3. Installation
Let’s start by downloading the archive of the latest version of the library from the Exoligent website: Download section
3.1. Linux
- The linux archive has the following tree structure
-
-
[docs]
-
PowerFIP Library - User’s Guide (*.pdf) :
The User’s Guide in PDF format. -
powerfip.html :
The User’s Guide in HTML format.
-
-
[drivers]
-
[linux]
The source code of the Linux kernel module for Exoligent PowerFIP PCI/PCIe devices:-
[udev.rules.d]
-
10-powerfip.rules
-
-
install.sh
-
Makefile
-
powerfip-pci.c
-
powerfip-pci.h
-
uninstall.sh
-
-
-
[firmware]
The PowerFIP coprocessor firmware for RISC-V Soft-CPU target :-
powerfip-firmware.bin
-
-
[include]
Header files to include in your projects to use the library:-
libpowerfip.h
-
mbox-common.h
-
powerfip-common.h
-
powerfip-drv.h
-
powerfip-mbox-common.h
-
-
[lib]
-
[aarch64]
-
[static]
-
libpowerfip.a [aarch64 static lib]
-
-
libpowerfip.so.1.3.0 [aarch64 shared lib]
-
-
[arm]
-
[static]
-
libpowerfip.a [arm static lib]
-
-
libpowerfip.so.1.3.0 [arm shared lib]
-
-
[i386]
-
[static]
-
libpowerfip.a [x86 static lib]
-
-
libpowerfip.so.1.3.0 [x86 shared lib]
-
-
[x86_64]
-
[static]
-
libpowerfip.a [x86_64 static lib]
-
-
libpowerfip.so.1.3.0 [x86_64 shared lib]
-
-
-
[tools] :
Turnkey examples to get started as soon as possible!-
[pwrfip_2sta]
-
[pwrfip_nsta]
-
[pwrfip_perf_long_frm]
-
[pwrfip_performance]
-
[pwrfip_ping]
-
[mbfip_gateway]
-
[uafip_tsn_gateway]
-
-
install.sh
-
uninstall.sh
-
release-notes.txt
-
readme.txt
-
3.1.1. Kernel Module
Open a terminal, and go to the linux driver directory:
$ cd driver/linux
Execute the following commands to build and install the kernel module:
$ make $ sudo ./install.sh
|
To remove the kernel module, enter the following command :
$ sudo ./uninstall.sh
3.1.2. Firmware/Library
Open a terminal, and go to the archive package root.
Then, enter the following command to install the PowerFIP firmware and library on your machine:
$ sudo ./install.sh
|
To remove these files, enter the following command:
$ sudo ./uninstall.sh
3.2. Windows
Run the lastest installer (.exe), and follow the wizard steps. All the files will be copied to the folder:
C:\Program Files (x86)\Exoligent\PowerFIP\
- This directory has the following tree structure
-
-
[docs]
-
PowerFIP Library - User’s Guide (*.pdf) :
The User’s Guide in PDF format. -
powerfip.html :
The User’s Guide in HTML format.
-
-
[drivers]
-
[win]
The binaries of the Windows driver for Exoligent PowerFIP PCI/PCIe devices:-
[Driver]
-
[x86]
-
pwrfip.sys
-
-
[x86-64]
-
pwrfip64.sys
-
-
-
pwrfip.cat
-
pwrfip.inf
-
pwrfip64.cat
-
-
-
[firmware]
The PowerFIP coprocessor firmware for RISC-V Soft-CPU target :-
powerfip-firmware.bin
-
-
[include]
Header files to include in your projects to use the library:-
libpowerfip.h
-
mbox-common.h
-
powerfip-common.h
-
powerfip-drv.h
-
powerfip-mbox-common.h
-
-
[lib]
-
[i686]
-
[static] - MinGW compiler: i686-8.1.0-posix-dwarf-rt_v6-rev0
-
libpowerfip.a [x86 static lib]
-
-
libpowerfip.dll [x86 shared lib]
-
libpowerfip.lib [x86 import lib]
-
-
[x86_64]
-
[static] - MinGW compiler: x86_64-8.1.0-posix-seh-rt_v6-rev0
-
libpowerfip.a [x86_64 static lib]
-
-
libpowerfip.dll [x86_64 shared lib]
-
libpowerfip.lib [x86_64 import lib]
-
-
-
[tools] :
Turnkey examples to get started as soon as possible!-
[pwrfip_2sta]
-
[pwrfip_nsta]
-
[pwrfip_perf_long_frm]
-
[pwrfip_performance]
-
[pwrfip_ping]
-
-
release-notes.txt
-
readme.txt
-
3.2.1. Driver
- Installation
-
-
Open the Device Manager window
-
Press Windows+X or right-click to Start button, then a menu will appear
-
Select Device Manager from the list
-
-
Double-click on the new Other PCI bridge device detected
-
Click on Update the driver
-
Select the last package driver, and click on Next button
-
# Target directory for driver C:\Program Files (x86)\Exoligent\PowerFIP\drivers\win
-
PowerFIP driver is now installed !
- Uninstallation
-
Go to the Device Manager window
-
Right-click on the PowerFIP device to be removed, and click on Uninstall button
-
Check Remove the driver for this device, and confirm the device uninstall
3.2.2. Firmware/Library
The PowerFIP firmware and library will be automatically installed by the package wizard.
|
To remove the package, execute the uninstaller wizard:
C:\Program Files (x86)\Exoligent\PowerFIP\Uninstall.exe
3.3. Examples
To quickly get into the swing of things, the source code of some examples is provided with the package.
To access to the examples, open a terminal and enter the following commands:
# From extracted archive directory $ cd tools
$ cd C:\Program Files (x86)\Exoligent\PowerFIP\tools
If you do not have administrator rights, it is advisable to copy/paste the following directories into your own workspace:
For example paste it to a new directory in 'My Documents':
|
We will now briefly describe the examples:
3.3.1. Simple Test - pwrfip_2sta
This example aims at making two FIP nodes communicate with each other through the FIP network with exchange of periodic and aperiodic variables.
The configuration of FIP nodes is done via static structures (see tools/pwrfip_2sta/sta.h
), and tries to cover all available FIP services (MPS writing/reading, Aperiodic variable list requesting, Messages sending/receiving, SM-MPS reading, Presence Test, …).
The example will therefore only work completely if you have two PCI/PCIe PowerFIP devices connected together with a FIP cable. |
Build the example:
$ cd tools/pwrfip_2sta # Build for i386 target (32-bit) $ make MACHINE=i386 # Build for x86_64 target (64-bit) $ make MACHINE=x86_64
# Build the example with static method way. $ set SYS_NAME=windows $ cd tools/pwrfip_2sta # Build for i686 target (32-bit) # Note: MinGW compiler: i686-8.1.0-posix-dwarf-rt_v6-rev0 $ make MACHINE=i686 # Build for x86_64 target (64-bit) # Note: MinGW compiler: x86_64-8.1.0-posix-seh-rt_v6-rev0 $ make MACHINE=x86_64
Get the help:
$ ./pwrfip_2sta -h
$ pwrfip_2sta.exe -h
Usage: pwrfip_2sta [OPTION]... It tests FIP board communication with PowerFIP library. By default, if no option is added, the app opens the first PCI/PCIe device with index 1 [-i 1], and starts FIP node 0 (addr=0) [-n 0] with bitrate sets to 1Mbps [-b 1]. Options: -i device index [default=1] -n FIP node to start [default=0] 0: node 0 1: node 1 -b FIP bitrate [default=1] 0: 31.25Kbps 1: 1Mbps 2: 2.5Mbps 3: 5Mbps 4: 12.5Mbps 5: 25Mbps -r FIP turn-around time in us [default=0] default TR times: @31.25Kbps: 424us @1Mbps : 30us @2.5Mbps : 30us @5Mbps : 32us @12.5Mbps : 32us @25Mbps : 32us -s FIP silence time in us [default=0] default TS times: @31.25Kbps: 4096us @1Mbps : 150us @2.5Mbps : 96us @5Mbps : 92us @12.5Mbps : 92us @25Mbps : 92us -l list the FIP boards present on the host machine -h show this help and exit -v show version and exit Examples: pwrfip_2sta -i 1 -n 0 -b 1 -r 30 -s 150
Launch FIP node 0:
# Adding the SYS_NICE capapibity as Effective and Permitted to the binary # => This root command is executed only once after the binary building $ sudo setcap cap_sys_nice+ep ./pwrfip_2sta
$ ./pwrfip_2sta -i 1 -n 0 -b 1
$ pwrfip_2sta.exe -i 1 -n 0 -b 1
[01-24 10:17:44.201472] app => [info] [fip] device info [01-24 10:17:44.201546] app => [info] index : 1 [01-24 10:17:44.201578] app => [info] fsn : 0x28d00484cf61 [01-24 10:17:44.201601] app => [info] vid : 0x11aa [01-24 10:17:44.201624] app => [info] did : 0x1556 [01-24 10:17:44.201645] app => [info] ssvid : 0x11aa [01-24 10:17:44.201662] app => [info] ssdid : 0x5811 [01-24 10:17:44.201682] app => [info] bar_cnt : 2 [01-24 10:17:44.201705] app => [info] bar_bsz[0] : 4096 [01-24 10:17:44.201730] app => [info] bar_base[0] : 0xa6000000 [01-24 10:17:44.201747] app => [info] bar_bsz[1] : 33554432 [01-24 10:17:44.201767] app => [info] bar_base[1] : 0xa4000000 [01-24 10:17:44.201791] app => [info] irq_number : 148 [01-24 10:17:44.201811] app => [info] drv_version : 1.4.0 [01-24 10:17:44.201831] app => [info] test: v2.2.0 - pwrfip lib: v1.1.0 [01-24 10:17:44.201851] sta0 => [info] [fip] node configuration [01-24 10:17:44.201872] sta0 => [info] [fip] bus arbiter infos [01-24 10:17:44.201890] sta0 => [info] start : 1306800us [01-24 10:17:44.201909] sta0 => [info] election : 77700us [01-24 10:17:44.201928] sta0 => [info] [fip] node init [01-24 10:17:44.258360] sta0 => [event] reset component (powerfip) [...]
The example sequence is as follows:
-
Open PCI/PCIe device (index 1)
-
Load Configuration (fip node 0)
-
Start the Bus Arbiter (start-up time: 1306800us, election time: 77700us)
-
Infinite Loop
During this loop, an interrupt is raised by the FIP coprocessor each time an ID_DAT(0x9003) is transmitted on the FIP network (i.e. at the macrocycle frequency: here T=40ms). This interrupt triggers the user handler linked to the SM-MPS BA synchronization variable (see:
|
-
Break the loop on an user keyboard press
-
Stop Bus Arbiter
-
Unload Configuration
-
Close PCI/PCIe device
3.3.2. Performance Test - pwrfip_performance
This example is very similar in structure to the previous example.
However, here the goal of the test is to measure the performance of the user read/write operation of the FIP variables from/to the database embedded in the FIP coprocessor.
Thanks to this we can evaluate the min/avg/max access times to the coprocessor depending on the amount of useful data read or written.
At the end of the test, a diagnostic report is generated and gives the access times (minimum, average, maximum) according to the length of the FIP user data produced or consumed: tools/pwrfip_performance/report_idx1.txt
.
In the same way as for the previous test, to have a complete performance report, the two FIP nodes in the example must be connected to each other. Linux - Test launch
# Adding the SYS_NICE capapibity as Effective and Permitted to the binary # => This root command is executed only once after the binary building $ sudo setcap cap_sys_nice+ep ./pwrfip_performance # => Terminal 1 # starts PCI/PCIe device index 1 with FIP node configuration 0 $ ./pwrfip_performance -i 1 -n 0 # => Terminal 2 # start PCI/PCIe device index 2 with FIP node configuration 1 $ ./pwrfip_performance -i 2 -n 1 Windows - Test launch
# => Terminal 1 # starts PCI/PCIe device index 1 with FIP node configuration 0 $ pwrfip_performance.exe -i 1 -n 0 # => Terminal 2 # start PCI/PCIe device index 2 with FIP node configuration 1 $ pwrfip_performance.exe -i 2 -n 1 |
This makes it possible to generate performance curves according to the execution context (PC architecture, real-time OS, etc.).
4. Functions
In this chapter, we will discover and describe the whole API (Application Programming Interface) of POWERFIP.
4.1. General
4.1.1. init
- Description
-
Library internal initialization
- Prototype
int pwrfip_init()
- Parameters
-
-
IN - None
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_init()
returns 0.
If unsuccessful,pwrfip_init()
returns -1 and sets errno value. - Remarks
This function must always be called before using any other function of the library. |
4.1.2. exit
- Description
-
Free all internal ressources used by the PowerFIP library
- Prototype
void pwrfip_exit()
- Parameters
-
-
IN - None
-
OUT - None
-
- Return Value
-
NONE
- Remarks
This function must always be called at the end of the use of the library. |
4.1.3. version_get
- Description
-
Gets the software library version.
- Prototype
const struct pwrfip_version *pwrfip_version_get()
- Parameters
-
-
IN - None
-
OUT - None
-
- Return Value
-
Pointer to a
struct pwrfip_version
. - Example
int main(int argc, char *argv[])
{
const struct pwrfip_version *lib_version;
pwrfip_init();
/* pwrfip - get lib version */
lib_version = pwrfip_version_get();
printf("pwrfip lib: v%d.%d.%d [build date: %02d/%02d/%02d]\n",
lib_version->info.major,
lib_version->info.minor,
lib_version->info.patch,
lib_version->date.info.month,
lib_version->date.info.day,
lib_version->date.info.year);
pwrfip_exit();
return 0;
}
4.1.4. error_get
- Description
-
Gets the last error code.
- Prototype
int pwrfip_error_get()
- Parameters
-
-
IN - None
-
OUT - None
-
- Return Value
-
The last error code.
- Remarks
-
See
enum pwrfip_error_code
to get the list of the specific library errors codes.
4.1.5. strerror
- Description
-
Gets the error string specified by its error code.
The library provides this error code via the lvalue: errno or via |
- Prototype
const char *pwrfip_strerror(int err)
- Parameters
-
-
IN
-
err:
Error code.
-
-
OUT - None
-
- Return Value
-
Error in string format.
- Remarks
-
See
enum pwrfip_error_code
to get the list of the specific library errors codes.
4.2. Device
4.2.1. device_list_get
- Description
-
Gets the list of PCI/PCIe powerfip devices present on the system.
The PowerFIP driver supports up to 16 devices. |
- Prototype
int pwrfip_device_list_get(struct pwrfip_dev_infos *dev_infos,
int *dev_cnt)
- Parameters
-
-
IN - None
-
OUT
-
dev_infos:
Information list of detected devices.
Seestruct pwrfip_dev_infos
. -
dev_cnt:
Count of detected devices.
-
-
- Return Value
-
If successful,
pwrfip_device_list_get()
returns 0.
If unsuccessful,pwrfip_device_list_get()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input/output parameter.
-
4.2.2. device_open
- Description
-
Opens a PCI/PCIe powerfip device.
- Prototype
struct pwrfip_dev *pwrfip_device_open(uint8_t dev_id)
- Parameters
-
-
IN
-
dev_id:
Device index on the system.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_device_open()
returns a newstruct pwrfip_dev
pointer (opaque structure).
If unsuccessful,pwrfip_device_open()
returns NULL and sets errno to one of the following values:-
EINVAL:
Invalid input parameter. -
ENOMEM:
Memory allocation error. -
[..]:
Other posix errors related to a file opening error
-
4.2.3. device_reset
- Description
-
Resets PCI/PCIe PowerFIP device.
-
FIP Coprocessor reset
-
Logic interface reset (of carrier board)
-
- Prototype
int pwrfip_device_reset(struct pwrfip_dev *dev)
- Parameters
-
-
IN
-
dev:
Pointer to the device to reset.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_device_reset()
returns 0.
If unsuccessful,pwrfip_device_reset()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input parameter.
-
4.2.4. device_close
- Description
-
Closes a PCI/PCIe powerfip device.
- Prototype
int pwrfip_device_close(struct pwrfip_dev *dev)
- Parameters
-
-
IN
-
dev:
Pointer to the device to close.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_device_close()
returns 0.
If unsuccessful,pwrfip_device_close()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid device pointer.
-
4.2.5. device_infos_get
- Description
-
Gets information relative to the PCI/PCIe device.
- Prototype
int pwrfip_device_infos_get(struct pwrfip_dev *dev,
struct pwrfip_dev_infos *info)
- Parameters
-
-
IN
-
dev:
Pointer to the device to query.
-
-
OUT
-
info:
Info structure.
Seestruct pwrfip_dev_infos
.
-
-
- Return Value
-
If successful,
pwrfip_device_infos_get()
returns 0.
If unsuccessful,pwrfip_device_infos_get()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input/output parameter.
-
4.2.6. device_report_get
- Description
-
Gets various information about the PowerFIP board.
- Prototype
int pwrfip_device_report_get(struct pwrfip_dev *dev,
struct pwrfip_dev_report *report)
- Parameters
-
-
IN
-
dev:
Pointer to the device to query.
-
-
OUT
-
report:
Device report.
Seestruct pwrfip_dev_report
.
-
-
- Return Value
-
If successful,
pwrfip_device_report_get()
returns 0.
If unsuccessful,pwrfip_device_report_get()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input/output parameter.
-
4.3. AE/LE
4.3.1. aele_create
- Description
-
The function
pwrfip_aele_create()
creates an Application/Layer entity attached to a FIP node. This container will gather all the production/consumtions variables and messages related to the local application. - Prototype
struct pwrfip_aele *pwrfip_aele_create(struct pwrfip_node *node);
- Parameters
-
-
IN
-
node:
Pointer to astruct pwrfip_node
.
-
-
OUT - None
-
- Return Value
-
Pointer to a
struct pwrfip_aele
(opaque structure).
4.3.2. aele_delete
- Description
-
The function
pwrfip_aele_delete()
deallocates a specific application/layer entity; and removes all items (variable, messages) attached to it. - Prototype
int pwrfip_aele_delete(struct pwrfip_aele *aele)
- Parameters
-
-
IN
-
aele:
Application entity to delete.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_aele_delete()
returns 0.
If unsuccessful,pwrfip_aele_delete()
returns -1 and sets errno to one of the following values:-
PWRFIP_ERR_AELE_NOT_STOP:
AE/LE is currently running. Stop it before try to delete it.
-
4.3.3. msg_create
- Description
-
Creates a FIP message inside an user’s application context.
- Prototype
struct pwrfip_msg *pwrfip_msg_create(
struct pwrfip_aele *aele, struct pwrfip_msg_cfg *cfg)
- Parameters
-
-
IN
-
aele:
Pointer to a user’s application context (AE/LE). -
cfg:
Pointer to a message’s configuration structure.
Seestruct pwrfip_msg_cfg
.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_msg_create()
returns a newstruct pwrfip_msg
pointer.
If unsuccessful,pwrfip_msg_create()
returns NULL and sets errno to one of the following values:-
EINVAL:
Invalid input parameters. -
ENOMEM:
Memory allocation error. -
PWRFIP_ERR_AELE_NOT_STOP:
AE/LE is currently running. Stop it before trying to create new objects. -
PWRFIP_ERR_CFG_MSG_EXIST:
Impossible to create this message. The AE/LE context already contains a message with the same header. -
PWRFIP_ERR_NODE_MSG_CAP_NOT_SUPPORTED:
The node doesn’t support the messaging service.
See.msg.enable
field ofstruct pwrfip_node_cfg
. -
PWRFIP_ERR_CFG_MSG_TYPE_UNKNOWN:
Unknown message type.
Seeenum pwrfip_msg_type
. -
PWRFIP_ERR_CFG_MSG_TX_CH_PER_UNKNOWN:
Unknown periodic message TX channel.
Seeenum pwrfip_msg_tx_channel
. -
PWRFIP_ERR_CFG_MSG_TX_CH_PER_NOID:
No ID attached to the periodic TX channel.
See.msg.tx_per_fifo_id[]
field ofstruct pwrfip_node_cfg
. -
PWRFIP_ERR_CFG_MSG_TX_ACK_MODE_UNKNOWN:
Unknown message acknowledgement mode.
Seeenum pwrfip_msg_tx_ack_mode
.
-
- Example
static struct pwrfip_msg_cfg prod_msg_cfg = {
.type = PWRFIP_MSG_TYPE_SEND,
.tx.channel = PWRFIP_MSG_TX_CH_APER,
.tx.ack_mode = PWRFIP_MSG_TX_ACK_MODE_SDA,
/* local data link layer address: 0x0C0000 */
.hdr.src.seg = 0,
.hdr.src.lsap = 0x0C00, /* ssap */
/* remote data link layer address: 0x0C0100 */
.hdr.dst.seg = 0,
.hdr.dst.lsap = 0x0C01, /* dsap (=target) */
.pwrfip_msg_handler = NULL,
};
static struct pwrfip_msg_cfg cons_msg_cfg = {
.type = PWRFIP_MSG_TYPE_RECV,
/* remote data link layer address: 0x0C0100 */
.hdr.src.seg = 0,
.hdr.src.lsap = 0x0C01, /* ssap */
/* local data link layer address: 0x0C0000 */
.hdr.dst.seg = 0,
.hdr.dst.lsap = 0x0C00, /* dsap (=target) */
.pwrfip_msg_handler = NULL,
};
int main(int argc, char *argv[])
{
int i, err = 0;
struct pwrfip_node_cfg node_cfg;
struct pwrfip_node *node;
struct pwrfip_aele *al;
struct pwrfip_msg *prod_msg, *cons_msg;
/**
* Node initialization
*/
memset(&node_cfg, 0, sizeof(struct pwrfip_node_cfg));
node_cfg.fip_phy_addr = 0;
node_cfg.fip_seg_num = 0;
node_cfg.msg.enable = 1;
if (node_cfg.msg.enable) {
/* set rx messaging sensitivity only for messages destined
* for segment 0 with DSAP values configured for the node
*/
node_cfg.msg.rx_segment_tab[0] = PWRFIP_MSG_SEG_ACCEPT_LTD;
node_cfg.msg.rx_fifo_size = 0; /* 0 to set default value (30) */
node_cfg.msg.tx_aper_fifo_size = 0; /* default value for tx aper channel:
* tx fifo depth = 24 messages
*/
node_cfg.msg.tx_max_repeat = 3; /* 3 tx retries in case of error */
/* periodic messaging channels are disabled */
for (i = 0; i < PWRFIP_MSG_TX_CH_PER_CNT; ++i)
node_cfg.msg.tx_per_fifo_id[i] = 0; /* no id attached */
}
/*...: other node configuration fields to fill (ba, handlers...) */
node = pwrfip_node_init(&node_cfg);
if (!node) {
printf("node creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* create an aele context */
al = pwrfip_aele_create(node);
if (!al) {
printf("aele creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* create a tx message */
prod_msg = pwrfip_msg_create(al, &prod_msg_cfg);
if (!prod_msg) {
printf("tx message creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* create a rx message */
cons_msg = pwrfip_msg_create(al, &cons_msg_cfg);
if (!cons_msg) {
printf("rx message creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/**
* Other tasks
*/
/* ... */
end:
/**
* Node exit
*/
/*...*/
return err;
}
4.3.4. msg_delete
- Description
-
Deallocates a specific message from an application entity (AE/LE).
- Prototype
int pwrfip_msg_delete(struct pwrfip_msg *msg)
- Parameters
-
-
IN
-
msg:
Pointer to the message to delete.
Seestruct pwrfip_msg
.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_msg_delete()
returns 0.
If unsuccessful,pwrfip_msg_delete()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input parameter. -
PWRFIP_ERR_AELE_NOT_STOP:
AE/LE attached to this message is currently running. Stop it before try to delete it.
-
4.3.5. sm_var_create
- Description
-
Creates an additionnal SM-MPS variables inside an user’s application context.
This function is used to allow the local node to consume SM-MPS variables produced by remote nodes. - Prototype
struct pwrfip_var *pwrfip_sm_var_create(
struct pwrfip_aele *aele, enum pwrfip_sm_var_type type,
uint8_t node_addr)
- Parameters
-
-
IN
-
aele:
Pointer to a user’s application context (AE/LE). -
type:
Type of SM-MPS variable to create.
Seeenum pwrfip_sm_var_type
. -
node_addr:
Remote node address.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_sm_var_create()
returns a newstruct pwrfip_var
pointer.
If unsuccessful,pwrfip_sm_var_create()
returns NULL and sets errno to one of the following values:-
EINVAL:
Invalid input parameters. -
ENOMEM:
Memory allocation error. -
PWRFIP_ERR_AELE_NOT_STOP:
AE/LE is currently running. Stop it before trying to create new objects. -
PWRFIP_ERR_CFG_VAR_EXIST:
Impossible to create this variable. The AE/LE context already contains a variable with this FIP identifier. -
PWRFIP_ERR_CFG_VAR_DIR:
An update of the variable tried to be applied; but it’s impossible to change the direction of the variable (prod/cons) for this FIP identifier. -
PWRFIP_ERR_CFG_MSG_PROD:
Impossible to link a produced message on this FIP identifier. A consumed variable is already attached to it. -
PWRFIP_ERR_CFG_MSG_DIR:
A FIP production message is already attached to this FIP identifier; so it is impossible to change the production channel.
-
- Example
int main(int argc, char *argv[])
{
int err = 0;
struct pwrfip_node *node;
struct pwrfip_aele *al;
/**
* Node initialization.
* Note: We assume here that the local node created has a FIP address = 1
*/
/*...*/
/**
* Create an aele context.
* Note: When the AE/LE is created, the following SM-MPS variables are
* automatically created: 0x9003, 0x9002, 0x10XY, 0x11XY, 0x14XY where
* XY is the local node address (here, FIP address = 1).
* If the node is master (ba active), 0x9002 and 0x9003 variables will
* be automatically produced and updated by the library; otherwise they
* will only be consumed.
* Moreover 0x10XY, 0x11XY, 0x14XY are always automatically produced and
* updated by the library.
*/
al = pwrfip_aele_create(node);
if (!al) {
printf("aele creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/**
* Creates other sm-mps variables to consume.
* Note: In this example, the local station will be connected to the remote
* stations 2 and 3; and we would like to be able to read their system
* management variables. So we create them.
*/
/* => creates consumed SM-MPS variables: 0x1002, 0x1102, 0x1402 */
pwrfip_sm_var_create(al, PWRFIP_SM_VAR_IDENT, 2);
pwrfip_sm_var_create(al, PWRFIP_SM_VAR_REPORT, 2);
pwrfip_sm_var_create(al, PWRFIP_SM_VAR_PRESENCE, 2);
/* => creates consumed SM-MPS variables: 0x1003, 0x1103, 0x1403 */
pwrfip_sm_var_create(al, PWRFIP_SM_VAR_IDENT, 3);
pwrfip_sm_var_create(al, PWRFIP_SM_VAR_REPORT, 3);
pwrfip_sm_var_create(al, PWRFIP_SM_VAR_PRESENCE, 3);
/**
* Other tasks
*/
/* ... */
end:
/**
* Node exit
*/
/*...*/
return err;
}
4.3.6. var_create
- Description
-
Creates a FIP variable inside an user’s application context.
- Prototype
struct pwrfip_var *pwrfip_var_create(struct pwrfip_aele *aele,
struct pwrfip_var_cfg *cfg)
- Parameters
-
-
IN
-
aele:
Pointer to a user’s application context (AE/LE). -
cfg:
Pointer to a variable’s configuration structure.
Seestruct pwrfip_var_cfg
.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_var_create()
returns a newstruct pwrfip_var
pointer.
If unsuccessful,pwrfip_var_create()
returns NULL and sets errno to one of the following values:-
EINVAL:
Invalid input parameters. -
ENOMEM:
Memory allocation error. -
PWRFIP_ERR_AELE_NOT_STOP:
AE/LE is currently running. Stop it before trying to create new objects. -
PWRFIP_ERR_CFG_VAR_EXIST:
Impossible to create this variable. The AE/LE context already contains a variable with this FIP identifier. -
PWRFIP_ERR_CFG_VAR_DIR:
An update of the variable tried to be applied; but it’s impossible to change the direction of the variable (prod/cons) for this FIP identifier. -
PWRFIP_ERR_CFG_MSG_PROD:
Impossible to link a produced message on this FIP identifier. A consumed variable is already attached to it. -
PWRFIP_ERR_CFG_MSG_DIR:
A FIP production message is already attached to this FIP identifier; so it is impossible to change the production channel.
-
- Example
void sync_var_handler(struct pwrfip_node *node,
struct pwrfip_var *var, struct pwrfip_event *evt);
static struct pwrfip_var_cfg prod_var_cfg = {
.type = PWRFIP_VAR_TYPE_PROD,
.id = 0x3800,
.prod.payload_bsz = 8,
.prod.flags = \
/* enable prod status */
PWRFIP_VAR_FLAGS_REFRESH | \
/* enable aper var request */
PWRFIP_VAR_FLAGS_APER_VAR_REQ | \
/* enable aper msg request */
PWRFIP_VAR_FLAGS_APER_MSG_REQ,
.prod.refreshment_ustime = 80000, /* 80ms */
.prod.evt_type = PWRFIP_EVT_TYPE_NONE,
.pwrfip_var_handler = NULL,
};
static struct pwrfip_var_cfg cons_var_cfg = {
.type = PWRFIP_VAR_TYPE_CONS,
.id = 0x3801,
.cons.payload_bsz = 8,
.cons.flags = \
/* enable prod status */
PWRFIP_VAR_FLAGS_REFRESH | \
/* enable promptness checking */
PWRFIP_VAR_FLAGS_PROMPT | \
/* enable pdu + len bytes checking */
PWRFIP_VAR_FLAGS_CHK_PDU_LEN,
.cons.promptness_ustime = 100000, /* 100ms */
.cons.evt_type = PWRFIP_EVT_TYPE_NONE,
.pwrfip_var_handler = NULL,
};
static struct pwrfip_var_cfg sync_var_cfg = {
.type = PWRFIP_VAR_TYPE_SYNC,
.id = 0x3000,
.pwrfip_var_handler = sync_var_handler,
};
int main(int argc, char *argv[])
{
int err = 0;
struct pwrfip_node *node;
struct pwrfip_aele *al;
struct pwrfip_var *prod_var, *cons_var, *sync_var;
/**
* Node initialization
*/
/*...*/
/* create an aele context */
al = pwrfip_aele_create(node);
if (!al) {
printf("aele creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* create a production variable */
prod_var = pwrfip_var_create(al, &prod_var_cfg);
if (!prod_var) {
printf("production variable creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* create a consumption variable */
cons_var = pwrfip_var_create(al, &cons_var_cfg);
if (!cons_var) {
printf("consumption variable creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* create a synchronization variable */
sync_var = pwrfip_var_create(al, &sync_var_cfg);
if (!sync_var) {
printf("synchronization variable creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/**
* Other tasks
*/
/* ... */
end:
/**
* Node exit
*/
/*...*/
return err;
}
4.3.7. var_delete
- Description
-
Deallocates a specific variable from an application entity (AE/LE).
- Prototype
int pwrfip_var_delete(struct pwrfip_var *var)
- Parameters
-
-
IN
-
var:
Pointer to the variable to delete.
Seestruct pwrfip_var
.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_var_delete()
returns 0.
If unsuccessful,pwrfip_var_delete()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input parameter. -
PWRFIP_ERR_AELE_NOT_STOP:
AE/LE attached to this variable is currently running. Stop it before try to delete it.
-
4.4. Bus Arbiter
4.4.1. ba_mcycle_create
- Description
-
This function creates a new macrocycle (or Bus Arbiter table) attached to a FIP node.
To support this function, the FIP node has to set Master capability. |
- Prototype
struct pwrfip_ba_mcycle *pwrfip_ba_mcycle_create(
struct pwrfip_node *node,
struct pwrfip_ba_mcycle_cfg *cfg)
- Parameters
-
-
IN
-
node:
Pointer to the FIP node where to create the new macrocycle.
Seestruct pwrfip_node
. -
cfg:
Pointer to a macrocycle configuration structure.
Seestruct pwrfip_ba_mcycle_cfg
.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_ba_mcycle_create()
returns a newstruct pwrfip_ba_mcycle
pointer (opaque structure).
If unsuccessful,pwrfip_ba_mcycle_create()
returns NULL and sets errno to one of the following values:-
EINVAL:
Invalid node or macrocycle configuration structure. -
ENOMEM:
Memory allocation error. -
PWRFIP_ERR_MCYCLE_WIND_UNKNOWN:
Invalid macrocycle window type (seeenum pwrfip_ba_wind_type
). -
PWRFIP_ERR_MCYCLE_WIND_COUNT:
Macrocycle window count has to be greater than 0. -
PWRFIP_ERR_MCYCLE_PER_WIND_REQ_COUNT:
Requests count inside a macrocycle periodic window has to be greater than 0. -
PWRFIP_ERR_MCYCLE_PER_WIND_REQ_UNKNOWN:
Invalid request type inside a macrocycle periodic window.
Requests allowed are only ID_DAT and ID_MSG type. -
PWRFIP_ERR_MCYCLE_WIND_TIME_INC:
Overlap on macrocycle windows end times.
The.end_ustime
field present in the configuration of certain types of bus arbiter window is a time relative to the beginning of the macrocycle.
This time must therefore be increasing as you go through the configuration list. -
PWRFIP_ERR_MCYCLE_WIND_END:
The macrocyle configuration must end with a time window (wait).
-
- Example
#define TST_BA_PER_REQ_COUNT 3
static struct pwrfip_ba_request tst_ba_per_req[TST_BA_PER_REQ_COUNT] = {
{
.type = PWRFIP_BA_ID_DAT,
.id = 0x3800,
},
{
.type = PWRFIP_BA_ID_DAT,
.id = 0x3801,
},
{
.type = PWRFIP_BA_ID_DAT,
.id = 0x9003,
},
};
static struct pwrfip_ba_wind_cfg tst_ba_wind_cfg[2][4] = {
/* ba mcycle 1 */
{
/* 1 - periodic variable window */
{
.type = PWRFIP_BA_WIND_PER,
.per.req_cnt = TST_BA_PER_REQ_COUNT,
.per.req_list = &tst_ba_per_req[0],
},
/* 2 - aperiodic message window */
{
.type = PWRFIP_BA_WIND_APER_MSG,
.aper_msg.end_ustime = 15000,
},
/* 3 - aperiodic variable window */
{
.type = PWRFIP_BA_WIND_APER_VAR,
.aper_var.end_ustime = 35000,
.aper_var.enable_testp = 1, /* enable presence test if no other
* request to dispatch */
},
/* 4 - resync wait window */
{
.type = PWRFIP_BA_WIND_WAIT,
.wait.end_ustime = 40000,
.wait.is_silent = 0, /* fill window with padding frames */
.wait.is_ext_resync = 0, /* internal resynchronization */
},
},
/* ba mcycle 2 */
{
/* 1 - periodic variable window */
{
.type = PWRFIP_BA_WIND_PER,
.per.req_cnt = TST_BA_PER_REQ_COUNT,
.per.req_list = &tst_ba_per_req[0],
},
/* 2 - aperiodic message window */
{
.type = PWRFIP_BA_WIND_APER_MSG,
.aper_msg.end_ustime = 75000,
},
/* 3 - resync wait window */
{
.type = PWRFIP_BA_WIND_WAIT,
.wait.end_ustime = 80000,
.wait.is_silent = 0, /* fill window with padding frames */
.wait.is_ext_resync = 0, /* internal resynchronization */
},
/* no other window */
{
.type = 0,
}
},
};
static struct pwrfip_ba_mcycle_cfg tst_ba_mcycle_cfg[2] = {
/* ba mcycle 1 */
{
.wind_cnt = 4,
.wind_list = &tst_ba_wind_cfg[0][0],
},
/* ba mcycle 2 */
{
.wind_cnt = 3,
.wind_list = &tst_ba_wind_cfg[1][0],
},
};
int main(int argc, char *argv[])
{
int err = 0;
struct pwrfip_node *node;
struct pwrfip_ba_mcycle *mcycle[2];
/**
* Node initialization
*/
/*...*/
/* create two bus arbiter macrocycles */
for (i = 0; i < 2; ++i) {
struct pwrfip_ba_mcycle_cfg *mcycle_cfg = &tst_ba_mcycle_cfg[i];
mcycle[i] = pwrfip_ba_mcycle_create(node, mcycle_cfg);
if (!mcycle[i]) {
/* get error */*
printf("macrocycle creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
}
/**
* Other tasks
*/
/* ... */
end:
/**
* Node exit
*/
/*...*/
return err;
}
4.4.2. ba_mcycle_delete
- Description
-
The function
pwrfip_ba_mcycle_delete()
deallocates a specific macrocycle. - Prototype
int pwrfip_ba_mcycle_delete(struct pwrfip_ba_mcycle *mcycle)
- Parameters
-
-
IN
-
mcycle:
Macrocycle to delete.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_ba_mcycle_delete()
returns 0.
If unsuccessful,pwrfip_ba_mcycle_delete()
returns -1 and sets errno to one of the following values:-
PWRFIP_ERR_BA_NOT_STOP:
The macrocycle is currently running. Stop it before try to delete it.
-
4.4.3. ba_startup_calculate
- Description
-
Tool function to calculate compliant start-up and election times for a bus arbiter in an environment where multiple FIP nodes are competing to become Master.
- Prototype
int pwrfip_ba_startup_calculate(uint32_t *stup_ustime, uint32_t *elec_ustime,
struct pwrfip_ba_startup_cfg *cfg)
- Parameters
-
-
IN
-
cfg:
Input parameters for time calculation.
Seestruct pwrfip_ba_startup_cfg
.
-
-
OUT
-
stup_ustime:
BA start-up time calculated in microseconds. -
elec_ustime:
BA election time calculated in microseconds.
-
-
- Return Value
-
If successful,
pwrfip_ba_startup_calculate()
returns 0.
If unsuccessful,pwrfip_ba_startup_calculate()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input/output parameters. -
PWRFIP_ERR_BA_STUP_PHY_ADDR_INVALID:
Local physical address exceeds maximum physical address given. -
PWRFIP_ERR_BA_STUP_PRIO_INVALID:
Local priority is higher than maximum one given.
-
BA Priority
Priority range is between [0;15], with 0 the highest priority. |
-
PWRFIP_ERR_BA_STUP_TS_INVALID:
Silence Time input parameter should not be 0.
4.4.4. ba_start
- Description
-
Starts a specific macrocycle for the master node attached.
- Prototype
int pwrfip_ba_start(struct pwrfip_ba_mcycle *mcycle)
- Parameters
-
-
IN
-
mcycle:
Macrocycle to start.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_ba_start()
returns 0.
If unsuccessful,pwrfip_ba_start()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid macrocycle pointer. -
PWRFIP_ERR_BA_NOT_STOP:
The node has already a running macrocycle.
Usepwrfip_ba_commute()
function instead. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.4.5. ba_stop
- Description
-
Stops the macrocycle of a specific FIP node.
- Prototype
int pwrfip_ba_stop(struct pwrfip_node *node)
- Parameters
-
-
IN
-
node:
FIP node to query.
Seestruct pwrfip_node
.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_ba_stop()
returns 0.
If unsuccessful,pwrfip_ba_stop()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid node pointer. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.4.6. ba_commute
- Description
-
Switch to the execution of another FIP macrocycle.
- Prototype
int pwrfip_ba_commute(struct pwrfip_ba_mcycle *mcycle)
- Parameters
-
-
IN
-
mcycle:
Pointer to the new macrocycle to switch to.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_ba_commute()
returns 0.
If unsuccessful,pwrfip_ba_commute()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid macrocycle pointer. -
PWRFIP_ERR_BA_NOT_RUN:
The node does not have a running macrocycle.
Usepwrfip_ba_start()
function instead. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.4.7. ba_status_get
- Description
-
Gets the bus arbiter status for a given FIP node.
- Prototype
int pwrfip_ba_status_get(struct pwrfip_node *node, struct pwrfip_ba_status *status)
- Parameters
-
-
IN
-
node:
FIP node to query.
Seestruct pwrfip_node
.
-
-
OUT
-
status:
Pointer to an outputstruct pwrfip_ba_status
.
-
-
- Return Value
-
If successful,
pwrfip_ba_status_get()
returns 0.
If unsuccessful,pwrfip_ba_status_get()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input/output parameters. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.5. Messages
4.5.1. msg_send
- Description
-
Writes a FIP message to the local coprocessor database.
- Prototype
int pwrfip_msg_send(struct pwrfip_msg *msg)
- Parameters
-
-
IN
-
msg:
Pointer to the target message to write.
Seestruct pwrfip_msg
.
-
-
OUT
-
msg:
Message’s updated info.
Seestruct pwrfip_msg
(.epoch
and.error
fields).
-
-
- Return Value
-
If successful,
pwrfip_msg_send()
returns 0.
If unsuccessful,pwrfip_msg_send()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input parameters. -
PWRFIP_ERR_INVALID_CTX:
The AE/LE context attached to the message object does not match that of the running node. -
PWRFIP_ERR_AELE_NOT_RUN:
FIP node is not running. It is therefore impossible to query the coprocessor database. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
- Remarks
-
There are two possible error levels for this operation:
-
The error returned by the
pwrfip_msg_send()
function is related to a context error inside the library, or a communication error with the coprocessor.
This type of error is quite critical since it indicates a malfunction of the library. -
The
.error
field returned in thestruct pwrfip_msg
(seeenum pwrfip_msg_err_code
) relates directly to the FIP frame state written to the network.
It is an indicator of the quality of the frame written.
-
- Example
static struct pwrfip_msg_cfg prod_msg_cfg = {
.type = PWRFIP_MSG_TYPE_SEND,
.tx.channel = PWRFIP_MSG_TX_CH_APER,
.tx.ack_mode = PWRFIP_MSG_TX_ACK_MODE_SDA,
/* local data link layer address: 0x0C0000 */
.hdr.src.seg = 0,
.hdr.src.lsap = 0x0C00, /* ssap */
/* remote data link layer address: 0x0C0100 */
.hdr.dst.seg = 0,
.hdr.dst.lsap = 0x0C01, /* dsap (=target) */
.pwrfip_msg_handler = NULL,
};
int main(int argc, char *argv[])
{
int i, err = 0;
struct pwrfip_node *node;
struct pwrfip_aele *al;
struct pwrfip_msg *prod_msg;
uint16_t w_counter = 0;
/**
* Node initialization
*/
/*...*/
/* create an aele context */
al = pwrfip_aele_create(node);
if (!al) {
printf("aele creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* create a production message */
prod_msg = pwrfip_msg_create(al, &prod_msg_cfg);
if (!prod_msg) {
printf("production message creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* node startup (slave) */
err = pwrfip_node_start(al, NULL, 0);
if (err) {
printf("node startup failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* writing loop */
for(;;) {
/* update msg payload */
w_counter++;
prod_msg->bsz = sizeof(w_counter);
memcpy(prod_msg->buffer, &w_counter, prod_msg->bsz);
/* send it to fip network */
if (pwrfip_msg_send(prod_msg)) {
printf("w_msg[header: src=0x%08x dst=0x%08x] failed: %s\n",
prod_msg->hdr.src.addr, prod_msg->hdr.dst.addr,
pwrfip_strerror(errno));
/* we consider this error as fatal error; so we
* stop the test */
break;
}
/* check msg state errors */
if (prod_msg->error) {
printf("w_msg[header: src=0x%08x dst=0x%08x] state error: %d\n",
prod_msg->hdr.src.addr, prod_msg->hdr.dst.addr,
prod_msg->error);
}
usleep(100000); /* 100ms */
}
end:
/**
* Node exit
*/
/*...*/
return err;
}
4.5.2. msg_tx_channel_purge
- Description
-
Purges the target periodic/aperiodic message TX channel.
- Prototype
int pwrfip_msg_tx_channel_purge(struct pwrfip_node *node,
enum pwrfip_msg_tx_channel channel,
uint16_t *purge_cnt, uint8_t *ch_error);
- Parameters
-
-
IN
-
node:
Pointer to the target node.
Seestruct pwrfip_node
. -
channel:
Message TX channel to purge.
Seeenum pwrfip_msg_tx_channel
.
-
-
OUT
-
purge_cnt:
Number of messages purged. -
ch_error:
Channel error.
Seeenum pwrfip_msg_err_code
.
-
-
- Return Value
-
If successful,
pwrfip_msg_tx_channel_purge()
returns 0.
If unsuccessful,pwrfip_msg_tx_channel_purge()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input parameters. -
PWRFIP_ERR_AELE_NOT_RUN:
FIP node is not running. It is therefore impossible to query the coprocessor database. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.6. Node
4.6.1. node_init
- Description
-
Creates a new FIP node context inside the library and load it to the local database of a binded coprocessor.
This is the main step in creating a FIP node. - Prototype
struct pwrfip_node *pwrfip_node_init(struct pwrfip_node_cfg *cfg)
- Parameters
-
-
IN
-
cfg:
Pointer to the FIP node configuration.
Seestruct pwrfip_node_cfg
.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_node_init()
returns a newstruct pwrfip_node
pointer.
If unsuccessful,pwrfip_node_init()
returns NULL and sets errno to one of the following values:-
EINVAL:
Invalid input configuration. -
ENOMEM:
Memory allocation error. -
PWRFIP_ERR_NODE_BSS_OVERFLOW:
Node BSS overflow.
You should reduce the FIFO sizes of the node. -
PWRFIP_ERR_NODE_HANDLER_MISSING:
Some user handlers are mandatory to continue the node creation:-
pwrfip_reset_handler
-
pwrfip_error_handler
-
-
PWRFIP_ERR_NODE_FRM_TYPE_INVALID:
Invalid frame type configuration. Should be:-
PWRFIP_FRM_FIP
-
PWRFIP_FRM_WORLDFIP
-
-
PWRFIP_ERR_NODE_BITRATE_INVALID:
Invalid FIP bitrate configuration. Should be:-
PWRFIP_BITRATE_31K25
-
PWRFIP_BITRATE_1M
-
PWRFIP_BITRATE_2M5
-
PWRFIP_BITRATE_5M
-
-
PWRFIP_ERR_NODE_TR_INVALID:
Invalid FIP turnaround time. Range should be:-
@31.25Kbps : min=320us, max=8232us, default=424us
-
@1Mbps : min=20us, max=258us, default=30us
-
@2.5Mbps : min=20us, max=103us, default=30us
-
@5Mbps : min=20us, max=103us, default=32us
-
@12.5Mbps : min=20us, max=103us, default=32us
-
@25Mbps : min=20us, max=103us, default=32us
-
-
PWRFIP_ERR_NODE_TS_INVALID:
Invalid FIP silence time. Range should be:-
@31.25Kbps : min=2880us, max=65535us, default=4096us
-
@1Mbps : min=70us, max=65535us, default=150us
-
@2.5Mbps : min=36us, max=65535us, default=96us
-
@5Mbps : min=36us, max=65535us, default=92us
-
@12.5Mbps : min=36us, max=65535us, default=92us
-
@25Mbps : min=36us, max=65535us, default=92us
-
-
PWRFIP_ERR_NODE_RX_MSG_FIFO_SZ:
Invalid queue size for message consumption.
Range value should be: [1..64]. -
PWRFIP_ERR_NODE_RX_MSG_SEG_CAP:
Invalid segment capability for consumption message. Should be:-
PWRFIP_MSG_SEG_IGNORE
-
PWRFIP_MSG_SEG_ACCEPT_ALL
-
PWRFIP_MSG_SEG_ACCEPT_LTD
-
-
PWRFIP_ERR_NODE_TX_MSG_FIFO_SZ:
Invalid queue size for message transmission.
Range value should be: [1..64]. -
PWRFIP_ERR_NODE_TX_MSG_REPEAT:
Invalid maximum repeats for acknowledged message transmission.
Range value should be: [0..3]. -
PWRFIP_ERR_NODE_BA_STUP_TIMES:
The bus arbiter election time must be shorter than the start-up time. -
PWRFIP_ERR_NODE_BA_REQ_FIFO_SZ:
Invalid queue size for BA requests.
Range value should be: [1..64]. -
PWRFIP_ERR_DEV_ALREADY_BIND:
The provided device is already bound to another FIP node session. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor. -
[..]:
Other posix errors related to a file opening error
-
- Example
void usr_rst_handler(struct pwrfip_node *node)
{
/* calling the reset function for a pci/pcie device */
if (pwrfip_device_reset(node->infos->cfg.dev)) {
printf("reset failed: %s\n", pwrfip_strerror(errno));
return;
}
_print(src, evt, "reset coprocessor component (powerfip) done\n");
}
void usr_err_handler(struct pwrfip_node *node,
enum pwrfip_error_code code)
{
printf("error_handler: %s (err_code=%d)\n",
pwrfip_strerror(code), code);
}
int main(int argc, char *argv[])
{
int err = 0;
struct pwrfip_dev *dev;
struct pwrfip_node *node;
struct pwrfip_node_cfg cfg;
/* pwrfip lib initialization [mandatory] */
if (pwrfip_init()) {
printf("cannot init pwrfip library: %s\n",
pwrfip_strerror(errno));
return -1;
}
/* open a pci/pcie device (1st index) */
dev = pwrfip_device_open(1);
if (!dev) {
printf("cannot open device: %s\n",
pwrfip_strerror(errno));
pwrfip_exit();
return -1;
}
/**
* Node initialization:
* Minimal set-up for a PCI/PCIe device
*/
cfg.fip_phy_addr = 1; /* fip node addr = 0x01 */
cfg.fip_seg_num = 0; /* fip node belongs to fip segment 0 */
cfg.fip_frm_type = PWRFIP_FRM_WORLDFIP; /* WorldFIP frame (IEC) */
cfg.fip_bitrate = PWRFIP_BITRATE_1M; /* 1Mbps */
cfg.turn_around_ustime = 0; /* default TR time for 1Mbps (30us) */
cfg.silence_ustime = 0; /* default TS time for 1Mbps (150us) */
cfg.enable_bimedium = 0; /* mono-medium topology (just one channel) */
cfg.msg.enable = 0; /* fip messaging not supported */
cfg.ba.enable = 0; /* no master capability for this node */
cfg.ident.manufacturer_name = "MyVendorName\0";
cfg.ident.model_name = "MyModelName\0";
cfg.ident.revision = 0x10; /* v1.0 */
cfg.dev = dev; /* coprocessor attachment: pci/pcie device to bind */
cfg.pwrfip_error_handler = usr_err_handler; /* local handler to notify
the internal errors of
the library */
cfg.pwrfip_reset_handler = usr_rst_handler; /* local handler to reset
the bound device */
node = pwrfip_node_init(&cfg);
if (!node) {
printf("node initialization failed: %s\n",
pwrfip_strerror(errno));
err = -1;
goto end;
}
/**
* Other tasks
*/
/* ... */
end:
/**
* Node exit
*/
/*...*/
/* close device */
pwrfip_device_close(dev);
/* pwrfip lib exit [mandatory] */
pwrfip_exit();
return err;
}
4.6.2. node_exit
- Description
-
Stops the coprocessor and deallocates all resources attached to the FIP node inside the library.
- Prototype
int pwrfip_node_exit(struct pwrfip_node *node)
- Parameters
-
-
IN
-
node:
Pointer to the FIP node to exit.
Seestruct pwrfip_node
.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_node_exit()
returns 0.
If unsuccessful,pwrfip_node_exit()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input parameter. -
PWRFIP_ERR_DEV_IRQ_HANDLER_STOPPED:
Internal IRQ handler for PCI/PCIe device is already stopped. -
PWRFIP_ERR_AELE_NOT_STOP:
Cannot stop the Application/Layer entity. The exit procedure has therefore failed. -
PWRFIP_ERR_BA_NOT_STOP:
Cannot stop the bus arbiter FSM. The exit procedure has therefore failed. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.6.3. node_status_get
- Description
-
Get the FSM status of the FIP node.
- Prototype
int pwrfip_node_status_get(struct pwrfip_node *node,
struct pwrfip_node_status *status)
- Parameters
-
-
IN
-
node:
Pointer to the target FIP node.
Seestruct pwrfip_node
.
-
-
OUT
-
status:
Pointer to an outputstruct pwrfip_node_status
.
-
-
- Return Value
-
If successful,
pwrfip_node_status_get()
returns 0.
If unsuccessful,pwrfip_node_status_get()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input/output parameters. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
- Example
static const char *pwrfip_node_state_str[_PWRFIP_NODE_STATE_MAX] = {
/* PWRFIP_NODE_STATE_INITIAL */
"initial",
/* PWRFIP_NODE_STATE_LOADED */
"loaded",
/* PWRFIP_NODE_STATE_READY */
"ready",
/* PWRFIP_NODE_STATE_RUNNING */
"running",
};
static const char *pwrfip_node_op_str[_PWRFIP_NODE_OP_MAX] = {
/* _PWRFIP_NODE_OP_UNKNOWN */
"unknown",
/* PWRFIP_NODE_OP_WAIT_RX_RP_FRM */
"rx rp frame",
/* PWRFIP_NODE_OP_WAIT_TX_RP_FRM */
"tx rp frame",
/* PWRFIP_NODE_OP_WAIT_RX_ID_FRM */
"rx id frame",
/* PWRFIP_NODE_OP_WAIT_TX_ID_FRM */
"tx id frame",
};
int main(int argc, char *argv[])
{
int err = 0;
struct pwrfip_node *node;
struct pwrfip_node_status n_status;
/**
* Node initialization
*/
/*...*/
/* get node status */
err = pwrfip_node_status_get(node, &n_status);
if (err) {
printf("node status getter failed: %s\n", pwrfip_strerror(errno));
goto end;
}
printf("node_status\n");
printf(" node_state : %d (%s)\n", n_status.state,
pwrfip_node_state_str[n_status.state]);
printf(" node_op : %d (%s)\n", n_status.op,
pwrfip_node_op_str[n_status.op]);
/**
* Other tasks
*/
/* ... */
end:
/**
* Node exit
*/
/*...*/
return err;
}
4.6.4. node_report_get
- Description
-
Gets the full diagnostic report of the FIP node.
- Prototype
int pwrfip_node_report_get(struct pwrfip_node *node,
struct pwrfip_node_report *report)
- Parameters
-
-
IN
-
node:
Pointer to the target FIP node.
Seestruct pwrfip_node
.
-
-
OUT
-
report:
Pointer to an outputstruct pwrfip_node_report
.
-
-
- Return Value
-
If successful,
pwrfip_node_report_get()
returns 0.
If unsuccessful,pwrfip_node_report_get()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input/output parameters. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
- Example
static const char *pwrfip_node_state_str[_PWRFIP_NODE_STATE_MAX] = {
/* PWRFIP_NODE_STATE_INITIAL */
"initial",
/* PWRFIP_NODE_STATE_LOADED */
"loaded",
/* PWRFIP_NODE_STATE_READY */
"ready",
/* PWRFIP_NODE_STATE_RUNNING */
"running",
};
static const char *pwrfip_ba_state_str[_PWRFIP_BA_STATE_MAX] = {
/* PWRFIP_BA_STATE_INITIAL */
"initial",
/* PWRFIP_BA_STATE_READY */
"ready",
/* PWRFIP_BA_STATE_STARTING */
"starting",
/* PWRFIP_BA_STATE_IDLE */
"idle",
/* PWRFIP_BA_STATE_RUNNING */
"running",
};
static const char *pwrfip_node_op_str[_PWRFIP_NODE_OP_MAX] = {
/* _PWRFIP_NODE_OP_UNKNOWN */
"unknown",
/* PWRFIP_NODE_OP_WAIT_RX_RP_FRM */
"rx rp frame",
/* PWRFIP_NODE_OP_WAIT_TX_RP_FRM */
"tx rp frame",
/* PWRFIP_NODE_OP_WAIT_RX_ID_FRM */
"rx id frame",
/* PWRFIP_NODE_OP_WAIT_TX_ID_FRM */
"tx id frame",
};
static const char *pwrfip_ba_wind_str[_PWRFIP_BA_WIND_TYPE_MAX] = {
/* _PWRFIP_BA_WIND_TYPE_NONE */
"none",
/* PWRFIP_BA_WIND_PER */
"periodic",
/* PWRFIP_BA_WIND_APER_VAR */
"aper. var",
/* PWRFIP_BA_WIND_APER_MSG */
"aper. msg",
/* PWRFIP_BA_WIND_WAIT */
"wait",
};
int main(int argc, char *argv[])
{
int err = 0;
struct pwrfip_node *node;
struct pwrfip_node_report n_report; /* full report */
uint16_t m_state; /* medium state */
/**
* Node initialization
*/
/*...*/
/**
* Node startup
*/
/*...*/
/* get node report */
err = pwrfip_node_report_get(node, &n_report);
if (err) {
printf("node report getter failed: %s\n", pwrfip_strerror(errno));
goto end;
}
m_state = n_report.medium_status.state;
printf("** coprocessor report:\n");
printf(" node_state : %d (%s)\n", n_report.node_status.state,
pwrfip_node_state_str[n_report.node_status.state]);
printf(" node_op : %d (%s)\n", n_report.node_status.op,
pwrfip_node_op_str[n_report.node_status.op]);
printf(" ba_state : %d (%s)\n", n_report.ba_status.state,
pwrfip_ba_state_str[n_report.ba_status.state]);
printf(" ba_window : %d (%s)\n", n_report.ba_status.window,
pwrfip_ba_wind_str[n_report.ba_status.window]);
printf(" medium_state : 0x%04x\n", m_state);
printf(" [channel 1]\n");
printf(" enable : %s\n",
(m_state & PWRFIP_MEDIUM_STATE_CH1_VALID) ? "yes": "no");
printf(" tx_err : %s\n",
(m_state & PWRFIP_MEDIUM_STATE_CH1_TX_ERROR) ? "yes": "no");
printf(" watchdog : %s\n",
(m_state & PWRFIP_MEDIUM_STATE_CH1_WATCHDOG) ? "yes": "no");
printf(" [channel 2]\n");
printf(" enable : %s\n",
(m_state & PWRFIP_MEDIUM_STATE_CH2_VALID) ? "yes": "no");
printf(" tx_err : %s\n",
(m_state & PWRFIP_MEDIUM_STATE_CH2_TX_ERROR) ? "yes": "no");
printf(" watchdog : %s\n",
(m_state & PWRFIP_MEDIUM_STATE_CH2_WATCHDOG) ? "yes": "no");
printf(" tx_err :\n");
printf(" ok : %d\n", n_report.tx_err.ok);
printf(" collision : %d\n", n_report.tx_err.collision);
printf(" consistency : %d\n", n_report.tx_err.consistency);
printf(" not_fresh : %d\n", n_report.tx_err.not_fresh);
printf(" rx_err :\n");
printf(" ok : %d\n", n_report.rx_err.ok);
printf(" pre_mis : %d\n", n_report.rx_err.pre_mis);
printf(" fsd_mis : %d\n", n_report.rx_err.fsd_mis);
printf(" fsd_unk : %d\n", n_report.rx_err.fsd_unk);
printf(" fed_mis : %d\n", n_report.rx_err.fed_mis);
printf(" crc_bad : %d\n", n_report.rx_err.crc_bad);
printf(" pdu_bad : %d\n", n_report.rx_err.pdu_bad);
printf(" len_bad : %d\n", n_report.rx_err.len_bad);
printf(" not_fresh : %d\n", n_report.rx_err.not_fresh);
printf(" not_prompt : %d\n", n_report.rx_err.not_prompt);
/**
* Other tasks
*/
/* ... */
end:
/**
* Node exit
*/
/*...*/
return err;
}
4.6.5. node_start
- Description
-
Starts the FIP node.
The user’s application data (AE/LE) as well as the desired macrocycles - if the node has a master capability - are loaded into the local coprocessor database. Then, the node connects to the FIP network in passive mode (slave agent).
To switch the node to active mode (master agent), use |
- Prototype
int pwrfip_node_start(struct pwrfip_aele *aele,
struct pwrfip_ba_mcycle **mcycle_list, int mcycle_cnt)
- Parameters
-
-
IN
-
aele:
Pointer to the application context (AE/LE: FIP variables/messages) to be loaded to the coprocessor (opaque structure). -
mcycle_list:
List of pointers to the macrocycles to be loaded (opaque structures). -
mcycle_cnt:
Number of macrocycles to be loaded in the FIP coprocessor.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_node_start()
returns 0.
If unsuccessful,pwrfip_node_start()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input parameters. -
PWRFIP_ERR_AELE_NOT_STOP:
The application context to be loaded is already active elsewhere. -
PWRFIP_ERR_INVALID_CTX:
A macrocycle to be loaded do not belong to the same FIP node as the application context (AE/LE). -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.6.6. node_stop
- Description
-
Disconnects the FIP node from the network.
Use the |
- Prototype
int pwrfip_node_stop(struct pwrfip_node *node)
- Parameters
-
-
IN
-
node:
Pointer to the target FIP node.
Seestruct pwrfip_node
.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_node_stop()
returns 0.
If unsuccessful,pwrfip_node_stop()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input/output parameters. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.7. Variables
4.7.1. var_write
- Description
-
Writes a FIP variable to the local coprocessor database.
- Prototype
int pwrfip_var_write(struct pwrfip_var *var)
- Parameters
-
-
IN
-
var:
Pointer to the target variable to write.
Seestruct pwrfip_var
.
-
-
OUT
-
var:
Variable’s updated info.
Seestruct pwrfip_var
(.error
field).
-
-
- Return Value
-
If successful,
pwrfip_var_write()
returns 0.
If unsuccessful,pwrfip_var_write()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input parameters. -
PWRFIP_ERR_INVALID_CTX:
The AE/LE context attached to the variable object does not match that of the running node. -
PWRFIP_ERR_AELE_NOT_RUN:
FIP node is not running. It is therefore impossible to query the coprocessor database. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
- Remarks
-
There are two possible error levels for this operation:
-
The error returned by the
pwrfip_var_write()
function is related to a context error inside the library, or a communication error with the coprocessor.
This type of error is quite critical since it indicates a malfunction of the library. -
The
.error
field returned in thestruct pwrfip_var
(seeenum pwrfip_var_err_code
) relates directly to the FIP frame state written to the network.
It is an indicator of the quality of the frame written (good or bad freshness).
-
- Example
static struct pwrfip_var_cfg prod_var_cfg = {
.type = PWRFIP_VAR_TYPE_PROD,
.id = 0x3800,
.prod.payload_bsz = 8,
.prod.flags = \
/* enable prod status */
PWRFIP_VAR_FLAGS_REFRESH,
.prod.refreshment_ustime = 80000, /* 80ms */
.prod.evt_type = PWRFIP_EVT_TYPE_NONE,
.pwrfip_var_handler = NULL,
};
int main(int argc, char *argv[])
{
int i, err = 0;
struct pwrfip_node *node;
struct pwrfip_aele *al;
struct pwrfip_var *prod_var;
uint8_t w_byte = 0;
/**
* Node initialization
*/
/*...*/
/* create an aele context */
al = pwrfip_aele_create(node);
if (!al) {
printf("aele creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* create a production variable */
prod_var = pwrfip_var_create(al, &prod_var_cfg);
if (!prod_var) {
printf("production variable creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* node startup (slave) */
err = pwrfip_node_start(al, NULL, 0);
if (err) {
printf("node startup failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* writing loop */
for(;;) {
/* update var payload */
/* for the example, we increment all the bytes of the
frame by 1 at each write */
w_byte++;
memset(prod_var->buffer, w_byte, prod_var->bsz);
/* write it to fip network */
if (pwrfip_var_write(prod_var)) {
printf("w_var[0x%04x] failed: %s\n", prod_var->id,
pwrfip_strerror(errno));
/* we consider this error as fatal error; so we
* stop the test */
break;
}
/* check var state errors */
if (prod_var->error) {
printf("w_var[0x%04x] state error: %d\n",
prod_var->id, prod_var->error);
}
usleep(5000); /* 5ms */
}
end:
/**
* Node exit
*/
/*...*/
return err;
}
4.7.2. var_read
- Description
-
Reads a FIP variable from the local coprocessor database.
- Prototype
int pwrfip_var_read(struct pwrfip_var *var)
- Parameters
-
-
IN
-
var:
Pointer to the target variable to read.
Seestruct pwrfip_var
.
-
-
OUT
-
var:
Variable’s updated content.
-
-
- Return Value
-
If successful,
pwrfip_var_read()
returns 0.
If unsuccessful,pwrfip_var_read()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input parameters. -
PWRFIP_ERR_INVALID_CTX:
The AE/LE context attached to the variable object does not match that of the running node. -
PWRFIP_ERR_AELE_NOT_RUN:
FIP node is not running. It is therefore impossible to query the coprocessor database. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
- Remarks
-
There are two possible error levels for this operation:
-
The error returned by the
pwrfip_var_read()
function is related to a context error inside the library, or a communication error with the coprocessor.
This type of error is quite critical since it indicates a malfunction of the library. -
The
.error
field returned in thestruct pwrfip_var
(seeenum pwrfip_var_err_code
) relates directly to the FIP frame state read from the network.
It is an indicator of the quality of the frame read (good or bad freshness/promptness), but also an indicator to know if the user configuration matches with the real frame read from the FIP network (length, PDU etc).
-
- Example
static struct pwrfip_var_cfg cons_var_cfg = {
.type = PWRFIP_VAR_TYPE_CONS,
.id = 0x3801,
.cons.payload_bsz = 8,
.cons.flags = \
/* enable prod status */
PWRFIP_VAR_FLAGS_REFRESH | \
/* enable promptness checking */
PWRFIP_VAR_FLAGS_PROMPT | \
/* enable pdu + len bytes checking */
PWRFIP_VAR_FLAGS_CHK_PDU_LEN,
.cons.promptness_ustime = 100000, /* 100ms */
.cons.evt_type = PWRFIP_EVT_TYPE_NONE,
.pwrfip_var_handler = NULL,
};
int main(int argc, char *argv[])
{
int i, err = 0;
struct pwrfip_node *node;
struct pwrfip_aele *al;
struct pwrfip_var *cons_var;
/**
* Node initialization
*/
/*...*/
/* create an aele context */
al = pwrfip_aele_create(node);
if (!al) {
printf("aele creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* create a consumption variable */
cons_var = pwrfip_var_create(al, &cons_var_cfg);
if (!cons_var) {
printf("consumption variable creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* node startup (slave) */
err = pwrfip_node_start(al, NULL, 0);
if (err) {
printf("node startup failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* reading loop */
for(;;) {
if (pwrfip_var_read(cons_var)) {
printf("r_var[0x%04x] failed: %s\n", cons_var->id,
pwrfip_strerror(errno));
/* we consider this error as fatal error; so we
* stop the test */
break;
}
/* print var payload */
printf("r_var[0x%04x]: ", cons_var->id);
for (i = 0; i < cons_var->bsz; ++i)
printf("%02x ", cons_var->buffer[i]);
printf("\n");
usleep(5000); /* 5ms */
}
end:
/**
* Node exit
*/
/*...*/
return err;
}
4.7.3. var_evt_set
- Description
-
Dynamically changes - inside the coprocessor database - the event sensitivity for the pointed variable.
- Prototype
int pwrfip_var_evt_set(struct pwrfip_var *var,
enum pwrfip_evt_type type)
- Parameters
-
-
IN
-
var:
Pointer to the variable on which to change the sensitivity to events.
Seestruct pwrfip_var
. -
type:
Type of event sensitivity (seeenum pwrfip_evt_type
):-
PWRFIP_EVT_TYPE_NONE:
Never report the transmission/reception of this variable to the user space. -
PWRFIP_EVT_TYPE_PERMANENT:
Always report the transmission/reception of this variable to the user space. -
PWRFIP_EVT_TYPE_TEMPORARY:
Report just once the transmission/reception of this variable to the user space.
-
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_var_evt_set()
returns 0.
If unsuccessful,pwrfip_var_evt_set()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input parameters. -
PWRFIP_ERR_INVALID_CTX:
The AE/LE context attached to the variable object does not match that of the running node. -
PWRFIP_ERR_AELE_NOT_RUN:
FIP node is not running. It is therefore impossible to change the variable’s event on the fly. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.7.4. varidlist_aper_request
- Description
-
Sends an aperiodic request for a list of variable IDs.
- Prototype
int pwrfip_varidlist_aper_request(struct pwrfip_node *node,
uint16_t *varid_list, int varid_cnt,
enum pwrfip_var_aper_channel_type channel,
uint8_t *ch_error);
- Parameters
-
-
IN
-
node:
Pointer to the node that makes the request.
Seestruct pwrfip_node
. -
varid_list:
Pointer to a list of IDs (16-bit) to request. -
varid_cnt:
Number of IDs contained in the list. -
channel:
Channel used to make the request.
Seeenum pwrfip_var_aper_channel_type
.
-
-
OUT
-
ch_error:
Channel error.
Seeenum pwrfip_var_err_code
.
-
-
- Return Value
-
If successful,
pwrfip_varidlist_aper_request()
returns 0.
If unsuccessful,pwrfip_varidlist_aper_request()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input parameters. -
PWRFIP_ERR_AELE_NOT_RUN:
FIP node is not running. It is therefore impossible to query the coprocessor database. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
- Remarks
-
There are two possible error levels for this operation:
-
The error returned by the
pwrfip_varidlist_aper_request()
function is related to a context error inside the library, or a communication error with the coprocessor.
This type of error is quite critical since it indicates a malfunction of the library. -
The
ch_error
value indicates a potential problem with the FIP channel inside the coprocessor, but doesn’t compromise the operation of the library.
For example, if the request queue is full, usepwrfip_var_aper_channel_purge()
to clear the contents of the saturated channel.
-
- Example
static struct pwrfip_var_cfg prod_var_cfg = {
.type = PWRFIP_VAR_TYPE_PROD,
.id = 0x3800,
.prod.payload_bsz = 8,
.prod.flags = \
/* enable prod status */
PWRFIP_VAR_FLAGS_REFRESH | \
/* enable aper var request */
PWRFIP_VAR_FLAGS_APER_VAR_REQ,
.prod.refreshment_ustime = 80000, /* 80ms */
.prod.evt_type = PWRFIP_EVT_TYPE_NONE,
.pwrfip_var_handler = NULL,
};
static uint16_t ids[4] = {
0x1000,
0x1001,
0x1100,
0x1101,
};
int main(int argc, char *argv[])
{
int err = 0;
struct pwrfip_node *node;
struct pwrfip_aele *al;
uint8_t channel_error = 0;
/**
* Node initialization
*/
/*...*/
/* create an aele context */
al = pwrfip_aele_create(node);
if (!al) {
printf("aele creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* create a production variable which support aperiodic variable requests */
/* note: this variable must be queried cyclically by the master node */
prod_var = pwrfip_var_create(al, &prod_var_cfg);
if (!prod_var) {
printf("production variable creation failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* node startup (slave) */
err = pwrfip_node_start(al, NULL, 0);
if (err) {
printf("node startup failed: %s\n", pwrfip_strerror(errno));
err = -1;
goto end;
}
/* main loop */
for(;;) {
/* request for an IDs list each 1 second */
if (pwrfip_varidlist_aper_request(node, ids, 4,
PWRFIP_VAR_APER_CH_NORMAL, &channel_error)) {
printf("var_aper_request failed: %s\n", pwrfip_strerror(errno));
/* we consider this error as fatal error; so we
* stop the test */
break;
}
/* check channel error */
if (channel_error)
printf("var_aper_request state error: %d\n", channel_error);
sleep(1); /* 1s */
}
end:
/**
* Node exit
*/
/*...*/
return err;
}
4.7.5. varlist_aper_request
- Description
-
Sends an aperiodic request for a list of FIP variables.
This function is similar to |
- Prototype
int pwrfip_varlist_aper_request(struct pwrfip_node *node,
struct pwrfip_var **var_list, int var_cnt,
enum pwrfip_var_aper_channel_type channel,
uint8_t *ch_error);
- Parameters
-
-
IN
-
node:
Pointer to the node that makes the request.
Seestruct pwrfip_node
. -
var_list:
Pointer to a list of variables to request.
Seestruct pwrfip_var
. -
var_cnt:
Number of variables contained in the list. -
channel:
Channel used to make the request.
Seeenum pwrfip_var_aper_channel_type
.
-
-
OUT
-
ch_error:
Channel error.
Seeenum pwrfip_var_err_code
.
-
-
- Return Value
-
If successful,
pwrfip_varlist_aper_request()
returns 0.
If unsuccessful,pwrfip_varlist_aper_request()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input parameters. -
PWRFIP_ERR_AELE_NOT_RUN:
FIP node is not running. It is therefore impossible to query the coprocessor database. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.7.6. var_aper_channel_purge
- Description
-
Purges the target aperiodic variable channel.
- Prototype
int pwrfip_var_aper_channel_purge(struct pwrfip_node *node,
enum pwrfip_var_aper_channel_type channel,
uint16_t *purge_cnt, uint8_t *ch_error);
- Parameters
-
-
IN
-
node:
Pointer to the target node.
Seestruct pwrfip_node
. -
channel:
Channel to purge.
Seeenum pwrfip_var_aper_channel_type
.
-
-
OUT
-
purge_cnt:
Number of variable IDs purged. -
ch_error:
Channel error.
Seeenum pwrfip_var_err_code
.
-
-
- Return Value
-
If successful,
pwrfip_var_aper_channel_purge()
returns 0.
If unsuccessful,pwrfip_var_aper_channel_purge()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input parameters. -
PWRFIP_ERR_AELE_NOT_RUN:
FIP node is not running. It is therefore impossible to query the coprocessor database. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.8. System Management Variables
4.8.1. sm_ba_sync_get
- Description
-
Gets the BA synchronization information from the network (ID[0x9003]).
- Prototype
int pwrfip_sm_ba_sync_get(struct pwrfip_node *node,
struct pwrfip_sm_ba_sync *ba_sync)
- Parameters
-
-
IN
-
node:
Pointer to the target FIP node.
Seestruct pwrfip_node
.
-
-
OUT
-
ba_sync:
BA synchronization structure to retrieve.
Seestruct pwrfip_sm_ba_sync
.
-
-
- Return Value
-
If successful,
pwrfip_sm_ba_sync_get()
returns 0.
If unsuccessful,pwrfip_sm_ba_sync_get()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input/output parameters. -
PWRFIP_ERR_AELE_NOT_RUN:
FIP node is currently stopped.
It is therefore impossible to query the coprocessor database. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.8.2. sm_identification_get
- Description
-
Gets the identification information from a remote FIP node (ID[0x10XY] where XY is the remote address).
- Prototype
int pwrfip_sm_identification_get(struct pwrfip_node *node,
uint8_t node_addr, struct pwrfip_sm_identification *ident)
- Parameters
-
-
IN
-
node:
Pointer to the target FIP node (local node).
Seestruct pwrfip_node
. -
node_addr:
Remote node address to request.
-
-
OUT
-
ident:
Identification structure to retrieve from the remote node.
Seestruct pwrfip_sm_identification
.
-
-
- Return Value
-
If successful,
pwrfip_sm_identification_get()
returns 0.
If unsuccessful,pwrfip_sm_identification_get()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input/output parameters. -
PWRFIP_ERR_AELE_NOT_RUN:
FIP node is currently stopped.
It is therefore impossible to query the coprocessor database. -
PWRFIP_ERR_AELE_VAR_NOT_FOUND:
Unknown variable ID for this FIP node.
Usepwrfip_sm_var_create()
with the correct remote node address before using this function. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.8.3. sm_presence_get
- Description
-
Gets the presence information from a remote FIP node (ID[0x14XY] where XY is the remote address).
- Prototype
int pwrfip_sm_presence_get(struct pwrfip_node *node,
uint8_t node_addr, struct pwrfip_sm_presence *pres)
- Parameters
-
-
IN
-
node:
Pointer to the target FIP node (local node).
Seestruct pwrfip_node
. -
node_addr:
Remote node address to request.
-
-
OUT
-
pres:
Presence structure to retrieve from the remote node.
Seestruct pwrfip_sm_presence
.
-
-
- Return Value
-
If successful,
pwrfip_sm_presence_get()
returns 0.
If unsuccessful,pwrfip_sm_presence_get()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input/output parameters. -
PWRFIP_ERR_AELE_NOT_RUN:
FIP node is currently stopped.
It is therefore impossible to query the coprocessor database. -
PWRFIP_ERR_AELE_VAR_NOT_FOUND:
Unknown variable ID for this FIP node.
Usepwrfip_sm_var_create()
with the correct remote node address before using this function. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.8.4. sm_presence_list_get
- Description
-
Gets the presence list information from the network (ID[0x9002]).
- Prototype
int pwrfip_sm_presence_list_get(struct pwrfip_node *node,
struct pwrfip_sm_presence_list *pres_list)
- Parameters
-
-
IN
-
node:
Pointer to the target FIP node.
Seestruct pwrfip_node
.
-
-
OUT
-
pres_list:
Presence list structure to retrieve.
Seestruct pwrfip_sm_presence_list
.
-
-
- Return Value
-
If successful,
pwrfip_sm_presence_list_get()
returns 0.
If unsuccessful,pwrfip_sm_presence_list_get()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input/output parameters. -
PWRFIP_ERR_AELE_NOT_RUN:
FIP node is currently stopped.
It is therefore impossible to query the coprocessor database. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.8.5. sm_report_get
- Description
-
Gets the report information from a remote FIP node (ID[0x11XY] where XY is the remote address).
- Prototype
int pwrfip_sm_report_get(struct pwrfip_node *node,
uint8_t node_addr, struct pwrfip_sm_report *report)
- Parameters
-
-
IN
-
node:
Pointer to the target FIP node (local node).
Seestruct pwrfip_node
. -
node_addr:
Remote node address to request.
-
-
OUT
-
report:
Report structure to retrieve from the remote node.
Seestruct pwrfip_sm_report
.
-
-
- Return Value
-
If successful,
pwrfip_sm_report_get()
returns 0.
If unsuccessful,pwrfip_sm_report_get()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input/output parameters. -
PWRFIP_ERR_AELE_NOT_RUN:
FIP node is currently stopped.
It is therefore impossible to query the coprocessor database. -
PWRFIP_ERR_AELE_VAR_NOT_FOUND:
Unknown variable ID for this FIP node.
Usepwrfip_sm_var_create()
with the correct remote node address before using this function. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
4.9. Medium
4.9.1. medium_status_get
- Description
-
Get the status of the FIP channels.
- Prototype
int pwrfip_medium_status_get(struct pwrfip_node *node,
struct pwrfip_medium_status *status)
- Parameters
-
-
IN
-
node:
Pointer to the target FIP node.
Seestruct pwrfip_node
.
-
-
OUT
-
status:
Pointer to an outputstruct pwrfip_medium_status
.
-
-
- Return Value
-
If successful,
pwrfip_medium_status_get()
returns 0.
If unsuccessful,pwrfip_medium_status_get()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input/output parameters. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
- Example
int main(int argc, char *argv[])
{
int err = 0;
struct pwrfip_node *node;
struct pwrfip_medium_status m_status;
uint16_t m_state;
/**
* Node initialization
*/
/*...*/
/**
* Node startup
*/
/*...*/
/* get medium state */
err = pwrfip_medium_status_get(node, &m_status);
if (err) {
printf("medium status getter failed: %s\n", pwrfip_strerror(errno));
goto end;
}
m_state = m_status.state;
printf("medium_state : 0x%04x\n", m_state);
printf(" [channel 1]\n");
printf(" enable : %s\n",
(m_state & PWRFIP_MEDIUM_STATE_CH1_VALID) ? "yes": "no");
printf(" tx_err : %s\n",
(m_state & PWRFIP_MEDIUM_STATE_CH1_TX_ERROR) ? "yes": "no");
printf(" watchdog : %s\n",
(m_state & PWRFIP_MEDIUM_STATE_CH1_WATCHDOG) ? "yes": "no");
printf(" [channel 2]\n");
printf(" enable : %s\n",
(m_state & PWRFIP_MEDIUM_STATE_CH2_VALID) ? "yes": "no");
printf(" tx_err : %s\n",
(m_state & PWRFIP_MEDIUM_STATE_CH2_TX_ERROR) ? "yes": "no");
printf(" watchdog : %s\n",
(m_state & PWRFIP_MEDIUM_STATE_CH2_WATCHDOG) ? "yes": "no");
/**
* Other tasks
*/
/* ... */
end:
/**
* Node exit
*/
/*...*/
return err;
}
4.9.2. medium_cmd_set
- Description
-
Sends a command to the coprocessor to control the FIP channels.
The following operations are allowed for each channel:-
Enable/Disable
-
Reset
-
Clear error
-
- Prototype
int pwrfip_medium_cmd_set(struct pwrfip_node *node, uint16_t flags)
- Parameters
-
-
IN
-
node:
Pointer to the target FIP node.
Seestruct pwrfip_node
. -
flags:
Command to send to the FIP channels manager.
-
-
The available commands are described by the |
-
OUT - None
- Return Value
-
If successful,
pwrfip_medium_cmd_set()
returns 0.
If unsuccessful,pwrfip_medium_cmd_set()
returns -1 and sets errno to one of the following values:
-
EINVAL:
Invalid input parameters. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
4.10. Events
4.10.1. evt_process
- Description
-
Reads and processes all FIP asynchronous events notified by the coprocessor.
- Prototype
int pwrfip_evt_process(struct pwrfip_node *node)
- Parameters
-
-
IN
-
node:
Pointer to the node to treat.
Seestruct pwrfip_node
.
-
-
OUT - None
-
- Return Value
-
If successful,
pwrfip_evt_process()
returns 0.
If unsuccessful,pwrfip_evt_process()
returns -1 and sets errno to one of the following values:-
EINVAL:
Invalid input parameter. -
PWRFIP_ERR_COM_XXX:
Communication error with the coprocessor.
-
- Remarks
Case of PCI/PCIe devices
If a PCI/PCIe PowerFIP device is bound to the node (see In order to correctly raise the interrupt, the user must configure at least one synchronous event during the FIP periodic cycle:
|
User handlers called inside this function
|
5. Structures
5.1. General
5.1.1. date
- Description
-
Date structure.
- Definition
struct pwrfip_date {
union {
uint32_t raw;
struct {
uint8_t day;
uint8_t month;
uint8_t year;
uint8_t reserved;
} info;
};
};
- Members
Name | Type | Description |
---|---|---|
day |
|
Day of the date. |
month |
|
Month of the date. |
year |
|
Year of the date. |
5.1.2. version
- Description
-
Version structure.
- Definition
struct pwrfip_version {
union {
uint32_t raw;
struct {
uint8_t patch;
uint8_t minor;
uint8_t major;
uint8_t reserved;
} info;
};
/* build date */
struct pwrfip_date date;
};
- Members
Name | Type | Description |
---|---|---|
patch |
|
Patch version |
minor |
|
Minor version |
major |
|
Major version |
date |
|
Build date |
5.2. Device
5.2.1. dev_infos
- Description
-
System information about the PowerFIP board.
- Definition
struct pwrfip_dev_infos {
uint32_t index;
uint64_t fsn;
/* device general info */
uint16_t vid;
uint16_t did;
uint16_t ssvid;
uint16_t ssdid;
/* physical BAR addresses */
int bar_cnt;
uint64_t bar_bsz[BAR_MAX];
uint64_t bar_base[BAR_MAX];
/* irq infos */
int irq_number;
/* driver infos */
uint32_t drv_version;
uint32_t drv_date;
};
- Members
Name | Type | Description |
---|---|---|
index |
|
Device index |
fsn |
|
Factory Serial Number |
vid |
|
Vendor ID |
did |
|
Device ID |
ssvid |
|
Subsystem Vendor ID |
ssdid |
|
Subsystem Device ID |
bar_cnt |
|
Number of BAR (Base Address Register) for this device |
bar_bsz |
|
Size of the BAR areas |
bar_base |
|
Memory base start address for each area. |
irq_number |
|
IRQ number |
drv_version |
|
Driver version |
drv_date |
|
Driver built date |
5.2.2. dev_report
- Description
-
Global report of the PowerFIP board.
- Definition
struct pwrfip_dev_report {
float temperature;
};
- Members
Name | Type | Description |
---|---|---|
temperature |
|
Temperature sensor (°C) |
5.3. Configuration
5.3.1. ba_request
- Description
-
Structure used to set-up an ID_DAT/ID_MSG request during a macrocycle periodic window.
- Definition
struct pwrfip_ba_request {
enum pwrfip_ba_id_type type;
uint16_t id;
};
- Members
Name | Type | Description |
---|---|---|
type |
|
Frame control code for the request |
id |
|
FIP identifier to request |
5.3.2. ba_aper_msg_wind_cfg
- Description
-
Structure used to set-up a macrocycle aperiodic message window.
- Definition
struct pwrfip_ba_aper_msg_wind_cfg {
uint32_t end_ustime;
};
- Members
Name | Type | Description |
---|---|---|
end_ustime |
|
End of aperiodic message window in microseconds (relative to macrocycle start) |
5.3.3. ba_aper_var_wind_cfg
- Description
-
Structure used to set-up a macrocycle aperiodic variable window.
- Definition
struct pwrfip_ba_aper_var_wind_cfg {
uint32_t end_ustime;
int enable_testp;
};
- Members
Name | Type | Description |
---|---|---|
end_ustime |
|
End of aperiodic variable window in microseconds (relative to macrocycle start) |
enable_testp |
|
Enable the presence test if the bus arbiter doesn’t have other tasks to perform during this window |
5.3.4. ba_per_wind_cfg
- Description
-
Structure used to set-up a macrocycle periodic window.
- Definition
struct pwrfip_ba_per_wind_cfg {
int req_cnt;
struct pwrfip_ba_request *req_list;
};
- Members
Name | Type | Description |
---|---|---|
req_cnt |
|
Number of periodic request |
req_list |
|
List of periodic requests |
5.3.5. ba_wait_wind_cfg
- Description
-
Structure used to set-up a macrocycle wait window.
- Definition
struct pwrfip_ba_wait_wind_cfg {
uint32_t end_ustime;
int is_silent;
int is_ext_resync;
};
- Members
Name | Type | Description | ||
---|---|---|---|---|
end_ustime |
|
End of waiting window in microseconds (relative to the macrocycle start time) |
||
is_silent |
|
|
||
is_ext_resync |
|
|
5.3.6. ba_wind_cfg
- Description
-
Structure used to set-up a macrocycle window for a master FIP node.
- Definition
struct pwrfip_ba_wind_cfg {
enum pwrfip_ba_wind_type type;
union {
struct pwrfip_ba_per_wind_cfg per;
struct pwrfip_ba_aper_var_wind_cfg aper_var;
struct pwrfip_ba_aper_msg_wind_cfg aper_msg;
struct pwrfip_ba_wait_wind_cfg wait;
};
};
- Members
Name | Type | Description |
---|---|---|
type |
|
Macrocycle window type |
|
|
Specialized configuration structure according to the |
5.3.7. ba_mcycle_cfg
- Description
-
Structure used to set-up a macrocycle for a master FIP node.
- Definition
struct pwrfip_ba_mcycle_cfg {
int wind_cnt;
struct pwrfip_ba_wind_cfg *wind_list;
};
- Members
Name | Type | Description |
---|---|---|
wind_cnt |
|
Number of macrocycle window configurations |
req_list |
|
List of window configurations |
5.3.8. ba_startup_cfg
- Description
-
This structure is used to set start-up and election times of a master node (Bus Arbiter).
- Definition
struct pwrfip_ba_startup_cfg {
enum pwrfip_ba_startup_mode mode;
uint32_t silence_ustime;
uint8_t max_phy_addr;
uint8_t max_prio;
uint8_t my_phy_addr;
uint8_t my_prio;
};
- Members
Name | Type | Description | ||
---|---|---|---|---|
mode |
|
Calculation method for bus arbiter startup and election times. |
||
silence_ustime |
|
Silence time in microseconds. |
||
max_phy_addr |
|
Last FIP agent address with master capability on network. |
||
max_prio |
|
Highest BA priority on the network.
|
||
my_phy_addr |
|
Physical address of this BA. |
||
my_prio |
|
Priority of this BA.
|
5.3.9. msg_rx_cfg
- Description
-
Specific set-up structure for an incoming FIP message.
- Definition
struct pwrfip_msg_rx_cfg {
uint16_t reserved;
};
- Members
Name | Type | Description |
---|---|---|
reserved |
|
Not significant field |
5.3.10. msg_tx_cfg
- Description
-
Specific set-up structure for an outcoming FIP message.
- Definition
struct pwrfip_msg_tx_cfg {
uint8_t channel;
uint8_t ack_mode;
};
- Members
Name | Type | Description |
---|---|---|
channel |
|
Message TX channel number. |
ack_mode |
|
Message acknowledgement mode. |
5.3.11. msg_cfg
- Description
-
Generic set-up structure of a FIP message for a FIP node.
- Definition
struct pwrfip_msg_cfg {
enum pwrfip_msg_type type;
struct pwrfip_msg_hdr hdr;
union {
struct pwrfip_msg_tx_cfg tx;
struct pwrfip_msg_rx_cfg rx;
};
void *user_ctx;
void (* pwrfip_msg_handler)(struct pwrfip_node *node,
struct pwrfip_msg *msg, struct pwrfip_event *evt);
};
- Members
Name | Type | Description | ||||
---|---|---|---|---|---|---|
type |
|
Message type (Transmission, Reception). |
||||
hdr |
|
Message header. |
||||
tx/rx |
|
Specialized configuration structure according to the |
||||
user_ctx |
|
User-specified context associated with this message. |
||||
pwrfip_msg_handler |
|
Local handler definition for a message.
|
5.3.12. node_ba_cfg
- Description
-
Bus Arbiter configuration structure for a FIP node.
- Definition
struct pwrfip_node_ba_cfg {
int enable;
/**
* => BA: StartUp/Election settings
*/
uint32_t priority;
uint32_t start_ustime;
uint32_t election_ustime;
/**
* => BA: Aperiodic requests FIFOs settings
*/
uint32_t msg_req_fifo_size;
uint32_t urgent_var_req_fifo_size;
uint32_t normal_var_req_fifo_size;
};
- Members
Name | Type | Description | ||
---|---|---|---|---|
enable |
|
Enable/Disable bus arbiter (master) capability. |
||
priority |
|
Bus arbiter priority.
|
||
start_ustime |
|
Bus arbiter start-up time in microseconds.
|
||
election_ustime |
|
Bus arbiter election time in microseconds.
|
||
msg_req_fifo_size |
|
Bus arbiter queue size for aperiodic message requests. |
||
urgent_var_req_fifo_size |
|
Bus arbiter queue size for aperiodic variable requests (urgent priority). |
||
normal_var_req_fifo_size |
|
Bus arbiter queue size for aperiodic variable requests (normal priority). |
5.3.13. node_cfg
- Description
-
Node configuration structure.
- Definition
struct pwrfip_node_cfg {
/**
* General FIP settings
*/
uint8_t fip_phy_addr;
uint8_t fip_seg_num;
uint8_t fip_frm_type;
uint8_t fip_bitrate;
uint32_t turn_around_ustime;
uint32_t silence_ustime;
uint32_t watchdog_ustime;
/**
* Extra FIP settings
*/
int enable_bimedium;
struct pwrfip_node_msg_cfg msg;
struct pwrfip_node_ba_cfg ba;
struct pwrfip_node_ident_cfg ident;
struct pwrfip_node_prtcl_cfg prtcl_ext;
/**
* Hardware access
*/
struct pwrfip_dev *dev;
unsigned long dpm_base_addr;
/**
* General Handlers
*/
void *user_ctx;
void (* pwrfip_var_handler)(
struct pwrfip_node *node,
struct pwrfip_var *var,
struct pwrfip_event *evt);
void (* pwrfip_msg_recv_handler)(
struct pwrfip_node *node,
struct pwrfip_msg *msg,
struct pwrfip_event *evt);
void (* pwrfip_msg_send_handler)(
struct pwrfip_node *node,
struct pwrfip_msg *msg,
struct pwrfip_event *evt);
void (* pwrfip_urg_req_handler)(
struct pwrfip_node *node,
struct pwrfip_event *evt);
void (* pwrfip_nor_req_handler)(
struct pwrfip_node *node,
struct pwrfip_event *evt);
void (* pwrfip_ba_state_handler)(
struct pwrfip_node *node,
struct pwrfip_event *evt);
void (* pwrfip_ba_sync_handler)(
struct pwrfip_node *node,
struct pwrfip_var *var,
struct pwrfip_event *evt);
void (* pwrfip_error_handler)(
struct pwrfip_node *node,
enum pwrfip_error_code error);
void (* pwrfip_reset_handler)(
struct pwrfip_node *node);
};
- Members
Name | Type | Description | ||
---|---|---|---|---|
fip_phy_addr |
|
Physical address of the agent (node address) |
||
fip_seg_num |
|
FIP segment number to which the agent belongs |
||
fip_frm_type |
|
FIP frame type |
||
fip_bitrate |
|
FIP bitrate |
||
turn_around_ustime |
|
Turn-Around time in microseconds (0=default time)
|
||
silence_ustime |
|
Silence time in microseconds (0=default time)
|
||
watchdog_ustime |
|
Watchdog time in us (0=disabled). |
||
enable_bimedium |
|
Enable/Disable Medium redundancy (eq. fieldual) |
||
msg |
|
Messaging capability. |
||
ba |
|
Master (Bus Arbiter) capability. |
||
ident |
|
Node identification. |
||
prtcl_ext |
|
Protocol extension capability. |
||
dev |
|
PCI/PCIe device to bind with node. |
||
dpm_base_addr |
|
Dual-port memory area start address |
||
user_ctx |
|
User context pointer |
||
pwrfip_var_handler |
|
General variable handler (Node Level) |
||
pwrfip_msg_recv_handler |
|
General message reception handler |
||
pwrfip_msg_send_handler |
|
General message emission handler |
||
pwrfip_urg_req_handler |
|
Urgent aperiodic variable transmission request handler |
||
pwrfip_nor_req_handler |
|
Normal aperiodic variable transmission request handler |
||
pwrfip_ba_state_handler |
|
Bus arbiter state event handler |
||
pwrfip_ba_sync_handler |
|
Dedicated handler for the SM-MPS BA synchronization variable (0x9003).
|
||
pwrfip_error_handler |
|
Internal library error handler |
||
pwrfip_reset_handler |
|
Reset chip procedure handler |
- Remarks
|
5.3.14. node_ident_cfg
- Description
-
Identification configuration structure.
This structure allows to create the SM-MPS identification variable in production for the local FIP node.
(0x10XY where XY is node address). - Definition
struct pwrfip_node_ident_cfg {
char *manufacturer_name;
char *model_name;
uint8_t revision;
char *tag_name;
char *vendor_field;
};
- Members
Name | Type | Description |
---|---|---|
manufacturer_name |
|
Vendor (or manufacturer) name in ASCII. |
model_name |
|
Model name in ASCII. |
revision |
|
Revision number (ex: 0x23 [v2.3]). |
tag_name |
|
Tag name. |
vendor_field |
|
Additional information. Free for the vendor. |
5.3.15. node_msg_cfg
- Description
-
Messaging configuration structure for a FIP node.
- Definition
#define PWRFIP_MSG_TX_CH_PER_CNT 8
struct pwrfip_node_msg_cfg {
int enable;
/**
* => Reception settings
*/
uint32_t rx_fifo_size;
uint8_t rx_segment_tab[256];
/**
* => Emission settings
*/
uint32_t tx_aper_fifo_size;
uint32_t tx_per_fifo_size[PWRFIP_MSG_TX_CH_PER_CNT];
uint16_t tx_per_fifo_id[PWRFIP_MSG_TX_CH_PER_CNT];
uint8_t tx_max_repeat;
};
- Members
Name | Type | Description |
---|---|---|
enable |
|
Enable/Disable FIP messaging. If disabled, all other structure members are non significant. |
rx_fifo_size |
|
Consumption queues sizes for FIP messages |
rx_segment_tab[256] |
|
Sensitivity of the node for the message reception according to the segment destination. |
tx_aper_fifo_size |
|
Transmission queues sizes for FIP aperiodic messages. |
tx_per_fifo_size[8] |
|
Transmission queues sizes for FIP periodic messages (8 channels). |
tx_per_fifo_id[8] |
|
FIP identifier attached to the periodic message transmission queue (8 channels). |
tx_max_repeat |
|
Number of retries to send a message if no acknowledgement received. |
5.3.16. node_prtcl_cfg
- Description
-
Protocol extension configuration structure.
Do not use this structure configuration if you want to keep the strict definition of the FIP/WorldFIP protocol (IEC 61158) |
- Definition
struct pwrfip_node_prtcl_cfg {
int enable;
int enable_var_long_form;
};
- Members
Name | Type | Description | ||
---|---|---|---|---|
enable |
|
Enable/Disable protocol extension capability. |
||
enable_var_long_form |
|
Extend FIP/WorldFIP variable length:
|
5.3.17. var_cons_cfg
- Description
-
Specific set-up structure for a consumption FIP variable.
- Definition
struct pwrfip_var_cons_cfg {
uint16_t payload_bsz;
uint16_t flags;
uint32_t promptness_ustime;
uint32_t evt_type;
};
- Members
Name | Type | Description |
---|---|---|
payload_bsz |
|
User data payload in bytes |
flags |
|
Set-up flags for consumption. |
promptness_ustime |
|
Promptness period in microseconds |
evt_type |
|
Set-up flags for event (Enable/Disable + Lifetime). |
5.3.18. var_prod_cfg
- Description
-
Specific set-up structure for a production FIP variable.
- Definition
struct pwrfip_var_prod_cfg {
uint16_t payload_bsz;
uint16_t flags;
uint32_t refreshment_ustime;
uint32_t evt_type;
};
- Members
Name | Type | Description |
---|---|---|
payload_bsz |
|
User data payload in bytes |
flags |
|
Set-up flags for production. |
refreshment_ustime |
|
Refresment period in microseconds |
evt_type |
|
Set-up flags for event (Enable/Disable + Lifetime). |
5.3.19. var_sync_cfg
- Description
-
Specific set-up structure for a synchronization FIP variable.
- Definition
struct pwrfip_var_sync_cfg {
uint32_t reserved[3];
};
- Members
Name | Type | Description |
---|---|---|
reserved |
|
Unused parameters |
- Remarks
-
A synchronization data has no user payload attached to it (no RP_DAT frame on network).
Only a FIP identifier and a permanent event are set-up.
When the ID_DAT frame associated with this FIP identifier is received - or produced (master) - by the node, an event is triggered and the user handler is executed.
5.3.20. var_cfg
- Description
-
Generic set-up structure of a FIP variable for a FIP node.
- Definition
struct pwrfip_var_cfg {
enum pwrfip_var_type type;
uint16_t id;
union {
struct pwrfip_var_cons_cfg cons;
struct pwrfip_var_prod_cfg prod;
struct pwrfip_var_sync_cfg sync;
};
void *user_ctx;
void (* pwrfip_var_handler) (
struct pwrfip_node *node,
struct pwrfip_var *var,
struct pwrfip_event *evt
);
};
- Members
Name | Type | Description | ||||
---|---|---|---|---|---|---|
type |
|
Variable type (Production, Consumption or Synchronization) |
||||
id |
|
FIP identifier |
||||
cons/prod/sync |
|
Specialized configuration structure according to the |
||||
user_ctx |
|
User-specified context associated with this variable. |
||||
pwrfip_var_handler |
|
Local handler definition for a synchronization variable.
|
5.4. Objects
5.4.1. msg
- Description
-
FIP Message object.
This is the handle structure to interact with a FIP message. - Definition
struct pwrfip_msg {
struct pwrfip_msg_hdr hdr;
uint16_t bsz;
uint8_t *buffer;
uint64_t epoch;
uint8_t channel_num;
uint8_t error;
void *user_ctx;
void *priv;
};
- Members
Name | Type | Description |
---|---|---|
hdr |
|
Message header. |
bsz |
|
Useful message byte size (without header). |
buffer |
|
Pointer to the useful message data. |
epoch |
|
RX/TX epoch info. |
channel_num |
|
RX/TX channel number.
|
error |
|
Error code for the read/write operation on the message (eq. msg_state). |
user_ctx |
|
User-specified context. |
priv |
|
Pointer to a reserved opaque structure |
5.4.2. node
- Description
-
FIP Node object.
This is the handle structure to interact with a FIP node. - Definition
struct pwrfip_node {
struct pwrfip_node_infos *infos;
void *priv;
};
- Members
Name | Type | Description |
---|---|---|
infos |
|
Pointer to the FIP node information |
priv |
|
Pointer to a reserved opaque structure |
5.4.3. var
- Description
-
FIP Variable object.
This is the handle structure to interact with a FIP variable. - Definition
struct pwrfip_var {
uint16_t id;
uint16_t bsz;
uint8_t *buffer;
struct {
uint32_t prod_ustime;
uint32_t send_ustime;
uint32_t cons_ustime;
} time_info;
uint8_t error;
void *user_ctx;
void *priv;
};
- Members
Name | Type | Description |
---|---|---|
id |
|
FIP identifier of the variable |
bsz |
|
Useful variable byte size |
buffer |
|
Pointer to the useful variable data. |
prod_ustime |
|
|
send_ustime |
|
Frame transmission time on the network in microseconds. |
cons_ustime |
|
Time in microseconds between last variable reception from the network and its reading from local database by user. (Only significant for consumed variables) |
error |
|
Error code for the read/write operation on the variable (eq. var_state). |
user_ctx |
|
User-specified context. |
priv |
|
Pointer to a reserved opaque structure |
5.5. Infos/Status/Report
5.5.1. ba_status
- Description
-
Bus Arbiter status of FIP coprocessor.
- Definition
struct pwrfip_ba_status {
uint16_t state;
uint16_t window;
uint32_t index;
};
- Members
Name | Type | Description |
---|---|---|
state |
|
Bus arbiter state |
window |
|
Macrocycle window currently active |
index |
|
Macrocycle index currently active |
5.5.2. medium_status
- Description
-
Medium (Channels) status of FIP coprocessor.
- Definition
struct pwrfip_medium_status {
uint16_t state;
uint16_t reserved;
};
- Members
Name | Type | Description |
---|---|---|
state |
|
Medium state. See |
reserved |
|
Reserved field. |
5.5.3. node_infos
- Description
-
Structure containing information about the FIP node (node configuration, software versions/dates).
- Definition
struct pwrfip_node_infos {
struct pwrfip_node_cfg cfg;
uint64_t cpu_id;
uint32_t bss_bsz;
uint32_t bss_max_bsz;
struct pwrfip_version gw_version;
struct pwrfip_version fw_version;
struct pwrfip_version drv_version;
struct pwrfip_version lib_version;
};
- Members
Name | Type | Description |
---|---|---|
cfg |
|
User configuration attached to the node |
cpu_id |
|
Coprocessor unique identifier |
bss_bsz |
|
Size in bytes of the node data contained in the BSS space of the coprocessor |
bss_max_bsz |
|
Maximum size in bytes of the coprocessor BSS space |
gw_version |
|
Coprocessor gateware version (FPGA) |
fw_version |
|
Coprocessor firmware version (C binary) |
drv_version |
|
Driver version |
lib_version |
|
Library version |
5.5.4. node_report
- Description
-
Global report of the FIP coprocessor.
- Definition
struct pwrfip_node_report {
struct pwrfip_node_status node_status;
struct pwrfip_ba_status ba_status;
struct pwrfip_medium_status medium_status;
/* stats */
struct pwrfip_tx_err tx_err;
struct pwrfip_rx_err rx_err;
};
- Members
Name | Type | Description |
---|---|---|
node_status |
|
Node FSM and operation status |
ba_status |
|
Bus arbiter FSM and window status |
medium_status |
|
Medium (Channels) Status |
tx_err |
|
Transmission errors statistics |
rx_err |
|
Reception errors statistics |
5.5.5. node_status
- Description
-
General status of FIP node.
- Definition
struct pwrfip_node_status {
uint16_t state;
uint16_t op;
};
- Members
Name | Type | Description |
---|---|---|
state |
|
Node state |
op |
|
Operation currently in progress |
5.5.6. rx_err
- Description
-
Report of RX error by the coprocessor.
- Definition
struct pwrfip_rx_err {
/**
* MAU frame errors
*/
/* no mau rx error occurs */
uint64_t ok;
/* -> Physical Layer errors */
uint64_t pre_mis;
uint64_t fsd_mis;
uint64_t fsd_unk;
uint64_t fed_mis;
/* -> Data-Link Layer errors */
uint64_t crc_bad;
uint64_t reserved[10];
/**
* Application layer errors
*/
uint64_t pdu_bad;
uint64_t len_bad;
uint64_t not_fresh;
uint64_t not_prompt;
};
- Members
Name | Type | Description |
---|---|---|
ok |
|
Frame Ok. No MAU TX error occurs |
pre_mis |
|
Missing preamble (glitches on line) |
fsd_mis |
|
Missing Frame Start Delimiter (FSD) |
fsd_unk |
|
Unknown Frame Start Delimiter (FSD) |
fed_mis |
|
Missing Frame End Delimiter (FED) |
crc_bad |
|
Wrong Cyclic Redundancy Check (CRC) |
reserved |
|
Internal errors (not documented) |
pdu_bad |
|
Unknown FIP Protocol Data Unit (PDU) |
len_bad |
|
Bad FIP frame length (LEN) |
not_fresh |
|
Consumed variable has not been correctly refreshed |
not_prompt |
|
Consumed variable is not prompt. |
5.5.7. tx_err
- Description
-
Report of TX error by the coprocessor.
- Definition
struct pwrfip_tx_err {
/**
* Medium Attachment Unit (MAU) errors
*/
uint64_t ok;
uint64_t collision;
uint64_t consistency;
uint64_t reserved[5];
/**
* Application layer errors
*/
uint64_t not_fresh;
};
- Members
Name | Type | Description |
---|---|---|
ok |
|
Frame Ok. No MAU TX error occurs |
collision |
|
Other frame present on network during transmission |
consistency |
|
The coprocessor listens to the FIP line at the time of its own transmission. |
reserved |
|
Internal errors (not documented) |
not_fresh |
|
Produced variable is not correctly refreshed inside local database |
5.5.8. sm_ba_sync
- Description
-
This structure allows to retrieve the BA synchronization SM-MPS variable (0x9003) from network.
For more information about this variable, see thisappendix
. - Definition
struct pwrfip_sm_ba_sync {
uint8_t addr;
uint8_t mcycle_num;
struct pwrfip_var *var;
};
- Members
Name | Type | Description |
---|---|---|
addr |
|
Master node address (Bus Arbiter). |
mcycle_num |
|
Macrocycle number in progress. |
var |
|
pointer to 0x9003 SM-MPS variable. |
5.5.9. sm_identification
- Description
-
This structure allows to retrieve an identification SM-MPS variable (0x10XY) from network.
For more information about this variable, see thisappendix
. - Definition
struct pwrfip_sm_identification {
char manufacturer_name[128];
char model_name[128];
uint8_t revision;
char tag_name[128];
uint8_t smmps_class;
char vendor_field[128];
struct pwrfip_var *var;
};
- Members
Name | Type | Description |
---|---|---|
manufacturer_name |
|
Vendor (or manufacturer) name in ASCII. |
model_name |
|
Model name in ASCII. |
revision |
|
Revision number (ex: 0x23 [v2.3]). |
tag_name |
|
Tag name. |
smmps_class |
|
SM-MPS conformity class. |
vendor_field |
|
Additional information of the vendor. |
var |
|
pointer to 0x10XY SM-MPS variable. |
5.5.10. sm_presence
- Description
-
This structure allows to retrieve a presence SM-MPS variable (0x14XY) from network.
For more information about this variable, see thisappendix
. - Definition
struct pwrfip_sm_presence {
uint8_t ident_len;
uint8_t ba_state;
uint8_t ba_prio;
struct pwrfip_var *var;
};
- Members
Name | Type | Description |
---|---|---|
ident_len |
|
Length of the SM-MPS identification variable related to this node. |
ba_state |
|
Bus arbiter state. |
ba_prio |
|
BA priority of the node (if master supported). |
var |
|
pointer to 0x14XY SM-MPS variable. |
5.5.11. sm_presence_list
- Description
-
This structure allows to retrieve the presence list SM-MPS variable (0x9002) from network.
For more information about this variable, see thisappendix
. - Definition
struct pwrfip_sm_presence_list {
int count;
uint8_t addr[256];
struct pwrfip_var *var;
};
- Members
Name | Type | Description |
---|---|---|
count |
|
Count of present FIP nodes on network. |
addr |
|
Adresses table of present FIP nodes. |
var |
|
pointer to 0x9002 SM-MPS variable. |
5.5.12. sm_report
- Description
-
This structure allows to retrieve a report SM-MPS variable (0x11XY) from network.
For more information about this variable, see thisappendix
. - Definition
union pwrfip_sm_report_ch_status {
uint16_t value;
struct {
uint16_t tx_quality_ch1:1;
uint16_t tx_quality_ch2:1;
uint16_t rx_quality_ch1:1;
uint16_t rx_quality_ch2:1;
uint16_t valid_ch1:1;
uint16_t valid_ch2:1;
uint16_t traffic_ch1:1;
uint16_t traffic_ch2:1;
uint16_t summary_ch1:1;
uint16_t summary_ch2:1;
uint16_t reserved:6;
};
};
struct pwrfip_sm_report {
uint16_t rx_ok_ch1;
uint16_t rx_ok_ch2;
uint16_t rx_nok_ch1;
uint16_t rx_nok_ch2;
union pwrfip_sm_report_ch_status channel_status;
struct pwrfip_var *var;
};
- Members
Name | Type | Description |
---|---|---|
rx_ok_ch1 |
|
Frames correctly received on channel 1 by time unit. |
rx_ok_ch2 |
|
Frames correctly received on channel 2 by time unit. |
rx_nok_ch1 |
|
Frames incorrectly received on channel 1 by time unit. |
rx_nok_ch2 |
|
Frames incorrectly received on channel 2 by time unit. |
channel_status |
|
Medium status of the node. |
var |
|
pointer to 0x11XY SM-MPS variable. |
5.6. Extras
5.6.1. event
- Description
-
FIP event.
- Definition
struct pwrfip_event {
uint64_t epoch;
uint16_t code;
uint16_t param;
uint32_t reserved[2];
};
- Members
Name | Type | Description |
---|---|---|
epoch |
|
Event epoch (10ns) |
code |
|
Event Code |
param |
|
Event Parameter. |
reserved |
|
Not documented fields |
5.6.2. msg_addr
- Description
-
FIP message address.
- Definition
struct pwrfip_msg_addr {
union {
uint32_t addr;
struct {
union {
uint8_t seg;
struct {
uint8_t seg_num:7;
uint8_t seg_group:1;
};
};
union {
uint16_t lsap;
struct {
uint16_t lsap_num:15;
uint16_t lsap_group:1;
};
};
uint8_t reserved;
};
};
};
- Members
Name | Type | Description |
---|---|---|
addr |
|
Data Link Layer (DLL) address |
seg |
|
FIP Segment field |
seg_num |
|
FIP Segment number |
seg_group |
|
Segment group:
|
lsap |
|
Link Service Access Point (LSAP) |
lsap_num |
|
LSAP number |
lsap_group |
|
LSAP group:
|
reserved |
|
Reserved field |
5.6.3. msg_hdr
- Description
-
FIP Message header.
- Definition
struct pwrfip_msg_hdr {
struct pwrfip_msg_addr src;
struct pwrfip_msg_addr dst;
};
- Members
Name | Type | Description |
---|---|---|
src |
|
Message source address. |
dst |
|
Message destination address. |
6. Enumerations
6.1. ba_id_type
- Description
-
ID request type allowed inside a macrocycle periodic window (for a master node only).
- Definition
enum pwrfip_ba_id_type {
PWRFIP_BA_ID_DAT = 0x03,
PWRFIP_BA_ID_MSG = 0x05,
};
- Values
Constant | Value | Description |
---|---|---|
PWRFIP_BA_ID_DAT |
0x03 |
Bus arbiter request for a FIP variable. |
PWRFIP_BA_ID_MSG |
0x05 |
Bus arbiter request for a FIP message. |
6.2. ba_startup_mode
- Description
-
Start-up mode of the bus arbiter.
In a context where several bus arbiters are competing on the network to become master, it is necessary to give election priorities for each of them.
This enumeration defines these calculation methods (or mode) allowing to set-up the start-up/election times of the bus arbiter according to the characteristics of the FIP node.
Bus Arbiter 's Start-up and Election times
Where T0 is the Silence Time in microseconds. |
- Definition
enum pwrfip_ba_startup_mode {
PWRFIP_BA_STUP_STANDARD,
PWRFIP_BA_STUP_OPTIMIZE_1,
PWRFIP_BA_STUP_OPTIMIZE_2,
PWRFIP_BA_STUP_OPTIMIZE_3,
};
- Values
Constant | Value | Description | ||
---|---|---|---|---|
PWRFIP_BA_STUP_STANDARD |
0 |
|
||
PWRFIP_BA_STUP_OPTIMIZE_1 |
1 |
|
||
PWRFIP_BA_STUP_OPTIMIZE_2 |
2 |
|
||
PWRFIP_BA_STUP_OPTIMIZE_3 |
3 |
|
- Remarks
-
These times can be automatically calculated with
pwrfip_ba_startup_calculate()
function.
6.3. ba_state
- Description
-
State of the bus arbiter.
- Definition
enum pwrfip_ba_state {
PWRFIP_BA_STATE_INITIAL,
PWRFIP_BA_STATE_READY,
PWRFIP_BA_STATE_STARTING,
PWRFIP_BA_STATE_IDLE,
PWRFIP_BA_STATE_RUNNING,
_PWRFIP_BA_STATE_MAX,
};
- Values
Constant | Value | Description |
---|---|---|
PWRFIP_BA_STATE_INITIAL |
0 |
Initial state. No bus arbiter config loaded |
PWRFIP_BA_STATE_READY |
1 |
User macrocycles context loaded. |
PWRFIP_BA_STATE_STARTING |
2 |
Starting-up state (not yet active). |
PWRFIP_BA_STATE_IDLE |
3 |
Idle state (maybe another bus arbiter is active on network) |
PWRFIP_BA_STATE_RUNNING |
4 |
Running state. |
_PWRFIP_BA_STATE_MAX |
5 |
Max BA state number |
6.4. ba_wind_type
- Description
-
Type of macrocycle window.
- Definition
enum pwrfip_ba_wind_type {
_PWRFIP_BA_WIND_TYPE_NONE,
_PWRFIP_BA_WIND_TYPE_MIN,
PWRFIP_BA_WIND_PER = _PWRFIP_BA_WIND_TYPE_MIN,
PWRFIP_BA_WIND_APER_VAR,
PWRFIP_BA_WIND_APER_MSG,
PWRFIP_BA_WIND_WAIT,
_PWRFIP_BA_WIND_TYPE_MAX,
};
- Values
Constant | Value | Description |
---|---|---|
_PWRFIP_BA_WIND_TYPE_NONE |
0 |
Invalid BA window type |
_PWRFIP_BA_WIND_TYPE_MIN |
1 |
Minimal valid type for a bus arbiter window |
PWRFIP_BA_WIND_PER |
1 |
Periodic window |
PWRFIP_BA_WIND_APER_VAR |
2 |
Aperiodic variable window |
PWRFIP_BA_WIND_APER_MSG |
3 |
Aperiodic message window |
PWRFIP_BA_WIND_WAIT |
4 |
External/Internal resync waiting window |
_PWRFIP_BA_WIND_TYPE_MAX |
5 |
Maximal valid type for a bus arbiter window |
6.5. bitrate
- Description
-
FIP bitrate.
- Definition
enum pwrfip_bitrate {
_PWRFIP_BITRATE_MIN = 1,
PWRFIP_BITRATE_31K25 = _PWRFIP_BITRATE_MIN,
PWRFIP_BITRATE_1M,
PWRFIP_BITRATE_2M5,
PWRFIP_BITRATE_5M,
PWRFIP_BITRATE_12M5,
PWRFIP_BITRATE_25M,
_PWRFIP_BITRATE_MAX,
_PWRFIP_BITRATE_UNKNOWN = 0,
};
- Values
Constant | Value | Description |
---|---|---|
_PWRFIP_BITRATE_MIN |
1 |
Minimum valid enum code for bitrate. |
PWRFIP_BITRATE_31K25 |
1 |
FIP/WorldFIP bitrate at 31.25Kbps. |
PWRFIP_BITRATE_1M |
2 |
FIP/WorldFIP bitrate at 1Mbps. |
PWRFIP_BITRATE_2M5 |
3 |
FIP/WorldFIP bitrate at 2.5Mbps. |
PWRFIP_BITRATE_5M |
4 |
FIP/WorldFIP bitrate at 5Mbps. |
PWRFIP_BITRATE_12M5 |
5 |
FIP/WorldFIP bitrate at 12.5Mbps. |
PWRFIP_BITRATE_25M |
6 |
FIP/WorldFIP bitrate at 25Mbps. |
_PWRFIP_BITRATE_MAX |
7 |
Maximum enum code for bitrate. |
_PWRFIP_BITRATE_UNKNOWN |
0 |
Not supported or unknown FIP bitrate. |
6.6. error_code
- Description
-
Library and coprocessor communication error codes.
- Definition
enum pwrfip_error_code {
_PWRFIP_ERR_CODE_MIN = 256,
/* library error codes */
PWRFIP_ERR_DEV_ALREADY_BIND = _PWRFIP_ERR_CODE_MIN,
PWRFIP_ERR_DEV_IRQ_HANDLER_STARTED,
PWRFIP_ERR_DEV_IRQ_HANDLER_STOPPED,
PWRFIP_ERR_DEV_DIAG_TASK_STARTED,
PWRFIP_ERR_DEV_DIAG_TASK_STOPPED,
PWRFIP_ERR_AELE_NOT_STOP,
PWRFIP_ERR_AELE_NOT_RUN,
PWRFIP_ERR_AELE_VAR_NOT_FOUND,
PWRFIP_ERR_BA_NOT_STOP,
PWRFIP_ERR_BA_NOT_RUN,
PWRFIP_ERR_INVALID_CTX,
PWRFIP_ERR_CFG_VAR_TYPE_UNKNOWN,
PWRFIP_ERR_CFG_VAR_DIR,
PWRFIP_ERR_CFG_MSG_PROD,
PWRFIP_ERR_CFG_MSG_DIR,
PWRFIP_ERR_CFG_VAR_EXIST,
PWRFIP_ERR_CFG_MSG_EXIST,
PWRFIP_ERR_CFG_VAR_BAD_LEN,
PWRFIP_ERR_CFG_MSG_TYPE_UNKNOWN,
PWRFIP_ERR_CFG_MSG_TX_ACK_MODE_UNKNOWN,
PWRFIP_ERR_CFG_MSG_TX_CH_PER_EXIST,
PWRFIP_ERR_CFG_MSG_TX_CH_PER_UNKNOWN,
PWRFIP_ERR_CFG_MSG_TX_CH_PER_NOID,
PWRFIP_ERR_MCYCLE_WIND_COUNT,
PWRFIP_ERR_MCYCLE_WIND_UNKNOWN,
PWRFIP_ERR_MCYCLE_WIND_END,
PWRFIP_ERR_MCYCLE_PER_WIND_REQ_COUNT,
PWRFIP_ERR_MCYCLE_PER_WIND_REQ_UNKNOWN,
PWRFIP_ERR_MCYCLE_WIND_TIME_INC,
PWRFIP_ERR_NODE_BSS_OVERFLOW,
PWRFIP_ERR_NODE_HANDLER_MISSING,
PWRFIP_ERR_NODE_FRM_TYPE_INVALID,
PWRFIP_ERR_NODE_BITRATE_INVALID,
PWRFIP_ERR_NODE_MSG_CAP_NOT_SUPPORTED,
PWRFIP_ERR_NODE_RX_MSG_FIFO_SZ,
PWRFIP_ERR_NODE_RX_MSG_SEG_CAP,
PWRFIP_ERR_NODE_TX_MSG_FIFO_SZ,
PWRFIP_ERR_NODE_TX_MSG_REPEAT,
PWRFIP_ERR_NODE_BA_STUP_TIMES,
PWRFIP_ERR_NODE_BA_REQ_FIFO_SZ,
PWRFIP_ERR_NODE_TR_INVALID,
PWRFIP_ERR_NODE_TS_INVALID,
PWRFIP_ERR_NODE_IDENT_PARAM,
PWRFIP_ERR_NODE_IDENT_LEN,
PWRFIP_ERR_BA_STUP_TS_INVALID,
PWRFIP_ERR_BA_STUP_PHY_ADDR_INVALID,
PWRFIP_ERR_BA_STUP_PRIO_INVALID,
/* communication errors codes (mailboxes) */
_PWRFIP_ERR_COM_CODE_OFFSET,
PWRFIP_ERR_COM_DIR_UNKNOWN = _PWRFIP_ERR_COM_CODE_OFFSET,
PWRFIP_ERR_COM_NOT_OUTBOX,
PWRFIP_ERR_COM_NOT_INBOX,
PWRFIP_ERR_COM_INVAL,
PWRFIP_ERR_COM_TMO,
PWRFIP_ERR_COM_BUSY,
PWRFIP_ERR_COM_NO_PKT,
PWRFIP_ERR_COM_PKT_BAD_SZ,
PWRFIP_ERR_COM_PKT_BAD_CMD,
PWRFIP_ERR_COM_PKT_RES_FAILED,
PWRFIP_ERR_COM_DMA_BAD_OP,
_PWRFIP_ERR_CODE_MAX,
};
- Values
Constant | Description | ||
---|---|---|---|
PWRFIP_ERR_DEV_ALREADY_BIND |
The device is already bound to another FIP node session. |
||
PWRFIP_ERR_DEV_IRQ_HANDLER_STARTED |
IRQ handler is already started. |
||
PWRFIP_ERR_DEV_IRQ_HANDLER_STOPPED |
IRQ handler is already stopped. |
||
PWRFIP_ERR_DEV_DIAG_TASK_STARTED |
Diagnostic task is already started. |
||
PWRFIP_ERR_DEV_DIAG_TASK_STOPPED |
Diagnostic task is already stopped. |
||
PWRFIP_ERR_AELE_NOT_STOP |
FIP node is currently running. |
||
PWRFIP_ERR_AELE_NOT_RUN |
FIP node is currently stopped. |
||
PWRFIP_ERR_AELE_VAR_NOT_FOUND |
Unknown variable ID for this FIP node. |
||
PWRFIP_ERR_BA_NOT_STOP |
Macrocycle (BA) is not stopped. |
||
PWRFIP_ERR_BA_NOT_RUN |
No BA is currently running. |
||
PWRFIP_ERR_INVALID_CTX |
Objects (aele, mcycle…) do not belong to the same node context. |
||
PWRFIP_ERR_CFG_VAR_TYPE_UNKNOWN |
Unknown variable type. |
||
PWRFIP_ERR_CFG_VAR_DIR |
Impossible to change the direction of the variable (prod/cons) for this ID. |
||
PWRFIP_ERR_CFG_MSG_PROD |
Impossible to link a produced message on this ID. A consumed variable is already attached to it. |
||
PWRFIP_ERR_CFG_MSG_DIR |
Impossible to change direction. A produced message is already attached to it. |
||
PWRFIP_ERR_CFG_VAR_EXIST |
A variable already exists for this ID. |
||
PWRFIP_ERR_CFG_MSG_EXIST |
A message already exists with this header. |
||
PWRFIP_ERR_CFG_VAR_BAD_LEN |
Incorrect payload size configuration.
|
||
PWRFIP_ERR_CFG_MSG_TYPE_UNKNOWN |
Unknown message type. |
||
PWRFIP_ERR_CFG_MSG_TX_ACK_MODE_UNKNOWN |
Unknown message acknowledgement mode. |
||
PWRFIP_ERR_CFG_MSG_TX_CH_PER_EXIST |
A periodic message channel is already attached to this ID. |
||
PWRFIP_ERR_CFG_MSG_TX_CH_PER_UNKNOWN |
Unknown periodic message channel number. |
||
PWRFIP_ERR_CFG_MSG_TX_CH_PER_NOID |
No ID attached to this periodic message channel number. |
||
PWRFIP_ERR_MCYCLE_WIND_COUNT |
Invalid macrocycle windows count (should be at least 1). |
||
PWRFIP_ERR_MCYCLE_WIND_UNKNOWN |
Unknown macrocycle windows type. |
||
PWRFIP_ERR_MCYCLE_WIND_END |
Invalid macrocycle (should end with a WAIT window). |
||
PWRFIP_ERR_MCYCLE_PER_WIND_REQ_COUNT |
At least one request is required for BA periodic window. |
||
PWRFIP_ERR_MCYCLE_PER_WIND_REQ_UNKNOWN |
Unknown macrocycle periodic request (ID_DAT or ID_MSG). |
||
PWRFIP_ERR_MCYCLE_WIND_TIME_INC |
Overlap on macrocycle windows end times. |
||
PWRFIP_ERR_NODE_BSS_OVERFLOW |
BSS overflow. Queues size of the node should be reduced. |
||
PWRFIP_ERR_NODE_HANDLER_MISSING |
Reset/Error/Warning handlers are mandatory. |
||
PWRFIP_ERR_NODE_FRM_TYPE_INVALID |
Invalid frame type (FIP or WorldFIP). |
||
PWRFIP_ERR_NODE_BITRATE_INVALID |
Invalid node bitrate configuration. |
||
PWRFIP_ERR_NODE_MSG_CAP_NOT_SUPPORTED |
The node does not support messaging capability. |
||
PWRFIP_ERR_NODE_RX_MSG_FIFO_SZ |
Queue size for message consumption should be in [1..64] range. |
||
PWRFIP_ERR_NODE_RX_MSG_SEG_CAP |
Segment capability for consumption message should be [0..2]. |
||
PWRFIP_ERR_NODE_TX_MSG_FIFO_SZ |
Queue size for message transmission should be in [1..64] range. |
||
PWRFIP_ERR_NODE_TX_MSG_REPEAT |
Maximum repeats for acknowledged message transmission should be in [0..3] range. |
||
PWRFIP_ERR_NODE_BA_STUP_TIMES |
The election time must be shorter than the start-up time. |
||
PWRFIP_ERR_NODE_BA_REQ_FIFO_SZ |
Queue size for BA requests should be in [1..64] range. |
||
PWRFIP_ERR_NODE_TR_INVALID |
Invalid FIP turn around time configuration. |
||
PWRFIP_ERR_NODE_TS_INVALID |
Invalid FIP silence time configuration. |
||
PWRFIP_ERR_NODE_IDENT_PARAM |
Mandatory parameters are missing for the node identification. |
||
PWRFIP_ERR_NODE_IDENT_LEN |
Node identification parameters exceed limit size. |
||
PWRFIP_ERR_BA_STUP_TS_INVALID |
Silence time should not be 0. |
||
PWRFIP_ERR_BA_STUP_PHY_ADDR_INVALID |
Local physical address should not exceed maximum network address. |
||
PWRFIP_ERR_BA_STUP_PRIO_INVALID |
Local BA priority should not exceed max priority (0: highest prio). |
||
PWRFIP_ERR_COM_DIR_UNKNOW |
Unknown direction for the mailbox. |
||
PWRFIP_ERR_COM_NOT_OUTBOX |
The mailbox is not configured as output. |
||
PWRFIP_ERR_COM_NOT_INBOX |
The mailbox is not configured as input. |
||
PWRFIP_ERR_COM_INVAL |
Mailbox invalid argument. |
||
PWRFIP_ERR_COM_TMO |
Mailbox timeout. |
||
PWRFIP_ERR_COM_BUSY |
Mailbox is busy. |
||
PWRFIP_ERR_COM_NO_PKT |
Mailbox has no packet to treat. |
||
PWRFIP_ERR_COM_PKT_BAD_SZ |
Incorrect packet size for the mailbox. |
||
PWRFIP_ERR_COM_PKT_BAD_CMD |
Unknown packet command id for the mailbox. |
||
PWRFIP_ERR_COM_PKT_RES_FAILED |
Error during response procedure (inbox). |
||
PWRFIP_ERR_COM_DMA_BAD_OP |
Bad DMA operation for mailbox. |
6.7. event_code
- Description
-
FIP event codes of the library.
- Definition
enum pwrfip_event_code {
PWRFIP_EVT_SEND_VAR_P = 0x8100,
PWRFIP_EVT_SEND_VAR_T = 0x0100,
PWRFIP_EVT_RECV_VAR_P = 0x8200,
PWRFIP_EVT_RECV_VAR_T = 0x0200,
PWRFIP_EVT_RECV_MSG = 0x0240,
PWRFIP_EVT_SEND_MSG = 0x0140,
PWRFIP_EVT_SEND_APU = 0x0130,
PWRFIP_EVT_SEND_APN = 0x0131,
PWRFIP_EVT_BA_ACTIVITY = 0x0400,
PWRFIP_EVT_BA_STOP_TMO = 0x0401,
PWRFIP_EVT_BA_STOP_ERR = 0x0402,
PWRFIP_EVT_BA_STOP_USR = 0x0404,
PWRFIP_EVT_BA_IDLE = 0x0408,
};
- Values
Constant | Value | Description | ||
---|---|---|---|---|
PWRFIP_EVT_SEND_VAR_P |
0x8100 |
A variable set-up with permanent event has been sent on the FIP network.
|
||
PWRFIP_EVT_SEND_VAR_T |
0x0100 |
A variable set-up with temporary event (once) has been sent on the FIP network.
|
||
PWRFIP_EVT_RECV_VAR_P |
0x8200 |
A variable set-up with permanent event has been received from the FIP network.
|
||
PWRFIP_EVT_RECV_VAR_T |
0x0200 |
A variable set-up with temporary event (once) has been received from the FIP network.
|
||
PWRFIP_EVT_RECV_MSG |
0x0240 |
A FIP message has been received from the FIP network. |
||
PWRFIP_EVT_SEND_MSG |
0x0140 |
A FIP message has been sent to the FIP network. |
||
PWRFIP_EVT_SEND_APU |
0x0130 |
An urgent aperiodic variable list has been sent to the FIP network. |
||
PWRFIP_EVT_SEND_APN |
0x0131 |
An normal aperiodic variable list has been sent to the FIP network. |
||
PWRFIP_EVT_BA_ACTIVITY |
0x0400 |
The bus arbiter is running. |
||
PWRFIP_EVT_BA_STOP_TMO |
0x0401 |
The bus arbiter has stopped on timeout.
|
||
PWRFIP_EVT_BA_STOP_ERR |
0x0402 |
The bus arbiter has stopped on network fault.
|
||
PWRFIP_EVT_BA_STOP_USR |
0x0404 |
The bus arbiter has been stopped by an user command. |
||
PWRFIP_EVT_BA_IDLE |
0x0408 |
The bus arbiter has switched to IDLE mode. |
6.8. evt_type
- Description
-
FIP event type.
- Definition
enum pwrfip_evt_type {
PWRFIP_EVT_TYPE_NONE,
PWRFIP_EVT_TYPE_PERMANENT_ID,
PWRFIP_EVT_TYPE_PERMANENT,
PWRFIP_EVT_TYPE_TEMPORARY,
};
- Values
Constant | Value | Description | ||
---|---|---|---|---|
PWRFIP_EVT_TYPE_NONE |
0 |
No event. |
||
PWRFIP_EVT_TYPE_PERMANENT_ID |
1 |
Permanent event on request detection.
|
||
PWRFIP_EVT_TYPE_PERMANENT |
2 |
Permanent event on response detection.
|
||
PWRFIP_EVT_TYPE_TEMPORARY |
3 |
Temporary event on response detection.
|
6.9. frame_type
- Description
-
Frame type.
- Definition
enum pwrfip_frame_type {
_PWRFIP_FRM_TYPE_MIN = 1,
PWRFIP_FRM_FIP = _PWRFIP_FRM_TYPE_MIN,
PWRFIP_FRM_WORLDFIP,
_PWRFIP_FRM_TYPE_MAX,
_PWRFIP_FRM_TYPE_UNKNOWN = 0,
};
- Values
Constant | Value | Description | ||
---|---|---|---|---|
_PWRFIP_FRM_TYPE_MIN |
1 |
Minimum valid enum code for frame type. |
||
PWRFIP_FRM_FIP |
1 |
FIP frame type.
|
||
PWRFIP_FRM_WORLDFIP |
2 |
WorldFIP frame type.
|
||
_PWRFIP_FRM_TYPE_MAX |
3 |
Maximum enum code for frame type. |
||
_PWRFIP_FRM_TYPE_UNKNOWN |
0 |
Unknown frame type. |
6.10. medium_cmd_flag
- Description
-
Medium management command.
The PowerFIP coprocessor provides a medium redundancy management solution for a FIP/WorldFIP bi-medium connection node. These commands allow to manage these two FIP channels. - Definition
enum pwrfip_medium_cmd_flag {
PWRFIP_MEDIUM_CMD_ENABLE_CH_1 = (1 << 0),
PWRFIP_MEDIUM_CMD_DISABLE_CH_1 = (1 << 1),
PWRFIP_MEDIUM_CMD_ENABLE_CH_2 = (1 << 2),
PWRFIP_MEDIUM_CMD_DISABLE_CH_2 = (1 << 3),
PWRFIP_MEDIUM_CMD_ENABLE_CH_1_2 = ((PWRFIP_MEDIUM_CMD_ENABLE_CH_1) |
(PWRFIP_MEDIUM_CMD_ENABLE_CH_2)),
PWRFIP_MEDIUM_CMD_DISABLE_CH_1_2 = ((PWRFIP_MEDIUM_CMD_DISABLE_CH_1) |
(PWRFIP_MEDIUM_CMD_DISABLE_CH_2)),
PWRFIP_MEDIUM_CMD_CLEAR_TX_ERR = (1 << 4),
PWRFIP_MEDIUM_CMD_RESET_CH_1 = (1 << 5),
PWRFIP_MEDIUM_CMD_RESET_CH_2 = (1 << 6),
PWRFIP_MEDIUM_CMD_RESET_CH_1_2 = ((PWRFIP_MEDIUM_CMD_RESET_CH_1) |
(PWRFIP_MEDIUM_CMD_RESET_CH_2)),
};
- Values
Constant | Value | Description |
---|---|---|
PWRFIP_MEDIUM_CMD_ENABLE_CH_1 |
0x0001 |
Enable FIP channel 1. |
PWRFIP_MEDIUM_CMD_DISABLE_CH_1 |
0x0002 |
Disable FIP channel 1. |
PWRFIP_MEDIUM_CMD_ENABLE_CH_2 |
0x0004 |
Enable FIP channel 2. |
PWRFIP_MEDIUM_CMD_DISABLE_CH_2 |
0x0008 |
Disable FIP channel 2. |
PWRFIP_MEDIUM_CMD_ENABLE_CH_1_2 |
0x0005 |
Enable both FIP channels. |
PWRFIP_MEDIUM_CMD_DISABLE_CH_1_2 |
0x000a |
Diable both FIP channels. |
PWRFIP_MEDIUM_CMD_CLEAR_TX_ERR |
0x0010 |
Clear TX error flag for both channels. |
PWRFIP_MEDIUM_CMD_RESET_CH_1 |
0x0020 |
Reset FIP channel 1. |
PWRFIP_MEDIUM_CMD_RESET_CH_2 |
0x0040 |
Reset FIP channel 2. |
PWRFIP_MEDIUM_CMD_RESET_CH_1_2 |
0x0060 |
Reset both channels. |
6.11. medium_state
- Description
-
Flags describing FIP medium (channels) state.
- Definition
enum pwrfip_medium_state {
PWRFIP_MEDIUM_STATE_CH1_VALID = (1 << 0),
PWRFIP_MEDIUM_STATE_CH2_VALID = (1 << 1),
PWRFIP_MEDIUM_STATE_CH1_TX_ERROR = (1 << 2),
PWRFIP_MEDIUM_STATE_CH2_TX_ERROR = (1 << 3),
PWRFIP_MEDIUM_STATE_CH1_WATCHDOG = (1 << 4),
PWRFIP_MEDIUM_STATE_CH2_WATCHDOG = (1 << 5),
};
- Values
Constant | Value | Description |
---|---|---|
PWRFIP_MEDIUM_STATE_CH1_VALID |
0x0001 |
Channel 1 is active |
PWRFIP_MEDIUM_STATE_CH2_VALID |
0x0002 |
Channel 2 is active |
PWRFIP_MEDIUM_STATE_CH1_TX_ERROR |
0x0004 |
TX Error detected on channel 1 |
PWRFIP_MEDIUM_STATE_CH2_TX_ERROR |
0x0008 |
TX Error detected on channel 2 |
PWRFIP_MEDIUM_STATE_CH1_WATCHDOG |
0x0010 |
Watchdog on channel 1. |
PWRFIP_MEDIUM_STATE_CH2_WATCHDOG |
0x0020 |
Watchdog on channel 2. |
6.12. msg_err_code
- Description
-
FIP message error codes after read/write operation.
- Definition
enum pwrfip_msg_err_code {
_PWRFIP_MSG_OK,
_PWRFIP_MSG_ERR_MIN,
/* configuration errors */
PWRFIP_MSG_TX_CH_UNKNOWN = _PWRFIP_MSG_ERR_MIN,
/* context error */
PWRFIP_MSG_TYPE_BAD,
PWRFIP_MSG_LEN_BAD,
/* -> rx msg */
PWRFIP_MSG_RX_FIFO_EMPTY,
/* -> tx msg */
PWRFIP_MSG_TX_FIFO_EMPTY,
PWRFIP_MSG_TX_FIFO_FULL,
PWRFIP_MSG_TX_TMO,
PWRFIP_MSG_TX_ACK_TMO,
PWRFIP_MSG_TX_ACK_NACK,
_PWRFIP_MSG_ERR_MAX,
};
- Values
Constant | Value | Description |
---|---|---|
_PWRFIP_MSG_OK |
0 |
No error. Operation correctly performed. |
_PWRFIP_MSG_ERR_MIN |
1 |
Minimal error code. |
PWRFIP_MSG_TX_CH_UNKNOWN |
1 |
Unknown message TX channel number. |
PWRFIP_MSG_TYPE_BAD |
2 |
Bad message type. |
PWRFIP_MSG_LEN_BAD |
3 |
Bad message length. |
PWRFIP_MSG_RX_FIFO_EMPTY |
4 |
RX message queue is empty. |
PWRFIP_MSG_TX_FIFO_EMPTY |
5 |
TX message queue is empty. |
PWRFIP_MSG_TX_FIFO_FULL |
6 |
TX message queue is full. |
PWRFIP_MSG_TX_TMO |
7 |
Message not sent and timeout expired (both mode: ack/noack). |
PWRFIP_MSG_TX_ACK_TMO |
8 |
Message sent but never acked (ack mode only). |
PWRFIP_MSG_TX_ACK_NACK |
9 |
Message sent but negatively acknowledged (ack mode only). |
_PWRFIP_MSG_ERR_MAX |
10 |
Maximum error code |
6.13. msg_rx_seg_cap
- Description
-
Message reception capability for the node depending on the destination segment of the FIP message.
A FIP node can be configured to be more or less sensitive to receiving FIP messages from the network. |
- Definition
enum pwrfip_msg_rx_seg_cap {
_PWRFIP_MSG_SEG_CAP_MIN = 0,
PWRFIP_MSG_SEG_IGNORE = _PWRFIP_MSG_SEG_CAP_MIN,
PWRFIP_MSG_SEG_ACCEPT_ALL,
PWRFIP_MSG_SEG_ACCEPT_LTD,
_PWRFIP_MSG_SEG_CAP_MAX,
};
- Values
Constant | Value | Description | ||
---|---|---|---|---|
_PWRFIP_MSG_SEG_CAP_MIN |
0 |
Minimum capacity value. |
||
PWRFIP_MSG_SEG_IGNORE |
0 |
Ignore all messages sent to the segment. |
||
PWRFIP_MSG_SEG_ACCEPT_ALL |
1 |
Accept all messages sent to the segment (regardless of the DSAP). |
||
PWRFIP_MSG_SEG_ACCEPT_LTD |
2 |
Limited acceptance.
|
||
_PWRFIP_MSG_SEG_CAP_MAX |
3 |
Maximum capacity value. |
6.14. msg_tx_ack_mode
- Description
-
Acknowledgement mode for a FIP message.
- Definition
enum pwrfip_msg_tx_ack_mode {
_PWRFIP_MSG_TX_ACK_MODE_MIN = 0,
PWRFIP_MSG_TX_ACK_MODE_SDN = _PWRFIP_MSG_TX_ACK_MODE_MIN,
PWRFIP_MSG_TX_ACK_MODE_SDA,
_PWRFIP_MSG_TX_ACK_MODE_MAX,
};
- Values
Constant | Value | Description |
---|---|---|
_PWRFIP_MSG_TX_ACK_MODE_MIN |
0 |
Mininum TX acknowledgment mode value |
PWRFIP_MSG_TX_ACK_MODE_SDN |
0 |
Send message without acknowledgment request (SDN) |
PWRFIP_MSG_TX_ACK_MODE_SDA |
1 |
Send message with acknowledgment request (SDA) |
_PWRFIP_MSG_TX_ACK_MODE_MAX |
2 |
Maximum TX acknowledgment mode value |
6.15. msg_tx_channel
- Description
-
Transmission channels number for FIP messages.
- Definition
enum pwrfip_msg_tx_channel {
_PWRFIP_MSG_TX_CH_MIN = 0,
PWRFIP_MSG_TX_CH_APER = _PWRFIP_MSG_TX_CH_MIN,
PWRFIP_MSG_TX_CH_PER_1,
PWRFIP_MSG_TX_CH_PER_2,
PWRFIP_MSG_TX_CH_PER_3,
PWRFIP_MSG_TX_CH_PER_4,
PWRFIP_MSG_TX_CH_PER_5,
PWRFIP_MSG_TX_CH_PER_6,
PWRFIP_MSG_TX_CH_PER_7,
PWRFIP_MSG_TX_CH_PER_8,
_PWRFIP_MSG_TX_CH_MAX,
};
- Values
Constant | Value | Description |
---|---|---|
_PWRFIP_MSG_TX_CH_MIN |
0 |
Mininum message TX channel value |
PWRFIP_MSG_TX_CH_APER |
0 |
Aperiodic message transmission channel |
PWRFIP_MSG_TX_CH_PER_1 |
1 |
Periodic message transmission channel 1 |
PWRFIP_MSG_TX_CH_PER_2 |
2 |
Periodic message transmission channel 2 |
PWRFIP_MSG_TX_CH_PER_3 |
3 |
Periodic message transmission channel 3 |
PWRFIP_MSG_TX_CH_PER_4 |
4 |
Periodic message transmission channel 4 |
PWRFIP_MSG_TX_CH_PER_5 |
5 |
Periodic message transmission channel 5 |
PWRFIP_MSG_TX_CH_PER_6 |
6 |
Periodic message transmission channel 6 |
PWRFIP_MSG_TX_CH_PER_7 |
7 |
Periodic message transmission channel 7 |
PWRFIP_MSG_TX_CH_PER_8 |
8 |
Periodic message transmission channel 8 |
_PWRFIP_MSG_TX_CH_MAX |
9 |
Maximum message TX channel value |
6.16. msg_type
- Description
-
FIP message type.
- Definition
enum pwrfip_msg_type {
_PWRFIP_MSG_TYPE_MIN = 0,
PWRFIP_MSG_TYPE_RECV = _PWRFIP_MSG_TYPE_MIN,
PWRFIP_MSG_TYPE_SEND,
_PWRFIP_MSG_TYPE_MAX,
};
- Values
Constant | Value | Description |
---|---|---|
_PWRFIP_MSG_TYPE_MIN |
0 |
Minimum message type value |
PWRFIP_MSG_TYPE_RECV |
0 |
Message to receive |
PWRFIP_MSG_TYPE_SEND |
1 |
Message to send |
_PWRFIP_MSG_TYPE_MAX |
2 |
Maximum message type value |
6.17. node_operation
- Description
-
Operation type inside a FIP node.
- Definition
enum pwrfip_node_operation {
_PWRFIP_NODE_OP_UNKNOWN,
PWRFIP_NODE_OP_WAIT_RX_RP_FRM,
PWRFIP_NODE_OP_WAIT_TX_RP_FRM,
PWRFIP_NODE_OP_WAIT_RX_ID_FRM,
PWRFIP_NODE_OP_WAIT_TX_ID_FRM,
_PWRFIP_NODE_OP_MAX,
};
- Values
Constant | Value | Description |
---|---|---|
_PWRFIP_NODE_OP_UNKNOWN |
0 |
Unknown operation |
PWRFIP_NODE_OP_WAIT_RX_RP_FRM |
1 |
Wait for reception of RP_XX frame |
PWRFIP_NODE_OP_WAIT_TX_RP_FRM |
2 |
RP_XX frame transmission in progress |
PWRFIP_NODE_OP_WAIT_RX_ID_FRM |
3 |
Wait for reception of ID_XX frame |
PWRFIP_NODE_OP_WAIT_TX_ID_FRM |
4 |
ID_XX frame transmission in progress |
_PWRFIP_NODE_OP_MAX |
5 |
Max node operation |
6.18. node_state
- Description
-
FSM (Finite State Machine) for a FIP node.
- Definition
enum pwrfip_node_state {
PWRFIP_NODE_STATE_INITIAL,
PWRFIP_NODE_STATE_LOADED,
PWRFIP_NODE_STATE_READY,
PWRFIP_NODE_STATE_RUNNING,
_PWRFIP_NODE_STATE_MAX,
};
- Values
Constant | Value | Description |
---|---|---|
PWRFIP_NODE_STATE_INITIAL |
0 |
Initial state. No config loaded |
PWRFIP_NODE_STATE_LOADED |
1 |
General node config loaded. |
PWRFIP_NODE_STATE_READY |
2 |
User context loaded (AE/LE). |
PWRFIP_NODE_STATE_RUNNING |
3 |
Running state. |
_PWRFIP_NODE_STATE_MAX |
4 |
Max node state number |
6.19. sm_var_type
- Description
-
FIP system management variable type (SM-MPS).
- Definition
enum pwrfip_sm_var_type {
PWRFIP_SM_VAR_IDENT,
PWRFIP_SM_VAR_REPORT,
PWRFIP_SM_VAR_PRESENCE,
};
- Values
Constant | Value | Description |
---|---|---|
PWRFIP_SM_VAR_IDENT |
0 |
Identification SM-MPS variable (0x10XY). |
PWRFIP_SM_VAR_REPORT |
1 |
Report SM-MPS variable (0x11XY). |
PWRFIP_SM_VAR_PRESENCE |
2 |
Presence SM-MPS variable (0x14XY). |
6.20. var_aper_channel_type
- Description
-
Priority level for the channel dedicated to aperiodic variable requests.
- Definition
enum pwrfip_var_aper_channel_type {
PWRFIP_VAR_APER_CH_NORMAL = 0,
PWRFIP_VAR_APER_CH_URGENT,
};
- Values
Constant | Value | Description |
---|---|---|
PWRFIP_VAR_APER_CH_NORMAL |
0 |
Normal priority. |
PWRFIP_VAR_APER_CH_URGENT |
1 |
Urgent priority. |
6.21. var_err_code
- Description
-
FIP variable error codes after read/write operation.
- Definition
enum pwrfip_var_err_code {
_PWRFIP_VAR_OK,
_PWRFIP_VAR_ERR_MIN,
/* configuration errors */
PWRFIP_VAR_ID_UNKNOWN = _PWRFIP_VAR_ERR_MIN,
PWRFIP_VAR_NOT_PRODUCING,
PWRFIP_VAR_NOT_CONSUMING,
PWRFIP_VAR_TX_APER_CH_UNKNOWN,
/* context error */
PWRFIP_VAR_PDU_INCONSISTENT,
PWRFIP_VAR_LEN_TOO_LONG,
PWRFIP_VAR_LEN_TOO_SHORT,
PWRFIP_VAR_NEVER_RECEIVED,
PWRFIP_VAR_TX_APER_FIFO_EMPTY,
PWRFIP_VAR_TX_APER_FIFO_FULL,
/* payload error */
/* -> cons var */
PWRFIP_VAR_NOT_MEANING,
PWRFIP_VAR_NOT_REFRESH,
PWRFIP_VAR_NOT_PROMPT,
PWRFIP_VAR_BAD_PROMPT_PER,
/* -> prod var */
PWRFIP_VAR_BAD_REFRESH_PER,
_PWRFIP_VAR_ERR_MAX,
};
- Values
Constant | Value | Description | ||
---|---|---|---|---|
_PWRFIP_VAR_OK |
0 |
No error. Operation correctly performed. |
||
_PWRFIP_VAR_ERR_MIN |
1 |
Minimal error code. |
||
PWRFIP_VAR_ID_UNKNOWN |
1 |
Unknown variable ID. |
||
PWRFIP_VAR_NOT_PRODUCING |
2 |
The FIP variable is not set to production. |
||
PWRFIP_VAR_NOT_CONSUMING |
3 |
The FIP variable is not set to consumption. |
||
PWRFIP_VAR_TX_APER_CH_UNKNOWN |
4 |
Unknown TX channel number for aperiodic variable.
|
||
PWRFIP_VAR_PDU_INCONSISTENT |
5 |
Inconsistent variable PDU (Protocol Data Unit). |
||
PWRFIP_VAR_LEN_TOO_LONG |
6 |
The size of the variable read on the FIP network is longer than the one configured in the local database. |
||
PWRFIP_VAR_LEN_TOO_SHORT |
7 |
The size of the variable read on the FIP network is shorter than the one configured in the local database. |
||
PWRFIP_VAR_NEVER_RECEIVED |
8 |
The variable has never been received on the FIP node. |
||
PWRFIP_VAR_TX_APER_FIFO_EMPTY |
9 |
TX aperiodic variable queue is empty. |
||
PWRFIP_VAR_TX_APER_FIFO_FULL |
10 |
TX aperiodic variable queue is full. |
||
PWRFIP_VAR_NOT_MEANING |
11 |
The FIP variable read is not significant. |
||
PWRFIP_VAR_NOT_REFRESH |
12 |
The FIP variable is not fresh. (see production status byte) |
||
PWRFIP_VAR_NOT_PROMPT |
13 |
The FIP variable is not prompt. |
||
PWRFIP_VAR_BAD_PROMPT_PER |
14 |
Bad reading frequency for application layer (promptness). |
||
PWRFIP_VAR_BAD_REFRESH_PER |
15 |
Bad writing frequency for application layer (refreshment) |
||
_PWRFIP_VAR_ERR_MAX |
16 |
Maximum error code |
6.22. var_flags
- Description
-
Set-up flags for a FIP variable
- Definition
enum pwrfip_var_flags {
/**
* PROD/CONS
*/
PWRFIP_VAR_FLAGS_REFRESH = (1 << 0),
PWRFIP_VAR_FLAGS_DYN_REFRESH = (1 << 1),
/**
* PROD only
*/
PWRFIP_VAR_FLAGS_APER_VAR_REQ = (1 << 8),
PWRFIP_VAR_FLAGS_APER_MSG_REQ = (1 << 9),
/**
* CONS only
*/
PWRFIP_VAR_FLAGS_PROMPT = (1 << 12),
PWRFIP_VAR_FLAGS_CHK_PDU_LEN = (1 << 13),
PWRFIP_VAR_FLAGS_MAX_VAL = (1 << 15),
};
- Values
Constant | Value | Description | ||
---|---|---|---|---|
PWRFIP_VAR_FLAGS_REFRESH |
0x0001 |
Enable/Disable production status (refreshment)
|
||
PWRFIP_VAR_FLAGS_DYN_REFRESH |
0x0002 |
Enable/Disable dynamic production status (eq. var_time)
|
||
PWRFIP_VAR_FLAGS_APER_VAR_REQ |
0x0100 |
Enable/Disable aperiodic variable request capability
|
||
PWRFIP_VAR_FLAGS_APER_MSG_REQ |
0x0200 |
Enable/Disable aperiodic message request capability
|
||
PWRFIP_VAR_FLAGS_PROMPT |
0x1000 |
Enable/Disable promptness status
|
||
PWRFIP_VAR_FLAGS_CHK_PDU_LEN |
0x2000 |
Enable/Disable PDU+LEN bytes frame check
|
||
PWRFIP_VAR_FLAGS_MAX_VAL |
0x8000 |
Maximal setting flag for variable |
6.23. var_type
- Description
-
FIP variable type.
- Definition
enum pwrfip_var_type {
PWRFIP_VAR_TYPE_CONS,
PWRFIP_VAR_TYPE_PROD,
PWRFIP_VAR_TYPE_SYNC,
_PWRFIP_VAR_TYPE_MAX,
};
- Values
Constant | Value | Description | ||
---|---|---|---|---|
PWRFIP_VAR_TYPE_CONS |
0 |
Consumption variable. |
||
PWRFIP_VAR_TYPE_PROD |
1 |
Production variable. |
||
PWRFIP_VAR_TYPE_SYNC |
2 |
Synchronization variable.
|
||
_PWRFIP_VAR_TYPE_MAX |
3 |
Maximum variable type value. |
Appendix A: SM-MPS variables
The network management variables SM-MPS are automatically created and internally managed by the PowerFIP library.
These variables are useful to know the general state of the network as well as to get information about a particular FIP node.
A.1. Identification - 0x10XY
- Description
-
The variable attached to the ID number 0x10XY (where XY is the node address) is called the Identification variable.
Each node produces this variable, and its payload allows to clearly identify the node on the network. - Frame Format
Bytes | Description |
---|---|
0x50 |
PDU type (SM-MPS) |
0xZZ |
PDU length (must not exceed 126 bytes) |
0x80 |
Manufacturer name field |
0xZZ |
Manufacturer name field length |
0xZZ |
First character for manufacturer name |
… |
… |
0xZZ |
Last character for manufacturer name |
0x81 |
Model name field |
0xZZ |
Model name field length |
0xZZ |
First character for model name |
… |
… |
0xZZ |
Last character for model name |
0x82 |
Revision field |
0x01 |
Revision field length |
0xZZ |
Revision number (ex: 0x10 for v1.0) |
0x83 |
Device tag name field |
0xZZ |
Device tag name field length |
0xZZ |
First character for tag name |
… |
… |
0xZZ |
Last character for tag name |
0x84 |
SM-MPS secondary function field |
0x01 |
SM-MPS secondary function field length |
0x10 |
SM-MPS secondary function field value:
|
0x8A |
Vendor field |
0xZZ |
Vendor field length |
0xZZ |
First byte for vendor field |
… |
… |
0xZZ |
Last byte for vendor field |
A.2. Report - 0x11XY
- Description
-
The variable attached to the ID number 0x11XY (where XY is the node address) is called the Report variable.
Each node produces this variable, and its payload contains various node-specific status counters (rx faults, number of transactions, …). - Frame Format
Bytes | Description | ||||
---|---|---|---|---|---|
0x50 |
PDU type (SM-MPS) |
||||
0x0F |
PDU length |
||||
0x50 |
Tag for counter of frames correctly received on channel 1 by Time Unit(1) |
||||
0xZZ |
Counter Most Significant Byte |
||||
0xZZ |
Counter Least Significant Byte |
||||
0x51 |
Tag for counter of frames correctly received on channel channel 2 by Time Unit(1) |
||||
0xZZ |
Counter Most Significant Byte |
||||
0xZZ |
Counter Least Significant Byte |
||||
0x52 |
Tag for counter of frames incorrectly received on channel 1 by Time Unit(1) |
||||
0xZZ |
Counter Most Significant Byte |
||||
0xZZ |
Counter Least Significant Byte |
||||
0x53 |
Tag for counter of frames incorrectly received on channel 2 by Time Unit(1) |
||||
0xZZ |
Counter Most Significant Byte |
||||
0xZZ |
Counter Least Significant Byte |
||||
0x54 |
Tag for channel status |
||||
0xZZ |
Channel status (MSB)
|
||||
0xZZ |
Channel status (LSB)
|
- Remarks
-
-
(1) Time Unit corresponds to the diagnostic period of the medium. This task is internally performed by the library, and the period is automatically set according to the FIP bitrate:
-
@31.25Kbps: 1.6s
-
@1Mbps: 500ms
-
@2.5Mbps: 200ms
-
@5Mbps: 100ms
-
@12.5Mbps: 40ms
-
@25Mbps: 20ms
-
-
(2): Traffic signal is the measure of frames correctly received and/or transmitted on/by the channel by Time Unit(1). To be OK, you need:
-
(TX frames OK + RX frames OK) > 0
-
-
(3): Validity of a channel is given by the medium redundancy component.
Seeenum pwrfip_medium_state
:-
PWRFIP_MEDIUM_STATE_CH1_VALID
-
PWRFIP_MEDIUM_STATE_CH2_VALID
-
-
(4): RX/TX quality is the measure of the error rate on the channel by Time Unit(1). This error threshold is set to 5% by the library.
To be OK, you need:-
(RX frames faults / RX frames OK) < Threshold
-
(TX frames faults / TX frames OK) < Threshold
-
-
A.3. Presence - 0x14XY
- Description
-
The variable attached to the ID number 0x14XY (where XY is the node address) is called the Presence variable.
Each node produces this variable and thus informs the other nodes of the FIP network of its presence. - Frame Format
Bytes | Description |
---|---|
0x50 |
PDU type (SM-MPS) |
0x05 |
PDU length |
0x80 |
Presence parameter |
0x03 |
Presence parameter length |
0xZZ |
Identification characteristics.
|
0x00 |
Reserved |
0xZZ |
Bus Arbiter global status (about the producer).
|
A.4. Presence Check - 0x9002
- Description
-
The variable attached to the ID number 0x9002 is called the Presence Check or Present List variable.
This variable is produced by the master node (Bus arbiter active).
It summarizes in a single variable the whole list of nodes presence on the network. - Frame Format
Bytes | Description |
---|---|
0x50 |
PDU type (SM-MPS) |
0x44 |
PDU length |
0x80 |
Channel 1 presence list |
0x20 |
Channel 1 presence list length |
0xZZ |
Status of nodes address 0 to 7.
|
… |
… |
0xZZ |
Status of nodes address 248 to 255.
|
0x81 |
Channel 2 presence list |
0x20 |
Channel 2 presence list length |
0xZZ |
Status of nodes address 0 to 7.
|
… |
… |
0xZZ |
Status of nodes address 248 to 255.
|
A.5. BA synchronization - 0x9003
- Description
-
The variable attached to the ID number 0x9003 is called the BA synchronisation variable.
This variable is produced by the master node, and indicates the current status of the Bus Arbiter on the network. - Frame Format
Bytes | Description |
---|---|
0x50 |
PDU type (SM-MPS) |
0x04 |
PDU length |
0x80 |
BA synchro parameter |
0x02 |
BA synchro parameter length |
0xZZ |
Macrocycle number of current BA program |
0xZZ |
Physical node address of the master |
Appendix B: Glossary of acronyms
AE/LE |
Application Entity/Link Entity |
BA |
Bus Arbiter |
BSS |
Block Starting Symbol |
DLL |
Data Link Layer |
DSAP |
Destination Service Access Point |
LLC |
Logical Link Control |
LSAP |
Link Service Access Point |
MPS |
Manufacturing Periodic/aperiodic Services |
SDA |
Send Data with Acknowledgement |
SDN |
Send Data with No acknowledgement |
SM-MPS |
System Management Manufacturing Periodic/aperiodic Services |
SSAP |
Source Service Access Point |
Appendix C: Revision History
Revision | Changes | Authors | Date |
---|---|---|---|
1.3.0 |
|
MC |
2024-04-03 |
1.2.0 |
|
MC |
2023-06-27 |
1.1.0 |
|
MC |
2022-06-21 |
1.0.2 |
|
MC |
2022-03-01 |
1.0.1 |
|
MC |
2022-01-13 |
1.0.0 |
|
MC |
2022-01-07 |
0.9.0 |
|
MC |
2021-12-07 |
0.8.0 |
|
MC |
2021-10-19 |
0.7.2 |
|
MC |
2021-09-21 |
0.7.1 |
Windows 7/8/10 OS support |
MC |
2021-08-04 |
0.7.0 |
First version (Linux OS) |
MC |
2021-07-05 |