Skip to content

Commit 907dd32

Browse files
idoschkuba-moo
authored andcommitted
mlxsw: Enable Tx checksum offload
The device is able to checksum plain TCP / UDP packets over IPv4 / IPv6 when the 'ipcs' bit in the send descriptor is set. Advertise support for the 'NETIF_F_IP{,6}_CSUM' features in net devices registered by the driver and VLAN uppers and set the 'ipcs' bit when the stack requests Tx checksum offload. Note that the device also calculates the IPv4 checksum, but it first zeroes the current checksum so there should not be any difference compared to the checksum calculated by the kernel. On SN5600 (Spectrum-4) there is about 10% improvement in Tx packet rate with 1400 byte packets when using pktgen. Tested on Spectrum-{1,2,3,4} with all the combinations of IPv4 / IPv6, TCP / UDP, with and without VLAN. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Petr Machata <petrm@nvidia.com> Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/8dc86c95474ce10572a0fa83b8adb0259558e982.1738950446.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 3337064 commit 907dd32

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

drivers/net/ethernet/mellanox/mlxsw/pci.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,6 +2214,8 @@ static int mlxsw_pci_skb_transmit(void *bus_priv, struct sk_buff *skb,
22142214
for (i++; i < MLXSW_PCI_WQE_SG_ENTRIES; i++)
22152215
mlxsw_pci_wqe_byte_count_set(wqe, i, 0);
22162216

2217+
mlxsw_pci_wqe_ipcs_set(wqe, skb->ip_summed == CHECKSUM_PARTIAL);
2218+
22172219
/* Everything is set up, ring producer doorbell to get HW going */
22182220
q->producer_counter++;
22192221
mlxsw_pci_queue_doorbell_producer_ring(mlxsw_pci, q);

drivers/net/ethernet/mellanox/mlxsw/pci_hw.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ MLXSW_ITEM32(pci, wqe, lp, 0x00, 30, 1);
9090
*/
9191
MLXSW_ITEM32(pci, wqe, type, 0x00, 23, 4);
9292

93+
/* pci_wqe_ipcs
94+
* Calculate IPv4 and TCP / UDP checksums.
95+
*/
96+
MLXSW_ITEM32(pci, wqe, ipcs, 0x00, 14, 1);
97+
9398
/* pci_wqe_byte_count
9499
* Size of i-th scatter/gather entry, 0 if entry is unused.
95100
*/

drivers/net/ethernet/mellanox/mlxsw/spectrum.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,8 +1574,10 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u16 local_port,
15741574
netif_carrier_off(dev);
15751575

15761576
dev->features |= NETIF_F_SG | NETIF_F_HW_VLAN_CTAG_FILTER |
1577-
NETIF_F_HW_TC;
1578-
dev->hw_features |= NETIF_F_HW_TC | NETIF_F_LOOPBACK;
1577+
NETIF_F_HW_TC | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
1578+
dev->hw_features |= NETIF_F_HW_TC | NETIF_F_LOOPBACK |
1579+
NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
1580+
dev->vlan_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
15791581
dev->lltx = true;
15801582
dev->netns_local = true;
15811583

0 commit comments

Comments
 (0)