Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi port updated #318

Merged
merged 4 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ set(PNET_MAX_CR 2
set(PNET_MAX_SLOTS 5
CACHE STRING "Per API. Should be > 1 to allow at least one I/O module")
set(PNET_MAX_SUBSLOTS 3
CACHE STRING "Per slot (3 needed for DAP)")
CACHE STRING "Per slot (DAP requires 2 + PNET_MAX_PORT)")
set(PNET_MAX_CHANNELS 1
CACHE STRING "Per sub-slot. Used for diagnosis")
set(PNET_MAX_DFP_IOCR 2
CACHE STRING "Allowed values are 0 (zero) or 2")
set(PNET_MAX_PORT 1
CACHE STRING "2 for media redundancy. Currently only 1 is supported")
CACHE STRING "Number of physical ports")
set(PNET_MAX_LOG_BOOK_ENTRIES 16
CACHE STRING "")
set(PNET_MAX_ALARMS 3
Expand Down
8 changes: 7 additions & 1 deletion doc/multiple_ports.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,17 @@ Run ``ifconfig`` to check that the bridge is up and its network interfaces are a
Configuration of p-net stack and sample application
---------------------------------------------------------
To run p-net and the sample application with multiple ports a couple
of things need to be done:
of things need to be done. Note that the settings described in the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we explain ccmake then you should maybe also mention that options can be set on the command line when configuring (-DPNET_MAX_PORTS=2), which is probably how you would set it in a build script or similar.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

following sections are changed by running ``ccmake .`` in the build folder.
``options.h`` will be regenerated. Another way to set the options is to
set them on the cmake command line (-DPNET_MAX_PORT=2 -DPNET_MAX_SUBSLOTS=4).

Reconfigure setting ``PNET_MAX_PORT`` to the actual number of physical ports available in the system.
For this example ``PNET_MAX_PORT`` shall be set to 2.

Reconfigure setting ``PNET_MAX_SUBSLOTS``. Each additional port will require an additional subslot.
For this example the ``PNET_MAX_SUBSLOTS`` should be be set to 4.

Example of initial log when starting the demo application with a multi port configuration::

pi@pndevice-pi:~/profinet/build $ sudo ./pn_dev -v
Expand Down
8 changes: 4 additions & 4 deletions include/pnet_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1161,14 +1161,14 @@ typedef struct pnet_ethaddr
#define PNET_STATION_NAME_MAX_SIZE (241)

/* Including termination. Standard says 14 (without termination) */
#define PNET_PORT_ID_MAX_SIZE (15)
#define PNET_PORT_NAME_MAX_SIZE (15)

/** Including termination */
#define PNET_LLDP_CHASSIS_ID_MAX_SIZE (PNET_CHASSIS_ID_MAX_SIZE)

/** Including termination */
#define PNET_LLDP_PORT_ID_MAX_SIZE \
(PNET_STATION_NAME_MAX_SIZE + PNET_PORT_ID_MAX_SIZE)
(PNET_STATION_NAME_MAX_SIZE + PNET_PORT_NAME_MAX_SIZE)

/**
* Network interface
Expand All @@ -1185,7 +1185,7 @@ typedef struct pnet_netif
typedef struct pnet_port_cfg
{
pnet_netif_t phy_port;
char port_id[PNET_LLDP_PORT_ID_MAX_SIZE]; /**< Terminated string */
char port_name[PNET_PORT_NAME_MAX_SIZE]; /**< Terminated string */
uint16_t rtclass_2_status;
uint16_t rtclass_3_status;
} pnet_port_cfg_t;
Expand Down Expand Up @@ -1214,7 +1214,7 @@ typedef struct pnet_ip_cfg
typedef struct pnet_if_cfg
{
pnet_netif_t main_port; /**< Main (DAP) network interface. */
pnet_ip_cfg_t ip_cfg; /**< IP Settings for main network interface */
pnet_ip_cfg_t ip_cfg; /**< IP Settings for main network interface */

pnet_port_cfg_t ports[PNET_MAX_PORT]; /**< Physical ports (DAP ports) */
} pnet_if_cfg_t;
Expand Down
14 changes: 12 additions & 2 deletions sample_app/GSDML-V2.4-rtlabs-IODevice-20201211.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,25 @@
</InterfaceSubmoduleItem>
<PortSubmoduleItem ID="IDS_P1" SubmoduleIdentNumber="0x00008001" SubslotNumber="32769" TextId="IDT_NAME_PS1" MaxPortRxDelay="350" MaxPortTxDelay="160">
<MAUTypeList>
<!--
MAUTypeItems shall match the actual network interfaces of the device.
Current list works for Raspberry Pi, Linksys usb/ethernet dongle and xmc sample targets
-->
<MAUTypeItem Value="30"/>
<MAUTypeItem Value="16"/>
<MAUTypeItem Value="5"/>
</MAUTypeList>
</PortSubmoduleItem>
<!-- Enable to support additional port. (PNET_MAX_PORT == 2) -->
<!-- Add additional PortSubmoduleItems to support additional ports -->
<!--
Enable to support additional port. (PNET_MAX_PORT == 2)
Add additional PortSubmoduleItems to support additional ports
-->
<!--
<PortSubmoduleItem ID="IDS_P2" SubmoduleIdentNumber="0x00008002" SubslotNumber="32770" TextId="IDT_NAME_PS2" MaxPortRxDelay="350" MaxPortTxDelay="160">
<MAUTypeList>
<MAUTypeItem Value="30"/>
<MAUTypeItem Value="16"/>
<MAUTypeItem Value="5"/>
</MAUTypeList>
</PortSubmoduleItem>
-->
Expand Down
4 changes: 2 additions & 2 deletions sample_app/sampleapp_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1395,8 +1395,8 @@ int app_pnet_cfg_init_default (pnet_cfg_t * stack_config)
for (i = 0; i < PNET_MAX_PORT; i++)
{
snprintf (
stack_config->if_cfg.ports[i].port_id,
PNET_LLDP_PORT_ID_MAX_SIZE,
stack_config->if_cfg.ports[i].port_name,
sizeof (stack_config->if_cfg.ports[i].port_name),
"port-%03d",
i + 1);
stack_config->if_cfg.ports[i].rtclass_2_status = 0;
Expand Down
Loading