Commit 1b9a4077 authored by Adam Wujek's avatar Adam Wujek 💬 Committed by Grzegorz Daniluk

Get rid of hexp_port_state

Done as a part of work to move hal to shm in wrs.

Done in this commit:
--use wrpc_get_port_state instead of halexp_get_port_state
--make wrpc_get_port_state fill hal_port_state structure in the way how HAL
  fills shmem.
--update lib/net.c to use struct hal_port_state instead of hexp_port_state_t
--update monitor/monitor_ppsi.c to use struct hal_port_state instead of
  hexp_port_state_t
--update ppsi to get needed changes
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 8f6a011e
......@@ -3,6 +3,7 @@
#include <errno.h>
#include "hal_exports.h"
#include <wrpc.h>
#include "ptpd_netif.h"
#include "board.h"
......@@ -71,7 +72,7 @@ wr_socket_t *ptpd_netif_create_socket(int sock_type, int flags,
wr_sockaddr_t * bind_addr)
{
int i;
hexp_port_state_t pstate;
struct hal_port_state pstate;
struct my_socket *sock;
/* Look for the first available socket. */
......@@ -89,7 +90,7 @@ wr_socket_t *ptpd_netif_create_socket(int sock_type, int flags,
if (sock_type != PTPD_SOCK_RAW_ETHERNET)
return NULL;
if (halexp_get_port_state(&pstate, bind_addr->if_name) < 0)
if (wrpc_get_port_state(&pstate, bind_addr->if_name) < 0)
return NULL;
memcpy(&sock->bind_addr, bind_addr, sizeof(wr_sockaddr_t));
......
#include <stdint.h>
#include <hal_exports.h>
#include <libwr/hal_shmem.h>
#include <wrc_ptp.h>
#include <syscon.h>
#include <endpoint.h>
......@@ -16,52 +16,51 @@ uint64_t ptpd_netif_get_msec_tics(void)
return timer_get_tics();
}
static int read_phase_val(hexp_port_state_t *state)
static int read_phase_val(struct hal_port_state *port)
{
int32_t dmtd_phase;
int32_t dmtd_phase;
if(spll_read_ptracker(0, &dmtd_phase, NULL))
{
state->phase_val = dmtd_phase;
state->phase_val_valid = 1;
}
else
{
state->phase_val = 0;
state->phase_val_valid = 0;
}
if (spll_read_ptracker(0, &dmtd_phase, NULL)) {
port->phase_val = dmtd_phase;
port->phase_val_valid = 1;
} else {
port->phase_val = 0;
port->phase_val_valid = 0;
}
return 0;
return 0;
}
extern uint32_t cal_phase_transition;
extern int32_t sfp_alpha;
int halexp_get_port_state(hexp_port_state_t *state, const char *port_name)
int wrpc_get_port_state(struct hal_port_state *port, const char *port_name)
{
state->valid = 1;
if (wrc_ptp_get_mode() == WRC_MODE_SLAVE)
port->mode = HEXP_PORT_MODE_WR_SLAVE;
else
port->mode = HEXP_PORT_MODE_WR_MASTER;
if(wrc_ptp_get_mode()==WRC_MODE_SLAVE)
state->mode = HEXP_PORT_MODE_WR_SLAVE;
else
state->mode = HEXP_PORT_MODE_WR_MASTER;
/* all deltas are added anyway */
ep_get_deltas(&port->calib.delta_tx_board,
&port->calib.delta_rx_board);
port->calib.delta_tx_phy = 0;
port->calib.delta_rx_phy = 0;
port->calib.sfp.delta_tx_ps = 0;
port->calib.sfp.delta_rx_ps = 0;
read_phase_val(port);
port->state = ep_link_up(NULL);
port->calib.tx_calibrated = 1;
port->calib.rx_calibrated = 1;
port->locked = spll_check_lock(0);
/* port->lock_priority = 0;*/
/*spll_get_phase_shift(0, NULL, (int32_t *)&port->phase_setpoint);*/
port->clock_period = 8000;
port->t2_phase_transition = cal_phase_transition;
port->t4_phase_transition = cal_phase_transition;
get_mac_addr(port->hw_addr);
port->hw_index = 0;
ep_get_deltas( &state->delta_tx, &state->delta_rx);
read_phase_val(state);
state->up = ep_link_up(NULL);
state->tx_calibrated = 1;
state->rx_calibrated = 1;
state->is_locked = spll_check_lock(0);
state->lock_priority = 0;
spll_get_phase_shift(0, NULL, (int32_t *)&state->phase_setpoint);
state->clock_period = 8000;
state->t2_phase_transition = cal_phase_transition;
state->t4_phase_transition = cal_phase_transition;
get_mac_addr(state->hw_addr);
state->hw_index = 0;
state->fiber_fix_alpha = sfp_alpha;
return 0;
return 0;
}
int ptpd_netif_get_dmtd_phase(wr_socket_t *sock, int32_t *phase)
......
......@@ -75,7 +75,7 @@ int wrc_mon_status()
void wrc_mon_gui(void)
{
static uint32_t last;
hexp_port_state_t ps;
struct hal_port_state state;
int tx, rx;
int aux_stat;
uint64_t sec;
......@@ -102,16 +102,16 @@ void wrc_mon_gui(void)
cprintf(C_WHITE, "%s", format_time(sec));
/*show_ports */
halexp_get_port_state(&ps, NULL);
wrpc_get_port_state(&state, NULL);
pcprintf(4, 1, C_BLUE, "\n\nLink status:");
pcprintf(6, 1, C_WHITE, "%s: ", "wru1");
if (ps.up)
if (state.state)
cprintf(C_GREEN, "Link up ");
else
cprintf(C_RED, "Link down ");
if (ps.up) {
if (state.state) {
minic_get_stats(&tx, &rx);
cprintf(C_GREY, "(RX: %d, TX: %d), mode: ", rx, tx);
......@@ -132,11 +132,11 @@ void wrc_mon_gui(void)
cprintf(C_RED, "WR Unknown ");
}
if (ps.is_locked)
if (state.locked)
cprintf(C_GREEN, "Locked ");
else
cprintf(C_RED, "NoLock ");
if (ps.rx_calibrated && ps.tx_calibrated)
if (state.calib.rx_calibrated && state.calib.tx_calibrated)
cprintf(C_GREEN, "Calibrated ");
else
cprintf(C_RED, "Uncalibrated ");
......@@ -259,7 +259,7 @@ static void wrc_mon_std_servo(void)
int wrc_log_stats(uint8_t onetime)
{
static uint32_t last;
hexp_port_state_t ps;
struct hal_port_state state;
int tx, rx;
int aux_stat;
uint64_t sec;
......@@ -273,10 +273,10 @@ int wrc_log_stats(uint8_t onetime)
last = timer_get_tics();
shw_pps_gen_get_time(&sec, &nsec);
halexp_get_port_state(&ps, NULL);
wrpc_get_port_state(&state, NULL);
minic_get_stats(&tx, &rx);
pp_printf("lnk:%d rx:%d tx:%d ", ps.up, rx, tx);
pp_printf("lock:%d ", ps.is_locked ? 1 : 0);
pp_printf("lnk:%d rx:%d tx:%d ", state.state, rx, tx);
pp_printf("lock:%d ", state.locked ? 1 : 0);
pp_printf("sv:%d ", cur_servo_state.valid ? 1 : 0);
pp_printf("ss:'%s' ", cur_servo_state.slave_servo_state);
aux_stat = spll_get_aux_status(0);
......
ppsi @ 4a60739f
Subproject commit d724bd8f100aa227d5aa01ccace3ed023b140a8b
Subproject commit 4a60739fc06a3d68718e1bdeece92bd7b279253d
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