不同于smartNIC,服务器网卡的TOE(TCP Offload Engine ,TCP卸载引擎)是一个传统功能,它旨在使用网卡上专用处理器来完成特定或所有数据包的处理任务,从而达到提升服务器网络处理性能的目的。
Linux 支持情况
Linux 操作系统有多种设置来支持网卡的offloading特性,包括TCP、UDP,以及分段和聚合等:
tso - TCP Segmentation Offload (for TCP)ufo - UDP Fragmentation Offload (for UDP)gso - Generic Segmentation Offloadgro - Generic Receive Offload (for RX)lro - Large Receive Offload (for RX)Linux对网卡offloading特性的支持,需要取决于kernel版本、网卡驱动和硬件支持情况。
可以通过ethtool命令,查看当前Linux系统默认开启或关闭的offloading功能,这个在不同版本会稍后差异,例:
$ ethtool -k eth0Features for eth0:rx-checksumming: ontx-checksumming: offscatter-gather: offtcp-segmentation-offload: off === tsoudp-fragmentation-offload: off === ufogeneric-segmentation-offload: off === gsogeneric-receive-offload: on === grolarge-receive-offload: off === lrontuple-filters: offreceive-hashing: off
当然以上只是个示例,拿刚发布的 RHEL9.1 来实际看一下,其参数项会比较多:
[root@localhost ~]# ethtool -k enp0s3Features for enp0s3:rx-checksumming: offtx-checksumming: on tx-checksum-ipv4: off [fixed] tx-checksum-ip-generic: on tx-checksum-ipv6: off [fixed] tx-checksum-fcoe-crc: off [fixed] tx-checksum-sctp: off [fixed]scatter-gather: on tx-scatter-gather: on tx-scatter-gather-fraglist: off [fixed]tcp-segmentation-offload: on tx-tcp-segmentation: on tx-tcp-ecn-segmentation: off [fixed] tx-tcp-mangleid-segmentation: off tx-tcp6-segmentation: off [fixed]generic-segmentation-offload: ongeneric-receive-offload: onlarge-receive-offload: off [fixed]……
我们也可以根据需要手工关闭某些功能,拿关闭gso来示例:
[root@localhost ~]# ethtool -K enp0s3 gso off
查看一下结果
总结
适当的调整和使用网卡TOE功能,可以在在特定的场景下(如文件服务、NFS、备份恢复等),减少CPU和内核处理压力。