高级搜索

留言板

尊敬的读者、作者、审稿人, 关于本刊的投稿、审稿、编辑和出版的任何问题, 您可以本页添加留言。我们将尽快给您答复。谢谢您的支持!

姓名
邮箱
手机号码
标题
留言内容
验证码

面向国产交换芯片的多模态网络后端编译器设计

凃化清 王元鸿 徐琪 朱俊 邹涛 隆克平

凃化清, 王元鸿, 徐琪, 朱俊, 邹涛, 隆克平. 面向国产交换芯片的多模态网络后端编译器设计[J]. 电子与信息学报. doi: 10.11999/JEIT250132
引用本文: 凃化清, 王元鸿, 徐琪, 朱俊, 邹涛, 隆克平. 面向国产交换芯片的多模态网络后端编译器设计[J]. 电子与信息学报. doi: 10.11999/JEIT250132
TU Huaqing, WANG Yuanhong, XU Qi, ZHU Jun, ZOU Tao, LONG Keping. A Polymorphic Network Backend Compiler for Domestic Switching Chips[J]. Journal of Electronics & Information Technology. doi: 10.11999/JEIT250132
Citation: TU Huaqing, WANG Yuanhong, XU Qi, ZHU Jun, ZOU Tao, LONG Keping. A Polymorphic Network Backend Compiler for Domestic Switching Chips[J]. Journal of Electronics & Information Technology. doi: 10.11999/JEIT250132

面向国产交换芯片的多模态网络后端编译器设计

doi: 10.11999/JEIT250132 cstr: 32379.14.JEIT250132
基金项目: 国家重点研发计划项目(2022YFB2901503),国家自然科学基金项目(U22A2005),浙江省重点研发计划项目(2024SSYS0001),中国博士后科学基金项目(2024M75986)。
详细信息
    作者简介:

    凃化清:女,博士后,研究方向为软件定义网络、可编程数据平面、多模态网络等

    王元鸿:男,硕士,研究方向为多模态网络、可编程网络

    徐琪:男,副研究员,研究方向为多模态网络、软件定义网络、时间敏感网络

    朱俊:男,高级工程师,研究方向为新型网络体系结构、软件定义网络、网络资源管理、网络协议设计优化等

    邹涛:男,研究员,研究方向为多模态网络技术和新型网络体系结构

    隆克平:男,教授,研究方向为新一代网络技术、光互联网关键技术、无线通信技术、人工智能与大数据

    通讯作者:

    邹涛, zout@zhejianglab.org

  • 中图分类号: TN393

A Polymorphic Network Backend Compiler for Domestic Switching Chips

Funds: National Key Research and Development Project of China (No. 2022YFB2901503), National Natural Science Foundation of China (No. U22A2005), Key R&D Program of Zhejiang (2024SSYS0001), China Postdoctoral Science Foundation (No. 2024M75986).
  • 摘要: 当前,后端编译器相关工作主要针对软件可编程交换机(BMv2)、现场可编程门阵列(FPGA)、Intel Tofino系列芯片等可编程设备进行设计和优化,不适用于国产盛科TsingMa.MX交换芯片上多模态网络程序的编译。为此,本文提出面向TsingMa.MX交换芯片的多模态网络后端编译器p4c-TsingMa,实现了高级网络编程语言到TsingMa.MX交换芯片的编译,使TsingMa.MX交换芯片同时支持多种网络模态报文的解析与转发。p4c-TsingMa首先使用先序遍历方法从中间表示中提取出协议类型、协议字段、动作等关键信息,然后根据所提取的信息进行指令转译,最终生成TsingMa.MX芯片控制命令。同时,p4c-TsingMa采用用户自定义字段(UDF)合并方法,将不同网络模态的匹配指令合并在一个查找表中,从而一次提取多个模态的匹配项,提高芯片资源利用率。实验结果表明,p4c-TsingMa可实现对多种网络模态程序的正确编译,相较于未启用 UDF 表项合并算法、单端口独立配置各模态UDF规则的场景,其可将寄存器资源利用率提升37.5%~75%。
  • 图  1  后端编译器p4c-TsingMa.MX的整体架构

    图  2  P4源程序及IR比较

    图  3  UDF指令转译过程

    图  4  关键字具体位分布图

    图  5  FlexEdit指令转译过程

    图  6  测试环境拓扑

    图  7  流表文件

    图  8  端口流量分析图

    表  1  不同编译方法对比

    目标平台 编译方法 IR解析策略 硬件映射逻辑 核心优化方向

    BMv2
    P4LLVM[16] 利用底层虚拟机框架解析P4代码,
    提取可通过底层虚拟机优化通道
    处理的网络程序逻辑
    生成JSON格式输出,借助底层虚拟机的
    通用优化能力提升网络程序效率
    为软件交换机bmv2提供专用后端编译支持

    FPGA
    P4FPGA[18] 解析P4代码并提取适合FPGA硬件实现的并行、高性能逻辑 生成Verilog代码,简化FPGA开发,融合 P4 的灵活性与 FPGA 的高性能 借助底层虚拟机优化通道提升网络程序执行效率

    Tofino
    Chipmunk[17] 解析P4代码并进行多层级编译处理,抽象掉Tofino硬件特定细节 生成Tofino专用文件,提供高层级编程抽象,适配 Tofino 的匹配 - 动作流水线架构 简化FPGA开发,实现P4与FPGA的高效融合
    TsingMa
    p4c-TsingMa
    (本文方法)
    通过先序遍历解析DAG结构的中间表示,精准提取协议类型等关键信息 自定义P4 语义-国产芯片 FlexParser / FlexEdit硬件参数”映射规则,生成适配的芯片指令,解决非原生P4支持的硬件适配问题 提供高层级编程抽象,屏蔽Tofino硬件细节
    下载: 导出CSV

    1  协议头字段偏移量计算算法

     输入:$hdr$-P4协议头类型定义(Type_Header对象)
     输出:更新全局映射$ structOffsets $,存储协议头字段的元数据
     (1) 初始化 $structInfo$← $\varnothing $
     (2) $ headerName $←$ hdr $的名字
     (3) 创建空的 $ headerOffset $ 字典
     (4) $ offset $← 0
     (5) for each 字段 $ ele $ in $ hdr $ 的字段列表 do :
     (6)  $ structInfo.eleName $←$ ele.name $
     (7)  if $ ele $的类型是 $ Type\_Bits $ then
     (8)   $ structInfo.eleType,length $← "Type_Bits",ele的位宽
     (9)   $ offset $←$ offset $+$ ele $的位宽
     (10) end if
     (11) 将 ($ ele $的名称,$ structInfo $) 插入 $ headerOffset $ 字典
     (12) end for
     (13) $ structInfo.eleName,length,eleOffset $←
     "totalOffset",offset,offset
     (14) 将 ("totalOffset",$ structInfo $) 插入 $ headerOffset $字典
     (15) 将 ($ headerName $, $ headerOffset $) 插入全局 $ structOffsets $字典
    下载: 导出CSV

    2  UDF表项合并算法

     (1) 对$ ruleSet $中的UDF规则根据关键字长度进行降序排序
     (2) 设置$mergeNum$个模态分组,每组初始化为$\varnothing $
     (3) for each UDF规则in $ruleSet$:
     (4)  找到消耗存储资源最少的模态分组,记为$ G\_min $
     (5)  $ G\_min \leftarrow G\_min \cup ${UDF规则}
     (6) end for
     (7) for each 模态分组:
     (8) 构建合并的UDF规则$ mergeRule $
     (9) $ mergeRuleSet \leftarrow mergeRuleSet \cup mergeRule $
     (10) end for
     (11) return $ mergeRuleSet $
    下载: 导出CSV

    表  2  IPv4模态CLI指令

    IDCLI说明
    1config udf_1 L2 96 0X0800 0XFFFFetherType通过udf_1这条规则匹配,基础偏移类型L2 偏移96位,掩码0XFFFF,匹配0X0800
    2config udf_2 L2 240 0X0A000003 0XFFFFFFFFdst_addr通过udf_2这条规则匹配,基础偏移类型L2 偏移240位,掩码0XFFFFFFFF,匹配0X0A000003
    3config udf match udf_1 udf_2 action Ethernet2将匹配到的数据包从Ethernet2端口转发
    下载: 导出CSV

    表  3  芯片资源占用情况

    网络模态关键字个数关键字长度(bit)寄存器资源利用率
    AccMF38062.5%
    CoreMF23225%
    IPv424837.5%
    PwL26450%
    IPv62144100%
    AccMF_CoreMF_IPv4_PwL6176100%
    下载: 导出CSV
  • [1] 凃化清, 廖君虎, 朱俊, 等. 多模态网络环境下网络模态共存与优化部署方法[J]. 电子学报, 2025, 53(5): 1650–1660. doi: 10.12263/DZXB.20250015.

    TU Huaqing, LIAO Junhu, ZHU Jun, et al. Network modal coexistence and optimal deployment method in polymorphic network environment[J]. Acta Electronica Sinica, 2025, 53(5): 1650–1660. doi: 10.12263/DZXB.20250015.
    [2] WU Jiangxing, LI Junfei, SUN Penghao, et al. Theoretical framework for a polymorphic network environment[J]. Engineering, 2024, 39: 222–234. doi: 10.1016/j.eng.2024.01.018.
    [3] 邬江兴, 胡宇翔. 网络技术体系与支撑环境分离的发展范式[J]. 信息通信技术与政策, 2021, 47(8): 1–11. doi: 10.12267/j.issn.2096-5931.2021.08.001.

    WU Jiangxing and HU Yuxiang. The development paradigm of separation between network technical system and supporting environment[J]. Information and Communications Technology and Policy, 2021, 47(8): 1–11. doi: 10.12267/j.issn.2096-5931.2021.08.001.
    [4] HU Yuxiang, LI Dan, SUN Penghao, et al. Polymorphic smart network: An open, flexible and universal architecture for future heterogeneous networks[J]. IEEE Transactions on Network Science and Engineering, 2020, 7(4): 2515–2525. doi: 10.1109/tnse.2020.3006249.
    [5] BOSSHART P, DALY D, GIBB G, et al. P4: Programming protocol-independent packet processors[J]. ACM SIGCOMM Computer Communication Review, 2014, 44(3): 87–95. doi: 10.1145/2656877.2656890.
    [6] Tofino[EB/OL]. https://www.barefootnetworks.com/products/brief-tofino, 2025. (查阅网上资料,请核对网址与文献是否相符).
    [7] Centec. CTC8180[EB/OL]. https://www.centec.com/silicon/26, 2025. (查阅网上资料,请核对网址与文献是否相符).
    [8] HAUSER F, HÄBERLE M, MERLING D, et al. A survey on data plane programming with P4: Fundamentals, advances, and applied research[J]. Journal of Network and Computer Applications, 2023, 212: 103561. doi: 10.1016/j.jnca.2022.103561.
    [9] YANG Y Fifan, HE Lin, ZHOU Jiasheng, et al. P4runpro: Enabling runtime programmability for RMT programmable switches[C]. Proceedings of the ACM SIGCOMM 2024 Conference, Sydney, Australia, 2024: 921–937. doi: 10.1145/3651890.3672230.
    [10] CHEN Zhikang, FENG Yong, LIU Shuxin, et al. OptimusPrime: Unleash dataplane programmability through a transformable architecture[C]. Proceedings of the ACM SIGCOMM 2024 Conference, Sydney, Australia, 2024: 904–920. doi: 10.1145/3651890.3672214.
    [11] WANG Tao, YANG Xiangrui, ANTICHI G, et al. Isolation mechanisms for high-speed packet-processing pipelines[C]. Proceedings of the 19th USENIX Symposium on Networked Systems Design and Implementation, Renton, USA, 2022: 1289–1305.
    [12] LU Chenyunfei, TANG Zhu, PENG Wei, et al. Running P4 programs on general programmable network interconnection chips[C]. Proceedings of 2023 Fourth International Conference on Frontiers of Computers and Communication Engineering, Xiamen, China, 2023: 1–6. doi: 10.1109/fcce58525.2023.00008.
    [13] DA ROBIN D and KHAN J I. An open-source P416 compiler backend for reconfigurable match-action table switches: Making networking innovation accessible[J]. Computer Networks, 2024, 242: 110246. doi: 10.1016/j.comnet.2024.110246.
    [14] GAO Jiaqi, ZHAI Ennan, LIU H H, et al. Lyra: A cross-platform language and compiler for data plane programming on heterogeneous ASICs[C]. Proceedings of the Annual Conference of the ACM Special Interest Group on Data Communication on the Applications, Technologies, Architectures, and Protocols for Computer Communication, 2020: 435–450. doi: 10.1145/3387514.3405879. (查阅网上资料,未找到对应的出版地信息,请确认).
    [15] LI Yifan, GAO Jiaqi, ZHAI Ennan, et al. Cetus: Releasing P4 programmers from the chore of trial and error compiling[C]. Proceedings of the 19th USENIX Symposium on Networked Systems Design and Implementation, Renton, USA, 2022: 371–385.
    [16] DANGETI T K, KEERTHY S V, and UPADRASTA R. P4LLVM: An LLVM based P4 compiler[C]. Proceedings of the 26th International Conference on Network Protocols, Cambridge, UK, 2018: 424–429. doi: 10.1109/icnp.2018.00059.
    [17] GAO Xiangyu, KIM T, WONG M D, et al. Switch code generation using program synthesis[C]. Proceedings of the Annual Conference of the ACM Special Interest Group on Data Communication on the Applications, Technologies, Architectures, and Protocols for Computer Communication, 2020: 44–61. doi: 10.1145/3387514.3405852. (查阅网上资料,未找到对应的出版地信息,请确认).
    [18] WANG Han, SOULÉ R, DANG H T, et al. P4FPGA: A rapid prototyping framework for P4[C]. Proceedings of the Symposium on SDN Research, Santa Clara, USA, 2017: 122–135. doi: 10.1145/3050220.3050234.
    [19] p4c, a reference compiler for P4 programming language[EB/OL]. https://github.com/p4lang/p4c, 2025. (查阅网上资料,请核对网址与文献是否相符).
    [20] HARKOUS H, PAPAGIANNI C, DE SCHEPPER K, et al. Virtual queues for P4: A poor man’s programmable traffic manager[J]. IEEE Transactions on Network and Service Management, 2021, 18(3): 2860–2872. doi: 10.1109/tnsm.2021.3077051.
    [21] VENKATAKEERTHY S, ANDALURI Y, DEY S, et al. Packet processing algorithm identification using program embeddings[C]. Proceedings of the 6th Asia-Pacific Workshop on Networking, Fuzhou, China, 2022: 76–82. doi: 10.1145/3542637.3542649.
    [22] VENKATAKEERTHY S, AGGARWAL R, JAIN S, et al. IR2VEC: LLVM IR based scalable program embeddings[J]. ACM Transactions on Architecture and Code Optimization (TACO), 2020, 17(4): 32. doi: 10.1145/3418463.
  • 加载中
图(8) / 表(5)
计量
  • 文章访问数:  72
  • HTML全文浏览量:  41
  • PDF下载量:  15
  • 被引次数: 0
出版历程
  • 收稿日期:  2025-03-05
  • 修回日期:  2025-11-03
  • 录用日期:  2025-11-03
  • 网络出版日期:  2025-11-08

目录

    /

    返回文章
    返回