Commit a1fce7e8 authored by Alessandro Rubini's avatar Alessandro Rubini

general: is_new_state is a flag (makes it larger)

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 80b4fd6b
...@@ -49,7 +49,7 @@ void sim_main_loop(struct pp_globals *ppg) ...@@ -49,7 +49,7 @@ void sim_main_loop(struct pp_globals *ppg)
/* Initialize each link's state machine */ /* Initialize each link's state machine */
for (j = 0; j < ppg->nlinks; j++) { for (j = 0; j < ppg->nlinks; j++) {
ppi = INST(ppg, j); ppi = INST(ppg, j);
ppi->is_new_state = 1; ppi->flags |= PPI_FLAG_IS_NEW_STATE;
} }
delay_ns = run_all_state_machines(ppg) * 1000LL * 1000LL; delay_ns = run_all_state_machines(ppg) * 1000LL * 1000LL;
...@@ -67,7 +67,7 @@ void sim_main_loop(struct pp_globals *ppg) ...@@ -67,7 +67,7 @@ void sim_main_loop(struct pp_globals *ppg)
new_state = bmc(ppi); new_state = bmc(ppi);
if (new_state != ppi->state) { if (new_state != ppi->state) {
ppi->state = new_state; ppi->state = new_state;
ppi->is_new_state = 1; ppi->flags |= PPI_FLAG_IS_NEW_STATE;
} }
} }
ppg->ebest_updated = 0; ppg->ebest_updated = 0;
......
...@@ -60,7 +60,7 @@ void unix_main_loop(struct pp_globals *ppg) ...@@ -60,7 +60,7 @@ void unix_main_loop(struct pp_globals *ppg)
* doing anything else but the protocol, this allows extra stuff * doing anything else but the protocol, this allows extra stuff
* to fit. * to fit.
*/ */
ppi->is_new_state = 1; ppi->flags |= PPI_FLAG_IS_NEW_STATE;
} }
delay_ms = run_all_state_machines(ppg); delay_ms = run_all_state_machines(ppg);
...@@ -80,7 +80,7 @@ void unix_main_loop(struct pp_globals *ppg) ...@@ -80,7 +80,7 @@ void unix_main_loop(struct pp_globals *ppg)
new_state = bmc(ppi); new_state = bmc(ppi);
if (new_state != ppi->state) { if (new_state != ppi->state) {
ppi->state = new_state; ppi->state = new_state;
ppi->is_new_state = 1; ppi->flags |= PPI_FLAG_IS_NEW_STATE;
} }
} }
ppg->ebest_updated = 0; ppg->ebest_updated = 0;
......
...@@ -96,7 +96,7 @@ void wrs_main_loop(struct pp_globals *ppg) ...@@ -96,7 +96,7 @@ void wrs_main_loop(struct pp_globals *ppg)
* doing anything else but the protocol, this allows extra stuff * doing anything else but the protocol, this allows extra stuff
* to fit. * to fit.
*/ */
ppi->is_new_state = 1; ppi->flags |= PPI_FLAG_IS_NEW_STATE;
} }
delay_ms = run_all_state_machines(ppg); delay_ms = run_all_state_machines(ppg);
...@@ -118,7 +118,7 @@ void wrs_main_loop(struct pp_globals *ppg) ...@@ -118,7 +118,7 @@ void wrs_main_loop(struct pp_globals *ppg)
new_state = bmc(ppi); new_state = bmc(ppi);
if (new_state != ppi->state) { if (new_state != ppi->state) {
ppi->state = new_state; ppi->state = new_state;
ppi->is_new_state = 1; ppi->flags |= PPI_FLAG_IS_NEW_STATE;
} }
} }
ppg->ebest_updated = 0; ppg->ebest_updated = 0;
......
...@@ -108,7 +108,7 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen) ...@@ -108,7 +108,7 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
/* found: handle this state */ /* found: handle this state */
ppi->next_state = state; ppi->next_state = state;
ppi->next_delay = 0; ppi->next_delay = 0;
if (ppi->is_new_state) if (pp_is_new_state(ppi))
pp_diag_fsm(ppi, ip->name, STATE_ENTER, plen); pp_diag_fsm(ppi, ip->name, STATE_ENTER, plen);
err = ip->f1(ppi, packet, plen); err = ip->f1(ppi, packet, plen);
if (err) if (err)
...@@ -118,11 +118,11 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen) ...@@ -118,11 +118,11 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
/* done: if new state mark it, and enter it now (0 ms) */ /* done: if new state mark it, and enter it now (0 ms) */
if (ppi->state != ppi->next_state) { if (ppi->state != ppi->next_state) {
ppi->state = ppi->next_state; ppi->state = ppi->next_state;
ppi->is_new_state = 1; ppi->flags |= PPI_FLAG_IS_NEW_STATE;
pp_diag_fsm(ppi, ip->name, STATE_LEAVE, 0); pp_diag_fsm(ppi, ip->name, STATE_LEAVE, 0);
return 0; /* next_delay unused: go to new state now */ return 0; /* next_delay unused: go to new state now */
} }
ppi->is_new_state = 0; ppi->flags &= ~PPI_FLAG_IS_NEW_STATE;
pp_diag_fsm(ppi, ip->name, STATE_LOOP, 0); pp_diag_fsm(ppi, ip->name, STATE_LOOP, 0);
return ppi->next_delay; return ppi->next_delay;
} }
......
...@@ -137,7 +137,7 @@ struct pp_instance_cfg { ...@@ -137,7 +137,7 @@ struct pp_instance_cfg {
*/ */
struct pp_instance { struct pp_instance {
int state; int state;
int next_state, next_delay, is_new_state; /* set by state processing */ int next_state, next_delay; /* set by state processing */
void *arch_data; /* if arch needs it */ void *arch_data; /* if arch needs it */
void *ext_data; /* if protocol ext needs it */ void *ext_data; /* if protocol ext needs it */
unsigned long d_flags; /* diagnostics, ppi-specific flags */ unsigned long d_flags; /* diagnostics, ppi-specific flags */
...@@ -195,6 +195,8 @@ struct pp_instance { ...@@ -195,6 +195,8 @@ struct pp_instance {
#define PPI_FLAG_MASTER_ONLY 0x0020 #define PPI_FLAG_MASTER_ONLY 0x0020
#define PPI_FLAG_FROM_CURRENT_PARENT 0x0100 #define PPI_FLAG_FROM_CURRENT_PARENT 0x0100
#define PPI_FLAG_WAITING_FOR_F_UP 0x0200 #define PPI_FLAG_WAITING_FOR_F_UP 0x0200
#define PPI_FLAG_IS_NEW_STATE 0x0400
#define pp_is_new_state(ppi) ((ppi)->flags & PPI_FLAG_IS_NEW_STATE)
struct pp_globals_cfg { struct pp_globals_cfg {
......
...@@ -30,7 +30,7 @@ void bare_main_loop(struct pp_instance *ppi) ...@@ -30,7 +30,7 @@ void bare_main_loop(struct pp_instance *ppi)
* doing anything else but the protocol, this allows extra stuff * doing anything else but the protocol, this allows extra stuff
* to fit. * to fit.
*/ */
ppi->is_new_state = 1; ppi->flags |= PPI_FLAG_IS_NEW_STATE;
delay_ms = pp_state_machine(ppi, NULL, 0); delay_ms = pp_state_machine(ppi, NULL, 0);
while (1) { while (1) {
struct bare_fd_set set; struct bare_fd_set set;
......
...@@ -18,7 +18,7 @@ int wr_calibrated(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -18,7 +18,7 @@ int wr_calibrated(struct pp_instance *ppi, unsigned char *pkt, int plen)
struct wr_dsport *wrp = WR_DSPOR(ppi); struct wr_dsport *wrp = WR_DSPOR(ppi);
MsgSignaling wrsig_msg; MsgSignaling wrsig_msg;
if (ppi->is_new_state) if (pp_is_new_state(ppi))
pp_timeout_set(ppi, PP_TO_EXT_0, wrp->wrStateTimeout); pp_timeout_set(ppi, PP_TO_EXT_0, wrp->wrStateTimeout);
if (pp_timeout_z(ppi, PP_TO_EXT_0)) { if (pp_timeout_z(ppi, PP_TO_EXT_0)) {
......
...@@ -19,7 +19,7 @@ int wr_calibration(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -19,7 +19,7 @@ int wr_calibration(struct pp_instance *ppi, unsigned char *pkt, int plen)
int e = 0, sendmsg = 0; int e = 0, sendmsg = 0;
uint32_t delta; uint32_t delta;
if (ppi->is_new_state) { if (pp_is_new_state(ppi)) {
wrp->wrStateRetry = WR_STATE_RETRY; wrp->wrStateRetry = WR_STATE_RETRY;
sendmsg = 1; sendmsg = 1;
} else if (pp_timeout_z(ppi, PP_TO_EXT_0)) { } else if (pp_timeout_z(ppi, PP_TO_EXT_0)) {
......
...@@ -19,7 +19,7 @@ int wr_locked(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -19,7 +19,7 @@ int wr_locked(struct pp_instance *ppi, unsigned char *pkt, int plen)
MsgSignaling wrsig_msg; MsgSignaling wrsig_msg;
struct wr_dsport *wrp = WR_DSPOR(ppi); struct wr_dsport *wrp = WR_DSPOR(ppi);
if (ppi->is_new_state) { if (pp_is_new_state(ppi)) {
wrp->wrStateRetry = WR_STATE_RETRY; wrp->wrStateRetry = WR_STATE_RETRY;
sendmsg = 1; sendmsg = 1;
} else if (pp_timeout_z(ppi, PP_TO_EXT_0)) { } else if (pp_timeout_z(ppi, PP_TO_EXT_0)) {
......
...@@ -19,7 +19,7 @@ int wr_m_lock(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -19,7 +19,7 @@ int wr_m_lock(struct pp_instance *ppi, unsigned char *pkt, int plen)
MsgSignaling wrsig_msg; MsgSignaling wrsig_msg;
struct wr_dsport *wrp = WR_DSPOR(ppi); struct wr_dsport *wrp = WR_DSPOR(ppi);
if (ppi->is_new_state) { if (pp_is_new_state(ppi)) {
wrp->wrStateRetry = WR_STATE_RETRY; wrp->wrStateRetry = WR_STATE_RETRY;
sendmsg = 1; sendmsg = 1;
} else if (pp_timeout_z(ppi, PP_TO_EXT_0)) { } else if (pp_timeout_z(ppi, PP_TO_EXT_0)) {
......
...@@ -23,7 +23,7 @@ int wr_present(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -23,7 +23,7 @@ int wr_present(struct pp_instance *ppi, unsigned char *pkt, int plen)
MsgSignaling wrsig_msg; MsgSignaling wrsig_msg;
if (ppi->is_new_state) { if (pp_is_new_state(ppi)) {
wrp->wrStateRetry = WR_STATE_RETRY; wrp->wrStateRetry = WR_STATE_RETRY;
sendmsg = 1; sendmsg = 1;
} else if (pp_timeout_z(ppi, PP_TO_EXT_0)) { } else if (pp_timeout_z(ppi, PP_TO_EXT_0)) {
......
...@@ -16,7 +16,7 @@ int wr_resp_calib_req(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -16,7 +16,7 @@ int wr_resp_calib_req(struct pp_instance *ppi, unsigned char *pkt, int plen)
int e = 0, enable = 0; int e = 0, enable = 0;
int send_pattern = (wrp->otherNodeCalSendPattern != 0); int send_pattern = (wrp->otherNodeCalSendPattern != 0);
if (ppi->is_new_state) { if (pp_is_new_state(ppi)) {
wrp->wrStateRetry = WR_STATE_RETRY; wrp->wrStateRetry = WR_STATE_RETRY;
enable = 1; enable = 1;
} else if (pp_timeout_z(ppi, PP_TO_EXT_0)) { } else if (pp_timeout_z(ppi, PP_TO_EXT_0)) {
......
...@@ -14,8 +14,8 @@ int wr_s_lock(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -14,8 +14,8 @@ int wr_s_lock(struct pp_instance *ppi, unsigned char *pkt, int plen)
struct wr_dsport *wrp = WR_DSPOR(ppi); struct wr_dsport *wrp = WR_DSPOR(ppi);
int enable = 0; int enable = 0;
if (ppi->is_new_state) { if (pp_is_new_state(ppi)) {
wrp->wrStateRetry = WR_STATE_RETRY; wrp->wrStateRetry = WR_STATE_RETRY;
enable = 1; enable = 1;
} else if (pp_timeout_z(ppi, PP_TO_EXT_0)) { } else if (pp_timeout_z(ppi, PP_TO_EXT_0)) {
wrp->ops->locking_disable(ppi); wrp->ops->locking_disable(ppi);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
int pp_faulty(struct pp_instance *ppi, unsigned char *pkt, int plen) int pp_faulty(struct pp_instance *ppi, unsigned char *pkt, int plen)
{ {
if (ppi->is_new_state) { if (pp_is_new_state(ppi)) {
pp_timeout_set(ppi, PP_TO_FAULTY, 4000); pp_timeout_set(ppi, PP_TO_FAULTY, 4000);
} }
......
...@@ -18,7 +18,7 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -18,7 +18,7 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (e) if (e)
goto out; goto out;
if (ppi->is_new_state) if (pp_is_new_state(ppi))
pp_timeout_restart_annrec(ppi); pp_timeout_restart_annrec(ppi);
if (plen == 0) if (plen == 0)
......
...@@ -15,7 +15,7 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -15,7 +15,7 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
int msgtype, d1, d2; int msgtype, d1, d2;
int e = 0; /* error var, to check errors in msg handling */ int e = 0; /* error var, to check errors in msg handling */
if (ppi->is_new_state) { if (pp_is_new_state(ppi)) {
pp_timeout_rand(ppi, PP_TO_SYNC, DSPOR(ppi)->logSyncInterval); pp_timeout_rand(ppi, PP_TO_SYNC, DSPOR(ppi)->logSyncInterval);
pp_timeout_rand(ppi, PP_TO_ANN_INTERVAL, pp_timeout_rand(ppi, PP_TO_ANN_INTERVAL,
DSPOR(ppi)->logAnnounceInterval); DSPOR(ppi)->logAnnounceInterval);
......
...@@ -13,7 +13,7 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -13,7 +13,7 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
{ {
int e = 0; /* error var, to check errors in msg handling */ int e = 0; /* error var, to check errors in msg handling */
if (ppi->is_new_state) if (pp_is_new_state(ppi))
pp_timeout_restart_annrec(ppi); pp_timeout_restart_annrec(ppi);
if (plen == 0) if (plen == 0)
......
...@@ -16,7 +16,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -16,7 +16,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
MsgDelayResp resp; MsgDelayResp resp;
int d1, d2; int d1, d2;
if (ppi->is_new_state) { if (pp_is_new_state(ppi)) {
pp_servo_init(ppi); pp_servo_init(ppi);
if (pp_hooks.new_slave) if (pp_hooks.new_slave)
......
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