diff options
author | Yevgeny Petrilin <yevgenyp@mellanox.co.il> | 2009-08-06 22:27:51 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-06 22:27:51 -0400 |
commit | b6b912e0804dc1b3e856da3cc82fbe78b50e968c (patch) | |
tree | cc35371a7ad0caed0841183cf7356b398b1e9588 /drivers/net/mlx4/en_rx.c | |
parent | a35ee541a66d11d26da30d3f6046dbddd073334e (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/en_rx.c')
-rw-r--r-- | drivers/net/mlx4/en_rx.c | 38 |
1 files changed, 11 insertions, 27 deletions
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 */ | ||
839 | void 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 | |||
855 | static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, | 838 | static 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 | ||