コード例 #1
0
ファイル: bf_sde.py プロジェクト: APS-Networks/APS-One-touch
def install_switch_bsp():
    set_sde_env()
    aps_bsp_installation_file = get_aps_bsp_pkg_abs_path()
    if (get_switch_model() == constants.bf6064x_t and (
            'BF2556' in aps_bsp_installation_file or 'bf2556' in aps_bsp_installation_file)) \
            or (get_switch_model() == constants.bf2556x_1t and (
            'BF6064' in aps_bsp_installation_file or 'bf6064' in aps_bsp_installation_file)):
        print("ERROR: Incompatible BSP provided in settings.yaml,"
              " Switch model is {model} but BSP is {bsp}".format(
                  model=get_switch_model(), bsp=aps_bsp_installation_file))
        exit(0)

    print("Installing {}".format(aps_bsp_installation_file))

    os.environ['BSP_INSTALL'] = get_env_var('SDE_INSTALL')
    print("BSP_INSTALL directory set to {}".format(os.environ['BSP_INSTALL']))

    install_bsp_deps()
    cmake_cmd = 'cmake -DCMAKE_INSTALL_PREFIX={}'.format(
        get_env_var('SDE_INSTALL'))
    cmake_cmd += ' -B ' + aps_bsp_installation_file
    cmake_cmd += ' -S ' + aps_bsp_installation_file
    execute_cmd(cmake_cmd)
    os.system("make -C {0}".format(aps_bsp_installation_file))
    os.system("make -C {0} install".format(aps_bsp_installation_file))

    return True
コード例 #2
0
ファイル: bf_sde.py プロジェクト: srieger1/APS-One-touch
def get_default_bsp_repo_path():
    if get_switch_model() == constants.bf2556x_1t:
        return get_abs_path('/bsp/bf-reference-bsp-9.2.0-BF2556')
    elif get_switch_model() == constants.bf6064x_t:
        return get_abs_path('/bsp/bf-reference-bsp-9.2.0-BF6064')
    else:
        print('Development BSp can\'t be retrieved for switch model'.format(
            get_switch_model()))
コード例 #3
0
ファイル: bf_sde.py プロジェクト: srieger1/APS-One-touch
def install_switch_bsp():
    set_sde_env_n_load_drivers()
    aps_bsp_installation_file = get_aps_bsp_pkg_abs_path()
    print("Installing {}".format(aps_bsp_installation_file))
    aps_zip = zipfile.ZipFile(aps_bsp_installation_file)
    aps_zip.extractall(Path(aps_bsp_installation_file).parent)
    aps_bsp_dir = aps_zip.namelist()[0] + '/apsn/'
    aps_bsp_dir_absolute = str(
        Path(aps_bsp_installation_file).parent) + '/' + aps_bsp_dir
    aps_zip.close()

    ref_bsp_tar = tarfile.open(get_ref_bsp_abs_path())
    ref_bsp_tar.extractall(Path(get_ref_bsp_abs_path()).parent)
    ref_bsp_dir = ref_bsp_tar.getnames()[0]
    os.chdir(
        str(Path(get_ref_bsp_abs_path()).parent) + '/' + ref_bsp_dir +
        '/packages')
    pltfm_tar_name = ''
    for f in os.listdir('./'):
        if f.endswith('.tgz'):
            pltfm_tar_name = f
    pltfm_tar = tarfile.open(pltfm_tar_name)
    pltfm_tar.extractall()
    bf_pltfm_dir = str(Path(
        get_ref_bsp_abs_path()).parent) + '/' + ref_bsp_dir + '/packages/' + \
                   pltfm_tar.getnames()[0]

    aps_pltfm_dir = bf_pltfm_dir + '/platforms/apsn/'
    if os.path.exists(aps_pltfm_dir):
        shutil.rmtree(aps_pltfm_dir)

    shutil.copytree(aps_bsp_dir_absolute, aps_pltfm_dir)

    pltfm_tar.close()
    ref_bsp_tar.close()
    os.chdir(bf_pltfm_dir)
    os.system('patch -p1 < {0}/{1}'.format(
        str(Path(aps_bsp_installation_file).parent), get_diff_file_name()))
    # os.environ['BSP'] = os.getcwd()
    # print("BSP home directory set to {}".format(os.environ['BSP']))
    os.environ['BSP_INSTALL'] = get_env_var('SDE_INSTALL')
    print("BSP_INSTALL directory set to {}".format(os.environ['BSP_INSTALL']))

    install_bsp_deps()
    os.system("autoreconf && autoconf")
    os.system("chmod +x ./autogen.sh")
    thrift_flag = ''
    if get_p4_studio_build_profile_name() != stratum_profile:
        thrift_flag = '--enable-thrift'
    if get_switch_model() == constants.bf2556x_1t:
        execute_cmd("CFLAGS=-Wno-error ./configure --prefix={0} {1} "
                    "--with-tof-brgup-plat".format(os.environ['BSP_INSTALL'],
                                                   thrift_flag))
    else:
        execute_cmd("CFLAGS=-Wno-error ./configure --prefix={0} {1}".format(
            os.environ['BSP_INSTALL'], thrift_flag))
    os.system("make")
    os.system("sudo make install")
    os.chdir(dname)
    return True
コード例 #4
0
ファイル: InstallAPS.py プロジェクト: srieger1/APS-One-touch
def do_basic_path_validation(prof_name):
    # Do basic path verification.
    print('Selected build profile is {}.'.format(prof_name))
    print('Switch model : {}'.format(get_switch_model()))
    validate_path_existence(get_sde_pkg_abs_path(), 'Barefoot SDE')
    if not is_sim_profile_selected():
        validate_path_existence(get_ref_bsp_abs_path(), 'BF BSP')
    if get_selected_profile_name() in [
            constants.stratum_sim_profile_name,
            constants.stratum_hw_profile_name
    ]:
        validate_path_existence(get_stratum_home_absolute(), 'Stratum')
コード例 #5
0
def install_switch_bsp():
    set_sde_env()
    aps_bsp_installation_file = get_aps_bsp_pkg_abs_path()
    if (get_switch_model() == constants.bf6064x_t and (
            'BF2556' in aps_bsp_installation_file or 'bf2556' in aps_bsp_installation_file)) \
            or (get_switch_model() == constants.bf2556x_1t and (
            'BF6064' in aps_bsp_installation_file or 'bf6064' in aps_bsp_installation_file)):
        print("ERROR: Incompatible BSP provided in settings.yaml,"
              " Switch model is {model} but BSP is {bsp}".format(
                  model=get_switch_model(), bsp=aps_bsp_installation_file))
        exit(0)

    print("Installing {}".format(aps_bsp_installation_file))

    os.environ['BSP_INSTALL'] = get_env_var('SDE_INSTALL')
    print("BSP_INSTALL directory set to {}".format(os.environ['BSP_INSTALL']))

    install_bsp_deps()

    import subprocess
    import re
    out = subprocess.check_output("cmake --version", shell=True)
    res = re.search(r'version\s*([\d.]+)', str(out)).group(1)
    if res >= '3.13':
        cmake_cmd = 'cmake -DCMAKE_INSTALL_PREFIX={}'.format(
            get_env_var('SDE_INSTALL'))
        cmake_cmd += ' -B ' + aps_bsp_installation_file
        cmake_cmd += ' -S ' + aps_bsp_installation_file
    else:
        cmake_cmd = 'cmake -DCMAKE_INSTALL_PREFIX={}'.format(
            get_env_var('SDE_INSTALL'))
        cmake_cmd += ' -B' + aps_bsp_installation_file
        cmake_cmd += ' -H' + aps_bsp_installation_file
    execute_cmd(cmake_cmd)
    os.system("make -C {0}".format(aps_bsp_installation_file))
    os.system("make -C {0} install".format(aps_bsp_installation_file))

    return True
コード例 #6
0
ファイル: drivers.py プロジェクト: srieger1/APS-One-touch
def load_and_verify_kernel_modules():
    output = execute_cmd_n_get_output('lsmod')
    bf_mod = True
    i2c_i801 = True

    os.system("sudo modprobe -q i2c-i801")
    os.system("sudo modprobe -q i2c-dev")

    sde_module_names = get_sde_modules()
    if sde_module_names is not None:
        for module_name in sde_module_names:
            if module_name == sde_module_bf_kdrv_string_value:
                if module_name not in output:
                    load_bf_kdrv()
                else:
                    print('Module {} already loaded'.format(module_name))
            elif module_name == sde_module_bf_kpkt_string_value:
                if module_name not in output:
                    load_bf_kpkt()
                else:
                    print('Module {} already loaded'.format(module_name))
            else:
                print('Invalid module to load - {}.'.format(module_name))
                exit(0)
    else:
        print('Select at-least one SDE module to load in settings.xml')
        exit(0)

    output = execute_cmd_n_get_output('lsmod')

    if 'i2c_i801' not in output and is_ubuntu():
        # Ubuntu check is there because i2c_i801 appears only in output of
        # lsmod in Ubuntu
        i2c_i801 = False
        print('ERROR:i2c_i801 is not loaded.')

    if not any(mod in output for mod in [sde_module_bf_kdrv_string_value,
                                         sde_module_bf_kpkt_string_value]):
        bf_mod = False
        print("ERROR: Neither of {0}/{1} module loaded.".
              format(sde_module_bf_kdrv_string_value,
                     sde_module_bf_kpkt_string_value))

    # Load switch specific kernel modules
    if get_switch_model() == constants.bf2556x_1t:
        return bf_mod and i2c_i801 and load_and_verify_kernel_modules_bf2556()
    else:
        return bf_mod and i2c_i801 and load_and_verify_kernel_modules_bf6064()
コード例 #7
0
def start_stratum():
    print("Starting Stratum....")
    stratum_start_cmd_bsp_less = 'sudo {0}/bazel-bin/stratum/hal/bin/barefoot/stratum_bf \
    --external_stratum_urls=0.0.0.0:28000 \
    --grpc_max_recv_msg_size=256 \
    --bf_sde_install={1} \
    --persistent_config_dir={2} \
    --forwarding_pipeline_configs_file={2}/p4_pipeline.pb.txt \
    --chassis_config_file={2}/chassis_config.pb.txt \
    --write_req_log_file={2}/p4_writes.pb.txt \
    --bf_switchd_cfg={0}/stratum/hal/bin/barefoot/tofino_skip_p4_no_bsp.conf'.format(
        get_env_var(constants.stratum_home_env_var_name),
        get_env_var(constants.bf_sde_install_env_var_name),
        get_env_var(constants.stratum_config_env_var_name)
    )

    append_to_env_var(constants.ld_lib_path_env_var_name,
                      common.get_gb_lib_home_absolute())

    stratum_start_cmd_bsp = 'export PLATFORM=x86-64-stordis-bf2556x-1t-r0 && \
    sudo -E start-stratum.sh --bf_sim '

    if get_switch_model() == constants.bf6064x_t:
        stratum_start_cmd_bsp = 'export PLATFORM=x86-64-stordis-bf6064x-t-r0 && \
            sudo -E start-stratum.sh --bf_sim '

    # Following call is made from bf_sde.py, following call will not be made if user does nothing for BF SDE.
    if not load_and_verify_kernel_modules():
        print("ERROR:Some kernel modules are not loaded.")
        exit(0)

    os.chdir(get_env_var(constants.stratum_home_env_var_name))
    print('Current dir: {}'.format(os.getcwd()))
    if get_stratum_mode() == 'bsp-less':
        print("Starting Stratum in bsp-less mode...")
        print("Executing command {}".format(stratum_start_cmd_bsp_less))
        shutil.copyfile(get_env_var(
            constants.stratum_home_env_var_name) + '/stratum/hal/config/x86-64-stordis-bf2556x-1t-r0/port_map.json',
                        get_env_var(
                            constants.bf_sde_install_env_var_name) + '/share/port_map.json')
        os.system(stratum_start_cmd_bsp_less)
    else:
        print("Starting Stratum in bsp mode...")
        print("Executing command {}".format(stratum_start_cmd_bsp))
        os.system(stratum_start_cmd_bsp)
    return True
コード例 #8
0
ファイル: drivers.py プロジェクト: khooi8913/APS-One-touch
def load_and_verify_kernel_modules():
    output = execute_cmd_n_get_output('lsmod')
    bf_mod = True

    sde_module_names = get_sde_modules()
    if sde_module_names is not None:
        for module_name in sde_module_names:
            if module_name == sde_module_bf_kdrv_string_value:
                if module_name not in output:
                    load_bf_kdrv()
                else:
                    print('Module {} already loaded'.format(module_name))
            elif module_name == sde_module_bf_kpkt_string_value:
                if module_name not in output:
                    load_bf_kpkt()
                else:
                    print('Module {} already loaded'.format(module_name))
            else:
                print('Invalid module to load - {}.'.format(module_name))
                exit(0)
    else:
        print('Select at-least one SDE module to load in settings.xml')
        exit(0)

    output = execute_cmd_n_get_output('lsmod')

    if not any(
            mod in output for mod in
        [sde_module_bf_kdrv_string_value, sde_module_bf_kpkt_string_value]):
        bf_mod = False
        print("ERROR: Neither of {0}/{1} module loaded.".format(
            sde_module_bf_kdrv_string_value, sde_module_bf_kpkt_string_value))

    # Load switch specific kernel modules
    if get_switch_model() == constants.bf2556x_1t:
        return bf_mod and load_and_verify_kernel_modules_bf2556()
    else:
        return bf_mod and load_and_verify_kernel_modules_bf6064()
コード例 #9
0
ファイル: bf_sde.py プロジェクト: srieger1/APS-One-touch
def get_diff_file_name():
    return '{}.diff'.format(get_switch_model()).lower()