Esempio n. 1
0
def load_drivers():
    if get_sde_profile_name() == constants.sde_hw_profile_name:
        print('Loading kernel modules.')
        if not load_and_verify_kernel_modules():
            print("ERROR:Some kernel modules are not loaded.")
            #exit(0)
    else:
        print('Running simulation, No need to load kernel modules.')
Esempio n. 2
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_home_absolute() + '/compilation_root')

    stratum_start_cmd_bsp = 'sudo LD_LIBRARY_PATH={3} {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_sim'.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),
                         get_env_var(constants.ld_lib_path_env_var_name))

    if not load_and_verify_kernel_modules():
        print("ERROR:Some kernel modules are not loaded.")
        exit(0)

    shutil.copyfile(
        get_env_var(constants.stratum_home_env_var_name) +
        '/stratum/hal/bin/barefoot/platforms/x86-64-stordis-bf2556x-1t-r0.json',
        get_env_var(constants.bf_sde_install_env_var_name) +
        '/share/port_map.json')
    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))
        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)
Esempio n. 3
0
def run_sal():
    print('Starting SAL reference application...')
    if get_selected_profile_name() == constants.sal_hw_profile_name and not load_and_verify_kernel_modules():
        print("ERROR:Some kernel modules are not loaded.")
        exit(0)

    #os.environ['TCMALLOC_LARGE_ALLOC_REPORT_THRESHOLD'] = '64077925800531312640'
    set_env_var(constants.sal_home_env_var_name, sal_rel_dir)

    sal_executable = sal_rel_dir + '/build/salRefApp'
    sal_run_cmd='sudo -E LD_LIBRARY_PATH={0}:{1} {2}'.format(
        sal_rel_dir + '/lib',
        get_sde_home_absolute() + '/install/lib', sal_executable)
    print('Running SAL with command: {}'.format(sal_run_cmd))
    os.system(sal_run_cmd)
Esempio n. 4
0
def run_sal():
    print('Starting SAL reference application...')
    set_sal_runtime_env()
    if get_selected_profile_name(
    ) == constants.sal_hw_profile_name and not load_and_verify_kernel_modules(
    ):
        print("ERROR:Some kernel modules are not loaded.")
        exit(0)

    sal_executable = sal_rel_dir + '/build/salRefApp'
    sal_run_cmd = 'sudo -E LD_LIBRARY_PATH={0}:{1}:{2} {3}'.format(
        sal_rel_dir + '/build', sal_rel_dir + '/lib',
        get_sde_home_absolute() + '/install/lib', sal_executable)
    print('Running SAL with command: {}'.format(sal_run_cmd))
    os.system(sal_run_cmd)
Esempio n. 5
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
Esempio n. 6
0
def run_sal():
    print('Starting SAL reference application...')
    if get_selected_profile_name(
    ) == constants.sal_hw_profile_name and not load_and_verify_kernel_modules(
    ):
        print("ERROR:Some kernel modules are not loaded.")
        exit(0)
    sal_home = get_env_var(constants.sal_home_env_var_name)
    sal_executable = sal_home + '/build/salRefApp'
    sal_run_cmd = 'sudo -E LD_LIBRARY_PATH={0}:{1}:{2}:{3} {4}'.format(
        sal_home + '/build', sal_home + '/lib',
        get_env_var(constants.tp_install_env_var_name) + '/lib',
        get_env_var(constants.sal_home_env_var_name) + '/install/lib',
        sal_executable)
    print('Running SAL with command: {}'.format(sal_run_cmd))
    execute_cmd(sal_run_cmd)
    return True
Esempio n. 7
0
def start_bf_switchd():
    # os.chdir(common.dname)
    print('Starting BF switchd.')
    set_sde_env()
    profile_name = get_sde_profile_name()

    # Check this is an HW and all drivers are loaded
    if profile_name == constants.sde_hw_profile_name and not load_and_verify_kernel_modules(
    ):
        print("ERROR:Some kernel modules are not loaded.")
        exit(0)

    if profile_name == constants.sde_sim_profile_name:
        # TODO Do something meaningful, Possibly launch tofino model in separate shell,
        # Currently This just an interrupt for user to start tofino model.
        input('Make sure that tofino-model is running?')

    p4_prog_name = get_from_setting_dict('BF SDE', 'p4_name')

    # LD_LIBRARY_PATH is set for ONLPv2 case, libs in install/lib folder are
    # not found there but this does not cause any harm for Ubuntu case either.
    # set_env('LD_LIBRARY_PATH', "/{0}/install/lib".format(get_env_var('SDE')))
    # print("LD_LIBRARY_PATH : ")
    # os.system("echo $LD_LIBRARY_PATH")

    if not p4_prog_name:
        print("Starting switchd without p4 program")
        start_switchd_cmd = "sudo {0}/install/bin/bf_switchd --install-dir {" \
                            "0}/install --conf-file {" \
                            "0}/pkgsrc/p4-examples/tofino/tofino_skip_p4.conf" \
                            ".in --skip-p4".format(get_env_var('SDE'))
        if profile_name == constants.sde_hw_profile_name:
            start_switchd_cmd = "sudo -E {0}/run_switchd.sh -c {0}/pkgsrc/p4-examples/tofino/tofino_skip_p4.conf.in --skip-p4".format(
                get_env_var('SDE'))
    else:
        print("Starting switchd with P4 prog:{}".format(p4_prog_name))
        start_switchd_cmd = 'sudo -E {0} /run_switchd.sh -p {1}'.format(
            get_env_var('SDE'), p4_prog_name.replace(".p4", ""))
    username = getpass.getuser()

    if username == "root":
        start_switchd_cmd = start_switchd_cmd.replace("sudo -E", "")
    alloc_dma()
    print("Starting switchd with command : {}".format(start_switchd_cmd))
    os.system(start_switchd_cmd)
Esempio n. 8
0
def set_sde_env():
    print("Setting environment for BF_SDE.")
    sde_home_absolute = get_sde_home_absolute()
    if validate_path_existence(sde_home_absolute, 'SDE'):
        set_env_var(constants.sde_env_var_name, sde_home_absolute)
        set_env_var(constants.sde_install_env_var_name,
                    get_env_var(constants.sde_env_var_name) + '/install')
        print('Environment variables set: \n SDE: {0} \n SDE_INSTALL: {1}'.
              format(get_env_var(constants.sde_env_var_name),
                     get_env_var(constants.sde_install_env_var_name)))
    else:
        print('ERROR: SDE directory couldnt be found, exiting .')
        exit(0)

    if get_sde_profile_name() == constants.sde_hw_profile_name:
        print('Loading kernel modules.')
        if not load_and_verify_kernel_modules():
            print("ERROR:Some kernel modules are not loaded.")
            exit(0)
    else:
        print('Running simulation, No need to load kernel modules.')

    return True