背景 经常需要去看mlx的PCIe初始化流程,尤其是mlx5_load, 但实际与PCIe初始化过程的关系和时机的全局图很难从单个函数或者单次跟踪某个行为查看,本文主要以PCIe初始化为锚点,注册PCIe驱动到Linux驱动框架后,PCIe设备被scan到之后调用probe函数为主要流程的图。 主要流程图 缩略图: 详细图: mlx5_core.koinitmlx5_core_verify_paramsmlx5_fpga_ipsec_build_fs_cmdsmlx5_register_debugfsmlx5_create_core_dirpci_register_driverstruct pci_driver mlx5_core_driver .probe = probe_one, .remove = remove_one, .suspend = mlx5_suspend, .resume = mlx5_resume, .shutdown = shutdown, .driver.pm = mlnx_pm, .err_handler = &mlx5_err_handler, .sriov_configure = mlx5_core_sriov_configure, .sriov_get_vf_total_msix = mlx5_sriov_get_vf_total_msix, .sriov_set_msix_vec_count = mlx5_core_sriov_set_msix_vec_count,mlx5_sf_driver_registermlx5e_initcleanupprobe_oneremove_onemlx5_suspendmlx5_resumeshutdownmlx5_err_handlermlnx_pmstruct dev_pm_ops mlnx_pm .suspend = suspend, .resume = resume,suspendresumestruct pci_error_handlers mlx5_err_handler .error_detected = mlx5_pci_err_detected, .slot_reset = mlx5_pci_slot_reset, .resume = mlx5_pci_resume};mlx5_pci_err_detectedmlx5_pci_slot_resetmlx5_pci_resumemlx5_core_disable_hcadisable_hcamlx5_uninit_onemlx5_pci_closemlx5_try_fast_unloadmlx5_mdev_uninitmlx5_function_teardownmlx5_unloadmlx5_cleanup_oncemlx5_remove_core_dirmlx5_unload_onemlx5_pci_disable_devicemlx5_core_get_capsmlx5_core_get_caps_modemlx5_core_other_function_set_capsset_capsmlx5_load_onemlx5_load_one_devl_lockedhandle_hca_capmlx5_is_roce_onmlx5_core_disable_sf_hcamlx5_pci_enable_deviceset_hca_capmlx5_core_enable_sf_hcaenable_hcamlx5_unload_one_devl_locked__init_backportmlx5_init_onemlx5_function_setupmlx5_loadmlx5_init_oncemlx5_core_enable_hcamlx5_recover_devicemlx5_disable_devicemlx5_mdev_initwait_fw_initmlx5_core_set_issi 全部围绕这PCIe驱动的fops展开,最主要的是probe流程,最终走到mlx5_load流程,mlx5_load涉及到很多其他功能初始化,具体参考兄弟篇