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