// Module included in the following assemblies:
//
// * networking/ptp/configuring-ptp.adoc

:_mod-docs-content-type: PROCEDURE
[id="configuring-linuxptp-services-as-grandmaster-clock-dual-nic_{context}"]
= Configuring linuxptp services as a grandmaster clock for 2 E810 NICs

[role="_abstract"]
You can configure the `linuxptp` services (`ptp4l`, `phc2sys`, `ts2phc`) as a grandmaster clock (T-GM) for 2 E810 NICs by creating a `PtpConfig` custom resource (CR) that configures the NICs.

You can configure the `linuxptp` services as a T-GM for the following E810 NICs:

* Intel E810-XXVDA4T Westport Channel NIC
* Intel E810-CQDA2T Logan Beach NIC

For distributed RAN (D-RAN) use cases, you can configure PTP for 2 NICs as follows:

* NIC 1 is synced to the global navigation satellite system (GNSS) time source.
* NIC 2 is synced to the 1PPS timing output provided by NIC one. This configuration is provided by the PTP hardware plugin in the `PtpConfig` CR.

The 2-card PTP T-GM configuration uses one instance of `ptp4l` and one instance of `ts2phc`.
The `ptp4l` and `ts2phc` programs are each configured to operate on two PTP hardware clocks (PHCs), one for each NIC.
The host system clock is synchronized from the NIC that is connected to the GNSS time source.

[NOTE]
--
Use the following example `PtpConfig` CR as the basis to configure `linuxptp` services as T-GM for dual Intel E810 network interfaces.

To configure PTP fast events, set appropriate values for `ptp4lOpts`, `ptp4lConf`, and `ptpClockThreshold`.
`ptpClockThreshold` is used only when events are enabled.
See "Configuring the PTP fast event notifications publisher" for more information.
--

.Prerequisites

* For T-GM clocks in production environments, install two Intel E810 NICs in the bare-metal cluster host.

* Install the OpenShift CLI (`oc`).

* Log in as a user with `cluster-admin` privileges.

* Install the PTP Operator.

.Procedure

. Create the `PtpConfig` CR. For example:

.. Save the following YAML in the `grandmaster-clock-ptp-config-dual-nics.yaml` file:
+
[source,yaml]
----
include::snippets/ptp_PtpConfigDualCardGmWpc.yaml[]
----
+
[NOTE]
--
Set the value for `ts2phc.nmea_serialport` to `/dev/gnss0`.
--

.. Create the CR by running the following command:
+
[source,terminal]
----
$ oc create -f grandmaster-clock-ptp-config-dual-nics.yaml
----

.Verification

. Check that the `PtpConfig` profile is applied to the node.

.. Get the list of pods in the `openshift-ptp` namespace by running the following command:
+
[source,terminal]
----
$ oc get pods -n openshift-ptp -o wide
----
+
.Example output
[source,terminal]
----
NAME                          READY   STATUS    RESTARTS   AGE     IP             NODE
linuxptp-daemon-74m2g         3/3     Running   3          4d15h   10.16.230.7    compute-1.example.com
ptp-operator-5f4f48d7c-x7zkf  1/1     Running   1          4d15h   10.128.1.145   compute-1.example.com
----

.. Check that the profile is correct. Examine the logs of the `linuxptp` daemon that corresponds to the node you specified in the `PtpConfig` profile.
Run the following command:
+
[source,terminal]
----
$ oc logs linuxptp-daemon-74m2g -n openshift-ptp -c linuxptp-daemon-container
----
+
.Example output
[source,terminal]
----
ts2phc[509863.660]: [ts2phc.0.config] nmea delay: 347527248 ns
ts2phc[509863.660]: [ts2phc.0.config] ens2f0 extts index 0 at 1705516553.000000000 corr 0 src 1705516553.652499081 diff 0
ts2phc[509863.660]: [ts2phc.0.config] ens2f0 master offset          0 s2 freq      -0
I0117 18:35:16.000146 1633226 stats.go:57] state updated for ts2phc =s2
I0117 18:35:16.000163 1633226 event.go:417] dpll State s2, gnss State s2, tsphc state s2, gm state s2,
ts2phc[1705516516]:[ts2phc.0.config] ens2f0 nmea_status 1 offset 0 s2
GM[1705516516]:[ts2phc.0.config] ens2f0 T-GM-STATUS s2
ts2phc[509863.677]: [ts2phc.0.config] ens7f0 extts index 0 at 1705516553.000000010 corr -10 src 1705516553.652499081 diff 0
ts2phc[509863.677]: [ts2phc.0.config] ens7f0 master offset          0 s2 freq      -0
I0117 18:35:16.016597 1633226 stats.go:57] state updated for ts2phc =s2
phc2sys[509863.719]: [ptp4l.0.config] CLOCK_REALTIME phc offset        -6 s2 freq  +15441 delay    510
phc2sys[509863.782]: [ptp4l.0.config] CLOCK_REALTIME phc offset        -7 s2 freq  +15438 delay    502
----
