You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
7.9 KiB
149 lines
7.9 KiB
def AutoTuneIbiasOnet(host: str, bmc: DevWhiteRiverExp, exp_id: int, slot_list: list, lane_list: List[int], |
|
remote_bmc: DevWhiteRiverExp, reg_table_file: str, route_name: str): |
|
reg_table = TransceiverConfigParser(reg_table_file) |
|
|
|
ibias_rssi_map_file = '/xz/gyou/nexusbench/main_data/ibias-rssi-map.json' |
|
ibias_rssi_map = IbiasRssiMapParser(ibias_rssi_map_file) |
|
|
|
if len(lane_list) == 8: # all, 8 is default value |
|
lane_list = [0,1,2,3] |
|
|
|
logging.info(f'lane_list: {lane_list}') |
|
|
|
substandard_slot = [] |
|
|
|
for slot_id in slot_list: |
|
|
|
logging.info(f"start auto tune ibias: exp_id={exp_id}, slots={slot_list}") |
|
|
|
for ibias_lane in lane_list: |
|
rssi_lanes = ibias_rssi_map.get_rssi_lane(route_name, ibias_lane) |
|
if rssi_lanes is None: |
|
logging.error(f'-----------------rssi lanes is none') |
|
continue |
|
# 一个一个ibias的校准 |
|
|
|
ibias_reg = reg_table.get_register_by_lane("ibias", ibias_lane) |
|
if not ibias_reg or not ibias_reg.valid_range or \ |
|
not ibias_reg.step or len(ibias_reg.valid_range) < 2: |
|
logging.error(f'-----------invalid ibias_reg or valid_range or step for ibias_reg') |
|
continue |
|
|
|
min_val = ibias_reg.valid_range[0] |
|
max_val = ibias_reg.valid_range[1] |
|
|
|
step = ibias_reg.step |
|
logging.info(f'-------min_val: {min_val}, max_val: {max_val}, step: {step}') |
|
#search_values = get_search_values(min_val, max_val, step) |
|
search_values = list(range(min_val, max_val + 1, step)) |
|
# search_values.sort(reverse=True) |
|
logging.info(f'-------search_values: {search_values}') |
|
|
|
measurements_map1 = [] |
|
measurements_map2 = [] |
|
expect_value = -1 |
|
for ibias_value in search_values: |
|
value_hex_str = f"{ibias_value:04X}" |
|
time.sleep(0.05) |
|
result = remote_bmc.SetOpticalModuleRegs(exp_id, slot_id, ibias_reg.bank, ibias_reg.page, |
|
ibias_reg.offset, 2, value_hex_str) |
|
time.sleep(0.2) |
|
for index, rssi_lane in enumerate(rssi_lanes): |
|
reg = reg_table.get_register_by_lane("rssi", rssi_lane) |
|
if not reg or not reg.valid_range: |
|
logging.error(f'------------- rssi reg or valid range is none') |
|
continue |
|
value = bmc.GetOpticalModuleRegs(exp_id, slot_id, reg.bank, reg.page, reg.offset, 2) |
|
rssi_value = int(value, 16) |
|
dbm = round(10 * math.log10(rssi_value / 10000), 3) |
|
logging.info(f'{bmc.m_smbus.server_id}<-{remote_bmc.m_smbus.server_id} slot:{slot_id}, ibias_lane: {ibias_lane}, ibias: {ibias_value}, rssi_lane: {rssi_lane}, rssi value: {rssi_value}, dbm: {dbm}') |
|
|
|
min_val = reg.valid_range[0] |
|
max_val = reg.valid_range[1] |
|
# expect_value = reg.value |
|
# if expect_value is None: |
|
expect_value = 5623 #-2.5, old 6310 (-2.0) |
|
# if rssi_value >= int(min_val) and rssi_value <= int(max_val): |
|
if index == 0: |
|
measurements_map1.append((ibias_value, rssi_value)) |
|
elif index == 1: |
|
measurements_map2.append((ibias_value, rssi_value)) |
|
|
|
# logging.info(f'rssi1 map: {measurements_map1}') |
|
# logging.info(f'rssi1 map: {measurements_map2}') |
|
|
|
logging.info(f'rssi1 map: {measurements_map1}') |
|
logging.info(f'rssi2 map: {measurements_map2}') |
|
dbm = round(10 * math.log10(expect_value / 10000), 3) |
|
logging.info(f'expect_value: {expect_value}, {dbm}dbm') |
|
result = find_best_ibias_for_expected_rssi(measurements_map1, measurements_map2, expect_value) |
|
# rssi_val1 = next((r for i, r in measurements_map1 if i == 2047), None) |
|
# rssi_val2 = next((r for i, r in measurements_map2 if i == 2047), None) |
|
# dbm1 = round(10 * math.log10(rssi_val1 / 10000), 3) |
|
# dbm2 = round(10 * math.log10(rssi_val2 / 10000), 3) |
|
# if dbm1 < -4 or dbm2 < -4: |
|
# substandard_slot.append(slot_id) |
|
# break |
|
|
|
# elif dbm1 < -3.5 or dbm2 < -3.5: # -3.5 ~ -4 |
|
# except_dbm = -2.8 |
|
# expect_value = int(10000 * (10 ** (except_dbm / 10))) |
|
# elif dbm1 < -2.5 or dbm2 < -2.5: # -2.5 ~ -3.5 |
|
# except_dbm = -2.7 |
|
# expect_value = int(10000 * (10 ** (except_dbm / 10))) |
|
# elif dbm1 < -1.5 or dbm2 < -1.5: # -1.5 ~ -2.5 |
|
# except_dbm = -1.5 |
|
# expect_value = int(10000 * (10 ** (except_dbm / 10))) |
|
|
|
if result: |
|
ibias, rssi1, rssi2 = result |
|
|
|
if ibias < 2500: |
|
except_dbm = -1.6 |
|
expect_value = int(10000 * (10 ** (except_dbm / 10))) |
|
logging.info(f' < 2500, use except_dbm {except_dbm}, old ibias: {ibias}') |
|
result = find_best_ibias_for_expected_rssi_old(measurements_map1, measurements_map2, expect_value) |
|
ibias, rssi1, rssi2 = result |
|
|
|
if ibias > 2900: |
|
except_dbm = -2.8 |
|
expect_value = int(10000 * (10 ** (except_dbm / 10))) |
|
logging.info(f' > 2900, use except_dbm {except_dbm}, old ibias: {ibias}') |
|
result = find_best_ibias_for_expected_rssi(measurements_map1, measurements_map2, expect_value) |
|
ibias, rssi1, rssi2 = result |
|
|
|
logging.info(f"{bmc.m_smbus.server_id}->{remote_bmc.m_smbus.server_id} ibias_lane: {ibias_lane}, best ibias: {ibias}") |
|
logging.info(f"rssi_lane: {rssi_lanes[0]}, RSSI1: {rssi1}") |
|
logging.info(f"rssi_lane: {rssi_lanes[1]} RSSI2: {rssi2}") |
|
|
|
value_hex_str = f"{ibias:04X}" |
|
logging.info(f'set best ibias value') |
|
time.sleep(0.05) |
|
result = remote_bmc.SetOpticalModuleRegs(exp_id, slot_id, ibias_reg.bank, ibias_reg.page, |
|
ibias_reg.offset, 2, value_hex_str) |
|
else: |
|
logging.warning(f'default expect_value{expect_value} not match! use 7586(-1.2dbm)') |
|
expect_value = 7586 # -1.2 |
|
result = find_best_ibias_for_expected_rssi(measurements_map1, measurements_map2, expect_value) |
|
if result: |
|
ibias, rssi1, rssi2 = result |
|
if ibias <= 2547: |
|
logging.info(f"{bmc.m_smbus.server_id}->{remote_bmc.m_smbus.server_id} ibias_lane: {ibias_lane}, best ibias: {ibias}") |
|
logging.info(f"rssi_lane: {rssi_lanes[0]}, RSSI1: {rssi1}") |
|
logging.info(f"rssi_lane: {rssi_lanes[1]} RSSI2: {rssi2}") |
|
|
|
value_hex_str = f"{ibias:04X}" |
|
logging.info(f'set best ibias value') |
|
time.sleep(0.05) |
|
result = remote_bmc.SetOpticalModuleRegs(exp_id, slot_id, ibias_reg.bank, ibias_reg.page, |
|
ibias_reg.offset, 2, value_hex_str) |
|
else: |
|
logging.error("No ibias value present in both maps was found.") |
|
substandard_slot.append(slot_id) |
|
else: |
|
logging.error("No ibias value present in both maps was found.") |
|
substandard_slot.append(slot_id) |
|
|
|
logging.info("Substandard SLOT:") |
|
for slot in substandard_slot: |
|
logging.error(f"exp: {exp_id}, slot: {slot}, MODULE: QDD{slot + 1}")
|
|
|