From 15221022527942382a9fc7974288599c13d25870 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Wed, 5 May 2021 05:32:38 +0000 Subject: [PATCH 01/28] [sonic_y_cable] add abstract class YCableBase required for Y-cable API support for multiple vendors Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 577 ++++++++++++++++++++++++++++++++++ 1 file changed, 577 insertions(+) create mode 100644 sonic_y_cable/y_cable_base.py diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py new file mode 100644 index 000000000..d039fbffd --- /dev/null +++ b/sonic_y_cable/y_cable_base.py @@ -0,0 +1,577 @@ +""" + y_cable_base.py + + Base class for implementing Y-Cable specific functionality in SONiC. + This is the base class of sonic_y_cable implentation. A vendor specific + implementation of YCable needs to inherit from this class. + Classes derived from this class provide the ability to interact + with a vendor specific Y-Cable +""" + + +class YCableBase(object): + + # definitions of targets for getting the cursor + # equalization parameters from the register spec + # the name of the target denotes which side cursor + # values will be retreived + + TARGET_NIC = 0 + TARGET_TOR1 = 1 + TARGET_TOR2 = 2 + + # definitions of targets for getting the EYE/BER + # and initiating PRBS/Loopback on the Y cable + # the name of the target denotes which side values + # will be retreived/initiated + + EYE_PRBS_TARGET_LOCAL = 0 + EYE_PRBS_TARGET_TOR1 = 1 + EYE_PRBS_TARGET_TOR2 = 2 + EYE_PRBS_TARGET_NIC = 3 + + # definitions of switch counter types + # to be entered by the user in get_switch_count api + # for retreiving the counter values + + SWITCH_COUNT_MANUAL = "manual" + SWITCH_COUNT_AUTO = "auto" + + # switching modes inside muxcable + SWITCHING_MODE_MANUAL = 0 + SWITCHING_MODE_AUTO = 1 + + # Valid return codes for upgrade firmware routine steps + FIRMWARE_DOWNLOAD_SUCCESS = 0 + FIRMWARE_DOWNLOAD_FAILURE = 1 + FIRMWARE_ACTIVATE_SUCCESS = 0 + FIRMWARE_ACTIVATE_FAILURE = 1 + FIRMWARE_ROLLBACK_SUCCESS = 0 + FIRMWARE_ROLLBACK_FAILURE = 1 + + def __init__(self, port): + self.port = port + + def toggle_mux_to_torA(self, port): + """ + This API specifically does a hard switch toggle of the Y cable's MUX regardless of link state to + TOR A. This means if the Y cable is actively routing, the "check_active_linked_tor_side" + API will now return Tor A. It also implies that if the link is actively routing on this port, Y cable + MUX will start forwarding packets from TOR A to NIC, and drop packets from TOR B to NIC + regardless of previous forwarding state. + + Args: + port: + an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX + + Returns: + a Boolean, true if the toggle succeeded and false if it did not succeed. + """ + + raise NotImplementedError + + def toggle_mux_to_torB(self, port): + """ + This API specifically does a hard switch toggle of the Y cable's MUX regardless of link state to + TOR B. This means if the Y cable is actively routing, the "check_active_linked_tor_side" + API will now return Tor B. It also implies that if the link is actively routing on this port, Y cable + MUX will start forwarding packets from TOR B to NIC, and drop packets from TOR A to NIC + regardless of previous forwarding state. + + Args: + port: + an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX + + Returns: + a Boolean, true if the toggle succeeded and false if it did not succeed. + """ + raise NotImplementedError + + def check_read_side(self, port): + """ + This API specifically checks which side of the Y cable the reads are actually getting performed + from, either TOR A or TOR B or NIC and returns the value. + + Args: + port: + an Integer, the actual physical port connected to Y end of a Y cable which can which side reading the MUX from + + Returns: + an Integer, 1 if reading the Y cable from TOR A side(TOR 1). + , 2 if reading the Y cable from TOR B side(TOR 2). + , 0 if reading the Y cable from NIC side. + , -1 if reading the Y cable API fails. + """ + + raise NotImplementedError + + def check_mux_direction(self, port): + """ + This API specifically checks which side of the Y cable mux is currently point to + and returns either TOR A or TOR B. Note that this API should return mux-direction + regardless of whether the link is active/routing state or not. + + Args: + port: + an Integer, the actual physical port connected to a Y cable + + Returns: + an Integer, 1 if the mux is pointing to TOR A . + , 2 if the mux is pointing to TOR B. + , -1 if checking which side mux is pointing to API fails. + """ + + raise NotImplementedError + + def check_active_linked_tor_side(self, port): + """ + This API specifically checks which side of the Y cable is actively linked and routing + and returns either TOR A or TOR B. + + Args: + port: + an Integer, the actual physical port connected to a Y cable + + Returns: + an Integer, 1 if TOR A is actively linked and routing(TOR 1). + , 2 if TOR B is actively linked and routing(TOR 2). + , 0 if nothing linked and actively routing + , -1 if checking which side linked for routing API fails. + """ + + raise NotImplementedError + + def check_if_link_is_active_for_NIC(self, port): + """ + This API specifically checks if NIC side of the Y cable's link is active + + Args: + port: + an Integer, the actual physical port connected to a Y cable + + Returns: + a boolean, true if the link is active + , false if the link is not active + """ + + raise NotImplementedError + + def check_if_link_is_active_for_torA(self, port): + """ + This API specifically checks if tor A side of the Y cable's link is active + + Args: + port: + an Integer, the actual physical port connected to a Y cable + + Returns: + a boolean, true if the link is active + , false if the link is not active + """ + + raise NotImplementedError + + def check_if_link_is_active_for_torB(self, port): + """ + This API specifically checks if tor B side of the Y cable's link is active + + Args: + port: + an Integer, the actual physical port connected to a Y cable + + Returns: + a boolean, true if the link is active + , false if the link is not active + """ + + raise NotImplementedError + + def get_eye_info(self, port): + """ + This API specifically returns the EYE height value for a specfic port. + The target could be local side, TOR1, TOR2, NIC etc. + + Args: + physical_port: + an Integer, the actual physical port connected to a Y cable + target: + an Integer, the target on which to enable the PRBS + EYE_PRBS_TARGET_LOCAL -> local side, + EYE_PRBS_TARGET_TOR1 -> TOR 1 + EYE_PRBS_TARGET_TOR2 -> TOR 2 + EYE_PRBS_TARGET_NIC -> NIC + Returns: + a list, with EYE values of lane 0 lane 1 lane 2 lane 3 with corresponding index + """ + + raise NotImplementedError + + def get_ber_info(self, port): + """ + This API specifically returns the BER (Bit error rate) value for a specfic port. + The target could be local side, TOR1, TOR2, NIC etc. + + Args: + physical_port: + an Integer, the actual physical port connected to a Y cable + target: + an Integer, the target on which to enable the PRBS + EYE_PRBS_TARGET_LOCAL -> local side, + EYE_PRBS_TARGET_TOR1 -> TOR 1 + EYE_PRBS_TARGET_TOR2 -> TOR 2 + EYE_PRBS_TARGET_NIC -> NIC + Returns: + a list, with BER values of lane 0 lane 1 lane 2 lane 3 with corresponding index + """ + + raise NotImplementedError + + def get_vendor(self, port): + """ + This API specifically returns the vendor name of the Y cable for a specfic port. + + Args: + physical_port: + an Integer, the actual physical port connected to a Y cable + Returns: + a string, with vendor name + """ + + raise NotImplementedError + + def get_part_number(self, port): + """ + This API specifically returns the part number of the Y cable for a specfic port. + + Args: + physical_port: + an Integer, the actual physical port connected to a Y cable + Returns: + a string, with part number + """ + + raise NotImplementedError + + def get_switch_count(self, port, count_type): + """ + This API specifically returns the switch count to change the Active TOR which has + been done manually by the user. + + Args: + physical_port: + an Integer, the actual physical port connected to a Y cable + count_type: + a string, for getting the count type + "manual" -> manual switch count + "auto" -> automatic switch count + Returns: + an integer, the number of times manually the Y-cable has been switched + """ + + raise NotImplementedError + + def get_target_cursor_values(self, port, lane, target): + """ + This API specifically returns the cursor equalization parameters for a target(NIC, TOR1, TOR2). + This includes pre one, pre two , main, post one, post two cursor values + + Args: + physical_port: + an Integer, the actual physical port connected to a Y cable + lane: + an Integer, the lane on which to collect the cursor values + 1 -> lane 1, + 2 -> lane 2 + 3 -> lane 3 + 4 -> lane 4 + target: + an Integer, the actual target to get the cursor values on + TARGET_NIC -> NIC, + TARGET_TOR1-> TOR1, + TARGET_TOR2 -> TOR2 + Returns: + a list, with pre one, pre two , main, post one, post two cursor values in the order + """ + + raise NotImplementedError + + def get_firmware_version(self, port, target): + """ This routine should return the active, inactive and next (committed) + firmware running on the target. Each of the version values in this context + could be a string with a major and minor number and a build value. + + Args: + physical_port: + an Integer, the actual physical port connected to a Y cable + target: + an Integer, the actual target to get the cursor values on + TARGET_NIC -> NIC, + TARGET_TOR1-> TOR1, + TARGET_TOR2 -> TOR2 + Returns: + a Dictionary: + with version_active, version_inactive and version_next keys + and their corresponding values + + """ + + raise NotImplementedError + + def download_firmware(self, port, fwfile): + """ This routine should download and store the firmware on all the + components of the Y cable of the port specified. + This should include any internal transfers, checksum validation etc. + from TOR to TOR or TOR to NIC side of the firmware specified by the fwfile. + This basically means that the firmware which is being downloaded should be + available to be activated (start being utilized by the cable) once this API is + successfully executed. + Note that this API should ideally not require any rollback even if it fails + as this should not interfere with the existing cable functionality because + this has not been activated yet. + + Args: + physical_port: + an Integer, the actual physical port connected to a Y cable + fwfile: + a string, a path to the file which contains the firmware image. + Note that the firmware file can be in the format of the vendor's + choosing (binary, archive, etc.). But note that it should be one file + which contains firmware for all components of the Y-cable + Returns: + an Integer: + a predefined code stating whether the firmware download was successful + or an error code as to what was the cause of firmware download failure + """ + + raise NotImplementedError + + def activate_firmware(self, port, fwfile): + """ This routine should activate the downloaded firmware on all the + components of the Y cable of the port specified. + This API is meant to be used in conjunction with download_firmware API, and + should be called once download_firmware API is succesful. + This means that the firmware which has been downloaded should be + activated (start being utilized by the cable) once this API is + successfully executed. + + Args: + physical_port: + an Integer, the actual physical port connected to a Y cable + Returns: + an Integer: + a predefined code stating whether the firmware activate was successful + """ + + raise NotImplementedError + + def rollback_firmware(self, port): + """ This routine should rollback the firmware to the previous version + which was being used by the cable. This API is intended to be called when the + user either witnesses an activate_firmware API failure or sees issues with + newer firmware in regards to stable cable functioning. + + Args: + physical_port: + an Integer, the actual physical port connected to a Y cable + Returns: + an Integer: + a predefined code stating whether the firmware rollback was successful + or an error code as to what was the cause of firmware rollback failure + """ + + raise NotImplementedError + + def set_switching_mode(self, port, mode): + """ + This API specifically enables the auto switching or manual switching feature on the muxcable, + depending upon the mode entered by the user. + Autoswitch feature if enabled actually does an automatic toggle of the mux in case the active + side link goes down and basically points the mux to the other side. + + Args: + physical_port: + an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX + mode: + an Integer, specifies which type of switching mode we set the muxcable to + either SWITCHING_MODE_AUTO or SWITCHING_MODE_MANUAL + + Returns: + a Boolean, true if the switch succeeded and false if it did not succeed. + """ + + raise NotImplementedError + + def get_switching_mode(self, port): + """ + This API specifically returns which type of switching mode the cable is set to auto/manual + + Args: + physical_port: + an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX + + Returns: + an Integer, SWITCHING_MODE_AUTO if auto switch is enabled. + SWITCHING_MODE_MANUAL if manual switch is enabled. + """ + + raise NotImplementedError + + def get_nic_temperature(self, port): + """ + This API specifically returns nic temperature of the physical port specified + + Args: + physical_port: + an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX + + Returns: + an Integer, the temperature of the NIC MCU + """ + + raise NotImplementedError + + def get_local_temperature(self, port): + """ + This API specifically returns local ToR temperature of the physical port specified + + Args: + physical_port: + an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX + + Returns: + an Integer, the temperature of the local MCU + """ + + raise NotImplementedError + + def get_nic_voltage(self, port): + """ + This API specifically returns nic voltage of the physical port specified + + Args: + physical_port: + an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX + + Returns: + a float, the voltage of the NIC MCU + """ + + raise NotImplementedError + + def get_local_voltage(self, port): + """ + This API specifically returns local ToR voltage of the physical port specified + + Args: + physical_port: + an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX + + Returns: + a float, the voltage of the local MCU + """ + + raise NotImplementedError + + def enable_prbs_mode(self, port, target, mode_value, lane_map): + """ + This API specifically configures and enables the PRBS mode/type depending upon the mode_value the user provides. + The mode_value configures the PRBS Type for generation and BER sensing on a per side basis. + Target is an integer for selecting which end of the Y cable we want to run PRBS on. + LaneMap specifies the lane configuration to run the PRBS on. + Note that this is a diagnostic mode command and must not run during normal traffic/switch operation + + Args: + physical_port: + an Integer, the actual physical port connected to a Y cable + target: + an Integer, the target on which to enable the PRBS + EYE_PRBS_TARGET_LOCAL -> local side, + EYE_PRBS_TARGET_TOR1 -> TOR 1 + EYE_PRBS_TARGET_TOR2 -> TOR 2 + EYE_PRBS_TARGET_NIC -> NIC + mode_value: + an Integer, the mode/type for configuring the PRBS mode. + + lane_map: + an Integer, representing the lane_map to be run PRBS on + 0bit for lane 0, 1bit for lane1 and so on. + for example 3 -> 0b'0011 , means running on lane0 and lane1 + + Returns: + a boolean, true if the enable is successful + , false if the enable failed + + """ + + raise NotImplementedError + + def disable_prbs_mode(self, port, target): + """ + This API specifically disables the PRBS mode on the physical port. + + Args: + physical_port: + an Integer, the actual physical port connected to a Y cable + target: + an Integer, the target on which to enable the PRBS + EYE_PRBS_TARGET_LOCAL -> local side, + EYE_PRBS_TARGET_TOR1 -> TOR 1 + EYE_PRBS_TARGET_TOR2 -> TOR 2 + EYE_PRBS_TARGET_NIC -> NIC + + Returns: + a boolean, true if the disable is successful + , false if the disable failed + """ + + raise NotImplementedError + + def enable_loopback_mode(self, port, target, lane_map): + """ + This API specifically configures and enables the Loopback mode on the port user provides. + Target is an integer for selecting which end of the Y cable we want to run loopback on. + LaneMap specifies the lane configuration to run the loopback on. + Note that this is a diagnostic mode command and must not run during normal traffic/switch operation + + Args: + physical_port: + an Integer, the actual physical port connected to a Y cable + target: + an Integer, the target on which to enable the PRBS + EYE_PRBS_TARGET_LOCAL -> local side, + EYE_PRBS_TARGET_TOR1 -> TOR 1 + EYE_PRBS_TARGET_TOR2 -> TOR 2 + EYE_PRBS_TARGET_NIC -> NIC + lane_map: + an Integer, representing the lane_map to be run PRBS on + 0bit for lane 0, 1bit for lane1 and so on. + for example 3 -> 0b'0011 , means running on lane0 and lane1 + + Returns: + a boolean, true if the enable is successful + , false if the enable failed + """ + + raise NotImplementedError + + def disable_loopback_mode(self, port, target): + """ + This API specifically disables the Loopback mode on the port user provides. + Target is an integer for selecting which end of the Y cable we want to run loopback on. + + Args: + physical_port: + an Integer, the actual physical port connected to a Y cable + target: + an Integer, the target on which to enable the PRBS + EYE_PRBS_TARGET_LOCAL -> local side, + EYE_PRBS_TARGET_TOR1 -> TOR 1 + EYE_PRBS_TARGET_TOR2 -> TOR 2 + EYE_PRBS_TARGET_NIC -> NIC + + Returns: + a boolean, true if the disable is successful + , false if the disable failed + """ + + raise NotImplementedError From 5bab0212eb588767fbcfcd8ea4eec08e05c579da Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Thu, 6 May 2021 05:01:44 +0000 Subject: [PATCH 02/28] fix comments Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 178 ++++++++++++++++++---------------- 1 file changed, 93 insertions(+), 85 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index d039fbffd..32845066c 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -17,8 +17,9 @@ class YCableBase(object): # values will be retreived TARGET_NIC = 0 - TARGET_TOR1 = 1 - TARGET_TOR2 = 2 + TARGET_TORA = 1 + TARGET_TORB = 2 + TARGET_UNKNOWN = -1 # definitions of targets for getting the EYE/BER # and initiating PRBS/Loopback on the Y cable @@ -26,8 +27,8 @@ class YCableBase(object): # will be retreived/initiated EYE_PRBS_TARGET_LOCAL = 0 - EYE_PRBS_TARGET_TOR1 = 1 - EYE_PRBS_TARGET_TOR2 = 2 + EYE_PRBS_TARGET_TORA = 1 + EYE_PRBS_TARGET_TORB = 2 EYE_PRBS_TARGET_NIC = 3 # definitions of switch counter types @@ -65,7 +66,7 @@ def toggle_mux_to_torA(self, port): an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: - a Boolean, true if the toggle succeeded and false if it did not succeed. + a Boolean, True if the toggle succeeded and False if it did not succeed. """ raise NotImplementedError @@ -83,7 +84,7 @@ def toggle_mux_to_torB(self, port): an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: - a Boolean, true if the toggle succeeded and false if it did not succeed. + a Boolean, True if the toggle succeeded and False if it did not succeed. """ raise NotImplementedError @@ -97,10 +98,11 @@ def check_read_side(self, port): an Integer, the actual physical port connected to Y end of a Y cable which can which side reading the MUX from Returns: - an Integer, 1 if reading the Y cable from TOR A side(TOR 1). - , 2 if reading the Y cable from TOR B side(TOR 2). - , 0 if reading the Y cable from NIC side. - , -1 if reading the Y cable API fails. + One of the following predefined constants: + TARGET_TORA, if reading the Y cable from TOR A side(TOR A). + TARGET_TORB, if reading the Y cable from TOR B side(TOR B). + TARGET_NIC, if reading the Y cable from NIC side. + TARGET_UNKNOWN, if reading the Y cable API fails. """ raise NotImplementedError @@ -116,9 +118,10 @@ def check_mux_direction(self, port): an Integer, the actual physical port connected to a Y cable Returns: - an Integer, 1 if the mux is pointing to TOR A . - , 2 if the mux is pointing to TOR B. - , -1 if checking which side mux is pointing to API fails. + One of the following predefined constants: + TARGET_TORA, if mux is pointing to TOR A side(TOR A). + TARGET_TORB, if mux is pointing to TOR B side(TOR B). + TARGET_UNKNOWN, if mux direction API fails. """ raise NotImplementedError @@ -133,10 +136,10 @@ def check_active_linked_tor_side(self, port): an Integer, the actual physical port connected to a Y cable Returns: - an Integer, 1 if TOR A is actively linked and routing(TOR 1). - , 2 if TOR B is actively linked and routing(TOR 2). - , 0 if nothing linked and actively routing - , -1 if checking which side linked for routing API fails. + One of the following predefined constants: + TARGET_TORA, if TOR A is actively linked and routing(TOR A). + TARGET_TORB, if TOR B is actively linked and routing(TOR B). + TARGET_UNKNOWN, if checking which side linked for routing API fails. """ raise NotImplementedError @@ -150,8 +153,8 @@ def check_if_link_is_active_for_NIC(self, port): an Integer, the actual physical port connected to a Y cable Returns: - a boolean, true if the link is active - , false if the link is not active + a boolean, True if the link is active + , False if the link is not active """ raise NotImplementedError @@ -165,8 +168,8 @@ def check_if_link_is_active_for_torA(self, port): an Integer, the actual physical port connected to a Y cable Returns: - a boolean, true if the link is active - , false if the link is not active + a boolean, True if the link is active + , False if the link is not active """ raise NotImplementedError @@ -180,8 +183,8 @@ def check_if_link_is_active_for_torB(self, port): an Integer, the actual physical port connected to a Y cable Returns: - a boolean, true if the link is active - , false if the link is not active + a boolean, True if the link is active + , False if the link is not active """ raise NotImplementedError @@ -189,17 +192,17 @@ def check_if_link_is_active_for_torB(self, port): def get_eye_info(self, port): """ This API specifically returns the EYE height value for a specfic port. - The target could be local side, TOR1, TOR2, NIC etc. + The target could be local side, TORA, TORB, NIC etc. Args: physical_port: an Integer, the actual physical port connected to a Y cable target: - an Integer, the target on which to enable the PRBS - EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TOR1 -> TOR 1 - EYE_PRBS_TARGET_TOR2 -> TOR 2 - EYE_PRBS_TARGET_NIC -> NIC + One of the following predefined constant, the target on which to get the eye: + EYE_PRBS_TARGET_LOCAL -> local side, + EYE_PRBS_TARGET_TORA -> TOR A + EYE_PRBS_TARGET_TORB -> TOR B + EYE_PRBS_TARGET_NIC -> NIC Returns: a list, with EYE values of lane 0 lane 1 lane 2 lane 3 with corresponding index """ @@ -209,17 +212,17 @@ def get_eye_info(self, port): def get_ber_info(self, port): """ This API specifically returns the BER (Bit error rate) value for a specfic port. - The target could be local side, TOR1, TOR2, NIC etc. + The target could be local side, TORA, TORB, NIC etc. Args: physical_port: an Integer, the actual physical port connected to a Y cable target: - an Integer, the target on which to enable the PRBS - EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TOR1 -> TOR 1 - EYE_PRBS_TARGET_TOR2 -> TOR 2 - EYE_PRBS_TARGET_NIC -> NIC + One of the following predefined constant, the target on which to get the ber: + EYE_PRBS_TARGET_LOCAL -> local side, + EYE_PRBS_TARGET_TORA -> TOR A + EYE_PRBS_TARGET_TORB -> TOR B + EYE_PRBS_TARGET_NIC -> NIC Returns: a list, with BER values of lane 0 lane 1 lane 2 lane 3 with corresponding index """ @@ -262,8 +265,8 @@ def get_switch_count(self, port, count_type): an Integer, the actual physical port connected to a Y cable count_type: a string, for getting the count type - "manual" -> manual switch count - "auto" -> automatic switch count + SWITCH_COUNT_MANUAL -> manual switch count + SWITCH_COUNT_MANUAL -> automatic switch count Returns: an integer, the number of times manually the Y-cable has been switched """ @@ -272,7 +275,7 @@ def get_switch_count(self, port, count_type): def get_target_cursor_values(self, port, lane, target): """ - This API specifically returns the cursor equalization parameters for a target(NIC, TOR1, TOR2). + This API specifically returns the cursor equalization parameters for a target(NIC, TORA, TORB). This includes pre one, pre two , main, post one, post two cursor values Args: @@ -285,10 +288,10 @@ def get_target_cursor_values(self, port, lane, target): 3 -> lane 3 4 -> lane 4 target: - an Integer, the actual target to get the cursor values on - TARGET_NIC -> NIC, - TARGET_TOR1-> TOR1, - TARGET_TOR2 -> TOR2 + One of the following predefined constant, the actual target to get the cursor values on: + TARGET_NIC -> NIC, + TARGET_TORA-> TOR1, + TARGET_TORB -> TOR2 Returns: a list, with pre one, pre two , main, post one, post two cursor values in the order """ @@ -304,10 +307,10 @@ def get_firmware_version(self, port, target): physical_port: an Integer, the actual physical port connected to a Y cable target: - an Integer, the actual target to get the cursor values on - TARGET_NIC -> NIC, - TARGET_TOR1-> TOR1, - TARGET_TOR2 -> TOR2 + One of the following predefined constant, the actual target to get the firmware version on: + TARGET_NIC -> NIC, + TARGET_TORA-> TOR1, + TARGET_TORB -> TOR2 Returns: a Dictionary: with version_active, version_inactive and version_next keys @@ -338,9 +341,12 @@ def download_firmware(self, port, fwfile): choosing (binary, archive, etc.). But note that it should be one file which contains firmware for all components of the Y-cable Returns: - an Integer: - a predefined code stating whether the firmware download was successful - or an error code as to what was the cause of firmware download failure + One of the following predefined constant: + FIRMWARE_DOWNLOAD_SUCCESS + FIRMWARE_DOWNLOAD_FAILURE + + a predefined code stating whether the firmware download was successful + or an error code as to what was the cause of firmware download failure """ raise NotImplementedError @@ -358,8 +364,9 @@ def activate_firmware(self, port, fwfile): physical_port: an Integer, the actual physical port connected to a Y cable Returns: - an Integer: - a predefined code stating whether the firmware activate was successful + One of the following predefined constant: + FIRMWARE_ACTIVATE_SUCCESS + FIRMWARE_ACTIVATE_FAILURE """ raise NotImplementedError @@ -374,9 +381,9 @@ def rollback_firmware(self, port): physical_port: an Integer, the actual physical port connected to a Y cable Returns: - an Integer: - a predefined code stating whether the firmware rollback was successful - or an error code as to what was the cause of firmware rollback failure + One of the following predefined constant: + FIRMWARE_ROLLBACK_SUCCESS + FIRMWARE_ROLLBACK_FAILURE """ raise NotImplementedError @@ -396,7 +403,7 @@ def set_switching_mode(self, port, mode): either SWITCHING_MODE_AUTO or SWITCHING_MODE_MANUAL Returns: - a Boolean, true if the switch succeeded and false if it did not succeed. + a Boolean, True if the switch succeeded and False if it did not succeed. """ raise NotImplementedError @@ -410,8 +417,9 @@ def get_switching_mode(self, port): an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: - an Integer, SWITCHING_MODE_AUTO if auto switch is enabled. - SWITCHING_MODE_MANUAL if manual switch is enabled. + One of the following predefined constants: + SWITCHING_MODE_AUTO if auto switch is enabled. + SWITCHING_MODE_MANUAL if manual switch is enabled. """ raise NotImplementedError @@ -484,11 +492,11 @@ def enable_prbs_mode(self, port, target, mode_value, lane_map): physical_port: an Integer, the actual physical port connected to a Y cable target: - an Integer, the target on which to enable the PRBS - EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TOR1 -> TOR 1 - EYE_PRBS_TARGET_TOR2 -> TOR 2 - EYE_PRBS_TARGET_NIC -> NIC + One of the following predefined constants, the target on which to enable the PRBS: + EYE_PRBS_TARGET_LOCAL -> local side, + EYE_PRBS_TARGET_TORA -> TOR A + EYE_PRBS_TARGET_TORB -> TOR B + EYE_PRBS_TARGET_NIC -> NIC mode_value: an Integer, the mode/type for configuring the PRBS mode. @@ -498,8 +506,8 @@ def enable_prbs_mode(self, port, target, mode_value, lane_map): for example 3 -> 0b'0011 , means running on lane0 and lane1 Returns: - a boolean, true if the enable is successful - , false if the enable failed + a boolean, True if the enable is successful + , False if the enable failed """ @@ -513,15 +521,15 @@ def disable_prbs_mode(self, port, target): physical_port: an Integer, the actual physical port connected to a Y cable target: - an Integer, the target on which to enable the PRBS - EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TOR1 -> TOR 1 - EYE_PRBS_TARGET_TOR2 -> TOR 2 - EYE_PRBS_TARGET_NIC -> NIC + One of the following predefined constants, the target on which to disable the PRBS: + EYE_PRBS_TARGET_LOCAL -> local side, + EYE_PRBS_TARGET_TORA -> TOR A + EYE_PRBS_TARGET_TORB -> TOR B + EYE_PRBS_TARGET_NIC -> NIC Returns: - a boolean, true if the disable is successful - , false if the disable failed + a boolean, True if the disable is successful + , False if the disable failed """ raise NotImplementedError @@ -537,19 +545,19 @@ def enable_loopback_mode(self, port, target, lane_map): physical_port: an Integer, the actual physical port connected to a Y cable target: - an Integer, the target on which to enable the PRBS - EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TOR1 -> TOR 1 - EYE_PRBS_TARGET_TOR2 -> TOR 2 - EYE_PRBS_TARGET_NIC -> NIC + One of the following predefined constants, the target on which to enable the loopback: + EYE_PRBS_TARGET_LOCAL -> local side, + EYE_PRBS_TARGET_TORA -> TOR A + EYE_PRBS_TARGET_TORB -> TOR B + EYE_PRBS_TARGET_NIC -> NIC lane_map: an Integer, representing the lane_map to be run PRBS on 0bit for lane 0, 1bit for lane1 and so on. for example 3 -> 0b'0011 , means running on lane0 and lane1 Returns: - a boolean, true if the enable is successful - , false if the enable failed + a boolean, True if the enable is successful + , False if the enable failed """ raise NotImplementedError @@ -563,15 +571,15 @@ def disable_loopback_mode(self, port, target): physical_port: an Integer, the actual physical port connected to a Y cable target: - an Integer, the target on which to enable the PRBS - EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TOR1 -> TOR 1 - EYE_PRBS_TARGET_TOR2 -> TOR 2 - EYE_PRBS_TARGET_NIC -> NIC + One of the following predefined constants, the target on which to disable the loopback: + EYE_PRBS_TARGET_LOCAL -> local side, + EYE_PRBS_TARGET_TORA -> TOR A + EYE_PRBS_TARGET_TORB -> TOR B + EYE_PRBS_TARGET_NIC -> NIC Returns: - a boolean, true if the disable is successful - , false if the disable failed + a boolean, True if the disable is successful + , False if the disable failed """ raise NotImplementedError From 9fe685a85b5c50ad657badd3722279e810995303 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Thu, 6 May 2021 05:07:57 +0000 Subject: [PATCH 03/28] fix missing comments Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 32845066c..92d273128 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -399,7 +399,11 @@ def set_switching_mode(self, port, mode): physical_port: an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX mode: - an Integer, specifies which type of switching mode we set the muxcable to + One of the following predefined constant: + SWITCHING_MODE_AUTO + SWITCHING_MODE_MANUAL + + specifies which type of switching mode we set the muxcable to either SWITCHING_MODE_AUTO or SWITCHING_MODE_MANUAL Returns: From d1dc947ee677c3cfbd430205cf5bda37e4c0a986 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Thu, 6 May 2021 20:47:44 +0000 Subject: [PATCH 04/28] fix corrections Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 54 +++++++++++++++++------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 92d273128..84917aad3 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -11,15 +11,15 @@ class YCableBase(object): - # definitions of targets for getting the cursor + # definitions of targets for getting the various fields/cursor # equalization parameters from the register spec - # the name of the target denotes which side cursor - # values will be retreived + # the name of the target denotes which side MCU + # values will be retreived on the Y-Cable + TARGET_UNKNOWN = -1 TARGET_NIC = 0 TARGET_TORA = 1 TARGET_TORB = 2 - TARGET_UNKNOWN = -1 # definitions of targets for getting the EYE/BER # and initiating PRBS/Loopback on the Y cable @@ -99,8 +99,8 @@ def check_read_side(self, port): Returns: One of the following predefined constants: - TARGET_TORA, if reading the Y cable from TOR A side(TOR A). - TARGET_TORB, if reading the Y cable from TOR B side(TOR B). + TARGET_TORA, if reading the Y cable from TOR A side. + TARGET_TORB, if reading the Y cable from TOR B side. TARGET_NIC, if reading the Y cable from NIC side. TARGET_UNKNOWN, if reading the Y cable API fails. """ @@ -119,8 +119,8 @@ def check_mux_direction(self, port): Returns: One of the following predefined constants: - TARGET_TORA, if mux is pointing to TOR A side(TOR A). - TARGET_TORB, if mux is pointing to TOR B side(TOR B). + TARGET_TORA, if mux is pointing to TOR A side. + TARGET_TORB, if mux is pointing to TOR B side. TARGET_UNKNOWN, if mux direction API fails. """ @@ -128,7 +128,7 @@ def check_mux_direction(self, port): def check_active_linked_tor_side(self, port): """ - This API specifically checks which side of the Y cable is actively linked and routing + This API specifically checks which side of the Y cable is actively linked and routing/sending and returns either TOR A or TOR B. Args: @@ -137,8 +137,8 @@ def check_active_linked_tor_side(self, port): Returns: One of the following predefined constants: - TARGET_TORA, if TOR A is actively linked and routing(TOR A). - TARGET_TORB, if TOR B is actively linked and routing(TOR B). + TARGET_TORA, if TOR A is actively linked and routing/sending traffic. + TARGET_TORB, if TOR B is actively linked and routin/sending traffic. TARGET_UNKNOWN, if checking which side linked for routing API fails. """ @@ -262,13 +262,13 @@ def get_switch_count(self, port, count_type): Args: physical_port: - an Integer, the actual physical port connected to a Y cable + an Integer, the actual physical port connected to a Y cable count_type: - a string, for getting the count type - SWITCH_COUNT_MANUAL -> manual switch count - SWITCH_COUNT_MANUAL -> automatic switch count - Returns: - an integer, the number of times manually the Y-cable has been switched + One of the following predefined constants, for getting the count type: + SWITCH_COUNT_MANUAL -> manual switch count + SWITCH_COUNT_AUTO -> automatic switch count + Returns: + an integer, the number of times manually the Y-cable has been switched """ raise NotImplementedError @@ -288,10 +288,10 @@ def get_target_cursor_values(self, port, lane, target): 3 -> lane 3 4 -> lane 4 target: - One of the following predefined constant, the actual target to get the cursor values on: + One of the following predefined constants, the actual target to get the cursor values on: TARGET_NIC -> NIC, - TARGET_TORA-> TOR1, - TARGET_TORB -> TOR2 + TARGET_TORA-> TORA, + TARGET_TORB -> TORB Returns: a list, with pre one, pre two , main, post one, post two cursor values in the order """ @@ -307,10 +307,10 @@ def get_firmware_version(self, port, target): physical_port: an Integer, the actual physical port connected to a Y cable target: - One of the following predefined constant, the actual target to get the firmware version on: + One of the following predefined constants, the actual target to get the firmware version on: TARGET_NIC -> NIC, - TARGET_TORA-> TOR1, - TARGET_TORB -> TOR2 + TARGET_TORA-> TORA, + TARGET_TORB -> TORB Returns: a Dictionary: with version_active, version_inactive and version_next keys @@ -341,7 +341,7 @@ def download_firmware(self, port, fwfile): choosing (binary, archive, etc.). But note that it should be one file which contains firmware for all components of the Y-cable Returns: - One of the following predefined constant: + One of the following predefined constants: FIRMWARE_DOWNLOAD_SUCCESS FIRMWARE_DOWNLOAD_FAILURE @@ -364,7 +364,7 @@ def activate_firmware(self, port, fwfile): physical_port: an Integer, the actual physical port connected to a Y cable Returns: - One of the following predefined constant: + One of the following predefined constants: FIRMWARE_ACTIVATE_SUCCESS FIRMWARE_ACTIVATE_FAILURE """ @@ -381,7 +381,7 @@ def rollback_firmware(self, port): physical_port: an Integer, the actual physical port connected to a Y cable Returns: - One of the following predefined constant: + One of the following predefined constants: FIRMWARE_ROLLBACK_SUCCESS FIRMWARE_ROLLBACK_FAILURE """ @@ -399,7 +399,7 @@ def set_switching_mode(self, port, mode): physical_port: an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX mode: - One of the following predefined constant: + One of the following predefined constants: SWITCHING_MODE_AUTO SWITCHING_MODE_MANUAL From 998f323acd67ec68695b7b061d3c64dc364feade Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Thu, 6 May 2021 22:12:01 +0000 Subject: [PATCH 05/28] fix suggestion Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 84917aad3..4446eacf6 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -198,7 +198,7 @@ def get_eye_info(self, port): physical_port: an Integer, the actual physical port connected to a Y cable target: - One of the following predefined constant, the target on which to get the eye: + One of the following predefined constants, the target on which to get the eye: EYE_PRBS_TARGET_LOCAL -> local side, EYE_PRBS_TARGET_TORA -> TOR A EYE_PRBS_TARGET_TORB -> TOR B @@ -218,7 +218,7 @@ def get_ber_info(self, port): physical_port: an Integer, the actual physical port connected to a Y cable target: - One of the following predefined constant, the target on which to get the ber: + One of the following predefined constants, the target on which to get the ber: EYE_PRBS_TARGET_LOCAL -> local side, EYE_PRBS_TARGET_TORA -> TOR A EYE_PRBS_TARGET_TORB -> TOR B From 8a9d6f7e73a8eeae5015b48970752a6cdda4c0ee Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Fri, 7 May 2021 17:59:38 +0000 Subject: [PATCH 06/28] fix comments Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 90 ++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 4446eacf6..9899b7eb6 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -18,8 +18,8 @@ class YCableBase(object): TARGET_UNKNOWN = -1 TARGET_NIC = 0 - TARGET_TORA = 1 - TARGET_TORB = 2 + TARGET_TOR_A = 1 + TARGET_TOR_B = 2 # definitions of targets for getting the EYE/BER # and initiating PRBS/Loopback on the Y cable @@ -27,8 +27,8 @@ class YCableBase(object): # will be retreived/initiated EYE_PRBS_TARGET_LOCAL = 0 - EYE_PRBS_TARGET_TORA = 1 - EYE_PRBS_TARGET_TORB = 2 + EYE_PRBS_TARGET_TOR_A = 1 + EYE_PRBS_TARGET_TOR_B = 2 EYE_PRBS_TARGET_NIC = 3 # definitions of switch counter types @@ -56,9 +56,9 @@ def __init__(self, port): def toggle_mux_to_torA(self, port): """ This API specifically does a hard switch toggle of the Y cable's MUX regardless of link state to - TOR A. This means if the Y cable is actively routing, the "check_active_linked_tor_side" - API will now return Tor A. It also implies that if the link is actively routing on this port, Y cable - MUX will start forwarding packets from TOR A to NIC, and drop packets from TOR B to NIC + TOR A. This means if the Y cable is actively sending traffic, the "check_active_linked_tor_side" + API will now return Tor A. It also implies that if the link is actively sending traffic on this port, + Y cable MUX will start forwarding packets from TOR A to NIC, and drop packets from TOR B to NIC regardless of previous forwarding state. Args: @@ -74,9 +74,9 @@ def toggle_mux_to_torA(self, port): def toggle_mux_to_torB(self, port): """ This API specifically does a hard switch toggle of the Y cable's MUX regardless of link state to - TOR B. This means if the Y cable is actively routing, the "check_active_linked_tor_side" - API will now return Tor B. It also implies that if the link is actively routing on this port, Y cable - MUX will start forwarding packets from TOR B to NIC, and drop packets from TOR A to NIC + TOR B. This means if the Y cable is actively sending traffic, the "check_active_linked_tor_side" + API will now return Tor B. It also implies that if the link is actively sending traffic on this port, + Y cable. MUX will start forwarding packets from TOR B to NIC, and drop packets from TOR A to NIC regardless of previous forwarding state. Args: @@ -99,8 +99,8 @@ def check_read_side(self, port): Returns: One of the following predefined constants: - TARGET_TORA, if reading the Y cable from TOR A side. - TARGET_TORB, if reading the Y cable from TOR B side. + TARGET_TOR_A, if reading the Y cable from TOR A side. + TARGET_TOR_B, if reading the Y cable from TOR B side. TARGET_NIC, if reading the Y cable from NIC side. TARGET_UNKNOWN, if reading the Y cable API fails. """ @@ -111,7 +111,7 @@ def check_mux_direction(self, port): """ This API specifically checks which side of the Y cable mux is currently point to and returns either TOR A or TOR B. Note that this API should return mux-direction - regardless of whether the link is active/routing state or not. + regardless of whether the link is active and sending traffic or not. Args: port: @@ -119,8 +119,8 @@ def check_mux_direction(self, port): Returns: One of the following predefined constants: - TARGET_TORA, if mux is pointing to TOR A side. - TARGET_TORB, if mux is pointing to TOR B side. + TARGET_TOR_A, if mux is pointing to TOR A side. + TARGET_TOR_B, if mux is pointing to TOR B side. TARGET_UNKNOWN, if mux direction API fails. """ @@ -128,7 +128,7 @@ def check_mux_direction(self, port): def check_active_linked_tor_side(self, port): """ - This API specifically checks which side of the Y cable is actively linked and routing/sending + This API specifically checks which side of the Y cable is actively linked and sending traffic and returns either TOR A or TOR B. Args: @@ -137,9 +137,9 @@ def check_active_linked_tor_side(self, port): Returns: One of the following predefined constants: - TARGET_TORA, if TOR A is actively linked and routing/sending traffic. - TARGET_TORB, if TOR B is actively linked and routin/sending traffic. - TARGET_UNKNOWN, if checking which side linked for routing API fails. + TARGET_TOR_A, if TOR A is actively linked and sending traffic. + TARGET_TOR_B, if TOR B is actively linked and sending traffic. + TARGET_UNKNOWN, if checking which side is linked and sending traffic API fails. """ raise NotImplementedError @@ -192,7 +192,7 @@ def check_if_link_is_active_for_torB(self, port): def get_eye_info(self, port): """ This API specifically returns the EYE height value for a specfic port. - The target could be local side, TORA, TORB, NIC etc. + The target could be local side, TOR_A, TOR_B, NIC etc. Args: physical_port: @@ -200,8 +200,8 @@ def get_eye_info(self, port): target: One of the following predefined constants, the target on which to get the eye: EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TORA -> TOR A - EYE_PRBS_TARGET_TORB -> TOR B + EYE_PRBS_TARGET_TOR_A -> TOR A + EYE_PRBS_TARGET_TOR_B -> TOR B EYE_PRBS_TARGET_NIC -> NIC Returns: a list, with EYE values of lane 0 lane 1 lane 2 lane 3 with corresponding index @@ -212,16 +212,16 @@ def get_eye_info(self, port): def get_ber_info(self, port): """ This API specifically returns the BER (Bit error rate) value for a specfic port. - The target could be local side, TORA, TORB, NIC etc. + The target could be local side, TOR_A, TOR_B, NIC etc. Args: physical_port: an Integer, the actual physical port connected to a Y cable target: - One of the following predefined constants, the target on which to get the ber: + One of the following predefined constants, the target on which to get the BER: EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TORA -> TOR A - EYE_PRBS_TARGET_TORB -> TOR B + EYE_PRBS_TARGET_TOR_A -> TOR A + EYE_PRBS_TARGET_TOR_B -> TOR B EYE_PRBS_TARGET_NIC -> NIC Returns: a list, with BER values of lane 0 lane 1 lane 2 lane 3 with corresponding index @@ -275,7 +275,7 @@ def get_switch_count(self, port, count_type): def get_target_cursor_values(self, port, lane, target): """ - This API specifically returns the cursor equalization parameters for a target(NIC, TORA, TORB). + This API specifically returns the cursor equalization parameters for a target(NIC, TOR_A, TOR_B). This includes pre one, pre two , main, post one, post two cursor values Args: @@ -290,8 +290,8 @@ def get_target_cursor_values(self, port, lane, target): target: One of the following predefined constants, the actual target to get the cursor values on: TARGET_NIC -> NIC, - TARGET_TORA-> TORA, - TARGET_TORB -> TORB + TARGET_TOR_A-> TORA, + TARGET_TOR_B -> TORB Returns: a list, with pre one, pre two , main, post one, post two cursor values in the order """ @@ -299,7 +299,8 @@ def get_target_cursor_values(self, port, lane, target): raise NotImplementedError def get_firmware_version(self, port, target): - """ This routine should return the active, inactive and next (committed) + """ + This routine should return the active, inactive and next (committed) firmware running on the target. Each of the version values in this context could be a string with a major and minor number and a build value. @@ -309,8 +310,8 @@ def get_firmware_version(self, port, target): target: One of the following predefined constants, the actual target to get the firmware version on: TARGET_NIC -> NIC, - TARGET_TORA-> TORA, - TARGET_TORB -> TORB + TARGET_TOR_A-> TORA, + TARGET_TOR_B -> TORB Returns: a Dictionary: with version_active, version_inactive and version_next keys @@ -321,7 +322,8 @@ def get_firmware_version(self, port, target): raise NotImplementedError def download_firmware(self, port, fwfile): - """ This routine should download and store the firmware on all the + """ + This routine should download and store the firmware on all the components of the Y cable of the port specified. This should include any internal transfers, checksum validation etc. from TOR to TOR or TOR to NIC side of the firmware specified by the fwfile. @@ -352,7 +354,8 @@ def download_firmware(self, port, fwfile): raise NotImplementedError def activate_firmware(self, port, fwfile): - """ This routine should activate the downloaded firmware on all the + """ + This routine should activate the downloaded firmware on all the components of the Y cable of the port specified. This API is meant to be used in conjunction with download_firmware API, and should be called once download_firmware API is succesful. @@ -372,7 +375,8 @@ def activate_firmware(self, port, fwfile): raise NotImplementedError def rollback_firmware(self, port): - """ This routine should rollback the firmware to the previous version + """ + This routine should rollback the firmware to the previous version which was being used by the cable. This API is intended to be called when the user either witnesses an activate_firmware API failure or sees issues with newer firmware in regards to stable cable functioning. @@ -498,8 +502,8 @@ def enable_prbs_mode(self, port, target, mode_value, lane_map): target: One of the following predefined constants, the target on which to enable the PRBS: EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TORA -> TOR A - EYE_PRBS_TARGET_TORB -> TOR B + EYE_PRBS_TARGET_TOR_A -> TOR A + EYE_PRBS_TARGET_TOR_B -> TOR B EYE_PRBS_TARGET_NIC -> NIC mode_value: an Integer, the mode/type for configuring the PRBS mode. @@ -527,8 +531,8 @@ def disable_prbs_mode(self, port, target): target: One of the following predefined constants, the target on which to disable the PRBS: EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TORA -> TOR A - EYE_PRBS_TARGET_TORB -> TOR B + EYE_PRBS_TARGET_TOR_A -> TOR A + EYE_PRBS_TARGET_TOR_B -> TOR B EYE_PRBS_TARGET_NIC -> NIC Returns: @@ -551,8 +555,8 @@ def enable_loopback_mode(self, port, target, lane_map): target: One of the following predefined constants, the target on which to enable the loopback: EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TORA -> TOR A - EYE_PRBS_TARGET_TORB -> TOR B + EYE_PRBS_TARGET_TOR_A -> TOR A + EYE_PRBS_TARGET_TOR_B -> TOR B EYE_PRBS_TARGET_NIC -> NIC lane_map: an Integer, representing the lane_map to be run PRBS on @@ -577,8 +581,8 @@ def disable_loopback_mode(self, port, target): target: One of the following predefined constants, the target on which to disable the loopback: EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TORA -> TOR A - EYE_PRBS_TARGET_TORB -> TOR B + EYE_PRBS_TARGET_TOR_A -> TOR A + EYE_PRBS_TARGET_TOR_B -> TOR B EYE_PRBS_TARGET_NIC -> NIC Returns: From acdb72e4e98225dfd266eaa3919b70c91af704df Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Fri, 7 May 2021 22:56:00 +0000 Subject: [PATCH 07/28] fix the physical_port string;fwfile addition as arg Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 51 ++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 9899b7eb6..8c302dbf8 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -195,7 +195,7 @@ def get_eye_info(self, port): The target could be local side, TOR_A, TOR_B, NIC etc. Args: - physical_port: + port: an Integer, the actual physical port connected to a Y cable target: One of the following predefined constants, the target on which to get the eye: @@ -215,7 +215,7 @@ def get_ber_info(self, port): The target could be local side, TOR_A, TOR_B, NIC etc. Args: - physical_port: + port: an Integer, the actual physical port connected to a Y cable target: One of the following predefined constants, the target on which to get the BER: @@ -234,7 +234,7 @@ def get_vendor(self, port): This API specifically returns the vendor name of the Y cable for a specfic port. Args: - physical_port: + port: an Integer, the actual physical port connected to a Y cable Returns: a string, with vendor name @@ -247,7 +247,7 @@ def get_part_number(self, port): This API specifically returns the part number of the Y cable for a specfic port. Args: - physical_port: + port: an Integer, the actual physical port connected to a Y cable Returns: a string, with part number @@ -261,7 +261,7 @@ def get_switch_count(self, port, count_type): been done manually by the user. Args: - physical_port: + port: an Integer, the actual physical port connected to a Y cable count_type: One of the following predefined constants, for getting the count type: @@ -279,7 +279,7 @@ def get_target_cursor_values(self, port, lane, target): This includes pre one, pre two , main, post one, post two cursor values Args: - physical_port: + port: an Integer, the actual physical port connected to a Y cable lane: an Integer, the lane on which to collect the cursor values @@ -305,7 +305,7 @@ def get_firmware_version(self, port, target): could be a string with a major and minor number and a build value. Args: - physical_port: + port: an Integer, the actual physical port connected to a Y cable target: One of the following predefined constants, the actual target to get the firmware version on: @@ -335,7 +335,7 @@ def download_firmware(self, port, fwfile): this has not been activated yet. Args: - physical_port: + port: an Integer, the actual physical port connected to a Y cable fwfile: a string, a path to the file which contains the firmware image. @@ -353,7 +353,7 @@ def download_firmware(self, port, fwfile): raise NotImplementedError - def activate_firmware(self, port, fwfile): + def activate_firmware(self, port, fwfile=None): """ This routine should activate the downloaded firmware on all the components of the Y cable of the port specified. @@ -364,8 +364,17 @@ def activate_firmware(self, port, fwfile): successfully executed. Args: - physical_port: + port: an Integer, the actual physical port connected to a Y cable + fwfile: + a string, a path to the file which contains the firmware image. + Note that the firmware file can be in the format of the vendor's + choosing (binary, archive, etc.). But note that it should be one file + which contains firmware for all components of the Y-cable. In case the + vendor chooses to pass this file in activate_firmware, the API should + have the logic to retreive the firmware version from this file + which has to be activated on the componenets of the Y-Cable + this API has been called for. Returns: One of the following predefined constants: FIRMWARE_ACTIVATE_SUCCESS @@ -382,7 +391,7 @@ def rollback_firmware(self, port): newer firmware in regards to stable cable functioning. Args: - physical_port: + port: an Integer, the actual physical port connected to a Y cable Returns: One of the following predefined constants: @@ -400,7 +409,7 @@ def set_switching_mode(self, port, mode): side link goes down and basically points the mux to the other side. Args: - physical_port: + port: an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX mode: One of the following predefined constants: @@ -421,7 +430,7 @@ def get_switching_mode(self, port): This API specifically returns which type of switching mode the cable is set to auto/manual Args: - physical_port: + port: an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: @@ -437,7 +446,7 @@ def get_nic_temperature(self, port): This API specifically returns nic temperature of the physical port specified Args: - physical_port: + port: an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: @@ -451,7 +460,7 @@ def get_local_temperature(self, port): This API specifically returns local ToR temperature of the physical port specified Args: - physical_port: + port: an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: @@ -465,7 +474,7 @@ def get_nic_voltage(self, port): This API specifically returns nic voltage of the physical port specified Args: - physical_port: + port: an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: @@ -479,7 +488,7 @@ def get_local_voltage(self, port): This API specifically returns local ToR voltage of the physical port specified Args: - physical_port: + port: an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: @@ -497,7 +506,7 @@ def enable_prbs_mode(self, port, target, mode_value, lane_map): Note that this is a diagnostic mode command and must not run during normal traffic/switch operation Args: - physical_port: + port: an Integer, the actual physical port connected to a Y cable target: One of the following predefined constants, the target on which to enable the PRBS: @@ -526,7 +535,7 @@ def disable_prbs_mode(self, port, target): This API specifically disables the PRBS mode on the physical port. Args: - physical_port: + port: an Integer, the actual physical port connected to a Y cable target: One of the following predefined constants, the target on which to disable the PRBS: @@ -550,7 +559,7 @@ def enable_loopback_mode(self, port, target, lane_map): Note that this is a diagnostic mode command and must not run during normal traffic/switch operation Args: - physical_port: + port: an Integer, the actual physical port connected to a Y cable target: One of the following predefined constants, the target on which to enable the loopback: @@ -576,7 +585,7 @@ def disable_loopback_mode(self, port, target): Target is an integer for selecting which end of the Y cable we want to run loopback on. Args: - physical_port: + port: an Integer, the actual physical port connected to a Y cable target: One of the following predefined constants, the target on which to disable the loopback: From b8ff39cceb12a0e8394755061d06fb6d240b780a Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Mon, 10 May 2021 18:17:33 +0000 Subject: [PATCH 08/28] fix more suggestions Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 205 ++++++++++++++-------------------- 1 file changed, 85 insertions(+), 120 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 8c302dbf8..c7b3f1799 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -51,19 +51,24 @@ class YCableBase(object): FIRMWARE_ROLLBACK_FAILURE = 1 def __init__(self, port): + """ + Args: + port: + an Integer, the actual physical port connected to a Y cable + """ self.port = port - def toggle_mux_to_torA(self, port): + def toggle_mux_to_torA(self): """ This API specifically does a hard switch toggle of the Y cable's MUX regardless of link state to - TOR A. This means if the Y cable is actively sending traffic, the "check_active_linked_tor_side" - API will now return Tor A. It also implies that if the link is actively sending traffic on this port, + TOR A on the port this is called for. This means if the Y cable is actively sending traffic, + the "get_active_linked_tor_side" API will now return Tor A. + It also implies that if the link is actively sending traffic on this port, Y cable MUX will start forwarding packets from TOR A to NIC, and drop packets from TOR B to NIC regardless of previous forwarding state. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: a Boolean, True if the toggle succeeded and False if it did not succeed. @@ -71,31 +76,29 @@ def toggle_mux_to_torA(self, port): raise NotImplementedError - def toggle_mux_to_torB(self, port): + def toggle_mux_to_torB(self): """ This API specifically does a hard switch toggle of the Y cable's MUX regardless of link state to - TOR B. This means if the Y cable is actively sending traffic, the "check_active_linked_tor_side" + TOR B. This means if the Y cable is actively sending traffic, the "get_active_linked_tor_side" API will now return Tor B. It also implies that if the link is actively sending traffic on this port, Y cable. MUX will start forwarding packets from TOR B to NIC, and drop packets from TOR A to NIC regardless of previous forwarding state. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: a Boolean, True if the toggle succeeded and False if it did not succeed. """ raise NotImplementedError - def check_read_side(self, port): + def get_read_side(self): """ This API specifically checks which side of the Y cable the reads are actually getting performed from, either TOR A or TOR B or NIC and returns the value. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to Y end of a Y cable which can which side reading the MUX from Returns: One of the following predefined constants: @@ -107,15 +110,14 @@ def check_read_side(self, port): raise NotImplementedError - def check_mux_direction(self, port): + def get_mux_direction(self): """ This API specifically checks which side of the Y cable mux is currently point to and returns either TOR A or TOR B. Note that this API should return mux-direction regardless of whether the link is active and sending traffic or not. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable Returns: One of the following predefined constants: @@ -126,14 +128,16 @@ def check_mux_direction(self, port): raise NotImplementedError - def check_active_linked_tor_side(self, port): + def get_active_linked_tor_side(self): """ This API specifically checks which side of the Y cable is actively linked and sending traffic and returns either TOR A or TOR B. + The port on which this API is called for can be referred using self.port. + This is different from get_mux_direction in a sense it also implies the link on the side + where mux is pointing to must be active and sending traffic, whereas get_mux_direction + just tells where the mux is pointing to. Args: - port: - an Integer, the actual physical port connected to a Y cable Returns: One of the following predefined constants: @@ -144,43 +148,18 @@ def check_active_linked_tor_side(self, port): raise NotImplementedError - def check_if_link_is_active_for_NIC(self, port): - """ - This API specifically checks if NIC side of the Y cable's link is active - - Args: - port: - an Integer, the actual physical port connected to a Y cable - - Returns: - a boolean, True if the link is active - , False if the link is not active - """ - - raise NotImplementedError - - def check_if_link_is_active_for_torA(self, port): - """ - This API specifically checks if tor A side of the Y cable's link is active - - Args: - port: - an Integer, the actual physical port connected to a Y cable - - Returns: - a boolean, True if the link is active - , False if the link is not active - """ - - raise NotImplementedError - - def check_if_link_is_active_for_torB(self, port): + def is_link_active(self, target): """ - This API specifically checks if tor B side of the Y cable's link is active + This API specifically checks if NIC, TOR_A and TOR_B of the Y cable's link is active. + The target specifies which link is supposed to be checked + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable + target: + One of the following predefined constants, the actual target to check the link on: + TARGET_NIC -> NIC, + TARGET_TOR_A-> TORA, + TARGET_TOR_B -> TORB Returns: a boolean, True if the link is active @@ -189,14 +168,13 @@ def check_if_link_is_active_for_torB(self, port): raise NotImplementedError - def get_eye_info(self, port): + def get_eye_info(self, target): """ This API specifically returns the EYE height value for a specfic port. The target could be local side, TOR_A, TOR_B, NIC etc. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable target: One of the following predefined constants, the target on which to get the eye: EYE_PRBS_TARGET_LOCAL -> local side, @@ -209,14 +187,13 @@ def get_eye_info(self, port): raise NotImplementedError - def get_ber_info(self, port): + def get_ber_info(self, target): """ This API specifically returns the BER (Bit error rate) value for a specfic port. The target could be local side, TOR_A, TOR_B, NIC etc. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable target: One of the following predefined constants, the target on which to get the BER: EYE_PRBS_TARGET_LOCAL -> local side, @@ -229,40 +206,39 @@ def get_ber_info(self, port): raise NotImplementedError - def get_vendor(self, port): + def get_vendor(self): """ This API specifically returns the vendor name of the Y cable for a specfic port. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable + Returns: a string, with vendor name """ raise NotImplementedError - def get_part_number(self, port): + def get_part_number(self): """ This API specifically returns the part number of the Y cable for a specfic port. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable + Returns: a string, with part number """ raise NotImplementedError - def get_switch_count(self, port, count_type): + def get_switch_count(self, count_type): """ This API specifically returns the switch count to change the Active TOR which has been done manually by the user. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable count_type: One of the following predefined constants, for getting the count type: SWITCH_COUNT_MANUAL -> manual switch count @@ -273,14 +249,13 @@ def get_switch_count(self, port, count_type): raise NotImplementedError - def get_target_cursor_values(self, port, lane, target): + def get_target_cursor_values(self, lane, target): """ This API specifically returns the cursor equalization parameters for a target(NIC, TOR_A, TOR_B). This includes pre one, pre two , main, post one, post two cursor values + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable lane: an Integer, the lane on which to collect the cursor values 1 -> lane 1, @@ -298,15 +273,14 @@ def get_target_cursor_values(self, port, lane, target): raise NotImplementedError - def get_firmware_version(self, port, target): + def get_firmware_version(self, target): """ This routine should return the active, inactive and next (committed) firmware running on the target. Each of the version values in this context could be a string with a major and minor number and a build value. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable target: One of the following predefined constants, the actual target to get the firmware version on: TARGET_NIC -> NIC, @@ -321,10 +295,10 @@ def get_firmware_version(self, port, target): raise NotImplementedError - def download_firmware(self, port, fwfile): + def download_firmware(self, fwfile): """ This routine should download and store the firmware on all the - components of the Y cable of the port specified. + components of the Y cable of the port for which this API is called.. This should include any internal transfers, checksum validation etc. from TOR to TOR or TOR to NIC side of the firmware specified by the fwfile. This basically means that the firmware which is being downloaded should be @@ -333,10 +307,9 @@ def download_firmware(self, port, fwfile): Note that this API should ideally not require any rollback even if it fails as this should not interfere with the existing cable functionality because this has not been activated yet. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable fwfile: a string, a path to the file which contains the firmware image. Note that the firmware file can be in the format of the vendor's @@ -353,28 +326,31 @@ def download_firmware(self, port, fwfile): raise NotImplementedError - def activate_firmware(self, port, fwfile=None): + def activate_firmware(self, fwfile=None): """ This routine should activate the downloaded firmware on all the - components of the Y cable of the port specified. + components of the Y cable of the port for which this API is called.. This API is meant to be used in conjunction with download_firmware API, and should be called once download_firmware API is succesful. This means that the firmware which has been downloaded should be activated (start being utilized by the cable) once this API is successfully executed. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable - fwfile: + fwfile (optional): a string, a path to the file which contains the firmware image. Note that the firmware file can be in the format of the vendor's choosing (binary, archive, etc.). But note that it should be one file which contains firmware for all components of the Y-cable. In case the vendor chooses to pass this file in activate_firmware, the API should have the logic to retreive the firmware version from this file - which has to be activated on the componenets of the Y-Cable + which has to be activated on the components of the Y-Cable this API has been called for. + If None is passed for fwfile, the cable should activate whatever + firmware is marked to be activated next. + If provided, it should retreive the firmware version(s) from this file, ensure + they are downloaded on the cable, then activate them. Returns: One of the following predefined constants: FIRMWARE_ACTIVATE_SUCCESS @@ -383,16 +359,15 @@ def activate_firmware(self, port, fwfile=None): raise NotImplementedError - def rollback_firmware(self, port): + def rollback_firmware(self): """ This routine should rollback the firmware to the previous version which was being used by the cable. This API is intended to be called when the user either witnesses an activate_firmware API failure or sees issues with newer firmware in regards to stable cable functioning. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable Returns: One of the following predefined constants: FIRMWARE_ROLLBACK_SUCCESS @@ -401,16 +376,15 @@ def rollback_firmware(self, port): raise NotImplementedError - def set_switching_mode(self, port, mode): + def set_switching_mode(self, mode): """ This API specifically enables the auto switching or manual switching feature on the muxcable, depending upon the mode entered by the user. Autoswitch feature if enabled actually does an automatic toggle of the mux in case the active side link goes down and basically points the mux to the other side. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX mode: One of the following predefined constants: SWITCHING_MODE_AUTO @@ -425,13 +399,12 @@ def set_switching_mode(self, port, mode): raise NotImplementedError - def get_switching_mode(self, port): + def get_switching_mode(self): """ This API specifically returns which type of switching mode the cable is set to auto/manual + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: One of the following predefined constants: @@ -441,13 +414,12 @@ def get_switching_mode(self, port): raise NotImplementedError - def get_nic_temperature(self, port): + def get_nic_temperature(self): """ - This API specifically returns nic temperature of the physical port specified + This API specifically returns nic temperature of the physical port for which this API is called. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: an Integer, the temperature of the NIC MCU @@ -455,13 +427,12 @@ def get_nic_temperature(self, port): raise NotImplementedError - def get_local_temperature(self, port): + def get_local_temperature(self): """ - This API specifically returns local ToR temperature of the physical port specified + This API specifically returns local ToR temperature of the physical port for which this API is called. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: an Integer, the temperature of the local MCU @@ -469,13 +440,12 @@ def get_local_temperature(self, port): raise NotImplementedError - def get_nic_voltage(self, port): + def get_nic_voltage(self): """ - This API specifically returns nic voltage of the physical port specified + This API specifically returns nic voltage of the physical port for which this API is called. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: a float, the voltage of the NIC MCU @@ -483,13 +453,12 @@ def get_nic_voltage(self, port): raise NotImplementedError - def get_local_voltage(self, port): + def get_local_voltage(self): """ - This API specifically returns local ToR voltage of the physical port specified + This API specifically returns local ToR voltage of the physical port for which this API is called. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX Returns: a float, the voltage of the local MCU @@ -497,17 +466,16 @@ def get_local_voltage(self, port): raise NotImplementedError - def enable_prbs_mode(self, port, target, mode_value, lane_map): + def enable_prbs_mode(self, target, mode_value, lane_map): """ This API specifically configures and enables the PRBS mode/type depending upon the mode_value the user provides. The mode_value configures the PRBS Type for generation and BER sensing on a per side basis. Target is an integer for selecting which end of the Y cable we want to run PRBS on. LaneMap specifies the lane configuration to run the PRBS on. Note that this is a diagnostic mode command and must not run during normal traffic/switch operation + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable target: One of the following predefined constants, the target on which to enable the PRBS: EYE_PRBS_TARGET_LOCAL -> local side, @@ -530,13 +498,12 @@ def enable_prbs_mode(self, port, target, mode_value, lane_map): raise NotImplementedError - def disable_prbs_mode(self, port, target): + def disable_prbs_mode(self, target): """ This API specifically disables the PRBS mode on the physical port. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable target: One of the following predefined constants, the target on which to disable the PRBS: EYE_PRBS_TARGET_LOCAL -> local side, @@ -551,16 +518,15 @@ def disable_prbs_mode(self, port, target): raise NotImplementedError - def enable_loopback_mode(self, port, target, lane_map): + def enable_loopback_mode(self, target, lane_map): """ This API specifically configures and enables the Loopback mode on the port user provides. Target is an integer for selecting which end of the Y cable we want to run loopback on. LaneMap specifies the lane configuration to run the loopback on. Note that this is a diagnostic mode command and must not run during normal traffic/switch operation + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable target: One of the following predefined constants, the target on which to enable the loopback: EYE_PRBS_TARGET_LOCAL -> local side, @@ -579,14 +545,13 @@ def enable_loopback_mode(self, port, target, lane_map): raise NotImplementedError - def disable_loopback_mode(self, port, target): + def disable_loopback_mode(self, target): """ This API specifically disables the Loopback mode on the port user provides. Target is an integer for selecting which end of the Y cable we want to run loopback on. + The port on which this API is called for can be referred using self.port. Args: - port: - an Integer, the actual physical port connected to a Y cable target: One of the following predefined constants, the target on which to disable the loopback: EYE_PRBS_TARGET_LOCAL -> local side, From 1d3e0a42c2b9c8c735d056558d3ee56d3ff33742 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Mon, 10 May 2021 18:28:11 +0000 Subject: [PATCH 09/28] fix debug modes def Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index c7b3f1799..7ee7762d8 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -565,3 +565,54 @@ def disable_loopback_mode(self, target): """ raise NotImplementedError + + def enable_debug_mode(self): + """ + This API specifically configures and enables a debug mode that the port is now + going to be run on. This means that PRBS/Loopback etc. type diagnostic mode + is now going to be run on the port and hence normal traffic will be disabled + on it. + The port on which this API is called for can be referred using self.port. + + Args: + + Returns: + a boolean, True if the enable is successful + , False if the enable failed + """ + + raise NotImplementedError + + def disable_debug_mode(self): + """ + This API specifically disables a debug mode that the port was currently being run on. + This means that PRBS/Loopback etc. type diagnostic mode + are now going to be stopped the port and hence normal traffic will be enabled + on it. + The port on which this API is called for can be referred using self.port. + + Args: + + Returns: + a boolean, True if the disable is successful + , False if the disable failed + """ + + raise NotImplementedError + + def is_debug_mode_enabled(self): + """ + This API specifically checks if a debug mode is currently being run on the port + for which this API is called for. + This means that PRBS/Loopback etc. type diagnostic mode + if any are being run on the port this should return True else False + The port on which this API is called for can be referred using self.port. + + Args: + + Returns: + a boolean, True if debug mode enabled + , False if debug mode not enabled + """ + + raise NotImplementedError From 66e9647ff767e805a83384badf803b5ca1ca0dbb Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Mon, 10 May 2021 19:17:31 +0000 Subject: [PATCH 10/28] fix suggestions for case;add new API Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 7ee7762d8..8ebc27086 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -58,7 +58,7 @@ def __init__(self, port): """ self.port = port - def toggle_mux_to_torA(self): + def toggle_mux_to_tor_a(self): """ This API specifically does a hard switch toggle of the Y cable's MUX regardless of link state to TOR A on the port this is called for. This means if the Y cable is actively sending traffic, @@ -76,7 +76,7 @@ def toggle_mux_to_torA(self): raise NotImplementedError - def toggle_mux_to_torB(self): + def toggle_mux_to_tor_b(self): """ This API specifically does a hard switch toggle of the Y cable's MUX regardless of link state to TOR B. This means if the Y cable is actively sending traffic, the "get_active_linked_tor_side" @@ -616,3 +616,21 @@ def is_debug_mode_enabled(self): """ raise NotImplementedError + + def debug_dump_registers(self): + """ + This API specifically should dump all registers with meaningful values + for the cable to be diagnosed for proper functioning. + This means that for all the fields on relevant vendor specific pages + this API should dump the appropriate fields with parsed values + which would help debug the Y-Cable + + Args: + + Returns: + a Dictionary: + with all the relevant key-value pairs for all the meaningful fields + which would help diagnose the cable for proper functioning + """ + + raise NotImplementedError From 458b62fc458072b08c6635d94ec8ee9b2570efa3 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Tue, 11 May 2021 06:55:30 +0000 Subject: [PATCH 11/28] fix the api names Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 53 +++++++++++++++-------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 8ebc27086..a3bd4cc14 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -3,18 +3,19 @@ Base class for implementing Y-Cable specific functionality in SONiC. This is the base class of sonic_y_cable implentation. A vendor specific - implementation of YCable needs to inherit from this class. + implementation of a 'YCable' class needs to inherit from this class. Classes derived from this class provide the ability to interact - with a vendor specific Y-Cable + with a vendor-specific Y-Cable """ class YCableBase(object): # definitions of targets for getting the various fields/cursor - # equalization parameters from the register spec + # equalization parameters from the register spec. # the name of the target denotes which side MCU - # values will be retreived on the Y-Cable + # values will be retrieved from or written to + # on the Y-Cable TARGET_UNKNOWN = -1 TARGET_NIC = 0 @@ -38,7 +39,7 @@ class YCableBase(object): SWITCH_COUNT_MANUAL = "manual" SWITCH_COUNT_AUTO = "auto" - # switching modes inside muxcable + # switching modes inside Y-Cable SWITCHING_MODE_MANUAL = 0 SWITCHING_MODE_AUTO = 1 @@ -378,7 +379,7 @@ def rollback_firmware(self): def set_switching_mode(self, mode): """ - This API specifically enables the auto switching or manual switching feature on the muxcable, + This API specifically enables the auto switching or manual switching feature on the Y-Cable, depending upon the mode entered by the user. Autoswitch feature if enabled actually does an automatic toggle of the mux in case the active side link goes down and basically points the mux to the other side. @@ -390,7 +391,7 @@ def set_switching_mode(self, mode): SWITCHING_MODE_AUTO SWITCHING_MODE_MANUAL - specifies which type of switching mode we set the muxcable to + specifies which type of switching mode we set the Y-Cable to either SWITCHING_MODE_AUTO or SWITCHING_MODE_MANUAL Returns: @@ -466,6 +467,11 @@ def get_local_voltage(self): raise NotImplementedError + +############################################################################################# +### Debug Functionality ### +############################################################################################# + def enable_prbs_mode(self, target, mode_value, lane_map): """ This API specifically configures and enables the PRBS mode/type depending upon the mode_value the user provides. @@ -566,15 +572,19 @@ def disable_loopback_mode(self, target): raise NotImplementedError - def enable_debug_mode(self): + def set_debug_mode(self, enable): """ - This API specifically configures and enables a debug mode that the port is now - going to be run on. This means that PRBS/Loopback etc. type diagnostic mode + This API specifically enables/disables a debug mode that the port is now + going to be run on. If enabled, this means that PRBS/Loopback etc. type diagnostic mode is now going to be run on the port and hence normal traffic will be disabled - on it. + on it if enabled and vice-versa if disabled. The port on which this API is called for can be referred using self.port. Args: + enable: + a boolean, True if the debug mode needs to be enabled + , False if the debug mode needs to be disabled + Returns: a boolean, True if the enable is successful @@ -583,29 +593,12 @@ def enable_debug_mode(self): raise NotImplementedError - def disable_debug_mode(self): - """ - This API specifically disables a debug mode that the port was currently being run on. - This means that PRBS/Loopback etc. type diagnostic mode - are now going to be stopped the port and hence normal traffic will be enabled - on it. - The port on which this API is called for can be referred using self.port. - - Args: - - Returns: - a boolean, True if the disable is successful - , False if the disable failed - """ - - raise NotImplementedError - - def is_debug_mode_enabled(self): + def get_debug_mode(self): """ This API specifically checks if a debug mode is currently being run on the port for which this API is called for. This means that PRBS/Loopback etc. type diagnostic mode - if any are being run on the port this should return True else False + if any are being run on the port this should return True else False. The port on which this API is called for can be referred using self.port. Args: From b6bbf8249e971b525438575d7869624e8c196169 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Tue, 11 May 2021 06:57:57 +0000 Subject: [PATCH 12/28] fix the suggestions Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 76 ++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index a3bd4cc14..a3ee23ff6 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -472,6 +472,45 @@ def get_local_voltage(self): ### Debug Functionality ### ############################################################################################# + + def set_debug_mode(self, enable): + """ + This API specifically enables/disables a debug mode that the port is now + going to be run on. If enabled, this means that PRBS/Loopback etc. type diagnostic mode + is now going to be run on the port and hence normal traffic will be disabled + on it if enabled and vice-versa if disabled. + The port on which this API is called for can be referred using self.port. + + Args: + enable: + a boolean, True if the debug mode needs to be enabled + , False if the debug mode needs to be disabled + + + Returns: + a boolean, True if the enable is successful + , False if the enable failed + """ + + raise NotImplementedError + + def get_debug_mode(self): + """ + This API specifically checks if a debug mode is currently being run on the port + for which this API is called for. + This means that PRBS/Loopback etc. type diagnostic mode + if any are being run on the port this should return True else False. + The port on which this API is called for can be referred using self.port. + + Args: + + Returns: + a boolean, True if debug mode enabled + , False if debug mode not enabled + """ + + raise NotImplementedError + def enable_prbs_mode(self, target, mode_value, lane_map): """ This API specifically configures and enables the PRBS mode/type depending upon the mode_value the user provides. @@ -572,43 +611,6 @@ def disable_loopback_mode(self, target): raise NotImplementedError - def set_debug_mode(self, enable): - """ - This API specifically enables/disables a debug mode that the port is now - going to be run on. If enabled, this means that PRBS/Loopback etc. type diagnostic mode - is now going to be run on the port and hence normal traffic will be disabled - on it if enabled and vice-versa if disabled. - The port on which this API is called for can be referred using self.port. - - Args: - enable: - a boolean, True if the debug mode needs to be enabled - , False if the debug mode needs to be disabled - - - Returns: - a boolean, True if the enable is successful - , False if the enable failed - """ - - raise NotImplementedError - - def get_debug_mode(self): - """ - This API specifically checks if a debug mode is currently being run on the port - for which this API is called for. - This means that PRBS/Loopback etc. type diagnostic mode - if any are being run on the port this should return True else False. - The port on which this API is called for can be referred using self.port. - - Args: - - Returns: - a boolean, True if debug mode enabled - , False if debug mode not enabled - """ - - raise NotImplementedError def debug_dump_registers(self): """ From a4de1c3d62df2550bceaffd3b1c87797df88f029 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Tue, 11 May 2021 23:08:10 +0000 Subject: [PATCH 13/28] fix naming Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index a3ee23ff6..2802bd52b 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -2,7 +2,7 @@ y_cable_base.py Base class for implementing Y-Cable specific functionality in SONiC. - This is the base class of sonic_y_cable implentation. A vendor specific + This is the base class of sonic_y_cable implentation. A vendor-specific implementation of a 'YCable' class needs to inherit from this class. Classes derived from this class provide the ability to interact with a vendor-specific Y-Cable @@ -616,7 +616,7 @@ def debug_dump_registers(self): """ This API specifically should dump all registers with meaningful values for the cable to be diagnosed for proper functioning. - This means that for all the fields on relevant vendor specific pages + This means that for all the fields on relevant vendor-specific pages this API should dump the appropriate fields with parsed values which would help debug the Y-Cable From 2a549cafee9fed4fc4fa7379ebeeb5399259580f Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Wed, 26 May 2021 18:54:20 +0000 Subject: [PATCH 14/28] add more definitions Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 442 +++++++++++++++++++++++++++++++--- 1 file changed, 412 insertions(+), 30 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 2802bd52b..4baf8f5a8 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -43,6 +43,17 @@ class YCableBase(object): SWITCHING_MODE_MANUAL = 0 SWITCHING_MODE_AUTO = 1 + # definitions of the fec mode to be configured + # on a port/cable + FEC_MODE_NONE, + FEC_MODE_RS, + FEC_MODE_FC + + # definitions of the modes to be run for loopback mode + # on the port/cable + LOOPBACK_MODE_NEAR_END + LOOPBACK_MODE_FAR_END + # Valid return codes for upgrade firmware routine steps FIRMWARE_DOWNLOAD_SUCCESS = 0 FIRMWARE_DOWNLOAD_FAILURE = 1 @@ -61,7 +72,7 @@ def __init__(self, port): def toggle_mux_to_tor_a(self): """ - This API specifically does a hard switch toggle of the Y cable's MUX regardless of link state to + This API does a hard switch toggle of the Y cable's MUX regardless of link state to TOR A on the port this is called for. This means if the Y cable is actively sending traffic, the "get_active_linked_tor_side" API will now return Tor A. It also implies that if the link is actively sending traffic on this port, @@ -79,7 +90,7 @@ def toggle_mux_to_tor_a(self): def toggle_mux_to_tor_b(self): """ - This API specifically does a hard switch toggle of the Y cable's MUX regardless of link state to + This API does a hard switch toggle of the Y cable's MUX regardless of link state to TOR B. This means if the Y cable is actively sending traffic, the "get_active_linked_tor_side" API will now return Tor B. It also implies that if the link is actively sending traffic on this port, Y cable. MUX will start forwarding packets from TOR B to NIC, and drop packets from TOR A to NIC @@ -95,7 +106,7 @@ def toggle_mux_to_tor_b(self): def get_read_side(self): """ - This API specifically checks which side of the Y cable the reads are actually getting performed + This API checks which side of the Y cable the reads are actually getting performed from, either TOR A or TOR B or NIC and returns the value. The port on which this API is called for can be referred using self.port. @@ -113,7 +124,7 @@ def get_read_side(self): def get_mux_direction(self): """ - This API specifically checks which side of the Y cable mux is currently point to + This API checks which side of the Y cable mux is currently point to and returns either TOR A or TOR B. Note that this API should return mux-direction regardless of whether the link is active and sending traffic or not. The port on which this API is called for can be referred using self.port. @@ -131,7 +142,7 @@ def get_mux_direction(self): def get_active_linked_tor_side(self): """ - This API specifically checks which side of the Y cable is actively linked and sending traffic + This API checks which side of the Y cable is actively linked and sending traffic and returns either TOR A or TOR B. The port on which this API is called for can be referred using self.port. This is different from get_mux_direction in a sense it also implies the link on the side @@ -151,7 +162,7 @@ def get_active_linked_tor_side(self): def is_link_active(self, target): """ - This API specifically checks if NIC, TOR_A and TOR_B of the Y cable's link is active. + This API checks if NIC, TOR_A and TOR_B of the Y cable's link is active. The target specifies which link is supposed to be checked The port on which this API is called for can be referred using self.port. @@ -171,7 +182,7 @@ def is_link_active(self, target): def get_eye_info(self, target): """ - This API specifically returns the EYE height value for a specfic port. + This API returns the EYE height value for a specfic port. The target could be local side, TOR_A, TOR_B, NIC etc. The port on which this API is called for can be referred using self.port. @@ -190,7 +201,7 @@ def get_eye_info(self, target): def get_ber_info(self, target): """ - This API specifically returns the BER (Bit error rate) value for a specfic port. + This API returns the BER (Bit error rate) value for a specfic port. The target could be local side, TOR_A, TOR_B, NIC etc. The port on which this API is called for can be referred using self.port. @@ -209,7 +220,7 @@ def get_ber_info(self, target): def get_vendor(self): """ - This API specifically returns the vendor name of the Y cable for a specfic port. + This API returns the vendor name of the Y cable for a specfic port. The port on which this API is called for can be referred using self.port. Args: @@ -222,7 +233,7 @@ def get_vendor(self): def get_part_number(self): """ - This API specifically returns the part number of the Y cable for a specfic port. + This API returns the part number of the Y cable for a specfic port. The port on which this API is called for can be referred using self.port. Args: @@ -233,17 +244,80 @@ def get_part_number(self): raise NotImplementedError - def get_switch_count(self, count_type): + def get_switch_count_total(self, switch_count_type, clear_on_read=False): + """ + This API returns the total switch count to change the Active TOR which has + been done manually/automatic by the user. + The port on which this API is called for can be referred using self.port. + + Args: + switch_count_type: + One of the following predefined constants, for getting the count type: + SWITCH_COUNT_MANUAL -> manual switch count + SWITCH_COUNT_AUTO -> automatic switch count + clear_on_read: + a boolean, True if the count has to be reset after read to zero + , False if the count is not to be reset after read + Returns: + an integer, the number of times the Y-cable has been switched + """ + + raise NotImplementedError + + def get_switch_count_tor_a(self, clear_on_read=False): + """ + This API returns the switch count to change the Active TOR which has + been done manually by the user initiated from ToR A + The port on which this API is called for can be referred using self.port. + + Args: + clear_on_read: + a boolean, True if the count has to be reset after read to zero + , False if the count is not to be reset after read + + Returns: + an integer, the number of times the Y-cable has been switched from ToR A + """ + + raise NotImplementedError + + def get_switch_count_tor_b(self, clear_on_read=False): + """ + This API returns the switch count to change the Active TOR which has + been done manually by the user initiated from ToR B + The port on which this API is called for can be referred using self.port. + + Args: + clear_on_read: + a boolean, True if the count has to be reset after read to zero + , False if the count is not to be reset after read + + Returns: + an integer, the number of times the Y-cable has been switched from ToR B + """ + + raise NotImplementedError + + def get_switch_count_target(self, switch_count_type, target, clear_on_read=False): """ - This API specifically returns the switch count to change the Active TOR which has - been done manually by the user. + This API returns the total number of times the Active TOR has + been done manually/automaticlly toggled towards a target. + For example, TARGET_TOR_A as target would imply + how many times the mux has been toggled towards TOR A. The port on which this API is called for can be referred using self.port. Args: - count_type: + switch_count_type: One of the following predefined constants, for getting the count type: SWITCH_COUNT_MANUAL -> manual switch count SWITCH_COUNT_AUTO -> automatic switch count + target: + One of the following predefined constants, the actual target to check the link on: + TARGET_TOR_A-> TORA, + TARGET_TOR_B -> TORB + clear_on_read: + a boolean, True if the count has to be reset after read to zero + , False if the count is not to be reset after read Returns: an integer, the number of times manually the Y-cable has been switched """ @@ -252,7 +326,7 @@ def get_switch_count(self, count_type): def get_target_cursor_values(self, lane, target): """ - This API specifically returns the cursor equalization parameters for a target(NIC, TOR_A, TOR_B). + This API returns the cursor equalization parameters for a target(NIC, TOR_A, TOR_B). This includes pre one, pre two , main, post one, post two cursor values The port on which this API is called for can be referred using self.port. @@ -274,6 +348,33 @@ def get_target_cursor_values(self, lane, target): raise NotImplementedError + def set_target_cursor_values(self, lane, cursor_values, target): + """ + This API sets the cursor equalization parameters for a target(NIC, TOR_A, TOR_B). + This includes pre one, pre two , main, post one, post two etc. cursor values + The port on which this API is called for can be referred using self.port. + + Args: + lane: + an Integer, the lane on which to collect the cursor values + 1 -> lane 1, + 2 -> lane 2 + 3 -> lane 3 + 4 -> lane 4 + cursor_values: + a list, with pre one, pre two , main, post one, post two cursor etc. values in the order + target: + One of the following predefined constants, the actual target to get the cursor values on: + TARGET_NIC -> NIC, + TARGET_TOR_A-> TORA, + TARGET_TOR_B -> TORB + Returns: + a boolean, True if cursor values setting is successful + , False if cursor values setting is not successful + """ + + raise NotImplementedError + def get_firmware_version(self, target): """ This routine should return the active, inactive and next (committed) @@ -379,7 +480,7 @@ def rollback_firmware(self): def set_switching_mode(self, mode): """ - This API specifically enables the auto switching or manual switching feature on the Y-Cable, + This API enables the auto switching or manual switching feature on the Y-Cable, depending upon the mode entered by the user. Autoswitch feature if enabled actually does an automatic toggle of the mux in case the active side link goes down and basically points the mux to the other side. @@ -402,7 +503,7 @@ def set_switching_mode(self, mode): def get_switching_mode(self): """ - This API specifically returns which type of switching mode the cable is set to auto/manual + This API returns which type of switching mode the cable is set to auto/manual The port on which this API is called for can be referred using self.port. Args: @@ -417,7 +518,7 @@ def get_switching_mode(self): def get_nic_temperature(self): """ - This API specifically returns nic temperature of the physical port for which this API is called. + This API returns nic temperature of the physical port for which this API is called. The port on which this API is called for can be referred using self.port. Args: @@ -430,7 +531,7 @@ def get_nic_temperature(self): def get_local_temperature(self): """ - This API specifically returns local ToR temperature of the physical port for which this API is called. + This API returns local ToR temperature of the physical port for which this API is called. The port on which this API is called for can be referred using self.port. Args: @@ -443,7 +544,7 @@ def get_local_temperature(self): def get_nic_voltage(self): """ - This API specifically returns nic voltage of the physical port for which this API is called. + This API returns nic voltage of the physical port for which this API is called. The port on which this API is called for can be referred using self.port. Args: @@ -456,7 +557,7 @@ def get_nic_voltage(self): def get_local_voltage(self): """ - This API specifically returns local ToR voltage of the physical port for which this API is called. + This API returns local ToR voltage of the physical port for which this API is called. The port on which this API is called for can be referred using self.port. Args: @@ -467,15 +568,270 @@ def get_local_voltage(self): raise NotImplementedError + def get_alive_status(self): + """ + This API checks if cable is connected to all the ports and is healthy. + The port on which this API is called for can be referred using self.port. + + Args: + + Returns: + a boolean, True if the cable is alive + , False if the cable is not alive + """ + + raise NotImplementedError + + def reset(self, target): + """ + This API resets the MCU to which this API is called for. + The target specifies which MCU is supposed to be reset + The port on which this API is called for can be referred using self.port. + + Args: + target: + One of the following predefined constants, the actual target to check the link on: + TARGET_NIC -> NIC, + TARGET_TOR_A-> TORA, + TARGET_TOR_B -> TORB + + Returns: + a boolean, True if the cable is target reset + , False if the cable target is not reset + """ + + raise NotImplementedError + + def create_port(self, speed, fec_mode=FEC_MODE_NONE, anlt=False): + """ + This API sets the mode of the cable/port for corresponding lane/fec etc. configuration as specified. + The speed specifies which mode is supposed to be set 50G, 100G etc + the anlt specifies if auto-negotiation + link training (AN/LT) has to be enabled + The port on which this API is called for can be referred using self.port. + + Args: + speed: + an Integer, the value for the link speed to be configured (in megabytes). + examples: + 50000 -> 50G + 100000 -> 100G + + fec_mode: + One of the following predefined constants, the actual fec mode for the port to be configured: + FEC_MODE_NONE, + FEC_MODE_RS, + FEC_MODE_FC + + anlt: + a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled + , False if auto-negotiation + link training (AN/LT) is not to be enabled + + + Returns: + a boolean, True if the port is configured + , False if the port is not configured + """ + + raise NotImplementedError + + def get_speed(self): + """ + This API gets the mode of the cable for corresponding lane configuration. + The port on which this API is called for can be referred using self.port. + + Args: + + Returns: + speed: + an Integer, the value for the link speed is configured (in megabytes). + examples: + 50000 -> 50G + 100000 -> 100G + """ + + raise NotImplementedError + + def set_fec_mode(self, fec_mode): + """ + This API gets the fec mode of the cable for which it is set to. + The port on which this API is called for can be referred using self.port. + + Args: + fec_mode: + One of the following predefined constants, the actual fec mode for the port to be configured: + FEC_MODE_NONE, + FEC_MODE_RS, + FEC_MODE_FC + + + Returns: + a boolean, True if the fec mode is configured + , False if the fec mode is not configured + """ + + raise NotImplementedError + + def get_fec_mode(self): + """ + This API gets the fec mode of the cable which it is set to. + The port on which this API is called for can be referred using self.port. + + Args: + + Returns: + fec_mode: + One of the following predefined constants, the actual fec mode for the port to be configured: + FEC_MODE_NONE, + FEC_MODE_RS, + FEC_MODE_FC + """ + + raise NotImplementedError + + def set_anlt(self, enable): + """ + This API enables/disables the cable auto-negotiation + link training (AN/LT). + The port on which this API is called for can be referred using self.port. + + Args: + enable: + a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled + , False if auto-negotiation + link training (AN/LT) is not to be enabled + + + Returns: + a boolean, True if the auto-negotiation + link training (AN/LT) enable/disable specified is configured + , False if the auto-negotiation + link training (AN/LT) enable/disable specified is not configured + """ + + raise NotImplementedError + + def get_anlt(self): + """ + This API gets the mode of the cable for corresponding lane configuration. + The port on which this API is called for can be referred using self.port. + + Args: + + Returns: + a boolean, True if auto-negotiation + link training (AN/LT) is enabled + , False if auto-negotiation + link training (AN/LT) is not enabled + """ + + raise NotImplementedError + + def get_event_log(self, clear_on_read=False): + """ + This API returns the event log of the cable + The port on which this API is called for can be referred using self.port. + + Args: + clear_on_read: + a boolean, True if the log has to be cleared after read + , False if the log is not to be cleared after read + + Returns: + list: + a list of strings which correspond to the event logs of the cable + """ + + raise NotImplementedError + + def get_pcs_stats(self): + """ + This API returns the pcs statistics of the cable + The port on which this API is called for can be referred using self.port. + + Args: + + Returns: + a dictionary: + a detailed format agreed upon by vendors + """ + + raise NotImplementedError + + def get_fec_stats(self): + """ + This API returns the fec statistics of the cable + The port on which this API is called for can be referred using self.port. + + Args: + + Returns: + a dictionary: + a detailed format agreed upon by vendors + """ + + raise NotImplementedError + + def set_autoswitch_hysteresis_timer(self, time): + """ + This API sets the hysteresis timer of the cable. This is basically the time in auto-switch mode + which the mux has to wait after toggling it once, before again toggling the mux to a different ToR + The port on which this API is called for can be referred using self.port. + + Args: + time: + an Integer, the time value for hysteresis to be set in milliseconds + + Returns: + a boolean, True if the time is configured + , False if the time is not configured + """ + + raise NotImplementedError + + def get_autoswitch_hysteresis_timer(self): + """ + This API gets the hysteresis timer of the cable. This is basically the time in auto-switch mode + which the mux has to wait after toggling it once, before again toggling the mux to a different ToR + The port on which this API is called for can be referred using self.port. + + Args: + + Returns: + time: + an Integer, the time value for hysteresis is configured in milliseconds + """ + + raise NotImplementedError + + def restart_anlt(self): + """ + This API restarts auto-negotiation + link training (AN/LT) mode + The port on which this API is called for can be referred using self.port. + + Args: + + Returns: + a boolean, True if restart is successful + , False if the restart is not successful + """ + + raise NotImplementedError + + def get_anlt_stats(self): + """ + This API returns auto-negotiation + link training (AN/LT) mode statistics + The port on which this API is called for can be referred using self.port. + + Args: + + Returns: + a dictionary: + a detailed format agreed upon by vendors + """ + + raise NotImplementedError ############################################################################################# ### Debug Functionality ### ############################################################################################# - def set_debug_mode(self, enable): """ - This API specifically enables/disables a debug mode that the port is now + This API enables/disables a debug mode that the port is now going to be run on. If enabled, this means that PRBS/Loopback etc. type diagnostic mode is now going to be run on the port and hence normal traffic will be disabled on it if enabled and vice-versa if disabled. @@ -496,7 +852,7 @@ def set_debug_mode(self, enable): def get_debug_mode(self): """ - This API specifically checks if a debug mode is currently being run on the port + This API checks if a debug mode is currently being run on the port for which this API is called for. This means that PRBS/Loopback etc. type diagnostic mode if any are being run on the port this should return True else False. @@ -513,7 +869,7 @@ def get_debug_mode(self): def enable_prbs_mode(self, target, mode_value, lane_map): """ - This API specifically configures and enables the PRBS mode/type depending upon the mode_value the user provides. + This API configures and enables the PRBS mode/type depending upon the mode_value the user provides. The mode_value configures the PRBS Type for generation and BER sensing on a per side basis. Target is an integer for selecting which end of the Y cable we want to run PRBS on. LaneMap specifies the lane configuration to run the PRBS on. @@ -545,7 +901,7 @@ def enable_prbs_mode(self, target, mode_value, lane_map): def disable_prbs_mode(self, target): """ - This API specifically disables the PRBS mode on the physical port. + This API disables the PRBS mode on the physical port. The port on which this API is called for can be referred using self.port. Args: @@ -563,9 +919,9 @@ def disable_prbs_mode(self, target): raise NotImplementedError - def enable_loopback_mode(self, target, lane_map): + def enable_loopback_mode(self, target, mode=NEAR_END_LOOPBACK, lane_map): """ - This API specifically configures and enables the Loopback mode on the port user provides. + This API configures and enables the Loopback mode on the port user provides. Target is an integer for selecting which end of the Y cable we want to run loopback on. LaneMap specifies the lane configuration to run the loopback on. Note that this is a diagnostic mode command and must not run during normal traffic/switch operation @@ -578,6 +934,10 @@ def enable_loopback_mode(self, target, lane_map): EYE_PRBS_TARGET_TOR_A -> TOR A EYE_PRBS_TARGET_TOR_B -> TOR B EYE_PRBS_TARGET_NIC -> NIC + mode_value: + One of the following predefined constants, the mode to be run for loopback: + LOOPBACK_MODE_NEAR_END + LOOPBACK_MODE_FAR_END lane_map: an Integer, representing the lane_map to be run PRBS on 0bit for lane 0, 1bit for lane1 and so on. @@ -592,7 +952,7 @@ def enable_loopback_mode(self, target, lane_map): def disable_loopback_mode(self, target): """ - This API specifically disables the Loopback mode on the port user provides. + This API disables the Loopback mode on the port user provides. Target is an integer for selecting which end of the Y cable we want to run loopback on. The port on which this API is called for can be referred using self.port. @@ -611,10 +971,32 @@ def disable_loopback_mode(self, target): raise NotImplementedError + def get_loopback_mode(self, target): + """ + This API returns the Loopback mode on the port which it has been configured to + Target is an integer for selecting which end of the Y cable we want to run loopback on. + The port on which this API is called for can be referred using self.port. + + Args: + target: + One of the following predefined constants, the target on which to disable the loopback: + EYE_PRBS_TARGET_LOCAL -> local side, + EYE_PRBS_TARGET_TOR_A -> TOR A + EYE_PRBS_TARGET_TOR_B -> TOR B + EYE_PRBS_TARGET_NIC -> NIC + + Returns: + mode_value: + One of the following predefined constants, the mode to be run for loopback: + LOOPBACK_MODE_NEAR_END + LOOPBACK_MODE_FAR_END + """ + + raise NotImplementedError def debug_dump_registers(self): """ - This API specifically should dump all registers with meaningful values + This API should dump all registers with meaningful values for the cable to be diagnosed for proper functioning. This means that for all the fields on relevant vendor-specific pages this API should dump the appropriate fields with parsed values From e828a03d6eaac2ae04d186d64e35cd2c493e9cc6 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Thu, 27 May 2021 04:01:39 +0000 Subject: [PATCH 15/28] fix comments Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 4baf8f5a8..cf299088a 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -45,14 +45,14 @@ class YCableBase(object): # definitions of the fec mode to be configured # on a port/cable - FEC_MODE_NONE, - FEC_MODE_RS, - FEC_MODE_FC + FEC_MODE_NONE = 0 + FEC_MODE_RS = 1 + FEC_MODE_FC = 2 # definitions of the modes to be run for loopback mode # on the port/cable - LOOPBACK_MODE_NEAR_END - LOOPBACK_MODE_FAR_END + LOOPBACK_MODE_NEAR_END = 0 + LOOPBACK_MODE_FAR_END = 1 # Valid return codes for upgrade firmware routine steps FIRMWARE_DOWNLOAD_SUCCESS = 0 @@ -170,7 +170,7 @@ def is_link_active(self, target): target: One of the following predefined constants, the actual target to check the link on: TARGET_NIC -> NIC, - TARGET_TOR_A-> TORA, + TARGET_TOR_A -> TORA, TARGET_TOR_B -> TORB Returns: @@ -313,7 +313,7 @@ def get_switch_count_target(self, switch_count_type, target, clear_on_read=False SWITCH_COUNT_AUTO -> automatic switch count target: One of the following predefined constants, the actual target to check the link on: - TARGET_TOR_A-> TORA, + TARGET_TOR_A -> TORA, TARGET_TOR_B -> TORB clear_on_read: a boolean, True if the count has to be reset after read to zero @@ -340,7 +340,7 @@ def get_target_cursor_values(self, lane, target): target: One of the following predefined constants, the actual target to get the cursor values on: TARGET_NIC -> NIC, - TARGET_TOR_A-> TORA, + TARGET_TOR_A -> TORA, TARGET_TOR_B -> TORB Returns: a list, with pre one, pre two , main, post one, post two cursor values in the order @@ -366,7 +366,7 @@ def set_target_cursor_values(self, lane, cursor_values, target): target: One of the following predefined constants, the actual target to get the cursor values on: TARGET_NIC -> NIC, - TARGET_TOR_A-> TORA, + TARGET_TOR_A -> TORA, TARGET_TOR_B -> TORB Returns: a boolean, True if cursor values setting is successful @@ -386,7 +386,7 @@ def get_firmware_version(self, target): target: One of the following predefined constants, the actual target to get the firmware version on: TARGET_NIC -> NIC, - TARGET_TOR_A-> TORA, + TARGET_TOR_A -> TORA, TARGET_TOR_B -> TORB Returns: a Dictionary: @@ -592,7 +592,7 @@ def reset(self, target): target: One of the following predefined constants, the actual target to check the link on: TARGET_NIC -> NIC, - TARGET_TOR_A-> TORA, + TARGET_TOR_A -> TORA, TARGET_TOR_B -> TORB Returns: From 8f1018ece05ddc27df0cfdad6919d175ec6920a0 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Thu, 10 Jun 2021 20:23:37 +0000 Subject: [PATCH 16/28] fix more suggestions Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 215 +++++++++++++++++++++++++--------- 1 file changed, 158 insertions(+), 57 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index cf299088a..b02f72219 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -27,10 +27,10 @@ class YCableBase(object): # the name of the target denotes which side values # will be retreived/initiated - EYE_PRBS_TARGET_LOCAL = 0 - EYE_PRBS_TARGET_TOR_A = 1 - EYE_PRBS_TARGET_TOR_B = 2 - EYE_PRBS_TARGET_NIC = 3 + EYE_PRBS_LOOPBACK_TARGET_NIC = 0 + EYE_PRBS_LOOPBACK_TARGET_TOR_A = 1 + EYE_PRBS_LOOPBACK_TARGET_TOR_B = 2 + EYE_PRBS_LOOPBACK_TARGET_LOCAL = 3 # definitions of switch counter types # to be entered by the user in get_switch_count api @@ -62,6 +62,11 @@ class YCableBase(object): FIRMWARE_ROLLBACK_SUCCESS = 0 FIRMWARE_ROLLBACK_FAILURE = 1 + # definitions of PRBS run modes + PRBS_DIRECTION_BOTH = 0 + PRBS_DIRECTION_GENERATOR = 1 + PRBS_DIRECTION_CHECKER = 2 + def __init__(self, port): """ Args: @@ -180,7 +185,7 @@ def is_link_active(self, target): raise NotImplementedError - def get_eye_info(self, target): + def get_eye_heights(self, target): """ This API returns the EYE height value for a specfic port. The target could be local side, TOR_A, TOR_B, NIC etc. @@ -189,10 +194,10 @@ def get_eye_info(self, target): Args: target: One of the following predefined constants, the target on which to get the eye: - EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TOR_A -> TOR A - EYE_PRBS_TARGET_TOR_B -> TOR B - EYE_PRBS_TARGET_NIC -> NIC + EYE_PRBS_LOOPBACK_TARGET_LOCAL -> local side, + EYE_PRBS_LOOPBACK_TARGET_TOR_A -> TOR A + EYE_PRBS_LOOPBACK_TARGET_TOR_B -> TOR B + EYE_PRBS_LOOPBACK_TARGET_NIC -> NIC Returns: a list, with EYE values of lane 0 lane 1 lane 2 lane 3 with corresponding index """ @@ -208,10 +213,10 @@ def get_ber_info(self, target): Args: target: One of the following predefined constants, the target on which to get the BER: - EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TOR_A -> TOR A - EYE_PRBS_TARGET_TOR_B -> TOR B - EYE_PRBS_TARGET_NIC -> NIC + EYE_PRBS_LOOPBACK_TARGET_LOCAL -> local side, + EYE_PRBS_LOOPBACK_TARGET_TOR_A -> TOR A + EYE_PRBS_LOOPBACK_TARGET_TOR_B -> TOR B + EYE_PRBS_LOOPBACK_TARGET_NIC -> NIC Returns: a list, with BER values of lane 0 lane 1 lane 2 lane 3 with corresponding index """ @@ -268,6 +273,8 @@ def get_switch_count_tor_a(self, clear_on_read=False): """ This API returns the switch count to change the Active TOR which has been done manually by the user initiated from ToR A + This is essentially all the successful switches initiated from ToR A. Toggles which were + initiated to toggle from ToR A and did not succed do not count. The port on which this API is called for can be referred using self.port. Args: @@ -285,6 +292,8 @@ def get_switch_count_tor_b(self, clear_on_read=False): """ This API returns the switch count to change the Active TOR which has been done manually by the user initiated from ToR B + This is essentially all the successful switches initiated from ToR B. Toggles which were + initiated to toggle from ToR B and did not succed do not count. The port on which this API is called for can be referred using self.port. Args: @@ -327,7 +336,8 @@ def get_switch_count_target(self, switch_count_type, target, clear_on_read=False def get_target_cursor_values(self, lane, target): """ This API returns the cursor equalization parameters for a target(NIC, TOR_A, TOR_B). - This includes pre one, pre two , main, post one, post two cursor values + This includes pre one, pre two , main, post one, post two , post three cursor values + If any of the value is not available please return None for that filter The port on which this API is called for can be referred using self.port. Args: @@ -343,7 +353,7 @@ def get_target_cursor_values(self, lane, target): TARGET_TOR_A -> TORA, TARGET_TOR_B -> TORB Returns: - a list, with pre one, pre two , main, post one, post two cursor values in the order + a list, with pre one, pre two , main, post one, post two , post three cursor values in the order """ raise NotImplementedError @@ -362,7 +372,7 @@ def set_target_cursor_values(self, lane, cursor_values, target): 3 -> lane 3 4 -> lane 4 cursor_values: - a list, with pre one, pre two , main, post one, post two cursor etc. values in the order + a list, with pre one, pre two , main, post one, post two cursor, post three etc. values in the order target: One of the following predefined constants, the actual target to get the cursor values on: TARGET_NIC -> NIC, @@ -461,7 +471,7 @@ def activate_firmware(self, fwfile=None): raise NotImplementedError - def rollback_firmware(self): + def rollback_firmware(self, fwfile=None): """ This routine should rollback the firmware to the previous version which was being used by the cable. This API is intended to be called when the @@ -470,6 +480,20 @@ def rollback_firmware(self): The port on which this API is called for can be referred using self.port. Args: + fwfile (optional): + a string, a path to the file which contains the firmware image. + Note that the firmware file can be in the format of the vendor's + choosing (binary, archive, etc.). But note that it should be one file + which contains firmware for all components of the Y-cable. In case the + vendor chooses to pass this file in rollback_firmware, the API should + have the logic to retreive the firmware version from this file + which should not be activated on the components of the Y-Cable + this API has been called for. + If None is passed for fwfile, the cable should rollback whatever + firmware is marked to be rollback next. + If provided, it should retreive the firmware version(s) from this file, ensure + that the firmware is rollbacked to a version which does not match to retreived version(s). + This is exactly the opposite behavior of this param to activate_firmware Returns: One of the following predefined constants: FIRMWARE_ROLLBACK_SUCCESS @@ -602,11 +626,14 @@ def reset(self, target): raise NotImplementedError - def create_port(self, speed, fec_mode=FEC_MODE_NONE, anlt=False): + def create_port(self, speed, fec_mode_tor_a=FEC_MODE_NONE, fec_mode_tor_b=FEC_MODE_NONE, + fec_mode_nic=FEC_MODE_NONE, anlt_tor_a=False, anlt_tor_b= False, anlt_nic=False): """ This API sets the mode of the cable/port for corresponding lane/fec etc. configuration as specified. The speed specifies which mode is supposed to be set 50G, 100G etc the anlt specifies if auto-negotiation + link training (AN/LT) has to be enabled + Note that in case create_port is called multiple times, the most recent api call will take the precedence + on either of TOR side. The port on which this API is called for can be referred using self.port. Args: @@ -616,15 +643,35 @@ def create_port(self, speed, fec_mode=FEC_MODE_NONE, anlt=False): 50000 -> 50G 100000 -> 100G - fec_mode: - One of the following predefined constants, the actual fec mode for the port to be configured: + fec_mode_tor_a: + One of the following predefined constants, the actual fec mode for the tor A to be configured: FEC_MODE_NONE, FEC_MODE_RS, FEC_MODE_FC - anlt: - a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled - , False if auto-negotiation + link training (AN/LT) is not to be enabled + fec_mode_tor_b: + One of the following predefined constants, the actual fec mode for the tor B to be configured: + FEC_MODE_NONE, + FEC_MODE_RS, + FEC_MODE_FC + + fec_mode_nic: + One of the following predefined constants, the actual fec mode for the nic to be configured: + FEC_MODE_NONE, + FEC_MODE_RS, + FEC_MODE_FC + + anlt_tor_a: + a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled on tor A + , False if auto-negotiation + link training (AN/LT) is not to be enabled on tor A + + anlt_tor_b: + a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled on tor B + , False if auto-negotiation + link training (AN/LT) is not to be enabled on tor B + + anlt_nic: + a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled on nic + , False if auto-negotiation + link training (AN/LT) is not to be enabled on nic Returns: @@ -651,7 +698,7 @@ def get_speed(self): raise NotImplementedError - def set_fec_mode(self, fec_mode): + def set_fec_mode(self, fec_mode, target): """ This API gets the fec mode of the cable for which it is set to. The port on which this API is called for can be referred using self.port. @@ -662,6 +709,11 @@ def set_fec_mode(self, fec_mode): FEC_MODE_NONE, FEC_MODE_RS, FEC_MODE_FC + target: + One of the following predefined constants, the actual target to set the fec mode on: + TARGET_NIC -> NIC, + TARGET_TOR_A -> TORA, + TARGET_TOR_B -> TORB Returns: @@ -671,12 +723,17 @@ def set_fec_mode(self, fec_mode): raise NotImplementedError - def get_fec_mode(self): + def get_fec_mode(self, target): """ This API gets the fec mode of the cable which it is set to. The port on which this API is called for can be referred using self.port. Args: + target: + One of the following predefined constants, the actual target to fec mode on: + TARGET_NIC -> NIC, + TARGET_TOR_A -> TORA, + TARGET_TOR_B -> TORB Returns: fec_mode: @@ -688,7 +745,7 @@ def get_fec_mode(self): raise NotImplementedError - def set_anlt(self, enable): + def set_anlt(self, enable, target): """ This API enables/disables the cable auto-negotiation + link training (AN/LT). The port on which this API is called for can be referred using self.port. @@ -697,6 +754,11 @@ def set_anlt(self, enable): enable: a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled , False if auto-negotiation + link training (AN/LT) is not to be enabled + target: + One of the following predefined constants, the actual target to get the stats on: + TARGET_NIC -> NIC, + TARGET_TOR_A -> TORA, + TARGET_TOR_B -> TORB Returns: @@ -706,12 +768,17 @@ def set_anlt(self, enable): raise NotImplementedError - def get_anlt(self): + def get_anlt(self, target): """ This API gets the mode of the cable for corresponding lane configuration. The port on which this API is called for can be referred using self.port. Args: + target: + One of the following predefined constants, the actual target to get the anlt on: + TARGET_NIC -> NIC, + TARGET_TOR_A -> TORA, + TARGET_TOR_B -> TORB Returns: a boolean, True if auto-negotiation + link training (AN/LT) is enabled @@ -737,12 +804,17 @@ def get_event_log(self, clear_on_read=False): raise NotImplementedError - def get_pcs_stats(self): + def get_pcs_stats(self, target): """ This API returns the pcs statistics of the cable The port on which this API is called for can be referred using self.port. Args: + target: + One of the following predefined constants, the actual target to get the stats on: + TARGET_NIC -> NIC, + TARGET_TOR_A -> TORA, + TARGET_TOR_B -> TORB Returns: a dictionary: @@ -751,12 +823,17 @@ def get_pcs_stats(self): raise NotImplementedError - def get_fec_stats(self): + def get_fec_stats(self, target): """ This API returns the fec statistics of the cable The port on which this API is called for can be referred using self.port. Args: + target: + One of the following predefined constants, the actual target to get the stats on: + TARGET_NIC -> NIC, + TARGET_TOR_A -> TORA, + TARGET_TOR_B -> TORB Returns: a dictionary: @@ -803,6 +880,11 @@ def restart_anlt(self): The port on which this API is called for can be referred using self.port. Args: + target: + One of the following predefined constants, the actual target to restart anlt on: + TARGET_NIC -> NIC, + TARGET_TOR_A -> TORA, + TARGET_TOR_B -> TORB Returns: a boolean, True if restart is successful @@ -811,12 +893,17 @@ def restart_anlt(self): raise NotImplementedError - def get_anlt_stats(self): + def get_anlt_stats(self, target): """ This API returns auto-negotiation + link training (AN/LT) mode statistics The port on which this API is called for can be referred using self.port. Args: + target: + One of the following predefined constants, the actual target to get anlt stats on: + TARGET_NIC -> NIC, + TARGET_TOR_A -> TORA, + TARGET_TOR_B -> TORB Returns: a dictionary: @@ -835,6 +922,10 @@ def set_debug_mode(self, enable): going to be run on. If enabled, this means that PRBS/Loopback etc. type diagnostic mode is now going to be run on the port and hence normal traffic will be disabled on it if enabled and vice-versa if disabled. + enable is typically to be used at the software level to inform the software + that debug APIs will be called afterwords. + disable will disable any previously enabled debug functionality inside the cable + so that traffic can pass through. Also it'll inform the software to come out of the debug mode. The port on which this API is called for can be referred using self.port. Args: @@ -867,7 +958,7 @@ def get_debug_mode(self): raise NotImplementedError - def enable_prbs_mode(self, target, mode_value, lane_map): + def enable_prbs_mode(self, target, mode_value, lane_mask, direction=PRBS_DIRECTION_BOTH): """ This API configures and enables the PRBS mode/type depending upon the mode_value the user provides. The mode_value configures the PRBS Type for generation and BER sensing on a per side basis. @@ -879,17 +970,22 @@ def enable_prbs_mode(self, target, mode_value, lane_map): Args: target: One of the following predefined constants, the target on which to enable the PRBS: - EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TOR_A -> TOR A - EYE_PRBS_TARGET_TOR_B -> TOR B - EYE_PRBS_TARGET_NIC -> NIC + EYE_PRBS_LOOPBACK_TARGET_LOCAL -> local side, + EYE_PRBS_LOOPBACK_TARGET_TOR_A -> TOR A + EYE_PRBS_LOOPBACK_TARGET_TOR_B -> TOR B + EYE_PRBS_LOOPBACK_TARGET_NIC -> NIC mode_value: an Integer, the mode/type for configuring the PRBS mode. - lane_map: - an Integer, representing the lane_map to be run PRBS on + lane_mask: + an Integer, representing the lane_mask to be run PRBS on 0bit for lane 0, 1bit for lane1 and so on. for example 3 -> 0b'0011 , means running on lane0 and lane1 + direction: + One of the following predefined constants, the direction to run the PRBS: + PRBS_DIRECTION_BOTH + PRBS_DIRECTION_GENERATOR + PRBS_DIRECTION_CHECKER Returns: a boolean, True if the enable is successful @@ -899,7 +995,7 @@ def enable_prbs_mode(self, target, mode_value, lane_map): raise NotImplementedError - def disable_prbs_mode(self, target): + def disable_prbs_mode(self, target, direction=PRBS_DIRECTION_BOTH): """ This API disables the PRBS mode on the physical port. The port on which this API is called for can be referred using self.port. @@ -907,10 +1003,15 @@ def disable_prbs_mode(self, target): Args: target: One of the following predefined constants, the target on which to disable the PRBS: - EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TOR_A -> TOR A - EYE_PRBS_TARGET_TOR_B -> TOR B - EYE_PRBS_TARGET_NIC -> NIC + EYE_PRBS_LOOPBACK_TARGET_LOCAL -> local side, + EYE_PRBS_LOOPBACK_TARGET_TOR_A -> TOR A + EYE_PRBS_LOOPBACK_TARGET_TOR_B -> TOR B + EYE_PRBS_LOOPBACK_TARGET_NIC -> NIC + direction: + One of the following predefined constants, the direction to run the PRBS: + PRBS_DIRECTION_BOTH + PRBS_DIRECTION_GENERATOR + PRBS_DIRECTION_CHECKER Returns: a boolean, True if the disable is successful @@ -919,7 +1020,7 @@ def disable_prbs_mode(self, target): raise NotImplementedError - def enable_loopback_mode(self, target, mode=NEAR_END_LOOPBACK, lane_map): + def enable_loopback_mode(self, target, mode=NEAR_END_LOOPBACK, lane_mask): """ This API configures and enables the Loopback mode on the port user provides. Target is an integer for selecting which end of the Y cable we want to run loopback on. @@ -930,16 +1031,16 @@ def enable_loopback_mode(self, target, mode=NEAR_END_LOOPBACK, lane_map): Args: target: One of the following predefined constants, the target on which to enable the loopback: - EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TOR_A -> TOR A - EYE_PRBS_TARGET_TOR_B -> TOR B - EYE_PRBS_TARGET_NIC -> NIC + EYE_PRBS_LOOPBACK_TARGET_LOCAL -> local side, + EYE_PRBS_LOOPBACK_TARGET_TOR_A -> TOR A + EYE_PRBS_LOOPBACK_TARGET_TOR_B -> TOR B + EYE_PRBS_LOOPBACK_TARGET_NIC -> NIC mode_value: One of the following predefined constants, the mode to be run for loopback: LOOPBACK_MODE_NEAR_END LOOPBACK_MODE_FAR_END - lane_map: - an Integer, representing the lane_map to be run PRBS on + lane_mask: + an Integer, representing the lane_mask to be run loopback on 0bit for lane 0, 1bit for lane1 and so on. for example 3 -> 0b'0011 , means running on lane0 and lane1 @@ -959,10 +1060,10 @@ def disable_loopback_mode(self, target): Args: target: One of the following predefined constants, the target on which to disable the loopback: - EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TOR_A -> TOR A - EYE_PRBS_TARGET_TOR_B -> TOR B - EYE_PRBS_TARGET_NIC -> NIC + EYE_PRBS_LOOPBACK_TARGET_LOCAL -> local side, + EYE_PRBS_LOOPBACK_TARGET_TOR_A -> TOR A + EYE_PRBS_LOOPBACK_TARGET_TOR_B -> TOR B + EYE_PRBS_LOOPBACK_TARGET_NIC -> NIC Returns: a boolean, True if the disable is successful @@ -980,10 +1081,10 @@ def get_loopback_mode(self, target): Args: target: One of the following predefined constants, the target on which to disable the loopback: - EYE_PRBS_TARGET_LOCAL -> local side, - EYE_PRBS_TARGET_TOR_A -> TOR A - EYE_PRBS_TARGET_TOR_B -> TOR B - EYE_PRBS_TARGET_NIC -> NIC + EYE_PRBS_LOOPBACK_TARGET_LOCAL -> local side, + EYE_PRBS_LOOPBACK_TARGET_TOR_A -> TOR A + EYE_PRBS_LOOPBACK_TARGET_TOR_B -> TOR B + EYE_PRBS_LOOPBACK_TARGET_NIC -> NIC Returns: mode_value: From 9dabc5c7c857697448b51eba1b54ed4236a8940b Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Tue, 15 Jun 2021 05:43:07 +0000 Subject: [PATCH 17/28] fix comments Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 109 ++++++++++++++++++---------------- 1 file changed, 59 insertions(+), 50 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index b02f72219..c19b4ac24 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -43,7 +43,7 @@ class YCableBase(object): SWITCHING_MODE_MANUAL = 0 SWITCHING_MODE_AUTO = 1 - # definitions of the fec mode to be configured + # definitions of the FEC mode to be configured # on a port/cable FEC_MODE_NONE = 0 FEC_MODE_RS = 1 @@ -204,24 +204,6 @@ def get_eye_heights(self, target): raise NotImplementedError - def get_ber_info(self, target): - """ - This API returns the BER (Bit error rate) value for a specfic port. - The target could be local side, TOR_A, TOR_B, NIC etc. - The port on which this API is called for can be referred using self.port. - - Args: - target: - One of the following predefined constants, the target on which to get the BER: - EYE_PRBS_LOOPBACK_TARGET_LOCAL -> local side, - EYE_PRBS_LOOPBACK_TARGET_TOR_A -> TOR A - EYE_PRBS_LOOPBACK_TARGET_TOR_B -> TOR B - EYE_PRBS_LOOPBACK_TARGET_NIC -> NIC - Returns: - a list, with BER values of lane 0 lane 1 lane 2 lane 3 with corresponding index - """ - - raise NotImplementedError def get_vendor(self): """ @@ -274,7 +256,7 @@ def get_switch_count_tor_a(self, clear_on_read=False): This API returns the switch count to change the Active TOR which has been done manually by the user initiated from ToR A This is essentially all the successful switches initiated from ToR A. Toggles which were - initiated to toggle from ToR A and did not succed do not count. + initiated to toggle from ToR A and did not succeed do not count. The port on which this API is called for can be referred using self.port. Args: @@ -293,7 +275,7 @@ def get_switch_count_tor_b(self, clear_on_read=False): This API returns the switch count to change the Active TOR which has been done manually by the user initiated from ToR B This is essentially all the successful switches initiated from ToR B. Toggles which were - initiated to toggle from ToR B and did not succed do not count. + initiated to toggle from ToR B and did not succeed do not count. The port on which this API is called for can be referred using self.port. Args: @@ -336,7 +318,7 @@ def get_switch_count_target(self, switch_count_type, target, clear_on_read=False def get_target_cursor_values(self, lane, target): """ This API returns the cursor equalization parameters for a target(NIC, TOR_A, TOR_B). - This includes pre one, pre two , main, post one, post two , post three cursor values + This includes pre one, pre two, main, post one, post two, post three cursor values If any of the value is not available please return None for that filter The port on which this API is called for can be referred using self.port. @@ -353,7 +335,7 @@ def get_target_cursor_values(self, lane, target): TARGET_TOR_A -> TORA, TARGET_TOR_B -> TORB Returns: - a list, with pre one, pre two , main, post one, post two , post three cursor values in the order + a list, with pre one, pre two, main, post one, post two, post three cursor values in the order """ raise NotImplementedError @@ -361,7 +343,7 @@ def get_target_cursor_values(self, lane, target): def set_target_cursor_values(self, lane, cursor_values, target): """ This API sets the cursor equalization parameters for a target(NIC, TOR_A, TOR_B). - This includes pre one, pre two , main, post one, post two etc. cursor values + This includes pre one, pre two, main, post one, post two etc. cursor values The port on which this API is called for can be referred using self.port. Args: @@ -372,7 +354,7 @@ def set_target_cursor_values(self, lane, cursor_values, target): 3 -> lane 3 4 -> lane 4 cursor_values: - a list, with pre one, pre two , main, post one, post two cursor, post three etc. values in the order + a list, with pre one, pre two, main, post one, post two cursor, post three etc. values in the order target: One of the following predefined constants, the actual target to get the cursor values on: TARGET_NIC -> NIC, @@ -438,7 +420,7 @@ def download_firmware(self, fwfile): raise NotImplementedError - def activate_firmware(self, fwfile=None): + def activate_firmware(self, fwfile=None, hitless=False): """ This routine should activate the downloaded firmware on all the components of the Y cable of the port for which this API is called.. @@ -463,6 +445,13 @@ def activate_firmware(self, fwfile=None): firmware is marked to be activated next. If provided, it should retreive the firmware version(s) from this file, ensure they are downloaded on the cable, then activate them. + + hitless (optional): + a boolean, True, Hitless upgrade: it will backup/restore the current state + (ex. variables of link status, API attributes...etc.) before + and after firmware upgrade. + a boolean, False, Non-hitless upgrade: it will update the firmware regardless + the current status, a link flip can be observed during the upgrade. Returns: One of the following predefined constants: FIRMWARE_ACTIVATE_SUCCESS @@ -629,9 +618,9 @@ def reset(self, target): def create_port(self, speed, fec_mode_tor_a=FEC_MODE_NONE, fec_mode_tor_b=FEC_MODE_NONE, fec_mode_nic=FEC_MODE_NONE, anlt_tor_a=False, anlt_tor_b= False, anlt_nic=False): """ - This API sets the mode of the cable/port for corresponding lane/fec etc. configuration as specified. + This API sets the mode of the cable/port for corresponding lane/FEC etc. configuration as specified. The speed specifies which mode is supposed to be set 50G, 100G etc - the anlt specifies if auto-negotiation + link training (AN/LT) has to be enabled + the AN/LT specifies if auto-negotiation + link training (AN/LT) has to be enabled Note that in case create_port is called multiple times, the most recent api call will take the precedence on either of TOR side. The port on which this API is called for can be referred using self.port. @@ -644,30 +633,30 @@ def create_port(self, speed, fec_mode_tor_a=FEC_MODE_NONE, fec_mode_tor_b=FEC_MO 100000 -> 100G fec_mode_tor_a: - One of the following predefined constants, the actual fec mode for the tor A to be configured: + One of the following predefined constants, the actual FEC mode for the ToR A to be configured: FEC_MODE_NONE, FEC_MODE_RS, FEC_MODE_FC fec_mode_tor_b: - One of the following predefined constants, the actual fec mode for the tor B to be configured: + One of the following predefined constants, the actual FEC mode for the ToR B to be configured: FEC_MODE_NONE, FEC_MODE_RS, FEC_MODE_FC fec_mode_nic: - One of the following predefined constants, the actual fec mode for the nic to be configured: + One of the following predefined constants, the actual FEC mode for the nic to be configured: FEC_MODE_NONE, FEC_MODE_RS, FEC_MODE_FC anlt_tor_a: - a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled on tor A - , False if auto-negotiation + link training (AN/LT) is not to be enabled on tor A + a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled on ToR A + , False if auto-negotiation + link training (AN/LT) is not to be enabled on ToR A anlt_tor_b: - a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled on tor B - , False if auto-negotiation + link training (AN/LT) is not to be enabled on tor B + a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled on ToR B + , False if auto-negotiation + link training (AN/LT) is not to be enabled on ToR B anlt_nic: a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled on nic @@ -700,44 +689,44 @@ def get_speed(self): def set_fec_mode(self, fec_mode, target): """ - This API gets the fec mode of the cable for which it is set to. + This API gets the FEC mode of the cable for which it is set to. The port on which this API is called for can be referred using self.port. Args: fec_mode: - One of the following predefined constants, the actual fec mode for the port to be configured: + One of the following predefined constants, the actual FEC mode for the port to be configured: FEC_MODE_NONE, FEC_MODE_RS, FEC_MODE_FC target: - One of the following predefined constants, the actual target to set the fec mode on: + One of the following predefined constants, the actual target to set the FEC mode on: TARGET_NIC -> NIC, TARGET_TOR_A -> TORA, TARGET_TOR_B -> TORB Returns: - a boolean, True if the fec mode is configured - , False if the fec mode is not configured + a boolean, True if the FEC mode is configured + , False if the FEC mode is not configured """ raise NotImplementedError def get_fec_mode(self, target): """ - This API gets the fec mode of the cable which it is set to. + This API gets the FEC mode of the cable which it is set to. The port on which this API is called for can be referred using self.port. Args: target: - One of the following predefined constants, the actual target to fec mode on: + One of the following predefined constants, the actual target to FEC mode on: TARGET_NIC -> NIC, TARGET_TOR_A -> TORA, TARGET_TOR_B -> TORB Returns: fec_mode: - One of the following predefined constants, the actual fec mode for the port to be configured: + One of the following predefined constants, the actual FEC mode for the port to be configured: FEC_MODE_NONE, FEC_MODE_RS, FEC_MODE_FC @@ -770,12 +759,12 @@ def set_anlt(self, enable, target): def get_anlt(self, target): """ - This API gets the mode of the cable for corresponding lane configuration. + This API gets the auto-negotiation + link training (AN/LT) mode of the cable for corresponding port. The port on which this API is called for can be referred using self.port. Args: target: - One of the following predefined constants, the actual target to get the anlt on: + One of the following predefined constants, the actual target to get the AN/LT on: TARGET_NIC -> NIC, TARGET_TOR_A -> TORA, TARGET_TOR_B -> TORB @@ -825,7 +814,7 @@ def get_pcs_stats(self, target): def get_fec_stats(self, target): """ - This API returns the fec statistics of the cable + This API returns the FEC statistics of the cable The port on which this API is called for can be referred using self.port. Args: @@ -881,7 +870,7 @@ def restart_anlt(self): Args: target: - One of the following predefined constants, the actual target to restart anlt on: + One of the following predefined constants, the actual target to restart AN/LT on: TARGET_NIC -> NIC, TARGET_TOR_A -> TORA, TARGET_TOR_B -> TORB @@ -900,7 +889,7 @@ def get_anlt_stats(self, target): Args: target: - One of the following predefined constants, the actual target to get anlt stats on: + One of the following predefined constants, the actual target to get AN/LT stats on: TARGET_NIC -> NIC, TARGET_TOR_A -> TORA, TARGET_TOR_B -> TORB @@ -980,7 +969,7 @@ def enable_prbs_mode(self, target, mode_value, lane_mask, direction=PRBS_DIRECTI lane_mask: an Integer, representing the lane_mask to be run PRBS on 0bit for lane 0, 1bit for lane1 and so on. - for example 3 -> 0b'0011 , means running on lane0 and lane1 + for example 3 -> 0b'0011, means running on lane0 and lane1 direction: One of the following predefined constants, the direction to run the PRBS: PRBS_DIRECTION_BOTH @@ -1042,7 +1031,7 @@ def enable_loopback_mode(self, target, mode=NEAR_END_LOOPBACK, lane_mask): lane_mask: an Integer, representing the lane_mask to be run loopback on 0bit for lane 0, 1bit for lane1 and so on. - for example 3 -> 0b'0011 , means running on lane0 and lane1 + for example 3 -> 0b'0011, means running on lane0 and lane1 Returns: a boolean, True if the enable is successful @@ -1095,6 +1084,26 @@ def get_loopback_mode(self, target): raise NotImplementedError + def get_ber_info(self, target): + """ + This API returns the BER (Bit error rate) value for a specfic port. + The target could be local side, TOR_A, TOR_B, NIC etc. + The port on which this API is called for can be referred using self.port. + + Args: + target: + One of the following predefined constants, the target on which to get the BER: + EYE_PRBS_LOOPBACK_TARGET_LOCAL -> local side, + EYE_PRBS_LOOPBACK_TARGET_TOR_A -> TOR A + EYE_PRBS_LOOPBACK_TARGET_TOR_B -> TOR B + EYE_PRBS_LOOPBACK_TARGET_NIC -> NIC + Returns: + a list, with BER values of lane 0 lane 1 lane 2 lane 3 with corresponding index + """ + + raise NotImplementedError + + def debug_dump_registers(self): """ This API should dump all registers with meaningful values From 5fcd0b230d2307b531979287d9c0f86408432e57 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Thu, 17 Jun 2021 13:49:22 +0000 Subject: [PATCH 18/28] push suggestion Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index c19b4ac24..9724ee16c 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -1104,7 +1104,7 @@ def get_ber_info(self, target): raise NotImplementedError - def debug_dump_registers(self): + def debug_dump_registers(self, option=None): """ This API should dump all registers with meaningful values for the cable to be diagnosed for proper functioning. @@ -1113,6 +1113,13 @@ def debug_dump_registers(self): which would help debug the Y-Cable Args: + option: + a string, the option param can be a string which if passed can help a vendor utilize it + as an input param or a concatenation of params for a function which they can call internally. + This essentially helps if the vendor chooses to dump only some of the registers instead of all + the registers, and thus provides more granularity for debugging/printing. + For example, the option can serdes_lane0, in this case the vendor would just dump + registers related to serdes lane 0. Returns: a Dictionary: From ab18d5f0ec9a04656cf54e0c3ddd5b806fec8557 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Fri, 18 Jun 2021 20:18:46 +0000 Subject: [PATCH 19/28] add more suggest/comments Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 9724ee16c..008fa2cf4 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -8,8 +8,20 @@ with a vendor-specific Y-Cable """ +from .logger import Logger -class YCableBase(object): +# +# YCableBase =================================================================== +# + +class YCableBase(Logger): + + def __init__(self, log_identifier): + super(YCableBase, self).__init__( + log_identifier=log_identifier, + log_facility=Logger.LOG_FACILITY_DAEMON, + log_option=(Logger.LOG_OPTION_NDELAY | Logger.LOG_OPTION_PID) + ) # definitions of targets for getting the various fields/cursor # equalization parameters from the register spec. @@ -1009,7 +1021,7 @@ def disable_prbs_mode(self, target, direction=PRBS_DIRECTION_BOTH): raise NotImplementedError - def enable_loopback_mode(self, target, mode=NEAR_END_LOOPBACK, lane_mask): + def enable_loopback_mode(self, target, lane_mask, mode=LOOPBACK_MODE_NEAR_END): """ This API configures and enables the Loopback mode on the port user provides. Target is an integer for selecting which end of the Y cable we want to run loopback on. From 5afe8dc6abd1bbabad0d090a11fbd2964405c570 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Mon, 28 Jun 2021 19:51:42 +0000 Subject: [PATCH 20/28] fix constructor Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 008fa2cf4..b5f1ab22c 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -16,13 +16,6 @@ class YCableBase(Logger): - def __init__(self, log_identifier): - super(YCableBase, self).__init__( - log_identifier=log_identifier, - log_facility=Logger.LOG_FACILITY_DAEMON, - log_option=(Logger.LOG_OPTION_NDELAY | Logger.LOG_OPTION_PID) - ) - # definitions of targets for getting the various fields/cursor # equalization parameters from the register spec. # the name of the target denotes which side MCU @@ -79,7 +72,7 @@ def __init__(self, log_identifier): PRBS_DIRECTION_GENERATOR = 1 PRBS_DIRECTION_CHECKER = 2 - def __init__(self, port): + def __init__(self, port, log_identifier): """ Args: port: @@ -87,6 +80,12 @@ def __init__(self, port): """ self.port = port + super(YCableBase, self).__init__( + log_identifier=log_identifier, + log_facility=Logger.LOG_FACILITY_DAEMON, + log_option=(Logger.LOG_OPTION_NDELAY | Logger.LOG_OPTION_PID) + ) + def toggle_mux_to_tor_a(self): """ This API does a hard switch toggle of the Y cable's MUX regardless of link state to From 1e5e2a5b6febfb922cfe204167ad10ea67b37ca6 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Mon, 28 Jun 2021 19:56:34 +0000 Subject: [PATCH 21/28] fix comment Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index b5f1ab22c..ca66c587c 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -81,9 +81,9 @@ def __init__(self, port, log_identifier): self.port = port super(YCableBase, self).__init__( - log_identifier=log_identifier, - log_facility=Logger.LOG_FACILITY_DAEMON, - log_option=(Logger.LOG_OPTION_NDELAY | Logger.LOG_OPTION_PID) + log_identifier=log_identifier, + log_facility=Logger.LOG_FACILITY_DAEMON, + log_option=(Logger.LOG_OPTION_NDELAY | Logger.LOG_OPTION_PID) ) def toggle_mux_to_tor_a(self): From 3b7ef85fb9382a1ae0dfb1e26d5aaff7df33f728 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Wed, 30 Jun 2021 17:37:50 +0000 Subject: [PATCH 22/28] fix logging Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index ca66c587c..3625d5486 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -8,13 +8,11 @@ with a vendor-specific Y-Cable """ -from .logger import Logger - # # YCableBase =================================================================== # -class YCableBase(Logger): +class YCableBase(): # definitions of targets for getting the various fields/cursor # equalization parameters from the register spec. @@ -72,19 +70,33 @@ class YCableBase(Logger): PRBS_DIRECTION_GENERATOR = 1 PRBS_DIRECTION_CHECKER = 2 - def __init__(self, port, log_identifier): + def __init__(self, port, main_logger): """ Args: port: an Integer, the actual physical port connected to a Y cable + main_logger: + a logging instance object, the main logging instance which can be used to log messages into syslog + which can be called from derived classes using functions defined as log_info, log_warning etc. + """ self.port = port + self.main_logger = main_logger + + def log_warning(self, msg): + self.main_logger.log_warning("y_cable_port {} {}".format(self.port, msg)) + + def log_error(self, msg): + self.main_logger.log_error("y_cable_port {} {}".format(self.port, msg)) - super(YCableBase, self).__init__( - log_identifier=log_identifier, - log_facility=Logger.LOG_FACILITY_DAEMON, - log_option=(Logger.LOG_OPTION_NDELAY | Logger.LOG_OPTION_PID) - ) + def log_info(self, msg): + self.main_logger.log_info("y_cable_port {} {}".format(self.port, msg)) + + def log_notice(self, msg): + self.main_logger.log_notice("y_cable_port {} {}".format(self.port, msg)) + + def log_debug(self, msg): + self.main_logger.log_debug("y_cable_port {} {}".format(self.port, msg)) def toggle_mux_to_tor_a(self): """ @@ -1132,6 +1144,7 @@ def debug_dump_registers(self, option=None): For example, the option can serdes_lane0, in this case the vendor would just dump registers related to serdes lane 0. + Returns: a Dictionary: with all the relevant key-value pairs for all the meaningful fields From cc576c9e845f2fd436b0d3da38c6f481e69f0a0a Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Wed, 30 Jun 2021 19:22:42 +0000 Subject: [PATCH 23/28] fix comments for logger Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 3625d5486..aeb4de42e 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -70,33 +70,33 @@ class YCableBase(): PRBS_DIRECTION_GENERATOR = 1 PRBS_DIRECTION_CHECKER = 2 - def __init__(self, port, main_logger): + def __init__(self, port, logger): """ Args: port: an Integer, the actual physical port connected to a Y cable - main_logger: - a logging instance object, the main logging instance which can be used to log messages into syslog - which can be called from derived classes using functions defined as log_info, log_warning etc. + logger: + a logging instance object, must be an instance of the Logger class from sonic_py_common instantiated + by the program which is instantiating this class. """ self.port = port - self.main_logger = main_logger + self._logger = logger def log_warning(self, msg): - self.main_logger.log_warning("y_cable_port {} {}".format(self.port, msg)) + self._logger.log_warning("y_cable_port {} {}".format(self.port, msg)) def log_error(self, msg): - self.main_logger.log_error("y_cable_port {} {}".format(self.port, msg)) + self._logger.log_error("y_cable_port {} {}".format(self.port, msg)) def log_info(self, msg): - self.main_logger.log_info("y_cable_port {} {}".format(self.port, msg)) + self._logger.log_info("y_cable_port {} {}".format(self.port, msg)) def log_notice(self, msg): - self.main_logger.log_notice("y_cable_port {} {}".format(self.port, msg)) + self._logger.log_notice("y_cable_port {} {}".format(self.port, msg)) def log_debug(self, msg): - self.main_logger.log_debug("y_cable_port {} {}".format(self.port, msg)) + self._logger.log_debug("y_cable_port {} {}".format(self.port, msg)) def toggle_mux_to_tor_a(self): """ From 08cd62271fb1b98f5bddfad5e3e4ec29d749aeff Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Thu, 1 Jul 2021 14:45:10 +0000 Subject: [PATCH 24/28] fix delimiter Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index aeb4de42e..1c38556d1 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -84,19 +84,19 @@ def __init__(self, port, logger): self._logger = logger def log_warning(self, msg): - self._logger.log_warning("y_cable_port {} {}".format(self.port, msg)) + self._logger.log_warning("y_cable_port {}: {}".format(self.port, msg)) def log_error(self, msg): - self._logger.log_error("y_cable_port {} {}".format(self.port, msg)) + self._logger.log_error("y_cable_port {}: {}".format(self.port, msg)) def log_info(self, msg): - self._logger.log_info("y_cable_port {} {}".format(self.port, msg)) + self._logger.log_info("y_cable_port {}: {}".format(self.port, msg)) def log_notice(self, msg): - self._logger.log_notice("y_cable_port {} {}".format(self.port, msg)) + self._logger.log_notice("y_cable_port {}: {}".format(self.port, msg)) def log_debug(self, msg): - self._logger.log_debug("y_cable_port {} {}".format(self.port, msg)) + self._logger.log_debug("y_cable_port {}: {}".format(self.port, msg)) def toggle_mux_to_tor_a(self): """ From df7ee657364d5431c8d17e70b12d8155307819b8 Mon Sep 17 00:00:00 2001 From: xinyu Date: Sat, 3 Jul 2021 21:34:47 +0800 Subject: [PATCH 25/28] fix missing parameter[target] of restart_anlt() --- sonic_y_cable/y_cable_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 1c38556d1..407a7779f 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -886,7 +886,7 @@ def get_autoswitch_hysteresis_timer(self): raise NotImplementedError - def restart_anlt(self): + def restart_anlt(self, target): """ This API restarts auto-negotiation + link training (AN/LT) mode The port on which this API is called for can be referred using self.port. From 27dc3cf19bc971826221c70789f668655870ed1c Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Mon, 19 Jul 2021 23:03:42 +0000 Subject: [PATCH 26/28] fix comments; add download status Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 37 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 407a7779f..3782c92d4 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -65,6 +65,18 @@ class YCableBase(): FIRMWARE_ROLLBACK_SUCCESS = 0 FIRMWARE_ROLLBACK_FAILURE = 1 + + # Valid status values for download_firmware + # The download_firmware_status variable should be assigned + # one of these predefined values inside download_firmware routine + # as to signify what is the current status of the firmware + # download is + + FIRMWARE_DOWNLOAD_STATUS_NOT_INITIATED_OR_FINISHED = 0 + FIRMWARE_DOWNLOAD_STATUS_INPROGRESS = 1 + FIRMWARE_DOWNLOAD_STATUS_FAILED = 2 + + # definitions of PRBS run modes PRBS_DIRECTION_BOTH = 0 PRBS_DIRECTION_GENERATOR = 1 @@ -82,6 +94,8 @@ def __init__(self, port, logger): """ self.port = port self._logger = logger + self.download_firmware_status = FIRMWARE_DOWNLOAD_STATUS_NOT_INITIATED_OR_FINISHED + def log_warning(self, msg): self._logger.log_warning("y_cable_port {}: {}".format(self.port, msg)) @@ -638,8 +652,7 @@ def reset(self, target): raise NotImplementedError - def create_port(self, speed, fec_mode_tor_a=FEC_MODE_NONE, fec_mode_tor_b=FEC_MODE_NONE, - fec_mode_nic=FEC_MODE_NONE, anlt_tor_a=False, anlt_tor_b= False, anlt_nic=False): + def create_port(self, speed, fec_mode_tor=FEC_MODE_NONE, fec_mode_nic= FEC_MODE_NONE, anlt_tor=False, anlt_nic=False): """ This API sets the mode of the cable/port for corresponding lane/FEC etc. configuration as specified. The speed specifies which mode is supposed to be set 50G, 100G etc @@ -655,14 +668,8 @@ def create_port(self, speed, fec_mode_tor_a=FEC_MODE_NONE, fec_mode_tor_b=FEC_MO 50000 -> 50G 100000 -> 100G - fec_mode_tor_a: - One of the following predefined constants, the actual FEC mode for the ToR A to be configured: - FEC_MODE_NONE, - FEC_MODE_RS, - FEC_MODE_FC - - fec_mode_tor_b: - One of the following predefined constants, the actual FEC mode for the ToR B to be configured: + fec_mode_tor: + One of the following predefined constants, the actual FEC mode for the ToR to be configured: FEC_MODE_NONE, FEC_MODE_RS, FEC_MODE_FC @@ -673,13 +680,9 @@ def create_port(self, speed, fec_mode_tor_a=FEC_MODE_NONE, fec_mode_tor_b=FEC_MO FEC_MODE_RS, FEC_MODE_FC - anlt_tor_a: - a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled on ToR A - , False if auto-negotiation + link training (AN/LT) is not to be enabled on ToR A - - anlt_tor_b: - a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled on ToR B - , False if auto-negotiation + link training (AN/LT) is not to be enabled on ToR B + anlt_tor: + a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled on ToR's + , False if auto-negotiation + link training (AN/LT) is not to be enabled on ToR's anlt_nic: a boolean, True if auto-negotiation + link training (AN/LT) is to be enabled on nic From 5fd135e6e785698c8db3f1abaa9438690c4218a6 Mon Sep 17 00:00:00 2001 From: xinyu Date: Tue, 20 Jul 2021 21:52:23 +0800 Subject: [PATCH 27/28] fix missing self keyword Signed-off-by: xinyu --- sonic_y_cable/y_cable_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index 3782c92d4..ab67f9917 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -94,7 +94,7 @@ def __init__(self, port, logger): """ self.port = port self._logger = logger - self.download_firmware_status = FIRMWARE_DOWNLOAD_STATUS_NOT_INITIATED_OR_FINISHED + self.download_firmware_status = self.FIRMWARE_DOWNLOAD_STATUS_NOT_INITIATED_OR_FINISHED def log_warning(self, msg): From 5ca5a038516636dffaca21421e0752a393a901a4 Mon Sep 17 00:00:00 2001 From: vaibhav-dahiya Date: Mon, 26 Jul 2021 17:20:00 +0000 Subject: [PATCH 28/28] add definition of LOOPBACK_MODE_NONE Signed-off-by: vaibhav-dahiya --- sonic_y_cable/y_cable_base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sonic_y_cable/y_cable_base.py b/sonic_y_cable/y_cable_base.py index ab67f9917..774c12db5 100644 --- a/sonic_y_cable/y_cable_base.py +++ b/sonic_y_cable/y_cable_base.py @@ -54,8 +54,9 @@ class YCableBase(): # definitions of the modes to be run for loopback mode # on the port/cable - LOOPBACK_MODE_NEAR_END = 0 - LOOPBACK_MODE_FAR_END = 1 + LOOPBACK_MODE_NONE = 0 + LOOPBACK_MODE_NEAR_END = 1 + LOOPBACK_MODE_FAR_END = 2 # Valid return codes for upgrade firmware routine steps FIRMWARE_DOWNLOAD_SUCCESS = 0 @@ -1104,6 +1105,7 @@ def get_loopback_mode(self, target): Returns: mode_value: One of the following predefined constants, the mode to be run for loopback: + LOOPBACK_MODE_NONE LOOPBACK_MODE_NEAR_END LOOPBACK_MODE_FAR_END """