Skip to content

Commit b7d6ebf

Browse files
committed
Rename PNET_MAX_PORT to PNET_NUMBER_OF_PHYSICAL_PORTS
1 parent 1376ac7 commit b7d6ebf

32 files changed

+192
-134
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ set(PNET_MAX_CR 2
6060
set(PNET_MAX_SLOTS 5
6161
CACHE STRING "Per API. Should be > 1 to allow at least one I/O module")
6262
set(PNET_MAX_SUBSLOTS 3
63-
CACHE STRING "Per slot (DAP requires 2 + PNET_MAX_PORT)")
63+
CACHE STRING "Per slot (DAP requires 2 + PNET_NUMBER_OF_PHYSICAL_PORTS)")
6464
set(PNET_MAX_CHANNELS 1
6565
CACHE STRING "Per sub-slot. Used for diagnosis")
6666
set(PNET_MAX_DFP_IOCR 2
6767
CACHE STRING "Allowed values are 0 (zero) or 2")
68-
set(PNET_MAX_PORT 1
68+
set(PNET_NUMBER_OF_PHYSICAL_PORTS 1
6969
CACHE STRING "Number of physical ports")
7070
set(PNET_MAX_LOG_BOOK_ENTRIES 16
7171
CACHE STRING "")

doc/multiple_ports.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ To run p-net and the sample application with multiple ports a couple
9999
of things need to be done. Note that the settings described in the
100100
following sections are changed by running ``ccmake .`` in the build folder.
101101
``options.h`` will be regenerated. Another way to set the options is to
102-
set them on the cmake command line (-DPNET_MAX_PORT=2 -DPNET_MAX_SUBSLOTS=4).
102+
set them on the cmake command line (-DPNET_NUMBER_OF_PHYSICAL_PORTS=2 -DPNET_MAX_SUBSLOTS=4).
103103

104-
Reconfigure setting ``PNET_MAX_PORT`` to the actual number of physical ports available in the system.
105-
For this example ``PNET_MAX_PORT`` shall be set to 2.
104+
Reconfigure setting ``PNET_NUMBER_OF_PHYSICAL_PORTS`` to the actual number of physical ports available in the system.
105+
For this example ``PNET_NUMBER_OF_PHYSICAL_PORTS`` shall be set to 2.
106106

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

include/pnet_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ typedef struct pnet_if_cfg
12041204
const char * main_netif_name; /**< Main (DAP) network interface. */
12051205
pnet_ip_cfg_t ip_cfg; /**< IP Settings for main network interface */
12061206

1207-
pnet_port_cfg_t physical_ports[PNET_MAX_PORT];
1207+
pnet_port_cfg_t physical_ports[PNET_NUMBER_OF_PHYSICAL_PORTS];
12081208
} pnet_if_cfg_t;
12091209

12101210
/**

options.h.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@
112112
#define PNET_MAX_DFP_IOCR @PNET_MAX_DFP_IOCR@
113113
#endif
114114

115-
#if !defined (PNET_MAX_PORT)
115+
#if !defined (PNET_NUMBER_OF_PHYSICAL_PORTS)
116116
/** 2 for media redundancy. Currently only 1 is supported. */
117-
#define PNET_MAX_PORT @PNET_MAX_PORT@
117+
#define PNET_NUMBER_OF_PHYSICAL_PORTS @PNET_NUMBER_OF_PHYSICAL_PORTS@
118118
#endif
119119

120120
#if !defined (PNET_MAX_LOG_BOOK_ENTRIES)

sample_app/GSDML-V2.4-RT-Labs-P-Net-Sample-App-20210202.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Current list works for Raspberry Pi, Linksys usb/ethernet dongle and xmc sample
6666
</MAUTypeList>
6767
</PortSubmoduleItem>
6868
<!--
69-
Enable to support additional port. (PNET_MAX_PORT == 2)
69+
Enable to support additional port. (PNET_NUMBER_OF_PHYSICAL_PORTS == 2)
7070
Add additional PortSubmoduleItems to support additional ports
7171
-->
7272
<!--

sample_app/sampleapp_common.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ void app_plug_dap (pnet_t * net, void * arg)
12761276
PNET_SUBMOD_DAP_INTERFACE_1_PORT_1_IDENT,
12771277
&cfg_dap_data);
12781278

1279-
#if PNET_MAX_PORT >= 2
1279+
#if PNET_MAX_PHY_PORTS >= 2
12801280
app_exp_submodule_ind (
12811281
net,
12821282
arg,
@@ -1288,7 +1288,7 @@ void app_plug_dap (pnet_t * net, void * arg)
12881288
&cfg_dap_data);
12891289
#endif
12901290

1291-
#if PNET_MAX_PORT >= 3
1291+
#if PNET_MAX_PHY_PORTS >= 3
12921292
app_exp_submodule_ind (
12931293
net,
12941294
arg,
@@ -1300,7 +1300,7 @@ void app_plug_dap (pnet_t * net, void * arg)
13001300
&cfg_dap_data);
13011301
#endif
13021302

1303-
#if PNET_MAX_PORT >= 4
1303+
#if PNET_MAX_PHY_PORTS >= 4
13041304
app_exp_submodule_ind (
13051305
net,
13061306
arg,
@@ -1481,7 +1481,10 @@ int app_pnet_cfg_init_netifs (
14811481
pnal_ipaddr_t netmask;
14821482
pnal_ipaddr_t gateway;
14831483

1484-
ret = app_get_netif_namelist (netif_list_str, if_list, PNET_MAX_PORT);
1484+
ret = app_get_netif_namelist (
1485+
netif_list_str,
1486+
if_list,
1487+
PNET_NUMBER_OF_PHYSICAL_PORTS);
14851488
if (ret != 0)
14861489
{
14871490
return ret;
@@ -1493,7 +1496,7 @@ int app_pnet_cfg_init_netifs (
14931496
printf ("Management port: %s\n", p_cfg->if_cfg.main_netif_name);
14941497
}
14951498

1496-
for (i = 1; i <= PNET_MAX_PORT; i++)
1499+
for (i = 1; i <= PNET_NUMBER_OF_PHYSICAL_PORTS; i++)
14971500
{
14981501
p_cfg->if_cfg.physical_ports[i - 1].netif_name = if_list->netif[i].name;
14991502
if (verbosity > 0)

sample_app/sampleapp_common.h

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static const cfg_submodule_type_t cfg_available_submodule_types[] = {
131131
PNET_DIR_NO_IO,
132132
0,
133133
0},
134-
#if PNET_MAX_PORT >= 2
134+
#if PNET_NUMBER_OF_PHYSICAL_PORTS >= 2
135135
{"DAP Port 2",
136136
APP_API,
137137
PNET_MOD_DAP_IDENT,
@@ -140,7 +140,7 @@ static const cfg_submodule_type_t cfg_available_submodule_types[] = {
140140
0,
141141
0},
142142
#endif
143-
#if PNET_MAX_PORT >= 3
143+
#if PNET_NUMBER_OF_PHYSICAL_PORTS >= 3
144144
{"DAP Port 3",
145145
APP_API,
146146
PNET_MOD_DAP_IDENT,
@@ -149,7 +149,7 @@ static const cfg_submodule_type_t cfg_available_submodule_types[] = {
149149
0,
150150
0},
151151
#endif
152-
#if PNET_MAX_PORT >= 4
152+
#if PNET_NUMBER_OF_PHYSICAL_PORTS >= 4
153153
{"DAP Port 4",
154154
APP_API,
155155
PNET_MOD_DAP_IDENT,
@@ -190,8 +190,8 @@ struct cmd_args
190190
char path_storage_directory[PNET_MAX_DIRECTORYPATH_SIZE]; /** Terminated */
191191
char station_name[PNET_STATION_NAME_MAX_SIZE]; /** Terminated string */
192192
char eth_interfaces
193-
[PNET_INTERFACE_NAME_MAX_SIZE * (PNET_MAX_PORT + 1) +
194-
PNET_MAX_PORT]; /** Terminated string */
193+
[PNET_INTERFACE_NAME_MAX_SIZE * (PNET_NUMBER_OF_PHYSICAL_PORTS + 1) +
194+
PNET_NUMBER_OF_PHYSICAL_PORTS]; /** Terminated string */
195195
int verbosity;
196196
int show;
197197
bool factory_reset;
@@ -205,7 +205,7 @@ typedef struct app_netif_name
205205

206206
typedef struct app_netif_namelist
207207
{
208-
app_netif_name_t netif[PNET_MAX_PORT + 1];
208+
app_netif_name_t netif[PNET_NUMBER_OF_PHYSICAL_PORTS + 1];
209209
} app_netif_namelist_t;
210210

211211
typedef struct app_subslot
@@ -321,19 +321,17 @@ int app_pnet_cfg_init_netifs (
321321

322322
/**
323323
* Parse a comma separated list of network interfaces and check
324-
* that the number of interfaces match the PNET_MAX_PORT configuration.
325-
* Examples:
326-
* PNET_MAX_PORT arg_str status
327-
* 1 "eth0" ok
328-
* 1 "eth0,eth1" err
329-
* 2 "br0,eth0,eth1" ok
330-
* 2 "br0,eth0," err
324+
* that the number of interfaces match the PNET_NUMBER_OF_PHYSICAL_PORTS
325+
* configuration. Examples: PNET_NUMBER_OF_PHYSICAL_PORTS arg_str status 1
326+
* "eth0" ok 1 "eth0,eth1" err 2
327+
* "br0,eth0,eth1" ok 2 "br0,eth0," err
331328
*
332329
* @param arg_str In: Network interface list as comma separated,
333330
* terminated string. For example "eth0" or
334331
* "br0,eth0,eth1".
335332
* @param p_if_list Out: List of network interfaces
336-
* @param max_port In: PNET_MAX_PORT, passed as argument to allow test
333+
* @param max_port In: PNET_NUMBER_OF_PHYSICAL_PORTS, passed as argument to
334+
* allow test
337335
* @return 0 if network interface list matches configuration
338336
* -1 on error
339337
*/

src/common/pf_cpm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ int pf_cpm_activate_req (pnet_t * net, pf_ar_t * p_ar, uint32_t crep)
578578
(uint32_t)p_iocr->param.reduction_ratio * 1000U) /
579579
32U; /* us */
580580

581-
for (ix = 0; ix < PNET_MAX_PORT; ix++)
581+
for (ix = 0; ix < PNET_NUMBER_OF_PHYSICAL_PORTS; ix++)
582582
{
583583
p_cpm->rxa[ix][0] = -1; /* "invalid" cycle counter */
584584
p_cpm->rxa[ix][1] = -1;

src/common/pf_eth.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,6 @@
3333
#include <string.h>
3434
#include "pf_includes.h"
3535

36-
/**
37-
* Init network interface.
38-
* Set name, read mac address, register receive callback.
39-
*
40-
* @param net InOut: The p-net stack instance
41-
* @param netif_name In: Network interface name
42-
* @param eth_receive_type In: Ethernet frame types that shall be received
43-
* by the network interface / port.
44-
* @param netif Out: Initialized network interface.
45-
* @return
46-
*/
4736
static int pf_eth_init_netif (
4837
pnet_t * net,
4938
const char * netif_name,
@@ -69,7 +58,7 @@ static int pf_eth_init_netif (
6958
return -1;
7059
}
7160

72-
memcpy (netif->mac.addr, pnal_mac_addr.addr, sizeof (netif->mac.addr));
61+
memcpy(netif->mac.addr, pnal_mac_addr.addr, sizeof(netif->mac.addr));
7362

7463
return 0;
7564
}
@@ -80,13 +69,13 @@ int pf_eth_init (pnet_t * net, const pnet_cfg_t * p_cfg)
8069
pf_port_iterator_t port_iterator;
8170
pf_port_t * p_port_data;
8271
pnal_ethertype_t main_port_receive_type;
83-
#if PNET_MAX_PORT > 1
72+
#if PNET_NUMBER_OF_PHYSICAL_PORTS > 1
8473
const pnet_port_cfg_t * p_port_cfg;
8574
#endif
8675

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

89-
#if (PNET_MAX_PORT == 1)
78+
#if (PNET_NUMBER_OF_PHYSICAL_PORTS == 1)
9079
main_port_receive_type = PNAL_ETHTYPE_ALL;
9180
#else
9281
main_port_receive_type = PNAL_ETHTYPE_PROFINET;
@@ -110,7 +99,7 @@ int pf_eth_init (pnet_t * net, const pnet_cfg_t * p_cfg)
11099
{
111100
p_port_data = pf_port_get_state (net, port);
112101

113-
#if PNET_MAX_PORT > 1
102+
#if PNET_NUMBER_OF_PHYSICAL_PORTS > 1
114103
p_port_cfg = pf_port_get_config (net, port);
115104

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

131120
port = pf_port_get_next (&port_iterator);
132121
}
122+
133123
return 0;
134124
}
135125

src/common/pf_eth.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ extern "C" {
2222

2323
/**
2424
* Initialize ETH component and network interfaces according to configuration
25-
* If device is configured with one network interface (PNET_MAX_PORT==1),
26-
* the management port and physical port 1 refers to same network interface.
27-
* In a multi port configuration, the management port and physical ports are
28-
* different network interfaces.
25+
* If device is configured with one network interface
26+
* (PNET_NUMBER_OF_PHYSICAL_PORTS==1), the management port and physical port 1
27+
* refers to same network interface. In a multi port configuration, the
28+
* management port and physical ports are different network interfaces.
2929
* @param net InOut: The p-net stack instance
3030
* @param p_cfg In: Configuration
3131
* @return 0 on success

0 commit comments

Comments
 (0)