Skip to content
Snippets Groups Projects
Commit 8b6982bd authored by Sven Meier's avatar Sven Meier Committed by Adam Wujek
Browse files

hal: added reset process to restart locking

This allows that a previous locked switch can restart the locking asas a master
on the same port
parent 91b25888
Branches
Tags
No related merge requests found
......@@ -26,6 +26,7 @@
#define HEXP_LOCK_CMD_START 1
#define HEXP_LOCK_CMD_CHECK 2
#define HEXP_LOCK_CMD_ENABLE_TRACKING 3
#define HEXP_LOCK_CMD_RESET 4
#define HEXP_LOCK_STATUS_LOCKED 0
#define HEXP_LOCK_STATUS_BUSY 1
......
......@@ -65,6 +65,10 @@ int halexp_lock_cmd(const char *port_name, int command, int priority)
else
return HEXP_LOCK_STATUS_NONE;
break;
case HEXP_LOCK_CMD_RESET:
return hal_port_reset(port_name);
}
return -100; /* fixme: add real error code */
......
......@@ -760,6 +760,39 @@ int hal_port_check_lock(const char *port_name)
(hs->flags & RTS_REF_LOCKED));
}
int hal_port_reset(const char *port_name)
{
struct hal_port_state *p = hal_lookup_port(ports,
hal_port_nports, port_name);
if (!p)
return -1;
if (p->state != HAL_PORT_STATE_LINK_DOWN
&& p->state != HAL_PORT_STATE_DISABLED) {
if (p->locked) {
pr_info("Switching RTS to use local reference\n");
if (hal_get_timing_mode()
!= HAL_TIMING_MODE_GRAND_MASTER)
rts_set_mode(RTS_MODE_GM_FREERUNNING);
}
/* turn off synced LED */
set_led_synced(p->hw_index, 0);
/* turn off link/wrmode LEDs */
set_led_wrmode(p->hw_index, SFP_LED_WRMODE_OFF);
p->state = HAL_PORT_STATE_LINK_DOWN;
hal_port_reset_state(p);
rts_enable_ptracker(p->hw_index, 0);
pr_info("%s: link down\n", p->name);
return 1;
}
return 0;
}
/* to avoid i2c transfers to set the link LEDs, cache their state */
static void set_led_wrmode(int p_index, int val)
{
......
......@@ -27,9 +27,10 @@ int hal_update_wripc(int ms_timeout);
int hal_add_cleanup_callback(hal_cleanup_callback_t cb);
int hal_port_start_lock(const char *port_name, int priority);
int hal_port_check_lock(const char *port_name);
int hal_port_enable_tracking(const char *port_name);
int hal_port_start_lock(const char *port_name, int priority);
int hal_port_check_lock(const char *port_name);
int hal_port_reset(const char *port_name);
int hal_port_enable_tracking(const char *port_name);
int hal_init_timing_mode(void);
int hal_init_timing(char *filename);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment