Skip to content

Commit

Permalink
Rename PNET_MAX_PORT to PNET_NUMBER_OF_PHYSICAL_PORTS
Browse files Browse the repository at this point in the history
  • Loading branch information
olbjo committed Feb 16, 2021
1 parent e7eceee commit f8f567e
Show file tree
Hide file tree
Showing 32 changed files with 192 additions and 134 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ 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 (DAP requires 2 + PNET_MAX_PORT)")
CACHE STRING "Per slot (DAP requires 2 + PNET_NUMBER_OF_PHYSICAL_PORTS)")
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
set(PNET_NUMBER_OF_PHYSICAL_PORTS 1
CACHE STRING "Number of physical ports")
set(PNET_MAX_LOG_BOOK_ENTRIES 16
CACHE STRING "")
Expand Down
6 changes: 3 additions & 3 deletions doc/multiple_ports.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ To run p-net and the sample application with multiple ports a couple
of things need to be done. Note that the settings described in the
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).
set them on the cmake command line (-DPNET_NUMBER_OF_PHYSICAL_PORTS=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_NUMBER_OF_PHYSICAL_PORTS`` to the actual number of physical ports available in the system.
For this example ``PNET_NUMBER_OF_PHYSICAL_PORTS`` 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.
Expand Down
2 changes: 1 addition & 1 deletion include/pnet_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ typedef struct pnet_if_cfg
const char * main_netif_name; /**< Main (DAP) network interface. */
pnet_ip_cfg_t ip_cfg; /**< IP Settings for main network interface */

pnet_port_cfg_t physical_ports[PNET_MAX_PORT];
pnet_port_cfg_t physical_ports[PNET_NUMBER_OF_PHYSICAL_PORTS];
} pnet_if_cfg_t;

/**
Expand Down
4 changes: 2 additions & 2 deletions options.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@
#define PNET_MAX_DFP_IOCR @PNET_MAX_DFP_IOCR@
#endif

#if !defined (PNET_MAX_PORT)
#if !defined (PNET_NUMBER_OF_PHYSICAL_PORTS)
/** 2 for media redundancy. Currently only 1 is supported. */
#define PNET_MAX_PORT @PNET_MAX_PORT@
#define PNET_NUMBER_OF_PHYSICAL_PORTS @PNET_NUMBER_OF_PHYSICAL_PORTS@
#endif

#if !defined (PNET_MAX_LOG_BOOK_ENTRIES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Current list works for Raspberry Pi, Linksys usb/ethernet dongle and xmc sample
</MAUTypeList>
</PortSubmoduleItem>
<!--
Enable to support additional port. (PNET_MAX_PORT == 2)
Enable to support additional port. (PNET_NUMBER_OF_PHYSICAL_PORTS == 2)
Add additional PortSubmoduleItems to support additional ports
-->
<!--
Expand Down
13 changes: 8 additions & 5 deletions sample_app/sampleapp_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ void app_plug_dap (pnet_t * net, void * arg)
PNET_SUBMOD_DAP_INTERFACE_1_PORT_1_IDENT,
&cfg_dap_data);

#if PNET_MAX_PORT >= 2
#if PNET_MAX_PHY_PORTS >= 2
app_exp_submodule_ind (
net,
arg,
Expand All @@ -1288,7 +1288,7 @@ void app_plug_dap (pnet_t * net, void * arg)
&cfg_dap_data);
#endif

#if PNET_MAX_PORT >= 3
#if PNET_MAX_PHY_PORTS >= 3
app_exp_submodule_ind (
net,
arg,
Expand All @@ -1300,7 +1300,7 @@ void app_plug_dap (pnet_t * net, void * arg)
&cfg_dap_data);
#endif

#if PNET_MAX_PORT >= 4
#if PNET_MAX_PHY_PORTS >= 4
app_exp_submodule_ind (
net,
arg,
Expand Down Expand Up @@ -1481,7 +1481,10 @@ int app_pnet_cfg_init_netifs (
pnal_ipaddr_t netmask;
pnal_ipaddr_t gateway;

ret = app_get_netif_namelist (netif_list_str, if_list, PNET_MAX_PORT);
ret = app_get_netif_namelist (
netif_list_str,
if_list,
PNET_NUMBER_OF_PHYSICAL_PORTS);
if (ret != 0)
{
return ret;
Expand All @@ -1493,7 +1496,7 @@ int app_pnet_cfg_init_netifs (
printf ("Management port: %s\n", p_cfg->if_cfg.main_netif_name);
}

for (i = 1; i <= PNET_MAX_PORT; i++)
for (i = 1; i <= PNET_NUMBER_OF_PHYSICAL_PORTS; i++)
{
p_cfg->if_cfg.physical_ports[i - 1].netif_name = if_list->netif[i].name;
if (verbosity > 0)
Expand Down
26 changes: 12 additions & 14 deletions sample_app/sampleapp_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static const cfg_submodule_type_t cfg_available_submodule_types[] = {
PNET_DIR_NO_IO,
0,
0},
#if PNET_MAX_PORT >= 2
#if PNET_NUMBER_OF_PHYSICAL_PORTS >= 2
{"DAP Port 2",
APP_API,
PNET_MOD_DAP_IDENT,
Expand All @@ -140,7 +140,7 @@ static const cfg_submodule_type_t cfg_available_submodule_types[] = {
0,
0},
#endif
#if PNET_MAX_PORT >= 3
#if PNET_NUMBER_OF_PHYSICAL_PORTS >= 3
{"DAP Port 3",
APP_API,
PNET_MOD_DAP_IDENT,
Expand All @@ -149,7 +149,7 @@ static const cfg_submodule_type_t cfg_available_submodule_types[] = {
0,
0},
#endif
#if PNET_MAX_PORT >= 4
#if PNET_NUMBER_OF_PHYSICAL_PORTS >= 4
{"DAP Port 4",
APP_API,
PNET_MOD_DAP_IDENT,
Expand Down Expand Up @@ -190,8 +190,8 @@ struct cmd_args
char path_storage_directory[PNET_MAX_DIRECTORYPATH_SIZE]; /** Terminated */
char station_name[PNET_STATION_NAME_MAX_SIZE]; /** Terminated string */
char eth_interfaces
[PNET_INTERFACE_NAME_MAX_SIZE * (PNET_MAX_PORT + 1) +
PNET_MAX_PORT]; /** Terminated string */
[PNET_INTERFACE_NAME_MAX_SIZE * (PNET_NUMBER_OF_PHYSICAL_PORTS + 1) +
PNET_NUMBER_OF_PHYSICAL_PORTS]; /** Terminated string */
int verbosity;
int show;
bool factory_reset;
Expand All @@ -205,7 +205,7 @@ typedef struct app_netif_name

typedef struct app_netif_namelist
{
app_netif_name_t netif[PNET_MAX_PORT + 1];
app_netif_name_t netif[PNET_NUMBER_OF_PHYSICAL_PORTS + 1];
} app_netif_namelist_t;

typedef struct app_subslot
Expand Down Expand Up @@ -321,19 +321,17 @@ int app_pnet_cfg_init_netifs (

/**
* Parse a comma separated list of network interfaces and check
* that the number of interfaces match the PNET_MAX_PORT configuration.
* Examples:
* PNET_MAX_PORT arg_str status
* 1 "eth0" ok
* 1 "eth0,eth1" err
* 2 "br0,eth0,eth1" ok
* 2 "br0,eth0," err
* that the number of interfaces match the PNET_NUMBER_OF_PHYSICAL_PORTS
* configuration. Examples: PNET_NUMBER_OF_PHYSICAL_PORTS arg_str status 1
* "eth0" ok 1 "eth0,eth1" err 2
* "br0,eth0,eth1" ok 2 "br0,eth0," err
*
* @param arg_str In: Network interface list as comma separated,
* terminated string. For example "eth0" or
* "br0,eth0,eth1".
* @param p_if_list Out: List of network interfaces
* @param max_port In: PNET_MAX_PORT, passed as argument to allow test
* @param max_port In: PNET_NUMBER_OF_PHYSICAL_PORTS, passed as argument to
* allow test
* @return 0 if network interface list matches configuration
* -1 on error
*/
Expand Down
2 changes: 1 addition & 1 deletion src/common/pf_cpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ int pf_cpm_activate_req (pnet_t * net, pf_ar_t * p_ar, uint32_t crep)
(uint32_t)p_iocr->param.reduction_ratio * 1000U) /
32U; /* us */

for (ix = 0; ix < PNET_MAX_PORT; ix++)
for (ix = 0; ix < PNET_NUMBER_OF_PHYSICAL_PORTS; ix++)
{
p_cpm->rxa[ix][0] = -1; /* "invalid" cycle counter */
p_cpm->rxa[ix][1] = -1;
Expand Down
20 changes: 5 additions & 15 deletions src/common/pf_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@
#include <string.h>
#include "pf_includes.h"

/**
* Init network interface.
* Set name, read mac address, register receive callback.
*
* @param net InOut: The p-net stack instance
* @param netif_name In: Network interface name
* @param eth_receive_type In: Ethernet frame types that shall be received
* by the network interface / port.
* @param netif Out: Initialized network interface.
* @return
*/
static int pf_eth_init_netif (
pnet_t * net,
const char * netif_name,
Expand All @@ -69,7 +58,7 @@ static int pf_eth_init_netif (
return -1;
}

memcpy (netif->mac.addr, pnal_mac_addr.addr, sizeof (netif->mac.addr));
memcpy(netif->mac.addr, pnal_mac_addr.addr, sizeof(netif->mac.addr));

return 0;
}
Expand All @@ -80,13 +69,13 @@ int pf_eth_init (pnet_t * net, const pnet_cfg_t * p_cfg)
pf_port_iterator_t port_iterator;
pf_port_t * p_port_data;
pnal_ethertype_t main_port_receive_type;
#if PNET_MAX_PORT > 1
#if PNET_NUMBER_OF_PHYSICAL_PORTS > 1
const pnet_port_cfg_t * p_port_cfg;
#endif

memset (net->eth_id_map, 0, sizeof (net->eth_id_map));

#if (PNET_MAX_PORT == 1)
#if (PNET_NUMBER_OF_PHYSICAL_PORTS == 1)
main_port_receive_type = PNAL_ETHTYPE_ALL;
#else
main_port_receive_type = PNAL_ETHTYPE_PROFINET;
Expand All @@ -110,7 +99,7 @@ int pf_eth_init (pnet_t * net, const pnet_cfg_t * p_cfg)
{
p_port_data = pf_port_get_state (net, port);

#if PNET_MAX_PORT > 1
#if PNET_NUMBER_OF_PHYSICAL_PORTS > 1
p_port_cfg = pf_port_get_config (net, port);

if (
Expand All @@ -130,6 +119,7 @@ int pf_eth_init (pnet_t * net, const pnet_cfg_t * p_cfg)

port = pf_port_get_next (&port_iterator);
}

return 0;
}

Expand Down
8 changes: 4 additions & 4 deletions src/common/pf_eth.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ extern "C" {

/**
* Initialize ETH component and network interfaces according to configuration
* If device is configured with one network interface (PNET_MAX_PORT==1),
* the management port and physical port 1 refers to same network interface.
* In a multi port configuration, the management port and physical ports are
* different network interfaces.
* If device is configured with one network interface
* (PNET_NUMBER_OF_PHYSICAL_PORTS==1), the management port and physical port 1
* refers to same network interface. In a multi port configuration, the
* management port and physical ports are different network interfaces.
* @param net InOut: The p-net stack instance
* @param p_cfg In: Configuration
* @return 0 on success
Expand Down
16 changes: 10 additions & 6 deletions src/common/pf_lldp.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
* This file should not have any knowledge of Profinet slots, subslots etc.
*
* ToDo: Differentiate between device and port MAC addresses.
* ToDo: Handle PNET_MAX_PORT ports.
*/

#include "pf_includes.h"
Expand Down Expand Up @@ -987,7 +986,8 @@ void pf_lldp_mac_address_to_string (
*
* @param net In: The p-net stack instance.
* @param loc_port_num In: Local port number.
* Valid range: 1 .. PNET_MAX_PORT.
* Valid range:
* 1 .. PNET_NUMBER_OF_PHYSICAL_PORTS.
* @param buf Out: Ethernet frame buffer of size
* PF_FRAME_BUFFER_SIZE bytes.
*
Expand Down Expand Up @@ -1068,7 +1068,8 @@ size_t pf_lldp_construct_frame (pnet_t * net, int loc_port_num, uint8_t buf[])
*
* @param net InOut: The p-net stack instance
* @param loc_port_num In: Local port number.
* Valid range: 1 .. PNET_MAX_PORT
* Valid range:
* 1 .. PNET_NUMBER_OF_PHYSICAL_PORTS.
*/
static void pf_lldp_send (pnet_t * net, int loc_port_num)
{
Expand Down Expand Up @@ -1134,7 +1135,8 @@ static void pf_lldp_trigger_sending (
*
* @param net InOut: The p-net stack instance
* @param loc_port_num In: Local port number.
* Valid range: 1 .. PNET_MAX_PORT
* Valid range:
* 1 .. PNET_NUMBER_OF_PHYSICAL_PORTS.
* @param send In: Send LLDP message
*/
static void pf_lldp_tx_restart (pnet_t * net, int loc_port_num, bool send)
Expand Down Expand Up @@ -1825,7 +1827,8 @@ int pf_lldp_generate_alias_name (
*
* @param net InOut: p-net stack instance
* @param loc_port_num In: Local port number.
* Valid range: 1 .. PNET_MAX_PORT
* Valid range:
* 1 .. PNET_NUMBER_OF_PHYSICAL_PORTS.
* @param new_info In: Peer data to be stored
*/
void pf_lldp_store_peer_info (
Expand Down Expand Up @@ -1853,7 +1856,8 @@ void pf_lldp_store_peer_info (
*
* @param net InOut: p-net stack instance
* @param loc_port_num In: Local port number.
* Valid range: 1 .. PNET_MAX_PORT
* Valid range:
* 1 .. PNET_NUMBER_OF_PHYSICAL_PORTS.
* @param lldp_peer_info In: Peer data to be applied
*/
void pf_lldp_update_peer (
Expand Down
Loading

0 comments on commit f8f567e

Please sign in to comment.