Skip to content

Commit

Permalink
mlx4: exploit skb->xmit_more to conditionally send doorbell
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Sep 28, 2014
1 parent a8404ce commit 5804283
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions drivers/net/ethernet/mellanox/mlx4/en_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down

0 comments on commit 5804283

Please sign in to comment.