aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox
diff options
context:
space:
mode:
authorIdo Shamay <idos@mellanox.com>2014-09-18 04:51:01 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-19 17:30:11 -0400
commitb1b6b4da7867d220f0da5f6686b869b304c5459b (patch)
treebb24828b191225b2af2e5f25ebbcc90c08469faa /drivers/net/ethernet/mellanox
parent43c816c67a536cfcfc24da50153115b75eca94f0 (diff)
net/mlx4_en: Add mlx4_en_get_cqe helper
This function derives the base address of the CQE from the CQE size, and calculates the real CQE context segment in it from the factor (this is like before). Before this change the code used the factor to calculate the base address of the CQE as well. The factor indicates in which segment of the cqe stride the cqe information is located. For 32-byte strides, the segment is 0, and for 64 byte strides, the segment is 1 (bytes 32..63). Using the factor was ok as long as we had only 32 and 64 byte strides. However, with larger strides, the factor is zero, and so cannot be used to calculate the base of the CQE. The helper uses the same method of CQE buffer pulling made by all other components that reads the CQE buffer (mlx4_ib driver and libmlx4). Signed-off-by: Ido Shamay <idos@mellanox.com> Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mellanox')
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4_en.h6
4 files changed, 11 insertions, 4 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index abddcf8c40aa..f3032fec8fce 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2459,6 +2459,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
2459 } 2459 }
2460 priv->rx_ring_num = prof->rx_ring_num; 2460 priv->rx_ring_num = prof->rx_ring_num;
2461 priv->cqe_factor = (mdev->dev->caps.cqe_size == 64) ? 1 : 0; 2461 priv->cqe_factor = (mdev->dev->caps.cqe_size == 64) ? 1 : 0;
2462 priv->cqe_size = mdev->dev->caps.cqe_size;
2462 priv->mac_index = -1; 2463 priv->mac_index = -1;
2463 priv->msg_enable = MLX4_EN_MSG_LEVEL; 2464 priv->msg_enable = MLX4_EN_MSG_LEVEL;
2464 spin_lock_init(&priv->stats_lock); 2465 spin_lock_init(&priv->stats_lock);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 14686b6f4bc5..a33048ee9621 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -671,7 +671,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
671 * descriptor offset can be deduced from the CQE index instead of 671 * descriptor offset can be deduced from the CQE index instead of
672 * reading 'cqe->index' */ 672 * reading 'cqe->index' */
673 index = cq->mcq.cons_index & ring->size_mask; 673 index = cq->mcq.cons_index & ring->size_mask;
674 cqe = &cq->buf[(index << factor) + factor]; 674 cqe = mlx4_en_get_cqe(cq->buf, index, priv->cqe_size) + factor;
675 675
676 /* Process all completed CQEs */ 676 /* Process all completed CQEs */
677 while (XNOR(cqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK, 677 while (XNOR(cqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK,
@@ -858,7 +858,7 @@ next:
858 858
859 ++cq->mcq.cons_index; 859 ++cq->mcq.cons_index;
860 index = (cq->mcq.cons_index) & ring->size_mask; 860 index = (cq->mcq.cons_index) & ring->size_mask;
861 cqe = &cq->buf[(index << factor) + factor]; 861 cqe = mlx4_en_get_cqe(cq->buf, index, priv->cqe_size) + factor;
862 if (++polled == budget) 862 if (++polled == budget)
863 goto out; 863 goto out;
864 } 864 }
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index bc8f51c77d80..c44f4237b9be 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -382,7 +382,7 @@ static bool mlx4_en_process_tx_cq(struct net_device *dev,
382 return true; 382 return true;
383 383
384 index = cons_index & size_mask; 384 index = cons_index & size_mask;
385 cqe = &buf[(index << factor) + factor]; 385 cqe = mlx4_en_get_cqe(buf, index, priv->cqe_size) + factor;
386 ring_index = ring->cons & size_mask; 386 ring_index = ring->cons & size_mask;
387 stamp_index = ring_index; 387 stamp_index = ring_index;
388 388
@@ -430,7 +430,7 @@ static bool mlx4_en_process_tx_cq(struct net_device *dev,
430 430
431 ++cons_index; 431 ++cons_index;
432 index = cons_index & size_mask; 432 index = cons_index & size_mask;
433 cqe = &buf[(index << factor) + factor]; 433 cqe = mlx4_en_get_cqe(buf, index, priv->cqe_size) + factor;
434 } 434 }
435 435
436 436
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index 3de41be49425..e3d71c386da7 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -542,6 +542,7 @@ struct mlx4_en_priv {
542 unsigned max_mtu; 542 unsigned max_mtu;
543 int base_qpn; 543 int base_qpn;
544 int cqe_factor; 544 int cqe_factor;
545 int cqe_size;
545 546
546 struct mlx4_en_rss_map rss_map; 547 struct mlx4_en_rss_map rss_map;
547 __be32 ctrl_flags; 548 __be32 ctrl_flags;
@@ -612,6 +613,11 @@ struct mlx4_mac_entry {
612 struct rcu_head rcu; 613 struct rcu_head rcu;
613}; 614};
614 615
616static inline struct mlx4_cqe *mlx4_en_get_cqe(void *buf, int idx, int cqe_sz)
617{
618 return buf + idx * cqe_sz;
619}
620
615#ifdef CONFIG_NET_RX_BUSY_POLL 621#ifdef CONFIG_NET_RX_BUSY_POLL
616static inline void mlx4_en_cq_init_lock(struct mlx4_en_cq *cq) 622static inline void mlx4_en_cq_init_lock(struct mlx4_en_cq *cq)
617{ 623{