Пример #1
0
def load_and_verify_kernel_modules():
    output = execute_cmd('lsmod')
    bf_kdrv = True
    i2c_i801 = True

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

    if 'bf_kdrv' not in output:
        load_bf_kdrv()

    output = execute_cmd('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 'bf_kdrv' not in output:
        bf_kdrv = False
        print("ERROR:bf_kdrv is not loaded.")

    # Load switch specific kernel modules
    if get_switch_model_from_settings() == constants.bf2556x_1t:
        return bf_kdrv and i2c_i801 and load_and_verify_kernel_modules_bf2556()
    else:
        return bf_kdrv and i2c_i801 and load_and_verify_kernel_modules_bf6064()
Пример #2
0
def do_basic_path_validation(profile_name):
    # Do basic path verification.
    print('Selected build profile is {}.'.format(profile_name))
    print('Switch model : {}'.format(get_switch_model_from_settings()))
    validate_path_existence(get_sde_pkg_abs_path(), 'Barefoot SDE')
    if not is_sim_profile_selected():
        validate_path_existence(get_bsp_pkg_abs_path(), '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')
Пример #3
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_from_settings() == 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)
Пример #4
0
import constants
from bf_sde import load_bf_sde_profile
from common import read_settings, get_selected_profile_name, \
    get_sde_pkg_abs_path, get_bsp_pkg_abs_path, \
    is_sim_profile_selected, get_switch_model_from_settings, \
    validate_path_existence
from sal import load_sal_profile
from stratum import load_stratum_profile, get_stratum_home_absolute

if __name__ == '__main__':
    read_settings()
    profile_name = get_selected_profile_name()
    # Do basic path verification.

    print('Selected build profile is {}.'.format(profile_name))
    print('Switch model : {}'.format(get_switch_model_from_settings()))
    validate_path_existence(get_sde_pkg_abs_path(), 'Barefoot SDE')
    if not is_sim_profile_selected():
        validate_path_existence(get_bsp_pkg_abs_path(), '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')

    if profile_name in ['stratum_hw_profile', 'stratum_sim_profile']:
        load_stratum_profile()
    elif profile_name == 'sde_sim_profile' or profile_name == 'sde_hw_profile':
        load_bf_sde_profile()
    else:
        load_sal_profile()