Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mlx4: exploit skb->xmit_more to conditionally send doorbell

skb->xmit_more tells us if another skb is coming next.

We need to send doorbell when : xmit_more is not set,
or txqueue is stopped (preventing next skb to come immediately)

Tested with a modified pktgen version, I got a 40% increase of
throughput.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
5804283d a8404ce5

+16 -7
+16 -7
drivers/net/ethernet/mellanox/mlx4/en_tx.c
··· 667 667 int lso_header_size; 668 668 void *fragptr; 669 669 bool bounce = false; 670 + bool send_doorbell; 670 671 671 672 if (!priv->port_up) 672 673 goto tx_drop; ··· 879 878 880 879 skb_tx_timestamp(skb); 881 880 882 - if (ring->bf_enabled && desc_size <= MAX_BF && !bounce && !vlan_tx_tag_present(skb)) { 881 + send_doorbell = !skb->xmit_more || netif_xmit_stopped(ring->tx_queue); 882 + 883 + if (ring->bf_enabled && desc_size <= MAX_BF && !bounce && 884 + !vlan_tx_tag_present(skb) && send_doorbell) { 883 885 tx_desc->ctrl.bf_qpn |= cpu_to_be32(ring->doorbell_qpn); 884 886 885 887 op_own |= htonl((bf_index & 0xffff) << 8); 886 - /* Ensure new descirptor hits memory 887 - * before setting ownership of this descriptor to HW */ 888 + /* Ensure new descriptor hits memory 889 + * before setting ownership of this descriptor to HW 890 + */ 888 891 wmb(); 889 892 tx_desc->ctrl.owner_opcode = op_own; 890 893 ··· 901 896 902 897 ring->bf.offset ^= ring->bf.buf_size; 903 898 } else { 904 - /* Ensure new descirptor hits memory 905 - * before setting ownership of this descriptor to HW */ 899 + /* Ensure new descriptor hits memory 900 + * before setting ownership of this descriptor to HW 901 + */ 906 902 wmb(); 907 903 tx_desc->ctrl.owner_opcode = op_own; 908 - wmb(); 909 - iowrite32be(ring->doorbell_qpn, ring->bf.uar->map + MLX4_SEND_DOORBELL); 904 + if (send_doorbell) { 905 + wmb(); 906 + iowrite32be(ring->doorbell_qpn, 907 + ring->bf.uar->map + MLX4_SEND_DOORBELL); 908 + } 910 909 } 911 910 912 911 return NETDEV_TX_OK;