Commit b7862cd7 authored by Alessandro Rubini's avatar Alessandro Rubini

bugfix: foreign masters must be an array

All archs allocated one foreign master, but the default was 5 and
the command line could even change it.  Hardwire the number to 5
and skip the allocation by folding the array in pp_instance itself.

Anyways, the add_foreign() function needs serious review, later on.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 419d9679
......@@ -42,7 +42,6 @@ int main(int argc, char **argv)
ppi->portDS = calloc(1, sizeof(*ppi->portDS));
ppi->timePropertiesDS = calloc(1, sizeof(*ppi->timePropertiesDS));
ppi->servo = calloc(1, sizeof(*ppi->servo));
ppi->frgn_master = calloc(1, sizeof(*ppi->frgn_master));
ppi->arch_data = calloc(1, sizeof(struct posix_arch_data));
ppi->n_ops = &posix_net_ops;
......
......@@ -36,7 +36,7 @@
* 802.1AS. We use the
* same value as in ptpdv1
*/
#define PP_DEFAULT_MAX_FOREIGN_RECORDS 5
#define PP_NR_FOREIGN_RECORDS 5
#define PP_DEFAULT_PARENTS_STATS 0
#define PP_DEFAULT_MAX_RESET 0
#define PP_DEFAULT_MAX_DELAY 0
......
......@@ -33,7 +33,6 @@ struct pp_runtime_opts {
no_rst_clk:1;
Integer16 ap, ai;
Integer16 s;
Integer16 max_foreign_records;
Integer8 announce_intvl;
Integer8 sync_intvl;
UInteger8 prio1;
......@@ -167,7 +166,7 @@ struct pp_instance {
Integer16 foreign_record_i;
Integer16 foreign_record_best;
Boolean record_update;
struct pp_frgn_master *frgn_master;
struct pp_frgn_master frgn_master[PP_NR_FOREIGN_RECORDS];
TimeInternal sync_receive_time;
UInteger16 recv_sync_sequence_id;
......
......@@ -30,7 +30,6 @@ static DSParent parentDS;
static DSPort portDS;
static DSTimeProperties timePropertiesDS;
static struct pp_servo servo;
static struct pp_frgn_master frgn_master;
int ppsi_main(int argc, char **argv)
{
......@@ -44,7 +43,6 @@ int ppsi_main(int argc, char **argv)
ppi->portDS = &portDS;
ppi->timePropertiesDS = &timePropertiesDS;
ppi->servo = &servo;
ppi->frgn_master = &frgn_master;
ppi->arch_data = NULL;
ppi->n_ops = &bare_net_ops;
ppi->t_ops = &bare_time_ops;
......
......@@ -41,7 +41,6 @@ static struct cmd_line_opt cmd_line_list[] = {
CMD_LINE_SEPARATOR,
{"-n NUMBER", "specify announce interval in 2^NUMBER sec"},
{"-y NUMBER", "specify sync interval in 2^NUMBER sec"},
{"-m NUMBER", "specify max number of foreign master records"},
CMD_LINE_SEPARATOR,
{"-g", "run as slave only"},
{"-v NUMBER", "specify system clock allen variance"},
......@@ -170,12 +169,6 @@ int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv)
if (OPTS(ppi)->announce_intvl > 4)
OPTS(ppi)->announce_intvl = 4;
break;
case 'm':
a = argv[++i];
OPTS(ppi)->max_foreign_records = atoi(a);
if (OPTS(ppi)->max_foreign_records < 1)
OPTS(ppi)->max_foreign_records = 1;
break;
case 'g':
OPTS(ppi)->slave_only = 1;
break;
......
......@@ -125,10 +125,8 @@ static void st_com_add_foreign(struct pp_instance *ppi, unsigned char *buf)
return;
/* New foreign master */
if (ppi->number_foreign_records <
OPTS(ppi)->max_foreign_records) {
if (ppi->number_foreign_records < PP_NR_FOREIGN_RECORDS)
ppi->number_foreign_records++;
}
j = ppi->foreign_record_i;
......@@ -151,7 +149,7 @@ static void st_com_add_foreign(struct pp_instance *ppi, unsigned char *buf)
PP_VPRINTF("New foreign Master added\n");
ppi->foreign_record_i = (ppi->foreign_record_i+1) %
OPTS(ppi)->max_foreign_records;
PP_NR_FOREIGN_RECORDS;
}
......
......@@ -28,7 +28,6 @@ struct pp_runtime_opts default_rt_opts = {
.s = PP_DEFAULT_DELAY_S,
.ethernet_mode = PP_DEFAULT_ETHERNET_MODE,
.ofst_first_updated = 0, /* FIXME: is it a option or a state var? */
.max_foreign_records = PP_DEFAULT_MAX_FOREIGN_RECORDS,
.announce_intvl = PP_DEFAULT_ANNOUNCE_INTERVAL,
.sync_intvl = PP_DEFAULT_SYNC_INTERVAL,
.prio1 = PP_DEFAULT_PRIORITY1,
......
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