From patchwork Thu Sep 25 14:17:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 393353 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E738B140081 for ; Fri, 26 Sep 2014 00:17:55 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753200AbaIYORv (ORCPT ); Thu, 25 Sep 2014 10:17:51 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:43590 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753040AbaIYORu (ORCPT ); Thu, 25 Sep 2014 10:17:50 -0400 Received: by mail-pd0-f182.google.com with SMTP id p10so10643974pdj.13 for ; Thu, 25 Sep 2014 07:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:content-type :content-transfer-encoding:mime-version; bh=u8a8YS+8i7kAW4LLtK5/xAuGN+WaiU5qM+bfsWxCgn0=; b=O5PIz1I1X4HY4zGopzzNWUK0QVheTFtiUo7yMRm36qnYjzYk+NWqXawKN+Hji2ufMj hzDYA4Rp1L4wBO4DAJISMRODSc9bIsbnFwYhAuh7ehtvldA6clZrpxjTcE0XIUh+DB15 npGyzhKqpvneVQEq47VKtlIr5aiPJlbBwLVxnLmfCGNoQqVghBOZGKFLWXk+5/VinTrx sYdGHY0qS76gk9UhMChZpPbxTx/qGCgoEXV3Jya3riEazSk2ZDwzwem2HAgFxbIbXhjk GmLS5H19pPMQ2s2BPH7QKmZnFXDO3gOrIw1bKkfpSPidETFKZ6pab2+KzoeaVTYM72sC VPxg== X-Received: by 10.70.94.3 with SMTP id cy3mr26796415pdb.114.1411654670428; Thu, 25 Sep 2014 07:17:50 -0700 (PDT) Received: from [172.19.240.131] ([172.19.240.131]) by mx.google.com with ESMTPSA id dh14sm2386478pac.17.2014.09.25.07.17.49 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Thu, 25 Sep 2014 07:17:50 -0700 (PDT) Message-ID: <1411654669.16953.17.camel@edumazet-glaptop2.roam.corp.google.com> Subject: [PATCH net-next] mlx4: exploit skb->xmit_more to conditionally send doorbell From: Eric Dumazet To: David Miller Cc: netdev , Amir Vadai Date: Thu, 25 Sep 2014 07:17:49 -0700 X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet 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 --- drivers/net/ethernet/mellanox/mlx4/en_tx.c | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index c44f4237b9be..adedc47e947d 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c @@ -667,6 +667,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) int lso_header_size; void *fragptr; bool bounce = false; + bool send_doorbell; if (!priv->port_up) goto tx_drop; @@ -878,12 +879,16 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) skb_tx_timestamp(skb); - if (ring->bf_enabled && desc_size <= MAX_BF && !bounce && !vlan_tx_tag_present(skb)) { + send_doorbell = !skb->xmit_more || netif_xmit_stopped(ring->tx_queue); + + if (ring->bf_enabled && desc_size <= MAX_BF && !bounce && + !vlan_tx_tag_present(skb) && send_doorbell) { tx_desc->ctrl.bf_qpn |= cpu_to_be32(ring->doorbell_qpn); op_own |= htonl((bf_index & 0xffff) << 8); - /* Ensure new descirptor hits memory - * before setting ownership of this descriptor to HW */ + /* Ensure new descriptor hits memory + * before setting ownership of this descriptor to HW + */ wmb(); tx_desc->ctrl.owner_opcode = op_own; @@ -896,12 +901,16 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) ring->bf.offset ^= ring->bf.buf_size; } else { - /* Ensure new descirptor hits memory - * before setting ownership of this descriptor to HW */ + /* Ensure new descriptor hits memory + * before setting ownership of this descriptor to HW + */ wmb(); tx_desc->ctrl.owner_opcode = op_own; - wmb(); - iowrite32be(ring->doorbell_qpn, ring->bf.uar->map + MLX4_SEND_DOORBELL); + if (send_doorbell) { + wmb(); + iowrite32be(ring->doorbell_qpn, + ring->bf.uar->map + MLX4_SEND_DOORBELL); + } } return NETDEV_TX_OK;