If set to 'true', this unconditionally sets the asCapable variable. The usual checks will be applied to asCapable if it is set to 'auto'. The default value is 'auto'.
This config option is needed by the Automotive Profile. The master will be able to send out Sync Message as soon as the daemon is started. Signed-off-by: Vedang Patel <vedang.pa...@intel.com> --- as_capable.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ config.c | 8 ++++++++ configs/default.cfg | 1 + port.c | 17 +++++++++++++---- port_private.h | 3 ++- ptp4l.8 | 6 ++++++ 6 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 as_capable.h diff --git a/as_capable.h b/as_capable.h new file mode 100644 index 000000000000..fbd77b22e9ea --- /dev/null +++ b/as_capable.h @@ -0,0 +1,45 @@ +/** + * @file as_capable.h + * @brief Enumerates the states for asCapable. + * @note Copyright (C) 2018 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef HAVE_AS_CAPABLE_H +#define HAVE_AS_CAPABLE_H + +/* Enum used by the asCapable config option. */ +enum as_capable_option { + AS_CAPABLE_TRUE, + AS_CAPABLE_AUTO, +}; + +/* + * Defines whether the device can interoperate with the device on other end via + * IEEE 802.1AS protocol. + * + * More information about this in Section 10.2.4.1 of IEEE 802.1AS standard. + */ +enum as_capable { + NOT_CAPABLE, + AS_CAPABLE, + /* + * Non-standard extension to support Automotive Profile. asCapable + * always set to true without checking the system at other end. + */ + ALWAYS_CAPABLE, +}; + +#endif diff --git a/config.c b/config.c index 7914ba4b5166..f4db05273f05 100644 --- a/config.c +++ b/config.c @@ -23,6 +23,7 @@ #include <stdlib.h> #include <string.h> +#include "as_capable.h" #include "bmc.h" #include "clock.h" #include "config.h" @@ -188,8 +189,15 @@ static struct config_enum tsproc_enu[] = { { NULL, 0 }, }; +static struct config_enum as_capable_enu[] = { + { "true", AS_CAPABLE_TRUE }, + { "auto", AS_CAPABLE_AUTO }, + { NULL, 0 }, +}; + struct config_item config_tab[] = { PORT_ITEM_INT("announceReceiptTimeout", 3, 2, UINT8_MAX), + PORT_ITEM_ENU("asCapable", AS_CAPABLE_AUTO, as_capable_enu), GLOB_ITEM_INT("assume_two_step", 0, 0, 1), PORT_ITEM_INT("boundary_clock_jbod", 0, 0, 1), GLOB_ITEM_INT("check_fup_sync", 0, 0, 1), diff --git a/configs/default.cfg b/configs/default.cfg index c5a8b57c9314..e9a62e73bc0d 100644 --- a/configs/default.cfg +++ b/configs/default.cfg @@ -31,6 +31,7 @@ fault_reset_interval 4 neighborPropDelayThresh 20000000 masterOnly 0 G.8275.portDS.localPriority 128 +asCapable auto # # Run time options # diff --git a/port.c b/port.c index 1a0e910a1151..aabbf7d83677 100644 --- a/port.c +++ b/port.c @@ -644,15 +644,16 @@ static int port_capable(struct port *p) } capable: - if (!p->asCapable) + if (p->asCapable == NOT_CAPABLE) { pr_debug("port %hu: setting asCapable", portnum(p)); - p->asCapable = 1; + p->asCapable = AS_CAPABLE; + } return 1; not_capable: if (p->asCapable) port_nrate_initialize(p); - p->asCapable = 0; + p->asCapable = NOT_CAPABLE; return 0; } @@ -742,6 +743,9 @@ static int port_sync_incapable(struct port *p) static int port_is_ieee8021as(struct port *p) { + if (p->asCapable == ALWAYS_CAPABLE) { + return 0; + } return p->follow_up_info ? 1 : 0; } @@ -1021,7 +1025,6 @@ static void port_nrate_initialize(struct port *p) /* We start in the 'incapable' state. */ p->pdr_missing = ALLOWED_LOST_RESPONSES + 1; - p->asCapable = 0; p->peer_portid_valid = 0; @@ -1600,6 +1603,12 @@ int port_initialize(struct port *p) p->neighborPropDelayThresh = config_get_int(cfg, p->name, "neighborPropDelayThresh"); p->min_neighbor_prop_delay = config_get_int(cfg, p->name, "min_neighbor_prop_delay"); + if (config_get_int(cfg, p->name, "asCapable") == AS_CAPABLE_TRUE) { + p->asCapable = ALWAYS_CAPABLE; + } else { + p->asCapable = NOT_CAPABLE; + } + for (i = 0; i < N_TIMER_FDS; i++) { fd[i] = -1; } diff --git a/port_private.h b/port_private.h index 19d1d7beaae8..91e79867bf38 100644 --- a/port_private.h +++ b/port_private.h @@ -21,6 +21,7 @@ #include <sys/queue.h> +#include "as_capable.h" #include "clock.h" #include "fsm.h" #include "msg.h" @@ -100,7 +101,7 @@ struct port { struct PortIdentity portIdentity; enum port_state state; /*portState*/ Integer64 asymmetry; - int asCapable; + enum as_capable asCapable; Integer8 logMinDelayReqInterval; TimeInterval peerMeanPathDelay; Integer8 logAnnounceInterval; diff --git a/ptp4l.8 b/ptp4l.8 index 10c5c2f967cb..e840e748fb42 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -661,6 +661,12 @@ The time source is a single byte code that gives an idea of the kind of local clock in use. The value is purely informational, having no effect on the outcome of the Best Master Clock algorithm, and is advertised when the clock becomes grand master. +.TP +.B asCapable +If set to 'true', all the checks which can unset asCapable variable (as +described in Section 10.2.4.1 of 802.1AS) are skipped. If set to 'auto', +asCapable is initialized to 'false' and will be set to 'true' after the +relevant checks have passed. The default value is 'auto'. .SH UNICAST DISCOVERY OPTIONS -- 2.7.3 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel