// Module included in the following assemblies:
//
// * networking/ptp/ptp-cloud-events-consumer-dev-reference-v2.adoc
// * networking/ptp/ptp-cloud-events-consumer-dev-reference.adoc

:_mod-docs-content-type: PROCEDURE
[id="cnf-configuring-the-ptp-fast-event-publisher-{ptp-events-rest-api}_{context}"]
= Configuring the PTP fast event notifications publisher

To start using PTP fast event notifications for a network interface in your cluster, you must enable the fast event publisher in the PTP Operator `PtpOperatorConfig` custom resource (CR) and configure `ptpClockThreshold` values in a `PtpConfig` CR that you create.

.Prerequisites

* You have installed the {product-title} CLI (`oc`).

* You have logged in as a user with `cluster-admin` privileges.

* You have installed the PTP Operator.

.Procedure

. Modify the default PTP Operator config to enable PTP fast events.

.. Save the following YAML in the `ptp-operatorconfig.yaml` file:
+
ifeval::["{ptp-events-rest-api}" == "v1"]
include::snippets/ptp-event-config-api-v1.adoc[]
endif::[]
ifeval::["{ptp-events-rest-api}" == "v2"]
include::snippets/ptp-event-config-api-v2.adoc[]
endif::[]

.. Update the `PtpOperatorConfig` CR:
+
[source,terminal]
----
$ oc apply -f ptp-operatorconfig.yaml
----

. Create a `PtpConfig` custom resource (CR) for the PTP enabled interface, and set the required values for `ptpClockThreshold` and `ptp4lOpts`.
The following YAML illustrates the required values that you must set in the `PtpConfig` CR:
+
[source,yaml]
----
spec:
  profile:
  - name: "profile1"
    interface: "enp5s0f0"
    ptp4lOpts: "-2 -s --summary_interval -4" <1>
    phc2sysOpts: "-a -r -m -n 24 -N 8 -R 16" <2>
    ptp4lConf: "" <3>
    ptpClockThreshold: <4>
      holdOverTimeout: 5
      maxOffsetThreshold: 100
      minOffsetThreshold: -100
----
<1> Append `--summary_interval -4` to use PTP fast events.
<2> Required `phc2sysOpts` values. `-m` prints messages to `stdout`. The `linuxptp-daemon` `DaemonSet` parses the logs and generates Prometheus metrics.
<3> Specify a string that contains the configuration to replace the default `/etc/ptp4l.conf` file. To use the default configuration, leave the field empty.
<4> Optional. If the `ptpClockThreshold` stanza is not present, default values are used for the `ptpClockThreshold` fields. The stanza shows default `ptpClockThreshold` values. The `ptpClockThreshold` values configure how long after the PTP master clock is disconnected before PTP events are triggered. `holdOverTimeout` is the time value in seconds before the PTP clock event state changes to `FREERUN` when the PTP master clock is disconnected. The `maxOffsetThreshold` and `minOffsetThreshold` settings configure offset values in nanoseconds that compare against the values for `CLOCK_REALTIME` (`phc2sys`) or master offset (`ptp4l`). When the `ptp4l` or `phc2sys` offset value is outside this range, the PTP clock state is set to `FREERUN`. When the offset value is within this range, the PTP clock state is set to `LOCKED`.
