@@ -3572,16 +3572,23 @@ void pf_put_pdport_data_real (
3572
3572
{
3573
3573
uint16_t block_pos = * p_pos ;
3574
3574
uint16_t block_len = 0 ;
3575
- uint8_t numPeers = 0 ;
3575
+ uint8_t num_peers = 0 ;
3576
+ uint16_t link_state = 0 ;
3576
3577
pf_lldp_station_name_t station_name ;
3577
3578
pf_lldp_port_name_t port_name ;
3579
+ pnal_eth_status_t eth_status ;
3578
3580
const uint16_t subslot = pf_port_loc_port_num_to_dap_subslot (loc_port_num );
3579
3581
const pnet_port_cfg_t * p_port_config =
3580
3582
pf_port_get_config (net , loc_port_num );
3581
3583
const pf_port_t * p_port_data = pf_port_get_state (net , loc_port_num );
3582
3584
const pf_lldp_peer_info_t * p_peer_info = & p_port_data -> lldp .peer_info ;
3583
3585
3584
- numPeers = p_peer_info -> ttl ? 1 : 0 ;
3586
+ num_peers = p_peer_info -> ttl ? 1 : 0 ;
3587
+
3588
+ if (pnal_eth_get_status (p_port_config -> phy_port .if_name , & eth_status ) != 0 )
3589
+ {
3590
+ memset (& eth_status , 0 , sizeof (eth_status ));
3591
+ }
3585
3592
3586
3593
/* Block header first */
3587
3594
pf_put_block_header (
@@ -3612,13 +3619,13 @@ void pf_put_pdport_data_real (
3612
3619
p_pos );
3613
3620
3614
3621
/* Number of Peers */
3615
- pf_put_byte (numPeers , res_len , p_bytes , p_pos );
3622
+ pf_put_byte (num_peers , res_len , p_bytes , p_pos );
3616
3623
3617
- /*Input only the number if it's there */
3618
- if (numPeers > 0 )
3619
- {
3620
- pf_put_padding (2 , res_len , p_bytes , p_pos );
3624
+ pf_put_padding (2 , res_len , p_bytes , p_pos );
3621
3625
3626
+ /* Peer info */
3627
+ if (num_peers > 0 )
3628
+ {
3622
3629
/* Peer port name */
3623
3630
pf_lldp_get_peer_port_name (net , loc_port_num , & port_name );
3624
3631
pf_put_byte (port_name .len , res_len , p_bytes , p_pos );
@@ -3653,92 +3660,50 @@ void pf_put_pdport_data_real (
3653
3660
p_pos );
3654
3661
3655
3662
pf_put_padding (2 , res_len , p_bytes , p_pos );
3663
+ } /* Peer info */
3656
3664
3657
- /* MAUType */
3658
- pf_put_uint16 (
3659
- is_big_endian ,
3660
- p_peer_info -> phy_config .operational_mau_type ,
3661
- res_len ,
3662
- p_bytes ,
3663
- p_pos );
3665
+ /* MAUType */
3666
+ pf_put_uint16 (
3667
+ is_big_endian ,
3668
+ eth_status .operational_mau_type ,
3669
+ res_len ,
3670
+ p_bytes ,
3671
+ p_pos );
3664
3672
3665
- pf_put_padding (2 , res_len , p_bytes , p_pos );
3673
+ pf_put_padding (2 , res_len , p_bytes , p_pos );
3666
3674
3667
- /* Domain Boundary */
3668
- pf_put_uint32 (
3669
- is_big_endian ,
3670
- p_peer_info -> domain_boundary ,
3671
- res_len ,
3672
- p_bytes ,
3673
- p_pos );
3675
+ /* Domain Boundary */
3676
+ /* Todo- hardcoded value*/
3677
+ pf_put_uint32 (is_big_endian , 0 , res_len , p_bytes , p_pos );
3674
3678
3675
- /* Multicast Boundary */
3676
- pf_put_uint32 (
3677
- is_big_endian ,
3678
- p_peer_info -> multicast_boundary ,
3679
- res_len ,
3680
- p_bytes ,
3681
- p_pos );
3679
+ /* Multicast Boundary */
3680
+ /* Todo- hardcoded value*/
3681
+ pf_put_uint32 (is_big_endian , 0 , res_len , p_bytes , p_pos );
3682
3682
3683
- /* LinkState.Port */
3684
- pf_put_byte (p_peer_info -> link_state_port , res_len , p_bytes , p_pos );
3683
+ /* PN-AL-protocol (Mar20) section 5.2.13.23 for LinkState encoding */
3684
+ /* LinkState.Link */
3685
+ if (eth_status .running )
3686
+ {
3687
+ link_state = PF_PD_LINK_STATE_LINK_UP ;
3688
+ }
3689
+ else
3690
+ {
3691
+ link_state = PF_PD_LINK_STATE_LINK_DOWN ;
3692
+ }
3685
3693
3686
- /* LinkState.Link */
3687
- /* TODO currently always set to up */
3688
- pf_put_byte (1 , res_len , p_bytes , p_pos );
3694
+ /* LinkState.Port */
3695
+ link_state |= (PF_PD_LINK_STATE_PORT_UNKNOWN << 8 );
3689
3696
3690
- pf_put_padding ( 2 , res_len , p_bytes , p_pos );
3697
+ pf_put_uint16 ( is_big_endian , link_state , res_len , p_bytes , p_pos );
3691
3698
3692
- /* MediaType (Decode what type it is and report it out per
3693
- * PROFINET AL Protocol Table 717
3694
- */
3695
- switch (p_peer_info -> phy_config .operational_mau_type )
3696
- {
3697
- case PNAL_ETH_MAU_RADIO :
3698
- /* Radio */
3699
- pf_put_uint32 (
3700
- is_big_endian ,
3701
- PF_PD_MEDIATYPE_RADIO ,
3702
- res_len ,
3703
- p_bytes ,
3704
- p_pos );
3705
- break ;
3706
- case PNAL_ETH_MAU_COPPER_10BaseT :
3707
- case PNAL_ETH_MAU_COPPER_100BaseTX_HALF_DUPLEX :
3708
- case PNAL_ETH_MAU_COPPER_100BaseTX_FULL_DUPLEX :
3709
- case PNAL_ETH_MAU_COPPER_1000BaseT_HALF_DUPLEX :
3710
- case PNAL_ETH_MAU_COPPER_1000BaseT_FULL_DUPLEX :
3711
- /* Copper */
3712
- pf_put_uint32 (
3713
- is_big_endian ,
3714
- PF_PD_MEDIATYPE_COPPER ,
3715
- res_len ,
3716
- p_bytes ,
3717
- p_pos );
3718
- break ;
3719
- case PNAL_ETH_MAU_FIBER_100BaseFX_HALF_DUPLEX :
3720
- case PNAL_ETH_MAU_FIBER_100BaseFX_FULL_DUPLEX :
3721
- case PNAL_ETH_MAU_FIBER_1000BaseX_HALF_DUPLEX :
3722
- case PNAL_ETH_MAU_FIBER_1000BaseX_FULL_DUPLEX :
3723
- /* Fiber */
3724
- pf_put_uint32 (
3725
- is_big_endian ,
3726
- PF_PD_MEDIATYPE_FIBER ,
3727
- res_len ,
3728
- p_bytes ,
3729
- p_pos );
3730
- break ;
3731
- default :
3732
- /* Unknown */
3733
- pf_put_uint32 (
3734
- is_big_endian ,
3735
- PF_PD_MEDIATYPE_UNKNOWN ,
3736
- res_len ,
3737
- p_bytes ,
3738
- p_pos );
3739
- break ;
3740
- }
3741
- }
3699
+ pf_put_padding (2 , res_len , p_bytes , p_pos );
3700
+
3701
+ pf_put_uint32 (
3702
+ is_big_endian ,
3703
+ pf_port_get_media_type (eth_status .operational_mau_type ),
3704
+ res_len ,
3705
+ p_bytes ,
3706
+ p_pos );
3742
3707
3743
3708
/* Finally insert the block length into the block header */
3744
3709
block_len = * p_pos - (block_pos + 4 );
@@ -3896,10 +3861,8 @@ static void pf_put_pd_multiblock_interface_and_statistics (
3896
3861
{
3897
3862
uint16_t block_pos = * p_pos ;
3898
3863
uint16_t block_len = 0 ;
3899
-
3900
3864
pnal_port_stats_t port_stats ;
3901
3865
3902
- /* TODO get correct interface/port name */
3903
3866
if (
3904
3867
pnal_get_port_statistics (
3905
3868
net -> fspm_cfg .if_cfg .main_port .if_name ,
@@ -3960,9 +3923,7 @@ static void pf_put_pd_multiblock_interface_and_statistics (
3960
3923
3961
3924
/**
3962
3925
* @internal
3963
- * Insert multiblock port and statistics
3964
- *
3965
- * TODO - Add multiport feature - current version only list port 1
3926
+ * Insert multiblock port and statistics for one port
3966
3927
*
3967
3928
* @param net InOut: The p-net stack instance
3968
3929
* @param is_big_endian In: Endianness of the destination buffer.
@@ -4042,33 +4003,38 @@ static void pf_put_pd_multiblock_port_and_statistics (
4042
4003
void pf_put_pd_real_data (
4043
4004
pnet_t * net ,
4044
4005
bool is_big_endian ,
4045
- int loc_port_num ,
4046
4006
const pf_iod_read_result_t * p_res ,
4047
4007
uint16_t res_len ,
4048
4008
uint8_t * p_bytes ,
4049
4009
uint16_t * p_pos )
4050
4010
{
4051
- /* Add Interface Data with the interface (port) statistics */
4011
+ int port ;
4012
+ pf_port_iterator_t port_iterator ;
4013
+
4052
4014
pf_put_pd_multiblock_interface_and_statistics (
4053
4015
net ,
4054
4016
is_big_endian ,
4055
4017
p_res ,
4056
4018
res_len ,
4057
4019
p_bytes ,
4058
4020
p_pos );
4059
- /* Added Port Data and Port Statistics
4060
- * ToDo: Probably should have a loop that knows how
4061
- * how many interfaces are on the device so this
4062
- * routine correctly reports out the information
4063
- */
4064
- pf_put_pd_multiblock_port_and_statistics (
4065
- net ,
4066
- is_big_endian ,
4067
- loc_port_num ,
4068
- p_res ,
4069
- res_len ,
4070
- p_bytes ,
4071
- p_pos );
4021
+
4022
+ pf_port_init_iterator_over_ports (net , & port_iterator );
4023
+ port = pf_port_get_next (& port_iterator );
4024
+
4025
+ while (port != 0 )
4026
+ {
4027
+ pf_put_pd_multiblock_port_and_statistics (
4028
+ net ,
4029
+ is_big_endian ,
4030
+ port ,
4031
+ p_res ,
4032
+ res_len ,
4033
+ p_bytes ,
4034
+ p_pos );
4035
+
4036
+ port = pf_port_get_next (& port_iterator );
4037
+ }
4072
4038
}
4073
4039
4074
4040
/**
0 commit comments