Commit 6a4e8121 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net/mlx4_en: Avoid calling bswap in tx fast path

- doorbell_qpn is stored in the cpu_to_be32() way to avoid bswap() in fast
  path.
- mdev->mr.key stored in ring->mr_key to also avoid bswap() and access to
  cold cache line.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarAmir Vadai <amirv@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 98b16349
...@@ -195,7 +195,8 @@ int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv, ...@@ -195,7 +195,8 @@ int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv,
memset(ring->buf, 0, ring->buf_size); memset(ring->buf, 0, ring->buf_size);
ring->qp_state = MLX4_QP_STATE_RST; ring->qp_state = MLX4_QP_STATE_RST;
ring->doorbell_qpn = ring->qp.qpn << 8; ring->doorbell_qpn = cpu_to_be32(ring->qp.qpn << 8);
ring->mr_key = cpu_to_be32(mdev->mr.key);
mlx4_en_fill_qp_context(priv, ring->size, ring->stride, 1, 0, ring->qpn, mlx4_en_fill_qp_context(priv, ring->size, ring->stride, 1, 0, ring->qpn,
ring->cqn, user_prio, &ring->context); ring->cqn, user_prio, &ring->context);
...@@ -654,7 +655,6 @@ static void mlx4_bf_copy(void __iomem *dst, const void *src, ...@@ -654,7 +655,6 @@ static void mlx4_bf_copy(void __iomem *dst, const void *src,
netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev;
struct device *ddev = priv->ddev; struct device *ddev = priv->ddev;
struct mlx4_en_tx_ring *ring; struct mlx4_en_tx_ring *ring;
struct mlx4_en_tx_desc *tx_desc; struct mlx4_en_tx_desc *tx_desc;
...@@ -769,7 +769,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -769,7 +769,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
goto tx_drop_unmap; goto tx_drop_unmap;
data->addr = cpu_to_be64(dma); data->addr = cpu_to_be64(dma);
data->lkey = cpu_to_be32(mdev->mr.key); data->lkey = ring->mr_key;
wmb(); wmb();
data->byte_count = cpu_to_be32(skb_frag_size(frag)); data->byte_count = cpu_to_be32(skb_frag_size(frag));
--data; --data;
...@@ -787,7 +787,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -787,7 +787,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
goto tx_drop_unmap; goto tx_drop_unmap;
data->addr = cpu_to_be64(dma); data->addr = cpu_to_be64(dma);
data->lkey = cpu_to_be32(mdev->mr.key); data->lkey = ring->mr_key;
wmb(); wmb();
data->byte_count = cpu_to_be32(byte_count); data->byte_count = cpu_to_be32(byte_count);
} }
...@@ -879,9 +879,12 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -879,9 +879,12 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
send_doorbell = !skb->xmit_more || netif_xmit_stopped(ring->tx_queue); send_doorbell = !skb->xmit_more || netif_xmit_stopped(ring->tx_queue);
real_size = (real_size / 16) & 0x3f;
if (ring->bf_enabled && desc_size <= MAX_BF && !bounce && if (ring->bf_enabled && desc_size <= MAX_BF && !bounce &&
!vlan_tx_tag_present(skb) && send_doorbell) { !vlan_tx_tag_present(skb) && send_doorbell) {
tx_desc->ctrl.bf_qpn |= cpu_to_be32(ring->doorbell_qpn); tx_desc->ctrl.bf_qpn = ring->doorbell_qpn |
cpu_to_be32(real_size);
op_own |= htonl((bf_index & 0xffff) << 8); op_own |= htonl((bf_index & 0xffff) << 8);
/* Ensure new descriptor hits memory /* Ensure new descriptor hits memory
...@@ -911,8 +914,8 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -911,8 +914,8 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
tx_desc->ctrl.owner_opcode = op_own; tx_desc->ctrl.owner_opcode = op_own;
if (send_doorbell) { if (send_doorbell) {
wmb(); wmb();
iowrite32be(ring->doorbell_qpn, iowrite32(ring->doorbell_qpn,
ring->bf.uar->map + MLX4_SEND_DOORBELL); ring->bf.uar->map + MLX4_SEND_DOORBELL);
} else { } else {
ring->xmit_more++; ring->xmit_more++;
} }
......
...@@ -279,7 +279,8 @@ struct mlx4_en_tx_ring { ...@@ -279,7 +279,8 @@ struct mlx4_en_tx_ring {
u16 stride; u16 stride;
u16 cqn; /* index of port CQ associated with this ring */ u16 cqn; /* index of port CQ associated with this ring */
u32 buf_size; u32 buf_size;
u32 doorbell_qpn; __be32 doorbell_qpn;
__be32 mr_key;
void *buf; void *buf;
struct mlx4_en_tx_info *tx_info; struct mlx4_en_tx_info *tx_info;
u8 *bounce_buf; u8 *bounce_buf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment