\section{Synchronization functional}
\label{chap:synch-functional}

The purpose of these tests is to verify the basic synchronization capabilities
of the switch.

{\bf Note:} Ports of WR Switch are numbered in tests below starting from 0 as in
configuration files, while ports on a front panel of a switch are numbered
starting from 1.

\paragraph{Hardware requirements}
\vspace{12pt}
\begin{itemize}
  \item WR Switch under test
  \item 3x Simple PCIe FMC Carrier (SPEC) with FMC DIO 5-channel module
  \item 1x 4-channel oscilloscope (e.g. 200MHz, 2GS/s)
  \item 1x non-WR, PTP (IEEE1588-2008) Switch
  \item 1x clock reference producing 10MHz and 1-PPS signal (e.g. GPSDO or
    Cesium atomic clock)
\end{itemize}

\paragraph{Default Switch Configuration}

\begin{table}[ht!]
  \begin{tabular}{l  l l}
    PPSI & port 0:      & slave\\
         & other ports: & master\\ 
  \end{tabular}
\end{table}

\newpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{WR synchronization}

These tests verify the synchronization between White Rabbit devices and the
switch under test.

%\newpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Master and Slave mode}

\paragraph{Description}
The test verifies whether the switch is capable of synchronizing to another WR
Master device and provide synchronization to WR Slave devices.

\paragraph{Test setup}
\vspace{12pt}
\begin{table}[ht!]
  \begin{tabular}{r l l}
    WR Switch: & {\bf port 0}    & -- SPEC running WR PTP Core in \emph{WR Master} mode\\
    WR Switch: & {\bf port 2}    & -- SPEC running WR PTP Core in \emph{WR Slave} mode\\
    WR Switch: & {\bf port 18}   & -- SPEC running WR PTP Core in \emph{WR Slave} mode\\
  Master SPEC: & {\bf 1-PPS out} & -- channel 1 of the oscilloscope\\
    WR Switch: & {\bf 1-PPS out} & -- channel 2 of the oscilloscope\\
  Slave SPECs: & {\bf 1-PPS out} & -- channels 3 and 4 of the oscilloscope\\
  \end{tabular}
\end{table}

\paragraph{Test passed if}

\begin{itemize*}
  \item \emph{wrsw\_pstats} tool on WR Switch reports frames flow on ports 0, 2,
    18
  \item \emph{wr\_mon} tool on WR Switch reports \emph{TRACK\_PHASE} servo state
    and \emph{0 ns} clock offset
  \item \emph{gui} or \emph{stat} command on slave SPECs reports
    \emph{TRACK\_PHASE} servo state and \emph{0 ns} clock offset
  \item Oscilloscope triggered on a rising edge of 1-PPS output of the Master
    SPEC shows stable 1-PPS signals generated by the Switch and 2 Slave SPECs
\end{itemize*}

\newpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{GrandMaster mode}

\paragraph{Description}
The test verifies whether the switch is capable of locking to external 10MHz and
1-PPS from reference clock like GPSDO or Cesium.

\paragraph{Switch Configuration}
\begin{table}[ht!]
  \begin{tabular}{l l}
    \emph{wrsw\_hal.conf} & mode = "GrandMaster"\\
  \end{tabular}
\end{table}

\paragraph{Test setup}
\begin{table}[ht!]
  \begin{tabular}{r l l}
    WR Switch: & {\bf port 2}    & -- SPEC running WR PTP Core in \emph{WR Slave} mode\\
    WR Switch: & {\bf port 18}   & -- SPEC running WR PTP Core in \emph{WR Slave} mode\\
    WR Switch: & {\bf 1-PPS in}  & -- 1-PPS signal from external atomic clock\\
    WR Switch: & {\bf 10 MHz in} & -- 10 MHz signal from external atomic clock\\
    WR Switch: & {\bf 1-PPS out} & -- channel 1 of the oscilloscope\\
  Slave SPECs: & {\bf 1-PPS out} & -- channels 2 and 3 of the oscilloscope\\
  \end{tabular}
\end{table}

\paragraph{Test passed if}
\begin{itemize*}
  \item \emph{lm32-vuart} tool on WR Switch reports that device is locked to
    external clock:\\
    \texttt{Sequencer\_state 8 mode 1 Alignment\_state 7 HL1 EL1 ML0}
  \item \emph{gui} or \emph{stat} command on slave SPECs reports
    \emph{TRACK\_PHASE} servo state and \emph{0 ns} clock offset
  \item Oscilloscope triggered on a rising edge of 1-PPS output of the WR Switch
    shows stable skew between 1-PPS signals generated by the Switch and 2 Slave SPECs
\end{itemize*}

\newpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{IEEE-1588 synchronization}

These tests verify the ability of WR Switch to synchronize also non-WR (regular
IEEE1588-2008) devices.

\subsubsection{Master for non-WR IEEE-1588 device}

\paragraph{Description}

The test verifies if regular IEEE-1588 device is able to synchronize to a WR
Master port of the WR Switch under test.

\paragraph{Test setup}
\begin{table}[ht!]
  \begin{tabular}{r l l}
    WR Switch: & {\bf port 2} & -- non-WR IEEE1588-2008 slave device\\
    WR Switch: & {\bf 1-PPS out} & -- channel 1 of the oscilloscope\\
non-WR device: & {\bf 1-PPS out} & -- channel 2 of the oscilloscope\\
  \end{tabular}
\end{table}

{\bf Note:} If non-WR slave device has only 10/100 Mbps Ethernet port you have
to connect it through 10/100/1000 Mbps Ethernet switch since WR Switch is able
to work only with 1 Gbps Ethernet.\\
You should connect 1-PPS outputs to the oscilloscope only if your non-WR
IEEE1588 device is able to produce 1-PPS signal.

\paragraph{Test passed if}
\begin{itemize*}
  \item non-WR IEEE-1588 device reports it managed to synchronize to WR Switch
  \item Oscilloscope triggered on a rising edge of 1-PPS output of the WR Switch
    shows stable skew between 1-PPS signals generated by the Switch and non-WR
    device.
\end{itemize*}


%\newpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\subsubsection{Slaving to non-WR IEEE-1588 device}
%
%\paragraph{Description}
%
%\paragraph{Test setup}
%
%\paragraph{Test passed if}


\newpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Getting initial time from NTP server}

\paragraph{Description}
The test verifies if WR Switch under test is able to get its initial time on
boot time from an NTP server.

\paragraph{Switch Configuration}
\begin{table}[ht!]
  \begin{tabular}{l l}
    \emph{/wr/etc/wr\_date.conf} & ntpserver $<$your NTP server address$>$\\
  \end{tabular}
\end{table}

\paragraph{Test setup}
\begin{table}[ht!]
  \begin{tabular}{r l l}
    WR Switch: & {\bf port 2} & -- SPEC running WR PTP Core in \emph{WR Slave} mode\\
  \end{tabular}
\end{table}

\paragraph{Test passed if}
\begin{itemize*}
  \item After rebooting the switch and letting Slave SPEC to synchronize,
    \emph{gui} command on SPEC reports date and time consistent with NTP server
    time.
\end{itemize*}
