clockdemo consists of the following files:
File |
Contains |
---|---|
clockdemo.c |
Main source code. |
clockdemo.exe |
Compiled executable. |
clockresource.c |
Auxiliary functions invoked by functions in clockdemo to manage timing reference information such as, trunks. |
clockresource.h |
Defines for clockresource.c. |
priority.txt |
Sample clocking priority list file. |
clockdemo performs three main tasks:
Monitors for clocking changes (for example, trunk signal failures).
Determines what to do when there is a change.
Reconfigures clocking on the boards.
When a change to a timing reference or board requires changes to the clocking configuration, clockdemo determines the minimum number of steps to take to rectify the situation, to avoid reconfiguring boards unnecessarily.
The code for each of clockdemo's tasks is encapsulated in the main section of the program. The loop is triggered at regular intervals (regulated by the timeout set using the -t option on the command line). It is also triggered whenever an NMS OAM board started or board stopped event is received. The main section contains the following functions:
Function |
Description |
---|---|
Polls all boards and returns the board status results in an array. | |
Determines an action to take (if necessary) for each board based upon the status results. | |
Reconfigures affected boards based upon the determined action. |
The following illustration shows clockdemo main functions:
The main section of the program does the following:
Step |
Action |
1 |
Initializes variables and parses the command line options. |
2 |
Invokes _initData_file to read and parse the configuration file. |
3 |
Attempts to open the switch for each listed board (by invoking swiOpenSwitch), and builds an array of switch handles (swihd_array[]). |
4 |
Based on the information from the configuration file, determines the primary and fallback timing references for the primary master, and the fallback timing reference for the secondary master. |
5 |
Builds an array (h110_parms[]) containing the new configuration for each affected board. |
6 |
Configures the primary and secondary master by invoking swiConfigBoardClock with h110_parms[]. |
7 |
Registers to receive NMS OAM events. |
8 |
Invokes swiGetBoardClock for each board to determine its clocking status, and stores the results in an array (h110_query_parms[]). |
9 |
Invokes _printClockStatus to print the initial clocking status to the screen. |
10 |
Enters the while loop described in the previous illustration. |
11 |
Updates the screen based on clocking changes. |
12 |
Shuts down if the Q key is pressed. |
_clock_monitor is called at regular intervals by the while loop in the main section. Its purpose is to determine whether a clocking change has occurred by monitoring the clocking status of each board and the status of each trunk involved in clocking. It returns an integer indicating one or more of six possible states. This information is used by the _clock_control function to determine whether to perform any clocking reconfiguration.
_clock_monitor is passed the following information:
Parameter |
Description |
---|---|
num_of_boards |
Number of boards in the chassis |
swihd_array[] |
Array containing the handles of all boards opened in the main section of the program. |
_clock_monitor returns the following information:
Parameter |
Description |
---|---|
clock_status |
Integer indicating the type of clocking change (if any):
|
h110_query_parms[] |
Updated array containing the clocking status information for each board. This information consists of the following:
|
(Managed in clockresource.c) |
A global structure containing the updated status of each trunk on each board. |
_clock_monitor does the following:
Step |
Action |
1 |
Checks each board in swihd_array[] to determine whether it exists. |
2 |
Polls the status of each existing board using swiGetBoardClock. This updates h110_query_parms[] for the board. |
3 |
If more than 50 percent of the boards report that A_CLOCK failed, includes CLKSYS_STATUS_A_FAIL in the returned clock_status. |
4 |
If more than 50 percent of the boards report that B_CLOCK failed, includes CLKSYS_STATUS_B_FAIL in the returned clock_status. |
5 |
If fallback is reported by a board, includes CLKSYS_STATUS_FALLBACK_OCCURRED in the returned clock_status. |
6 |
If fallback is reported by a board, but there is no clock failure, includes CLKSYS_STATUS_INCONSISTENT in the returned clock_status. |
7 |
If one of the trunks designated as a fallback source has failed, includes CLKSYS_STATUS_REFERENCE_CHANGED in the returned clock_status. |
8 |
Updates the global structure containing the updated status of each trunk on each board. |
_clock_control is called at regular intervals by the while loop in the main section, directly after _clock_monitor returns. It uses the information returned by _clock_monitor to determine if any action is necessary to reconfigure the clocks. It returns an action code describing the action to be taken (if any).
_clock_control is passed the following information:
Parameter |
Description |
---|---|
clock_status |
Code returned by _clock_monitor describing the status of the system clocks and timing references. |
h110_parms[] |
The previous set of clocking settings made to each board by clockdemo. |
h110_query_parms[] |
Array containing the clocking status information for each board, updated by _clock_monitor. |
num_of_boards |
Number of boards in the system. |
_clock_control returns the following information:
Parameter |
Description |
---|---|
action |
Integer describing one or more actions to take (if any):
|
h110_parms[] |
An updated set of clock settings to make to one or more boards. |
_clock_control does the following:
Step |
Action |
1 |
Calls _find_master. This function examines h110_parms[] and returns indices to the boards in the array configured as primary and secondary master. _find_master also determines which clock (A_CLOCK or B_CLOCK) is being used as the primary system clock. |
2 |
If the primary clock (A_CLOCK or B_CLOCK) has failed:
|
3 |
If the primary clock (A_CLOCK or B_CLOCK) is functional, but the secondary clock (B_CLOCK or A_CLOCK) failed:
|
4 |
If CLKSYS_STATUS_INCONSISTENT was returned by _clock_monitor:
|
5 |
If CLKSYS_STATUS_REFERENCE_CHANGED was returned by _clock_monitor:
|
_clock_reconfigure is called at regular intervals by the while loop in the main section. It is called directly after _clock_control returns, unless action is CLKSYS_ACTION_NONE. It reconfigures one or more of the boards in the system based upon the action returned by _clock_control.
_clock_reconfigure is passed the following information:
Parameter |
Description |
---|---|
action |
Action code returned by _clock_control. |
h110_parms[] |
Array updated by _clock_control describing the new configuration to set. |
swihd_array[] |
Array of switch handles. |
num_of_boards |
Number of boards in the system. |
h110_query_parms[] |
Array updated by _clock_monitor containing the current configuration as reported by swiGetBoardClock. |
_clock_reconfigure does the following:
Step |
Action |
1 |
If action is CLKSYS_ACTION_RELOAD:
|
2 |
If action is CLKSYS_ACTION_NEW_PRIMARY and the board number of the primary master has changed:
|
3 |
If action is CLKSYS_ACTION_NEW_PRIMARY and the board number of the primary master has NOT changed:
|
4 |
If action is CLKSYS_ACTION_NEW_SECONDARY:
|
5 |
If action is CLKSYS_ACTION_RELOAD_PRIMARY_FALLBACK:
|