def __init__(self): for x in range(0, self.port_end): self.port_to_eeprom_mapping[x] = self.LOCAL_OOM_PATH % x SfpUtilBase.__init__(self) pim = PimUtil() pim.init_pim_fpga()
def get_presence(self, port_num): # Check for invalid port_num if port_num < self.port_start or port_num > self.port_end: return False pim = PimUtil() status = pim.get_qsfp_presence(port_num) return status
def port_link_state_change(self, portname, state): pim = PimUtil() port_idx = self._port_name_to_index(portname) new_control, led_mode = self._port_state_to_mode(port_idx, state) color, control = pim.get_port_led(port_idx) if color == led_mode: if control == new_control: return pim.set_port_led(port_idx, led_mode, new_control) #port linkup, led is green
def get_transceiver_change_event(self, timeout=0): pim = PimUtil() start_time = time.time() port_dict = {} forever = False if timeout == 0: forever = True elif timeout > 0: timeout = timeout / float(1000) # Convert to secs else: print("get_transceiver_change_event:Invalid timeout value", timeout) return False, {} end_time = start_time + timeout if start_time > end_time: print( 'get_transceiver_change_event:' 'time wrap / invalid timeout value', timeout) return False, {} # Time wrap or possibly incorrect timeout while timeout >= 0: change_status = 0 port_dict = pim.get_qsfp_interrupt() present = 0 for key, value in port_dict.items(): if value == 1: present = self.get_presence(key) change_status = 1 if present: port_dict[key] = '1' else: port_dict[key] = '0' if change_status: return True, port_dict if forever: time.sleep(1) else: timeout = end_time - time.time() if timeout >= 1: time.sleep(1) # We poll at 1 second granularity else: if timeout > 0: time.sleep(timeout) return True, {} print("get_evt_change_event: Should not reach here.") return False, {}
port_use_i2c_bus= [0] * 128 #pim_port_use_bus[idx] are for 8 channel use. At default, pim_port_use_bus[idx]=0 #pim_port_use_bus[idx] will save pim_idx(0 to 7). #setup service will check when pim insert at first time. #It will find # 1. Does this pim card insert or not in the past. So it will check pim_port_use_bus[idx] # 2. If make sure that pim_port_use_bus[idx]==0. Assgin oom start i2c dev numer to pim_port_use_bus[idx]. #Never set pim_port_use_bus[idx] to 0 #So if pim next insert, it need to check whether pim_port_use_bus[idx] is 0 or not. #if pim_port_use_bus[idx]!=0, means this pim card has setup oom sysfs pim_port_use_bus=[0] * 8 oom_i2c_bus_table=1 pim_dev=PimUtil() # Deafults VERSION = '1.0' FUNCTION_NAME = '/usr/local/bin/setup_qsfp_eeprom' DEBUG = False PIM_MIN=0 PIM_MAX=8 def my_log(txt): if DEBUG == True: print("[ACCTON DBG]: "+txt) return def log_os_system(cmd): logging.info('Run :'+cmd)
def __init__(self): pim = PimUtil() pim.init_pim_fpga()
def reset(self, port_num): if port_num < self.port_start or port_num > self.port_end: return False pim = PimUtil() pim.reset(port_num) return True
def set_low_power_mode(self, port_num, lpmode): if port_num < self.port_start or port_num > self.port_end: return False pim = PimUtil() pim.set_low_power_mode(port_num, lpmode) return True
def get_low_power_mode(self, port_num): if port_num < self.port_start or port_num > self.port_end: return False pim = PimUtil() return pim.get_low_power_mode(port_num)