Commit 1f503295 authored by Jean-Claude BAU's avatar Jean-Claude BAU

New field activePeer in pp_instance structure

This field is used to store the active peer connected to an instance. In
wr_mon tool, it replaces the field peer on the display which was not
very explicit when many peers are connected on the same port. The field
activePeer takes the value of peer field in the following cases :

           MASTER          UNCALIBRATED/SLAVE
P2P     Rx PDELAY_RESP    Rx qualified ANNOUNCE
          (Filtered)
E2E       DELAY_RESP      Rx qualified ANNOUNCE

In other cases, the activePeer field is set to 0
parent 9519a833
......@@ -99,8 +99,13 @@ char *get_state_as_string(struct pp_instance *ppi, int state) {
int pp_leave_current_state(struct pp_instance *ppi)
{
/* If something has to be done in an extension */
if ( ppi->ext_hooks->state_change)
if ( ppi->ext_hooks->state_change) {
// When leaving MASTER/SLAVE states, clear the active peer field
if ( ppi->state==PPS_MASTER || ppi->state==PPS_SLAVE)
bzero(ppi->activePeer,sizeof(ppi->activePeer));
ppi->ext_hooks->state_change(ppi);
}
/* if the next or old state is non standard PTP reset all timeouts */
if ((ppi->state > PPS_LAST_STATE) || (ppi->next_state > PPS_LAST_STATE))
......
......@@ -240,7 +240,8 @@ struct pp_instance {
struct pp_channel ch[__NR_PP_NP]; /* general and event ch */
Integer32 mcast_addr[2]; /* only ipv4/udp */
int tx_offset, rx_offset; /* ptp payload vs send/recv */
unsigned char peer[6]; /* Our peer's MAC address */
unsigned char peer[6]; /* Our peer's MAC address from last received msg*/
unsigned char activePeer[6]; /* Our peer's MAC address we talk with */
uint16_t peer_vid; /* Our peer's VID (for PROTO_VLAN) */
/* Times, for the various offset computations */
......
......@@ -101,6 +101,10 @@ int st_com_peer_handle_pres(struct pp_instance *ppi, void *buf,
if (!(hdr->flagField[0] & PP_TWO_STEP_FLAG))
e = presp_call_servo(ppi);
/* Save active peer MAC address */
memcpy(ppi->activePeer,ppi->peer, sizeof(ppi->activePeer));
} else {
pp_diag(ppi, frames, 2, "pp_pclock : "
"PDelay Resp doesn't match PDelay Req\n");
......
......@@ -58,6 +58,9 @@ static int master_handle_delay_request(struct pp_instance *ppi,
if ( !msg_issue_delay_resp(ppi, &ppi->last_rcv_time) ) {
if (is_ext_hook_available(ppi,handle_dreq))
ppi->ext_hooks->handle_dreq(ppi);
/* Save active peer MAC address */
memcpy(ppi->activePeer,ppi->peer, sizeof(ppi->activePeer));
}
}
}
......
......@@ -192,7 +192,7 @@ static int slave_handle_announce(struct pp_instance *ppi, void *buf, int len)
{
int ret;
struct pp_frgn_master frgn_master;
if ((ret = st_com_handle_announce(ppi, buf, len))!=0)
return ret;
......@@ -230,6 +230,9 @@ static int slave_handle_announce(struct pp_instance *ppi, void *buf, int len)
/* 9.5.3 Figure 29 update data set if announce from current master */
bmc_s1(ppi, &frgn_master);
/* Save active peer MAC address */
memcpy(ppi->activePeer,ppi->peer, sizeof(ppi->activePeer));
return 0;
}
......
......@@ -243,6 +243,7 @@ struct dump_info ppi_info [] = {
DUMP_FIELD(int, tx_offset),
DUMP_FIELD(int, rx_offset),
DUMP_FIELD_SIZE(bina, peer, 6),
DUMP_FIELD_SIZE(bina, activePeer, 6),
DUMP_FIELD(uint16_t, peer_vid),
DUMP_FIELD(time, t1),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment