From 2503cdd8c178f3fda8fcacf35c53f03a2c607bfe Mon Sep 17 00:00:00 2001 From: Harish Venkatraman Date: Mon, 28 Jan 2019 13:29:49 -0800 Subject: [PATCH 1/2] [dell/Z9100] Fix for optics not detected in fanout mode This commit fixes the issue of optics not detected error while running sfputil show eeprom command. The root casuse was the value of port index from port_config.ini for fan out scenario. The port index should be starting from 0 and not 1. Platform cpld registers are assuming the port numbers to start from 0 (lowermost bit), sfputils.py uses this port number in get_presence function. Since the indexing passed is wrong the optics was not detected and gave SFP EEPROM not detected message. Signed-off-by: Harish Venkatraman --- .../Force10-Z9100-C8D48/port_config.ini | 112 +++++++++--------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/device/dell/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C8D48/port_config.ini b/device/dell/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C8D48/port_config.ini index c1a086764854..45379934edfd 100644 --- a/device/dell/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C8D48/port_config.ini +++ b/device/dell/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C8D48/port_config.ini @@ -1,57 +1,57 @@ # name lanes alias index speed -Ethernet0 49,50 fiftyGigE1/1/1 1 50000 -Ethernet2 51,52 fiftyGigE1/1/2 1 50000 -Ethernet4 53,54 fiftyGigE1/2/1 2 50000 -Ethernet6 55,56 fiftyGigE1/2/2 2 50000 -Ethernet8 57,58 fiftyGigE1/3/1 3 50000 -Ethernet10 59,60 fiftyGigE1/3/2 3 50000 -Ethernet12 61,62 fiftyGigE1/4/1 4 50000 -Ethernet14 63,64 fiftyGigE1/4/2 4 50000 -Ethernet16 65,66 fiftyGigE1/5/1 5 50000 -Ethernet18 67,68 fiftyGigE1/5/2 5 50000 -Ethernet20 69,70 fiftyGigE1/6/1 6 50000 -Ethernet22 71,72 fiftyGigE1/6/2 6 50000 -Ethernet24 73,74,75,76 hundredGigE1/7 7 100000 -Ethernet28 77,78,79,80 hundredGigE1/8 8 100000 -Ethernet32 37,38,39,40 hundredGigE1/9 9 100000 -Ethernet36 33,34,35,36 hundredGigE1/10 10 100000 -Ethernet40 45,46 fiftyGigE1/11/1 11 50000 -Ethernet42 47,48 fiftyGigE1/11/2 11 50000 -Ethernet44 41,42 fiftyGigE1/12/1 12 50000 -Ethernet46 43,44 fiftyGigE1/12/2 12 50000 -Ethernet48 81,82 fiftyGigE1/13/1 13 50000 -Ethernet50 83,84 fiftyGigE1/13/2 13 50000 -Ethernet52 85,86 fiftyGigE1/14/1 14 50000 -Ethernet54 87,88 fiftyGigE1/14/2 14 50000 -Ethernet56 89,90 fiftyGigE1/15/1 15 50000 -Ethernet58 91,92 fiftyGigE1/15/2 15 50000 -Ethernet60 93,94 fiftyGigE1/16/1 16 50000 -Ethernet62 95,96 fiftyGigE1/16/2 16 50000 -Ethernet64 97,98 fiftyGigE1/17/1 17 50000 -Ethernet66 99,100 fiftyGigE1/17/2 17 50000 -Ethernet68 101,102 fiftyGigE1/18/1 18 50000 -Ethernet70 103,104 fiftyGigE1/18/2 18 50000 -Ethernet72 105,106 fiftyGigE1/19/1 19 50000 -Ethernet74 107,108 fiftyGigE1/19/2 19 50000 -Ethernet76 109,110 fiftyGigE1/20/1 20 50000 -Ethernet78 111,112 fiftyGigE1/20/2 20 50000 -Ethernet80 21,22 fiftyGigE1/21/1 21 50000 -Ethernet82 23,24 fiftyGigE1/21/2 21 50000 -Ethernet84 17,18 fiftyGigE1/22/1 22 50000 -Ethernet86 19,20 fiftyGigE1/22/2 22 50000 -Ethernet88 29,30 fiftyGigE1/23/1 23 50000 -Ethernet90 31,32 fiftyGigE1/23/2 23 50000 -Ethernet92 25,26 fiftyGigE1/24/1 24 50000 -Ethernet94 27,28 fiftyGigE1/24/2 24 50000 -Ethernet96 117,118 fiftyGigE1/25/1 25 50000 -Ethernet98 119,120 fiftyGigE1/25/2 25 50000 -Ethernet100 113,114 fiftyGigE1/26/1 26 50000 -Ethernet102 115,116 fiftyGigE1/26/2 26 50000 -Ethernet104 125,126,127,128 hundredGigE1/27 27 100000 -Ethernet108 121,122,123,124 hundredGigE1/28 28 100000 -Ethernet112 5,6,7,8 hundredGigE1/29 29 100000 -Ethernet116 1,2,3,4 hundredGigE1/30 30 100000 -Ethernet120 13,14 fiftyGigE1/31/1 31 50000 -Ethernet122 15,16 fiftyGigE1/31/2 31 50000 -Ethernet124 9,10 fiftyGigE1/32/1 32 50000 -Ethernet126 11,12 fiftyGigE1/32/2 32 50000 +Ethernet0 49,50 fiftyGigE1/1/1 0 50000 +Ethernet2 51,52 fiftyGigE1/1/2 0 50000 +Ethernet4 53,54 fiftyGigE1/2/1 1 50000 +Ethernet6 55,56 fiftyGigE1/2/2 1 50000 +Ethernet8 57,58 fiftyGigE1/3/1 2 50000 +Ethernet10 59,60 fiftyGigE1/3/2 2 50000 +Ethernet12 61,62 fiftyGigE1/4/1 3 50000 +Ethernet14 63,64 fiftyGigE1/4/2 3 50000 +Ethernet16 65,66 fiftyGigE1/5/1 4 50000 +Ethernet18 67,68 fiftyGigE1/5/2 4 50000 +Ethernet20 69,70 fiftyGigE1/6/1 5 50000 +Ethernet22 71,72 fiftyGigE1/6/2 5 50000 +Ethernet24 73,74,75,76 hundredGigE1/7 6 100000 +Ethernet28 77,78,79,80 hundredGigE1/8 7 100000 +Ethernet32 37,38,39,40 hundredGigE1/9 8 100000 +Ethernet36 33,34,35,36 hundredGigE1/10 9 100000 +Ethernet40 45,46 fiftyGigE1/11/1 10 50000 +Ethernet42 47,48 fiftyGigE1/11/2 10 50000 +Ethernet44 41,42 fiftyGigE1/12/1 11 50000 +Ethernet46 43,44 fiftyGigE1/12/2 11 50000 +Ethernet48 81,82 fiftyGigE1/13/1 12 50000 +Ethernet50 83,84 fiftyGigE1/13/2 12 50000 +Ethernet52 85,86 fiftyGigE1/14/1 13 50000 +Ethernet54 87,88 fiftyGigE1/14/2 13 50000 +Ethernet56 89,90 fiftyGigE1/15/1 14 50000 +Ethernet58 91,92 fiftyGigE1/15/2 14 50000 +Ethernet60 93,94 fiftyGigE1/16/1 15 50000 +Ethernet62 95,96 fiftyGigE1/16/2 15 50000 +Ethernet64 97,98 fiftyGigE1/17/1 16 50000 +Ethernet66 99,100 fiftyGigE1/17/2 16 50000 +Ethernet68 101,102 fiftyGigE1/18/1 17 50000 +Ethernet70 103,104 fiftyGigE1/18/2 17 50000 +Ethernet72 105,106 fiftyGigE1/19/1 18 50000 +Ethernet74 107,108 fiftyGigE1/19/2 18 50000 +Ethernet76 109,110 fiftyGigE1/20/1 19 50000 +Ethernet78 111,112 fiftyGigE1/20/2 19 50000 +Ethernet80 21,22 fiftyGigE1/21/1 20 50000 +Ethernet82 23,24 fiftyGigE1/21/2 20 50000 +Ethernet84 17,18 fiftyGigE1/22/1 21 50000 +Ethernet86 19,20 fiftyGigE1/22/2 21 50000 +Ethernet88 29,30 fiftyGigE1/23/1 22 50000 +Ethernet90 31,32 fiftyGigE1/23/2 22 50000 +Ethernet92 25,26 fiftyGigE1/24/1 23 50000 +Ethernet94 27,28 fiftyGigE1/24/2 23 50000 +Ethernet96 117,118 fiftyGigE1/25/1 24 50000 +Ethernet98 119,120 fiftyGigE1/25/2 24 50000 +Ethernet100 113,114 fiftyGigE1/26/1 25 50000 +Ethernet102 115,116 fiftyGigE1/26/2 25 50000 +Ethernet104 125,126,127,128 hundredGigE1/27 26 100000 +Ethernet108 121,122,123,124 hundredGigE1/28 27 100000 +Ethernet112 5,6,7,8 hundredGigE1/29 28 100000 +Ethernet116 1,2,3,4 hundredGigE1/30 29 100000 +Ethernet120 13,14 fiftyGigE1/31/1 30 50000 +Ethernet122 15,16 fiftyGigE1/31/2 30 50000 +Ethernet124 9,10 fiftyGigE1/32/1 31 50000 +Ethernet126 11,12 fiftyGigE1/32/2 31 50000 From ff8a2a02fce5b3ee441426d7baa9441eb0b61367 Mon Sep 17 00:00:00 2001 From: Harish Venkatraman Date: Thu, 14 Feb 2019 15:22:23 -0800 Subject: [PATCH 2/2] [dell/z9100] Fix for optics not detected in fanout mode This commit fixes the issue of optics not detected error while running sfputil show eeprom command. The root cause was wrong port_index in fan out scenarios. Earlier fix of changing the port_config.ini is reverted and changes made in z9100 platform specific sfputil.py file. The port number is decrement and tested for both 100G and 50G fanout cases. Tested for the following show commands and test was succesful show interfaces status, show interfaces transceiver eeprom, show interfaces transceiver lpmode, show interface tranceiver presence. Signed-off-by: Harish Venkatraman --- .../Force10-Z9100-C8D48/port_config.ini | 112 +++++------ .../plugins/sfputil.py | 177 +++++++----------- 2 files changed, 124 insertions(+), 165 deletions(-) diff --git a/device/dell/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C8D48/port_config.ini b/device/dell/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C8D48/port_config.ini index 45379934edfd..c1a086764854 100644 --- a/device/dell/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C8D48/port_config.ini +++ b/device/dell/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C8D48/port_config.ini @@ -1,57 +1,57 @@ # name lanes alias index speed -Ethernet0 49,50 fiftyGigE1/1/1 0 50000 -Ethernet2 51,52 fiftyGigE1/1/2 0 50000 -Ethernet4 53,54 fiftyGigE1/2/1 1 50000 -Ethernet6 55,56 fiftyGigE1/2/2 1 50000 -Ethernet8 57,58 fiftyGigE1/3/1 2 50000 -Ethernet10 59,60 fiftyGigE1/3/2 2 50000 -Ethernet12 61,62 fiftyGigE1/4/1 3 50000 -Ethernet14 63,64 fiftyGigE1/4/2 3 50000 -Ethernet16 65,66 fiftyGigE1/5/1 4 50000 -Ethernet18 67,68 fiftyGigE1/5/2 4 50000 -Ethernet20 69,70 fiftyGigE1/6/1 5 50000 -Ethernet22 71,72 fiftyGigE1/6/2 5 50000 -Ethernet24 73,74,75,76 hundredGigE1/7 6 100000 -Ethernet28 77,78,79,80 hundredGigE1/8 7 100000 -Ethernet32 37,38,39,40 hundredGigE1/9 8 100000 -Ethernet36 33,34,35,36 hundredGigE1/10 9 100000 -Ethernet40 45,46 fiftyGigE1/11/1 10 50000 -Ethernet42 47,48 fiftyGigE1/11/2 10 50000 -Ethernet44 41,42 fiftyGigE1/12/1 11 50000 -Ethernet46 43,44 fiftyGigE1/12/2 11 50000 -Ethernet48 81,82 fiftyGigE1/13/1 12 50000 -Ethernet50 83,84 fiftyGigE1/13/2 12 50000 -Ethernet52 85,86 fiftyGigE1/14/1 13 50000 -Ethernet54 87,88 fiftyGigE1/14/2 13 50000 -Ethernet56 89,90 fiftyGigE1/15/1 14 50000 -Ethernet58 91,92 fiftyGigE1/15/2 14 50000 -Ethernet60 93,94 fiftyGigE1/16/1 15 50000 -Ethernet62 95,96 fiftyGigE1/16/2 15 50000 -Ethernet64 97,98 fiftyGigE1/17/1 16 50000 -Ethernet66 99,100 fiftyGigE1/17/2 16 50000 -Ethernet68 101,102 fiftyGigE1/18/1 17 50000 -Ethernet70 103,104 fiftyGigE1/18/2 17 50000 -Ethernet72 105,106 fiftyGigE1/19/1 18 50000 -Ethernet74 107,108 fiftyGigE1/19/2 18 50000 -Ethernet76 109,110 fiftyGigE1/20/1 19 50000 -Ethernet78 111,112 fiftyGigE1/20/2 19 50000 -Ethernet80 21,22 fiftyGigE1/21/1 20 50000 -Ethernet82 23,24 fiftyGigE1/21/2 20 50000 -Ethernet84 17,18 fiftyGigE1/22/1 21 50000 -Ethernet86 19,20 fiftyGigE1/22/2 21 50000 -Ethernet88 29,30 fiftyGigE1/23/1 22 50000 -Ethernet90 31,32 fiftyGigE1/23/2 22 50000 -Ethernet92 25,26 fiftyGigE1/24/1 23 50000 -Ethernet94 27,28 fiftyGigE1/24/2 23 50000 -Ethernet96 117,118 fiftyGigE1/25/1 24 50000 -Ethernet98 119,120 fiftyGigE1/25/2 24 50000 -Ethernet100 113,114 fiftyGigE1/26/1 25 50000 -Ethernet102 115,116 fiftyGigE1/26/2 25 50000 -Ethernet104 125,126,127,128 hundredGigE1/27 26 100000 -Ethernet108 121,122,123,124 hundredGigE1/28 27 100000 -Ethernet112 5,6,7,8 hundredGigE1/29 28 100000 -Ethernet116 1,2,3,4 hundredGigE1/30 29 100000 -Ethernet120 13,14 fiftyGigE1/31/1 30 50000 -Ethernet122 15,16 fiftyGigE1/31/2 30 50000 -Ethernet124 9,10 fiftyGigE1/32/1 31 50000 -Ethernet126 11,12 fiftyGigE1/32/2 31 50000 +Ethernet0 49,50 fiftyGigE1/1/1 1 50000 +Ethernet2 51,52 fiftyGigE1/1/2 1 50000 +Ethernet4 53,54 fiftyGigE1/2/1 2 50000 +Ethernet6 55,56 fiftyGigE1/2/2 2 50000 +Ethernet8 57,58 fiftyGigE1/3/1 3 50000 +Ethernet10 59,60 fiftyGigE1/3/2 3 50000 +Ethernet12 61,62 fiftyGigE1/4/1 4 50000 +Ethernet14 63,64 fiftyGigE1/4/2 4 50000 +Ethernet16 65,66 fiftyGigE1/5/1 5 50000 +Ethernet18 67,68 fiftyGigE1/5/2 5 50000 +Ethernet20 69,70 fiftyGigE1/6/1 6 50000 +Ethernet22 71,72 fiftyGigE1/6/2 6 50000 +Ethernet24 73,74,75,76 hundredGigE1/7 7 100000 +Ethernet28 77,78,79,80 hundredGigE1/8 8 100000 +Ethernet32 37,38,39,40 hundredGigE1/9 9 100000 +Ethernet36 33,34,35,36 hundredGigE1/10 10 100000 +Ethernet40 45,46 fiftyGigE1/11/1 11 50000 +Ethernet42 47,48 fiftyGigE1/11/2 11 50000 +Ethernet44 41,42 fiftyGigE1/12/1 12 50000 +Ethernet46 43,44 fiftyGigE1/12/2 12 50000 +Ethernet48 81,82 fiftyGigE1/13/1 13 50000 +Ethernet50 83,84 fiftyGigE1/13/2 13 50000 +Ethernet52 85,86 fiftyGigE1/14/1 14 50000 +Ethernet54 87,88 fiftyGigE1/14/2 14 50000 +Ethernet56 89,90 fiftyGigE1/15/1 15 50000 +Ethernet58 91,92 fiftyGigE1/15/2 15 50000 +Ethernet60 93,94 fiftyGigE1/16/1 16 50000 +Ethernet62 95,96 fiftyGigE1/16/2 16 50000 +Ethernet64 97,98 fiftyGigE1/17/1 17 50000 +Ethernet66 99,100 fiftyGigE1/17/2 17 50000 +Ethernet68 101,102 fiftyGigE1/18/1 18 50000 +Ethernet70 103,104 fiftyGigE1/18/2 18 50000 +Ethernet72 105,106 fiftyGigE1/19/1 19 50000 +Ethernet74 107,108 fiftyGigE1/19/2 19 50000 +Ethernet76 109,110 fiftyGigE1/20/1 20 50000 +Ethernet78 111,112 fiftyGigE1/20/2 20 50000 +Ethernet80 21,22 fiftyGigE1/21/1 21 50000 +Ethernet82 23,24 fiftyGigE1/21/2 21 50000 +Ethernet84 17,18 fiftyGigE1/22/1 22 50000 +Ethernet86 19,20 fiftyGigE1/22/2 22 50000 +Ethernet88 29,30 fiftyGigE1/23/1 23 50000 +Ethernet90 31,32 fiftyGigE1/23/2 23 50000 +Ethernet92 25,26 fiftyGigE1/24/1 24 50000 +Ethernet94 27,28 fiftyGigE1/24/2 24 50000 +Ethernet96 117,118 fiftyGigE1/25/1 25 50000 +Ethernet98 119,120 fiftyGigE1/25/2 25 50000 +Ethernet100 113,114 fiftyGigE1/26/1 26 50000 +Ethernet102 115,116 fiftyGigE1/26/2 26 50000 +Ethernet104 125,126,127,128 hundredGigE1/27 27 100000 +Ethernet108 121,122,123,124 hundredGigE1/28 28 100000 +Ethernet112 5,6,7,8 hundredGigE1/29 29 100000 +Ethernet116 1,2,3,4 hundredGigE1/30 30 100000 +Ethernet120 13,14 fiftyGigE1/31/1 31 50000 +Ethernet122 15,16 fiftyGigE1/31/2 31 50000 +Ethernet124 9,10 fiftyGigE1/32/1 32 50000 +Ethernet126 11,12 fiftyGigE1/32/2 32 50000 diff --git a/device/dell/x86_64-dell_z9100_c2538-r0/plugins/sfputil.py b/device/dell/x86_64-dell_z9100_c2538-r0/plugins/sfputil.py index 4cccfbb291f4..49caa2bd1848 100644 --- a/device/dell/x86_64-dell_z9100_c2538-r0/plugins/sfputil.py +++ b/device/dell/x86_64-dell_z9100_c2538-r0/plugins/sfputil.py @@ -16,15 +16,15 @@ class SfpUtil(SfpUtilBase): """Platform-specific SfpUtil class""" - PORT_START = 0 - PORT_END = 31 + PORT_START = 1 + PORT_END = 32 PORTS_IN_BLOCK = 32 - IOM_1_PORT_START = 0 - IOM_1_PORT_END = 11 - IOM_2_PORT_START = 12 - IOM_2_PORT_END = 21 - IOM_3_PORT_START = 22 - IOM_3_PORT_END = 31 + IOM_1_PORT_START = 1 + IOM_1_PORT_END = 12 + IOM_2_PORT_START = 13 + IOM_2_PORT_END = 22 + IOM_3_PORT_START = 23 + IOM_3_PORT_END = 32 BASE_VAL_PATH = "/sys/class/i2c-adapter/i2c-{0}/{0}-003e/" OIR_FD_PATH = "/sys/devices/platform/dell_ich.0/sci_int_gpio_sus6" @@ -33,38 +33,39 @@ class SfpUtil(SfpUtilBase): epoll = -1 _port_to_eeprom_mapping = {} _port_to_i2c_mapping = { - 0: [9, 18], - 1: [9, 19], - 2: [9, 20], - 3: [9, 21], - 4: [9, 22], - 5: [9, 23], - 6: [9, 24], - 7: [9, 25], - 8: [8, 26], - 9: [8, 27], - 10: [8, 28], - 11: [8, 29], - 12: [8, 31], # reordered - 13: [8, 30], - 14: [8, 33], # reordered - 15: [8, 32], - 16: [7, 34], - 17: [7, 35], - 18: [7, 36], - 19: [7, 37], - 20: [7, 38], - 21: [7, 39], - 22: [7, 40], - 23: [7, 41], - 24: [6, 42], - 25: [6, 43], - 26: [6, 44], - 27: [6, 45], - 28: [6, 46], - 29: [6, 47], - 30: [6, 48], - 31: [6, 49] + 0: [0, 00], # Dummy Entry + 1: [9, 18], + 2: [9, 19], + 3: [9, 20], + 4: [9, 21], + 5: [9, 22], + 6: [9, 23], + 7: [9, 24], + 8: [9, 25], + 9: [8, 26], + 10: [8, 27], + 11: [8, 28], + 12: [8, 29], + 13: [8, 31], # reordered + 14: [8, 30], + 15: [8, 33], # reordered + 16: [8, 32], + 17: [7, 34], + 18: [7, 35], + 19: [7, 36], + 20: [7, 37], + 21: [7, 38], + 22: [7, 39], + 23: [7, 40], + 24: [7, 41], + 25: [6, 42], + 26: [6, 43], + 27: [6, 44], + 28: [6, 45], + 29: [6, 46], + 30: [6, 47], + 31: [6, 48], + 32: [6, 49] } @property @@ -127,13 +128,10 @@ def __del__(self): self.epoll.close() self.oir_fd.close() - def get_presence(self, port_num): - - global i2c_line - + def normalize_port(self, port_num): # Check for invalid port_num if port_num < self.port_start or port_num > self.port_end: - return False + return -1, -1 # port_num and i2c match if port_num >= self.iom1_port_start and port_num <= self.iom1_port_end: i2c_line = 14 @@ -144,6 +142,24 @@ def get_presence(self, port_num): port_num <= self.iom3_port_end): i2c_line = 16 + # Rationalize port settings + if port_num >= self.iom1_port_start and port_num <= self.iom1_port_end: + port_num = port_num - 1 + elif port_num >= self.iom2_port_start and port_num <= self.iom2_port_end: + port_num = (port_num - 1) % 12 + elif (port_num >= self.iom3_port_start and + port_num <= self.iom3_port_end): + port_num = (port_num - 1) % 22 + + return i2c_line, port_num + + + def get_presence(self, port_num): + + i2c_line, port_num = self.normalize_port(port_num) + if port_num == -1: + return False + try: qsfp_path = self.BASE_VAL_PATH.format(i2c_line)+"qsfp_modprs" reg_file = open(qsfp_path, "r") @@ -161,13 +177,6 @@ def get_presence(self, port_num): # content is a string containing the hex representation of the register reg_value = int(content, 16) - # Rationalize port settings - if port_num >= self.iom2_port_start and port_num <= self.iom2_port_end: - port_num = port_num % 12 - elif (port_num >= self.iom3_port_start and - port_num <= self.iom3_port_end): - port_num = port_num % 22 - # Mask off the bit corresponding to our port mask = (1 << port_num) @@ -179,20 +188,10 @@ def get_presence(self, port_num): def get_low_power_mode(self, port_num): - # Check for invalid port_num - if port_num < self.port_start or port_num > self.port_end: + i2c_line, port_num = self.normalize_port(port_num) + if port_num == -1: return False - # port_num and i2c match - if port_num >= self.iom1_port_start and port_num <= self.iom1_port_end: - i2c_line = 14 - elif (port_num >= self.iom2_port_start and - port_num <= self.iom2_port_end): - i2c_line = 15 - elif (port_num >= self.iom3_port_start and - port_num <= self.iom3_port_end): - i2c_line = 16 - try: qsfp_path = self.BASE_VAL_PATH.format(i2c_line)+"qsfp_lpmode" reg_file = open(qsfp_path, "r") @@ -210,13 +209,6 @@ def get_low_power_mode(self, port_num): # content is a string containing the hex representation of the register reg_value = int(content, 16) - # Rationalize port settings - if port_num >= self.iom2_port_start and port_num <= self.iom2_port_end: - port_num = port_num % 12 - elif (port_num >= self.iom3_port_start and - port_num <= self.iom3_port_end): - port_num = port_num % 22 - # Mask off the bit corresponding to our port mask = (1 << port_num) @@ -228,24 +220,15 @@ def get_low_power_mode(self, port_num): def set_low_power_mode(self, port_num, lpmode): - # Check for invalid port_num - if port_num < self.port_start or port_num > self.port_end: + i2c_line, port_num = self.normalize_port(port_num) + if port_num == -1: return False - # port_num and i2c match - if port_num >= self.iom1_port_start and port_num <= self.iom1_port_end: - i2c_line = 14 - elif (port_num >= self.iom2_port_start and - port_num <= self.iom2_port_end): - i2c_line = 15 - elif (port_num >= self.iom3_port_start and - port_num <= self.iom3_port_end): - i2c_line = 16 - try: qsfp_path = self.BASE_VAL_PATH.format(i2c_line)+"qsfp_lpmode" reg_file = open(qsfp_path, "r+") + except IOError as e: print "Error: unable to open file: %s" % str(e) return False @@ -259,13 +242,6 @@ def set_low_power_mode(self, port_num, lpmode): # content is a string containing the hex representation of the register reg_value = int(content, 16) - # Rationalize port settings - if port_num >= self.iom2_port_start and port_num <= self.iom2_port_end: - port_num = port_num % 12 - elif (port_num >= self.iom3_port_start and - port_num <= self.iom3_port_end): - port_num = port_num % 22 - # Mask off the bit corresponding to our port mask = (1 << port_num) # LPMode is active high; set or clear the bit accordingly @@ -285,20 +261,10 @@ def set_low_power_mode(self, port_num, lpmode): def reset(self, port_num): - # Check for invalid port_num - if port_num < self.port_start or port_num > self.port_end: + i2c_line, port_num = self.normalize_port(port_num) + if port_num == -1: return False - # port_num and i2c match - if port_num >= self.iom1_port_start and port_num <= self.iom1_port_end: - i2c_line = 14 - elif (port_num >= self.iom2_port_start and - port_num <= self.iom2_port_end): - i2c_line = 15 - elif (port_num >= self.iom3_port_start and - port_num <= self.iom3_port_end): - i2c_line = 16 - try: qsfp_path = self.BASE_VAL_PATH.format(i2c_line)+"qsfp_lpmode" reg_file = open(qsfp_path, "r+") @@ -312,13 +278,6 @@ def reset(self, port_num): # File content is a string containing the hex representation of th reg_value = int(content, 16) - # Rationalize port settings - if port_num >= self.iom2_port_start and port_num <= self.iom2_port_end: - port_num = port_num % 12 - elif (port_num >= self.iom3_port_start and - port_num <= self.iom3_port_end): - port_num = port_num % 22 - # Mask off the bit corresponding to our port mask = (1 << port_num)