Commit 5db97f77 authored by baujc's avatar baujc Committed by Adam Wujek

WRPC optimization of bmc_add_frgn_master()

parent 92439350
...@@ -890,7 +890,7 @@ void bmc_add_frgn_master(struct pp_instance *ppi, void *buf, ...@@ -890,7 +890,7 @@ void bmc_add_frgn_master(struct pp_instance *ppi, void *buf,
pid->clockIdentity.id[6], pid->clockIdentity.id[7], pid->clockIdentity.id[6], pid->clockIdentity.id[7],
pid->portNumber); pid->portNumber);
if (DSDEF(ppi)->numberPorts > 1) { if (!IS_ARCH_WRPC() && DSDEF(ppi)->numberPorts > 1) {
/* Check if announce from the same port from this clock 9.3.2.5 a) /* Check if announce from the same port from this clock 9.3.2.5 a)
* from another port of this clock we still handle even though it * from another port of this clock we still handle even though it
* states something different in IEEE1588 because in 9.5.2.3 * states something different in IEEE1588 because in 9.5.2.3
...@@ -964,48 +964,53 @@ void bmc_add_frgn_master(struct pp_instance *ppi, void *buf, ...@@ -964,48 +964,53 @@ void bmc_add_frgn_master(struct pp_instance *ppi, void *buf,
frgn_master.foreignMasterAnnounceMessages[i] = 1; frgn_master.foreignMasterAnnounceMessages[i] = 1;
/* New foreign master */ /* New foreign master */
if (ppi->frgn_rec_num < PP_NR_FOREIGN_RECORDS) { if ( PP_NR_FOREIGN_RECORDS > 1 ) {
/* there is space for a new one */ if (ppi->frgn_rec_num < PP_NR_FOREIGN_RECORDS) {
sel = ppi->frgn_rec_num; /* there is space for a new one */
ppi->frgn_rec_num++; sel = ppi->frgn_rec_num;
ppi->frgn_rec_num++;
} else { } else {
/* find the worst to replace */ /* find the worst to replace */
for (i = 1, worst = 0; i < ppi->frgn_rec_num; i++) { for (i = 1, worst = 0; i < ppi->frgn_rec_num; i++) {
/* qualify them for this check */ /* qualify them for this check */
memcpy(&temp_frgn_master, &ppi->frgn_master[i], memcpy(&temp_frgn_master, &ppi->frgn_master[i],
sizeof(temp_frgn_master)); sizeof(temp_frgn_master));
memcpy(&worst_frgn_master, &ppi->frgn_master[worst],
sizeof(worst_frgn_master));
for (j = 0; j < PP_FOREIGN_MASTER_TIME_WINDOW; j++) {
temp_frgn_master.foreignMasterAnnounceMessages[j] = 1;
worst_frgn_master.foreignMasterAnnounceMessages[j] = 1;
}
if (bmc_dataset_cmp(ppi, &temp_frgn_master,
&worst_frgn_master) > 0)
worst = i;
}
/* copy the worst again and qualify it */
memcpy(&worst_frgn_master, &ppi->frgn_master[worst], memcpy(&worst_frgn_master, &ppi->frgn_master[worst],
sizeof(worst_frgn_master)); sizeof(worst_frgn_master));
for (j = 0; j < PP_FOREIGN_MASTER_TIME_WINDOW; j++) { for (i = 0; i < PP_FOREIGN_MASTER_TIME_WINDOW; i++) {
temp_frgn_master.foreignMasterAnnounceMessages[j] = 1; worst_frgn_master.foreignMasterAnnounceMessages[i] = 1;
worst_frgn_master.foreignMasterAnnounceMessages[j] = 1;
} }
if (bmc_dataset_cmp(ppi, &temp_frgn_master, /* check if worst is better than the new one, and skip the new
&worst_frgn_master) > 0) * one if so */
worst = i; if (bmc_dataset_cmp(ppi, &worst_frgn_master, &frgn_master)
} < 0) {
pp_diag(ppi, bmc, 1, "%s:%i: New foreign "
"master worse than worst in the full "
"table, skipping\n",
__func__, __LINE__);
return;
}
/* copy the worst again and qualify it */ sel = worst;
memcpy(&worst_frgn_master, &ppi->frgn_master[worst],
sizeof(worst_frgn_master));
for (i = 0; i < PP_FOREIGN_MASTER_TIME_WINDOW; i++) {
worst_frgn_master.foreignMasterAnnounceMessages[i] = 1;
}
/* check if worst is better than the new one, and skip the new
* one if so */
if (bmc_dataset_cmp(ppi, &worst_frgn_master, &frgn_master)
< 0) {
pp_diag(ppi, bmc, 1, "%s:%i: New foreign "
"master worse than worst in the full "
"table, skipping\n",
__func__, __LINE__);
return;
} }
} else {
sel = worst; sel = 0;
ppi->frgn_rec_num=1;
} }
/* clear qualification timeouts */ /* clear qualification timeouts */
......
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