Commit 493dee1e authored by Alessandro Rubini's avatar Alessandro Rubini

general: fix sent_seq_id in ppi structure

The structure was separately allocated with a size of 16.  This avoids
the alloc and makes the array the right size from the enum of message
types. We thus a remove a number of magic "16" in the code.
wrpc-sw must be updated too, in order to use this commit.

There's still a problem: the code claims the number to be "last sent",
but actually the value is incremented after sending. I'll need to pass
again on this thing.

ps: I changed name from "sent_seq_id" to "sent_seq" to the compiler
complains for previous users, otherwise undetectable.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent f42935ff
...@@ -25,7 +25,6 @@ static struct pp_net_path net_path_static; ...@@ -25,7 +25,6 @@ static struct pp_net_path net_path_static;
CONST_VERBOSITY int pp_diag_verbosity = 0; CONST_VERBOSITY int pp_diag_verbosity = 0;
/* ppi fields */ /* ppi fields */
static UInteger16 sent_seq_id[16];
static DSDefault defaultDS; static DSDefault defaultDS;
static DSCurrent currentDS; static DSCurrent currentDS;
static DSParent parentDS; static DSParent parentDS;
...@@ -41,7 +40,6 @@ int ppsi_main(int argc, char **argv) ...@@ -41,7 +40,6 @@ int ppsi_main(int argc, char **argv)
PP_PRINTF("bare: starting. Compiled on %s\n", __DATE__); PP_PRINTF("bare: starting. Compiled on %s\n", __DATE__);
ppi->net_path = &net_path_static; ppi->net_path = &net_path_static;
ppi->sent_seq_id = sent_seq_id;
ppi->defaultDS = &defaultDS; ppi->defaultDS = &defaultDS;
ppi->currentDS = &currentDS; ppi->currentDS = &currentDS;
ppi->parentDS = &parentDS; ppi->parentDS = &parentDS;
......
...@@ -25,7 +25,6 @@ static struct pp_net_path net_path_static; ...@@ -25,7 +25,6 @@ static struct pp_net_path net_path_static;
CONST_VERBOSITY int pp_diag_verbosity = 0; CONST_VERBOSITY int pp_diag_verbosity = 0;
/* ppi fields */ /* ppi fields */
static UInteger16 sent_seq_id[16];
static DSDefault defaultDS; static DSDefault defaultDS;
static DSCurrent currentDS; static DSCurrent currentDS;
static DSParent parentDS; static DSParent parentDS;
...@@ -41,7 +40,6 @@ int ppsi_main(int argc, char **argv) ...@@ -41,7 +40,6 @@ int ppsi_main(int argc, char **argv)
PP_PRINTF("bare: starting. Compiled on %s\n", __DATE__); PP_PRINTF("bare: starting. Compiled on %s\n", __DATE__);
ppi->net_path = &net_path_static; ppi->net_path = &net_path_static;
ppi->sent_seq_id = sent_seq_id;
ppi->defaultDS = &defaultDS; ppi->defaultDS = &defaultDS;
ppi->currentDS = &currentDS; ppi->currentDS = &currentDS;
ppi->parentDS = &parentDS; ppi->parentDS = &parentDS;
......
...@@ -36,7 +36,6 @@ int main(int argc, char **argv) ...@@ -36,7 +36,6 @@ int main(int argc, char **argv)
if (!ppi) if (!ppi)
exit(__LINE__); exit(__LINE__);
ppi->sent_seq_id = calloc(16, sizeof(*ppi->sent_seq_id));
ppi->defaultDS = calloc(1, sizeof(*ppi->defaultDS)); ppi->defaultDS = calloc(1, sizeof(*ppi->defaultDS));
ppi->currentDS = calloc(1, sizeof(*ppi->currentDS)); ppi->currentDS = calloc(1, sizeof(*ppi->currentDS));
ppi->parentDS = calloc(1, sizeof(*ppi->parentDS)); ppi->parentDS = calloc(1, sizeof(*ppi->parentDS));
...@@ -48,7 +47,7 @@ int main(int argc, char **argv) ...@@ -48,7 +47,7 @@ int main(int argc, char **argv)
ppi->arch_data = calloc(1, sizeof(struct posix_arch_data)); ppi->arch_data = calloc(1, sizeof(struct posix_arch_data));
if ((!ppi->defaultDS) || (!ppi->currentDS) || (!ppi->parentDS) if ((!ppi->defaultDS) || (!ppi->currentDS) || (!ppi->parentDS)
|| (!ppi->portDS) || (!ppi->timePropertiesDS) || (!ppi->sent_seq_id) || (!ppi->portDS) || (!ppi->timePropertiesDS)
|| (!ppi->net_path) || (!ppi->frgn_master) || (!ppi->arch_data) || (!ppi->net_path) || (!ppi->frgn_master) || (!ppi->arch_data)
) )
exit(__LINE__); exit(__LINE__);
......
...@@ -304,6 +304,7 @@ enum pp_std_messages { ...@@ -304,6 +304,7 @@ enum pp_std_messages {
PPM_ANNOUNCE, PPM_ANNOUNCE,
PPM_SIGNALING, PPM_SIGNALING,
PPM_MANAGEMENT, PPM_MANAGEMENT,
__PP_NR_MESSAGES_TYPES,
PPM_NOTHING_TO_DO = 0x100, /* for hooks.master_msg() */ PPM_NOTHING_TO_DO = 0x100, /* for hooks.master_msg() */
}; };
......
...@@ -179,9 +179,7 @@ struct pp_instance { ...@@ -179,9 +179,7 @@ struct pp_instance {
MsgDelayResp resp; MsgDelayResp resp;
MsgAnnounce announce; MsgAnnounce announce;
} msg_tmp; } msg_tmp;
UInteger16 *sent_seq_id; /* sequence id of the last message sent of the UInteger16 sent_seq[__PP_NR_MESSAGES_TYPES]; /* last sent this type */
* same type
*/
MsgHeader msg_tmp_header; MsgHeader msg_tmp_header;
MsgHeader delay_req_hdr; MsgHeader delay_req_hdr;
UInteger32 UInteger32
......
...@@ -53,7 +53,7 @@ static inline int __send_and_log(struct pp_instance *ppi, int msglen, ...@@ -53,7 +53,7 @@ static inline int __send_and_log(struct pp_instance *ppi, int msglen,
ppi->last_snt_time.seconds, ppi->last_snt_time.seconds,
ppi->last_snt_time.nanoseconds, ppi->last_snt_time.nanoseconds,
pp_msg_names[msgtype]); pp_msg_names[msgtype]);
ppi->sent_seq_id[msgtype]++; /* FIXME: fold in the send method too? */ ppi->sent_seq[msgtype]++; /* FIXME: fold in the send method too? */
return 0; return 0;
} }
......
...@@ -173,7 +173,7 @@ void msg_pack_sync(struct pp_instance *ppi, Timestamp *orig_tstamp) ...@@ -173,7 +173,7 @@ void msg_pack_sync(struct pp_instance *ppi, Timestamp *orig_tstamp)
/* Table 19 */ /* Table 19 */
*(UInteger16 *) (buf + 2) = htons(PP_SYNC_LENGTH); *(UInteger16 *) (buf + 2) = htons(PP_SYNC_LENGTH);
*(UInteger16 *) (buf + 30) = htons(ppi->sent_seq_id[PPM_SYNC]); *(UInteger16 *) (buf + 30) = htons(ppi->sent_seq[PPM_SYNC]);
*(UInteger8 *) (buf + 32) = 0x00; *(UInteger8 *) (buf + 32) = 0x00;
/* Table 23 */ /* Table 23 */
...@@ -215,7 +215,7 @@ int msg_pack_announce(struct pp_instance *ppi) ...@@ -215,7 +215,7 @@ int msg_pack_announce(struct pp_instance *ppi)
*(char *)(buf + 0) = *(char *)(buf + 0) | 0x0B; *(char *)(buf + 0) = *(char *)(buf + 0) | 0x0B;
/* Table 19 */ /* Table 19 */
*(UInteger16 *) (buf + 2) = htons(PP_ANNOUNCE_LENGTH); *(UInteger16 *) (buf + 2) = htons(PP_ANNOUNCE_LENGTH);
*(UInteger16 *) (buf + 30) = htons(ppi->sent_seq_id[PPM_ANNOUNCE]); *(UInteger16 *) (buf + 30) = htons(ppi->sent_seq[PPM_ANNOUNCE]);
*(UInteger8 *) (buf + 32) = 0x05; *(UInteger8 *) (buf + 32) = 0x05;
/* Table 23 */ /* Table 23 */
*(Integer8 *) (buf + 33) = DSPOR(ppi)->logAnnounceInterval; *(Integer8 *) (buf + 33) = DSPOR(ppi)->logAnnounceInterval;
...@@ -281,7 +281,7 @@ void msg_pack_follow_up(struct pp_instance *ppi, Timestamp *prec_orig_tstamp) ...@@ -281,7 +281,7 @@ void msg_pack_follow_up(struct pp_instance *ppi, Timestamp *prec_orig_tstamp)
/* Table 19 */ /* Table 19 */
*(UInteger16 *) (buf + 2) = htons(PP_FOLLOW_UP_LENGTH); *(UInteger16 *) (buf + 2) = htons(PP_FOLLOW_UP_LENGTH);
*(UInteger16 *) (buf + 30) = htons(ppi->sent_seq_id[PPM_SYNC] - 1); *(UInteger16 *) (buf + 30) = htons(ppi->sent_seq[PPM_SYNC] - 1);
/* sentSyncSequenceId has already been incremented in msg_issue_sync */ /* sentSyncSequenceId has already been incremented in msg_issue_sync */
*(UInteger8 *) (buf + 32) = 0x02; *(UInteger8 *) (buf + 32) = 0x02;
...@@ -330,7 +330,7 @@ void msg_pack_delay_req(struct pp_instance *ppi, Timestamp *orig_tstamp) ...@@ -330,7 +330,7 @@ void msg_pack_delay_req(struct pp_instance *ppi, Timestamp *orig_tstamp)
/* Table 19 */ /* Table 19 */
*(UInteger16 *) (buf + 2) = htons(PP_DELAY_REQ_LENGTH); *(UInteger16 *) (buf + 2) = htons(PP_DELAY_REQ_LENGTH);
*(UInteger16 *) (buf + 30) = htons(ppi->sent_seq_id[PPM_DELAY_REQ]); *(UInteger16 *) (buf + 30) = htons(ppi->sent_seq[PPM_DELAY_REQ]);
*(UInteger8 *) (buf + 32) = 0x01; *(UInteger8 *) (buf + 32) = 0x01;
/* Table 23 */ /* Table 23 */
......
...@@ -67,7 +67,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -67,7 +67,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
if ((memcmp(DSPOR(ppi)->portIdentity.clockIdentity, if ((memcmp(DSPOR(ppi)->portIdentity.clockIdentity,
ppi->msg_tmp.resp.requestingPortIdentity.clockIdentity, ppi->msg_tmp.resp.requestingPortIdentity.clockIdentity,
PP_CLOCK_IDENTITY_LENGTH) == 0) && PP_CLOCK_IDENTITY_LENGTH) == 0) &&
((ppi->sent_seq_id[PPM_DELAY_REQ] - 1) == ((ppi->sent_seq[PPM_DELAY_REQ] - 1) ==
hdr->sequenceId) && hdr->sequenceId) &&
(DSPOR(ppi)->portIdentity.portNumber == (DSPOR(ppi)->portIdentity.portNumber ==
ppi->msg_tmp.resp.requestingPortIdentity.portNumber) ppi->msg_tmp.resp.requestingPortIdentity.portNumber)
......
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