Commit 9bfceb2b authored by Jean-Claude BAU's avatar Jean-Claude BAU

HAL code review: PPSi adaptation

The HAL states and the HAL share memory have changed. PPSi must follow
these modifications.
parent ec89448c
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
static struct pp_globals ppg_static; static struct pp_globals ppg_static;
static defaultDS_t defaultDS; static defaultDS_t defaultDS;
static currentDS_t currentDS; static currentDS_t currentDS;
static [parentDS_t parentDS; static parentDS_t parentDS;
static timePropertiesDS_t timePropertiesDS; static timePropertiesDS_t timePropertiesDS;
static struct pp_servo servo; static struct pp_servo servo;
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
#include <string.h> #include <string.h>
/* Port state machine states */ /* Port state machine states */
#define HAL_PORT_STATE_DISABLED 0 typedef enum {
#define HAL_PORT_STATE_LINK_DOWN 1 HAL_PORT_STATE_INIT=0,
#define HAL_PORT_STATE_UP 2 HAL_PORT_STATE_DISABLED,
#define HAL_PORT_STATE_CALIBRATION 3 HAL_PORT_STATE_LINK_DOWN,
#define HAL_PORT_STATE_LOCKING 4 HAL_PORT_STATE_LINK_UP,
#define HAL_PORT_STATE_RESET 5 } halPortState_t;
/* Read temperature from SFPs */ /* Read temperature from SFPs */
#define READ_SFP_DIAG_ENABLE 1 #define READ_SFP_DIAG_ENABLE 1
...@@ -59,33 +59,35 @@ typedef struct hal_port_calibration { ...@@ -59,33 +59,35 @@ typedef struct hal_port_calibration {
struct shw_sfp_caldata sfp; struct shw_sfp_caldata sfp;
struct shw_sfp_header sfp_header_raw; struct shw_sfp_header sfp_header_raw;
struct shw_sfp_dom sfp_dom_raw; struct shw_sfp_dom sfp_dom_raw;
int sfpPresent;
} hal_port_calibration_t; } hal_port_calibration_t;
/* Internal port state structure */ typedef struct {
struct hal_port_state { int state;
/* non-zero: allocated */ int nextState;
int in_use; } halPortFsmState_t;
/* linux i/f name */
char name[16];
/* MAC addr */ typedef struct {
uint8_t hw_addr[6]; int isSupported; /* Set if Low Phase Drift Calibration is supported */
halPortFsmState_t txSetupStates;
halPortFsmState_t rxSetupStates;
}halPortLPDC_t; /* data for Low phase drift calibration */
/* ioctl() hw index */ /* Internal port state structure */
int hw_index; struct hal_port_state {
int in_use; /* non-zero: allocated */
char name[16]; /* linux i/f name */
uint8_t hw_addr[6]; /* MAC addr */
int hw_index; /* ioctl() hw index : 0..n */
/* file descriptor for ioctls() */ int fd; /* file descriptor for ioctls() */
int fd;
int hw_addr_auto; int hw_addr_auto;
/* port FSM state (HAL_PORT_STATE_xxxx) */ /* port FSM state (HAL_PORT_STATE_xxxx) */
int state; halPortFsmState_t portStates;
/* fiber type, used to get alpha for SFP frequency */
int fiber_index;
/* 1: PLL is locked to this port */ int fiber_index;/* fiber type, used to get alpha for SFP frequency */
int locked; int locked; /* 1: PLL is locked to this port */
/* calibration data */ /* calibration data */
hal_port_calibration_t calib; hal_port_calibration_t calib;
...@@ -94,11 +96,10 @@ struct hal_port_state { ...@@ -94,11 +96,10 @@ struct hal_port_state {
uint32_t phase_val; uint32_t phase_val;
int phase_val_valid; int phase_val_valid;
int tx_cal_pending, rx_cal_pending; int tx_cal_pending, rx_cal_pending;
/* locking FSM state */
int lock_state;
/*reference lock period in picoseconds*/ int lock_state; /* locking FSM state */
uint32_t clock_period;
uint32_t clock_period; /*reference lock period in picoseconds*/
/* approximate DMTD phase value (on slave port) at which RX timestamp /* approximate DMTD phase value (on slave port) at which RX timestamp
* (T2) counter transistion occurs (picoseconds) */ * (T2) counter transistion occurs (picoseconds) */
...@@ -108,8 +109,7 @@ struct hal_port_state { ...@@ -108,8 +109,7 @@ struct hal_port_state {
* counter transistion occurs (picoseconds) */ * counter transistion occurs (picoseconds) */
uint32_t t4_phase_transition; uint32_t t4_phase_transition;
/* Endpoint's base address */ uint32_t ep_base;/* Endpoint's base address */
uint32_t ep_base;
/* whether SFP has diagnostic Monitoring capability */ /* whether SFP has diagnostic Monitoring capability */
int has_sfp_diag; int has_sfp_diag;
...@@ -122,6 +122,16 @@ struct hal_port_state { ...@@ -122,6 +122,16 @@ struct hal_port_state {
int synchronized; // <>0 if port is synchronized int synchronized; // <>0 if port is synchronized
int portInfoUpdated; // Set to 1 when updated int portInfoUpdated; // Set to 1 when updated
/* Events to process */
int evt_reset; /* Set if a reset is requested */
int evt_lock; /* Set if the ptracker must be activated*/
int evt_linkUp; /* Set if link is up ( driver call */
/* Low phase drift calibration data */
halPortLPDC_t lpdc;
/* Pll FSM */
halPortFsmState_t pllStates;
}; };
struct hal_temp_sensors { struct hal_temp_sensors {
...@@ -132,8 +142,7 @@ struct hal_temp_sensors { ...@@ -132,8 +142,7 @@ struct hal_temp_sensors {
}; };
/* This is the overall structure stored in shared memory */ /* This is the overall structure stored in shared memory */
#define HAL_SHMEM_VERSION 12 /* Version 12, added monitor to #define HAL_SHMEM_VERSION 13 /* Version 13, HAL code review */
struct hal_port_state */
struct hal_shmem_header { struct hal_shmem_header {
int nports; int nports;
...@@ -143,10 +152,14 @@ struct hal_shmem_header { ...@@ -143,10 +152,14 @@ struct hal_shmem_header {
int read_sfp_diag; int read_sfp_diag;
}; };
static inline int state_up(int state) static inline int get_port_state(struct hal_port_state *ps)
{
return ps->portStates.state;
}
static inline int state_up(struct hal_port_state *ps)
{ {
return (state != HAL_PORT_STATE_LINK_DOWN return get_port_state(ps) == HAL_PORT_STATE_LINK_UP;
&& state != HAL_PORT_STATE_DISABLED);
} }
static inline struct hal_port_state *hal_lookup_port( static inline struct hal_port_state *hal_lookup_port(
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <netinet/if_ether.h> #include <netinet/if_ether.h>
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
#include <limits.h>
#include <time.h> #include <time.h>
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
...@@ -53,9 +54,7 @@ static unsigned int run_all_state_machines(struct pp_globals *ppg) ...@@ -53,9 +54,7 @@ static unsigned int run_all_state_machines(struct pp_globals *ppg)
continue; continue;
} }
ppi->link_up = ppi->link_up =state_up(p);
(p->state != HAL_PORT_STATE_LINK_DOWN &&
p->state != HAL_PORT_STATE_DISABLED);
if (old_lu != ppi->link_up) { if (old_lu != ppi->link_up) {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <generated/autoconf.h> #include <generated/autoconf.h>
#include <stdint.h> #include <stdint.h>
#include <limits.h>
#include <stdarg.h> #include <stdarg.h>
#include <float.h> #include <float.h>
#include <stddef.h> #include <stddef.h>
......
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