From: Arkadiusz Kubalewski <arkadiusz.kubalew...@intel.com> Extend interface struct, allow to keep information about SyncE parent device.
Add helper function (util.c) to acquire Do Not Use - Quality Level value. Co-developed-by: Anatolii Gerasymenko <anatolii.gerasyme...@intel.com> Signed-off-by: Anatolii Gerasymenko <anatolii.gerasyme...@intel.com> Co-developed-by: Michal Michalik <michal.micha...@intel.com> Signed-off-by: Michal Michalik <michal.micha...@intel.com> Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalew...@intel.com> --- v4: changed order of patch in patch-series v3: rebase patch series v2: updated license headers interface.c | 29 +++++++++++++++++++++++++++-- interface.h | 24 ++++++++++++++++++++++++ util.c | 22 ++++++++++++++++++++++ util.h | 8 ++++++++ 4 files changed, 81 insertions(+), 2 deletions(-) diff --git a/interface.c b/interface.c index 445a270..6fc11bf 100644 --- a/interface.c +++ b/interface.c @@ -7,11 +7,19 @@ #include <stdlib.h> #include "interface.h" +#define SYNCE_PARENT_EXIST (1 << 0) + struct interface { STAILQ_ENTRY(interface) list; char name[MAX_IFNAME_SIZE + 1]; - char ts_label[MAX_IFNAME_SIZE + 1]; - struct sk_ts_info ts_info; + union { + char ts_label[MAX_IFNAME_SIZE + 1]; + char synce_parent_label[MAX_IFNAME_SIZE + 1]; + }; + union { + struct sk_ts_info ts_info; + int synce_flags; + }; int vclock; }; @@ -88,3 +96,20 @@ int interface_get_vclock(struct interface *iface) { return iface->vclock; } + +void interface_se_set_parent_dev(struct interface *iface, const char *dev_name) +{ + strncpy(iface->synce_parent_label, dev_name, MAX_IFNAME_SIZE); + iface->synce_flags |= SYNCE_PARENT_EXIST; +} + +const char *interface_se_get_parent_dev_label(struct interface *iface) +{ + return iface->synce_parent_label; +} + +bool interface_se_has_parent_dev(struct interface *iface) +{ + return !!(iface->synce_flags & SYNCE_PARENT_EXIST); +} + diff --git a/interface.h b/interface.h index 752f4f1..47cc25f 100644 --- a/interface.h +++ b/interface.h @@ -105,4 +105,28 @@ void interface_set_vclock(struct interface *iface, int vclock); */ int interface_get_vclock(struct interface *iface); +/** + * Set the synce parent device for a given interface. + * @param iface The interface of interest. + * @param dev_name The desired label for the interface. + */ +void interface_se_set_parent_dev(struct interface *iface, const char *dev_name); + +/** + * Obtain the name of the parent synce device to which an interface belongs. + * The parent device must provde an interface to control device-level synce + * configuration. + * @param iface The interface of interest. + * @return Name of the parent synce device + */ +const char *interface_se_get_parent_dev_label(struct interface *iface); + +/** + * Tests whether an interface has a synce parent device. + * Which means it is regular port configured for synce. + * @param iface The interface of interest. + * @return True if the interface is a synce parent device + */ +bool interface_se_has_parent_dev(struct interface *iface); + #endif diff --git a/util.c b/util.c index a59b559..1c04870 100644 --- a/util.c +++ b/util.c @@ -30,6 +30,7 @@ #include "print.h" #include "sk.h" #include "util.h" +#include "synce_msg.h" #define NS_PER_SEC 1000000000LL #define NS_PER_HOUR (3600 * NS_PER_SEC) @@ -779,3 +780,24 @@ int rate_limited(int interval, time_t *last) return 0; } + +uint8_t synce_get_dnu_value(int network_option, int extended_tlv) +{ + uint8_t ret = O1N_QL_DNU_ENHSSM; + + if (extended_tlv) { + if (network_option == SYNCE_NETWORK_OPT_1) { + ret = O1N_QL_DNU_ENHSSM; + } else if (network_option == SYNCE_NETWORK_OPT_2) { + ret = O2N_QL_DUS_ENHSSM; + } + } else { + if (network_option == SYNCE_NETWORK_OPT_1) { + ret = O1N_QL_DNU_SSM; + } else if (network_option == SYNCE_NETWORK_OPT_2) { + ret = O2N_QL_DUS_SSM; + } + } + + return ret; +} diff --git a/util.h b/util.h index 558a675..c52dc2e 100644 --- a/util.h +++ b/util.h @@ -458,4 +458,12 @@ void parray_extend(void ***a, ...); */ int rate_limited(int interval, time_t *last); +/** + * Acquire proper SynceE Do Not Use signal value basing on given arguments + * + * @param network_option Type of the network + * @param extended_tlv If QL for extended tlv + * @return Do Not Use signal value + */ +uint8_t synce_get_dnu_value(int netwotk_option, int extended_tlv); #endif -- 2.9.5 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel