Thread View
j: Next unread message
k: Previous unread message
j a: Jump to all threads
j l: Jump to MailingList overview
From: maogangpin
>
driver inclusion
category: feature
bugzilla: https://atomgit.com/openeuler/kernel/issues/9708
CVE: NA
---------------------------------
Current hinic5 driver does not support PXE, this will causing timeout while boot from remote host.
Signed-off-by: maogangpin >
Reviewed-by: Qiujun >
Reviewed-by: chiqijun >
---
.../ethernet/huawei/hinic5/GLOBAL_VERSION_NEW | 12 +
.../ethernet/huawei/hinic5/build/__init__.py | 3 +
.../huawei/hinic5/build/build_main.py | 166 +
.../huawei/hinic5/build/build_util.py | 105 +
.../net/ethernet/huawei/hinic5/build/env.py | 708 ++++
.../hinic5/build/host/linux/Makefile.ko | 123 +
.../hinic5/build/host/linux/__init__.py | 3 +
.../hinic5/build/host/linux/build_host.py | 99 +
.../hinic5/build/host/linux/kcompat-lib.sh | 300 ++
.../hinic5/build/host/linux/nic/__init__.py | 3 +
.../hinic5/build/host/linux/nic/build_nic.py | 182 +
.../host/linux/nic/nic-kcompat-generator.sh | 500 +++
.../hinic5/build/host/linux/roce/__init__.py | 3 +
.../build/host/linux/roce/build_roce.py | 567 ++++
.../host/linux/roce/roce_kcompat_generator.sh | 330 ++
.../hinic5/build/host/linux/sdk/__init__.py | 3 +
.../hinic5/build/host/linux/sdk/build_sdk.py | 207 ++
.../host/linux/sdk/sdk-kcompat-generator.sh | 308 ++
.../hinic5/build/host/linux/udma/__init__.py | 3 +
.../build/host/linux/udma/build_udma.py | 532 +++
.../hinic5/build/tools/build_log/build_log.sh | 95 +
.../cmake/huawei_secure_cConfig.cmake | 96 +
.../huawei_secure_c/include/securec.h | 676 ++++
.../huawei_secure_c/include/securectype.h | 613 ++++
.../adapt_implicit_fallthrough_level5.patch | 20 +
.../platform/huawei_secure_c/src/Makefile | 196 ++
.../platform/huawei_secure_c/src/fscanf_s.c | 52 +
.../platform/huawei_secure_c/src/fwscanf_s.c | 51 +
.../platform/huawei_secure_c/src/gets_s.c | 72 +
.../platform/huawei_secure_c/src/input.inl | 2482 ++++++++++++++
.../platform/huawei_secure_c/src/memcpy_s.c | 630 ++++
.../platform/huawei_secure_c/src/memmove_s.c | 122 +
.../platform/huawei_secure_c/src/memset_s.c | 583 ++++
.../platform/huawei_secure_c/src/output.inl | 1951 +++++++++++
.../platform/huawei_secure_c/src/scanf_s.c | 50 +
.../platform/huawei_secure_c/src/secinput.h | 193 ++
.../huawei_secure_c/src/securecutil.c | 82 +
.../huawei_secure_c/src/securecutil.h | 682 ++++
.../huawei_secure_c/src/secureinput_a.c | 37 +
.../huawei_secure_c/src/secureinput_w.c | 74 +
.../huawei_secure_c/src/secureprintoutput.h | 168 +
.../huawei_secure_c/src/secureprintoutput_a.c | 119 +
.../huawei_secure_c/src/secureprintoutput_w.c | 40 +
.../platform/huawei_secure_c/src/snprintf_s.c | 110 +
.../platform/huawei_secure_c/src/sprintf_s.c | 57 +
.../platform/huawei_secure_c/src/sscanf_s.c | 57 +
.../platform/huawei_secure_c/src/strcat_s.c | 103 +
.../platform/huawei_secure_c/src/strcpy_s.c | 392 +++
.../platform/huawei_secure_c/src/strncat_s.c | 121 +
.../platform/huawei_secure_c/src/strncpy_s.c | 157 +
.../platform/huawei_secure_c/src/strtok_s.c | 116 +
.../platform/huawei_secure_c/src/swprintf_s.c | 47 +
.../platform/huawei_secure_c/src/swscanf_s.c | 53 +
.../platform/huawei_secure_c/src/vfscanf_s.c | 63 +
.../platform/huawei_secure_c/src/vfwscanf_s.c | 66 +
.../platform/huawei_secure_c/src/vscanf_s.c | 62 +
.../huawei_secure_c/src/vsnprintf_s.c | 146 +
.../platform/huawei_secure_c/src/vsprintf_s.c | 69 +
.../platform/huawei_secure_c/src/vsscanf_s.c | 88 +
.../huawei_secure_c/src/vswprintf_s.c | 64 +
.../platform/huawei_secure_c/src/vswscanf_s.c | 79 +
.../platform/huawei_secure_c/src/vwscanf_s.c | 63 +
.../platform/huawei_secure_c/src/wcscat_s.c | 108 +
.../platform/huawei_secure_c/src/wcscpy_s.c | 87 +
.../platform/huawei_secure_c/src/wcsncat_s.c | 116 +
.../platform/huawei_secure_c/src/wcsncpy_s.c | 110 +
.../platform/huawei_secure_c/src/wcstok_s.c | 115 +
.../platform/huawei_secure_c/src/wmemcpy_s.c | 73 +
.../platform/huawei_secure_c/src/wmemmove_s.c | 72 +
.../platform/huawei_secure_c/src/wscanf_s.c | 51 +
.../drv_cfm_intf/hmm/hinic5_hmm.h | 101 +
.../drv_cfm_intf/hmm/hmm_buddy.h | 77 +
.../drv_cfm_intf/hmm/hmm_common.h | 577 ++++
.../drv_sdk_intf/hisdk/hinic5_cqm.h | 901 +++++
.../drv_sdk_intf/hisdk/hinic5_service.h | 590 ++++
.../drv_sdk_intf/hisdk/hinic5_vram_api.h | 50 +
.../drv_sdk_intf/ossl/ossl_user.h | 13 +
.../drv_sdk_intf/ossl/vbs_kcompat.h | 13 +
.../urts/arch/arm/udk_byteorder.h | 33 +
.../drv_sdk_intf/urts/arch/arm/udk_cycles.h | 35 +
.../drv_sdk_intf/urts/arch/arm/udk_io.h | 27 +
.../urts/arch/arm/udk_membarrier.h | 49 +
.../urts/arch/x86/udk_byteorder.h | 88 +
.../drv_sdk_intf/urts/arch/x86/udk_cycles.h | 33 +
.../drv_sdk_intf/urts/arch/x86/udk_io.h | 26 +
.../urts/arch/x86/udk_membarrier.h | 59 +
.../drv_sdk_intf/urts/udk_args.h | 93 +
.../drv_sdk_intf/urts/udk_atomic.h | 235 ++
.../drv_sdk_intf/urts/udk_byteorder.h | 79 +
.../drv_sdk_intf/urts/udk_common.h | 243 ++
.../drv_sdk_intf/urts/udk_cycles.h | 75 +
.../drv_sdk_intf/urts/udk_ethdev.h | 713 ++++
.../drv_sdk_intf/urts/udk_ether.h | 116 +
.../drv_sdk_intf/urts/udk_io.h | 23 +
.../drv_sdk_intf/urts/udk_log.h | 243 ++
.../drv_sdk_intf/urts/udk_malloc.h | 107 +
.../drv_sdk_intf/urts/udk_mbuf.h | 513 +++
.../drv_sdk_intf/urts/udk_membarrier.h | 17 +
.../drv_sdk_intf/urts/udk_mempool.h | 603 ++++
.../drv_sdk_intf/urts/udk_memzone.h | 121 +
.../drv_sdk_intf/urts/udk_ops.h | 113 +
.../drv_sdk_intf/urts/udk_pci.h | 46 +
.../drv_sdk_intf/urts/udk_ring.h | 249 ++
.../drv_sdk_intf/urts/udk_rwlock.h | 148 +
.../drv_sdk_intf/urts/udk_spinlock.h | 102 +
.../drv_sdk_intf/urts/udk_usrnl.h | 219 ++
.../drv_sdk_intf/urts/udk_vdev.h | 147 +
.../drv_srvc_intf/roce/hrn5_dfx_u_api.h | 60 +
.../drv_srvc_intf/roce/hrn5_u_api.h | 146 +
.../drv_srvc_intf/roce/hyper_roce_extend.h | 68 +
.../drv_srvc_intf/roce/roce_uld_kernel_api.h | 536 +++
.../drv_srvc_intf/roce/roce_uld_user_api.h | 209 ++
.../fw_msg_intf/ccp/ccp_algo_format.h | 398 +++
.../fw_msg_intf/cfm/hmm_cmd_defs.h | 259 ++
.../fw_msg_intf/cfm/qos_base_mpu_defs.h | 120 +
.../fw_msg_intf/cqm/cqm_npu_cmd.h | 23 +
.../fw_msg_intf/cqm/cqm_npu_cmd_defs.h | 82 +
.../fw_msg_intf/mag/eeprom_qsfp_defs.h | 440 +++
.../fw_msg_intf/mag/eeprom_sfp_defs.h | 209 ++
.../fw_msg_intf/mpu/mpu_outband_mctp_cmd.h | 44 +
.../mpu/mpu_outband_mctp_cmd_defs.h | 206 ++
.../fw_msg_intf/mpu/mpu_outband_ncsi_cmd.h | 239 ++
.../mpu/mpu_outband_ncsi_cmd_defs.h | 123 +
.../fw_msg_intf/mpu/mpu_outband_smbus_cmd.h | 134 +
.../mpu/mpu_outband_smbus_cmd_defs.h | 726 ++++
.../fw_msg_intf/nic/nic_mig_mpu_intf.h | 36 +
.../fw_msg_intf/nic/nic_mig_npu_intf.h | 175 +
.../fw_msg_intf/nic/nic_npu_cmd_defs.h | 200 ++
.../fw_msg_intf/nic/nic_npu_wqe_defs.h | 333 ++
.../fw_msg_intf/public/adm_dict.h | 78 +
.../fw_msg_intf/public/counter_dict.h | 31 +
.../fw_msg_intf/public/dfx_cap_pkt_cfg.h | 147 +
.../fw_msg_intf/public/hmm_context.h | 230 ++
.../fw_msg_intf/rdma/roce5_gid_type.h | 21 +
.../fw_msg_intf/rdma/roce_cqe_format.h | 159 +
.../rdma/roce_npu_cmd_ext_data_defs.h | 23 +
.../fw_msg_intf/rdma/roce_npu_cmd_type_defs.h | 71 +
.../fw_msg_intf/rdma/roce_wqe_opt_types.h | 43 +
.../fw_msg_intf/rdma/roce_wqe_ulp_task.h | 121 +
.../ubc_net/ubcnet_base_view_defs.h | 12 +
.../ubc_net/ubcnet_heartbeat_view_defs.h | 138 +
.../fw_msg_intf/ubc_net/ubcnet_mami_extend.h | 267 ++
.../fw_msg_intf/ubc_net/ubcnet_mpu_cmd.h | 54 +
.../fw_msg_intf/ubc_net/ubcnet_mpu_cmd_defs.h | 276 ++
.../fw_msg_intf/ubc_net/ubcnet_npu_cmd.h | 48 +
.../fw_msg_intf/ubc_net/ubcnet_npu_cmd_defs.h | 175 +
.../fw_msg_intf/ubc_net/ubcnet_rdma_extend.h | 89 +
.../ubc_net/ubcnet_rdma_view_defs.h | 112 +
.../host/cfm/hmm/hmm_buddy.c | 186 +
.../host/cfm/hmm/hmm_common.c | 798 +++++
.../host/cfm/hmm/hmm_em.c | 395 +++
.../host/cfm/hmm/hmm_em_inner.h | 76 +
.../host/cfm/hmm/hmm_init.c | 157 +
.../host/cfm/hmm/hmm_mpt.c | 60 +
.../host/cfm/hmm/hmm_mr.c | 397 +++
.../host/cfm/hmm/hmm_mtt.c | 586 ++++
.../host/cfm/hmm/hmm_umem.c | 404 +++
.../host/cfm/hmm/hmm_umem_inner.h | 98 +
.../host/cfm/rdma/rdma_bitmap.c | 148 +
.../host/cfm/rdma/rdma_bitmap.h | 40 +
.../include/sdk/knldk/hinic5_lld_common.h | 22 +
.../host/include/sdk/knldk/hinic5_vram.h | 34 +
.../host/include/sdk/knldk/vram_common.h | 182 +
.../cqm_182x_cmdq_adapt/cqm_182x_cmdq_ops.c | 89 +
.../cqm_182x_cmdq_adapt/cqm_182x_cmdq_ops.h | 41 +
.../cqm_187x_cmdq_adapt/cqm_187x_cmdq_ops.c | 87 +
.../cqm_187x_cmdq_adapt/cqm_187x_cmdq_ops.h | 54 +
.../host/sdk/knldk/cqm/cqm_bat_cla.c | 2745 +++++++++++++++
.../host/sdk/knldk/cqm/cqm_bat_cla.h | 256 ++
.../host/sdk/knldk/cqm/cqm_bitmap_table.c | 1807 ++++++++++
.../host/sdk/knldk/cqm/cqm_bitmap_table.h | 85 +
.../host/sdk/knldk/cqm/cqm_bloomfilter.c | 549 +++
.../host/sdk/knldk/cqm/cqm_bloomfilter.h | 54 +
.../host/sdk/knldk/cqm/cqm_cmd.c | 213 ++
.../host/sdk/knldk/cqm/cqm_cmd.h | 43 +
.../host/sdk/knldk/cqm/cqm_cmdq.h | 28 +
.../host/sdk/knldk/cqm/cqm_cmdq_adapt.c | 14 +
.../host/sdk/knldk/cqm/cqm_db.c | 571 ++++
.../host/sdk/knldk/cqm/cqm_db.h | 36 +
.../host/sdk/knldk/cqm/cqm_main.c | 2262 +++++++++++++
.../host/sdk/knldk/cqm/cqm_main.h | 520 +++
.../host/sdk/knldk/cqm/cqm_object.c | 1765 ++++++++++
.../host/sdk/knldk/cqm/cqm_object.h | 385 +++
.../host/sdk/knldk/cqm/cqm_object_intern.c | 1625 +++++++++
.../host/sdk/knldk/cqm/cqm_object_intern.h | 118 +
.../host/sdk/knldk/cqm/cqm_secure_mem.c | 253 ++
.../host/sdk/knldk/crm/hinic5_mgmt_msg.c | 817 +++++
.../host/sdk/knldk/include/hisdk5_hwif.h | 363 ++
.../host/sdk/knldk/include/hisdk5_typedef.h | 20 +
.../host/sdk/knldk/lld/CMakeLists.txt | 94 +
.../host/sdk/knldk/lld/Makefile | 185 +
.../host/sdk/knldk/vram/hinic5_vram.c | 309 ++
.../host/sdk/knldk/vram/vram_common.c | 224 ++
.../host/service/include/hinic5_rdma.h | 65 +
.../nic/ipxe/182x_cmdq_adapt/182x_cmdq_ops.c | 122 +
.../nic/ipxe/182x_cmdq_adapt/182x_cmdq_ops.h | 37 +
.../nic/ipxe/187x_cmdq_adapt/187x_cmdq_ops.c | 135 +
.../nic/ipxe/187x_cmdq_adapt/187x_cmdq_ops.h | 54 +
.../host/service/nic/ipxe/base/hinic5_cmd.h | 264 ++
.../host/service/nic/ipxe/base/hinic5_cmdq.c | 893 +++++
.../host/service/nic/ipxe/base/hinic5_cmdq.h | 250 ++
.../nic/ipxe/base/hinic5_cmdq_enhance.h | 168 +
.../service/nic/ipxe/base/hinic5_compat.h | 185 +
.../host/service/nic/ipxe/base/hinic5_csr.h | 118 +
.../nic/ipxe/base/hinic5_enhance_cmdq.c | 103 +
.../host/service/nic/ipxe/base/hinic5_eqs.c | 665 ++++
.../host/service/nic/ipxe/base/hinic5_eqs.h | 95 +
.../service/nic/ipxe/base/hinic5_hw_cfg.c | 228 ++
.../service/nic/ipxe/base/hinic5_hw_cfg.h | 121 +
.../service/nic/ipxe/base/hinic5_hw_comm.c | 459 +++
.../service/nic/ipxe/base/hinic5_hw_comm.h | 223 ++
.../host/service/nic/ipxe/base/hinic5_hwdev.c | 481 +++
.../host/service/nic/ipxe/base/hinic5_hwdev.h | 107 +
.../host/service/nic/ipxe/base/hinic5_hwif.c | 823 +++++
.../host/service/nic/ipxe/base/hinic5_hwif.h | 140 +
.../host/service/nic/ipxe/base/hinic5_mbox.c | 1236 +++++++
.../host/service/nic/ipxe/base/hinic5_mbox.h | 196 ++
.../host/service/nic/ipxe/base/hinic5_mgmt.c | 445 +++
.../host/service/nic/ipxe/base/hinic5_mgmt.h | 132 +
.../host/service/nic/ipxe/base/hinic5_wq.c | 144 +
.../host/service/nic/ipxe/base/hinic5_wq.h | 65 +
.../host/service/nic/ipxe/hinic5_mag_cfg.h | 209 ++
.../host/service/nic/ipxe/hinic5_main.c | 699 ++++
.../host/service/nic/ipxe/hinic5_nic_cfg.c | 1189 +++++++
.../host/service/nic/ipxe/hinic5_nic_cfg.h | 904 +++++
.../host/service/nic/ipxe/hinic5_nic_dev.h | 55 +
.../host/service/nic/ipxe/hinic5_nic_io.c | 633 ++++
.../host/service/nic/ipxe/hinic5_nic_io.h | 285 ++
.../host/service/nic/ipxe/hinic5_rx.c | 444 +++
.../host/service/nic/ipxe/hinic5_rx.h | 220 ++
.../host/service/nic/ipxe/hinic5_settings.c | 532 +++
.../host/service/nic/ipxe/hinic5_settings.h | 27 +
.../host/service/nic/ipxe/hinic5_tx.c | 498 +++
.../host/service/nic/ipxe/hinic5_tx.h | 224 ++
.../host/service/nic/ipxe/menu.ipxe | 25 +
.../host/service/nic/linux/CMakeLists.txt | 82 +
.../mpu/outband_mpu_ncsi_cmd_defs.h | 1641 +++++++++
.../drv_fw_msg/roce/hi182x/roce_mpu_cmd.h | 78 +
.../roce/hi182x/roce_mpu_cmd_defs.h | 543 +++
.../include/drv_fw_msg/roce/roce_aeq_format.h | 173 +
.../include/drv_fw_msg/roce/roce_cc_format.h | 238 ++
.../include/drv_fw_msg/roce/roce_cfg_format.h | 178 +
.../include/drv_fw_msg/roce/roce_ctx_format.h | 45 +
.../drv_fw_msg/roce/roce_hyper_npu_cmd.h | 211 ++
.../include/drv_fw_msg/roce/roce_npu_cmd.h | 146 +
.../drv_fw_msg/roce/roce_npu_cmd_cq_defs.h | 235 ++
.../drv_fw_msg/roce/roce_npu_cmd_defs.h | 318 ++
.../drv_fw_msg/roce/roce_npu_cmd_dfx_defs.h | 46 +
.../drv_fw_msg/roce/roce_npu_cmd_ext_defs.h | 115 +
.../drv_fw_msg/roce/roce_npu_cmd_gid_defs.h | 196 ++
.../drv_fw_msg/roce/roce_npu_cmd_mr_defs.h | 334 ++
.../drv_fw_msg/roce/roce_npu_cmd_qp_defs.h | 993 ++++++
.../drv_fw_msg/roce/roce_npu_cmd_srq_defs.h | 269 ++
.../drv_fw_msg/roce/roce_wqe_base_format.h | 565 ++++
.../include/drv_fw_msg/roce/roce_wqe_format.h | 316 ++
.../include/drv_fw_msg/roce/roce_xqe_format.h | 320 ++
.../include/drv_fw_msg/uboe/ub_aeqe.h | 356 ++
.../include/drv_fw_msg/uboe/ub_dw_index.h | 42 +
.../include/drv_fw_msg/uboe/ub_mpu_cmd.h | 117 +
.../include/drv_fw_msg/uboe/ub_mpu_cmd_defs.h | 937 +++++
.../drv_fw_msg/uboe/ub_mpu_dfx_cmd_defs.h | 337 ++
.../include/drv_fw_msg/uboe/ub_npu_base_cmd.h | 454 +++
.../include/drv_fw_msg/uboe/ub_npu_eid_cmd.h | 18 +
.../drv_fw_msg/uboe/ub_npu_eid_cmd_defs.h | 106 +
.../drv_fw_msg/uboe/ub_npu_event_cmd.h | 21 +
.../drv_fw_msg/uboe/ub_npu_event_cmd_defs.h | 53 +
.../drv_fw_msg/uboe/ub_npu_jetty_cmd.h | 49 +
.../drv_fw_msg/uboe/ub_npu_jetty_cmd_defs.h | 672 ++++
.../include/drv_fw_msg/uboe/ub_npu_jfc_cmd.h | 26 +
.../drv_fw_msg/uboe/ub_npu_jfc_cmd_defs.h | 198 ++
.../include/drv_fw_msg/uboe/ub_npu_jfr_cmd.h | 24 +
.../include/drv_fw_msg/uboe/ub_npu_jfrc_cmd.h | 26 +
.../drv_fw_msg/uboe/ub_npu_jfrc_cmd_defs.h | 105 +
.../include/drv_fw_msg/uboe/ub_npu_mapt_cmd.h | 30 +
.../drv_fw_msg/uboe/ub_npu_mapt_cmd_defs.h | 188 ++
.../include/drv_fw_msg/uboe/ub_npu_mig_cmd.h | 44 +
.../drv_fw_msg/uboe/ub_npu_mig_cmd_defs.h | 464 +++
.../include/drv_fw_msg/uboe/ub_npu_sip_cmd.h | 21 +
.../drv_fw_msg/uboe/ub_npu_sip_cmd_defs.h | 117 +
.../include/drv_fw_msg/uboe/ub_npu_srq_cmd.h | 24 +
.../drv_fw_msg/uboe/ub_npu_srq_cmd_defs.h | 242 ++
.../include/drv_fw_msg/uboe/ub_npu_tp_cmd.h | 60 +
.../drv_fw_msg/uboe/ub_npu_tp_cmd_defs.h | 1274 +++++++
.../include/drv_fw_msg/uboe/ub_npu_tpg_cmd.h | 25 +
.../drv_fw_msg/uboe/ub_npu_tpg_cmd_defs.h | 179 +
.../include/drv_fw_msg/uboe/ub_npu_upi_cmd.h | 16 +
.../drv_fw_msg/uboe/ub_npu_upi_cmd_defs.h | 146 +
.../drv_fw_msg/uboe/ub_npu_userctl_defs.h | 141 +
.../include/drv_fw_msg/uboe/ub_npu_utp_cmd.h | 18 +
.../drv_fw_msg/uboe/ub_npu_utp_cmd_defs.h | 161 +
.../include/drv_fw_msg/uboe/ub_npu_vtp_cmd.h | 26 +
.../drv_fw_msg/uboe/ub_npu_vtp_cmd_defs.h | 237 ++
.../drv_fw_msg/uboe/ub_ta_wqe_define.h | 3007 +++++++++++++++++
.../drv_fw_msg/uboe/ub_ta_wqe_format.h | 34 +
.../drv_fw_msg/uboe/ub_tp_wqe_define.h | 349 ++
.../drv_fw_msg/uboe/ub_tp_wqe_format.h | 20 +
.../include/drv_fw_msg/uboe/ub_wqe_format.h | 647 ++++
.../include/drv_fw_msg/uboe/ub_xqe_format.h | 498 +++
.../drv_fw_msg/uboe/uboe_pub_tbl_def.h | 52 +
.../include/drv_tool_msg/cfm_pub_cmd.h | 10 +
.../include/drv_tool_msg/hihtr_pub_cmd.h | 33 +
.../include/drv_tool_msg/hyper_roce_pub_cmd.h | 48 +
.../include/drv_tool_msg/mig_pub_cmd.h | 42 +
.../include/drv_tool_msg/roce_pub_cmd.h | 47 +
.../include/drv_tool_msg/ub_pub_cmd.h | 857 +++++
305 files changed, 82357 insertions(+)
create mode 100644 drivers/net/ethernet/huawei/hinic5/GLOBAL_VERSION_NEW
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/__init__.py
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/build_main.py
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/build_util.py
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/env.py
create mode 100644 drivers/net/ethernet/huawei/hinic5/build/host/linux/Makefile.ko
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/host/linux/__init__.py
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/host/linux/build_host.py
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/host/linux/kcompat-lib.sh
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/host/linux/nic/__init__.py
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/host/linux/nic/build_nic.py
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/host/linux/nic/nic-kcompat-generator.sh
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/host/linux/roce/__init__.py
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/host/linux/roce/build_roce.py
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/host/linux/roce/roce_kcompat_generator.sh
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/host/linux/sdk/__init__.py
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/host/linux/sdk/build_sdk.py
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/host/linux/sdk/sdk-kcompat-generator.sh
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/host/linux/udma/__init__.py
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/host/linux/udma/build_udma.py
create mode 100755 drivers/net/ethernet/huawei/hinic5/build/tools/build_log/build_log.sh
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/cmake/huawei_secure_cConfig.cmake
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/include/securec.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/include/securectype.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/patch/adapt_implicit_fallthrough_level5.patch
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/Makefile
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/fscanf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/fwscanf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/gets_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/input.inl
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/memcpy_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/memmove_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/memset_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/output.inl
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/scanf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/secinput.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/securecutil.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/securecutil.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/secureinput_a.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/secureinput_w.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/secureprintoutput.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/secureprintoutput_a.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/secureprintoutput_w.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/snprintf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/sprintf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/sscanf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/strcat_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/strcpy_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/strncat_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/strncpy_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/strtok_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/swprintf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/swscanf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/vfscanf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/vfwscanf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/vscanf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/vsnprintf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/vsprintf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/vsscanf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/vswprintf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/vswscanf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/vwscanf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/wcscat_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/wcscpy_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/wcsncat_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/wcsncpy_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/wcstok_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/wmemcpy_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/wmemmove_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/wscanf_s.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_cfm_intf/hmm/hinic5_hmm.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_cfm_intf/hmm/hmm_buddy.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_cfm_intf/hmm/hmm_common.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/hisdk/hinic5_cqm.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/hisdk/hinic5_service.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/hisdk/hinic5_vram_api.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/ossl/ossl_user.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/ossl/vbs_kcompat.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/arch/arm/udk_byteorder.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/arch/arm/udk_cycles.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/arch/arm/udk_io.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/arch/arm/udk_membarrier.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/arch/x86/udk_byteorder.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/arch/x86/udk_cycles.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/arch/x86/udk_io.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/arch/x86/udk_membarrier.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_args.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_atomic.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_byteorder.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_common.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_cycles.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_ethdev.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_ether.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_io.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_log.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_malloc.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_mbuf.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_membarrier.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_mempool.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_memzone.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_ops.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_pci.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_ring.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_rwlock.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_spinlock.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_usrnl.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_sdk_intf/urts/udk_vdev.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_srvc_intf/roce/hrn5_dfx_u_api.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_srvc_intf/roce/hrn5_u_api.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_srvc_intf/roce/hyper_roce_extend.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_srvc_intf/roce/roce_uld_kernel_api.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/drv_srvc_intf/roce/roce_uld_user_api.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/ccp/ccp_algo_format.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/cfm/hmm_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/cfm/qos_base_mpu_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/cqm/cqm_npu_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/cqm/cqm_npu_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/mag/eeprom_qsfp_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/mag/eeprom_sfp_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/mpu/mpu_outband_mctp_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/mpu/mpu_outband_mctp_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/mpu/mpu_outband_ncsi_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/mpu/mpu_outband_ncsi_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/mpu/mpu_outband_smbus_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/mpu/mpu_outband_smbus_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/nic/nic_mig_mpu_intf.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/nic/nic_mig_npu_intf.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/nic/nic_npu_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/nic/nic_npu_wqe_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/public/adm_dict.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/public/counter_dict.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/public/dfx_cap_pkt_cfg.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/public/hmm_context.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/rdma/roce5_gid_type.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/rdma/roce_cqe_format.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/rdma/roce_npu_cmd_ext_data_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/rdma/roce_npu_cmd_type_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/rdma/roce_wqe_opt_types.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/rdma/roce_wqe_ulp_task.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/ubc_net/ubcnet_base_view_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/ubc_net/ubcnet_heartbeat_view_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/ubc_net/ubcnet_mami_extend.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/ubc_net/ubcnet_mpu_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/ubc_net/ubcnet_mpu_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/ubc_net/ubcnet_npu_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/ubc_net/ubcnet_npu_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/ubc_net/ubcnet_rdma_extend.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_develop_interface/fw_msg_intf/ubc_net/ubcnet_rdma_view_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/cfm/hmm/hmm_buddy.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/cfm/hmm/hmm_common.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/cfm/hmm/hmm_em.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/cfm/hmm/hmm_em_inner.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/cfm/hmm/hmm_init.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/cfm/hmm/hmm_mpt.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/cfm/hmm/hmm_mr.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/cfm/hmm/hmm_mtt.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/cfm/hmm/hmm_umem.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/cfm/hmm/hmm_umem_inner.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/cfm/rdma/rdma_bitmap.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/cfm/rdma/rdma_bitmap.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/include/sdk/knldk/hinic5_lld_common.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/include/sdk/knldk/hinic5_vram.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/include/sdk/knldk/vram_common.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_182x_cmdq_adapt/cqm_182x_cmdq_ops.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_182x_cmdq_adapt/cqm_182x_cmdq_ops.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_187x_cmdq_adapt/cqm_187x_cmdq_ops.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_187x_cmdq_adapt/cqm_187x_cmdq_ops.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_bat_cla.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_bat_cla.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_bitmap_table.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_bitmap_table.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_bloomfilter.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_bloomfilter.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_cmd.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_cmdq.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_cmdq_adapt.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_db.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_db.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_main.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_main.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_object.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_object.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_object_intern.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_object_intern.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/cqm/cqm_secure_mem.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/crm/hinic5_mgmt_msg.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/include/hisdk5_hwif.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/include/hisdk5_typedef.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/lld/CMakeLists.txt
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/lld/Makefile
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/vram/hinic5_vram.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/sdk/knldk/vram/vram_common.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/include/hinic5_rdma.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/182x_cmdq_adapt/182x_cmdq_ops.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/182x_cmdq_adapt/182x_cmdq_ops.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/187x_cmdq_adapt/187x_cmdq_ops.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/187x_cmdq_adapt/187x_cmdq_ops.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_cmdq.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_cmdq.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_cmdq_enhance.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_compat.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_csr.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_enhance_cmdq.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_eqs.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_eqs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_hw_cfg.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_hw_cfg.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_hw_comm.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_hw_comm.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_hwdev.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_hwdev.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_hwif.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_hwif.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_mbox.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_mbox.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_mgmt.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_mgmt.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_wq.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/base/hinic5_wq.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/hinic5_mag_cfg.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/hinic5_main.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/hinic5_nic_cfg.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/hinic5_nic_cfg.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/hinic5_nic_dev.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/hinic5_nic_io.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/hinic5_nic_io.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/hinic5_rx.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/hinic5_rx.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/hinic5_settings.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/hinic5_settings.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/hinic5_tx.c
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/hinic5_tx.h
create mode 100755 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/ipxe/menu.ipxe
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/host/service/nic/linux/CMakeLists.txt
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/mpu/outband_mpu_ncsi_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/hi182x/roce_mpu_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/hi182x/roce_mpu_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_aeq_format.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_cc_format.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_cfg_format.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_ctx_format.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_hyper_npu_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_npu_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_npu_cmd_cq_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_npu_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_npu_cmd_dfx_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_npu_cmd_ext_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_npu_cmd_gid_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_npu_cmd_mr_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_npu_cmd_qp_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_npu_cmd_srq_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_wqe_base_format.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_wqe_format.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/roce/roce_xqe_format.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_aeqe.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_dw_index.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_mpu_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_mpu_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_mpu_dfx_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_base_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_eid_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_eid_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_event_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_event_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_jetty_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_jetty_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_jfc_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_jfc_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_jfr_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_jfrc_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_jfrc_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_mapt_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_mapt_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_mig_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_mig_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_sip_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_sip_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_srq_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_srq_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_tp_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_tp_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_tpg_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_tpg_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_upi_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_upi_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_userctl_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_utp_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_utp_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_vtp_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_npu_vtp_cmd_defs.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_ta_wqe_define.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_ta_wqe_format.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_tp_wqe_define.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_tp_wqe_format.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_wqe_format.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/ub_xqe_format.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_fw_msg/uboe/uboe_pub_tbl_def.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_tool_msg/cfm_pub_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_tool_msg/hihtr_pub_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_tool_msg/hyper_roce_pub_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_tool_msg/mig_pub_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_tool_msg/roce_pub_cmd.h
create mode 100644 drivers/net/ethernet/huawei/hinic5/src/dpu_platform_library/include/drv_tool_msg/ub_pub_cmd.h
diff --git a/drivers/net/ethernet/huawei/hinic5/GLOBAL_VERSION_NEW b/drivers/net/ethernet/huawei/hinic5/GLOBAL_VERSION_NEW
new file mode 100644
index 000000000..679df7612
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/GLOBAL_VERSION_NEW
@@ -0,0 +1,12 @@
+dpu_dev_kit:1.0.0.2
+driver:21.0.10.1
+tool:21.0.10.1
+boot:21.0.10.1
+mpu:21.0.10.1
+npu:21.0.10.1
+smu_l0:21.0.10.1
+smu_l1:21.0.10.1
+cps_data:21.0.10.1
+cps:22.12.11
+roce_scc:21.0.10.1
+roce_imp:21.0.10.1
\ No newline at end of file
diff --git a/drivers/net/ethernet/huawei/hinic5/build/__init__.py b/drivers/net/ethernet/huawei/hinic5/build/__init__.py
new file mode 100755
index 000000000..cc0d19d0a
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/__init__.py
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+# -*- encoding:utf-8 -*-
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
\ No newline at end of file
diff --git a/drivers/net/ethernet/huawei/hinic5/build/build_main.py b/drivers/net/ethernet/huawei/hinic5/build/build_main.py
new file mode 100755
index 000000000..506017465
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/build_main.py
@@ -0,0 +1,166 @@
+#!/usr/bin/env python
+# -*- encoding:utf-8 -*-
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
+import os
+import re
+import sys
+from time import time
+from multiprocessing import Pool
+import logging
+import env
+
+
+sys.path.append(env.HI1823_BUILD_HOST_DIR)
+import build_host
+
+hi1823_type = None
+chip_version = None
+
+hi1823_feature_dict = {
+ "sdk" : "SDK",
+ "SDK" : "SDK",
+ "sdk_ko" : "SDK_KO",
+ "SDK_KO" : "SDK_KO",
+ "nic" : "NIC",
+ "NIC" : "NIC",
+ "nic_ko" : "NIC_KO",
+ "NIC_KO" : "NIC_KO",
+ "roce" : "ROCE",
+ "ROCE" : "ROCE",
+ "udma" : "UDMA",
+ "UDMA" : "UDMA",
+}
+
+hi1823_type_dict = {
+ "driver" : "DRIVER",
+ "DRIVER" : "DRIVER",
+ "driver_ubus" : "DRIVER_UBUS",
+ "DRIVER_UBUS" : "DRIVER_UBUS",
+}
+
+hi1823_driver_type_dict = {
+ "kernel" : "KERNEL",
+ "KERNEL" : "KERNEL",
+ "kernel_arm" : "KERNEL",
+ "KERNEL_ARM" : "KERNEL",
+ "roce_compute" : "ROCE_COMPUTE",
+ "ROCE_COMPUTE" : "ROCE_COMPUTE",
+ "roce_standard_mlnx" : "ROCE_STANDARD_MLNX",
+ "ROCE_STANDARD_MLNX" : "ROCE_STANDARD_MLNX",
+}
+
+hi1823_fc_os_release_type_dict = {
+ "release" : "RELEASE",
+ "RELEASE" : "RELEASE",
+ "debug" : "DEBUG",
+ "DEBUG" : "DEBUG",
+ "loopback" : "LOOPBACK",
+ "LOOPBACK" : "LOOPBACK",
+}
+
+hi1823_env_type_dict = {
+ "ub_beta" : ("1650", "opensource/openeuler/kernel/olk-6.6", "kernel"),
+ "bigdipperv5r9" : ("1650", "open_source/2403_SP2", "ube/ubengine/ssapi/kernelspace"),
+}
+
+hi1823_driver_ubus_edition_dict = {
+ "b180" : "B180",
+ "B180" : "B180",
+ "b186" : "B186",
+ "B186" : "B186",
+ "b188" : "B188",
+ "B188" : "B188",
+}
+
+def manual():
+ logging.info(f"{sys.argv[0]} [feature] [type] [driver_type]:")
+ logging.info("[feature]:")
+ logging.info(" sdk | SDK | nic | NIC")
+ logging.info("[type]:")
+ logging.info(" driver | DRIVER | driver_ubus | DRIVER_UBUS")
+ logging.info("[driver_type]:")
+ logging.info(" kernel | KERNEL | user | USER")
+ logging.info("[ubus_edition_type]:")
+ logging.info(" b180 | b186 | b188")
+
+def get_hi1823_arg(arg):
+ if env.hi1823_feature == None:
+ env.hi1823_feature = hi1823_feature_dict.get(arg, None)
+ if env.hi1823_feature != None:
+ return 0
+
+ if env.hi1823_type == None:
+ env.hi1823_type = hi1823_type_dict.get(arg, None)
+ if env.hi1823_type != None:
+ return 0
+
+ if env.hi1823_driver_type == None:
+ env.hi1823_driver_type = hi1823_driver_type_dict.get(arg, None)
+ if env.hi1823_driver_type != None:
+ return 0
+
+ if env.hi1823_fc_os_release_type == None:
+ env.hi1823_fc_os_release_type = hi1823_fc_os_release_type_dict.get(arg, None)
+ if env.hi1823_fc_os_release_type != None:
+ return 0
+
+ if env.hi1823_ubus_driver_unified_compile_edition == None:
+ env.hi1823_ubus_driver_unified_compile_edition = hi1823_driver_ubus_edition_dict.get(arg, None)
+ if env.hi1823_ubus_driver_unified_compile_edition != None:
+ return 0
+
+ global chip_version
+ if chip_version == None:
+ arg_lower = arg.lower()
+ if arg_lower.startswith("hi") and "v" in arg_lower: # 芯片的型号为 hi1823v100,检测hi v
+ chip_version = arg_lower
+ if chip_version != None:
+ return 0
+
+ if env.hi1823_env_type == None:
+ for key,value in hi1823_env_type_dict.items():
+ if arg.startswith(key):
+ env.hi1823_env_type = value[0]
+ env.hi1823_os_path = value[1]
+ env.hi1823_component_path = value[2]
+ env.hi1823_1650_build_version = arg
+ return 0
+
+ logging.error(f"argument is unexpect. extras arg [{arg}]")
+ return 1
+
+if __name__ == "__main__":
+ count = 0
+
+ for arg in sys.argv:
+ if count == 0:
+ count += 1
+ continue
+ else:
+ print(f"arg = {arg}")
+ ret = get_hi1823_arg(arg)
+ count += 1
+ if ret:
+ logging.error(f"get argument fail")
+ manual()
+ sys.exit(1)
+
+ if chip_version == None:
+ chip_version = "hi1823v200"
+
+ os.putenv("CHIP_VERSION", chip_version)
+
+ logging.info(f"""env.hi1823_feature = {env.hi1823_feature}. hi1823_type = {env.hi1823_type}.
+env.hi1823_driver_type = {env.hi1823_driver_type}.""")
+
+ if env.hi1823_type == "DRIVER":
+ ret = build_host.build_host_main()
+ if ret:
+ sys.exit(1)
+ elif env.hi1823_type == "DRIVER_UBUS":
+ env.hi1823_ubus_driver_unified_compile = True
+ ret = build_host.build_host_main()
+ if ret:
+ sys.exit(1)
+ else:
+ logging.error(f"Unkown type, Please check your inputting! hi1823_type = {env.hi1823_type}")
diff --git a/drivers/net/ethernet/huawei/hinic5/build/build_util.py b/drivers/net/ethernet/huawei/hinic5/build/build_util.py
new file mode 100755
index 000000000..769323377
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/build_util.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+# -*- encoding:utf-8 -*-
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2025. All rights reserved.
+
+import logging
+import os
+import subprocess
+import sys
+
+
+def _format_cmd(cmd):
+ if isinstance(cmd, list) or isinstance(cmd, tuple):
+ return ' '.join(cmd)
+ return cmd
+
+def _format_cmd_output(output: str):
+ append = '\n'
+ if output and output[-1] == '\n':
+ append = ''
+ return f'{"=" * 50} Output {"=" * 50}\n{output}{append}{"=" * 108}\n'
+
+def _subprocess_run_compat_args():
+ # capture output and decode output to text
+ if sys.version_info >= (3, 7):
+ return {
+ 'text': True,
+ # 'capture_output': True, # capture stdout and stderr into two separate pipes
+ 'stdout': subprocess.PIPE,
+ 'stderr': subprocess.STDOUT,
+ }
+ else:
+ return {
+ 'universal_newlines': True,
+ 'stdout': subprocess.PIPE,
+ 'stderr': subprocess.STDOUT,
+ }
+
+def do_cmd(*cmd, input=None, check=True, shell=False, verbose=False, silence=False, **kwargs):
+ """
+ Wrapper for subprocess.run()
+ """
+ if not verbose and not silence:
+ logging.info(f'EXEC: {_format_cmd(cmd)}')
+
+ try:
+ r = subprocess.run(list(cmd), input=input, check=check, shell=shell, errors='replace',
+ **_subprocess_run_compat_args(), **kwargs)
+ if verbose and not silence:
+ logging.info(f'EXEC: {_format_cmd(cmd)}, return {r.returncode}\n{_format_cmd_output(r.stdout)}')
+ return r
+ except subprocess.CalledProcessError as e:
+ if not silence:
+ logging.error(f'EXEC: {_format_cmd(cmd)}\n{e}\n{_format_cmd_output(e.stdout)}')
+ raise
+ except Exception as e:
+ logging.error(f'EXEC: {e}')
+ raise
+
+
+def try_run(*cmd, verbose=False, **kwargs):
+ """
+ Try runnnig a command, no errors will be printed
+ """
+ try:
+ if verbose:
+ return do_cmd(*cmd, verbose=True, **kwargs)
+ else:
+ return do_cmd(*cmd, silence=True, **kwargs)
+ except subprocess.CalledProcessError:
+ # ignore called error
+ return None
+
+
+def try_run_and_test(*cmd, verbose=False, **kwargs) -> bool:
+ """
+ Try runnnig a command, and return whether retcode is zero (success)
+ """
+ p = try_run(*cmd, verbose=verbose, **kwargs)
+ return p and p.returncode == 0
+
+
+def do_make(*make_args,
+ workdir='',
+ jobs=0, jobs_is_cpu_count=True,
+ verbose=True):
+ args = []
+ if workdir:
+ args += ['-C', workdir]
+ if jobs:
+ args += ['-j', str(jobs)]
+ elif jobs_is_cpu_count:
+ args += ['-j', str(os.cpu_count())]
+
+ do_cmd('make', *args, *make_args, verbose=verbose)
+
+
+def do_make_clean(workdir=''):
+ do_make('clean', workdir=workdir, jobs_is_cpu_count=False, verbose=False)
+
+
+def rpm_build(workdir, spec, arch):
+ cmd = ['rpmbuild', '--define', f'_topdir {workdir}', '-bb', spec]
+ if arch == 'aarch64':
+ cmd.append('--target=aarch64')
+ do_cmd(*cmd, cwd=f'{workdir}/SPECS')
diff --git a/drivers/net/ethernet/huawei/hinic5/build/env.py b/drivers/net/ethernet/huawei/hinic5/build/env.py
new file mode 100755
index 000000000..3be01f6e9
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/env.py
@@ -0,0 +1,708 @@
+#!/usr/bin/env python
+# -*- encoding:utf-8 -*-
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
+import os
+import re
+import sys
+import shutil
+import logging
+import platform
+import subprocess
+from build_util import try_run_and_test
+
+logging.getLogger().setLevel(logging.INFO)
+DIR_HEAD = "/"
+
+HI1823_BUILD_DIR = os.path.dirname(__file__)
+HI1823_BUILD_HOST_DIR = f"{HI1823_BUILD_DIR}/host/linux"
+HI1823_TRUNK_DIR = os.path.split(HI1823_BUILD_DIR)[0]
+HI1823_BUILD_HINICADM_DIR = f"{HI1823_BUILD_DIR}/tools/linux/hinicadm"
+HI1823_BUILD_HINICADMDFX_DIR = f"{HI1823_BUILD_DIR}/tools/linux/hinicadmdfx"
+HI1823_BUILD_HIFCADMDFX_DIR = f"{HI1823_BUILD_DIR}/tools/linux/hifcadmdfx"
+HI1823_BUILD_UBTEST_DIR = f"{HI1823_BUILD_DIR}/tools/linux/ub-test"
+HI1823_BUILD_UBMAC_DIR = f"{HI1823_TRUNK_DIR}/test/at_test/ubmac"
+HI1823_BUILD_SDK_DIR = f"{HI1823_BUILD_DIR}/host/linux/sdk"
+HI1823_BUILD_LOG_PATH = f"{HI1823_BUILD_DIR}/tools/build_log"
+HI1823_LLD_CODE_DIR = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/sdk/knldk/lld"
+HI1823_RPM_BUILD_DIR = f"{HI1823_TRUNK_DIR}/rpmbuild"
+HI1823_DEB_BUILD_DIR = f"{HI1823_TRUNK_DIR}/debbuild"
+HI1823_BUILD_SSSDK_DIR = f"{HI1823_BUILD_DIR}/host/linux/sss"
+HI1823_HOTPATCH_BUILD_DIR = f"{HI1823_TRUNK_DIR}/../patch_build"
+HI1823_BUILD_NIC_DIR = f"{HI1823_BUILD_DIR}/host/linux/nic"
+HI1823_BUILD_IPSEC_DIR = f"{HI1823_BUILD_DIR}/host/linux/crypt"
+HI1872_BUILD_MACSEC_DIR = f"{HI1823_BUILD_DIR}/host/linux/macsec"
+HI1823_IPSEC_CODE_DIR = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/crypt"
+HI1872_MACSEC_CODE_DIR = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/macsec"
+HI1823_BUILD_PPA_DIR = f"{HI1823_BUILD_DIR}/host/linux/ppa"
+HI1823_OPENSOURCE_DIR = f"{HI1823_BUILD_DIR}/../../Opensource"
+HI1823_V100_TOP_DIR = f"{HI1823_BUILD_DIR}/../../Hi1823_chip_solution"
+HI1823_BUILD_DPDK_DIR = f"{HI1823_BUILD_DIR}/host/linux/dpdk"
+HI1823_BUILD_ROCE_DIR = f"{HI1823_BUILD_DIR}/host/linux/roce"
+HI1823_BUILD_UDMA_DIR = f"{HI1823_BUILD_DIR}/host/linux/udma"
+HI1823_BUILD_PLOG_DIR = f"{HI1823_BUILD_DIR}/host/linux/plog"
+HI1823_BUILD_OVS_DIR = f"{HI1823_BUILD_DIR}/host/linux/ovs"
+HI1872_BUILD_PFE_DIR = f"{HI1823_BUILD_DIR}/host/linux/pfe"
+HI1823_BUILD_HPD_DIR = f"{HI1823_BUILD_DIR}/host/linux/hpd"
+HI1823_BUILD_TOE_DIR = f"{HI1823_BUILD_DIR}/host/linux/toe"
+HI1823_BUILD_DTOE_DIR = f"{HI1823_BUILD_DIR}/host/linux/dtoe"
+HI1823_BUILD_VBS_DIR = f"{HI1823_BUILD_DIR}/host/linux/dsware"
+HI1823_BUILD_MIGRATE_DIR = f"{HI1823_BUILD_DIR}/host/linux/migrate"
+HI1823_BUILD_DMMU_DIR = f"{HI1823_BUILD_DIR}/host/linux/dmmu"
+HI1823_BUILD_JBOF_DIR = f"{HI1823_BUILD_DIR}/host/linux/jbof"
+HI1823_BUILD_DIST_QOS_DIR = f"{HI1823_BUILD_DIR}/host/linux/dist_qos"
+
+HI1823_BUILD_UBUS_KERNEL_DIR = f"{HI1823_BUILD_DIR}/../../../KunpengTrunk/open_source/2403_SP2"
+HI1823_BUILD_UBUS_DRIVER_MODULE_DIR = f"{HI1823_BUILD_DIR}/../../../KunpengTrunk/open_source/2403_SP2/ubus"
+
+hi1823_type = None
+hi1823_feature = None
+hi1823_driver_type = None
+hi1823_fc_os_release_type = None
+hi1823_env_type = None
+hi1823_os_path = None
+hi1823_component_path = None
+
+hi1823_1650_build_version = None
+hi1823_bin_dir = None
+hi1823_ci_lib_dir = None
+hi1823_nic_code_dir = None
+hi1823_dist_qos_code_dir = None
+hi1823_ppa_code_dir = None
+hi1823_dpdk_code_dir = None
+hi1823_ppa_usr_code_dir = None
+huawei_secure_code_dir = None
+hi1823_roce_knl_code_dir = None
+hi1823_roce_usr_code_dir = None
+hi1823_udma_knl_code_dir = None
+hi1823_udma_usr_code_dir = None
+hi1823_plog_code_dir = None
+hi1823_ovs_knl_code_dir = None
+hi1823_ovs_usr_code_dir = None
+hi1872_pfe_code_dir = None
+hi1823_hpd_code_dir = None
+hi1823_toecore_code_dir = None
+hi1823_tom_code_dir = None
+hi1823_vbs_knl_code_dir = None
+hi1823_vbs_usr_code_dir = None
+hi1823_migrvf_base_code_dir = None
+hi1823_migrvf_virtio_code_dir = None
+hi1823_migrvf_ub_code_dir = None
+hi1823_cloud_migration_dir = None
+hi1823_cloud_migration_fake_zero_dir = None
+hi1823_compute_migration_dir = None
+hi1823_dmmu_code_dir = None
+hi1823_jbof_usr_code_dir = None
+hi1823_jbof_usr_at_code_dir = None
+hi1823_tifoe_knl_code_dir = None
+hi1823_tifoe_usr_code_dir = None
+HI1823_FC_CODE_DIR = None
+
+hi1823_os_arch = None
+hi1823_complie_os_kver = None
+hi1823_complie_os_kver_underline = None
+hi1823_os_type = None
+hi1823_os_release = None
+hi1823_os_pkg_mgr = None
+hi1823_vpmd_code_dir = None
+
+build_roce_mode = None
+
+hi1823_ubus_driver_unified_compile = False
+hi1823_ubus_driver_unified_compile_edition = None
+
+def copy_file(srcfile, dstpath, dst_fname = None):
+ if not os.path.isfile(srcfile):
+ logging.error(f"{srcfile} not exist!")
+ return 1
+ else:
+ fpath, fname = os.path.split(srcfile)
+ if not os.path.exists(dstpath):
+ os.makedirs(dstpath)
+ if dst_fname:
+ shutil.copy(srcfile, f"{dstpath}/{dst_fname}")
+ else:
+ shutil.copy(srcfile, f"{dstpath}/{fname}")
+
+ return 0
+
+def copy_file_with_end(srcpath, dstpath, suffix):
+ if not os.path.exists(srcpath):
+ logging.error(f"{srcpath} not exist!")
+ return 1
+ else:
+ if not os.path.exists(dstpath):
+ os.makedirs(dstpath)
+ for file_name in os.listdir(srcpath):
+ if file_name.endswith(suffix):
+ ret = copy_file(f"{srcpath}/{file_name}", dstpath)
+ if ret:
+ return ret
+
+ return 0
+
+def copy_file_with_start(srcpath, dstpath, prefix):
+ if not os.path.exists(srcpath):
+ logging.error(f"{srcpath} not exist!")
+ return 1
+ else:
+ if not os.path.exists(dstpath):
+ os.makedirs(dstpath)
+ for file_name in os.listdir(srcpath):
+ if file_name.startswith(prefix):
+ ret = copy_file(f"{srcpath}/{file_name}", dstpath)
+ if ret:
+ return ret
+
+ return 0
+
+def copy_file_with_start_and_end(srcpath, dstpath, prefix, suffix):
+ if not os.path.exists(srcpath):
+ logging.error(f"{srcpath} not exist!")
+ return 1
+ else:
+ if not os.path.exists(dstpath):
+ os.makedirs(dstpath)
+ for file_name in os.listdir(srcpath):
+ if file_name.startswith(prefix) and file_name.endswith(suffix):
+ ret = copy_file(f"{srcpath}/{file_name}", dstpath)
+ if ret:
+ return ret
+
+ return 0
+
+def collect_build_info(path, dst_dir, suffix=None):
+ if suffix:
+ build_info = f"build_info_{suffix}.txt"
+ else:
+ build_info = "build_info.txt"
+
+ if os.path.isfile(f"{path}/{build_info}"):
+ if not os.path.isfile(f"{dst_dir}/{build_info}"):
+ logging.info(f"collect_build_info. path = [{path}], dst_dir = [{dst_dir}]")
+ build_file = f"{dst_dir}/{build_info}"
+ cmd = ["cat", f"{path}/{build_info}"]
+ try:
+ with open(build_file, 'wb') as fp:
+ rslt = subprocess.run(cmd, shell=False, check=True, stdout=fp, stderr=subprocess.PIPE)
+ except Exception as e:
+ logging.error(f"exec cmd fail:{e}. error = [{rslt.stderr}]")
+ return 1
+
+ return 0
+
+def set_env():
+ os.environ['HI1823_TRUNK_DIR'] = HI1823_TRUNK_DIR
+ os.environ['HI1823_BUILD_DIR'] = HI1823_BUILD_DIR
+ os.environ['HI1823_BIN_DIR'] = hi1823_bin_dir
+ if not hi1823_os_type:
+ logging.warning("hi1823_os_type is none. not set env")
+ else:
+ os.environ['HI1823_OS_TYPE'] = hi1823_os_type
+ if not hi1823_os_release:
+ logging.warning("hi1823_os_release is none. not set env")
+ else:
+ os.environ['HI1823_OS_RELEASE'] = hi1823_os_release
+ if not HI1823_FC_CODE_DIR:
+ logging.warning("HI1823_FC_CODE_DIR is none. not set env")
+ else:
+ os.environ['HI1823_FC_CODE_DIR'] = HI1823_FC_CODE_DIR
+
+ if hi1823_ubus_driver_unified_compile == True:
+ os.environ['CONFIG_UB_UNIFIED_UBUS'] = "y"
+ if not HI1823_BUILD_UBUS_DRIVER_MODULE_DIR:
+ logging.warning("HI1823_BUILD_UBUS_DRIVER_MODULE_DIR is none. not set env")
+ else:
+ os.environ['UBUS_MODULE_DIR'] = HI1823_BUILD_UBUS_DRIVER_MODULE_DIR
+
+ if not HI1823_BUILD_UBUS_KERNEL_DIR:
+ logging.warning("HI1823_BUILD_UBUS_KERNEL_DIR is none. not set env")
+ else:
+ os.environ['UBUS_BUILD_KERNEL_DIR'] = HI1823_BUILD_UBUS_KERNEL_DIR
+
+ if hi1823_ubus_driver_unified_compile_edition == "B188":
+ os.environ['CONFIG_UB_UBUS_B188'] = "y"
+ else:
+ os.environ['CONFIG_UB_UBUS_B188'] = "n"
+
+def dir_define():
+ global hi1823_bin_dir
+ global hi1823_ci_lib_dir
+ global hi1823_nic_code_dir
+ global hi1823_dist_qos_code_dir
+ global hi1823_ppa_code_dir
+ global hi1823_dpdk_code_dir
+ global hi1823_ppa_usr_code_dir
+ global huawei_secure_code_dir
+ global hi1823_roce_knl_code_dir
+ global hi1823_roce_usr_code_dir
+ global hi1823_udma_knl_code_dir
+ global hi1823_udma_usr_code_dir
+ global hi1823_plog_code_dir
+ global hi1823_ovs_knl_code_dir
+ global hi1823_ovs_usr_code_dir
+ global hi1872_pfe_code_dir
+ global hi1823_hpd_code_dir
+ global hi1823_toecore_code_dir
+ global hi1823_tom_code_dir
+ global hi1823_vbs_knl_code_dir
+ global hi1823_vbs_usr_code_dir
+ global hi1823_migrvf_base_code_dir
+ global hi1823_migrvf_virtio_code_dir
+ global hi1823_migrvf_ub_code_dir
+ global hi1823_cloud_migration_dir
+ global hi1823_cloud_migration_fake_zero_dir
+ global hi1823_compute_migration_dir
+ global hi1823_dmmu_code_dir
+ global hi1823_jbof_usr_code_dir
+ global hi1823_jbof_usr_at_code_dir
+ global hi1823_vpmd_code_dir
+ global hi1823_tifoe_knl_code_dir
+ global hi1823_tifoe_usr_code_dir
+ global HI1823_FC_CODE_DIR
+
+ #Directories must define in this function, because HI1823_TRUNK_DIR may be change in cross compile conditions.
+ hi1823_nic_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/nic/linux"
+ hi1823_dpdk_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/nic/dpdk"
+ hi1823_dist_qos_code_dir = f"{HI1823_TRUNK_DIR}/test/at_test/host/service/dist_qos/kernel"
+ hi1823_ppa_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/ppa/kernel"
+ hi1823_ppa_usr_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/ppa/usr"
+ HI1823_CRYPT_CODE_DIR = f"{HI1823_TRUNK_DIR}/test/crypt"
+ HI1823_FC_CODE_DIR = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/fc/linux"
+ HI1823_FC_TGT_DIR = f"{HI1823_TRUNK_DIR}/test/fc_tgt"
+ hi1823_plog_code_dir = f"{HI1823_TRUNK_DIR}/test/chip_level_test/plog_at_src"
+ hi1823_ovs_knl_code_dir = f"{HI1823_TRUNK_DIR}/test/at_test/host/service/ovs/linux/kernel"
+ hi1823_ovs_usr_code_dir = f"{HI1823_TRUNK_DIR}/test/at_test/host/service/ovs/linux/user"
+ # hi1872_pfe_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/pfe"
+ hi1872_pfe_code_dir = f"{HI1823_TRUNK_DIR}/test/non_product/pfe"
+ hi1823_hpd_code_dir = f"{HI1823_TRUNK_DIR}/test/samples/sdi/hpd"
+ HI1823_ISN_USR_CODE_DIR = f"{HI1823_TRUNK_DIR}/src/driver/linux/isn/lib"
+ HI1823_ISN_APP_CODE_DIR = f"{HI1823_TRUNK_DIR}/src/driver/linux/isn/app"
+ HI1823_ISN_KNL_CODE_DIR = f"{HI1823_TRUNK_DIR}/src/driver/linux/isn/kernel"
+ hi1823_vbs_knl_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/vbs/kernel"
+ hi1823_vbs_usr_code_dir = f"{HI1823_TRUNK_DIR}/test/at_test/host/service/vbs/user"
+ hi1823_jbof_usr_code_dir = f"{HI1823_TRUNK_DIR}/test/at_test/host/service/jbof/user"
+ hi1823_jbof_usr_at_code_dir = f"{HI1823_TRUNK_DIR}/test/at_test/host/service/jbof/user_at"
+ hi1823_vpmd_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/sdk/usrdk/vpmd"
+ HI1823_SDK_CODE_DIR = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/sdk/knldk/"
+ hi1823_bin_dir = f"{HI1823_TRUNK_DIR}/bin"
+ hi1823_ci_lib_dir = f"{HI1823_TRUNK_DIR}/ci/lib"
+ hi1823_roce_knl_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/roce/linux/kernel"
+ hi1823_roce_usr_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/roce/linux/user"
+ HI1823_ROCE_HW_VERBS_EXT_DIR = f"{HI1823_TRUNK_DIR}/src/dpu_extended_library/roce/hw_verbs_ext"
+ HI1823_ROCE_HW_ROCE_EXT_DIR = f"{HI1823_TRUNK_DIR}/src/dpu_extended_library/roce/hw_roce_ext"
+ hi1823_udma_knl_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/udma/kernel"
+ hi1823_udma_usr_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/udma/user"
+ huawei_secure_code_dir = f"{HI1823_TRUNK_DIR}/platform/huawei_secure_c/"
+ HI1823_CI_BUILD_DIR = f"{HI1823_TRUNK_DIR}/ci/build"
+ HI1823_TOE_CODE_DIR = f"{HI1823_TRUNK_DIR}/test/at_test/host/service/toe"
+ hi1823_tom_code_dir = f"{HI1823_TRUNK_DIR}/test/at_test/host/service/toe/toecode"
+ hi1823_toecore_code_dir = f"{HI1823_TRUNK_DIR}/test/at_test/host/service/toe/toecore"
+ HI1823_TOEDFX_CODE_DIR = f"{HI1823_TRUNK_DIR}/test/at_test/host/service/toe/dfx"
+ hi1823_tifoe_knl_code_dir = f"{HI1823_TRUNK_DIR}/test/at_test/host/service/toe_tifoe_test/kernel"
+ hi1823_tifoe_usr_code_dir = f"{HI1823_TRUNK_DIR}/test/at_test/host/service/toe_tifoe_test/user"
+ hi1823_migrvf_base_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/migrate/base"
+ hi1823_migrvf_virtio_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/migrate/virtio"
+ hi1823_migrvf_ub_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/migrate/ub"
+ hi1823_cloud_migration_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/migrate"
+ hi1823_cloud_migration_fake_zero_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/migrate/zero"
+ hi1823_compute_migration_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/migrate/virtio_product/computing"
+ hi1823_dmmu_code_dir = f"{HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/dmmu"
+
+def get_package_manager_type():
+ """
+ Checks if the Linux system uses RPM or DEB based package management.
+ Returns 'rpm', 'deb', or 'unknown' if neither is detected.
+ """
+ if try_run_and_test('test', '-f', '/etc/redhat-release', verbose=True):
+ return 'rpm'
+ if try_run_and_test('test', '-f', '/etc/debian_version', verbose=True):
+ return 'deb'
+ if try_run_and_test('which', 'rpm', verbose=True):
+ return 'rpm'
+ if try_run_and_test('which', 'dpkg', verbose=True):
+ return 'deb'
+ return 'unknown'
+
+def get_driver_output_path(driver_type):
+ global hi1823_bin_dir, hi1823_os_arch, hi1823_os_release
+ if hi1823_os_arch == 'x86_64':
+ return f'{hi1823_bin_dir}/driver/linux/{driver_type}/{hi1823_os_release}'
+ return f'{hi1823_bin_dir}/driver/linux/{driver_type}/arm/{hi1823_os_release}'
+
+def get_os_info_by_eulerlinux():
+ global hi1823_os_type
+ global hi1823_os_release
+ hi1823_diff_id = os.getenv('HI1823_DIFF_ID', None)
+ with open("/etc/EulerLinux.conf", 'r') as file:
+ os_file_info = file.read()
+ if (re.search("pangea", os_file_info, re.IGNORECASE) or \
+ re.search("storage", os_file_info, re.IGNORECASE)):
+ hi1823_os_type = "PANGEA"
+ cmd = f"cat {DIR_HEAD}etc/EulerLinux.conf | grep -iE 'version=euleros' | awk -F '=' '{{print $2}}' |\
+ sed 's/_/ /g' | grep -o V.* | awk '{{print $1}}'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = f"PANGEA_{version}"
+ elif re.search("uvp", os_file_info, re.IGNORECASE):
+ hi1823_os_type = "UVP"
+ cmd = f"cat {DIR_HEAD}etc/EulerLinux.conf | grep -iE 'uvp_version' | awk -F '=' '{{print $2}}' | sed 's/-/_/g'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ if hi1823_diff_id:
+ hi1823_os_release = f"{version}_{hi1823_diff_id}"
+ else:
+ hi1823_os_release = version
+ elif (re.search("EulerOS", os_file_info, re.IGNORECASE) and \
+ re.search("storage", hi1823_complie_os_kver, re.IGNORECASE)) or \
+ hi1823_complie_os_kver == "4.1.18-vhulk3.3.5.aarch64":
+ hi1823_os_type = "EULEROS_PANGEA"
+ cmd = f"cat {DIR_HEAD}etc/EulerLinux.conf | grep -iE 'version' | awk -F '=' '{{print $2}}' |\
+ awk -F '-' '{{print $1}}' | tr 'a-z' 'A-Z'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ if hi1823_diff_id:
+ hi1823_os_release = f"{version}_{hi1823_diff_id}"
+ else:
+ hi1823_os_release = version
+ elif re.search("EulerOS", os_file_info, re.IGNORECASE):
+ hi1823_os_type = "EULEROS"
+ cmd = f"cat {DIR_HEAD}etc/EulerLinux.conf | grep -iE 'version' | awk -F '=' '{{print $2}}' |\
+ awk -F '-' '{{print $1}}' | tr 'a-z' 'A-Z'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ if hi1823_diff_id:
+ hi1823_os_release = f"{version}_{hi1823_diff_id}"
+ else:
+ hi1823_os_release = version
+ elif re.search("HyperStack", os_file_info, re.IGNORECASE):
+ hi1823_os_type = "HyperStack"
+ cmd = f"cat {DIR_HEAD}etc/EulerLinux.conf | grep -iE 'version' | awk -F '=' '{{print $2}}' |\
+ awk -F '-' '{{print $1}}' | tr 'a-z' 'A-Z'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = version
+ elif re.search("HCE", os_file_info, re.IGNORECASE):
+ hi1823_os_type = "HCE"
+ cmd = f"cat {DIR_HEAD}etc/EulerLinux.conf | grep -iE 'version' | awk -F '=' '{{print $2}}' |\
+ sed 's/-/_/g'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ if hi1823_diff_id:
+ hi1823_os_release = f"{version}_{hi1823_diff_id}"
+ else:
+ hi1823_os_release = version
+
+ return 0
+
+def get_os_info_by_euleros_latest():
+ global hi1823_os_type
+ global hi1823_os_release
+ with open("/etc/euleros-latest", 'r') as file:
+ os_file_info = file.read()
+ if (re.search("pangea", os_file_info, re.IGNORECASE) or \
+ re.search("storage", os_file_info, re.IGNORECASE)):
+ hi1823_os_type = "PANGEA"
+ cmd = f"cat {DIR_HEAD}etc/euleros-latest | grep -iE 'version=euleros' | awk -F '=' '{{print $2}}' |\
+ sed 's/_/ /g' | grep -o V.* | awk '{{print $1}}'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = f"PANGEA_{version}"
+ elif re.search("uvp", os_file_info, re.IGNORECASE):
+ hi1823_os_type = "UVP"
+ cmd = f"cat {DIR_HEAD}etc/euleros-latest | grep -iE 'uvp_version' | awk -F '=' '{{print $2}}' | sed 's/-/_/g'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = version
+ elif re.search("EulerOS", os_file_info, re.IGNORECASE):
+ hi1823_os_type = "EULEROS"
+ cmd = f"cat {DIR_HEAD}etc/euleros-latest | grep -iE 'eulerversion' | awk -F '=' '{{print $2}}' |\
+ awk -F '-' '{{print $1}}' | tr 'a-z' 'A-Z'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = version
+
+ return 0
+
+def _os_release_row_parser(row):
+ m = re.match('(\w+)="(.*)"', row)
+ return m.group(1), m.group(2)
+
+def get_os_info_for_alinux():
+ if not os.path.exists("/etc/os-release"):
+ raise Exception("no /etc/os-release for alinux")
+
+ with open("/etc/os-release", 'r') as file:
+ items = [_os_release_row_parser(row) for row in file]
+ os_info = dict(items)
+
+ os_id = os_info['ID'].upper()
+ os_ver_id = os_info['VERSION_ID']
+ os_var_id = os_info.get('VARIANT_ID')
+
+ if os_id == 'ALINUX':
+ # OpenAnolis
+ if os_var_id == 'openanolis':
+ alinux_minor = os_info['ALINUX_MINOR_ID']
+ alinux_update = os_info['ALINUX_UPDATE_ID']
+ os_ver = f'{os_ver_id}_{alinux_minor}_U{alinux_update}_{os_var_id.upper()}'
+ # No variant
+ else:
+ alinux_update = os_info['UPDATE_ID']
+ os_ver = f'{os_ver_id}_U{alinux_update}'
+ else:
+ raise Exception(f'unknown OS ID "{os_id}" for alinux')
+
+ global hi1823_os_type, hi1823_os_release
+ hi1823_os_type = os_id
+ hi1823_os_release = f'{os_id}_{os_ver}'
+
+def get_os_info_by_os_release():
+ global hi1823_os_type, hi1823_os_release, hi1823_complie_os_kver_underline, hi1823_os_arch
+ with open("/etc/os-release", 'r') as file:
+ os_file_info = file.read()
+ if re.search("kylin", os_file_info, re.IGNORECASE):
+ hi1823_os_type = "KYLIN"
+ cmd = f"cat {DIR_HEAD}etc/os-release | grep -E 'VERSION_ID' | awk -F '=' '{{print $2}}' | sed 's/\"//g'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ if re.search("Tercel", os_file_info, re.IGNORECASE):
+ global hi1823_complie_os_kver
+ if "23.8.v2101.ky10" in hi1823_complie_os_kver:
+ hi1823_os_release = f"Kylin{version}SP1_BUILD20"
+ else:
+ hi1823_os_release = f"Kylin{version}SP1"
+ elif re.search("Sword", os_file_info, re.IGNORECASE):
+ hi1823_os_release = f"Kylin{version}SP2"
+ else:
+ hi1823_os_release = f"Kylin{version}"
+ elif re.search("UnionTech", os_file_info, re.IGNORECASE) or re.search("UOS", os_file_info, re.IGNORECASE):
+ hi1823_os_type = "UOS"
+ cmd = f"cat {DIR_HEAD}etc/os-release | grep -E 'VERSION_ID' | awk -F '=' '{{print $2}}' | sed 's/\"//g'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = f"UOS{version}"
+ elif re.search("ctyun", os_file_info, re.IGNORECASE):
+ hi1823_os_type = "ctyun"
+ cmd = f"cat {DIR_HEAD}etc/os-release | grep -E 'VERSION_ID' | awk -F '=' '{{print $2}}' | sed 's/\"//g'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = f"ctyun{version}"
+ elif re.search("anolis", os_file_info, re.IGNORECASE):
+ hi1823_os_type = "anolis"
+ cmd = f"cat {DIR_HEAD}etc/os-release | grep -E 'VERSION_ID' | awk -F '=' '{{print $2}}' | sed 's/\"//g'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = f"anolis{version}"
+ elif re.search("sles", os_file_info, re.IGNORECASE):
+ hi1823_os_type = "SUSE"
+ cmd = f"cat {DIR_HEAD}etc/os-release | grep -wE 'VERSION' | awk -F '=' '{{print $2}}' | sed 's/\"//g' | sed 's/-//g'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = f"SuSE{version}"
+ else:
+ hi1823_os_type = "Ubuntu"
+ cmd = f"cat {DIR_HEAD}etc/os-release | grep -wE 'VERSION' | awk -F '=' '{{print $2}}' | sed 's/\"//g' |\
+ sed 's/-//g' | awk '{{print $1}}'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = f"ubuntu{version}_{hi1823_complie_os_kver_underline}_{hi1823_os_arch}"
+
+ return 0
+
+def get_os_info():
+ global hi1823_os_arch, hi1823_os_pkg_mgr
+ global hi1823_complie_os_kver, hi1823_complie_os_kver_underline
+ global hi1823_os_type, hi1823_os_release
+ hi1823_os_arch = platform.machine()
+ hi1823_os_pkg_mgr = get_package_manager_type()
+
+ cmd = "uname -r"
+ global hi1823_complie_os_kver
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ hi1823_complie_os_kver = output
+ hi1823_complie_os_kver_underline = output.replace('-', '_')
+
+ logging.info(f'hi1823_os_arch {hi1823_os_arch}')
+ logging.info(f'hi1823_os_pkg_mgr {hi1823_os_pkg_mgr}')
+ logging.info(f'hi1823_complie_os_kver {hi1823_complie_os_kver}')
+ logging.info(f'hi1823_complie_os_kver_underline {hi1823_complie_os_kver_underline}')
+
+ if os.path.isfile("/etc/EulerLinux.conf"):
+ return get_os_info_by_eulerlinux()
+
+ if os.path.isfile("/etc/euleros-latest"):
+ return get_os_info_by_euleros_latest()
+
+ if os.path.isfile("/etc/os-release"):
+ with open("/etc/os-release", "r") as f:
+ for line in f:
+ if line.startswith("NAME="):
+ os_name = line.strip().split("=")[1].strip('"')
+ break
+ if "Red Hat" in os_name:
+ hi1823_os_type = "REDHAT"
+ if os.path.isfile("/etc/os-release"):
+ cmd = f"cat {DIR_HEAD}etc/os-release | grep -E 'VERSION_ID' | awk -F '=' '{{print $2}}' | sed 's/\"//g'"
+ else:
+ cmd = f"cat {DIR_HEAD}etc/redhat-release | awk -F 'release' '{{print $2}}' | sed 's/ //g' | awk -F '(' '{{print $1}}'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = f"RedHat{version}"
+ return 0
+
+ if os.path.isfile("/etc/bclinux-release"):
+ hi1823_os_type = "BCLINUX"
+ cmd = f"cat {DIR_HEAD}etc/os-release | grep -E 'VERSION_ID' | awk -F '=' '{{print $2}}' | sed 's/\"//g'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = f"BCLinux{version}"
+ return 0
+
+ # Alibaba Cloud Linux
+ if os.path.exists('/etc/alinux-release'):
+ return get_os_info_for_alinux()
+
+ if os.path.isfile("/etc/centos-release") and not os.path.exists("/etc/euleros-release") and\
+ not os.path.exists("/etc/redflag-release"):
+ hi1823_os_type = "CENTOS"
+ cmd = f"cat {DIR_HEAD}etc/centos-release | grep -E 'release' | awk -F 'release ' '{{print $2}}' |\
+ awk -F \" \" '{{print $1}}'|awk -F \".\" '{{print $1\".\"$2}}'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = f"CentOS{version}"
+ return 0
+
+ if os.path.isfile("/etc/openEuler-release"):
+ hi1823_os_type = "openEuler"
+ cmd = f"cat {DIR_HEAD}etc/os-release | grep -E 'VERSION=' | awk -F '[\" ]' '{{print $2}}'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version1 = output
+ cmd = f"cat {DIR_HEAD}etc/os-release | grep -E 'VERSION=' | awk -F '[-)\"]' '{{print $3}}'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version2 = output
+ hi1823_os_release = f"openEuler{version1}{version2}"
+ return 0
+
+ if os.path.isfile("/etc/hce-release"):
+ hi1823_os_type = "HCE"
+ cmd = f"cat {DIR_HEAD}etc/hce-latest | grep -iE 'hceversion' | awk -F '=' '{{print $2}}' | sed 's/-/_/g' | tr 'a-z' 'A-Z'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = version
+ return 0
+
+ if os.path.isfile("/etc/VesselOS-release"):
+ hi1823_os_type = "VesselOS"
+ cmd = f"cat {DIR_HEAD}etc/VesselOS-release | grep -E 'release' | awk -F 'release ' '{{print $2}}' |\
+ awk -F \" \" '{{print $1}}'|awk -F \".\" '{{print $1\".\"$2}}'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version = output
+ hi1823_os_release = f"VesselOS{version}"
+ return 0
+
+ if os.path.isfile("/etc/SuSE-release"):
+ hi1823_os_type = "SUSE"
+ cmd = f"cat {DIR_HEAD}etc/SuSE-release | grep -E 'VERSION' | awk -F '=' '{{print $2}}' | sed 's/ //g'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version1 = output
+ cmd = f"cat {DIR_HEAD}etc/SuSE-release | grep -E 'PATCHLEVEL' | awk -F '=' '{{print $2}}' | sed 's/ //g'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ version2 = output
+ hi1823_os_release = f"SuSE{version1}SP{version2}"
+
+ if os.path.isfile("/etc/os-release"):
+ return get_os_info_by_os_release()
+
+ return 0
+
+def get_global_version(type):
+ version_file = f"{HI1823_TRUNK_DIR}/src/GLOBAL_VERSION_NEW"
+ try:
+ with open(version_file) as file:
+ lines = file.readlines()
+ for line in lines:
+ ver_type = line.split(":")[0]
+ if ver_type == type:
+ value = line.split(":")[1]
+ return value.strip('\n')
+ except Exception as e:
+ logging.error(f"get global version [{type}] in [{version_file}] fail. error: {e} ")
+ return None
+
+ logging.error(f"no support global version [{type}] in [{version_file}].")
+ return None
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/Makefile.ko b/drivers/net/ethernet/huawei/hinic5/build/host/linux/Makefile.ko
new file mode 100644
index 000000000..88a56b175
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/Makefile.ko
@@ -0,0 +1,123 @@
+ccflags-y += -Wframe-larger-than=2048
+ccflags-y += -Wno-implicit-fallthrough
+
+ifndef __TIME_STR__
+SYS_TIME=$(shell date +%Y-%m-%d_%H:%M:%S)
+ccflags-y += -D __TIME_STR__=\"$(SYS_TIME)\"
+endif
+GLOBAL_VERSION=$(shell cat $(HI1823_TRUNK_DIR)/src/GLOBAL_VERSION_NEW | grep driver | awk -F ':' '{print $$2}')
+ccflags-y += -DGLOBAL_VERSION_STR=\"$(GLOBAL_VERSION)\"
+EXTRA_CFLAGS += -I$(HI1823_TRUNK_DIR)/src/dpu_develop_interface
+
+$(warning cflags, $(ccflags-y))
+V ?= 0
+
+
+ifeq ($(HI1823_RELEASE_TYPE), LLT)
+ ccflags-y += -D_LLT_TEST_
+else
+ ccflags-y += -DHW_CONVERT_ENDIAN
+endif
+
+ccflags-y += -D__LINUX__
+
+ifeq ($(HI1823_OS_TYPE), EULEROS)
+EXTRA_CFLAGS += -DOS_EULER
+endif
+ifeq ($(HI1823_OS_TYPE), openEuler)
+EXTRA_CFLAGS += -DOS_OPENEULER
+endif
+ifeq ($(HI1823_OS_TYPE), HCE)
+EXTRA_CFLAGS += -DOS_HCE
+endif
+ifeq ($(HI1823_OS_TYPE), Ubuntu)
+EXTRA_CFLAGS += -DOS_UBUNTU
+endif
+
+EXTRA_CFLAGS += -DSECUREC_EXPORT_KERNEL_SYMBOL=0
+
+KERNEL_VER ?= $(shell uname -r 2>/dev/null)
+
+ifeq ($(CONFIG_UB_UNIFIED_UBUS), y)
+KERNEL_DIR ?= $(UBUS_BUILD_KERNEL_DIR)
+DEFAULT_KERNEL_DIR ?= $(UBUS_BUILD_KERNEL_DIR)
+# 目前build_cache里的内核是6.6的,KERNEL_VER不影响功能,暂时写死
+KERNEL_VER ?= 6.6.0-132.0.0.111.oe2403sp3.aarch64
+else
+KERNEL_DIR ?= /lib/modules/$(KERNEL_VER)/build
+DEFAULT_KERNEL_DIR ?= /lib/modules/$(KERNEL_VER)/build
+endif
+
+OPTIONAL_FLAGS := -Wno-implicit-fallthrough -Wno-misleading-indentation -Wno-missing-prototypes -Wno-error=missing-declarations -Werror=date-time -Wno-missing-attributes -Wno-format-overflow -Wno-packed-not-aligned
+filter_unsupported_flag = \
+ $(eval support := $(call check_gcc_support, $(1))) \
+ $(if $(filter 0, $(support)), \
+ $(eval EXTRA_CFLAGS := $(filter-out $(1), $(EXTRA_CFLAGS))), \
+ $(eval EXTRA_CFLAGS += $(1)) \
+ ) \
+ $(if $(filter 0, $(support)), \
+ $(eval KBUILD_CFLAGS := $(filter-out $(1), $(KBUILD_CFLAGS))) \
+ )
+check_gcc_support = $(shell \
+ if echo "int main() { return 0; }" | gcc $(1) -c -x c -o /dev/null - 2>/dev/null; then \
+ gcc_support=1; \
+ else \
+ gcc_support=0; \
+ fi; \
+ \
+ if echo "int main() { return 0; }" | cc1 $(1) -x c - 2>/dev/null; then \
+ cc1_support=1; \
+ else \
+ cc1_support=0; \
+ fi; \
+ \
+ if command -v cc1 2>/dev/null; then \
+ if [ $$cc1_support -eq 1 ]; then \
+ echo 1; \
+ else \
+ echo 0; \
+ fi; \
+ else \
+ if [ $$gcc_support -eq 1 ]; then \
+ echo 1; \
+ else \
+ echo 0; \
+ fi; \
+ fi \
+)
+$(foreach flag, $(OPTIONAL_FLAGS), $(call filter_unsupported_flag, $(flag)))
+
+# CONFIG_FRAME_WARN
+CONFIG_FRAME := $(shell grep -q "CONFIG_FRAME_WARN=1024" $(KERNEL_DIR)/.config && echo 1)
+ifeq ($(CONFIG_FRAME),1)
+ EXTRA_CFLAGS += -Wframe-larger-than=2048
+endif
+
+# STACK_PROTECT
+NO_STACK_PROTECT := $(shell grep -q "STACKPROTECTOR_NONE=y" $(KERNEL_DIR)/.config && echo 1)
+STACK_PROTECT := $(shell grep -q "STACKPROTECTOR=y" $(KERNEL_DIR)/.config && echo 1)
+ifneq ($(NO_STACK_PROTECT),1)
+ ifeq ($(STACK_PROTECT),1)
+ EXTRA_CFLAGS += -fstack-protector-all
+ endif
+endif
+
+ifneq ($(KERNEL_DIR),$(DEFAULT_KERNEL_DIR))
+ # 尝试执行make kernelrelease
+ KERNEL_RELEASE := $(shell cd $(KERNEL_DIR) && make kernelrelease 2>/dev/null)
+
+ ifneq ($(KERNEL_RELEASE),)
+ # 如果执行成功,更新KERNEL_VER
+ KERNEL_VER := $(KERNEL_RELEASE)
+ $(info execute 'make kernelrelease' in $(KERNEL_DIR), using kernel version $(KERNEL_VER))
+ else
+ # 如果执行失败,保持原值并打印信息
+ $(warning Failed to execute 'make kernelrelease' in $(KERNEL_DIR), using default kernel version $(KERNEL_VER))
+ endif
+endif
+
+default:
+ $(MAKE) -C $(KERNEL_DIR) M=$(shell pwd) -W modules
+
+clean:
+ rm -rf *.o *.ko *.order .*.cmd *.mod.* .H* .tm* .tmp_versions Module.symvers *.ko.unsigned null
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/__init__.py b/drivers/net/ethernet/huawei/hinic5/build/host/linux/__init__.py
new file mode 100755
index 000000000..cc0d19d0a
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/__init__.py
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+# -*- encoding:utf-8 -*-
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
\ No newline at end of file
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/build_host.py b/drivers/net/ethernet/huawei/hinic5/build/host/linux/build_host.py
new file mode 100755
index 000000000..e11fbded3
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/build_host.py
@@ -0,0 +1,99 @@
+#!/usr/bin/env python
+# -*- encoding:utf-8 -*-
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
+import os
+import re
+import sys
+import env
+import logging
+import subprocess
+from pathlib import Path
+import shutil, random, string
+
+sys.path.append(env.HI1823_BUILD_SDK_DIR)
+import build_sdk
+sys.path.append(env.HI1823_BUILD_NIC_DIR)
+import build_nic
+sys.path.append(env.HI1823_BUILD_ROCE_DIR)
+import build_roce
+sys.path.append(env.HI1823_BUILD_UDMA_DIR)
+import build_udma
+
+def build_host_main():
+ # In order to adapt cross compile conditions.
+ env.dir_define()
+ ret = env.get_os_info()
+ if ret:
+ return ret
+ # set env for make cmd
+ env.set_env()
+
+ # Generating sdk compilation header file sdk_kcompat.h
+ sdk_kcompat_generator_path = Path(f"{env.HI1823_BUILD_SDK_DIR}/sdk-kcompat-generator.sh").resolve()
+ sdk_kcompat_path = f"{env.HI1823_TRUNK_DIR}/src/dpu_develop_interface/drv_sdk_intf/ossl/sdk_kcompat.h"
+
+ nic_kcompat_generator_path = Path(f"{env.HI1823_BUILD_NIC_DIR}/nic-kcompat-generator.sh").resolve()
+ nic_kcompat_generator_path_tmp = None
+ nic_kcompat_path = f"{env.HI1823_TRUNK_DIR}/src/dpu_develop_interface/drv_sdk_intf/ossl/nic_kcompat.h"
+
+ if env.hi1823_ubus_driver_unified_compile == False:
+ subprocess.run(
+ [ "bash", "-c",
+ f"source {sdk_kcompat_generator_path} && gen_sdk_kcompat '{sdk_kcompat_path}'"
+ ],
+ check=True
+ )
+ else:
+ subprocess.run(
+ [ "bash", "-c",
+ f"source {sdk_kcompat_generator_path} && gen_sdk_kcompat '{sdk_kcompat_path}' '{env.HI1823_BUILD_UBUS_KERNEL_DIR}'"
+ ],
+ check=True
+ )
+
+ # Nic drv适配1650
+ ksrc = env.HI1823_BUILD_UBUS_KERNEL_DIR
+ nic_kcompat_generator_path_tmp = str(nic_kcompat_generator_path).replace(".sh", f"_{random.randint(1000, 9999)}.sh")
+ shutil.copy(nic_kcompat_generator_path, nic_kcompat_generator_path_tmp)
+
+ with open(nic_kcompat_generator_path_tmp, 'r') as f:
+ content = f.read().replace("KERN_VER=$(uname -r)", "KERN_VER=NULL")
+ content = content.replace('KSRC=""', f'KSRC="{ksrc}"')
+ with open(nic_kcompat_generator_path_tmp, 'w') as f:
+ f.write(content)
+ nic_kcompat_generator_path = nic_kcompat_generator_path_tmp
+
+ # Generating NIC compilation header file nic_kcompat.h
+ subprocess.run(
+ [ "bash", "-c",
+ f"source {nic_kcompat_generator_path} && gen_nic_kcompat '{nic_kcompat_path}'"
+ ],
+ check=True
+ )
+ if nic_kcompat_generator_path_tmp and os.path.exists(nic_kcompat_generator_path_tmp):
+ os.remove(nic_kcompat_generator_path_tmp)
+ print(f"nic_kcompat header file generated: {os.path.exists(nic_kcompat_path)}")
+
+ ret = 0
+ if env.hi1823_feature == "SDK":
+ ret = build_sdk.build_sdk()
+ elif env.hi1823_feature == "SDK_KO":
+ ret = build_sdk.build_sdk_ko()
+ elif env.hi1823_feature == "NIC":
+ ret = build_sdk.build_sdk()
+ if ret:
+ return ret
+ ret = build_nic.build_nic()
+ elif env.hi1823_feature == "NIC_KO":
+ ret = build_sdk.build_sdk_ko()
+ if ret:
+ return ret
+ ret = build_nic.build_nic_ko()
+ elif env.hi1823_feature == "ROCE":
+ ret = build_roce.build_roce()
+ elif env.hi1823_feature == "UDMA":
+ ret = build_udma.build_udma()
+ else:
+ logging.error("Unkown Feature, Please check your inputting!")
+
+ return ret
\ No newline at end of file
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/kcompat-lib.sh b/drivers/net/ethernet/huawei/hinic5/build/host/linux/kcompat-lib.sh
new file mode 100755
index 000000000..dcaa778c4
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/kcompat-lib.sh
@@ -0,0 +1,300 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-only
+# Copyright(c) 2025 Huawei Technologies Co., Ltd
+
+# Example of using the gen function
+# Required Field []
+# Optional Items ()
+# gen DEFINE if [fun|enum|struct|macro|typedef|symbol] NAME (absent) in
+# gen DEFINE if [fun|enum|struct|macro|typedef|symbol] NAME [matches|lacks] PATTERN in
+# gen DEFINE if [fun] NAME [countparam] [number] in
+# gen DEFINE if [method] method_name of NAME [matches|lacks] PATTERN in
+# gen DEFINE if [method] method_name of NAME [matches|lacks] (fun_param|return_type) PATTERN in
+# gen DEFINE if [method] method_name of NAME (absent) in
+# gen DEFINE if [method] method_name of NAME [countparam] [number] in
+
+set -e
+
+function g_log_err() {
+ local log_time=$(date +"%Y-%m-%d %H:%M:%S")
+ echo >&2 "$log_time $@"
+ exit 10
+}
+
+WB='[ \t\n]'
+NI='[^A-Za-z0-9_]'
+# Return to function context, don't pass return type in $1
+# looks only in files specified (files[@], struct_context)
+function find_fun_context() {
+ test $# -ge 1
+ local start1 end1
+ start1="/$WB*([(]\*)?($NI|^)$1$WB*($|[()])/"
+ end1='/\);?$/'
+ shift
+ awk "
+ /^$WB*\*/ {next}
+ $start1, $end1
+ " "$@"
+}
+
+# Return to enum context
+function find_enum_context() {
+ test $# -ge 2
+ local start2 end2
+ start2="/^$WB*enum$WB+$1"' \{$/'
+ end2='/\};$/'
+ awk "
+ /^$WB*\*/ {next}
+ $start2, $end2
+ " ${files[@]}
+}
+
+# Return to struct context
+function find_struct_context() {
+ test $# -ge 2
+ local start3 end3
+ start3="/^$WB*struct$WB+$1"' \{$/'
+ end3='/^\};$/'
+ awk "
+ /^$WB*\*/ {next}
+ $start3, $end3
+ " ${files[@]}
+}
+
+# Return to first line of macro definition
+function find_macro_context() {
+ test $# -ge 2
+ local start4 end4
+ # Match only unindented macro definitions
+ start4="/^#define$WB+$1"'([ \t\(]|$)/'
+ end4=1 # Extract only the first row of the matched range.
+ awk "
+ /^$WB*\*/ {next}
+ $start4, $end4
+ " ${files[@]}
+}
+
+# Return to first line of $1 typedef definition
+# This only handles typedefs where the name is on first line
+function find_typedef_context() {
+ test $# -ge 2
+ local start5 end5
+ start5="/^typedef$WB.*$1"'[\(\); \t\n]/'
+ end5='/;$/'
+ awk "
+ /^$WB*\*/ {next}
+ $start5, $end5
+ " ${files[@]}
+}
+
+# Return to symbol line from Module.symvers
+function find_symbol_context() {
+ test $# -ge 2
+ local start6 end6
+ start6="/^0x[0-9a-f]+\t$1\t/"
+ end6=1 # only one line
+ awk "
+ /^$WB*\*/ {next}
+ $start6, $end6
+ " ${files[@]}
+}
+
+# Return the number of function parameters
+function count_fun_params() {
+ local context="$1"
+ local count=0
+
+ local params=$(echo "$context" | awk 'BEGIN{ORS=" "} {print}' | sed -n 's/.*(\(.*\)).*/\1/p' | xargs)
+ if [ -n "$params" ] && [ "$params" != "void" ]; then
+ IFS=',' read -ra param_array <<< "$params"
+ for param in "${param_array[@]}"; do
+ if [ -n "$(echo "$param" | tr -d '[:space:]')" ]; then
+ ((count+=1))
+ fi
+ done
+ else
+ count=0
+ fi
+ echo $count
+}
+
+function gen() {
+ test $# -ge 6 || g_log_err "$src_line: too few arguments"
+ local define="" struct_name="" member_name="" func_name=""
+ local src_line="${BASH_SOURCE[0]}:${BASH_LINENO[0]}"
+ files=()
+ local context=""
+ local pattern='.'
+ local seen_in=0
+ local define="$1"
+ local param_count=""
+ [ "$2" != "if" ] && g_log_err "$src_line: 'if' keyword expected"
+ local kind="$3"
+ shift 3
+ if [ "$kind" = "string" ]; then
+ given_value="$1"
+ keyword="$2"
+ expected_value="$3"
+ found_fmt="#define %s 1\n"
+ if [ "${given_value}" = "${expected_value}" ]; then
+ printf -- "$found_fmt" "$define"
+ fi
+ return 0
+ fi
+ for arg in "$@"; do
+ if [ "$arg" = "in" ]; then
+ seen_in=1
+ continue
+ fi
+ if [ $seen_in -eq 1 ] && [ -e "$arg" ] ; then
+ files+=("$arg")
+ fi
+ done
+ if [ ${#files[@]} -eq 0 ]; then
+ echo >&2 "[INFO] ${BASH_LINENO[0]} gen invoked, but input file is missing."
+ return 0
+ fi
+
+ for f in "${files[@]}"; do
+ if [[ -e "$f" ]]; then
+ file_desc=$(file "$f")
+ # linux 下ASCII CRLF 文件匹配错误,需要告警退出
+ if [[ "$file_desc" == *"with CRLF line terminators"* ]]; then
+ echo >&2 "[ERROR] ${BASH_SOURCE[0]}:${BASH_LINENO[0]}: CRLF line endings detected in '$f'"
+ echo >&2 " This may cause parsing errors. Please convert to LF (Unix) line endings."
+ echo >&2 " Hint: run 'dos2unix \"$f\"' or 'sed -i \"s/\\r\$//\" \"$f\"'"
+ return 0
+ fi
+ fi
+ done
+
+ case "$kind" in
+ fun|enum|struct|macro|typedef|symbol)
+ test $# -ge 2 || g_log_err "$src_line: too few arguments"
+ name="$1"
+ shift
+ if [[ "$1" == "matches" || "$1" == "lacks" ]]; then
+ test $# -ge 2 || g_log_err "$src_line: too few arguments"
+ modelops="$1"
+ pattern="$2"
+ elif [[ "$1" == "absent" ]]; then
+ test $# -ge 2 || g_log_err "$src_line: too few arguments"
+ modelops="$1"
+ elif [[ "$1" == "countparam" ]]; then
+ test $# -ge 2 || g_log_err "$src_line: too few arguments"
+ modelops="$1"
+ param_count="$2"
+ else
+ modelops=matches
+ fi
+ context="$(find_${kind}_context "$name" "${files[@]}")"
+ process_context "$context" "$define" "$pattern" "$modelops" "$param_count"
+ ;;
+ method)
+ test $# -ge 5 || g_log_err "$src_line: too few arguments"
+ member_name="$1"
+ pattern="$1"
+ [ "$2" != of ] && g_log_err "$src_line: 'of' keyword expected"
+ struct_name="$3"
+ shift 3
+ if [[ "$1" == "matches" || "$1" == "lacks" ]]; then
+ modelops="$1"
+ pattern="$2"
+ if [[ "$2" == "return_type" || "$2" == "fun_param" ]]; then
+ pattern="$3"
+ fi
+ elif [[ "$1" == "countparam" ]]; then
+ modelops="$1"
+ param_count="$2"
+ elif [[ "$1" == "absent" ]]; then
+ modelops="$1"
+ else
+ modelops=matches
+ fi
+ local struct_context=""
+ struct_context="$(find_struct_context "$struct_name" "${files[@]}")"
+ context="$(find_fun_context "$member_name" <<< "$struct_context")"
+ process_context "$context" "$define" "$pattern" "$modelops" "$param_count"
+ ;;
+ *)
+ g_log_err "$src_line: unknown kind" ;;
+ esac
+}
+
+process_context() {
+ local context="$1" define="$2" pattern="$3" modelops="$4" param_count="$5"
+ local found=0 not_empty=0
+ if [ "$modelops" = "countparam" ]; then
+ local actual_param_count=$(count_fun_params "$context")
+ if [[ "$param_count" =~ ^[0-9]+$ ]] && [ "$actual_param_count" -eq "$param_count" ]; then
+ found=1
+ fi
+ else
+ # Use awk to check whether the given pattern matches in $context
+ read found not_empty <<< "$(awk -v pattern="$pattern" '
+ BEGIN {
+ NI = "[^A-Za-z0-9_]"
+ if (!match(pattern, NI "$"))
+ pattern = pattern "(" NI "|$)"
+ pattern = "(^|" NI ")" pattern
+ found = 0
+ not_empty = 0
+ }
+ /./ { not_empty = 1 } # mark context as non-empty
+ $0 ~ pattern { found = 1 } # mark if the pattern matches
+ END {
+ print found, not_empty
+ }
+ ' <<< "$context")"
+ fi
+ format_result "$define" "$found" "$not_empty" "$modelops"
+}
+
+format_result() {
+ local define="$1" found="$2" not_empty="$3" modelops="$4"
+ local found_fmt_tmp
+
+ found_fmt_tmp="#define %s 1\n";
+
+ if { [ "$modelops" = lacks ] && [ "$found" -eq 0 ] && [ "$not_empty" -eq 1 ]; } ||
+ { [ "$modelops" = matches ] && [ "$found" -eq 1 ]; } ||
+ { [ "$modelops" = absent ] && [ "$found" -eq 0 ]; } ||
+ { [ "$modelops" = countparam ] && [ "$found" -eq 1 ]; }
+ then
+ printf "$found_fmt_tmp" "$define"
+ fi
+}
+
+find_config_net_devlink() {
+ local -a config_files=( config_files
+ "$KOBJ/include/generated/autoconf.h"
+ "$KOBJ/include/linux/autoconf.h"
+ "$KOBJ/.config"
+ )
+ local file
+
+ echo >&2 "${KSRC-}"
+ if ! [ -d "${KSRC-}" ]; then
+ echo >&2 "Error: KSRC not valid"
+ exit 13
+ fi
+
+ for file in "${config_files[@]}"; do
+ if [ -f "$file" ]; then
+ echo >&2 "find config file: $file"
+ config_file=$(realpath "${file-}")
+ if grep -qE "^(#define )?CONFIG_NET_DEVLINK((_MODULE)? 1|=m|=y)$" "$config_file"; then
+ echo >&2 "CONFIG_NET_DEVLINK Found"
+ return 0
+ else
+ return 1
+ fi
+ fi
+ done
+ return 1
+}
+
+# return true/false instead of generating output.
+function check() {
+ [[ "$(gen CHECK if "$@")" = "#define CHECK 1" ]]
+}
\ No newline at end of file
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/nic/__init__.py b/drivers/net/ethernet/huawei/hinic5/build/host/linux/nic/__init__.py
new file mode 100755
index 000000000..cc0d19d0a
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/nic/__init__.py
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+# -*- encoding:utf-8 -*-
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
\ No newline at end of file
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/nic/build_nic.py b/drivers/net/ethernet/huawei/hinic5/build/host/linux/nic/build_nic.py
new file mode 100755
index 000000000..0f646b143
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/nic/build_nic.py
@@ -0,0 +1,182 @@
+#!/usr/bin/env python
+# -*- encoding:utf-8 -*-
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
+import os
+import re
+import sys
+import env
+import logging
+import shutil
+import subprocess
+from build_util import do_cmd, do_make, do_make_clean, rpm_build
+
+
+NIC_RPM_BUILD_DIR = f"{env.HI1823_BUILD_DIR}/host/linux/nic/nic_rpm_build/"
+nic_kcompat_file = f"{env.HI1823_TRUNK_DIR}/src/dpu_develop_interface/drv_sdk_intf/ossl/nic_kcompat.h"
+
+def save_output(path):
+ shutil.rmtree(path, ignore_errors=True)
+ os.makedirs(path, exist_ok=True)
+ env.copy_file(f"{env.hi1823_nic_code_dir}/hinic5.ko", path)
+ env.copy_file(nic_kcompat_file, path)
+
+ # get build info
+ cmd = ["sh", f"{env.HI1823_BUILD_LOG_PATH}/build_log.sh", f"{env.hi1823_nic_code_dir}/build", path, "hinic5.ko"]
+ do_cmd(*cmd)
+
+ ret = env.collect_build_info(path, f"{env.hi1823_bin_dir}/driver/linux/nic")
+ if ret:
+ raise Exception('env.collect_build_info failed')
+
+ # strip debug info of ko for release rpm or deb package
+ cmd = ["strip", "--strip-debug", f"{path}/hinic5.ko", "-o", f"{path}/hinic5_tmp.ko"]
+ do_cmd(*cmd)
+
+
+def build_clean():
+ module_file = f"{env.hi1823_ci_lib_dir}/NIC_Module.symvers"
+ if os.path.isfile(module_file):
+ os.remove(module_file)
+ env.copy_file(f"{env.hi1823_nic_code_dir}/Module.symvers", env.hi1823_ci_lib_dir, "NIC_Module.symvers")
+
+ # make clean
+ do_make_clean(workdir=env.hi1823_nic_code_dir)
+
+ cmd = ["find", f"{env.HI1823_TRUNK_DIR}/src/dpu_platform_library/host/sdk/knldk", "-name", "*.o",
+ "-o", "-name", "*.cmd", "-o", "-name", "*.mod"]
+ result = do_cmd(*cmd)
+ do_cmd('xargs', 'rm', '-f', input=result.stdout)
+
+ cmd = ["find", f"{env.HI1823_TRUNK_DIR}/src/dpu_platform_library/host/sdk/ossl", "-name", "*.o",
+ "-o", "-name", "*.cmd"]
+ result = do_cmd(*cmd)
+ do_cmd('xargs', 'rm', '-f', input=result.stdout)
+
+ cmd = ["find", f"{env.HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/nic", "-name", "*.o",
+ "-o", "-name", "*.cmd", "-o", "-name", "*.mod"]
+ result = do_cmd(*cmd)
+ do_cmd('xargs', 'rm', '-f', input=result.stdout)
+
+
+def build_deb_package(arch):
+ workdir = f'{env.HI1823_BUILD_DIR}/host/linux/nic/nic_deb_build/'
+ kernel_release = env.hi1823_complie_os_kver
+ driver_version = env.get_global_version('driver')
+
+ if arch == "x86_64":
+ distname = "amd64"
+ else:
+ distname = "arm64"
+
+ distdir = f'{workdir}/{distname}'
+ modules_dir = f"{distdir}/lib/modules/"
+ modules_load_dir = f"{distdir}/lib/modules-load.d/"
+ ko_dir = f'{modules_dir}/{kernel_release}/updates/hinic5/'
+
+ shutil.rmtree(modules_dir, ignore_errors=True)
+ os.makedirs(ko_dir)
+
+ # prepare hinic5
+ nic_output = env.get_driver_output_path('nic')
+ shutil.move(f'{nic_output}/hinic5_tmp.ko', f'{ko_dir}/hinic5.ko')
+ env.copy_file(f"{workdir}/hinic5-modules.conf", modules_load_dir)
+
+ do_cmd('sed', '-i', f'/^Version/c Version: {driver_version}', f'{distdir}/DEBIAN/control')
+ do_cmd('chmod', '-R', '775', f'{distdir}/DEBIAN/')
+
+ # build deb
+ deb_file = f"hinic5-{driver_version}-{env.hi1823_complie_os_kver_underline}.{arch}.deb"
+ cmd = ["dpkg", "-b", distname, deb_file]
+ do_cmd(*cmd, cwd=workdir)
+
+ shutil.move(f'{workdir}/{deb_file}', nic_output)
+
+
+def get_rpm_spec(os_type, arch):
+ if os_type == 'UVP':
+ spec = 'hinic5_uvp.spec'
+ else:
+ spec = 'hinic5.spec'
+ return spec
+
+
+def build_rpm_package(arch):
+ os_type = env.hi1823_os_type
+ workdir = env.HI1823_RPM_BUILD_DIR
+
+ shutil.rmtree(workdir, ignore_errors=True)
+ cmd = [
+ 'mkdir', '-pv', '-m', '777',
+ f'{workdir}/BUILD',
+ f'{workdir}/BUILDROOT',
+ f'{workdir}/RPMS',
+ f'{workdir}/SOURCES',
+ f'{workdir}/SPECS',
+ f'{workdir}/SRPMS'
+ ]
+ do_cmd(*cmd)
+
+ env.copy_file(f'{env.HI1823_TRUNK_DIR}/src/GLOBAL_VERSION_NEW', f'{workdir}/SOURCES')
+
+ # prepare hinic5
+ nic_output = env.get_driver_output_path('nic')
+
+ shutil.move(f'{nic_output}/hinic5_tmp.ko', f'{workdir}/SOURCES/hinic5.ko')
+ env.copy_file(f'{NIC_RPM_BUILD_DIR}/hinic5-modules.conf', f'{workdir}/SOURCES')
+
+ # prepare OS
+ if os_type == 'UVP':
+ env.copy_file(f'{NIC_RPM_BUILD_DIR}hinic5-dracut.conf', f'{workdir}/SOURCES')
+
+ # prepare rpm spec
+ spec = get_rpm_spec(os_type, arch)
+ if not spec:
+ raise Exception(f'no spec to build rpm. OS type {os_type}, arch {arch}')
+ env.copy_file(f'{NIC_RPM_BUILD_DIR}/{spec}', f'{workdir}/SPECS')
+
+ # build rpm
+ rpm_build(workdir=workdir, spec=spec, arch=arch)
+
+ # copy rpm to output dir
+ rpm_dir = f'{workdir}/RPMS/{arch}'
+ env.copy_file_with_end(rpm_dir, nic_output, ".rpm")
+
+
+def build_package(pkg_type, arch):
+ if pkg_type == "rpm":
+ return build_rpm_package(arch=arch)
+ if pkg_type == "deb":
+ return build_deb_package(arch=arch)
+ raise Exception(f'unknown package manager type {pkg_type}')
+
+
+def build_nic_rpm_deb():
+ try:
+ build_package(
+ pkg_type=env.hi1823_os_pkg_mgr,
+ arch=env.hi1823_os_arch,
+ )
+ return 0
+ except Exception as e:
+ logging.exception(f'build package failed')
+ return 1
+
+
+def build_nic_ko():
+ srcdir = env.hi1823_nic_code_dir
+ outdir = env.get_driver_output_path('nic')
+
+ try:
+ # make
+ do_make_clean(workdir=srcdir)
+ do_make(workdir=srcdir)
+
+ save_output(outdir)
+ build_clean()
+ return 0
+ except Exception as e:
+ logging.exception(f'build ko failed')
+ return 1
+
+def build_nic():
+ return build_nic_ko()
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/nic/nic-kcompat-generator.sh b/drivers/net/ethernet/huawei/hinic5/build/host/linux/nic/nic-kcompat-generator.sh
new file mode 100755
index 000000000..62ba8da23
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/nic/nic-kcompat-generator.sh
@@ -0,0 +1,500 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright(c) 2025 Huawei Technologies Co., Ltd
+
+# This file is used to automatically generate HAVE_ and NEED_ macros
+# for the current or incoming kernel.
+#
+# It is primarily implemented by invoking the 'gen' function in the kcompat-lib.sh file
+# (you can refer to the main part of 'gen_xx' for details).
+# The 'gen' tool can search for declarations of various types in kernel header files to generate macros.
+# For example, search for a function in a specified file and check whether the given function exists.
+# Please refer to the comments above the 'gen' function in kcompat-lib.sh.
+
+# End of intro.
+# The implementation is in kcompat-lib.sh, and below is an example of the 'gen' invocation.
+
+set -e
+
+echo "curr bash script file name: $(basename "${BASH_SOURCE[0]}")"
+export LC_ALL=C
+SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
+ORIG_CWD="$(pwd)"
+trap 'rc=$?; echo >&2 "$(realpath "$ORIG_CWD/${BASH_SOURCE[0]}"):$LINENO: failed with rc: $rc"' ERR
+
+# shellcheck source=kcompat-lib.sh
+CURR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+KCOMPAT_LIB="${CURR_DIR}/../kcompat-lib.sh"
+
+if [ -f "$KCOMPAT_LIB" ]; then
+ echo "$KCOMPAT_LIB file is exist"
+else
+ echo "$KCOMPAT_LIB file is not exist"
+fi
+source "$KCOMPAT_LIB"
+
+ARCH=$(uname -m)
+IS_ARM=""
+if [ "$ARCH" == aarch64 ]; then
+ IS_ARM=1
+fi
+
+function ready_gen()
+{
+ KERN_VER=$(uname -r)
+ KSRC=""
+
+ if [ -e /usr/src/kernels/linux-"$KERN_VER"/include/config ]; then
+ KSRC="/usr/src/kernels/linux-"$KERN_VER"/"
+ elif [ -e /usr/src/kernels/"$KERN_VER"/include/config ]; then
+ KSRC="/usr/src/kernels/"$KERN_VER"/"
+ elif [ -e /lib/modules/"$KERN_VER"/build/include/config ]; then
+ KSRC="/lib/modules/"$KERN_VER"/build/"
+ fi
+
+ if [ -z "$KSRC" ]; then
+ KERN_VER=$(uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/')
+ if [ -e /usr/src/kernels/linux-"$KERN_VER"/include/config ]; then
+ KSRC="/usr/src/kernels/linux-"$KERN_VER"/"
+ elif [ -e /usr/src/kernels/"$KERN_VER"/include/config ]; then
+ KSRC="/usr/src/kernels/"$KERN_VER"/"
+ elif [ -e /lib/modules/"$KERN_VER"/build/include/config ]; then
+ KSRC="/lib/modules/"$KERN_VER"/build/"
+ fi
+ fi
+
+ if [ -z "$KSRC" ]; then
+ echo "Invalid kernel src. Expected: ${KERN_VER}. Please check if kernel-devel(for other OS) or linux-headers(for debian) installed"
+ KSOURCES=$(ls -w 1 /usr/src/kernels/ ; ls -w 1 /lib/modules/)
+ echo "Found: ${KSOURCES}"
+ exit 1
+ fi
+ KOBJ=$KSRC
+
+ if [ ! -d "${KSRC}"/include/linux ]; then
+ echo "Detect other Debian/SLES include directory using KSRC..."
+ # detect other SLES include directory using KSRC
+ t=$(dirname "$KSRC")/$(basename "$KSRC")
+ if [ -L "$t" ]; then
+ # a symlink
+ t=$(readlink -f $t)
+ fi
+ # SLES
+ t=${t%-obj*}
+ # LinxOS
+ t=${t/-linx-security-arm64/-common-linx-security}
+ # Debian
+ t=${t/-amd64/-common}
+ t=${t/-arm64/-common}
+ if [ -d "${t}"/include/linux ]; then
+ KSRC=$t
+ fi
+ fi
+ echo "nic-kcompat-generator.sh -> KERN_VER: ${KERN_VER}"
+ echo "nic-kcompat-generator.sh -> KSRC: ${KSRC}"
+ export KSRC KOBJ
+}
+
+function gen_devres() {
+ dvh='include/linux/device.h'
+ ddrh='include/linux/device/devres.h'
+ # gen NEED_DEVM_KASPRINTF if fun devm_kasprintf absent in "$dvh" "$ddrh"
+ # gen NEED_DEVM_KCALLOC if fun devm_kcalloc absent in "$dvh" "$ddrh" -- delete
+ # gen NEED_DEVM_KFREE if fun devm_kfree absent in "$dvh" "$ddrh"
+ # gen NEED_DEVM_KMEMDUP if fun devm_kmemdup absent in "$dvh" "$ddrh"
+ # gen NEED_DEVM_KSTRDUP if fun devm_kstrdup absent in "$dvh" "$ddrh"
+ # gen NEED_DEVM_KVASPRINTF if fun devm_kvasprintf absent in "$dvh" "$ddrh"
+ # gen NEED_DEVM_KZALLOC if fun devm_kzalloc absent in "$dvh" "$ddrh"
+}
+
+function gen_dma() {
+ dma='include/linux/dma-mapping.h'
+ da='include/linux/dma-attrs.h'
+ # gen HAVE_DMA_SET_MASK if fun dma_set_mask in "$dma"
+ # gen NEED_DMA_ZALLOC_COHERENT if fun dma_zalloc_coherent absent in "$dma"
+ # gen NEED_DMA_SET_MASK_AND_COHERENT if fun dma_set_mask_and_coherent absent in "$dma"
+ # gen HAVE_STRUCT_DMA_ATTRS if struct dma_attrs in "$da"
+ HAVE_DMA_ATTR_WRITE_BARRIER=0
+ if check enum dma_attr matches DMA_ATTR_WRITE_BARRIER in "$da" ||
+ check macro DMA_ATTR_WRITE_BARRIER in "$dma"; then
+ HAVE_DMA_ATTR_WRITE_BARRIER=1
+ fi
+ # gen HAVE_DMA_ATTR_WRITE_BARRIER if string "$HAVE_DMA_ATTR_WRITE_BARRIER" equals 1
+}
+
+function gen_ethtool() {
+ eth='include/linux/ethtool.h'
+ ueth='include/uapi/linux/ethtool.h'
+ gen HAVE_ETHTOOL_COALESCE_EXTACK if method get_coalesce of ethtool_ops matches 'struct kernel_ethtool_coalesce \\*' in "$eth"
+ gen HAVE_ETHTOOL_EXTENDED_RINGPARAMS if method get_ringparam of ethtool_ops matches 'struct kernel_ethtool_ringparam \\*' in "$eth"
+ gen HAVE_RXFH_HASHFUNC if method get_rxfh of ethtool_ops matches hfunc in "$eth"
+ # gen HAVE_RXFH_PARAM if method get_rxfh of ethtool_ops matches 'struct ethtool_rxfh_param \\*' in "$eth"
+ # gen HAVE_ETHTOOL_GET_RXNFC_U32_RULELOCS if method get_rxnfc of ethtool_ops matches 'u32 \\*rule_locs' in "$eth"
+
+ gen HAVE_ETHTOOL_GET_RXNFC_VOID_RULELOCS if method get_rxnfc of ethtool_ops matches 'void \\*rule_locs' in "$eth"
+ gen HAVE_ETHTOOL_GET_RXFH_INDIR_SIZE if method get_rxfh_indir_size of ethtool_ops in "$eth"
+ gen HAVE_ETHTOOL_GET_MODULE_EEPROM_BY_PAGE if method get_module_eeprom_by_page of ethtool_ops in "$eth"
+ gen HAVE_ETHTOOL_RXFH_INDIR_STRUCT_RXFH_INDIR if method set_rxfh_indir of ethtool_ops matches 'struct ethtool_rxfh_indir \\*' in "$eth"
+ gen SUPPORTED_COALESCE_PARAMS if struct ethtool_ops matches supported_coalesce_params in "$eth"
+ gen HAVE_ETHTOOL_SET_PHYS_ID if method set_phys_id of ethtool_ops in "$eth"
+ gen HAVE_ETHTOOL_OPS_EXT if struct ethtool_ops_ext in "$eth"
+ gen NEED_DEFINE_SPEED_20000 if macro SPEED_20000 absent in "$eth"
+ gen NEED_DEFINE_SPEED_25000 if macro SPEED_25000 absent in "$eth"
+ gen NEED_DEFINE_SPEED_40000 if macro SPEED_40000 absent in "$eth"
+ gen NEED_DEFINE_SPEED_100000 if macro SPEED_100000 absent in "$eth"
+ gen NEED_DEFINE_ETH_MODULE_SFF_8636 if macro ETH_MODULE_SFF_8636 absent in "$ueth"
+ gen NEED_DEFINE_ETH_MODULE_SFF_8636_LEN if macro ETH_MODULE_SFF_8636_LEN absent in "$ueth"
+ gen NEED_DEFINE_ETH_MODULE_SFF_8436 if macro ETH_MODULE_SFF_8436 absent in "$ueth"
+ gen NEED_DEFINE_ETH_MODULE_SFF_8436_LEN if macro ETH_MODULE_SFF_8436_LEN absent in "$ueth"
+ gen HAVE_ETHTOOL_GLINKSETTINGS if macro ETHTOOL_GLINKSETTINGS in "$ueth"
+ gen NEED_ENUM_ETHTOOL_LINK_MODE_25000baseCR_Full_BIT if enum ethtool_link_mode_bit_indices lacks ETHTOOL_LINK_MODE_25000baseCR_Full_BIT in "$ueth"
+ gen NEED_ENUM_ETHTOOL_LINK_MODE_25000baseKR_Full_BIT if enum ethtool_link_mode_bit_indices lacks ETHTOOL_LINK_MODE_25000baseKR_Full_BIT in "$ueth"
+ gen NEED_ENUM_ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT if enum ethtool_link_mode_bit_indices lacks ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT in "$ueth"
+ gen NEED_ENUM_ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT if enum ethtool_link_mode_bit_indices lacks ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT in "$ueth"
+
+ HAVE_NEW_ETHTOOL_LINK_SETTINGS_ONLY=0
+ if check method get_settings of ethtool_ops absent in "$eth" &&
+ check method get_link_ksettings of ethtool_ops in "$eth"; then
+ HAVE_NEW_ETHTOOL_LINK_SETTINGS_ONLY=1
+ fi
+ gen HAVE_NEW_ETHTOOL_LINK_SETTINGS_ONLY if string "$HAVE_NEW_ETHTOOL_LINK_SETTINGS_ONLY" equals 1
+
+ gen HAVE_KERNEL_ETHTOOL_TS_INFO if struct kernel_ethtool_ts_info in "$eth"
+ gen HAVE_ETHTOOL_RXFH_PARAM if struct ethtool_rxfh_param in "$eth"
+ gen NEED_ETHTOOL_COALESCE_USECS_LOW_HIGH if macro ETHTOOL_COALESCE_USECS_LOW_HIGH absent in "$eth"
+ gen NEED_ETHTOOL_COALESCE_MAX_FRAMES_LOW_HIGH if macro ETHTOOL_COALESCE_MAX_FRAMES_LOW_HIGH absent in "$eth"
+ gen NEED_ETHTOOL_COALESCE_PKT_RATE_RX_USECS if macro ETHTOOL_COALESCE_PKT_RATE_RX_USECS absent in "$eth"
+}
+
+function gen_filter() {
+ fh='include/linux/filter.h'
+ gen HAVE_NETDEV_PROG_XDP_WARN_ACTION if fun bpf_warn_invalid_xdp_action matches 'struct net_device \\*' in "$fh"
+ # gen NEED_DEFINE_XDP_DO_FLUSH_MAP if macro xdp_do_flush_map absent in "$fh"
+ gen HAVE_XDP_DO_FLUSH_MAP if fun xdp_do_flush_map in "$fh"
+}
+
+function gen_netdevice() {
+ ndh='include/linux/netdevice.h'
+ nddh='include/linux/net_debug.h'
+ gen NEED_NETIF_NAPI_ADD_NO_WEIGHT if fun netif_napi_add matches 'int weight' in "$ndh"
+ gen HAVE_NETIF_NAPI_NO_WEIGHT if fun netif_napi_add lacks 'int weight' in "$ndh"
+ gen HAVE_NETIF_NAPI_ADD_WEIGHT if fun netif_napi_add_weight in "$ndh"
+ gen HAVE_NDO_TX_TIMEOUT_TXQ if method ndo_tx_timeout of net_device_ops matches txqueue in "$ndh"
+ gen HAVE_NDO_XDP if method ndo_xdp of net_device_ops in "$ndh"
+ gen HAVE_NDO_BPF if method ndo_bpf of net_device_ops in "$ndh"
+ gen HAVE_XDP_XDP_QUERY_PROG if enum xdp_netdev_command matches XDP_QUERY_PROG in "$ndh"
+ gen HAVE_BPF_XDP_QUERY_PROG if enum bpf_netdev_command matches XDP_QUERY_PROG in "$ndh"
+ gen HAVE_NDO_GET_STATS64 if method ndo_get_stats64 of net_device_ops in "$ndh"
+ gen HAVE_NDO_DO_IOCTL if method ndo_do_ioctl of net_device_ops in "$ndh"
+
+ gen HAVE_VOID_NDO_GET_STATS64 if method ndo_get_stats64 of net_device_ops matches 'void[ \t]*\\(\\*' in "$ndh"
+ gen HAVE_NDO_SET_FEATURES if method ndo_set_features of net_device_ops in "$ndh"
+ gen HAVE_NDO_SET_U32_FEATURES if method ndo_set_features of net_device_ops matches 'u32 features' in "$ndh"
+ gen HAVE_NAPI_GRO_FLUSH_OLD if fun napi_gro_flush matches 'bool flush_old' in "$ndh"
+ gen HAVE_NDO_UDP_TUNNEL_ADD if method ndo_udp_tunnel_add of net_device_ops in "$ndh"
+ gen HAVE_VF_SPOOFCHK_CONFIGURE if method ndo_set_vf_spoofchk of net_device_ops in "$ndh"
+ gen HAVE_NDO_SET_VF_TRUST if method ndo_set_vf_trust of net_device_ops in "$ndh"
+ gen HAVE_NDO_SET_VF_MIN_MAX_TX_RATE if method ndo_set_vf_rate of net_device_ops in "$ndh"
+ # gen HAVE_NETDEV_LEVEL_ONCE if macro netdev_warn_once in "$ndh" "$nddh"
+ # gen HAVE_DEV_OPEN_EXTACK if fun dev_open matches extack in "$ndh"
+ gen HAVE_NETDEVICE_MIN_MAX_MTU if struct net_device matches min_mtu in "$ndh"
+ gen HAVE_NETDEV_STATS_IN_NETDEV if struct net_device matches 'struct net_device_stats[ \t]*stats' in "$ndh"
+ gen HAVE_NETDEVICE_MACSEC_OPS if struct net_device matches 'const struct macsec_ops[ \t]*\\*macsec_ops' in "$ndh"
+ # gen NEED_DEFINE_NAPI_POLL_WEIGHT if macro NAPI_POLL_WEIGHT absent in "$ndh"
+ gen HAVE_NDO_SET_VF_LINK_STATE if method ndo_set_vf_link_state of net_device_ops in "$ndh"
+ gen HAVE_NDO_SELECT_QUEUE_FALLBACK if method ndo_select_queue of net_device_ops matches fallback in "$ndh"
+ gen HAVE_NDO_SELECT_QUEUE_SB_DEV if method ndo_select_queue of net_device_ops matches sb_dev in "$ndh"
+ gen HAVE_NDO_SELECT_QUEUE_ACCEL if method ndo_select_queue of net_device_ops matches accel_priv in "$ndh"
+ gen NEED_NETDEV_NOTIFIER_INFO_TO_DEV if fun netdev_notifier_info_to_dev absent in "$ndh"
+ # exception centos7.9 x86 os
+ # (Un)registration functions for the notifiers that takes 'struct netdev_notifier_info *' as parameter in register_netdevice_notifier_rh
+ # gen HAVE_REGISTER_NETDEVICE_NOTIFIER_RH if fun register_netdevice_notifier_rh in "$ndh"
+ gen HAVE_NET_DEVICE_OPS_EXT if struct net_device_ops_ext in "$ndh"
+ gen HAVE_NET_DEVICE_OPS_EXTENDED if struct net_device_ops_extended in "$ndh"
+ gen HAVE_NET_DEV_OPS_EXT_NDO_SET_VF_VLAN if method ndo_set_vf_vlan of net_device_ops_extended in "$ndh"
+ gen HAVE_NET_DEV_OPS_EXT_NDO_CHANGE_MTU if method ndo_change_mtu of net_device_ops_extended in "$ndh"
+ gen HAVE_NETDEVICE_EXTENDED_MIN_MAX_MTU if struct net_device_extended matches min_mtu in "$ndh"
+ gen NEED_NETDEV_PHYS_ITEM_ID if struct netdev_phys_item_id absent in "$ndh"
+ gen NEED_DEFINE_NETDEV_RSS_KEY_LEN if macro NETDEV_RSS_KEY_LEN absent in "$ndh"
+ gen NEED_NAPI_SCHEDULE_IRQOFF if fun napi_schedule_irqoff absent in "$ndh"
+ # gen NEED_DEFINE_NETDEV_HW_ADDR_LIST_FOR_EACH if macro netdev_hw_addr_list_for_each absent in "$ndh"
+ # gen HAVE_NDO_XDP_XMIT if method ndo_xdp_xmit of net_device_ops in "$ndh"
+ gen HAVE_NETDEV_CHANGEUPPER if enum netdev_cmd matches NETDEV_CHANGEUPPER in "$ndh"
+ gen HAVE_NETDEV_CHANGEUPPER if macro NETDEV_CHANGEUPPER in "$ndh"
+}
+
+function gen_pci() {
+ pcih='include/linux/pci.h'
+ pdch='include/linux/pci-dma-compat.h'
+ # gen NEED_DEFINE_PCI_POOL_ALLOC if macro pci_pool_alloc absent in "$pcih"
+ # gen NEED_DEFINE_PCI_POOL_FREE if macro pci_pool_free absent in "$pcih"
+ # gen NEED_DEFINE_PCI_POOL if macro pci_pool absent in "$pcih"
+ # gen NEED_DEFINE_PCI_DMA_BIDIRECTIONAL if macro PCI_DMA_BIDIRECTIONAL absent in "$pcih" "$pdch"
+ # gen NEED_PCI_SRIOV_GET_TOTALVFS if fun pci_sriov_get_totalvfs absent in "$pcih"
+ # gen NEED_DEFINE_PCI_DEVID if macro PCI_DEVID absent in "$pcih"
+ # gen NEED_PCI_ENABLE_MSIX_RANGE if fun pci_enable_msix_range absent in "$pcih"
+ # gen HAVE_SRIOV_CONFIGURE if method sriov_configure of pci_driver in "$pcih"
+ # gen HAVE_PCI_DEV_FLAGS_ASSIGNED if enum pci_dev_flags matches PCI_DEV_FLAGS_ASSIGNED in "$pcih"
+ # gen NEED_PCI_VFS_ASSIGNED if fun pci_vfs_assigned absent in "$pcih"
+}
+
+function gen_limits() {
+ lih='include/linux/limits.h'
+ kh='include/linux/kernel.h'
+ gen NEED_DEFINE_U16_MAX if macro U16_MAX absent in "$lih" "$kh"
+ gen NEED_DEFINE_U32_MAX if macro U32_MAX absent in "$lih" "$kh"
+}
+
+function gen_skbuff() {
+ skbh='include/linux/skbuff.h'
+ gen HAVE_SKB_RECV_DATAGRAM_NOBLOCK if fun skb_recv_datagram matches 'int noblock' in "$skbh"
+ # gen NEED_PLT_HASH_TYPES if enum pkt_hash_types absent in "$skbh"
+ gen NEED_SKB_SET_HASH if fun skb_set_hash absent in "$skbh"
+ gen HAVE_SK_BUFF_ENCAPSULATION if struct sk_buff matches encapsulation in "$skbh"
+ gen NEED_SKB_FRAG_OFF_ADD if fun skb_frag_off_add absent in "$skbh"
+ gen HAVE_TYPEDEF_SKB_FRAG_T_BIOVEC if typedef skb_frag_t matches bio_vec in "$skbh"
+ gen HAVE_SKB_L4_RXHASH if struct sk_buff matches l4_rxhash in "$skbh"
+ # gen NEED_DEFINE_DEV_ALLOC_PAGES if macro dev_alloc_pages absent in "$skbh"
+ # gen NEED_DEFINE_DEV_ALLOC_PAGE if macro dev_alloc_page absent in "$skbh"
+ gen HAVE_SKBUFF_CSUM_LEVEL if struct sk_buff matches csum_level in "$skbh"
+ # gen NEED___SKB_PUT_DATA if fun __skb_put_data absent in "$skbh"
+}
+
+function gen_list() {
+ lh='include/linux/list.h'
+ gen NEED_DEFINE_LIST_FIRST_ENTRY_OR_NULL if macro list_first_entry_or_null absent in "$lh"
+ gen NEED_DEFINE_LIST_NEXT_ENTRY if macro list_next_entry absent in "$lh"
+ gen NEED_DEFINE_LIST_PREV_ENTRY if macro list_prev_entry absent in "$lh"
+}
+
+function gen_ether() {
+ edh='include/linux/etherdevice.h'
+ ieh='include/uapi/linux/if_ether.h'
+ gen HAVE_ETH_GET_HEADLEN_NET_DEVICE_ARG if fun eth_get_headlen matches 'struct net_device \\*' in "$edh"
+ gen HAVE_ETH_HW_ADDR_SET if fun eth_hw_addr_set in "$edh"
+ # gen HAVE_ETH_MAC_ADDR if fun eth_mac_addr in "$edh"
+ gen NEED_ETHER_ADDR_COPY if fun ether_addr_copy absent in "$edh"
+ gen HAVE_ETH_GET_HEADLEN_FUNC if fun eth_get_headlen in "$edh"
+ gen NEED_ETH_P_8021AD if macro ETH_P_8021AD absent in "$edh"
+ # gen NEED_ETHER_ZERO_ADDR if fun eth_zero_addr absent in "$edh"
+}
+
+function gen_mm() {
+ mm='include/linux/mm.h'
+ mmt='include/linux/mm_types.h'
+ gen HAVE_VM_FLAGS_SET if fun vm_flags_set in include/linux/mm.h
+ # gen HAVE_GET_USER_PAGES_GUP_FLAGS if fun get_user_pages matches gup_flags in "$mm"
+ # gen HAVE_GET_USER_PAGES_VMAS if fun get_user_pages matches vmas in "$mm"
+ # gen HAVE_GET_USER_PAGES_LONGTERM if fun get_user_pages_longterm in "$mm"
+ # gen HAVE_PINNED_VM_TYPE_ATOMIC64_T if struct mm_struct matches 'atomic64_t[ \t]*pinned_vm;' in "$mmt"
+ # gen HAVE_GET_USER_PAGES_8_PARAMS if fun get_user_pages countparam 8 in "$mm"
+}
+
+function gen_mmap_lock() {
+ mml='include/linux/mmap_lock.h'
+ # gen HAVE_MMAP_WRITE_LOCK if fun mmap_write_lock in "$mml"
+}
+
+function gen_time() {
+ tih='include/linux/time.h'
+ utih='include/uapi/linux/time.h'
+ tp32h='include/linux/timekeeping32.h'
+ # gen NEED_DO_GETTIMEOFDAY if fun do_gettimeofday absent in "$tih" "$tp32h"
+
+ NEED_STRUCT_TIMEVAL=0
+ if grep -q "^#ifndef __KERNEL__" "${KSRC%/}/$tih" || grep -q "^#ifndef __KERNEL__" "${KSRC%/}/$utih"; then
+ NEED_STRUCT_TIMEVAL=1
+ fi
+ # gen NEED_STRUCT_TIMEVAL if string "$NEED_STRUCT_TIMEVAL" equals 1
+}
+
+function gen_kobject() {
+ obh='include/linux/kobject.h'
+ gen HAVE_KOBJ_TYPE_DEFAULT_GROUPS if struct kobj_type matches 'const struct attribute_group \\*' in "$obh"
+ gen HAVE_KOBJ_TYPE_DEFAULT_ATTRS if struct kobj_type matches 'struct attribute \\*' in "$obh"
+}
+
+function gen_other() {
+ pciaerh='include/linux/aer.h'
+ ush='include/linux/u64_stats_sync.h'
+ gfp='include/linux/gfp.h'
+ # gen HAVE_PCI_ENABLE_PCIE_ERROR_REPORTING if fun pci_enable_pcie_error_reporting in "$pciaerh"
+ # gen HAVE_PCI_DISABLE_PCIE_ERROR_REPORTING if fun pci_disable_pcie_error_reporting in "$pciaerh"
+ # gen NEED_PCI_CLEANUP_AER_UNCORRECT_ERROR_STATUS if fun pci_cleanup_aer_uncorrect_error_status absent in "$pciaerh"
+ # gen HAVE_TIMER_SETUP if fun timer_setup in include/linux/timer.h
+ # gen NEED_TIMER_SETUP if fun timer_setup absent in include/linux/timer.h
+ gen NEED_PDE_DATA if fun PDE_DATA absent in include/linux/proc_fs.h
+ gen HAVE_PDE_DATA_LOWERCASE if fun pde_data in include/linux/proc_fs.h
+ # gen HAVE_PROC_OPS if struct proc_ops in include/linux/proc_fs.h
+ # gen NEED_PROC_OPS if struct proc_ops absent in include/linux/proc_fs.h
+ gen NEED_NETIF_F_SCTP_CRC if macro NETIF_F_SCTP_CRC absent in include/linux/netdev_features.h
+ # gen NEED_DEFINE_NETIF_F_GSO_UDP_TUNNEL_CSUM if macro NETIF_F_GSO_UDP_TUNNEL_CSUM absent in include/linux/netdev_features.h
+ gen HAVE_NETIF_F_RXHASH if macro NETIF_F_RXHASH in include/linux/netdev_features.h
+ gen HAVE_SOCK_CREATE_KERN_NET if fun sock_create_kern matches 'struct net \\*' in include/linux/net.h
+ gen HAVE_SK_DATE_READY_BYTES if method sk_data_ready of sock matches 'int bytes' in include/net/sock.h
+ gen HAVE_UDP_TUNNEL_NIC_INFO if struct udp_tunnel_nic_info in include/net/udp_tunnel.h
+ # gen HAVE_VLAN_FIND_DEV_DEEP_RCU if fun __vlan_find_dev_deep_rcu in include/linux/if_vlan.h
+ gen NEED_DEFINE_SKB_VLAN_TAG_PRESENT if macro skb_vlan_tag_present absent in include/linux/if_vlan.h
+ gen NEED___vlan_get_protocol if fun __vlan_get_protocol absent in include/linux/if_vlan.h
+ gen NEED_DEFINE_FIELD_SIZEOF if macro FIELD_SIZEOF absent in include/linux/kernel.h
+ # gen NEED_RTC_TIME_TO_TM if fun rtc_time_to_tm absent in include/linux/rtc.h
+ gen NEED_STRLCPY if fun strlcpy absent in include/linux/string.h
+ # gen NEED_CPUMASK_LOCAL_SPREAD if fun cpumask_local_spread absent in include/linux/cpumask.h
+ # gen HAVE_GENL_OPS_FIELD_VALIDATE if struct genl_ops matches validate in include/net/genetlink.h
+ # gen NEED_DEFINE_GET_DS if macro get_ds absent in include/asm-generic/uaccess.h
+ # gen NEED_BITMAP_ZALLOC if fun bitmap_zalloc absent in include/linux/bitmap.h
+ # gen HAVE_MACRO_VM_FAULT_T if typedef vm_fault_t in include/linux/mm_types.h
+ # gen NEED_CSUM_REPLACE_BY_DIFF if fun csum_replace_by_diff absent in include/net/checksum.h
+ # gen NEED_DEFINE_KFREE_RCU if macro kfree_rcu absent in include/linux/rcupdate.h
+ # gen NEED_DEFINE_U64_STATS_INIT if macro u64_stats_init absent in include/linux/u64_stats_sync.h
+ # gen NEED_DEFINE_BIT_ULL if macro BIT_ULL absent in include/linux/bitops.h include/linux/bits.h
+ gen NEED_DEFINE_DMA_RMB if macro dma_rmb absent in include/asm-generic/barrier.h
+ gen HAVE_XDP_SUPPORT if macro __LINUX_NET_XDP_H__ in include/net/xdp.h
+ # gen HAVE_XDP_FRAME_SZ if struct xdp_buff matches frame_sz in include/net/xdp.h
+ gen HAVE_XDP_DATA_META if fun xdp_set_data_meta_invalid in include/net/xdp.h
+ gen HAVE_XDP_RXQ_INFO_REG_NAPI_ID if fun xdp_rxq_info_reg matches napi_id in include/net/xdp.h
+ # only declared in some EulerOS version, like EulerV2R12, only used in SDI scenarios
+ # gen HAVE_KALLSYMS_LOOKUP_NAME_WRAP if fun kallsyms_lookup_name_wrap in include/linux/kallsyms.h
+ # gen NEED_KREF_READ if fun kref_read absent in include/linux/kref.h
+ # gen HAVE_BPF_TRACE_H if macro __LINUX_BPF_TRACE_H__ in include/linux/bpf_trace.h
+ gen HAVE_NETDEV_XDP_ACT_NDO_XMIT if enum netdev_xdp_act matches NETDEV_XDP_ACT_NDO_XMIT in include/uapi/linux/netdev.h
+ NEED_KMALLOC_ARRAY=0
+ if check fun kmalloc_array absent in include/linux/slab.h &&
+ check macro kmalloc_array absent in include/linux/slab.h; then
+ NEED_KMALLOC_ARRAY=1
+ fi
+ # gen NEED_KMALLOC_ARRAY if string "$NEED_KMALLOC_ARRAY" equals 1
+ gen HAVE_PAGE_POOL_SUPPORT if fun alloc_pages_bulk_array_node in "$gfp"
+
+ ppl1='include/net/page_pool.h'
+ ppl2='include/net/page_pool/types.h'
+ ppl3='include/net/page_pool/helpers.h'
+
+ if [[ -e "$ppl1" ]]; then
+ gen HAVE_PAGE_POOL_OLD if fun page_pool_alloc_frag in "$ppl1"
+ fi
+ if [[ -e "$ppl2" && -e "$ppl3" ]]; then
+ gen HAVE_PAGE_POOL_NEW if fun page_pool_alloc_frag in "$ppl2" "$ppl3"
+ fi
+
+ gen HAVE_PP_FLAG_PAGE_FRAG if macro PP_FLAG_PAGE_FRAG in "$ppl1" "$ppl2" "$ppl3"
+ gen HAVE_FLOW_ACTION_PRIORITY if enum flow_action_id matches FLOW_ACTION_PRIORITY in include/net/flow_offload.h
+
+ tinfo='arch/arm64/include/asm/thread_info.h'
+ processor='arch/x86/include/asm/processor.h'
+ uaccess='include/linux/uaccess.h'
+ gen HAVE_MM_SEGMENT_T if typedef mm_segment_t in "$tinfo" "$processor" "$uaccess"
+}
+
+function gen_symbol() {
+ module_symvers='Module.symvers'
+
+ # only used in SDI scenarios, some special OS which kernel version < 5.7 but have not
+ # exported function kallsyms_lookup_name
+ HAVE_KALLSYMS_LOOKUP_NAME_EXPORTED=0
+ if grep -q "kallsyms_lookup_name" "${KSRC%/}/$module_symvers"; then
+ HAVE_KALLSYMS_LOOKUP_NAME_EXPORTED=1
+ fi
+ # gen HAVE_KALLSYMS_LOOKUP_NAME_EXPORTED if string "$HAVE_KALLSYMS_LOOKUP_NAME_EXPORTED" equals 1
+}
+
+# all the generations, extracted from main() to keep normal code and various
+# prep separated
+function gen_all() {
+ gen_netdevice
+ # code above is covered by unit_tests/test_gold.sh
+ if [ -n "${JUST_UNIT_TESTING-}" ]; then
+ return
+ fi
+ gen_devres
+ gen_dma
+ gen_ethtool
+ gen_filter
+ gen_pci
+ gen_limits
+ gen_skbuff
+ gen_list
+ gen_ether
+ gen_mm
+ gen_mmap_lock
+ # gen_time
+ gen_other
+ #gen_symbol
+ gen_kobject
+}
+
+function gen_nic_kcompat() {
+ ready_gen
+ local out=$1
+ if ! [ -d "${KSRC-}" ]; then
+ echo >&2 "env KSRC=${KSRC-} does not exist or is not a directory"
+ exit 11
+ fi
+
+ # Assume KOBJ is the same as KSRC if not set.
+ if [ -z "${KOBJ-}" ]; then
+ KOBJ="${KSRC-}"
+ fi
+
+ # check if caller (like our makefile) wants to redirect output to file
+ if [ -n "${out-}" ]; then
+
+ # in case out exists, we don't want to overwrite it, instead
+ # write to a temporary copy.
+ if [ -s "${out}" ]; then
+ TMP_OUT="$(mktemp "${out}.XXX")"
+ trap "rm -f '${TMP_OUT}'" EXIT
+
+ REAL_OUT="${out}"
+ out="${TMP_OUT}"
+ fi
+
+ exec 3>&1
+ exec > "$out"
+ # all stdout goes to out since now
+ echo "/* uname=$(uname -r) Autogenerated for KSRC=${KSRC-} via $(basename "$0") */"
+ fi
+
+ cd "${KSRC}"
+
+
+ # check if KSRC was ok/if we are in proper place to look for headers
+ if [ ! -e include/linux/kernel.h ]; then
+ echo >&2 "seems that there are no kernel includes placed in KSRC=${KSRC}
+ pwd=$(pwd); ls -l:"
+ ls -l >&2
+ exit 8
+ fi
+
+ echo "#ifndef NIC_KCOMPAT_H"
+ echo "#define NIC_KCOMPAT_H"
+
+ set +x
+ gen_all
+ set -x
+
+ echo "#endif /* NIC_KCOMPAT_H */"
+ exec >&3
+ if [ -n "${out-}" ]; then
+ cd "$ORIG_CWD"
+
+ # Compare and see if anything changed. This avoids updating
+ # mtime of the file.
+ if [ -n "${REAL_OUT-}" ]; then
+ if cmp --silent "${REAL_OUT}" "${TMP_OUT}"; then
+ # exit now, skipping print of the output since
+ # there were no changes. the trap should
+ # cleanup TMP_OUT
+ return 0
+ fi
+
+ mv -f "${TMP_OUT}" "${REAL_OUT}"
+ out="${REAL_OUT}"
+ fi
+ fi
+ cat -n "$out" >&2
+}
+
+if [ "$1" = "--gen_nic_kcompat" ]; then
+ gen_nic_kcompat "$2"
+fi
\ No newline at end of file
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/roce/__init__.py b/drivers/net/ethernet/huawei/hinic5/build/host/linux/roce/__init__.py
new file mode 100755
index 000000000..cc0d19d0a
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/roce/__init__.py
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+# -*- encoding:utf-8 -*-
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
\ No newline at end of file
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/roce/build_roce.py b/drivers/net/ethernet/huawei/hinic5/build/host/linux/roce/build_roce.py
new file mode 100755
index 000000000..0c7041744
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/roce/build_roce.py
@@ -0,0 +1,567 @@
+#!/usr/bin/env python
+# -*- encoding:utf-8 -*-
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
+import os
+import re
+import sys
+import env
+import logging
+import shutil
+import glob
+import platform
+import subprocess
+import build_sdk
+import build_nic
+from pathlib import Path
+
+def run_shell_cmd(cmd, output=True):
+ rslt = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
+ if rslt.returncode:
+ logging.error(f"exec cmd fail:{' '.join(cmd)}. status = [{rslt.returncode}]. output:[{rslt.stdout}]")
+ return 1
+ if output:
+ logging.info(f"output = [{rslt.stdout}]")
+ return 0
+
+def copy_dir(source_dir, target_dir):
+ if not os.path.exists(target_dir):
+ os.makedirs(target_dir)
+ for root, dirs, files in os.walk(source_dir):
+ target_root = os.path.join(target_dir, os.path.relpath(root, source_dir))
+ for file in files:
+ source_file = os.path.join(root, file)
+ target_file = os.path.join(target_root, file)
+ shutil.copy(source_file, target_file)
+
+def get_roce_build_info(copy_dir):
+ cmd = ['cp', f'{env.hi1823_roce_knl_code_dir}/Makefile', f'{copy_dir}/Makefile_bak']
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ returncode = 0
+ while True:
+ cmd = ['sed', '-i', "/Makefile.ko$/d", f"{env.hi1823_roce_knl_code_dir}/Makefile"]
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ break
+
+ cmd = ['sed', '-i', "s/ifeq ($(KERNELRELEASE), )/ifneq ($(KERNELRELEASE), )/g", f"{env.hi1823_roce_knl_code_dir}/Makefile"]
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ break
+
+ cmd = ['make', '-C', env.hi1823_roce_knl_code_dir, 'build_info']
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ break
+
+ if True:
+ break
+
+ cmd = ['cp', f'{copy_dir}/Makefile_bak', f'{env.hi1823_roce_knl_code_dir}/Makefile']
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ os.remove(f'{copy_dir}/Makefile_bak')
+
+ return returncode
+
+def build_roce_knl_6_6_git_apply(is_reverse: bool = False):
+ project_name = "ChipSolution"
+ current_dir = os.getcwd()
+ project_dir = current_dir.split(project_name)[0] + project_name
+ file = "/etc/os-release"
+ with open(file, 'r') as f:
+ os_release_lines = f.readlines()
+ version_line = [os_release_line for os_release_line in os_release_lines if "VERSION_ID" in os_release_line]
+
+ version = int(version_line[0].split('"')[1].split(".")[0])
+ if version >= 22:
+ os.chdir(project_dir)
+ cmd = []
+ if is_reverse == True:
+ cmd = ["git", "apply", "--reverse", "build/host/linux/sdk/patch_code/knl6_6_compile.patch"]
+ else:
+ cmd = ["git", "apply", "build/host/linux/sdk/patch_code/knl6_6_compile.patch"]
+
+ subprocess.run(cmd, shell=False, check=True, capture_output=True)
+ os.chdir(current_dir)
+
+def build_roce_recurec_git_apply(is_reverse: bool = False):
+ project_name = "ChipSolution"
+ current_dir = os.getcwd()
+ project_dir = current_dir.split(project_name)[0] + project_name
+
+ os.chdir(project_dir)
+ cmd = []
+ if is_reverse == True:
+ cmd = ["git", "apply", "--reverse", "platform/huawei_secure_c/patch/adapt_implicit_fallthrough_level5.patch"]
+ else:
+ cmd = ["git", "apply", "platform/huawei_secure_c/patch/adapt_implicit_fallthrough_level5.patch"]
+
+ subprocess.run(cmd, shell=False, check=True, capture_output=True)
+ os.chdir(current_dir)
+
+def build_roce_kernel():
+ OFED_TYPE = "KERNEL"
+
+ cmd = ["kmod", "list"]
+ kmod_list = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
+ if 'hiroce5' in kmod_list.stdout:
+ cmd = ["sudo", "rmmod", "hiroce5"]
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ if 'hinic5' in kmod_list.stdout:
+ cmd = ["sudo", "rmmod", "hinic5"]
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ if not os.path.exists(f"{env.HI1823_TRUNK_DIR}/pangea"):
+ build_sdk.build_sdk()
+ build_nic.build_nic()
+
+ if not env.hi1823_driver_type:
+ ROCE_KRN_DRIVER_TYPE = "ROCE_STANDARD"
+ elif env.hi1823_driver_type == "ROCE_STANDARD_MLNX":
+ ROCE_KRN_DRIVER_TYPE = "ROCE_STANDARD"
+ OFED_TYPE = "MLNX_OFED"
+ else:
+ ROCE_KRN_DRIVER_TYPE = env.hi1823_driver_type
+
+ cmd = ["sh", "-x", f"{env.HI1823_BUILD_ROCE_DIR}/roce_kcompat_generator.sh", f"{env.hi1823_roce_knl_code_dir}/include", "", f"{OFED_TYPE}"]
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ cmd = ["cat", f"{env.hi1823_roce_knl_code_dir}/include/roce_kernel_compat_gen.h"]
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ logging.info("build roce clean")
+ cmd = ["make", "-C", env.hi1823_roce_knl_code_dir, "clean"]
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ if not env.hi1823_fc_os_release_type:
+ # build release version by default
+ ROCE_ENABLE_DEBUG = "OFF"
+ else:
+ if env.hi1823_fc_os_release_type == "RELEASE":
+ ROCE_ENABLE_DEBUG = "OFF"
+ elif env.hi1823_fc_os_release_type == "DEBUG":
+ ROCE_ENABLE_DEBUG = "ON"
+ else:
+ logging.error(f"unsupported fc os release type:{env.hi1823_fc_os_release_type}")
+ return 1
+
+ env.build_roce_mode = os.getenv("build_roce_mode")
+ if not env.build_roce_mode:
+ # not build hyper roce perftest by default
+ BUILD_HYPER_ROCE = "OFF"
+ else:
+ if env.build_roce_mode == "roce":
+ BUILD_HYPER_ROCE = "OFF"
+ elif env.build_roce_mode == "hyperroce":
+ BUILD_HYPER_ROCE = "ON"
+ else:
+ logging.error(f"unsupported perftest type:{env.build_roce_mode}")
+ return 1
+
+ logging.info("build roce kernel")
+ cmd = ['make', '-C', env.hi1823_roce_knl_code_dir, f'VERSION={ROCE_KRN_DRIVER_TYPE}', f'OFED_VERSION={OFED_TYPE}', f'ENABLE_DEBUG={ROCE_ENABLE_DEBUG}',
+ f'ENABLE_HYPER_ROCE={BUILD_HYPER_ROCE}', '-j', '16']
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ KRN_OUTPUT_DIR = f"{env.hi1823_bin_dir}/driver/linux/roce/{env.hi1823_os_release}/{ROCE_KRN_DRIVER_TYPE}/kernel"
+ if os.path.exists(KRN_OUTPUT_DIR):
+ shutil.rmtree(KRN_OUTPUT_DIR)
+ KRN_OUTPUT_DIR_WIETH_DGB = f"{KRN_OUTPUT_DIR}/debug"
+
+ os.makedirs(KRN_OUTPUT_DIR)
+ os.makedirs(KRN_OUTPUT_DIR_WIETH_DGB)
+
+ env.copy_file(f"{env.hi1823_roce_knl_code_dir}/hiroce5.ko", KRN_OUTPUT_DIR_WIETH_DGB)
+
+ cmd = ["strip", "-g", f"{env.hi1823_roce_knl_code_dir}/hiroce5.ko"]
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ env.copy_file(f"{env.hi1823_roce_knl_code_dir}/hiroce5.ko", KRN_OUTPUT_DIR)
+
+ # get build info
+ logging.info("build roce build_info")
+ returncode = get_roce_build_info(KRN_OUTPUT_DIR)
+ if returncode:
+ return returncode
+
+ cmd = ["sh", f"{env.HI1823_BUILD_LOG_PATH}/build_log.sh", f"{env.hi1823_roce_knl_code_dir}/build", KRN_OUTPUT_DIR, "hiroce5.ko"]
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ ret = env.collect_build_info(KRN_OUTPUT_DIR, f"{env.hi1823_bin_dir}/driver/linux/roce")
+ if ret:
+ return ret
+
+ env.copy_file(f"{env.hi1823_roce_knl_code_dir}/Module.symvers", env.hi1823_ci_lib_dir, "ROCE_Module.symvers")
+
+ cmd = ["make", "-C", env.hi1823_roce_knl_code_dir, "clean"]
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ return 0
+
+def build_huawei_securec():
+ os.chdir(f"{env.huawei_secure_code_dir}/src")
+
+ cmd = ["make", "clean"]
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ output_dir = f"{env.hi1823_ci_lib_dir}/huawei_securec/{env.hi1823_os_release}"
+ os.makedirs(output_dir, exist_ok=True)
+
+ cmd = ['make', '-C', f'{env.huawei_secure_code_dir}/src']
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ cmd = ['make', '-C', f'{env.huawei_secure_code_dir}/src', 'lib']
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ env.copy_file(f"{env.huawei_secure_code_dir}/lib/libsecurec.so", output_dir)
+
+ cmd = ["make", "clean"]
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ return 0
+
+def build_roce_user():
+ build_roce_knl_6_6_git_apply(is_reverse = True)
+
+ ret = build_huawei_securec()
+ if ret:
+ return ret
+
+ # Generating roce user compilation header file roce_kcompat.h
+ roce_usr_compat_generator_path = Path(f"{env.HI1823_BUILD_ROCE_DIR}/roce_user_compat_generator.sh").resolve()
+ roce_usr_kcompat_path = f"{env.hi1823_roce_usr_code_dir}/libhiroce-1.0.0/include/roce_user_kcompat.h"
+
+ top_dir = f"{env.HI1823_TRUNK_DIR}"
+ subprocess.run(
+ [
+ "bash", "-cx",
+ f"source {roce_usr_compat_generator_path} && gen_roce_user_kcompat '{roce_usr_kcompat_path}' '{top_dir}' "
+ ],
+ check=True
+ )
+
+ if not env.hi1823_driver_type:
+ ROCE_USR_DRIVER_TYPE = "ROCE_STANDARD"
+ elif env.hi1823_driver_type == "ROCE_STANDARD_MLNX":
+ ROCE_USR_DRIVER_TYPE = "ROCE_STANDARD"
+ else:
+ ROCE_USR_DRIVER_TYPE = env.hi1823_driver_type
+
+ # build so/a
+ ROCE_BUILD_DIR = f"{env.hi1823_roce_usr_code_dir}/build"
+ ROCE_OUTPUT_DIR = f"{env.hi1823_roce_usr_code_dir}/output"
+
+ ROCE_MODIFY_SRQ_SGE_EN = "on"
+
+ if not env.hi1823_fc_os_release_type:
+ # build release version by default
+ ROCE_ENABLE_DEBUG = "OFF"
+ else:
+ if env.hi1823_fc_os_release_type == "RELEASE":
+ ROCE_ENABLE_DEBUG = "OFF"
+ elif env.hi1823_fc_os_release_type == "DEBUG":
+ ROCE_ENABLE_DEBUG = "ON"
+ else:
+ logging.error(f"unsupported fc os release type:{env.hi1823_fc_os_release_type}")
+ return 1
+
+ env.build_roce_mode = os.getenv("build_roce_mode")
+ if not env.build_roce_mode:
+ # not build hyper roce perftest by default
+ BUILD_HYPER_ROCE = "OFF"
+ else:
+ if env.build_roce_mode == "roce":
+ BUILD_HYPER_ROCE = "OFF"
+ elif env.build_roce_mode == "hyperroce":
+ BUILD_HYPER_ROCE = "ON"
+ else:
+ logging.error(f"unsupported perftest type:{env.build_roce_mode}")
+ return 1
+
+ cmd = [
+ 'cmake',
+ f'-B{ROCE_BUILD_DIR}',
+ f'-DROOT_PROJECT_DIR={env.HI1823_TRUNK_DIR}',
+ f'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={ROCE_OUTPUT_DIR}',
+ f'-DTYPE={ROCE_USR_DRIVER_TYPE}',
+ f'-DROCE_MODIFY_SRQ_SGE_EN={ROCE_MODIFY_SRQ_SGE_EN}',
+ f'-DENABLE_DEBUG={ROCE_ENABLE_DEBUG}',
+ f'-DENABLE_HYPER_ROCE={BUILD_HYPER_ROCE}',
+ env.hi1823_roce_usr_code_dir
+ ]
+ returncode = run_shell_cmd(cmd, output=True)
+ if returncode:
+ return returncode
+
+ cmd = ['cmake', '--build', ROCE_BUILD_DIR, '--', '-j16']
+ returncode = run_shell_cmd(cmd, output=True)
+ if returncode:
+ return returncode
+
+ USR_OUTPUT_DIR = f"{env.hi1823_bin_dir}/driver/linux/roce/{env.hi1823_os_release}/{ROCE_USR_DRIVER_TYPE}/user"
+ if os.path.exists(USR_OUTPUT_DIR):
+ shutil.rmtree(USR_OUTPUT_DIR)
+
+ os.makedirs(USR_OUTPUT_DIR)
+
+ libh_list = glob.glob(f'{ROCE_OUTPUT_DIR}/libh*.so')
+ for item in libh_list:
+ try:
+ shutil.copy(item, USR_OUTPUT_DIR)
+ except Exception as e:
+ logging.error(f'copy {item} to {USR_OUTPUT_DIR} failed: {e}')
+ return 1
+
+ env.copy_file(f"{roce_usr_kcompat_path}", USR_OUTPUT_DIR)
+
+ # get build info
+ if 'CentOS' not in env.hi1823_os_release:
+ cmd = ["sh", f"{env.HI1823_BUILD_LOG_PATH}/build_log.sh", f"{env.hi1823_roce_usr_code_dir}/build", USR_OUTPUT_DIR, "libhrn5-rdmav34.so", "user"]
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ ret = env.collect_build_info(USR_OUTPUT_DIR, f"{env.hi1823_bin_dir}/driver/linux/roce", "user")
+ if ret:
+ return ret
+
+ build_roce_knl_6_6_git_apply()
+ logging.info("compile roce user complete.")
+
+ return 0
+
+def build_roce():
+ if not env.hi1823_os_release:
+ env.hi1823_os_release = platform.uname().release.replace('-', '_')
+ elif env.hi1823_os_release == "EULEROS_SERVER_V200R010C00SPC300B560":
+ env.hi1823_os_release = f"{env.hi1823_os_release}_{env.hi1823_os_arch}"
+
+ # kernel
+ ret = build_roce_kernel()
+ if ret:
+ return ret
+
+ return ret
+
+def collect_common_file(roce_rpm_type):
+ shutil.rmtree(env.HI1823_RPM_BUILD_DIR, ignore_errors=True)
+ cmd = ["mkdir", "-pv", "-m", "777", f"{env.HI1823_RPM_BUILD_DIR}/BUILD", f"{env.HI1823_RPM_BUILD_DIR}/BUILDROOT",
+ f"{env.HI1823_RPM_BUILD_DIR}/RPMS", f"{env.HI1823_RPM_BUILD_DIR}/SOURCES", f"{env.HI1823_RPM_BUILD_DIR}/SPECS",
+ f"{env.HI1823_RPM_BUILD_DIR}/SRPMS"]
+ returncode = run_shell_cmd(cmd)
+ if returncode:
+ return returncode
+
+ env.copy_file(f"{env.HI1823_TRUNK_DIR}/src/GLOBAL_VERSION_NEW", f"{env.HI1823_RPM_BUILD_DIR}/SOURCES")
+
+ src_build_dir = f"{env.HI1823_TRUNK_DIR}/build/host/linux/roce/hiroce_rpm_build"
+ env.copy_file_with_end(src_build_dir, f"{env.HI1823_RPM_BUILD_DIR}/SPECS", "spec")
+
+ returncode = copy_dir(src_build_dir, f'{env.HI1823_RPM_BUILD_DIR}/SOURCES')
+ if returncode:
+ return returncode
+
+ src_bin_dir = f"{env.hi1823_bin_dir}/driver/linux/roce/{env.hi1823_os_release}/{roce_rpm_type}"
+ env.copy_file_with_end(f"{src_bin_dir}/user", f"{env.HI1823_RPM_BUILD_DIR}/SOURCES", "so")
+ env.copy_file_with_end(f"{src_bin_dir}/kernel", f"{env.HI1823_RPM_BUILD_DIR}/SOURCES", "ko")
+
+ return 0
+
+def collect_vbs_extern_file(roce_rpm_type):
+ src_bin_dir = f"{env.hi1823_bin_dir}/driver/linux/roce/{env.hi1823_os_release}/{roce_rpm_type}"
+
+ returncode = copy_dir(f"{src_bin_dir}/hw_verbs_ext", f'{env.HI1823_RPM_BUILD_DIR}/SOURCES')
+ if returncode:
+ return returncode
+
+ returncode = copy_dir(f"{src_bin_dir}/hw_roce_ext", f'{env.HI1823_RPM_BUILD_DIR}/SOURCES')
+ if returncode:
+ return returncode
+
+ return 0
+
+def build_roce_rpm():
+ VBS_EXT = 0
+
+ if not env.hi1823_driver_type:
+ ROCE_RPM_TYPE = "ROCE_STANDARD"
+ elif env.hi1823_driver_type == "ROCE_VBS":
+ ROCE_RPM_TYPE = env.hi1823_driver_type
+ elif env.hi1823_driver_type == "CHIP_TEST" or env.hi1823_driver_type == "ROCE_COMPUTE":
+ ROCE_RPM_TYPE = env.hi1823_driver_type
+ elif env.hi1823_driver_type == "ROCE_VROCE":
+ ROCE_RPM_TYPE = env.hi1823_driver_type
+ else:
+ logging.error(f"not support rpm type: [{env.hi1823_driver_type}]")
+ return 1
+
+ ret = collect_common_file(ROCE_RPM_TYPE)
+ if ret:
+ return ret
+
+ os.chdir(f"{env.HI1823_RPM_BUILD_DIR}/SPECS")
+
+ cmd = [
+ "rpmbuild", "--define", f'_topdir {env.HI1823_RPM_BUILD_DIR}', '-bb', 'hiroce5.spec',
+ "--define", f'vbs_ext {VBS_EXT}'
+ ]
+ returncode = run_shell_cmd(cmd, output=False)
+ if returncode:
+ return returncode
+
+ src_dir = f"{env.HI1823_RPM_BUILD_DIR}/RPMS/{env.hi1823_os_arch}"
+ dst_dir = f"{env.hi1823_bin_dir}/driver/linux/roce/{env.hi1823_os_release}/{ROCE_RPM_TYPE}"
+ env.copy_file_with_end(src_dir, dst_dir, ".rpm")
+
+ return 0
+
+def build_roce_deb():
+ """基于1825 rpm配置变量生成deb包"""
+
+ # 确定ROCE_DEB_TYPE(参考rpm中的逻辑)
+ if not env.hi1823_driver_type:
+ ROCE_DEB_TYPE = "ROCE_STANDARD"
+ elif env.hi1823_driver_type == "ROCE_VBS":
+ ROCE_DEB_TYPE = env.hi1823_driver_type
+ elif env.hi1823_driver_type == "CHIP_TEST" or env.hi1823_driver_type == "ROCE_COMPUTE":
+ ROCE_DEB_TYPE = env.hi1823_driver_type
+ elif env.hi1823_driver_type == "ROCE_VROCE":
+ ROCE_DEB_TYPE = env.hi1823_driver_type
+ else:
+ logging.error(f"not support deb type: [{env.hi1823_driver_type}]")
+ return 1
+
+ # 设置输出目录
+ KRN_OUTPUT_DIR = f"{env.hi1823_bin_dir}/driver/linux/roce/{env.hi1823_os_release}/{ROCE_DEB_TYPE}/kernel"
+ USR_OUTPUT_DIR = f"{env.hi1823_bin_dir}/driver/linux/roce/{env.hi1823_os_release}/{ROCE_DEB_TYPE}/user"
+
+ # 检查支持的OS类型
+ if env.hi1823_os_type not in ["Ubuntu", "Linx"]:
+ logging.error(f"OS type {env.hi1823_os_type} not supported for deb packaging")
+ return 1
+
+ # 获取版本信息
+ version_var = ""
+ try:
+ with open(f"{env.HI1823_TRUNK_DIR}/src/GLOBAL_VERSION_NEW", 'r') as f:
+ for line in f:
+ if 'driver' in line:
+ version_var = line.split(':')[1].strip()
+ break
+ except Exception as e:
+ logging.error(f"Failed to read version file: {e}")
+ return 1
+
+ lower_os_type = env.hi1823_os_type.lower()
+ arch_dir = "arm64" if env.hi1823_os_arch == "aarch64" else "amd64"
+ lib_dir = "aarch64-linux-gnu" if env.hi1823_os_arch == "aarch64" else "x86_64-linux-gnu"
+
+ # 清理并创建构建目录
+ deb_build_base = f"{env.HI1823_BUILD_DIR}/host/linux/roce/hiroce_deb_build"
+ arch_build_dir = f"{deb_build_base}/{arch_dir}"
+
+ # 清理目录
+ shutil.rmtree(f"{arch_build_dir}/lib/modules", ignore_errors=True)
+
+ # 创建目录结构
+ dirs_to_create = [
+ f"{arch_build_dir}/lib/modules/{env.hi1823_complie_os_kver}/updates/hiroce5",
+ f"{arch_build_dir}/usr/lib/{lib_dir}",
+ f"{arch_build_dir}/etc/modules-load.d",
+ f"{arch_build_dir}/etc/libibverbs.d",
+ f"{arch_build_dir}/etc/logrotate.d"
+ ]
+
+ for directory in dirs_to_create:
+ os.makedirs(directory, exist_ok=True, mode=0o755)
+
+ # 复制内核模块
+ ko_src = f"{KRN_OUTPUT_DIR}/hiroce5.ko"
+ ko_dst = f"{arch_build_dir}/lib/modules/{env.hi1823_complie_os_kver}/updates/hiroce5/hiroce5.ko"
+ if not os.path.exists(ko_src):
+ logging.error(f"Kernel module not found: {ko_src}")
+ return 1
+ shutil.copy2(ko_src, ko_dst)
+
+ # 复制用户态库
+ for so_file in glob.glob(f"{USR_OUTPUT_DIR}/*.so"):
+ shutil.copy2(so_file, f"{arch_build_dir}/usr/lib/{lib_dir}/")
+
+ # 更新control文件版本
+ control_file = f"{arch_build_dir}/DEBIAN/control"
+ if os.path.exists(control_file):
+ with open(control_file, 'r') as f:
+ content = f.read()
+ content = re.sub(r'^Version:.*$', f'Version: {version_var}', content, flags=re.MULTILINE)
+ with open(control_file, 'w') as f:
+ f.write(content)
+
+ # 复制配置文件
+ config_files = {
+ "hrn5.driver": f"{arch_build_dir}/etc/libibverbs.d/",
+ "hiroce5-modules.conf": f"{arch_build_dir}/etc/modules-load.d/",
+ "libroce5": f"{arch_build_dir}/etc/logrotate.d/"
+ }
+
+ config_source_dir = f"{env.HI1823_BUILD_DIR}/host/linux/roce/hiroce_rpm_build"
+ for config_file, dest_dir in config_files.items():
+ src_path = f"{config_source_dir}/{config_file}"
+ if os.path.exists(src_path):
+ shutil.copy2(src_path, dest_dir)
+
+ # 设置DEBIAN目录权限
+ debian_dir = f"{arch_build_dir}/DEBIAN"
+ if os.path.exists(debian_dir):
+ for file in os.listdir(debian_dir):
+ file_path = os.path.join(debian_dir, file)
+ os.chmod(file_path, 0o775)
+
+ # 构建deb包
+ os.chdir(deb_build_base)
+ kver_underline = env.hi1823_complie_os_kver.replace('.', '_')
+ deb_name = f"hiroce5-{version_var}-{kver_underline}.{lower_os_type}.{env.hi1823_os_arch}.deb"
+
+ cmd = ["dpkg-deb", "--build", arch_dir, deb_name]
+ returncode = run_shell_cmd(cmd, output=False)
+ if returncode:
+ return returncode
+
+ # 移动deb包到输出目录
+ deb_src = f"{deb_build_base}/{deb_name}"
+ deb_dst = f"{KRN_OUTPUT_DIR}/{deb_name}"
+ shutil.move(deb_src, deb_dst)
+
+ logging.info(f"DEB package generated: {deb_dst}")
+ return 0
\ No newline at end of file
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/roce/roce_kcompat_generator.sh b/drivers/net/ethernet/huawei/hinic5/build/host/linux/roce/roce_kcompat_generator.sh
new file mode 100755
index 000000000..335cae74b
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/roce/roce_kcompat_generator.sh
@@ -0,0 +1,330 @@
+#!/bin/bash
+
+# SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB
+#!/bin/bash
+# Copyright(c) 2026 Huawei Technologies Co., Ltd
+
+# This file is used to automatically generate HAVE_ and NEED_ macros
+# for the current or incoming kernel.
+#
+# It is primarily implemented by invoking the 'gen' function in the kcompat-lib.sh file
+# (you can refer to the main part of 'gen_xx' for details).
+# The 'gen' tool can search for declarations of various types in kernel header files to generate macros.
+# For example, search for a function in a specified file and check whether the given function exists.
+# Please refer to the comments above the 'gen' function in kcompat-lib.sh.
+
+# End of intro.
+# The implementation is in kcompat-lib.sh, and below is an example of the 'gen' invocation.
+
+set -e
+
+export LC_ALL=C
+
+SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
+ORIG_CWD="$(pwd)"
+ROCE_INCLUDE_DIR=""
+KSRC=""
+OUT=""
+
+trap 'rc=$?; echo >&2 "$(realpath "$ORIG_CWD/${BASH_SOURCE[0]}"):$LINENO: failed with rc: $rc"' ERR
+
+# shellcheck source=kcompat-lib.sh
+if [[ -f "$SCRIPT_DIR/kcompat-lib.sh" ]]; then
+ source "$SCRIPT_DIR/kcompat-lib.sh"
+elif [[ -f "$SCRIPT_DIR/../kcompat-lib.sh" ]]; then
+ source "$SCRIPT_DIR/../kcompat-lib.sh"
+else
+ echo "Error: kcompat-lib.sh not found."
+ exit 1
+fi
+
+function ready_gen()
+{
+ if [ -z "$KSRC" ]; then
+ BUILD_KERNEL=$(uname -r)
+ if [ -e "/usr/src/kernels/linux-$BUILD_KERNEL/include/config" ]; then
+ KSRC="/usr/src/kernels/linux-$BUILD_KERNEL/"
+ elif [ -e "/usr/src/kernels/$BUILD_KERNEL/include/config" ]; then
+ KSRC="/usr/src/kernels/$BUILD_KERNEL/"
+ elif [ -e "/lib/modules/$BUILD_KERNEL/build/include/config" ]; then
+ KSRC="/lib/modules/$BUILD_KERNEL/build/"
+ fi
+ fi
+
+ if [ -z "$KSRC" ]; then
+ BUILD_KERNEL=$(uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/')
+ if [ -e "/usr/src/kernels/linux-$BUILD_KERNEL/include/config" ]; then
+ KSRC="/usr/src/kernels/linux-$BUILD_KERNEL/"
+ elif [ -e "/usr/src/kernels/$BUILD_KERNEL/include/config" ]; then
+ KSRC="/usr/src/kernels/$BUILD_KERNEL/"
+ elif [ -e "/lib/modules/$BUILD_KERNEL/build/include/config" ]; then
+ KSRC="/lib/modules/$BUILD_KERNEL/build/"
+ fi
+ fi
+
+ if [ -z "$KSRC" ]; then
+ echo "Invalid kernel src. Expected: $BUILD_KERNEL"
+ KSOURCES=$(ls -w 1 /usr/src/kernels/ ; ls -w 1 /lib/modules/)
+ echo "Found: $KSOURCES"
+ exit 1
+ fi
+
+ # Generate roce_kernel_compat_gen.h
+ GSRC=$KSRC
+ if [ ! -d "$KSRC/include/rdma" ]; then
+ echo "Detect other Debian/SLES include directory using KSRC..."
+ # detect other SLES include directory using KSRC
+ t=$(dirname $KSRC)/$(basename $KSRC)
+ if [ -L "$t" ]; then
+ # a symlink
+ t=$(readlink -f $t)
+ fi
+ # SLES
+ t=${t%-obj*}
+ # Debian
+ t=${t/-amd64/-common}
+ t=${t/-arm64/-common}
+ if [ -d "$t/include/rdma" ]; then
+ GSRC=$t
+ fi
+ fi
+
+ echo "KSRC: $KSRC"
+ echo "GSRC: $GSRC"
+
+ OUT=$ROCE_INCLUDE_DIR/roce_kernel_compat_gen.h KSRC=$GSRC QUIET_COMPAT=1
+}
+# DO NOT break gen calls below (via \), to make our compat code more grep-able,
+# keep them also grouped, first by feature (like DEVLINK), then by .h filename
+# finally, keep them sorted within a group (sort by flag name)
+
+# handy line of DOC copy-pasted form kcompat-lib.sh:
+# gen DEFINE if (KIND [METHOD of]) NAME [(matches|lacks) PATTERN|absent] in
+
+function gen_rdma_ib_umem() {
+ um='include/rdma/ib_umem.h'
+ kernel_um=$KSRC/include/rdma/ib_umem.h
+ gen HAVE_IB_UMEM_NUM_DMA_BLOCKS if fun ib_umem_num_dma_blocks in "$um"
+ gen HAVE_RDMA_UMEM_FOR_EACH_DMA_BLOCK if macro rdma_umem_for_each_dma_block in "$um"
+ gen IB_UMEM_HAVE_SG_APPEND_TABLE if struct ib_umem matches 'sg_append_table' in "$kernel_um"
+ gen UMEM_HAVE_PAGE_SHIFT if struct ib_umem matches 'int[ \t]*page_shift' in "$um"
+ gen IB_UMEM_GET_HAVE_IB_DEVICE if fun ib_umem_get matches 'struct ib_device \\*' in "$um"
+ gen IB_UMEM_GET_HAVE_IB_UCONTEXT if fun ib_umem_get matches 'struct ib_ucontext \\*' in "$um"
+ gen HAVE_IB_UMEM_PAGE_COUNT if fun ib_umem_page_count in "$um"
+ gen HAVE_IB_UMEM_NUM_PAGES if fun ib_umem_num_pages in "$um"
+
+ gen IB_UMEM_GET_PEER if fun ib_umem_get_peer in "$um"
+ gen IB_UMEM_GET_PEER_HAVE_IBDEVICE if fun ib_umem_get_peer matches 'struct ib_device \\*' in "$um"
+ gen IB_UMEM_NEED_IB_UMEM_FIND_BEST_PGSZ if fun ib_umem_find_best_pgsz absent in "$um"
+}
+
+function gen_rdma_ib_verbs() {
+ iv='include/rdma/ib_verbs.h'
+
+ gen IB_MODIFY_QP_IS_OK_HAVE_RDMA_LINK_LAYER if fun ib_modify_qp_is_ok matches 'enum rdma_link_layer' in "$iv"
+ gen HAVE_RDMA_AH_INIT_ATTR if struct rdma_ah_init_attr in "$iv"
+ gen IB_REG_DEV_HAVE_PORT_CALLBACK if fun ib_register_device matches 'int \\(\\*port_callback' in "$iv"
+ gen IB_REG_DEV_HAVE_NAME if fun ib_register_device matches 'char \\*name' in "$iv"
+ gen IB_REG_DEV_HAVE_DEVICE if fun ib_register_device matches 'struct device \\*' in "$iv"
+ gen IB_SRQ_HAVE_UOBJECT if struct ib_srq matches 'struct ib_uobject[ \t]*\\*'
+ gen IB_CQ_HAVE_UOBJECT if struct ib_cq matches 'struct ib_uobject[ \t]*\\*'
+ gen IB_DEV_HAVE_UVERBS_EX_CMD_MASK if struct ib_device matches 'uverbs_ex_cmd_mask' in "$iv"
+ gen IB_DEV_ATTR_HAVE_MAX_FMR if struct ib_device_attr matches 'max_fmr' in "$iv"
+ gen IB_DEV_ATTR_HAVE_MAX_MAP_PER_FMR if struct ib_device_attr matches 'max_map_per_fmr' in "$iv"
+ gen HAVE__IB_ALLOC_DEVICE if fun _ib_alloc_device in "$iv"
+ gen IB_WR_OPCODE_HAVE_BIND_MW if enum ib_wr_opcode matches IB_WR_BIND_MW in "$iv"
+ gen IB_QP_CREATE_FLAGS_HAVE_INTEGRITY_EN if enum ib_qp_create_flags matches IB_QP_CREATE_INTEGRITY_EN in "$iv"
+ gen HAVE_IB_DEVICE_OPS if struct ib_device_ops in "$iv"
+ gen ROCE_CREATE_QP_INT if method create_qp of ib_device_ops matches 'int[ \t]*\\(\\*' in "$iv"
+ gen ROCE_CREATE_QP_IB_QP if method create_qp of ib_device_ops matches 'struct ib_qp[ \t]*\\*\\(\\*' in "$iv"
+ gen IB_DEVICE_OPS_HAVE_CREATE_USER_AH if method create_user_ah of ib_device_ops in "$iv"
+ gen HAVE_ALL_ROCE_FUNCS_U8_PORT if method query_port of ib_device_ops matches 'u8 port_num' in "$iv"
+ gen HAVE_ALL_ROCE_FUNCS_U32_PORT if method query_port of ib_device_ops matches 'u32 port_num' in "$iv"
+ gen GET_LINK_LAYER_HAVE_U8_PORT if method get_link_layer of ib_device_ops matches 'u8 port_num' in "$iv"
+ gen GET_LINK_LAYER_HAVE_U32_PORT if method get_link_layer of ib_device_ops matches 'u32 port_num' in "$iv"
+ gen QUERY_GID_HAVE_U8_PORT if method query_gid of ib_device_ops matches 'u8 port_num' in "$iv"
+ gen QUERY_GID_HAVE_U32_PORT if method query_gid of ib_device_ops matches 'u32 port_num' in "$iv"
+ gen QUERY_PKEY_HAVE_U8_PORT if method query_pkey of ib_device_ops matches 'u8 port_num' in "$iv"
+ gen QUERY_PKEY_HAVE_U32_PORT if method query_pkey of ib_device_ops matches 'u32 port_num' in "$iv"
+ gen MODIFY_PORT_HAVE_U8_PORT if method modify_port of ib_device_ops matches 'u8 port_num' in "$iv"
+ gen MODIFY_PORT_HAVE_U32_PORT if method modify_port of ib_device_ops matches 'u32 port_num' in "$iv"
+ gen GET_PORT_IMMUTABLE_HAVE_U8_PORT if method get_port_immutable of ib_device_ops matches 'u8 port_num' in "$iv"
+ gen GET_PORT_IMMUTABLE_HAVE_U32_PORT if method get_port_immutable of ib_device_ops matches 'u32 port_num' in "$iv"
+ gen GET_NETDEV_HAVE_U8_PORT if method get_netdev of ib_device_ops matches 'u8 port_num' in "$iv"
+ gen GET_NETDEV_HAVE_U32_PORT if method get_netdev of ib_device_ops matches 'u32 port_num' in "$iv"
+ gen IB_DEVICE_OPS_HAVE_IB_QP_OBJ if struct ib_device_ops matches 'DECLARE_RDMA_OBJ_SIZE\\(ib_qp\\)' in "$iv"
+ gen HAVE_IB_DEVICE_LOCAL_DMA_LKEY if enum ib_device_cap_flags matches IB_DEVICE_LOCAL_DMA_LKEY in "$iv"
+ gen HAVE_IB_KERNEL_CAP_FLAGS if enum ib_kernel_cap_flags in "$iv"
+ gen IB_QUERY_PORT_HAVE_U8_PORT if fun ib_query_port matches 'u8 port_num' in "$iv"
+ gen IB_QUERY_PORT_HAVE_U32_PORT if fun ib_query_port matches 'u32 port_num' in "$iv"
+ gen IB_MR_TYPE_HAVE_USER if enum ib_mr_type matches IB_MR_TYPE_USER in "$iv"
+ gen IB_MR_TYPE_HAVE_INTEGRITY if enum ib_mr_type matches IB_MR_TYPE_INTEGRITY in "$iv"
+}
+
+function gen_rdma_ib_addr() {
+ ia='include/rdma/ib_addr.h'
+
+ gen RDMA_RESOLVE_IP_HAVE_GID_ATTR if fun rdma_resolve_ip matches 'bool resolve_by_gid_attr' in "$ia"
+}
+
+function gen_rdma_uverbs_ioctl() {
+ ui='include/rdma/uverbs_ioctl.h'
+
+ gen UVERBS_IOCTL_HAVE_RDMA_UDATA_TO_DRV_CONTEXT if macro rdma_udata_to_drv_context in "$ui"
+ gen UVERBS_IOCTL_HAVE_DECLARE_UVERBS_WRITE_EX if macro DECLARE_UVERBS_WRITE_EX in "$ui"
+}
+
+function gen_rdma_netlink() {
+ nl=$KSRC/include/net/netlink.h
+
+ gen NLA_POLICY_HAVE_MIN_MAX if struct nla_policy matches 's16 min, max' in "$nl"
+}
+
+function gen_rdma_mmu_notifier() {
+ # mlnx ofed defines MMU_INTERVAL_NOTIFIER based on the kernel mmu_notifier.h
+ mmu_notifier=${KSRC}/include/linux/mmu_notifier.h
+
+ gen MMU_INTERVAL_NOTIFIER if struct mmu_interval_notifier in "$mmu_notifier"
+}
+
+function gen_rdma_inetdevice() {
+ inetdev=$KSRC/include/linux/inetdevice.h
+ ndh='include/linux/netdevice.h'
+
+ gen INETDEV_HAVE_FOR_IFA if macro for_ifa in "$inetdev"
+
+ # exception centos7.9 x86 os
+ # (Un)registration functions for the notifiers that takes 'struct netdev_notifier_info *' as parameter in register_netdevice_notifier_rh
+ if [[ -z "${MLNX_OFED_DIR:-}" ]]; then
+ gen HAVE_REGISTER_NETDEVICE_NOTIFIER_RH if fun register_netdevice_notifier_rh in "$ndh"
+ fi
+}
+
+function gen_rdma_kobjtype() {
+ kobject=$KSRC/include/linux/kobject.h
+
+ gen KBOJ_TYPE_HAVE_ATTRS_GROUP if struct kobj_type matches 'const struct attribute_group \\*' in "$kobject"
+}
+
+function gen_rdma() {
+ # Distinguish the mlnx and native rdma-core packages that use the same image for Kylin V10SP3/SP2
+ if [[ -n "${MLNX_OFED_DIR:-}" && -d "$MLNX_OFED_DIR" ]]; then
+ cd $MLNX_OFED_DIR
+ else
+ cd .
+ fi
+
+ gen_rdma_ib_umem
+ gen_rdma_ib_verbs
+ gen_rdma_ib_addr
+ gen_rdma_uverbs_ioctl
+ gen_rdma_mmu_notifier
+ gen_rdma_inetdevice
+ gen_rdma_netlink
+ gen_rdma_kobjtype
+
+ cd - > /dev/null
+}
+
+# all the generations, extracted from main() to keep normal code and various
+# prep separated
+function gen_all() {
+ CHECK_DIR=(/opt/buildtools)
+ if [[ "$OFED_TYPE" == "MLNX_OFED" ]]; then
+ modfile=$(find ${CHECK_DIR[0]} -maxdepth 2 -name Module.symvers | grep mlnx-ofa_kernel)
+ if [ -n "$modfile" ] && [ -f "$modfile" ]; then
+ MLNX_OFED_DIR=$(dirname "$modfile")
+ fi
+ fi
+ gen_rdma
+}
+
+function gen_roce_kcompat() {
+ ready_gen
+ # check if caller (like our makefile) wants to redirect output to file
+ OUT_DEFINE=_ROCE_KCOMPAT_GEN_H_
+ if [ -n "${OUT-}" ]; then
+ OUT_DEFINE="$(basename $OUT .h)"
+ OUT_DEFINE="_${OUT_DEFINE^^}_H_"
+
+ # in case OUT exists, we don't want to overwrite it, instead
+ # write to a temporary copy.
+ if [ -s "$OUT" ]; then
+ TMP_OUT="$(mktemp "$OUT.XXX")"
+ trap "rm -f '$TMP_OUT'" EXIT
+
+ REAL_OUT="$OUT"
+ OUT="$TMP_OUT"
+ fi
+
+ ls -l $ROCE_INCLUDE_DIR
+ exec > "$OUT"
+ # all stdout goes to OUT since now
+ echo "/* Autogenerated for KSRC=${KSRC-} via $(basename "$0") */"
+ fi
+ if [ -d "${KSRC-}" ]; then
+ cd $KSRC
+ fi
+
+ # check if KSRC was ok/if we are in proper place to look for headers
+ if [ ! -e include/linux/kernel.h ]; then
+ echo >&2 "seems that there are no kernel includes placed in KSRC=$KSRC
+ pwd=$(pwd); ls -l:"
+ ls -l >&2
+ exit 8
+ fi
+
+ echo "#ifndef $OUT_DEFINE"
+ echo "#define $OUT_DEFINE"
+ gen_all
+ echo "#endif /* $OUT_DEFINE */"
+
+ if [ -n "${OUT-}" ]; then
+ cd "$ORIG_CWD"
+
+ # Compare and see if anything changed. This avoids updating
+ # mtime of the file.
+ if [ -n "${REAL_OUT-}" ]; then
+ if cmp --silent "$REAL_OUT" "$TMP_OUT"; then
+ # exit now, skipping print of the output since
+ # there were no changes. the trap should
+ # cleanup TMP_OUT
+ exit 0
+ fi
+
+ mv -f "$TMP_OUT" "$REAL_OUT"
+ OUT="$REAL_OUT"
+ fi
+
+ # dump output, will be visible in CI
+ if [ -n "${JUST_UNIT_TESTING-}${QUIET_COMPAT-}" ]; then
+ return
+ fi
+ cat -n "$OUT" >&2
+ fi
+}
+
+if [[ -z ${1:-} ]]; then
+ echo "Not set roce kernel source path"
+ exit 1
+fi
+
+ROCE_INCLUDE_DIR=$1
+
+if [[ -n "$2" ]]; then
+ KSRC="$2"
+fi
+
+if [ "$CONFIG_UB_UNIFIED_UBUS" = "y" ]; then
+ KSRC=$UBUS_BUILD_KERNEL_DIR
+fi
+
+if [[ -n "$3" ]]; then
+ OFED_TYPE="$3"
+fi
+
+gen_roce_kcompat
+if [ $? -ne 0 ]; then
+ echo "Failed to generate $ROCE_INCLUDE_DIR/roce_kernel_compat_gen.h"
+ exit 1
+fi
\ No newline at end of file
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/sdk/__init__.py b/drivers/net/ethernet/huawei/hinic5/build/host/linux/sdk/__init__.py
new file mode 100755
index 000000000..cc0d19d0a
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/sdk/__init__.py
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+# -*- encoding:utf-8 -*-
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
\ No newline at end of file
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/sdk/build_sdk.py b/drivers/net/ethernet/huawei/hinic5/build/host/linux/sdk/build_sdk.py
new file mode 100755
index 000000000..652894f23
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/sdk/build_sdk.py
@@ -0,0 +1,207 @@
+#!/usr/bin/env python
+# -*- encoding:utf-8 -*-
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
+import os
+import re
+import sys
+import env
+import logging
+import shutil
+import subprocess
+from build_util import do_cmd, do_make, do_make_clean, rpm_build
+
+SDK_RPM_BUILD_DIR = f'{env.HI1823_BUILD_DIR}/host/linux/sdk/sdk_rpm_build/'
+
+
+def save_output(path):
+ shutil.rmtree(path, ignore_errors=True)
+ os.makedirs(path, exist_ok=True)
+ env.copy_file(f"{env.HI1823_LLD_CODE_DIR}/hisdk5.ko", path)
+
+ # get build info
+ cmd = ["sh", f"{env.HI1823_BUILD_LOG_PATH}/build_log.sh", f"{env.HI1823_LLD_CODE_DIR}/build", path, "hisdk5.ko"]
+ do_cmd(*cmd)
+
+ ret = env.collect_build_info(path, f"{env.hi1823_bin_dir}/driver/linux/sdk")
+ if ret:
+ raise Exception('env.collect_build_info failed')
+
+ # strip debug info of ko for release rpm or deb package
+ cmd = ["strip", "--strip-debug", f"{path}/hisdk5.ko", "-o", f"{path}/hisdk5_tmp.ko"]
+ do_cmd(*cmd)
+
+
+def build_clean():
+ module_file = f"{env.hi1823_ci_lib_dir}/SDK_Module.symvers"
+ if os.path.isfile(module_file):
+ os.remove(module_file)
+ env.copy_file(f"{env.HI1823_LLD_CODE_DIR}/Module.symvers", env.hi1823_ci_lib_dir, "SDK_Module.symvers")
+
+ # make clean
+ do_make_clean(workdir=env.HI1823_LLD_CODE_DIR)
+
+ cmd = ["find", f"{env.HI1823_TRUNK_DIR}/src/dpu_platform_library/host/sdk/knldk",
+ "-name", "*.o", "-o", "-name", "*.cmd", "-o", "-name", "*.mod"]
+ result = do_cmd(*cmd)
+ do_cmd('xargs', 'rm', '-f', input=result.stdout)
+
+ cmd = ["find", f"{env.HI1823_TRUNK_DIR}/src/dpu_platform_library/host/sdk/ossl",
+ "-name", "*.o", "-o", "-name", "*.cmd"]
+ result = do_cmd(*cmd)
+ do_cmd('xargs', 'rm', '-f', input=result.stdout)
+
+
+def build_deb_package(arch):
+ workdir = f'{env.HI1823_BUILD_DIR}/host/linux/sdk/sdk_deb_build/'
+ kernel_release = env.hi1823_complie_os_kver
+ driver_version = env.get_global_version('driver')
+
+ if arch == "x86_64":
+ distname = "amd64"
+ else:
+ distname = "arm64"
+
+ distdir = f'{workdir}/{distname}'
+ modules_dir = f"{distdir}/lib/modules/"
+ modules_load_dir = f"{distdir}/lib/modules-load.d/"
+ ko_dir = f'{modules_dir}/{kernel_release}/updates/hisdk5/'
+
+ shutil.rmtree(modules_dir, ignore_errors=True)
+ os.makedirs(ko_dir)
+
+ # prepare hisdk5
+ sdk_output = env.get_driver_output_path('sdk')
+ shutil.move(f'{sdk_output}/hisdk5_tmp.ko', f'{ko_dir}/hisdk5.ko')
+ env.copy_file(f"{workdir}/hisdk5-modules.conf", modules_load_dir)
+
+ do_cmd('sed', '-i', f'/^Version/c Version: {driver_version}', f'{distdir}/DEBIAN/control')
+ do_cmd('chmod', '-R', '775', f'{distdir}/DEBIAN/')
+
+ # build deb
+ deb_file = f"hisdk5-{driver_version}-{env.hi1823_complie_os_kver_underline}.{arch}.deb"
+ cmd = ["dpkg", "-b", distname, deb_file]
+ do_cmd(*cmd, cwd=workdir)
+
+ shutil.move(f'{workdir}/{deb_file}', sdk_output)
+
+
+def get_rpm_spec(os_type, arch):
+ if os_type == 'UVP':
+ spec = 'hisdk5_uvp.spec'
+ else:
+ spec = 'hisdk5.spec'
+ return spec
+
+
+def build_rpm_package(arch):
+ os_type = env.hi1823_os_type
+ workdir = env.HI1823_RPM_BUILD_DIR
+
+ shutil.rmtree(workdir, ignore_errors=True)
+ cmd = [
+ 'mkdir', '-pv', '-m', '777',
+ f'{workdir}/BUILD',
+ f'{workdir}/BUILDROOT',
+ f'{workdir}/RPMS',
+ f'{workdir}/SOURCES',
+ f'{workdir}/SPECS',
+ f'{workdir}/SRPMS'
+ ]
+ do_cmd(*cmd)
+
+ env.copy_file(f'{env.HI1823_TRUNK_DIR}/src/GLOBAL_VERSION_NEW', f'{workdir}/SOURCES')
+
+ # prepare hisdk5
+ sdk_output = env.get_driver_output_path('sdk')
+
+ shutil.move(f'{sdk_output}/hisdk5_tmp.ko', f'{workdir}/SOURCES/hisdk5.ko')
+ env.copy_file(f'{SDK_RPM_BUILD_DIR}/hisdk5-modules.conf', f'{workdir}/SOURCES')
+
+ # prepare OS
+ if os_type == 'UVP':
+ env.copy_file(f'{SDK_RPM_BUILD_DIR}hisdk5-dracut.conf', f'{workdir}/SOURCES')
+
+ # prepare rpm spec
+ spec = get_rpm_spec(os_type, arch)
+ if not spec:
+ raise Exception(f'no spec to build rpm. OS type {os_type}, arch {arch}')
+ env.copy_file(f'{SDK_RPM_BUILD_DIR}/{spec}', f'{workdir}/SPECS')
+
+ # build rpm
+ rpm_build(workdir=workdir, spec=spec, arch=arch)
+
+ # copy rpm to output dir
+ rpm_dir = f'{workdir}/RPMS/{arch}'
+ env.copy_file_with_end(rpm_dir, sdk_output, ".rpm")
+
+
+def build_package(pkg_type, arch):
+ if pkg_type == "rpm":
+ return build_rpm_package(arch=arch)
+ if pkg_type == "deb":
+ return build_deb_package(arch=arch)
+ raise Exception(f'unknown package manager type {pkg_type}')
+
+
+def build_sdk_rpm_deb():
+ try:
+ build_package(
+ pkg_type=env.hi1823_os_pkg_mgr,
+ arch=env.hi1823_os_arch,
+ )
+ return 0
+ except Exception as e:
+ logging.exception(f'build package failed')
+ return 1
+
+def sdk_dfx_ko_build(workdir, outdir, solo=False):
+ logging.info(f'\n{"↓" * 60} Build SDK DFX ko {"↓" * 60}')
+
+ mod_name = 'hidfx3'
+ make_args = []
+ if solo:
+ logging.info(f'solo dfx driver : {solo}')
+ mod_name = 'hidfx3solo'
+ make_args = ['CONFIG_DFX_SOLO=y']
+
+ try:
+ do_make_clean(workdir)
+ do_make(*make_args, workdir=workdir)
+
+ # save output
+ env.copy_file(f"{workdir}/{mod_name}.ko", outdir)
+ do_cmd("strip", "--strip-debug", f"{outdir}/{mod_name}.ko", "-o", f"{outdir}/{mod_name}.strip.ko")
+
+ do_make_clean(workdir)
+ logging.info(f'Build SDK DFX ko success')
+ except Exception as e:
+ logging.error(f'Build SDK DFX ko failed: {e}')
+ raise
+ finally:
+ logging.info(f'\n{"↑" * 60} Build SDK DFX ko {"↑" * 60}')
+
+def build_sdk_ko():
+ srcdir = env.HI1823_LLD_CODE_DIR
+ outdir = env.get_driver_output_path('sdk')
+ sdk_dfx_dir = f'{env.HI1823_TRUNK_DIR}/tools/dfx_driver/src'
+
+ try:
+ # make
+ do_make_clean(workdir=srcdir)
+ do_make(workdir=srcdir)
+
+ save_output(outdir)
+ build_clean()
+
+ # build hidfx3.ko
+ if os.getenv('BUILD_SDK_DFX') == 'y':
+ sdk_dfx_ko_build(sdk_dfx_dir, outdir)
+ sdk_dfx_ko_build(sdk_dfx_dir, outdir, solo=True)
+ return 0
+ except Exception as e:
+ logging.exception(f'build ko failed')
+ return 1
+
+
+def build_sdk():
+ return build_sdk_ko()
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/sdk/sdk-kcompat-generator.sh b/drivers/net/ethernet/huawei/hinic5/build/host/linux/sdk/sdk-kcompat-generator.sh
new file mode 100755
index 000000000..e2fbd51d9
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/sdk/sdk-kcompat-generator.sh
@@ -0,0 +1,308 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright(c) 2025 Huawei Technologies Co., Ltd
+
+# This file is used to automatically generate HAVE_ and NEED_ macros
+# for the current or incoming kernel.
+#
+# It is primarily implemented by invoking the 'gen' function in the kcompat-lib.sh file
+# (you can refer to the main part of 'gen_xx' for details).
+# The 'gen' tool can search for declarations of various types in kernel header files to generate macros.
+# For example, search for a function in a specified file and check whether the given function exists.
+# Please refer to the comments above the 'gen' function in kcompat-lib.sh.
+
+# End of intro.
+# The implementation is in kcompat-lib.sh, and below is an example of the 'gen' invocation.
+
+set -e
+
+echo "curr bash script file name: $(basename "${BASH_SOURCE[0]}")"
+export LC_ALL=C
+SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
+ORIG_CWD="$(pwd)"
+trap 'rc=$?; echo >&2 "$(realpath "$ORIG_CWD/${BASH_SOURCE[0]}"):$LINENO: failed with rc: $rc"' ERR
+
+# shellcheck source=kcompat-lib.sh
+CURR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+KCOMPAT_LIB="${CURR_DIR}/../kcompat-lib.sh"
+
+if [ -f "$KCOMPAT_LIB" ]; then
+ echo "$KCOMPAT_LIB file is exist"
+else
+ echo "$KCOMPAT_LIB file is not exist"
+fi
+source "$KCOMPAT_LIB"
+
+ARCH=$(uname -m)
+IS_ARM=""
+if [ "$ARCH" == aarch64 ]; then
+ IS_ARM=1
+fi
+
+function ready_gen()
+{
+ KERN_VER=$(uname -r)
+ KSRC=""
+
+ if [ -e /usr/src/kernels/linux-"$KERN_VER"/include/config ]; then
+ KSRC="/usr/src/kernels/linux-"$KERN_VER"/"
+ elif [ -e /usr/src/kernels/"$KERN_VER"/include/config ]; then
+ KSRC="/usr/src/kernels/"$KERN_VER"/"
+ elif [ -e /lib/modules/"$KERN_VER"/build/include/config ]; then
+ KSRC="/lib/modules/"$KERN_VER"/build/"
+ fi
+
+ if [ -z "$KSRC" ]; then
+ KERN_VER=$(uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/')
+ if [ -e /usr/src/kernels/linux-"$KERN_VER"/include/config ]; then
+ KSRC="/usr/src/kernels/linux-"$KERN_VER"/"
+ elif [ -e /usr/src/kernels/"$KERN_VER"/include/config ]; then
+ KSRC="/usr/src/kernels/"$KERN_VER"/"
+ elif [ -e /lib/modules/"$KERN_VER"/build/include/config ]; then
+ KSRC="/lib/modules/"$KERN_VER"/build/"
+ fi
+ fi
+
+ if [ -z "$KSRC" ]; then
+ echo "Invalid kernel src. Expected: ${KERN_VER}"
+ echo "Please check if kernel-devel(for other OS) or linux-headers(for debian) installed"
+ KSOURCES=$(ls -w 1 /usr/src/kernels/ ; ls -w 1 /lib/modules/)
+ echo "Found: ${KSOURCES}"
+ exit 1
+ fi
+ KOBJ=$KSRC
+
+ if [ ! -d "${KSRC}"/include/linux ]; then
+ echo "Detect other Debian/SLES include directory using KSRC..."
+ # detect other SLES include directory using KSRC
+ t=$(dirname "$KSRC")/$(basename "$KSRC")
+ if [ -L "$t" ]; then
+ # a symlink
+ t=$(readlink -f $t)
+ fi
+ # SLES
+ t=${t%-obj*}
+ # LinxOS
+ t=${t/-linx-security-arm64/-common-linx-security}
+ # Debian
+ t=${t/-amd64/-common}
+ t=${t/-arm64/-common}
+ if [ -d "${t}"/include/linux ]; then
+ KSRC=$t
+ fi
+ fi
+
+ if [ -d "$1" ]; then
+ KSRC=$1
+ # 目前build_cache里的内核是6.6的,KERNEL_VER不影响功能,暂时写死
+ KERN_VER="6.6.0-132.0.0.111.oe2403sp3.aarch64"
+ fi
+ echo "sdk-kcompat-generator.sh -> KERN_VER: ${KERN_VER}"
+ echo "sdk-kcompat-generator.sh -> KSRC: ${KSRC}"
+ export KSRC KOBJ
+}
+
+# 解决在linux 内核头文件中未定义的语法说明
+#eg. gen DEFINE if [fun|enum|struct|macro|typedef|symbol] NAME (absent) in
+# 解决在linux 内核头文件中有多种格式定义的语法说明
+# matches PATTERN:定义中存在这个字符pattern. lacks PATTERN:定义中存在这个字符pattern: 定义中没有这个pattern
+#eg. gen DEFINE if [fun|enum|struct|macro|typedef|symbol] NAME [matches|lacks] PATTERN in
+function gen_pci() {
+ pci_h='include/linux/pci.h'
+ pdc_h='include/linux/pci-dma-compat.h'
+
+ gen NEED_PCI_DOMAIN_NR if fun pci_domain_nr absent in "$pci_h"
+ gen NEED_DEFINE_PCI_DMA_COMPAT if macro PCI_DMA_BIDIRECTIONAL absent in "$pdc_h"
+ gen HAVE_PCIE_RESET_DONE if struct pci_error_handlers matches reset_done in "$pci_h"
+ gen NEED_PCI_SRIOV_GET_TOTALVFS if fun pci_sriov_get_totalvfs absent in "$pci_h"
+}
+
+function gen_sysfs() {
+ sysfs_h='include/linux/sysfs.h'
+
+ gen NEED_PDE_DATA if fun PDE_DATA absent in include/linux/proc_fs.h
+ gen HAVE_PDE_DATA_LOWERCASE if fun pde_data in include/linux/proc_fs.h
+ gen NEED_SYSFS_EMIT if fun sysfs_emit absent in "$sysfs_h"
+}
+
+function gen_ptp_clock_kernel() {
+ ptp_clock_kernel_h='include/linux/ptp_clock_kernel.h'
+
+ gen NEED_PTP_ADJUST_BY_SCALED_PPM if fun adjust_by_scaled_ppm absent in "$ptp_clock_kernel_h"
+}
+
+function gen_math64() {
+ math64_h='include/linux/math64.h'
+
+ gen NEED_MATH64_MUL_U64_U64_DIV_U64 if fun mul5_u64_u64_div_u64 absent in "$math64_h"
+}
+
+function gen_timer() {
+ timer_h='include/linux/timer.h'
+
+ gen HAVE_TIMER_SETUP if fun timer_setup in "$timer_h"
+}
+
+function gen_cpumask() {
+ cpumask_h='include/linux/cpumask.h'
+
+ gen NEED_CPUMASK_LOCAL_SPREAD if fun cpumask_local_spread absent in "$cpumask_h"
+}
+
+function gen_etherdevice() {
+ etherdevice_h='include/linux/etherdevice.h'
+
+ gen HAVE_ETH_HW_ADDR_SET if fun eth_hw_addr_set in "$etherdevice_h"
+ gen NEED_ETH_ZERO_ADDR if fun eth_zero_addr absent in "$etherdevice_h"
+}
+
+function gen_devlink() {
+ devlink_h='include/net/devlink.h'
+ gen HAVE_DEVLINK_H if macro _NET_DEVLINK_H_ in "$devlink_h"
+
+ gen HAVE_DEVLINK_FLASH_UPDATE_METHOD if struct devlink_ops matches flash_update in "$devlink_h"
+ gen HAVE_DEVLINK_FLASH_UPDATE_BEGIN_END_NOTIFY if fun devlink_flash_update_begin_notify in "$devlink_h"
+ gen HAVE_DEVLINK_FLASH_UPDATE_PARAMS_FW if struct devlink_flash_update_params matches 'struct firmware \\*fw' in "$devlink_h"
+ gen HAVE_DEVLINK_FLASH_UPDATE_PARAMS_FILE_NAME if struct devlink_flash_update_params matches file_name in "$devlink_h"
+ gen HAVE_DEVLINK_OPS_FLASH_UPDATE_HAVE_PARAMS if method flash_update of devlink_ops matches devlink_flash_update_params in "$devlink_h"
+
+ gen HAVE_DEVLINK_PARAMS_PUBLISH if fun devlink_params_publish in "$devlink_h"
+ gen HAVE_DEVLINK_PARAMS_UNPUBLISH if fun devlink_params_unpublish in "$devlink_h"
+
+ gen HAVE_DEVLINK_ALLOC_SET_DEV if fun devlink_alloc matches 'struct device' in "$devlink_h"
+ gen HAVE_DEVLINK_ALLOC if fun devlink_alloc in "$devlink_h"
+
+ gen HAVE_DEVLINK_REGISTER if fun devlink_register in "$devlink_h"
+ gen HAVE_DEVLINK_REGISTER_SET_DEV if fun devlink_register matches 'struct device' in "$devlink_h"
+ gen HAVE_DEVLINK_REGISTER_HAVE_RET if fun devlink_register matches 'int devlink_register' in "$devlink_h"
+
+ gen HAVE_DEVLINK_PARAM_SET_EXTACK if method set of devlink_param matches 'struct netlink_ext_ack' in "$devlink_h"
+}
+
+function gen_uaccess() {
+ uaccess_h='include/linux/uaccess.h'
+ asm_generic_uaccess_h='include/asm-generic/uaccess.h'
+
+ gen NEED_FORCE_UACCESS_BEGIN if fun force_uaccess_begin absent in "$uaccess_h"
+ gen NEED_FORCE_UACCESS_END if fun force_uaccess_end absent in "$uaccess_h"
+ gen NEED_GET_FS if macro get_fs absent in "$asm_generic_uaccess_h"
+ gen NEED_SET_FS if fun set_fs absent in "$asm_generic_uaccess_h"
+}
+
+function gen_aer() {
+ aer_h='include/linux/aer.h'
+
+ gen NEED_PCI_ENABLE_PCIE_ERROR_REPORTING if fun pci_enable_pcie_error_reporting absent in "$aer_h"
+ gen NEED_PCI_DISABLE_PCIE_ERROR_REPORTING if fun pci_disable_pcie_error_reporting absent in "$aer_h"
+}
+
+function gen_gnss() {
+ class_h='include/linux/device/class.h'
+ device_h='include/linux/device.h'
+ class2_h='include/linux/class.h'
+
+ gen HAVE_DEVNODE_CONST_DEV if method devnode of class matches '(const|RH_KABI_CONST) struct device' in "$class_h" "$device_h" "$class2_h"
+
+ NEED_CLASS_CREATE=0
+ if check fun class_create matches 'owner' in "$class_h" "$device_h" "$class2_h" ||
+ check macro class_create matches 'owner' in "$class_h" "$device_h" "$class2_h" ; then
+ NEED_CLASS_CREATE=1
+ fi
+ gen HAVE_CLASS_CREATE_OWNER if string "$NEED_CLASS_CREATE" equals 1
+
+}
+
+# all the generations, extracted from main() to keep normal code and various
+# prep separated
+function gen_all() {
+ gen_pci
+ gen_sysfs
+ gen_ptp_clock_kernel
+ gen_math64
+ gen_timer
+ gen_cpumask
+ gen_etherdevice
+ gen_devlink
+ gen_uaccess
+ gen_aer
+ gen_gnss
+}
+
+function gen_sdk_kcompat() {
+ local ubus_build_kernel_dir=$2
+
+ echo >&2 "gen_sdk_kcompat ubus_build_kernel_dir=${ubus_build_kernel_dir}"
+ if [ -d "$ubus_build_kernel_dir" ]; then
+ ready_gen "$ubus_build_kernel_dir"
+ else
+ ready_gen
+ fi
+
+ local out=$1
+ if ! [ -d "${KSRC-}" ]; then
+ echo >&2 "env KSRC=${KSRC-} does not exist or is not a directory"
+ exit 11
+ fi
+
+ # check if caller (like our makefile) wants to redirect output to file
+ if [ -n "${out-}" ]; then
+
+ # in case out exists, we don't want to overwrite it, instead
+ # write to a temporary copy.
+ if [ -s "${out}" ]; then
+ TMP_OUT="$(mktemp "${out}.XXX")"
+ trap "rm -f '${TMP_OUT}'" EXIT
+
+ REAL_OUT="${out}"
+ out="${TMP_OUT}"
+ fi
+
+ exec 3>&1
+ exec > "$out"
+ # all stdout goes to out since now
+ echo "/* uname=$(uname -r) Autogenerated for KSRC=${KSRC-} via $(basename "$0") */"
+ fi
+
+ cd "${KSRC}"
+
+
+ # check if KSRC was ok/if we are in proper place to look for headers
+ if [ ! -e include/linux/kernel.h ]; then
+ echo >&2 "seems that there are no kernel includes placed in KSRC=${KSRC}
+ pwd=$(pwd); ls -l:"
+ ls -l >&2
+ exit 8
+ fi
+
+ echo "#ifndef SDK_KCOMPAT_H"
+ echo "#define SDK_KCOMPAT_H"
+
+ set +x
+ gen_all
+ set -x
+
+ echo "#endif /* SDK_KCOMPAT_H */"
+ exec >&3
+ if [ -n "${out-}" ]; then
+ cd "$ORIG_CWD"
+
+ # Compare and see if anything changed. This avoids updating
+ # mtime of the file.
+ if [ -n "${REAL_OUT-}" ]; then
+ if cmp --silent "${REAL_OUT}" "${TMP_OUT}"; then
+ # exit now, skipping print of the output since
+ # there were no changes. the trap should
+ # cleanup TMP_OUT
+ return 0
+ fi
+
+ mv -f "${TMP_OUT}" "${REAL_OUT}"
+ out="${REAL_OUT}"
+ fi
+ fi
+ cat -n "$out" >&2
+}
+
+if [ "$1" = "--gen_sdk_kcompat" ]; then
+ gen_sdk_kcompat "$2"
+fi
\ No newline at end of file
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/udma/__init__.py b/drivers/net/ethernet/huawei/hinic5/build/host/linux/udma/__init__.py
new file mode 100755
index 000000000..cc0d19d0a
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/udma/__init__.py
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+# -*- encoding:utf-8 -*-
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
\ No newline at end of file
diff --git a/drivers/net/ethernet/huawei/hinic5/build/host/linux/udma/build_udma.py b/drivers/net/ethernet/huawei/hinic5/build/host/linux/udma/build_udma.py
new file mode 100755
index 000000000..1bc135990
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/host/linux/udma/build_udma.py
@@ -0,0 +1,532 @@
+#!/usr/bin/env python
+# -*- encoding:utf-8 -*-
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
+import os
+import re
+import sys
+import env
+import logging
+import shutil
+import subprocess
+import build_sdk
+import build_nic
+
+UDMA_DRIVER_TYPE = None
+KRN_OUTPUT_DIR = None
+KRN_OUTPUT_DIR_WIETH_DGB = None
+USR_OUTPUT_DIR = None
+USR_OUTPUT_DIR_WIETH_DGB = None
+KRN_OUTPUT_DIR_V100 = None
+KRN_OUTPUT_DIR_WIETH_DGB_V100 = None
+USR_OUTPUT_DIR_V100 = None
+USR_OUTPUT_DIR_WIETH_DGB_V100 = None
+URMA_KRN_OUTPUT_DIR = None
+URMA_KRN_OUTPUT_DIR_WIETH_DBG = None
+URMA_USR_OUTPUT_DIR = None
+URMA_USR_OUTPUT_DIR_WIETH_DBG = None
+RPM_OUTPUT_DIR = None
+
+HI1823_1650_BUILD_DIR = None
+KDIR = None
+UBUS_UBC_BUILD_DIR = None
+HISDK5_BUILD_DIR = None
+HINIC5_BUILD_DIR = None
+BUILD_KERNEL_DIR = None
+
+HI1823_UMDK_CODE_DIR = f"{env.HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/UMDK"
+HI1823_UMDK_SPEC_FILE_NAME = 'umdk.spec'
+HI1823_UMDK_SPEC_FILE_PATHNAME = f'{env.HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/UMDK/{HI1823_UMDK_SPEC_FILE_NAME}'
+HI1823_UMDK_TAR_FILE_VERSION = 'umdk-25.12.0'
+HI1823_UMDK_RPM_OPTION = '--with ubagg_disable --with urma'
+HI1823_UMDK_LIB_URMA_DIR = f'{HI1823_UMDK_CODE_DIR}/build/urma/lib/urma/core'
+HI1823_UMDK_LIB_TPSA_DIR = f'{HI1823_UMDK_CODE_DIR}/build/urma/lib/uvs/core'
+HI1823_UMDK_LIB_URMA_COMM_DIR = f'{HI1823_UMDK_CODE_DIR}/build/urma/common'
+HI1823_UMDK_UBCORE_SYMVERS_DIR = f'{HI1823_UMDK_CODE_DIR}/build/urma/kmod/drivers/ub/urma/ubcore'
+HI1823_UMDK_UBCORE_KO_DIR = f'{HI1823_UMDK_CODE_DIR}/build/urma/kmod/drivers/ub/urma/ubcore'
+HI1823_UMDK_UBURMA_SYMVERS_DIR = f'{HI1823_UMDK_CODE_DIR}/build/urma/kmod/drivers/ub/urma/uburma'
+HI1823_UMDK_UBURMA_KO_DIR = f'{HI1823_UMDK_CODE_DIR}/build/urma/kmod/drivers/ub/urma/uburma'
+
+def build_rpm_prepare():
+ if not env.hi1823_os_release:
+ cmd = "echo -n $(uname -r) | sed -e 's/-/_/g'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ env.hi1823_os_release = output
+
+ global UDMA_DRIVER_TYPE
+ if not env.hi1823_driver_type:
+ UDMA_DRIVER_TYPE = "UDMA_STANDARD"
+
+ global KRN_OUTPUT_DIR
+ global KRN_OUTPUT_DIR_WIETH_DGB
+ global USR_OUTPUT_DIR
+ global USR_OUTPUT_DIR_WIETH_DGB
+ global RPM_OUTPUT_DIR
+ KRN_OUTPUT_DIR = f"{env.hi1823_bin_dir}/driver/linux/udma/{env.hi1823_os_release}/{UDMA_DRIVER_TYPE}/kernel"
+ KRN_OUTPUT_DIR_WIETH_DGB = f"{KRN_OUTPUT_DIR}/debug"
+ USR_OUTPUT_DIR = f"{env.hi1823_bin_dir}/driver/linux/udma/{env.hi1823_os_release}/{UDMA_DRIVER_TYPE}/user"
+ USR_OUTPUT_DIR_WIETH_DGB = f"{USR_OUTPUT_DIR}/debug"
+ RPM_OUTPUT_DIR = f"{env.hi1823_bin_dir}/driver/linux/udma/{env.hi1823_os_release}/{UDMA_DRIVER_TYPE}"
+
+ return 0
+
+def build_prepare():
+ if not env.hi1823_os_release:
+ cmd = "echo -n $(uname -r) | sed -e 's/-/_/g'"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ env.hi1823_os_release = output
+
+ global UDMA_DRIVER_TYPE
+ if not env.hi1823_driver_type:
+ UDMA_DRIVER_TYPE = "UDMA_STANDARD"
+
+ global KRN_OUTPUT_DIR
+ global KRN_OUTPUT_DIR_WIETH_DGB
+ global USR_OUTPUT_DIR
+ global USR_OUTPUT_DIR_WIETH_DGB
+ global RPM_OUTPUT_DIR
+ KRN_OUTPUT_DIR = f"{env.hi1823_bin_dir}/driver/linux/udma/{env.hi1823_os_release}/{UDMA_DRIVER_TYPE}/kernel"
+ KRN_OUTPUT_DIR_WIETH_DGB = f"{KRN_OUTPUT_DIR}/debug"
+ USR_OUTPUT_DIR = f"{env.hi1823_bin_dir}/driver/linux/udma/{env.hi1823_os_release}/{UDMA_DRIVER_TYPE}/user"
+ USR_OUTPUT_DIR_WIETH_DGB = f"{USR_OUTPUT_DIR}/debug"
+ RPM_OUTPUT_DIR = f"{env.hi1823_bin_dir}/driver/linux/udma/{env.hi1823_os_release}/{UDMA_DRIVER_TYPE}"
+
+ global URMA_KRN_OUTPUT_DIR
+ global URMA_KRN_OUTPUT_DIR_WIETH_DBG
+ global URMA_USR_OUTPUT_DIR
+ global URMA_USR_OUTPUT_DIR_WIETH_DBG
+ URMA_KRN_OUTPUT_DIR = f"{env.HI1823_TRUNK_DIR}/platform/bin/driver/linux/urma/{env.hi1823_os_release}/{UDMA_DRIVER_TYPE}/kernel"
+ URMA_KRN_OUTPUT_DIR_WIETH_DBG = f"{URMA_KRN_OUTPUT_DIR}/debug"
+ URMA_USR_OUTPUT_DIR = f"{env.HI1823_TRUNK_DIR}/platform/bin/driver/linux/urma/{env.hi1823_os_release}/{UDMA_DRIVER_TYPE}/user"
+ URMA_USR_OUTPUT_DIR_WIETH_DBG = f"{URMA_USR_OUTPUT_DIR}/debug"
+
+ if os.path.isdir(KRN_OUTPUT_DIR):
+ shutil.rmtree(KRN_OUTPUT_DIR)
+ if os.path.isdir(USR_OUTPUT_DIR):
+ shutil.rmtree(USR_OUTPUT_DIR)
+ if os.path.isdir(URMA_KRN_OUTPUT_DIR):
+ shutil.rmtree(URMA_KRN_OUTPUT_DIR)
+ if os.path.isdir(URMA_USR_OUTPUT_DIR):
+ shutil.rmtree(URMA_USR_OUTPUT_DIR)
+
+ os.makedirs(KRN_OUTPUT_DIR)
+ os.makedirs(KRN_OUTPUT_DIR_WIETH_DGB)
+ os.makedirs(USR_OUTPUT_DIR)
+ os.makedirs(USR_OUTPUT_DIR_WIETH_DGB)
+
+ os.makedirs(URMA_KRN_OUTPUT_DIR)
+ os.makedirs(URMA_KRN_OUTPUT_DIR_WIETH_DBG)
+ os.makedirs(URMA_USR_OUTPUT_DIR)
+ os.makedirs(URMA_USR_OUTPUT_DIR_WIETH_DBG)
+
+ global BUILD_KERNEL_DIR
+ BUILD_KERNEL_DIR = env.hi1823_udma_knl_code_dir
+ if (env.hi1823_env_type == "1650"):
+ global HI1823_1650_BUILD_DIR
+ global KDIR
+ global UBUS_UBC_BUILD_DIR
+ global HISDK5_BUILD_DIR
+ global HINIC5_BUILD_DIR
+ HI1823_1650_BUILD_DIR = f"{env.HI1823_TRUNK_DIR}/../build_cache/{env.hi1823_1650_build_version}"
+ KDIR = f"{HI1823_1650_BUILD_DIR}/{env.hi1823_os_path}"
+ UBUS_UBC_BUILD_DIR = f"{HI1823_1650_BUILD_DIR}/cmake/component/{env.hi1823_component_path}/ubus"
+ HISDK5_BUILD_DIR = f"{HI1823_1650_BUILD_DIR}/cmake/ChipSolution/src/dpu_platform_library/host/sdk/knldk/lld"
+ HINIC5_BUILD_DIR = f"{HI1823_1650_BUILD_DIR}/cmake/ChipSolution/src/dpu_platform_library/host/service/nic/linux"
+ BUILD_KERNEL_DIR = f"{HI1823_1650_BUILD_DIR}/cmake/ChipSolution/src/dpu_platform_library/host/service/udma/kernel"
+
+ if env.hi1823_ubus_driver_unified_compile == True:
+ KDIR = env.HI1823_BUILD_UBUS_KERNEL_DIR
+ UBUS_UBC_BUILD_DIR = env.HI1823_BUILD_UBUS_DRIVER_MODULE_DIR
+ HISDK5_BUILD_DIR = f"{env.HI1823_BUILD_DIR}/../src/dpu_platform_library/host/sdk/knldk/lld"
+ HINIC5_BUILD_DIR = f"{env.HI1823_BUILD_DIR}/../src/dpu_platform_library/host/service/nic/linux"
+ BUILD_KERNEL_DIR = f"{env.HI1823_BUILD_DIR}/../src/dpu_platform_library/host/service/udma/kernel"
+
+ return 0
+
+def copy_umdk():
+ env.copy_file(f"{HI1823_UMDK_UBCORE_KO_DIR}/ubcore.ko", URMA_KRN_OUTPUT_DIR_WIETH_DBG)
+ env.copy_file(f"{HI1823_UMDK_UBCORE_KO_DIR}/ubcore.ko", URMA_KRN_OUTPUT_DIR)
+ env.copy_file(f"{HI1823_UMDK_UBCORE_SYMVERS_DIR}/Module.symvers", env.hi1823_ci_lib_dir, "UBCORE_Module.symvers")
+ cmd = f"strip -g {URMA_KRN_OUTPUT_DIR}/ubcore.ko"
+ logging.info(f"exec cmd :[{cmd}]")
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ env.copy_file(f"{HI1823_UMDK_UBURMA_KO_DIR}/uburma.ko", URMA_KRN_OUTPUT_DIR_WIETH_DBG)
+ env.copy_file(f"{HI1823_UMDK_UBURMA_KO_DIR}/uburma.ko", URMA_KRN_OUTPUT_DIR)
+ env.copy_file(f"{HI1823_UMDK_UBURMA_SYMVERS_DIR}/Module.symvers", env.hi1823_ci_lib_dir, "UBURMA_Module.symvers")
+ cmd = f"strip -g {URMA_KRN_OUTPUT_DIR}/uburma.ko"
+ logging.info(f"exec cmd :[{cmd}]")
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ # Copy user library
+ logging.info("Copy user library")
+ env.copy_file_with_start(f"{HI1823_UMDK_LIB_URMA_DIR}", URMA_USR_OUTPUT_DIR_WIETH_DBG, "liburma")
+ env.copy_file_with_start(f"{HI1823_UMDK_LIB_URMA_DIR}", URMA_USR_OUTPUT_DIR, "liburma")
+ cmd = f"strip -s {URMA_USR_OUTPUT_DIR}/liburma*"
+ logging.info(f"exec cmd :[{cmd}]")
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ logging.info("Copy libtpsa")
+ env.copy_file_with_start(f"{HI1823_UMDK_LIB_TPSA_DIR}", URMA_USR_OUTPUT_DIR_WIETH_DBG, "libtpsa")
+ env.copy_file_with_start(f"{HI1823_UMDK_LIB_TPSA_DIR}", URMA_USR_OUTPUT_DIR, "libtpsa")
+ cmd = f"strip -s {URMA_USR_OUTPUT_DIR}/libtpsa*"
+ logging.info(f"exec cmd :[{cmd}]")
+ status, output = subprocess.getstatusoutput(cmd)
+ logging.info(f"exec cmd :status:[{status}]. output:[{output}]")
+
+ logging.info("Copy liburma_common*")
+ env.copy_file_with_start(f"{HI1823_UMDK_LIB_URMA_COMM_DIR}", URMA_USR_OUTPUT_DIR_WIETH_DBG, "liburma_common")
+ env.copy_file_with_start(f"{HI1823_UMDK_LIB_URMA_COMM_DIR}", URMA_USR_OUTPUT_DIR, "liburma_common")
+ cmd = f"strip -s {URMA_USR_OUTPUT_DIR}/liburma_common*"
+ logging.info(f"exec cmd :[{cmd}]")
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ env.copy_file(f"{HI1823_UMDK_CODE_DIR}/build/urma/tools/uvs_admin/uvs_admin", URMA_USR_OUTPUT_DIR_WIETH_DBG)
+ env.copy_file(f"{HI1823_UMDK_CODE_DIR}/build/urma/tools/uvs_admin/uvs_admin", URMA_USR_OUTPUT_DIR)
+ env.copy_file(f"{HI1823_UMDK_CODE_DIR}/build/urma/tools/urma_admin/urma_admin", URMA_USR_OUTPUT_DIR_WIETH_DBG)
+ env.copy_file(f"{HI1823_UMDK_CODE_DIR}/build/urma/tools/urma_admin/urma_admin", URMA_USR_OUTPUT_DIR)
+ env.copy_file(f"{HI1823_UMDK_CODE_DIR}/build/urma/tools/urma_perftest/urma_perftest", URMA_USR_OUTPUT_DIR_WIETH_DBG)
+ env.copy_file(f"{HI1823_UMDK_CODE_DIR}/build/urma/tools/urma_perftest/urma_perftest", URMA_USR_OUTPUT_DIR)
+ env.copy_file(f"{HI1823_UMDK_CODE_DIR}/build/urma/tools/transport_service/tpsa_daemon", URMA_USR_OUTPUT_DIR_WIETH_DBG)
+ env.copy_file(f"{HI1823_UMDK_CODE_DIR}/build/urma/tools/transport_service/tpsa_daemon", URMA_USR_OUTPUT_DIR)
+
+def build_umdk():
+ shutil.rmtree(f"{HI1823_UMDK_CODE_DIR}/build", ignore_errors=True)
+
+ tmp_ops = ""
+ if (env.hi1823_env_type == "1650"):
+ cmd = f"cp -rf {HI1823_UMDK_CODE_DIR}/huawei_secure_c/include/*.h {env.HI1823_TRUNK_DIR}/../{env.hi1823_os_path}/include/linux/"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ cmd = f"sed -i 's|#include |#include |g' {env.HI1823_TRUNK_DIR}/../{env.hi1823_os_path}/include/linux/securec.h"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ cmd = f"cp -rf {env.HI1823_TRUNK_DIR}/../{env.hi1823_os_path}/include/linux/stdarg.h {env.HI1823_TRUNK_DIR}/../{env.hi1823_os_path}/include/"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ cmd = f"\cp -rf {env.HI1823_TRUNK_DIR}/src/dpu_platform_library/host/service/UMDK/src/urma/kmod/include/ub {env.HI1823_TRUNK_DIR}/../open_source/2403_SP2/include/"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ tmp_ops = f"-DKERNEL_PATH={KDIR} -DSECUREC_COMPILE=enable -DBUILD_DLOCK=disable -DBUILD_URPC=disable -DBUILD_UMS=disable -DBUILD_URMA=enable -DBUILD_ALL=disable -DBUILD_UDMA=disable"
+
+ if env.hi1823_ubus_driver_unified_compile == True:
+ if os.path.isdir(f'{KDIR}/include/ub/urma'):
+ shutil.rmtree(f'{KDIR}/include/ub/urma')
+
+ tmp_ops = f"-DKERNEL_PATH={KDIR} -DSECUREC_COMPILE=enable -DBUILD_DLOCK=disable -DBUILD_URPC=disable -DBUILD_UMS=disable -DBUILD_URMA=enable -DBUILD_ALL=disable -DBUILD_UDMA=disable"
+
+ if "eulerosv2r9" in str(env.hi1823_complie_os_kver) or env.hi1823_env_type == "1650" or (env.hi1823_ubus_driver_unified_compile == True):
+ cmd = f"cmake {HI1823_UMDK_CODE_DIR}/src -B {HI1823_UMDK_CODE_DIR}/build -DURMA_OVER_IB=disable {tmp_ops}"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ logging.info(f"cmd:[{cmd}], output:[{output}]")
+
+ cmd = f"make -j16 -C {HI1823_UMDK_CODE_DIR}/build"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ logging.info(f"cmd:[{cmd}], output = [{output}]")
+ else:
+ logging.info("Copy urma spec file to rpmbuild dir...")
+ env.copy_file(HI1823_UMDK_SPEC_FILE_PATHNAME, f"{env.HI1823_RPM_BUILD_DIR}/SPECS")
+
+ logging.info("Tar urma files...")
+ cmd = f"cd {HI1823_UMDK_CODE_DIR};tar -czf {env.HI1823_RPM_BUILD_DIR}/SOURCES/{HI1823_UMDK_TAR_FILE_VERSION}.tar.gz ./*"
+ rslt = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ if rslt.returncode:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{rslt.returncode}]. output:[{rslt.stdout.decode()}]. stderr:[{rslt.stderr.decode()}]")
+ return 1
+ logging.info("Excute rpmbuild rdma rpm package...")
+ cmd = f"rpmbuild --noclean --define \"_topdir {env.HI1823_RPM_BUILD_DIR}\" -ba {env.HI1823_RPM_BUILD_DIR}/SPECS/{HI1823_UMDK_SPEC_FILE_NAME} {HI1823_UMDK_RPM_OPTION}"
+ rslt = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ if rslt.returncode:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{rslt.returncode}]. output:[{rslt.stdout.decode()}]. stderr:[{rslt.stderr.decode()}]")
+ return 1
+ logging.info(f"output = [{rslt.stdout.decode()}]")
+
+ cmd = f'cd {env.HI1823_RPM_BUILD_DIR}/BUILD/{HI1823_UMDK_TAR_FILE_VERSION}/src/urma/kmod; sh build.sh'
+ rslt = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ if rslt.returncode:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{rslt.returncode}]. output:[{rslt.stdout.decode()}]. stderr:[{rslt.stderr.decode()}]")
+ return 1
+ logging.info(f"output = [{rslt.stdout.decode()}]")
+
+ # copy rpmbuild files to HI1823_UMDK_CODE_DIR/build
+ cmd = f"mkdir -pv -m 777 {HI1823_UMDK_CODE_DIR}/build; cp -rf {env.HI1823_RPM_BUILD_DIR}/BUILD/{HI1823_UMDK_TAR_FILE_VERSION}/* {HI1823_UMDK_CODE_DIR}/build/"
+ rslt = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ logging.info(f"exec cmd :[{cmd}] status:[{rslt.returncode}]. output:[{rslt.stdout.decode()}]. stderr:[{rslt.stderr.decode()}]")
+
+ # copy rpms to output dir
+ env.copy_file_with_start_and_end(f"{env.HI1823_RPM_BUILD_DIR}/RPMS/{env.hi1823_os_arch}", RPM_OUTPUT_DIR, "umdk", ".rpm")
+ env.copy_file_with_start_and_end(f"{env.HI1823_RPM_BUILD_DIR}/SRPMS", RPM_OUTPUT_DIR, "umdk", ".rpm")
+
+ copy_umdk()
+ # build clean
+ cmd = f"find {HI1823_UMDK_CODE_DIR}/build -name '*.o' -o -name '*.cmd' -o -name '*.mod'|xargs rm -f"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ return 0
+
+def build_udma_kernel():
+ cmd = f"make -C {env.hi1823_udma_knl_code_dir} clean"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ if env.hi1823_ubus_driver_unified_compile == True:
+ cmd = f"sed -i 's|#include |#include |g' {BUILD_KERNEL_DIR}/../base/udma_base_sq.c"
+ status, output = subprocess.getstatusoutput(cmd)
+
+ if env.hi1823_env_type == "1650":
+ cmd = f"cp -rf {env.HI1823_TRUNK_DIR}/../{env.hi1823_os_path}/include/linux/stddef.h {env.HI1823_TRUNK_DIR}/../{env.hi1823_os_path}/include/"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ cmd = f"make -C {env.hi1823_udma_knl_code_dir} UMDK_DIR={HI1823_UMDK_CODE_DIR} VERSION={UDMA_DRIVER_TYPE} -j16"
+ if env.hi1823_env_type == "1650":
+ cmd = f"make -j64 -C {KDIR} M={BUILD_KERNEL_DIR} src={env.hi1823_udma_knl_code_dir} UMDK_DIR={HI1823_UMDK_CODE_DIR} VERSION={UDMA_DRIVER_TYPE} UBUS_UBC_BUILD_DIR={UBUS_UBC_BUILD_DIR} HI1823_TRUNK_DIR={env.HI1823_TRUNK_DIR} HI1823_BUILD_DIR={env.HI1823_TRUNK_DIR}/build CONFIG_UBUS_DEVICE=y HI1823_OS_TYPE=openEuler24.03 VERBOSE=1 HISDK5_SYMVERS={HISDK5_BUILD_DIR}/Module.symvers HINIC5_SYMVERS={HINIC5_BUILD_DIR}/Module.symvers"
+ else:
+ cmd = f"make -C {env.hi1823_udma_knl_code_dir} UMDK_DIR={HI1823_UMDK_CODE_DIR} VERSION={UDMA_DRIVER_TYPE} -j16"
+
+ rslt = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ if rslt.returncode:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{rslt.returncode}]. output:[{rslt.stdout}] err:{rslt.stderr.decode()}")
+ return 1
+ logging.info(f"output = [{rslt.stdout.decode()}]")
+ os.chmod(f"{BUILD_KERNEL_DIR}/hiudma5.ko", 0o644)
+ env.copy_file(f"{BUILD_KERNEL_DIR}/hiudma5.ko", KRN_OUTPUT_DIR_WIETH_DGB)
+ env.copy_file(f"{BUILD_KERNEL_DIR}/hiudma5.ko", KRN_OUTPUT_DIR)
+ env.copy_file(f"{BUILD_KERNEL_DIR}/Module.symvers", env.hi1823_ci_lib_dir, "UBUDMA_Module.symvers")
+
+ cmd = f"strip -g {KRN_OUTPUT_DIR}/hiudma5.ko"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ # get build info
+ cmd = f"sh {env.HI1823_BUILD_LOG_PATH}/build_log.sh {BUILD_KERNEL_DIR}/build {KRN_OUTPUT_DIR} hiudma5.ko"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ ret = env.collect_build_info(KRN_OUTPUT_DIR, f"{env.hi1823_bin_dir}/driver/linux/udma")
+ if ret:
+ return ret
+
+ cmd = f"make -C {env.hi1823_udma_knl_code_dir} clean"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ # build clean
+ cmd = f"find {env.hi1823_udma_knl_code_dir} -name '*.o' -o -name '*.cmd' -o -name '*.mod'|xargs rm -f"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ return 0
+
+def build_huawei_securec():
+ os.chdir(f"{env.huawei_secure_code_dir}/src")
+
+ cmd = ["make", "clean"]
+ try:
+ subprocess.run(cmd, shell=False, check=True, capture_output=True)
+ except Exception as e:
+ logging.error(f"exec cmd fail:{e}. error = [{e.stderr}]")
+ return 1
+
+ output_dir = f"{env.hi1823_ci_lib_dir}/huawei_securec/{env.hi1823_os_release}"
+ os.makedirs(output_dir, exist_ok=True)
+
+ cmd = f"make -C {env.huawei_secure_code_dir}/src"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ logging.info(f"output = [{output}]")
+
+ cmd = f"make -C {env.huawei_secure_code_dir}/src lib"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ logging.info(f"output = [{output}]")
+
+ env.copy_file(f"{env.huawei_secure_code_dir}/lib/libsecurec.so", output_dir)
+
+ cmd = ["make", "clean"]
+ try:
+ subprocess.run(cmd, shell=False, check=True, capture_output=True)
+ except Exception as e:
+ logging.error(f"exec cmd fail:{e}. error = [{e.stderr}]")
+ return 1
+
+ return 0
+
+def build_udma_user():
+ ret = build_huawei_securec()
+ if ret:
+ return ret
+ shutil.rmtree(f"{env.hi1823_udma_usr_code_dir}/build", ignore_errors=True)
+
+ logging.info(env.hi1823_udma_usr_code_dir)
+ cmd = f"ls -l {env.hi1823_udma_usr_code_dir}"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ file_list = output
+ logging.info(file_list)
+
+ if env.hi1823_ubus_driver_unified_compile == True:
+ cmd = f"sed -i 's|#include |#include |g' {BUILD_KERNEL_DIR}/../base/udma_base_sq.c"
+ status, output = subprocess.getstatusoutput(cmd)
+
+ cmd = f"cmake {env.hi1823_udma_usr_code_dir} -B {env.hi1823_udma_usr_code_dir}/build -DUMDK_CODE_DIR={HI1823_UMDK_CODE_DIR}"
+
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ cmd = f"make -C {env.hi1823_udma_usr_code_dir}/build -j16"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+ logging.info(f"output = [{output}]")
+
+ build_info_lines = [
+ 'Source 0', 'OpenSource 0', 'ThirdParty 0', 'Tool 0', 'RealTarget 1', 'liburma.so', 'CMTarget 1', 'liburma.so'
+ ]
+ with open(f'{USR_OUTPUT_DIR}/build_info_user.txt', 'w') as f:
+ for line in build_info_lines:
+ f.write(f'{line}\n')
+
+ ret = env.collect_build_info(USR_OUTPUT_DIR, f"{env.hi1823_bin_dir}/driver/linux/udma", "user")
+ if ret:
+ return ret
+
+ env.copy_file_with_start(f"{env.hi1823_udma_usr_code_dir}/build", USR_OUTPUT_DIR_WIETH_DGB, "liburma")
+ env.copy_file_with_start(f"{env.hi1823_udma_usr_code_dir}/build", USR_OUTPUT_DIR, "liburma")
+
+ cmd = f"strip -s {USR_OUTPUT_DIR}/liburma*"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ os.chmod(f"{USR_OUTPUT_DIR}/liburma_hiudma5.so", 0o550)
+ os.chmod(f"{USR_OUTPUT_DIR_WIETH_DGB}/liburma_hiudma5.so", 0o550)
+
+ cmd = f"make -C {env.hi1823_udma_usr_code_dir}/build clean"
+ status, output = subprocess.getstatusoutput(cmd)
+ if status:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{status}]. output:[{output}]")
+ return 1
+
+ return 0
+
+def build_udma_rpm():
+ logging.info("*********************Start build udma rpm *********************")
+ ret = build_rpm_prepare()
+ if ret:
+ return ret
+
+ shutil.rmtree(env.HI1823_RPM_BUILD_DIR, ignore_errors=True)
+ cmd = f"mkdir -pv -m 777 {env.HI1823_RPM_BUILD_DIR}/{{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}}"
+ rslt = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ if rslt.returncode:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{rslt.returncode}]. output:[{rslt.stdout.decode()}]. stderr:[{rslt.stderr.decode()}]")
+ return 1
+
+ env.copy_file(f"{KRN_OUTPUT_DIR}/hiudma5.ko", f"{env.HI1823_RPM_BUILD_DIR}/SOURCES/")
+ env.copy_file(f"{USR_OUTPUT_DIR}/liburma_hiudma5.so", f"{env.HI1823_RPM_BUILD_DIR}/SOURCES/")
+ env.copy_file(f"{env.HI1823_TRUNK_DIR}/ci/tool/hiudma5_udk_log/hiudma5", f"{env.HI1823_RPM_BUILD_DIR}/SOURCES")
+ env.copy_file(f"{env.HI1823_TRUNK_DIR}/ci/tool/hiudma5_udk_log/hiudma5.conf", f"{env.HI1823_RPM_BUILD_DIR}/SOURCES")
+ env.copy_file(f"{env.HI1823_TRUNK_DIR}/ci/tool/hiudma5_udk_log/hiudma5logdump.conf", f"{env.HI1823_RPM_BUILD_DIR}/SOURCES")
+ env.copy_file(f"{env.HI1823_TRUNK_DIR}/src/GLOBAL_VERSION_NEW", f"{env.HI1823_RPM_BUILD_DIR}/SOURCES")
+ env.copy_file(f"{env.HI1823_TRUNK_DIR}/build/host/linux/udma/udma_rpm_build/udma-modules.conf", f"{env.HI1823_RPM_BUILD_DIR}/SOURCES")
+ env.copy_file(f"{env.HI1823_TRUNK_DIR}/build/host/linux/udma/udma_rpm_build/udma.spec", f"{env.HI1823_RPM_BUILD_DIR}/SPECS")
+
+ cmd = f"rpmbuild --define \"_topdir {env.HI1823_RPM_BUILD_DIR}\" -bb {env.HI1823_RPM_BUILD_DIR}/SPECS/udma.spec --target={env.hi1823_os_arch}"
+ rslt = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ if rslt.returncode:
+ logging.error(f"exec cmd fail. [{cmd}] status:[{rslt.returncode}]. output:[{rslt.stdout.decode()}]. stderr:[{rslt.stderr.decode()}]")
+ return 1
+
+ env.copy_file_with_start_and_end(f"{env.HI1823_RPM_BUILD_DIR}/RPMS/{env.hi1823_os_arch}", RPM_OUTPUT_DIR, "hiudma5", ".rpm")
+
+ os.system(f"chmod 644 {RPM_OUTPUT_DIR}/hiudma5*")
+
+ logging.info("*********************build udma rpm success*********************")
+
+ return 0
+
+def build_udma():
+ ret = build_prepare()
+ if ret:
+ return ret
+
+ if env.hi1823_env_type != "1650":
+ logging.info("*********************Start build sdk & nic*********************")
+ build_sdk.build_sdk()
+ build_nic.build_nic()
+
+ logging.info("*********************Start build umdk*********************")
+ # build UMDK(urma). Temporarily, the UMDK is ultimately delivered upstream as a binary
+ ret = build_umdk()
+ if ret:
+ return ret
+
+ logging.info("*********************Start build udma kernel*********************")
+ ret = build_udma_kernel()
+ if ret:
+ return ret
+
+ logging.info("*********************Start build udma user*********************")
+ ret = build_udma_user()
+
+ return ret
diff --git a/drivers/net/ethernet/huawei/hinic5/build/tools/build_log/build_log.sh b/drivers/net/ethernet/huawei/hinic5/build/tools/build_log/build_log.sh
new file mode 100755
index 000000000..617003fcd
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/build/tools/build_log/build_log.sh
@@ -0,0 +1,95 @@
+#!/bin/bash
+# Perform hot backups of Oracle databases.
+# Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
+set -e
+set +e
+CUR_DIR=$PWD
+SOURCE_DIR=$1
+TARGET_DIR=$2
+CMTARGET=$3
+INFO_SUFFIX=$4
+
+if [ ! -z "$INFO_SUFFIX" ]; then
+ BUILD_INFO_FILE="$TARGET_DIR/build_info_$INFO_SUFFIX.txt"
+else
+ BUILD_INFO_FILE=$TARGET_DIR/build_info.txt
+fi
+
+cd $SOURCE_DIR
+# Source
+if [ -e "build_src.txt" ]; then
+ sed -i "s/ /\n/g" build_src.txt
+ count=0
+ for line in $(cat build_src.txt)
+ do
+ let count++
+ done
+ if [ -e "$BUILD_INFO_FILE" ];then
+ echo "" >> $BUILD_INFO_FILE
+ echo "Source $count" >> $BUILD_INFO_FILE
+ else
+ echo "Source $count" > $BUILD_INFO_FILE
+ fi
+ cat build_src.txt >> $BUILD_INFO_FILE
+else
+ echo "Source 0" > $BUILD_INFO_FILE
+fi
+
+# OpenSource
+if [ -e "build_opensrc.txt" ]; then
+ sed -i "s/ /\n/g" build_opensrc.txt
+ count=0
+ for line in $(cat build_opensrc.txt)
+ do
+ let count++
+ done
+ echo "OpenSource $count" >> $BUILD_INFO_FILE
+ cat build_opensrc.txt >> $BUILD_INFO_FILE
+else
+ echo "OpenSource 0" >> $BUILD_INFO_FILE
+fi
+
+# ThirdParty
+if [ -e "build_third_party.txt" ]; then
+ sed -i "s/ /\n/g" build_third_party.txt
+ count=0
+ for line in $(cat build_third_party.txt)
+ do
+ let count++
+ done
+ echo "ThirdParty $count" >> $BUILD_INFO_FILE
+ cat build_third_party.txt >> $BUILD_INFO_FILE
+else
+ echo "ThirdParty 0" >> $BUILD_INFO_FILE
+fi
+
+# Tool
+if [ -e "build_tool.txt" ]; then
+ sed -i "s/ /\n/g" build_tool.txt
+ count=0
+ for line in $(cat build_tool.txt)
+ do
+ let count++
+ done
+ echo "Tool $count" >> $BUILD_INFO_FILE
+ cat build_tool.txt >> $BUILD_INFO_FILE
+else
+ echo "Tool 0" >> $BUILD_INFO_FILE
+fi
+
+# Target
+count=0
+target_suffix=".bin\|.ko\|.so\|hinicadm"
+for line in $(ls $TARGET_DIR | grep $target_suffix)
+do
+ let count++
+done
+echo "RealTarget $count" >> $BUILD_INFO_FILE
+ls $TARGET_DIR | grep $target_suffix >> $BUILD_INFO_FILE
+
+# CM Target
+count=1
+echo "CMTarget $count" >> $BUILD_INFO_FILE
+echo $CMTARGET >> $BUILD_INFO_FILE
+
+
diff --git a/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/cmake/huawei_secure_cConfig.cmake b/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/cmake/huawei_secure_cConfig.cmake
new file mode 100644
index 000000000..f91007059
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/cmake/huawei_secure_cConfig.cmake
@@ -0,0 +1,96 @@
+# Generated by CMake
+
+if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
+ message(FATAL_ERROR "CMake >= 2.6.0 required")
+endif()
+cmake_policy(PUSH)
+cmake_policy(VERSION 2.6...3.17)
+#----------------------------------------------------------------
+# Generated CMake target import file.
+#----------------------------------------------------------------
+
+# Commands may need to know the format version.
+set(CMAKE_IMPORT_FILE_VERSION 1)
+
+# Protect against multiple inclusion, which would fail when already imported targets are added once more.
+set(_targetsDefined)
+set(_targetsNotDefined)
+set(_expectedTargets)
+foreach(_expectedTarget Hisec::huawei_secure_c)
+ list(APPEND _expectedTargets ${_expectedTarget})
+ if(NOT TARGET ${_expectedTarget})
+ list(APPEND _targetsNotDefined ${_expectedTarget})
+ endif()
+ if(TARGET ${_expectedTarget})
+ list(APPEND _targetsDefined ${_expectedTarget})
+ endif()
+endforeach()
+if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
+ unset(_targetsDefined)
+ unset(_targetsNotDefined)
+ unset(_expectedTargets)
+ set(CMAKE_IMPORT_FILE_VERSION)
+ cmake_policy(POP)
+ return()
+endif()
+if(NOT "${_targetsDefined}" STREQUAL "")
+ message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
+endif()
+unset(_targetsDefined)
+unset(_targetsNotDefined)
+unset(_expectedTargets)
+
+
+# Compute the installation prefix relative to this file.
+get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+if(_IMPORT_PREFIX STREQUAL "/")
+ set(_IMPORT_PREFIX "")
+endif()
+
+# Create imported target Hisec::huawei_secure_c
+add_library(Hisec::huawei_secure_c INTERFACE IMPORTED)
+
+set_target_properties(Hisec::huawei_secure_c PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
+)
+
+if(CMAKE_VERSION VERSION_LESS 3.0.0)
+ message(FATAL_ERROR "This file relies on consumers using CMake 3.0.0 or greater.")
+endif()
+
+# Load information for each installed configuration.
+get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+file(GLOB CONFIG_FILES "${_DIR}/huawei_secure_cConfig-*.cmake")
+foreach(f ${CONFIG_FILES})
+ include(${f})
+endforeach()
+
+# Cleanup temporary variables.
+set(_IMPORT_PREFIX)
+
+# Loop over all imported files and verify that they actually exist
+foreach(target ${_IMPORT_CHECK_TARGETS} )
+ foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
+ if(NOT EXISTS "${file}" )
+ message(FATAL_ERROR "The imported target \"${target}\" references the file
+ \"${file}\"
+but this file does not exist. Possible reasons include:
+* The file was deleted, renamed, or moved to another location.
+* An install or uninstall procedure did not complete successfully.
+* The installation package was faulty and contained
+ \"${CMAKE_CURRENT_LIST_FILE}\"
+but not all the files it references.
+")
+ endif()
+ endforeach()
+ unset(_IMPORT_CHECK_FILES_FOR_${target})
+endforeach()
+unset(_IMPORT_CHECK_TARGETS)
+
+# This file does not depend on other imported targets which have
+# been exported from the same project but in a separate export set.
+
+# Commands beyond this point should not need to know the version.
+set(CMAKE_IMPORT_FILE_VERSION)
+cmake_policy(POP)
diff --git a/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/include/securec.h b/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/include/securec.h
new file mode 100644
index 000000000..a5d275c99
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/include/securec.h
@@ -0,0 +1,676 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2014-2021. All rights reserved.
+ * Licensed under Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ * http://license.coscl.org.cn/MulanPSL2
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
+ * See the Mulan PSL v2 for more details.
+ * Description: The user of this secure c library should include this header file in you source code.
+ * This header file declare all supported API prototype of the library,
+ * such as memcpy_s, strcpy_s, wcscpy_s,strcat_s, strncat_s, sprintf_s, scanf_s, and so on.
+ * Create: 2014-02-25
+ * Notes: Do not modify this file by yourself.
+ */
+
+#ifndef SECUREC_H_5D13A042_DC3F_4ED9_A8D1_882811274C27
+#define SECUREC_H_5D13A042_DC3F_4ED9_A8D1_882811274C27
+
+#include "securectype.h"
+#ifndef SECUREC_HAVE_STDARG_H
+#define SECUREC_HAVE_STDARG_H 1
+#endif
+
+#if SECUREC_HAVE_STDARG_H
+#include
+#ifdef _LINUX_STDARG_H
+#include
+#else
+#include
+#endif
+
+#endif
+
+#ifndef SECUREC_HAVE_ERRNO_H
+#define SECUREC_HAVE_ERRNO_H 1
+#endif
+
+/* EINVAL ERANGE may defined in errno.h */
+#if SECUREC_HAVE_ERRNO_H
+#if SECUREC_IN_KERNEL
+#include
+#else
+#include
+#endif
+#endif
+
+/* Define error code */
+#if defined(SECUREC_NEED_ERRNO_TYPE) || !defined(__STDC_WANT_LIB_EXT1__) || \
+ (defined(__STDC_WANT_LIB_EXT1__) && (!__STDC_WANT_LIB_EXT1__))
+#ifndef SECUREC_DEFINED_ERRNO_TYPE
+#define SECUREC_DEFINED_ERRNO_TYPE
+/* Just check whether macrodefinition exists. */
+#ifndef errno_t
+typedef int errno_t;
+#endif
+#endif
+#endif
+
+/* Success */
+#ifndef EOK
+#define EOK 0
+#endif
+
+#ifndef EINVAL
+/* The src buffer is not correct and destination buffer can not be reset */
+#define EINVAL 22
+#endif
+
+#ifndef EINVAL_AND_RESET
+/* Once the error is detected, the dest buffer must be reset! Value is 22 or 128 */
+#define EINVAL_AND_RESET 150
+#endif
+
+#ifndef ERANGE
+/* The destination buffer is not long enough and destination buffer can not be reset */
+#define ERANGE 34
+#endif
+
+#ifndef ERANGE_AND_RESET
+/* Once the error is detected, the dest buffer must be reset! Value is 34 or 128 */
+#define ERANGE_AND_RESET 162
+#endif
+
+#ifndef EOVERLAP_AND_RESET
+/* Once the buffer overlap is detected, the dest buffer must be reset! Value is 54 or 128 */
+#define EOVERLAP_AND_RESET 182
+#endif
+
+/* If you need export the function of this library in Win32 dll, use __declspec(dllexport) */
+#ifndef SECUREC_API
+#if defined(SECUREC_DLL_EXPORT)
+#if defined(_MSC_VER)
+#define SECUREC_API __declspec(dllexport)
+#else /* build for linux */
+#define SECUREC_API __attribute__((visibility("default")))
+#endif /* end of _MSC_VER and SECUREC_DLL_EXPORT */
+#elif defined(SECUREC_DLL_IMPORT)
+#if defined(_MSC_VER)
+#define SECUREC_API __declspec(dllimport)
+#else
+#define SECUREC_API
+#endif /* end of _MSC_VER and SECUREC_DLL_IMPORT */
+#else
+/*
+ * Standardized function declaration. If a security function is declared in the your code,
+ * it may cause a compilation alarm,Please delete the security function you declared.
+ * Adding extern under windows will cause the system to have inline functions to expand,
+ * so do not add the extern in default
+ */
+#if defined(_MSC_VER)
+#define SECUREC_API
+#else
+#define SECUREC_API extern
+#endif
+#endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Description: The GetHwSecureCVersion function get SecureC Version string and version number.
+ * Parameter: verNumber - to store version number (for example value is 0x500 | 0xa)
+ * Return: version string
+ */
+SECUREC_API const char *GetHwSecureCVersion(unsigned short *verNumber);
+
+#if SECUREC_ENABLE_MEMSET
+/*
+ * Description: The memset_s function copies the value of c (converted to an unsigned char) into each of
+ * the first count characters of the object pointed to by dest.
+ * Parameter: dest - destination address
+ * Parameter: destMax - The maximum length of destination buffer
+ * Parameter: c - the value to be copied
+ * Parameter: count - copies count bytes of value to dest
+ * Return: EOK if there was no runtime-constraint violation
+ */
+SECUREC_API errno_t memset_s(void *dest, size_t destMax, int c, size_t count);
+#endif
+
+#ifndef SECUREC_ONLY_DECLARE_MEMSET
+#define SECUREC_ONLY_DECLARE_MEMSET 0
+#endif
+
+#if !SECUREC_ONLY_DECLARE_MEMSET
+
+#if SECUREC_ENABLE_MEMMOVE
+/*
+ * Description: The memmove_s function copies n characters from the object pointed to by src
+ * into the object pointed to by dest.
+ * Parameter: dest - destination address
+ * Parameter: destMax - The maximum length of destination buffer
+ * Parameter: src - source address
+ * Parameter: count - copies count bytes from the src
+ * Return: EOK if there was no runtime-constraint violation
+ */
+SECUREC_API errno_t memmove_s(void *dest, size_t destMax, const void *src,
+ size_t count);
+#endif
+
+#if SECUREC_ENABLE_MEMCPY
+/*
+ * Description: The memcpy_s function copies n characters from the object pointed to
+ * by src into the object pointed to by dest.
+ * Parameter: dest - destination address
+ * Parameter: destMax - The maximum length of destination buffer
+ * Parameter: src - source address
+ * Parameter: count - copies count bytes from the src
+ * Return: EOK if there was no runtime-constraint violation
+ */
+SECUREC_API errno_t memcpy_s(void *dest, size_t destMax, const void *src,
+ size_t count);
+#endif
+
+#if SECUREC_ENABLE_STRCPY
+/*
+ * Description: The strcpy_s function copies the string pointed to by strSrc (including
+ * the terminating null character) into the array pointed to by strDest
+ * Parameter: strDest - destination address
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating null character)
+ * Parameter: strSrc - source address
+ * Return: EOK if there was no runtime-constraint violation
+ */
+SECUREC_API errno_t strcpy_s(char *strDest, size_t destMax, const char *strSrc);
+#endif
+
+#if SECUREC_ENABLE_STRNCPY
+/*
+ * Description: The strncpy_s function copies not more than n successive characters (not including
+ * the terminating null character) from the array pointed to by strSrc to the array pointed to by strDest.
+ * Parameter: strDest - destination address
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating null character)
+ * Parameter: strSrc - source address
+ * Parameter: count - copies count characters from the src
+ * Return: EOK if there was no runtime-constraint violation
+ */
+SECUREC_API errno_t strncpy_s(char *strDest, size_t destMax, const char *strSrc,
+ size_t count);
+#endif
+
+#if SECUREC_ENABLE_STRCAT
+/*
+ * Description: The strcat_s function appends a copy of the string pointed to by strSrc (including
+ * the terminating null character) to the end of the string pointed to by strDest.
+ * Parameter: strDest - destination address
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating null wide character)
+ * Parameter: strSrc - source address
+ * Return: EOK if there was no runtime-constraint violation
+ */
+SECUREC_API errno_t strcat_s(char *strDest, size_t destMax, const char *strSrc);
+#endif
+
+#if SECUREC_ENABLE_STRNCAT
+/*
+ * Description: The strncat_s function appends not more than n successive characters (not including
+ * the terminating null character)
+ * from the array pointed to by strSrc to the end of the string pointed to by strDest.
+ * Parameter: strDest - destination address
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating null character)
+ * Parameter: strSrc - source address
+ * Parameter: count - copies count characters from the src
+ * Return: EOK if there was no runtime-constraint violation
+ */
+SECUREC_API errno_t strncat_s(char *strDest, size_t destMax, const char *strSrc,
+ size_t count);
+#endif
+
+#if SECUREC_ENABLE_VSPRINTF
+/*
+ * Description: The vsprintf_s function is equivalent to the vsprintf function except for the parameter destMax
+ * and the explicit runtime-constraints violation
+ * Parameter: strDest - produce output according to a format,write to the character string strDest.
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating null wide character)
+ * Parameter: format - format string
+ * Parameter: argList - instead of a variable number of arguments
+ * Return: the number of characters printed(not including the terminating null byte '\0'),
+ * If an error occurred Return: -1.
+ */
+SECUREC_API int vsprintf_s(char *strDest, size_t destMax, const char *format,
+ va_list argList) SECUREC_ATTRIBUTE(3, 0);
+#endif
+
+#if SECUREC_ENABLE_SPRINTF
+/*
+ * Description: The sprintf_s function is equivalent to the sprintf function except for the parameter destMax
+ * and the explicit runtime-constraints violation
+ * Parameter: strDest - produce output according to a format ,write to the character string strDest.
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating null byte '\0')
+ * Parameter: format - format string
+ * Return: the number of characters printed(not including the terminating null byte '\0'),
+ * If an error occurred Return: -1.
+*/
+SECUREC_API int sprintf_s(char *strDest, size_t destMax, const char *format,
+ ...) SECUREC_ATTRIBUTE(3, 4);
+#endif
+
+#if SECUREC_ENABLE_VSNPRINTF
+/*
+ * Description: The vsnprintf_s function is equivalent to the vsnprintf function except for
+ * the parameter destMax/count and the explicit runtime-constraints violation
+ * Parameter: strDest - produce output according to a format ,write to the character string strDest.
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating null byte '\0')
+ * Parameter: count - do not write more than count bytes to strDest(not including the terminating null byte '\0')
+ * Parameter: format - format string
+ * Parameter: argList - instead of a variable number of arguments
+ * Return: the number of characters printed(not including the terminating null byte '\0'),
+ * If an error occurred Return: -1.Pay special attention to returning -1 when truncation occurs.
+ */
+SECUREC_API int vsnprintf_s(char *strDest, size_t destMax, size_t count,
+ const char *format, va_list argList)
+ SECUREC_ATTRIBUTE(4, 0);
+#endif
+
+#if SECUREC_ENABLE_SNPRINTF
+/*
+ * Description: The snprintf_s function is equivalent to the snprintf function except for
+ * the parameter destMax/count and the explicit runtime-constraints violation
+ * Parameter: strDest - produce output according to a format ,write to the character string strDest.
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating null byte '\0')
+ * Parameter: count - do not write more than count bytes to strDest(not including the terminating null byte '\0')
+ * Parameter: format - format string
+ * Return: the number of characters printed(not including the terminating null byte '\0'),
+ * If an error occurred Return: -1.Pay special attention to returning -1 when truncation occurs.
+ */
+SECUREC_API int snprintf_s(char *strDest, size_t destMax, size_t count,
+ const char *format, ...) SECUREC_ATTRIBUTE(4, 5);
+#endif
+
+#if SECUREC_SNPRINTF_TRUNCATED
+/*
+ * Description: The vsnprintf_truncated_s function is equivalent to the vsnprintf_s function except
+ * no count parameter and return value
+ * Parameter: strDest - produce output according to a format ,write to the character string strDest
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating null byte '\0')
+ * Parameter: format - format string
+ * Parameter: argList - instead of a variable number of arguments
+ * Return: the number of characters printed(not including the terminating null byte '\0'),
+ * If an error occurred Return: -1.Pay special attention to returning destMax - 1 when truncation occurs
+*/
+SECUREC_API int vsnprintf_truncated_s(char *strDest, size_t destMax,
+ const char *format, va_list argList)
+ SECUREC_ATTRIBUTE(3, 0);
+
+/*
+ * Description: The snprintf_truncated_s function is equivalent to the snprintf_s function except
+ * no count parameter and return value
+ * Parameter: strDest - produce output according to a format,write to the character string strDest.
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating null byte '\0')
+ * Parameter: format - format string
+ * Return: the number of characters printed(not including the terminating null byte '\0'),
+ * If an error occurred Return: -1.Pay special attention to returning destMax - 1 when truncation occurs.
+ */
+SECUREC_API int snprintf_truncated_s(char *strDest, size_t destMax,
+ const char *format, ...)
+ SECUREC_ATTRIBUTE(3, 4);
+#endif
+
+#if SECUREC_ENABLE_SCANF
+/*
+ * Description: The scanf_s function is equivalent to fscanf_s with the argument stdin
+ * interposed before the arguments to scanf_s
+ * Parameter: format - format string
+ * Return: the number of input items assigned, If an error occurred Return: -1.
+ */
+SECUREC_API int scanf_s(const char *format, ...);
+#endif
+
+#if SECUREC_ENABLE_VSCANF
+/*
+ * Description: The vscanf_s function is equivalent to scanf_s, with the variable argument list replaced by argList
+ * Parameter: format - format string
+ * Parameter: argList - instead of a variable number of arguments
+ * Return: the number of input items assigned, If an error occurred Return: -1.
+ */
+SECUREC_API int vscanf_s(const char *format, va_list argList);
+#endif
+
+#if SECUREC_ENABLE_SSCANF
+/*
+ * Description: The sscanf_s function is equivalent to fscanf_s, except that input is obtained from a
+ * string (specified by the argument buffer) rather than from a stream
+ * Parameter: buffer - read character from buffer
+ * Parameter: format - format string
+ * Return: the number of input items assigned, If an error occurred Return: -1.
+ */
+SECUREC_API int sscanf_s(const char *buffer, const char *format, ...);
+#endif
+
+#if SECUREC_ENABLE_VSSCANF
+/*
+ * Description: The vsscanf_s function is equivalent to sscanf_s, with the variable argument list
+ * replaced by argList
+ * Parameter: buffer - read character from buffer
+ * Parameter: format - format string
+ * Parameter: argList - instead of a variable number of arguments
+ * Return: the number of input items assigned, If an error occurred Return: -1.
+ */
+SECUREC_API int vsscanf_s(const char *buffer, const char *format,
+ va_list argList);
+#endif
+
+#if SECUREC_ENABLE_FSCANF
+/*
+ * Description: The fscanf_s function is equivalent to fscanf except that the c, s, and [ conversion specifiers
+ * apply to a pair of arguments (unless assignment suppression is indicated by a *)
+ * Parameter: stream - stdio file stream
+ * Parameter: format - format string
+ * Return: the number of input items assigned, If an error occurred Return: -1.
+ */
+SECUREC_API int fscanf_s(FILE *stream, const char *format, ...);
+#endif
+
+#if SECUREC_ENABLE_VFSCANF
+/*
+ * Description: The vfscanf_s function is equivalent to fscanf_s, with the variable argument list
+ * replaced by argList
+ * Parameter: stream - stdio file stream
+ * Parameter: format - format string
+ * Parameter: argList - instead of a variable number of arguments
+ * Return: the number of input items assigned, If an error occurred Return: -1.
+ */
+SECUREC_API int vfscanf_s(FILE *stream, const char *format, va_list argList);
+#endif
+
+#if SECUREC_ENABLE_STRTOK
+/*
+ * Description: The strtok_s function parses a string into a sequence of strToken,
+ * replace all characters in strToken string that match to strDelimit set with 0.
+ * On the first call to strtok_s the string to be parsed should be specified in strToken.
+ * In each subsequent call that should parse the same string, strToken should be NULL
+ * Parameter: strToken - the string to be delimited
+ * Parameter: strDelimit - specifies a set of characters that delimit the tokens in the parsed string
+ * Parameter: context - is a pointer to a char * variable that is used internally by strtok_s function
+ * Return: On the first call returns the address of the first non \0 character, otherwise NULL is returned.
+ * In subsequent calls, the strtoken is set to NULL, and the context set is the same as the previous call,
+ * return NULL if the *context string length is equal 0, otherwise return *context.
+ */
+SECUREC_API char *strtok_s(char *strToken, const char *strDelimit,
+ char **context);
+#endif
+
+#if SECUREC_ENABLE_GETS && !SECUREC_IN_KERNEL
+/*
+ * Description: The gets_s function reads at most one less than the number of characters specified
+ * by destMax from the stream pointed to by stdin, into the array pointed to by buffer
+ * Parameter: buffer - destination address
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating null character)
+ * Return: buffer if there was no runtime-constraint violation,If an error occurred Return: NULL.
+ */
+SECUREC_API char *gets_s(char *buffer, size_t destMax);
+#endif
+
+#if SECUREC_ENABLE_WCHAR_FUNC
+#if SECUREC_ENABLE_MEMCPY
+/*
+ * Description: The wmemcpy_s function copies n successive wide characters from the object pointed to
+ * by src into the object pointed to by dest.
+ * Parameter: dest - destination address
+ * Parameter: destMax - The maximum length of destination buffer
+ * Parameter: src - source address
+ * Parameter: count - copies count wide characters from the src
+ * Return: EOK if there was no runtime-constraint violation
+ */
+SECUREC_API errno_t wmemcpy_s(wchar_t *dest, size_t destMax, const wchar_t *src,
+ size_t count);
+#endif
+
+#if SECUREC_ENABLE_MEMMOVE
+/*
+ * Description: The wmemmove_s function copies n successive wide characters from the object
+ * pointed to by src into the object pointed to by dest.
+ * Parameter: dest - destination address
+ * Parameter: destMax - The maximum length of destination buffer
+ * Parameter: src - source address
+ * Parameter: count - copies count wide characters from the src
+ * Return: EOK if there was no runtime-constraint violation
+ */
+SECUREC_API errno_t wmemmove_s(wchar_t *dest, size_t destMax,
+ const wchar_t *src, size_t count);
+#endif
+
+#if SECUREC_ENABLE_STRCPY
+/*
+ * Description: The wcscpy_s function copies the wide string pointed to by strSrc(including the terminating
+ * null wide character) into the array pointed to by strDest
+ * Parameter: strDest - destination address
+ * Parameter: destMax - The maximum length of destination buffer
+ * Parameter: strSrc - source address
+ * Return: EOK if there was no runtime-constraint violation
+ */
+SECUREC_API errno_t wcscpy_s(wchar_t *strDest, size_t destMax,
+ const wchar_t *strSrc);
+#endif
+
+#if SECUREC_ENABLE_STRNCPY
+/*
+ * Description: The wcsncpy_s function copies not more than n successive wide characters (not including the
+ * terminating null wide character) from the array pointed to by strSrc to the array pointed to by strDest
+ * Parameter: strDest - destination address
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating wide character)
+ * Parameter: strSrc - source address
+ * Parameter: count - copies count wide characters from the src
+ * Return: EOK if there was no runtime-constraint violation
+ */
+SECUREC_API errno_t wcsncpy_s(wchar_t *strDest, size_t destMax,
+ const wchar_t *strSrc, size_t count);
+#endif
+
+#if SECUREC_ENABLE_STRCAT
+/*
+ * Description: The wcscat_s function appends a copy of the wide string pointed to by strSrc (including the
+ * terminating null wide character) to the end of the wide string pointed to by strDest
+ * Parameter: strDest - destination address
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating wide character)
+ * Parameter: strSrc - source address
+ * Return: EOK if there was no runtime-constraint violation
+ */
+SECUREC_API errno_t wcscat_s(wchar_t *strDest, size_t destMax,
+ const wchar_t *strSrc);
+#endif
+
+#if SECUREC_ENABLE_STRNCAT
+/*
+ * Description: The wcsncat_s function appends not more than n successive wide characters (not including the
+ * terminating null wide character) from the array pointed to by strSrc to the end of the wide string pointed to
+ * by strDest.
+ * Parameter: strDest - destination address
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating wide character)
+ * Parameter: strSrc - source address
+ * Parameter: count - copies count wide characters from the src
+ * Return: EOK if there was no runtime-constraint violation
+ */
+SECUREC_API errno_t wcsncat_s(wchar_t *strDest, size_t destMax,
+ const wchar_t *strSrc, size_t count);
+#endif
+
+#if SECUREC_ENABLE_STRTOK
+/*
+ * Description: The wcstok_s function is the wide-character equivalent of the strtok_s function
+ * Parameter: strToken - the string to be delimited
+ * Parameter: strDelimit - specifies a set of characters that delimit the tokens in the parsed string
+ * Parameter: context - is a pointer to a char * variable that is used internally by strtok_s function
+ * Return: a pointer to the first character of a token, or a null pointer if there is no token
+ * or there is a runtime-constraint violation.
+ */
+SECUREC_API wchar_t *wcstok_s(wchar_t *strToken, const wchar_t *strDelimit,
+ wchar_t **context);
+#endif
+
+#if SECUREC_ENABLE_VSPRINTF
+/*
+ * Description: The vswprintf_s function is the wide-character equivalent of the vsprintf_s function
+ * Parameter: strDest - produce output according to a format,write to the character string strDest
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating null)
+ * Parameter: format - format string
+ * Parameter: argList - instead of a variable number of arguments
+ * Return: the number of characters printed(not including the terminating null wide character),
+ * If an error occurred Return: -1.
+ */
+SECUREC_API int vswprintf_s(wchar_t *strDest, size_t destMax,
+ const wchar_t *format, va_list argList);
+#endif
+
+#if SECUREC_ENABLE_SPRINTF
+/*
+ * Description: The swprintf_s function is the wide-character equivalent of the sprintf_s function
+ * Parameter: strDest - produce output according to a format,write to the character string strDest
+ * Parameter: destMax - The maximum length of destination buffer(including the terminating null)
+ * Parameter: format - format string
+ * Return: the number of characters printed(not including the terminating null wide character),
+ * If an error occurred Return: -1.
+ */
+SECUREC_API int swprintf_s(wchar_t *strDest, size_t destMax,
+ const wchar_t *format, ...);
+#endif
+
+#if SECUREC_ENABLE_FSCANF
+/*
+ * Description: The fwscanf_s function is the wide-character equivalent of the fscanf_s function
+ * Parameter: stream - stdio file stream
+ * Parameter: format - format string
+ * Return: the number of input items assigned, If an error occurred Return: -1.
+ */
+SECUREC_API int fwscanf_s(FILE *stream, const wchar_t *format, ...);
+#endif
+
+#if SECUREC_ENABLE_VFSCANF
+/*
+ * Description: The vfwscanf_s function is the wide-character equivalent of the vfscanf_s function
+ * Parameter: stream - stdio file stream
+ * Parameter: format - format string
+ * Parameter: argList - instead of a variable number of arguments
+ * Return: the number of input items assigned, If an error occurred Return: -1.
+ */
+SECUREC_API int vfwscanf_s(FILE *stream, const wchar_t *format,
+ va_list argList);
+#endif
+
+#if SECUREC_ENABLE_SCANF
+/*
+ * Description: The wscanf_s function is the wide-character equivalent of the scanf_s function
+ * Parameter: format - format string
+ * Return: the number of input items assigned, If an error occurred Return: -1.
+ */
+SECUREC_API int wscanf_s(const wchar_t *format, ...);
+#endif
+
+#if SECUREC_ENABLE_VSCANF
+/*
+ * Description: The vwscanf_s function is the wide-character equivalent of the vscanf_s function
+ * Parameter: format - format string
+ * Parameter: argList - instead of a variable number of arguments
+ * Return: the number of input items assigned, If an error occurred Return: -1.
+ */
+SECUREC_API int vwscanf_s(const wchar_t *format, va_list argList);
+#endif
+
+#if SECUREC_ENABLE_SSCANF
+/*
+ * Description: The swscanf_s function is the wide-character equivalent of the sscanf_s function
+ * Parameter: buffer - read character from buffer
+ * Parameter: format - format string
+ * Return: the number of input items assigned, If an error occurred Return: -1.
+ */
+SECUREC_API int swscanf_s(const wchar_t *buffer, const wchar_t *format, ...);
+#endif
+
+#if SECUREC_ENABLE_VSSCANF
+/*
+ * Description: The vswscanf_s function is the wide-character equivalent of the vsscanf_s function
+ * Parameter: buffer - read character from buffer
+ * Parameter: format - format string
+ * Parameter: argList - instead of a variable number of arguments
+ * Return: the number of input items assigned, If an error occurred Return: -1.
+ */
+SECUREC_API int vswscanf_s(const wchar_t *buffer, const wchar_t *format,
+ va_list argList);
+#endif
+#endif /* SECUREC_ENABLE_WCHAR_FUNC */
+#endif
+
+/* Those functions are used by macro,must declare hare, also for without function declaration warning */
+extern errno_t strncpy_error(char *strDest, size_t destMax, const char *strSrc,
+ size_t count);
+extern errno_t strcpy_error(char *strDest, size_t destMax, const char *strSrc);
+
+#if SECUREC_WITH_PERFORMANCE_ADDONS
+/* Those functions are used by macro */
+extern errno_t memset_sOptAsm(void *dest, size_t destMax, int c, size_t count);
+extern errno_t memset_sOptTc(void *dest, size_t destMax, int c, size_t count);
+extern errno_t memcpy_sOptAsm(void *dest, size_t destMax, const void *src,
+ size_t count);
+extern errno_t memcpy_sOptTc(void *dest, size_t destMax, const void *src,
+ size_t count);
+
+/* The strcpy_sp is a macro, not a function in performance optimization mode. */
+#define strcpy_sp(dest, destMax, src) \
+ ((__builtin_constant_p((destMax)) && __builtin_constant_p((src))) ? \
+ SECUREC_STRCPY_SM((dest), (destMax), (src)) : \
+ strcpy_s((dest), (destMax), (src)))
+
+/* The strncpy_sp is a macro, not a function in performance optimization mode. */
+#define strncpy_sp(dest, destMax, src, count) \
+ ((__builtin_constant_p((count)) && __builtin_constant_p((destMax)) && \
+ __builtin_constant_p((src))) ? \
+ SECUREC_STRNCPY_SM((dest), (destMax), (src), (count)) : \
+ strncpy_s((dest), (destMax), (src), (count)))
+
+/* The strcat_sp is a macro, not a function in performance optimization mode. */
+#define strcat_sp(dest, destMax, src) \
+ ((__builtin_constant_p((destMax)) && __builtin_constant_p((src))) ? \
+ SECUREC_STRCAT_SM((dest), (destMax), (src)) : \
+ strcat_s((dest), (destMax), (src)))
+
+/* The strncat_sp is a macro, not a function in performance optimization mode. */
+#define strncat_sp(dest, destMax, src, count) \
+ ((__builtin_constant_p((count)) && __builtin_constant_p((destMax)) && \
+ __builtin_constant_p((src))) ? \
+ SECUREC_STRNCAT_SM((dest), (destMax), (src), (count)) : \
+ strncat_s((dest), (destMax), (src), (count)))
+
+/* The memcpy_sp is a macro, not a function in performance optimization mode. */
+#define memcpy_sp(dest, destMax, src, count) \
+ (__builtin_constant_p((count)) ? \
+ (SECUREC_MEMCPY_SM((dest), (destMax), (src), (count))) : \
+ (__builtin_constant_p((destMax)) ? \
+ (((size_t)(destMax) > 0 && \
+ (((unsigned long long)(destMax) & \
+ (unsigned long long)(-2)) < \
+ SECUREC_MEM_MAX_LEN)) ? \
+ memcpy_sOptTc((dest), (destMax), (src), \
+ (count)) : \
+ ERANGE) : \
+ memcpy_sOptAsm((dest), (destMax), (src), (count))))
+
+/* The memset_sp is a macro, not a function in performance optimization mode. */
+#define memset_sp(dest, destMax, c, count) \
+ (__builtin_constant_p((count)) ? \
+ (SECUREC_MEMSET_SM((dest), (destMax), (c), (count))) : \
+ (__builtin_constant_p((destMax)) ? \
+ (((((unsigned long long)(destMax) & \
+ (unsigned long long)(-2)) < \
+ SECUREC_MEM_MAX_LEN)) ? \
+ memset_sOptTc((dest), (destMax), (c), \
+ (count)) : \
+ ERANGE) : \
+ memset_sOptAsm((dest), (destMax), (c), (count))))
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/include/securectype.h b/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/include/securectype.h
new file mode 100644
index 000000000..bf13f1556
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/include/securectype.h
@@ -0,0 +1,613 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2014-2021. All rights reserved.
+ * Licensed under Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ * http://license.coscl.org.cn/MulanPSL2
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
+ * See the Mulan PSL v2 for more details.
+ * Description: Define internal used macro and data type. The marco of SECUREC_ON_64BITS
+ * will be determined in this header file, which is a switch for part
+ * of code. Some macro are used to suppress warning by MS compiler.
+ * Create: 2014-02-25
+ * Notes: User can change the value of SECUREC_STRING_MAX_LEN and SECUREC_MEM_MAX_LEN
+ * macro to meet their special need, but The maximum value should not exceed 2G.
+ */
+/*
+ * [Standardize-exceptions]: Performance-sensitive
+ * [reason]: Strict parameter verification has been done before use
+ */
+
+#ifndef SECURECTYPE_H_A7BBB686_AADA_451B_B9F9_44DACDAE18A7
+#define SECURECTYPE_H_A7BBB686_AADA_451B_B9F9_44DACDAE18A7
+
+#ifndef SECUREC_USING_STD_SECURE_LIB
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+#if defined(__STDC_WANT_SECURE_LIB__) && (!__STDC_WANT_SECURE_LIB__)
+/* Security functions have been provided since vs2005, default use of system library functions */
+#define SECUREC_USING_STD_SECURE_LIB 0
+#else
+#define SECUREC_USING_STD_SECURE_LIB 1
+#endif
+#else
+#define SECUREC_USING_STD_SECURE_LIB 0
+#endif
+#endif
+
+/* Compatibility with older Secure C versions, shielding VC symbol redefinition warning */
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && (!SECUREC_USING_STD_SECURE_LIB)
+#ifndef SECUREC_DISABLE_CRT_FUNC
+#define SECUREC_DISABLE_CRT_FUNC 1
+#endif
+#ifndef SECUREC_DISABLE_CRT_IMP
+#define SECUREC_DISABLE_CRT_IMP 1
+#endif
+#else /* MSC VER */
+#ifndef SECUREC_DISABLE_CRT_FUNC
+#define SECUREC_DISABLE_CRT_FUNC 0
+#endif
+#ifndef SECUREC_DISABLE_CRT_IMP
+#define SECUREC_DISABLE_CRT_IMP 0
+#endif
+#endif
+
+#if SECUREC_DISABLE_CRT_FUNC
+#ifdef __STDC_WANT_SECURE_LIB__
+#undef __STDC_WANT_SECURE_LIB__
+#endif
+#define __STDC_WANT_SECURE_LIB__ 0
+#endif
+
+#if SECUREC_DISABLE_CRT_IMP
+#ifdef _CRTIMP_ALTERNATIVE
+#undef _CRTIMP_ALTERNATIVE
+#endif
+#define _CRTIMP_ALTERNATIVE /* Comment Microsoft *_s function */
+#endif
+
+/* Compile in kernel under macro control */
+#ifndef SECUREC_IN_KERNEL
+#ifdef __KERNEL__
+#define SECUREC_IN_KERNEL 1
+#else
+#define SECUREC_IN_KERNEL 0
+#endif
+#endif
+
+/* make kernel symbols of functions available to loadable modules */
+#ifndef SECUREC_EXPORT_KERNEL_SYMBOL
+#if SECUREC_IN_KERNEL
+#define SECUREC_EXPORT_KERNEL_SYMBOL 1
+#else
+#define SECUREC_EXPORT_KERNEL_SYMBOL 0
+#endif
+#endif
+
+#if SECUREC_IN_KERNEL
+#ifndef SECUREC_ENABLE_SCANF_FILE
+#define SECUREC_ENABLE_SCANF_FILE 0
+#endif
+#ifndef SECUREC_ENABLE_WCHAR_FUNC
+#define SECUREC_ENABLE_WCHAR_FUNC 0
+#endif
+#else /* SECUREC_IN_KERNEL */
+#ifndef SECUREC_ENABLE_SCANF_FILE
+#define SECUREC_ENABLE_SCANF_FILE 1
+#endif
+#ifndef SECUREC_ENABLE_WCHAR_FUNC
+#define SECUREC_ENABLE_WCHAR_FUNC 1
+#endif
+#endif
+
+/* Default secure function declaration, default declarations for non-standard functions */
+#ifndef SECUREC_SNPRINTF_TRUNCATED
+#define SECUREC_SNPRINTF_TRUNCATED 1
+#endif
+
+#if SECUREC_USING_STD_SECURE_LIB
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+/* Declare secure functions that are not available in the VS compiler */
+#ifndef SECUREC_ENABLE_MEMSET
+#define SECUREC_ENABLE_MEMSET 1
+#endif
+/* VS 2005 have vsnprintf_s function */
+#ifndef SECUREC_ENABLE_VSNPRINTF
+#define SECUREC_ENABLE_VSNPRINTF 0
+#endif
+#ifndef SECUREC_ENABLE_SNPRINTF
+/* VS 2005 have vsnprintf_s function Adapt the snprintf_s of the security function */
+#define snprintf_s _snprintf_s
+#define SECUREC_ENABLE_SNPRINTF 0
+#endif
+/* Before VS 2010 do not have v functions */
+#if _MSC_VER <= 1600 || defined(SECUREC_FOR_V_SCANFS)
+#ifndef SECUREC_ENABLE_VFSCANF
+#define SECUREC_ENABLE_VFSCANF 1
+#endif
+#ifndef SECUREC_ENABLE_VSCANF
+#define SECUREC_ENABLE_VSCANF 1
+#endif
+#ifndef SECUREC_ENABLE_VSSCANF
+#define SECUREC_ENABLE_VSSCANF 1
+#endif
+#endif
+
+#else /* MSC VER */
+#ifndef SECUREC_ENABLE_MEMSET
+#define SECUREC_ENABLE_MEMSET 0
+#endif
+#ifndef SECUREC_ENABLE_SNPRINTF
+#define SECUREC_ENABLE_SNPRINTF 0
+#endif
+#ifndef SECUREC_ENABLE_VSNPRINTF
+#define SECUREC_ENABLE_VSNPRINTF 0
+#endif
+#endif
+
+#ifndef SECUREC_ENABLE_MEMMOVE
+#define SECUREC_ENABLE_MEMMOVE 0
+#endif
+#ifndef SECUREC_ENABLE_MEMCPY
+#define SECUREC_ENABLE_MEMCPY 0
+#endif
+#ifndef SECUREC_ENABLE_STRCPY
+#define SECUREC_ENABLE_STRCPY 0
+#endif
+#ifndef SECUREC_ENABLE_STRNCPY
+#define SECUREC_ENABLE_STRNCPY 0
+#endif
+#ifndef SECUREC_ENABLE_STRCAT
+#define SECUREC_ENABLE_STRCAT 0
+#endif
+#ifndef SECUREC_ENABLE_STRNCAT
+#define SECUREC_ENABLE_STRNCAT 0
+#endif
+#ifndef SECUREC_ENABLE_SPRINTF
+#define SECUREC_ENABLE_SPRINTF 0
+#endif
+#ifndef SECUREC_ENABLE_VSPRINTF
+#define SECUREC_ENABLE_VSPRINTF 0
+#endif
+#ifndef SECUREC_ENABLE_SSCANF
+#define SECUREC_ENABLE_SSCANF 0
+#endif
+#ifndef SECUREC_ENABLE_VSSCANF
+#define SECUREC_ENABLE_VSSCANF 0
+#endif
+#ifndef SECUREC_ENABLE_SCANF
+#define SECUREC_ENABLE_SCANF 0
+#endif
+#ifndef SECUREC_ENABLE_VSCANF
+#define SECUREC_ENABLE_VSCANF 0
+#endif
+
+#ifndef SECUREC_ENABLE_FSCANF
+#define SECUREC_ENABLE_FSCANF 0
+#endif
+#ifndef SECUREC_ENABLE_VFSCANF
+#define SECUREC_ENABLE_VFSCANF 0
+#endif
+#ifndef SECUREC_ENABLE_STRTOK
+#define SECUREC_ENABLE_STRTOK 0
+#endif
+#ifndef SECUREC_ENABLE_GETS
+#define SECUREC_ENABLE_GETS 0
+#endif
+
+#else /* SECUREC USE STD SECURE LIB */
+
+#ifndef SECUREC_ENABLE_MEMSET
+#define SECUREC_ENABLE_MEMSET 1
+#endif
+#ifndef SECUREC_ENABLE_MEMMOVE
+#define SECUREC_ENABLE_MEMMOVE 1
+#endif
+#ifndef SECUREC_ENABLE_MEMCPY
+#define SECUREC_ENABLE_MEMCPY 1
+#endif
+#ifndef SECUREC_ENABLE_STRCPY
+#define SECUREC_ENABLE_STRCPY 1
+#endif
+#ifndef SECUREC_ENABLE_STRNCPY
+#define SECUREC_ENABLE_STRNCPY 1
+#endif
+#ifndef SECUREC_ENABLE_STRCAT
+#define SECUREC_ENABLE_STRCAT 1
+#endif
+#ifndef SECUREC_ENABLE_STRNCAT
+#define SECUREC_ENABLE_STRNCAT 1
+#endif
+#ifndef SECUREC_ENABLE_SPRINTF
+#define SECUREC_ENABLE_SPRINTF 1
+#endif
+#ifndef SECUREC_ENABLE_VSPRINTF
+#define SECUREC_ENABLE_VSPRINTF 1
+#endif
+#ifndef SECUREC_ENABLE_SNPRINTF
+#define SECUREC_ENABLE_SNPRINTF 1
+#endif
+#ifndef SECUREC_ENABLE_VSNPRINTF
+#define SECUREC_ENABLE_VSNPRINTF 1
+#endif
+#ifndef SECUREC_ENABLE_SSCANF
+#define SECUREC_ENABLE_SSCANF 1
+#endif
+#ifndef SECUREC_ENABLE_VSSCANF
+#define SECUREC_ENABLE_VSSCANF 1
+#endif
+#ifndef SECUREC_ENABLE_SCANF
+#if SECUREC_ENABLE_SCANF_FILE
+#define SECUREC_ENABLE_SCANF 1
+#else
+#define SECUREC_ENABLE_SCANF 0
+#endif
+#endif
+#ifndef SECUREC_ENABLE_VSCANF
+#if SECUREC_ENABLE_SCANF_FILE
+#define SECUREC_ENABLE_VSCANF 1
+#else
+#define SECUREC_ENABLE_VSCANF 0
+#endif
+#endif
+
+#ifndef SECUREC_ENABLE_FSCANF
+#if SECUREC_ENABLE_SCANF_FILE
+#define SECUREC_ENABLE_FSCANF 1
+#else
+#define SECUREC_ENABLE_FSCANF 0
+#endif
+#endif
+#ifndef SECUREC_ENABLE_VFSCANF
+#if SECUREC_ENABLE_SCANF_FILE
+#define SECUREC_ENABLE_VFSCANF 1
+#else
+#define SECUREC_ENABLE_VFSCANF 0
+#endif
+#endif
+
+#ifndef SECUREC_ENABLE_STRTOK
+#define SECUREC_ENABLE_STRTOK 1
+#endif
+#ifndef SECUREC_ENABLE_GETS
+#define SECUREC_ENABLE_GETS 1
+#endif
+#endif /* SECUREC_USE_STD_SECURE_LIB */
+
+#if !SECUREC_ENABLE_SCANF_FILE
+#if SECUREC_ENABLE_FSCANF
+#undef SECUREC_ENABLE_FSCANF
+#define SECUREC_ENABLE_FSCANF 0
+#endif
+#if SECUREC_ENABLE_VFSCANF
+#undef SECUREC_ENABLE_VFSCANF
+#define SECUREC_ENABLE_VFSCANF 0
+#endif
+#if SECUREC_ENABLE_SCANF
+#undef SECUREC_ENABLE_SCANF
+#define SECUREC_ENABLE_SCANF 0
+#endif
+#if SECUREC_ENABLE_FSCANF
+#undef SECUREC_ENABLE_FSCANF
+#define SECUREC_ENABLE_FSCANF 0
+#endif
+
+#endif
+
+#if SECUREC_IN_KERNEL
+#include
+#include
+#else
+#ifndef SECUREC_HAVE_STDIO_H
+#define SECUREC_HAVE_STDIO_H 1
+#endif
+#ifndef SECUREC_HAVE_STRING_H
+#define SECUREC_HAVE_STRING_H 1
+#endif
+#ifndef SECUREC_HAVE_STDLIB_H
+#define SECUREC_HAVE_STDLIB_H 1
+#endif
+#if SECUREC_HAVE_STDIO_H
+#include
+#endif
+#if SECUREC_HAVE_STRING_H
+#include
+#endif
+#if SECUREC_HAVE_STDLIB_H
+#include
+#endif
+#endif
+
+/*
+ * If you need high performance, enable the SECUREC_WITH_PERFORMANCE_ADDONS macro, default is enable.
+ * The macro is automatically closed on the windows platform and linux kernel
+ */
+#ifndef SECUREC_WITH_PERFORMANCE_ADDONS
+#if SECUREC_IN_KERNEL
+#define SECUREC_WITH_PERFORMANCE_ADDONS 0
+#else
+#define SECUREC_WITH_PERFORMANCE_ADDONS 1
+#endif
+#endif
+
+/* If enable SECUREC_COMPATIBLE_WIN_FORMAT, the output format will be compatible to Windows. */
+#if (defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER)) && \
+ !defined(SECUREC_COMPATIBLE_LINUX_FORMAT)
+#ifndef SECUREC_COMPATIBLE_WIN_FORMAT
+#define SECUREC_COMPATIBLE_WIN_FORMAT
+#endif
+#endif
+
+#if defined(SECUREC_COMPATIBLE_WIN_FORMAT)
+/* On windows platform, can't use optimized function for there is no __builtin_constant_p like function */
+/* If need optimized macro, can define this: define __builtin_constant_p(x) 0 */
+#ifdef SECUREC_WITH_PERFORMANCE_ADDONS
+#undef SECUREC_WITH_PERFORMANCE_ADDONS
+#define SECUREC_WITH_PERFORMANCE_ADDONS 0
+#endif
+#endif
+
+#if defined(__VXWORKS__) || defined(__vxworks) || defined(__VXWORKS) || \
+ defined(_VXWORKS_PLATFORM_) || defined(SECUREC_VXWORKS_VERSION_5_4)
+#ifndef SECUREC_VXWORKS_PLATFORM
+#define SECUREC_VXWORKS_PLATFORM
+#endif
+#endif
+
+/* If enable SECUREC_COMPATIBLE_LINUX_FORMAT, the output format will be compatible to Linux. */
+#if !defined(SECUREC_COMPATIBLE_WIN_FORMAT) && \
+ !defined(SECUREC_VXWORKS_PLATFORM)
+#ifndef SECUREC_COMPATIBLE_LINUX_FORMAT
+#define SECUREC_COMPATIBLE_LINUX_FORMAT
+#endif
+#endif
+
+#ifdef SECUREC_COMPATIBLE_LINUX_FORMAT
+#ifndef SECUREC_HAVE_STDDEF_H
+#define SECUREC_HAVE_STDDEF_H 1
+#endif
+/* Some system may no stddef.h */
+#if SECUREC_HAVE_STDDEF_H
+#if !SECUREC_IN_KERNEL
+#include
+#endif
+#endif
+#endif
+
+/*
+ * Add the -DSECUREC_SUPPORT_FORMAT_WARNING=1 compiler option to supoort -Wformat=2.
+ * Default does not check the format is that the same data type in the actual code.
+ * In the product is different in the original data type definition of VxWorks and Linux.
+ */
+#ifndef SECUREC_SUPPORT_FORMAT_WARNING
+#define SECUREC_SUPPORT_FORMAT_WARNING 0
+#endif
+
+#if SECUREC_SUPPORT_FORMAT_WARNING
+#define SECUREC_ATTRIBUTE(x, y) __attribute__((format(printf, (x), (y))))
+#else
+#define SECUREC_ATTRIBUTE(x, y)
+#endif
+
+/*
+ * Add the -DSECUREC_SUPPORT_BUILTIN_EXPECT=0 compiler option, if compiler can not support __builtin_expect.
+ */
+#ifndef SECUREC_SUPPORT_BUILTIN_EXPECT
+#define SECUREC_SUPPORT_BUILTIN_EXPECT 1
+#endif
+
+#if SECUREC_SUPPORT_BUILTIN_EXPECT && defined(__GNUC__) && \
+ ((__GNUC__ > 3) || \
+ (defined(__GNUC_MINOR__) && (__GNUC__ == 3 && __GNUC_MINOR__ > 3)))
+/*
+ * This is a built-in function that can be used without a declaration, if warning for declaration not found occurred,
+ * you can add -DSECUREC_NEED_BUILTIN_EXPECT_DECLARE to compiler options
+ */
+#ifdef SECUREC_NEED_BUILTIN_EXPECT_DECLARE
+long __builtin_expect(long exp, long c);
+#endif
+
+#define SECUREC_LIKELY(x) __builtin_expect(!!(x), 1)
+#define SECUREC_UNLIKELY(x) __builtin_expect(!!(x), 0)
+#else
+#define SECUREC_LIKELY(x) (x)
+#define SECUREC_UNLIKELY(x) (x)
+#endif
+
+/* Define the max length of the string */
+#ifndef SECUREC_STRING_MAX_LEN
+#define SECUREC_STRING_MAX_LEN 0x7fffffffUL
+#endif
+#define SECUREC_WCHAR_STRING_MAX_LEN (SECUREC_STRING_MAX_LEN / sizeof(wchar_t))
+
+/* Add SECUREC_MEM_MAX_LEN for memcpy and memmove */
+#ifndef SECUREC_MEM_MAX_LEN
+#define SECUREC_MEM_MAX_LEN 0x7fffffffUL
+#endif
+#define SECUREC_WCHAR_MEM_MAX_LEN (SECUREC_MEM_MAX_LEN / sizeof(wchar_t))
+
+#if SECUREC_STRING_MAX_LEN > 0x7fffffffUL
+#error "max string is 2G"
+#endif
+
+#if (defined(__GNUC__) && defined(__SIZEOF_POINTER__))
+#if (__SIZEOF_POINTER__ != 4) && (__SIZEOF_POINTER__ != 8)
+#error "unsupported system"
+#endif
+#endif
+
+#if defined(_WIN64) || defined(WIN64) || defined(__LP64__) || defined(_LP64)
+#define SECUREC_ON_64BITS
+#endif
+
+#if (!defined(SECUREC_ON_64BITS) && defined(__GNUC__) && \
+ defined(__SIZEOF_POINTER__))
+#if __SIZEOF_POINTER__ == 8
+#define SECUREC_ON_64BITS
+#endif
+#endif
+
+#if defined(__SVR4) || defined(__svr4__)
+#define SECUREC_ON_SOLARIS
+#endif
+
+#if (defined(__hpux) || defined(_AIX) || defined(SECUREC_ON_SOLARIS))
+#define SECUREC_ON_UNIX
+#endif
+
+/*
+ * Codes should run under the macro SECUREC_COMPATIBLE_LINUX_FORMAT in unknown system on default,
+ * and strtold.
+ * The function strtold is referenced first at ISO9899:1999(C99), and some old compilers can
+ * not support these functions. Here provides a macro to open these functions:
+ * SECUREC_SUPPORT_STRTOLD -- If defined, strtold will be used
+ */
+#ifndef SECUREC_SUPPORT_STRTOLD
+#define SECUREC_SUPPORT_STRTOLD 0
+#if (defined(SECUREC_COMPATIBLE_LINUX_FORMAT))
+#if defined(__USE_ISOC99) || (defined(_AIX) && defined(_ISOC99_SOURCE)) || \
+ (defined(__hpux) && defined(__ia64)) || \
+ (defined(SECUREC_ON_SOLARIS) && \
+ (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
+ defined(_STDC_C99) || defined(__EXTENSIONS__))
+#undef SECUREC_SUPPORT_STRTOLD
+#define SECUREC_SUPPORT_STRTOLD 1
+#endif
+#endif
+#if ((defined(SECUREC_WRLINUX_BELOW4) || defined(_WRLINUX_BELOW4_)))
+#undef SECUREC_SUPPORT_STRTOLD
+#define SECUREC_SUPPORT_STRTOLD 0
+#endif
+#endif
+
+#if SECUREC_WITH_PERFORMANCE_ADDONS
+
+#ifndef SECUREC_TWO_MIN
+#define SECUREC_TWO_MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+/* For strncpy_s performance optimization */
+#define SECUREC_STRNCPY_SM(dest, destMax, src, count) \
+ (((void *)(dest) != NULL && (const void *)(src) != NULL && \
+ (size_t)(destMax) > 0 && \
+ (((unsigned long long)(destMax) & (unsigned long long)(-2)) < \
+ SECUREC_STRING_MAX_LEN) && \
+ (SECUREC_TWO_MIN((size_t)(count), strlen(src)) + 1) <= \
+ (size_t)(destMax)) ? \
+ (((size_t)(count) < strlen(src)) ? \
+ (memcpy((dest), (src), (count)), \
+ *((char *)(dest) + (count)) = '\0', EOK) : \
+ (memcpy((dest), (src), strlen(src) + 1), EOK)) : \
+ (strncpy_error((dest), (destMax), (src), (count))))
+
+#define SECUREC_STRCPY_SM(dest, destMax, src) \
+ (((void *)(dest) != NULL && (const void *)(src) != NULL && \
+ (size_t)(destMax) > 0 && \
+ (((unsigned long long)(destMax) & (unsigned long long)(-2)) < \
+ SECUREC_STRING_MAX_LEN) && \
+ (strlen(src) + 1) <= (size_t)(destMax)) ? \
+ (memcpy((dest), (src), strlen(src) + 1), EOK) : \
+ (strcpy_error((dest), (destMax), (src))))
+
+/* For strcat_s performance optimization */
+#if defined(__GNUC__)
+#define SECUREC_STRCAT_SM(dest, destMax, src) \
+ ({ \
+ int catRet_ = EOK; \
+ if ((void *)(dest) != NULL && (const void *)(src) != NULL && \
+ (size_t)(destMax) > 0 && \
+ (((unsigned long long)(destMax) & \
+ (unsigned long long)(-2)) < SECUREC_STRING_MAX_LEN)) { \
+ char *catTmpDst_ = (char *)(dest); \
+ size_t catRestSize_ = (destMax); \
+ while (catRestSize_ > 0 && *catTmpDst_ != '\0') { \
+ ++catTmpDst_; \
+ --catRestSize_; \
+ } \
+ if (catRestSize_ == 0) { \
+ catRet_ = EINVAL; \
+ } else if ((strlen(src) + 1) <= catRestSize_) { \
+ memcpy(catTmpDst_, (src), strlen(src) + 1); \
+ catRet_ = EOK; \
+ } else { \
+ catRet_ = ERANGE; \
+ } \
+ if (catRet_ != EOK) { \
+ catRet_ = strcat_s((dest), (destMax), (src)); \
+ } \
+ } else { \
+ catRet_ = strcat_s((dest), (destMax), (src)); \
+ } \
+ catRet_; \
+ })
+#else
+#define SECUREC_STRCAT_SM(dest, destMax, src) strcat_s((dest), (destMax), (src))
+#endif
+
+/* For strncat_s performance optimization */
+#if defined(__GNUC__)
+#define SECUREC_STRNCAT_SM(dest, destMax, src, count) \
+ ({ \
+ int ncatRet_ = EOK; \
+ if ((void *)(dest) != NULL && (const void *)(src) != NULL && \
+ (size_t)(destMax) > 0 && \
+ (((unsigned long long)(destMax) & \
+ (unsigned long long)(-2)) < SECUREC_STRING_MAX_LEN) && \
+ (((unsigned long long)(count) & \
+ (unsigned long long)(-2)) < SECUREC_STRING_MAX_LEN)) { \
+ char *ncatTmpDest_ = (char *)(dest); \
+ size_t ncatRestSize_ = (size_t)(destMax); \
+ while (ncatRestSize_ > 0 && *ncatTmpDest_ != '\0') { \
+ ++ncatTmpDest_; \
+ --ncatRestSize_; \
+ } \
+ if (ncatRestSize_ == 0) { \
+ ncatRet_ = EINVAL; \
+ } else if ((SECUREC_TWO_MIN((count), strlen(src)) + \
+ 1) <= ncatRestSize_) { \
+ if ((size_t)(count) < strlen(src)) { \
+ memcpy(ncatTmpDest_, (src), (count)); \
+ *(ncatTmpDest_ + (count)) = '\0'; \
+ } else { \
+ memcpy(ncatTmpDest_, (src), \
+ strlen(src) + 1); \
+ } \
+ } else { \
+ ncatRet_ = ERANGE; \
+ } \
+ if (ncatRet_ != EOK) { \
+ ncatRet_ = strncat_s((dest), (destMax), (src), \
+ (count)); \
+ } \
+ } else { \
+ ncatRet_ = \
+ strncat_s((dest), (destMax), (src), (count)); \
+ } \
+ ncatRet_; \
+ })
+#else
+#define SECUREC_STRNCAT_SM(dest, destMax, src, count) \
+ strncat_s((dest), (destMax), (src), (count))
+#endif
+
+/* This macro do not check buffer overlap by default */
+#define SECUREC_MEMCPY_SM(dest, destMax, src, count) \
+ (!(((size_t)(destMax) == 0) || \
+ (((unsigned long long)(destMax) & (unsigned long long)(-2)) > \
+ SECUREC_MEM_MAX_LEN) || \
+ ((size_t)(count) > (size_t)(destMax)) || \
+ ((void *)(dest)) == NULL || ((const void *)(src) == NULL)) ? \
+ (memcpy((dest), (src), (count)), EOK) : \
+ (memcpy_s((dest), (destMax), (src), (count))))
+
+#define SECUREC_MEMSET_SM(dest, destMax, c, count) \
+ (!((((unsigned long long)(destMax) & (unsigned long long)(-2)) > \
+ SECUREC_MEM_MAX_LEN) || \
+ ((void *)(dest) == NULL) || \
+ ((size_t)(count) > (size_t)(destMax))) ? \
+ (memset((dest), (c), (count)), EOK) : \
+ (memset_s((dest), (destMax), (c), (count))))
+
+#endif
+#endif
diff --git a/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/patch/adapt_implicit_fallthrough_level5.patch b/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/patch/adapt_implicit_fallthrough_level5.patch
new file mode 100644
index 000000000..cbd74bd8d
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/patch/adapt_implicit_fallthrough_level5.patch
@@ -0,0 +1,20 @@
+diff --git a/platform/huawei_secure_c/src/securecutil.h b/platform/huawei_secure_c/src/securecutil.h
+index 459647ec2ab..b624e6e575a 100644
+--- a/platform/huawei_secure_c/src/securecutil.h
++++ b/platform/huawei_secure_c/src/securecutil.h
+@@ -553,15 +553,11 @@ typedef struct {
+ #define SECUREC_ERROR_BUFFER_OVERLAP(msg)
+ #endif
+
+-#if defined(__clang__)
+ #ifndef fallthrough
+ #define FALLTHROUGH __attribute__((fallthrough))
+ #else
+ #define FALLTHROUGH fallthrough
+ #endif
+-#else
+-#define FALLTHROUGH
+-#endif /* __clang__ */
+
+ #ifdef __cplusplus
+ extern "C" {
diff --git a/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/Makefile b/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/Makefile
new file mode 100644
index 000000000..6513bc423
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/Makefile
@@ -0,0 +1,196 @@
+######
+### This is a sample file for linux platform, please write the Makefile according to the actual situation of the product
+### If you want to create a shared library, use the command:"make"
+### If you want to create a static library, use the command:"make lib"
+### If you want to create a .ko file, use the command:"make kernel"
+### If you want to filter out unsupported compiler options, add the command:"CHECK_OPTION=check"
+######
+
+PROJECT=libsecurec.so
+#if you need a debug version library, use "-g" instead of "-s -DNDEBUG -O2".
+# If you compiler report a warning on "break strict-aliasing rules", there is no problem. If you need to clear all warnings, you can add "-fno-strict-aliasing" option to your compiler, but this will impact the performance a little.
+CC?=gcc
+
+#for linux secure compile options from stdandard 2018.8
+SECURE_CFLAG_FOR_SHARED_LIBRARY = -fPIC
+SECURE_LDFLAG_FOR_SHARED_LIBRARY += -s
+SECURE_LDFLAG_FOR_SHARED_LIBRARY += -Wl,-z,relro,-z,now,-z,noexecstack
+#This option ensure forced links to functions in the library. If these functions are already contained in other libraries, cross-calls will occur
+#SECURE_LDFLAG_FOR_SHARED_LIBRARY += -Wl,-Bsymbolic
+
+
+GCC_HAVE_STRONG=$(shell $(CC) -fstack-protector-strong -E -dM - < /dev/null 2>&1 |grep -- "fstack-protector-strong" >/dev/null ;if [ $$? -ne 0 ] ;then echo yes;fi)
+ifeq ($(GCC_HAVE_STRONG),yes)
+SECURE_CFLAG_FOR_SHARED_LIBRARY += -fstack-protector-strong
+else
+SECURE_CFLAG_FOR_SHARED_LIBRARY += -fstack-protector-all
+endif
+
+
+#-fvisibility=hidden need modify source code
+#SECURE_CFLAG_FOR_SHARED_LIBRARY_OPTIONAL += -fvisibility=hidden
+
+#-ftrapv -D_FORTIFY_SOURCE=2 -fstack-check May result in performance degradation after opening
+SECURE_CFLAG_FOR_SHARED_LIBRARY_OPTIONAL += -D_FORTIFY_SOURCE=2 -O2
+#SECURE_CFLAG_FOR_SHARED_LIBRARY_OPTIONAL += -ftrapv
+#SECURE_CFLAG_FOR_SHARED_LIBRARY_OPTIONAL += -fstack-check
+
+
+SECURE_CFLAG_FOR_SHARED_LIBRARY_OPTIONAL += -Wformat=2 -Wfloat-equal -Wshadow
+# about pie option , We compiled a dynamic library, so we did not use it. ,If you want to compile executable files, please open this option
+#SECURE_CFLAG_FOR_EXE = -fPIE -pie
+
+
+
+## code standard options
+SECUREC_CODE_STANDARD_OPTION = -Wconversion
+SECUREC_CODE_STANDARD_OPTION += -Wformat-security
+SECUREC_CODE_STANDARD_OPTION += -Wextra
+SECUREC_CODE_STANDARD_OPTION += --param ssp-buffer-size=4
+
+#repeat options
+#SECUREC_CODE_STANDARD_OPTION += -D_FORTIFY_SOURCE=2
+#SECUREC_CODE_STANDARD_OPTION += -Wl,-z,relro,-z,now
+#SECUREC_CODE_STANDARD_OPTION += -fstack-protector
+
+#from product options
+PRODUCT_OPTION_FOR_SELECTION = -Warray-bounds
+PRODUCT_OPTION_FOR_SELECTION += -Wpointer-arith
+PRODUCT_OPTION_FOR_SELECTION += -Wcast-qual
+PRODUCT_OPTION_FOR_SELECTION += -Wstrict-prototypes
+PRODUCT_OPTION_FOR_SELECTION += -Wmissing-prototypes
+PRODUCT_OPTION_FOR_SELECTION += -Wstrict-overflow=1
+PRODUCT_OPTION_FOR_SELECTION += -Wstrict-aliasing=2
+PRODUCT_OPTION_FOR_SELECTION += -Wswitch -Wswitch-default
+PRODUCT_OPTION_FOR_SELECTION += -Wdate-time
+PRODUCT_OPTION_FOR_SELECTION += -Wdisabled-optimization
+PRODUCT_OPTION_FOR_SELECTION += -Wduplicated-branches
+PRODUCT_OPTION_FOR_SELECTION += -Wduplicated-cond
+PRODUCT_OPTION_FOR_SELECTION += -Wignored-qualifiers
+PRODUCT_OPTION_FOR_SELECTION += -Wimplicit-fallthrough=3
+PRODUCT_OPTION_FOR_SELECTION += -Wmissing-include-dirs
+PRODUCT_OPTION_FOR_SELECTION += -Wshift-negative-value
+PRODUCT_OPTION_FOR_SELECTION += -Wsign-compare
+PRODUCT_OPTION_FOR_SELECTION += -Wtrampolines
+PRODUCT_OPTION_FOR_SELECTION += -Wtype-limits
+PRODUCT_OPTION_FOR_SELECTION += -Wwrite-strings
+PRODUCT_OPTION_FOR_SELECTION += -Werror
+PRODUCT_OPTION_FOR_SELECTION += -Wunused-macros
+PRODUCT_OPTION_FOR_SELECTION += -Wshift-overflow=2
+PRODUCT_OPTION_FOR_SELECTION += -Wnested-externs
+PRODUCT_OPTION_FOR_SELECTION += -Wlogical-op
+PRODUCT_OPTION_FOR_SELECTION += -Wjump-misses-init
+PRODUCT_OPTION_FOR_SELECTION += -Wvla
+PRODUCT_OPTION_FOR_SELECTION += -Wframe-larger-than=4096
+PRODUCT_OPTION_FOR_SELECTION += -Wsuggest-attribute=format
+PRODUCT_OPTION_FOR_SELECTION += -Wmissing-format-attribute
+PRODUCT_OPTION_FOR_SELECTION += # -fno-inline-small-functions -fno-indirect-inlining -fno-inline-functions-called-once -fno-early-inlining -fno-inline
+PRODUCT_OPTION_FOR_SELECTION += # -ftrapv
+
+ifeq ($(CHECK_OPTION),check)
+PRODUCT_OPTION := $(shell touch tmp.c; echo "int main(void){return 0;}" > tmp.c; \
+ for loop in $(PRODUCT_OPTION_FOR_SELECTION); \
+ do err=$$({ `$(CC) $$loop -I../include -c tmp.c >/dev/null`; } 2>&1);\
+ echo $${err} | grep ^clang:.w.*ted\]$$ > /dev/null 2>&1;\
+ if [ $$? = 0 ] || [ "X$${err}" = "X" ];then echo "$$loop";fi;\
+ done;\
+ if [ -f tmp.o ];then rm tmp.o;fi;\
+ if [ -f tmp.c ];then rm tmp.c;fi;)
+else
+PRODUCT_OPTION := $(PRODUCT_OPTION_FOR_SELECTION)
+endif
+
+CFLAG = -Wall -DNDEBUG -O2 $(SECURE_CFLAG_FOR_SHARED_LIBRARY) $(SECURE_CFLAG_FOR_EXE) $(SECURE_CFLAG_FOR_SHARED_LIBRARY_OPTIONAL) $(SECUREC_CODE_STANDARD_OPTION) $(PRODUCT_OPTION)
+#CFLAG += -DSECUREC_VXWORKS_PLATFORM
+#CFLAG += -DSECUREC_SUPPORT_STRTOLD
+#CFLAG += -DSECUREC_VXWORKS_VERSION_5_4
+#CFLAG += -D__STDC_WANT_LIB_EXT1__=0
+CFLAG += $(CFLAG_EXT)
+
+ARCH:=$(shell getconf LONG_BIT)
+
+ifeq ($(MAKECMDGOALS),lib)
+#Set static library related options
+CFLAG :=$(filter-out "xxxxx",$(CFLAG))
+endif
+
+#SOURCES=$(wildcard *.c)
+SOURCES = fscanf_s.c gets_s.c memcpy_s.c memmove_s.c memset_s.c scanf_s.c securecutil.c secureinput_a.c secureprintoutput_a.c snprintf_s.c sprintf_s.c sscanf_s.c strcat_s.c strcpy_s.c strncat_s.c strncpy_s.c strtok_s.c vfscanf_s.c vscanf_s.c vsnprintf_s.c vsprintf_s.c vsscanf_s.c
+
+SOURCES += fwscanf_s.c secureinput_w.c secureprintoutput_w.c swprintf_s.c swscanf_s.c vfwscanf_s.c vswprintf_s.c vswscanf_s.c vwscanf_s.c wcscat_s.c wcscpy_s.c wcsncat_s.c wcsncpy_s.c wcstok_s.c wmemcpy_s.c wmemmove_s.c wscanf_s.c
+
+OBJECTS=$(patsubst %.c,%.o,$(SOURCES))
+
+.PHONY:clean lib kernel
+
+ENABLE_SCANF_FILE=$(findstring SECUREC_ENABLE_SCANF_FILE=0,$(CFLAG))
+ifeq ($(ENABLE_SCANF_FILE),SECUREC_ENABLE_SCANF_FILE=0)
+OBJECTS:=$(filter-out fscanf_s.o vfscanf_s.o vscanf_s.o scanf_s.o vwscanf_s.o wscanf_s.o fwscanf_s.o vfwscanf_s.o,$(OBJECTS))
+endif
+
+
+ifneq ($(CFLAGS),)
+CFLAG :=$(CFLAGS)
+endif
+CFLAG += -I../include
+LD_FLAG ?= $(SECURE_LDFLAG_FOR_SHARED_LIBRARY) $(SECURE_CFLAG_FOR_SHARED_LIBRARY)
+AR ?=ar
+RANLIB ?=ranlib
+
+$(PROJECT): note_msg $(OBJECTS)
+ @mkdir -p ../obj
+ mkdir -p ../lib
+ $(CC) -shared -o ../lib/$@ $(patsubst %.o,../obj/%.o,$(OBJECTS)) $(LD_FLAG)
+ @echo "finish $(PROJECT)"
+ #you may add you custom commands here
+
+lib: note_msg $(OBJECTS)
+ $(AR) crv libsecurec.a $(patsubst %.o,../obj/%.o,$(OBJECTS))
+ $(RANLIB) libsecurec.a
+ -mkdir -p ../lib
+ -cp libsecurec.a ../lib
+ @echo "finish libsecurec.a"
+ #you may add you custom commands here
+.c.o:
+ @mkdir -p ../obj
+ $(CC) -c $< $(CFLAG) -o ../obj/$(patsubst %.c,%.o,$<)
+
+EXTRA_CFLAGS += -I$(INCDIR) -fstack-protector $(CFLAG_EXT)
+
+# provide the default value to module name and ccflags-y
+ifeq ($(MODULE),)
+ MODULE := ksecurec
+endif
+ifeq ($(DEBUG),y)
+ ccflags-y += -DDEBUG
+endif
+
+ifneq ($(KERNELRELEASE),)
+ obj-m := ksecurec.o
+ifeq ($(SECUREC_KERNEL_ALL),)
+ #ksecurec-objs := memcpy_s.o memmove_s.o memset_s.o securecutil.o strcat_s.o strcpy_s.o strncat_s.o strncpy_s.o
+ ksecurec-objs := memcpy_s.o memmove_s.o memset_s.o securecutil.o strcat_s.o strcpy_s.o strncat_s.o strncpy_s.o sprintf_s.o vsprintf_s.o snprintf_s.o vsnprintf_s.o secureprintoutput_a.o sscanf_s.o vsscanf_s.o secureinput_a.o strtok_s.o
+else
+ ksecurec-objs := memcpy_s.o memmove_s.o memset_s.o securecutil.o strcat_s.o strcpy_s.o strncat_s.o strncpy_s.o sprintf_s.o vsprintf_s.o snprintf_s.o vsnprintf_s.o secureprintoutput_a.o sscanf_s.o vsscanf_s.o secureinput_a.o strtok_s.o
+endif
+else
+ KERNELDIR := /lib/modules/$(shell uname -r)/build
+ PWD := $(shell pwd)
+kernel: note_msg
+ $(MAKE) -C $(KERNELDIR) M=$(PWD) INCDIR=$(PWD)/../include modules
+endif
+
+NOTE_MSG:='\n'
+NOTE_MSG+='---------------------------------------------------------\n'
+NOTE_MSG+='+ This Makefile is a sample file, do not use in product +\n'
+NOTE_MSG+='---------------------------------------------------------\n'
+
+note_msg:
+ -@echo -e $(NOTE_MSG)
+
+clean:
+ @echo "cleaning ...."
+ -rm modules.order Module.symvers $(MODULE).ko $(MODULE).mod.c $(MODULE).mod.o $(MODULE).o *.o
+ -rm -rf ../obj ../lib
+ @echo "clean up"
+
diff --git a/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/fscanf_s.c b/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/fscanf_s.c
new file mode 100644
index 000000000..05e1e724c
--- /dev/null
+++ b/drivers/net/ethernet/huawei/hinic5/platform/huawei_secure_c/src/fscanf_s.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd. 2014-2021. All rights reserved.
+ * Licensed under Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ * http://license.coscl.org.cn/MulanPSL2
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
+ * See the Mulan PSL v2 for more details.
+ * Description: fscanf_s function
+ * Create: 2014-02-25
+ */
+
+#include "securec.h"
+
+/*
+ *
+ * The fscanf_s function is equivalent to fscanf except that the c, s,
+ * and [ conversion specifiers apply to a pair of arguments (unless assignment suppression is indicated by a*)
+ * The fscanf function reads data from the current position of stream into
+ * the locations given by argument (if any). Each argument must be a pointer
+ * to a variable of a type that corresponds to a type specifier in format.
+ * format controls the interpretation of the input fields and has the same
+ * form and function as the format argument for scanf.
+ *
+ *
+ * stream Pointer to FILE structure.
+ * format Format control string, see Format Specifications.
+ * ... Optional arguments.
+ *
+ *