diff --git a/as_capable.h b/as_capable.h new file mode 100644 index 0000000..fbd77b2 --- /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 ac082bf..c55bd51 100644 --- a/config.c +++ b/config.c @@ -23,6 +23,7 @@ #include #include +#include "as_capable.h" #include "bmc.h" #include "clock.h" #include "config.h" @@ -195,8 +196,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 2ac6eb7..d2b8c8f 100644 --- a/configs/default.cfg +++ b/configs/default.cfg @@ -32,6 +32,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 303310f..cd87553 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 19d1d7b..91e7986 100644 --- a/port_private.h +++ b/port_private.h @@ -21,6 +21,7 @@ #include +#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 d1751df..8e9b9a2 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -686,6 +686,12 @@ Check mode only check but do not set. Full mode set the receive filter to mark all packets with hardware time stamp, so all applications can get them. The default is normal. +.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