aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/mlx4
diff options
context:
space:
mode:
authorYevgeny Petrilin <yevgenyp@mellanox.co.il>2009-08-06 22:27:51 -0400
committerDavid S. Miller <davem@davemloft.net>2009-08-06 22:27:51 -0400
commitb6b912e0804dc1b3e856da3cc82fbe78b50e968c (patch)
treecc35371a7ad0caed0841183cf7356b398b1e9588 /drivers/net/mlx4
parenta35ee541a66d11d26da30d3f6046dbddd073334e (diff)
mlx4_en: Using real number of rings as RSS map size
There is no point in using more QPs then actual number of receive rings. If the RSS function for two streams gives the same result modulo number of rings, they will arrive to the same RX ring anyway. Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/mlx4')
-rw-r--r--drivers/net/mlx4/en_main.c5
-rw-r--r--drivers/net/mlx4/en_netdev.c3
-rw-r--r--drivers/net/mlx4/en_rx.c38
-rw-r--r--drivers/net/mlx4/mlx4_en.h11
4 files changed, 16 insertions, 41 deletions
diff --git a/drivers/net/mlx4/en_main.c b/drivers/net/mlx4/en_main.c
index 9ed4a158f895..507e11fce9ed 100644
--- a/drivers/net/mlx4/en_main.c
+++ b/drivers/net/mlx4/en_main.c
@@ -218,8 +218,9 @@ static void *mlx4_en_add(struct mlx4_dev *dev)
218 mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH) { 218 mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH) {
219 mlx4_info(mdev, "Using %d tx rings for port:%d\n", 219 mlx4_info(mdev, "Using %d tx rings for port:%d\n",
220 mdev->profile.prof[i].tx_ring_num, i); 220 mdev->profile.prof[i].tx_ring_num, i);
221 mdev->profile.prof[i].rx_ring_num = 221 mdev->profile.prof[i].rx_ring_num = min_t(int,
222 min_t(int, dev->caps.num_comp_vectors, MAX_RX_RINGS); 222 roundup_pow_of_two(dev->caps.num_comp_vectors),
223 MAX_RX_RINGS);
223 mlx4_info(mdev, "Defaulting to %d rx rings for port:%d\n", 224 mlx4_info(mdev, "Defaulting to %d rx rings for port:%d\n",
224 mdev->profile.prof[i].rx_ring_num, i); 225 mdev->profile.prof[i].rx_ring_num, i);
225 } 226 }
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index c8a24dcca762..f8bbc5a39e15 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -1011,9 +1011,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
1011 if (err) 1011 if (err)
1012 goto out; 1012 goto out;
1013 1013
1014 /* Populate Rx default RSS mappings */
1015 mlx4_en_set_default_rss_map(priv, &priv->rss_map, priv->rx_ring_num *
1016 RSS_FACTOR, priv->rx_ring_num);
1017 /* Allocate page for receive rings */ 1014 /* Allocate page for receive rings */
1018 err = mlx4_alloc_hwq_res(mdev->dev, &priv->res, 1015 err = mlx4_alloc_hwq_res(mdev->dev, &priv->res,
1019 MLX4_EN_PAGE_SIZE, MLX4_EN_PAGE_SIZE); 1016 MLX4_EN_PAGE_SIZE, MLX4_EN_PAGE_SIZE);
diff --git a/drivers/net/mlx4/en_rx.c b/drivers/net/mlx4/en_rx.c
index 91bdfdfd431f..47b178e2b49e 100644
--- a/drivers/net/mlx4/en_rx.c
+++ b/drivers/net/mlx4/en_rx.c
@@ -835,23 +835,6 @@ void mlx4_en_calc_rx_buf(struct net_device *dev)
835 835
836/* RSS related functions */ 836/* RSS related functions */
837 837
838/* Calculate rss size and map each entry in rss table to rx ring */
839void mlx4_en_set_default_rss_map(struct mlx4_en_priv *priv,
840 struct mlx4_en_rss_map *rss_map,
841 int num_entries, int num_rings)
842{
843 int i;
844
845 rss_map->size = roundup_pow_of_two(num_entries);
846 en_dbg(DRV, priv, "Setting default RSS map of %d entires\n",
847 rss_map->size);
848
849 for (i = 0; i < rss_map->size; i++) {
850 rss_map->map[i] = i % num_rings;
851 en_dbg(DRV, priv, "Entry %d ---> ring %d\n", i, rss_map->map[i]);
852 }
853}
854
855static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, 838static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv,
856 int qpn, int srqn, int cqn, 839 int qpn, int srqn, int cqn,
857 enum mlx4_qp_state *state, 840 enum mlx4_qp_state *state,
@@ -902,16 +885,17 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
902 int good_qps = 0; 885 int good_qps = 0;
903 886
904 en_dbg(DRV, priv, "Configuring rss steering\n"); 887 en_dbg(DRV, priv, "Configuring rss steering\n");
905 err = mlx4_qp_reserve_range(mdev->dev, rss_map->size, 888 err = mlx4_qp_reserve_range(mdev->dev, priv->rx_ring_num,
906 rss_map->size, &rss_map->base_qpn); 889 priv->rx_ring_num,
890 &rss_map->base_qpn);
907 if (err) { 891 if (err) {
908 en_err(priv, "Failed reserving %d qps\n", rss_map->size); 892 en_err(priv, "Failed reserving %d qps\n", priv->rx_ring_num);
909 return err; 893 return err;
910 } 894 }
911 895
912 for (i = 0; i < rss_map->size; i++) { 896 for (i = 0; i < priv->rx_ring_num; i++) {
913 cqn = priv->rx_ring[rss_map->map[i]].cqn; 897 cqn = priv->rx_ring[i].cqn;
914 srqn = priv->rx_ring[rss_map->map[i]].srq.srqn; 898 srqn = priv->rx_ring[i].srq.srqn;
915 qpn = rss_map->base_qpn + i; 899 qpn = rss_map->base_qpn + i;
916 err = mlx4_en_config_rss_qp(priv, qpn, srqn, cqn, 900 err = mlx4_en_config_rss_qp(priv, qpn, srqn, cqn,
917 &rss_map->state[i], 901 &rss_map->state[i],
@@ -940,7 +924,7 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
940 924
941 ptr = ((void *) &context) + 0x3c; 925 ptr = ((void *) &context) + 0x3c;
942 rss_context = (struct mlx4_en_rss_context *) ptr; 926 rss_context = (struct mlx4_en_rss_context *) ptr;
943 rss_context->base_qpn = cpu_to_be32(ilog2(rss_map->size) << 24 | 927 rss_context->base_qpn = cpu_to_be32(ilog2(priv->rx_ring_num) << 24 |
944 (rss_map->base_qpn)); 928 (rss_map->base_qpn));
945 rss_context->default_qpn = cpu_to_be32(rss_map->base_qpn); 929 rss_context->default_qpn = cpu_to_be32(rss_map->base_qpn);
946 rss_context->hash_fn = rss_xor & 0x3; 930 rss_context->hash_fn = rss_xor & 0x3;
@@ -967,7 +951,7 @@ rss_err:
967 mlx4_qp_remove(mdev->dev, &rss_map->qps[i]); 951 mlx4_qp_remove(mdev->dev, &rss_map->qps[i]);
968 mlx4_qp_free(mdev->dev, &rss_map->qps[i]); 952 mlx4_qp_free(mdev->dev, &rss_map->qps[i]);
969 } 953 }
970 mlx4_qp_release_range(mdev->dev, rss_map->base_qpn, rss_map->size); 954 mlx4_qp_release_range(mdev->dev, rss_map->base_qpn, priv->rx_ring_num);
971 return err; 955 return err;
972} 956}
973 957
@@ -983,13 +967,13 @@ void mlx4_en_release_rss_steer(struct mlx4_en_priv *priv)
983 mlx4_qp_free(mdev->dev, &rss_map->indir_qp); 967 mlx4_qp_free(mdev->dev, &rss_map->indir_qp);
984 mlx4_qp_release_range(mdev->dev, priv->base_qpn, 1); 968 mlx4_qp_release_range(mdev->dev, priv->base_qpn, 1);
985 969
986 for (i = 0; i < rss_map->size; i++) { 970 for (i = 0; i < priv->rx_ring_num; i++) {
987 mlx4_qp_modify(mdev->dev, NULL, rss_map->state[i], 971 mlx4_qp_modify(mdev->dev, NULL, rss_map->state[i],
988 MLX4_QP_STATE_RST, NULL, 0, 0, &rss_map->qps[i]); 972 MLX4_QP_STATE_RST, NULL, 0, 0, &rss_map->qps[i]);
989 mlx4_qp_remove(mdev->dev, &rss_map->qps[i]); 973 mlx4_qp_remove(mdev->dev, &rss_map->qps[i]);
990 mlx4_qp_free(mdev->dev, &rss_map->qps[i]); 974 mlx4_qp_free(mdev->dev, &rss_map->qps[i]);
991 } 975 }
992 mlx4_qp_release_range(mdev->dev, rss_map->base_qpn, rss_map->size); 976 mlx4_qp_release_range(mdev->dev, rss_map->base_qpn, priv->rx_ring_num);
993} 977}
994 978
995 979
diff --git a/drivers/net/mlx4/mlx4_en.h b/drivers/net/mlx4/mlx4_en.h
index c7c5e86804ff..2d76ff4c564b 100644
--- a/drivers/net/mlx4/mlx4_en.h
+++ b/drivers/net/mlx4/mlx4_en.h
@@ -95,8 +95,6 @@
95#define MLX4_EN_PAGE_SIZE (1 << MLX4_EN_PAGE_SHIFT) 95#define MLX4_EN_PAGE_SIZE (1 << MLX4_EN_PAGE_SHIFT)
96#define MAX_TX_RINGS 16 96#define MAX_TX_RINGS 16
97#define MAX_RX_RINGS 16 97#define MAX_RX_RINGS 16
98#define MAX_RSS_MAP_SIZE 64
99#define RSS_FACTOR 2
100#define TXBB_SIZE 64 98#define TXBB_SIZE 64
101#define HEADROOM (2048 / TXBB_SIZE + 1) 99#define HEADROOM (2048 / TXBB_SIZE + 1)
102#define STAMP_STRIDE 64 100#define STAMP_STRIDE 64
@@ -377,11 +375,9 @@ struct mlx4_en_dev {
377 375
378 376
379struct mlx4_en_rss_map { 377struct mlx4_en_rss_map {
380 int size;
381 int base_qpn; 378 int base_qpn;
382 u16 map[MAX_RSS_MAP_SIZE]; 379 struct mlx4_qp qps[MAX_RX_RINGS];
383 struct mlx4_qp qps[MAX_RSS_MAP_SIZE]; 380 enum mlx4_qp_state state[MAX_RX_RINGS];
384 enum mlx4_qp_state state[MAX_RSS_MAP_SIZE];
385 struct mlx4_qp indir_qp; 381 struct mlx4_qp indir_qp;
386 enum mlx4_qp_state indir_state; 382 enum mlx4_qp_state indir_state;
387}; 383};
@@ -555,9 +551,6 @@ int mlx4_en_map_buffer(struct mlx4_buf *buf);
555void mlx4_en_unmap_buffer(struct mlx4_buf *buf); 551void mlx4_en_unmap_buffer(struct mlx4_buf *buf);
556 552
557void mlx4_en_calc_rx_buf(struct net_device *dev); 553void mlx4_en_calc_rx_buf(struct net_device *dev);
558void mlx4_en_set_default_rss_map(struct mlx4_en_priv *priv,
559 struct mlx4_en_rss_map *rss_map,
560 int num_entries, int num_rings);
561int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv); 554int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv);
562void mlx4_en_release_rss_steer(struct mlx4_en_priv *priv); 555void mlx4_en_release_rss_steer(struct mlx4_en_priv *priv);
563int mlx4_en_free_tx_buf(struct net_device *dev, struct mlx4_en_tx_ring *ring); 556int mlx4_en_free_tx_buf(struct net_device *dev, struct mlx4_en_tx_ring *ring);