aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/mlx4
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-09-14 13:37:28 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-14 13:37:28 -0400
commitd7e9660ad9d5e0845f52848bce31bcf5cdcdea6b (patch)
treec6c67d145771187b194d79d603742b31090a59d6 /drivers/net/mlx4
parentb8cb48aae1b8c50b37dcb7710363aa69a7a0d9ca (diff)
parent13af7a6ea502fcdd4c0e3d7de6e332b102309491 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1623 commits) netxen: update copyright netxen: fix tx timeout recovery netxen: fix file firmware leak netxen: improve pci memory access netxen: change firmware write size tg3: Fix return ring size breakage netxen: build fix for INET=n cdc-phonet: autoconfigure Phonet address Phonet: back-end for autoconfigured addresses Phonet: fix netlink address dump error handling ipv6: Add IFA_F_DADFAILED flag net: Add DEVTYPE support for Ethernet based devices mv643xx_eth.c: remove unused txq_set_wrr() ucc_geth: Fix hangs after switching from full to half duplex ucc_geth: Rearrange some code to avoid forward declarations phy/marvell: Make non-aneg speed/duplex forcing work for 88E1111 PHYs drivers/net/phy: introduce missing kfree drivers/net/wan: introduce missing kfree net: force bridge module(s) to be GPL Subject: [PATCH] appletalk: Fix skb leak when ipddp interface is not loaded ... Fixed up trivial conflicts: - arch/x86/include/asm/socket.h converted to <asm-generic/socket.h> in the x86 tree. The generic header has the same new #define's, so that works out fine. - drivers/net/tun.c fix conflict between 89f56d1e9 ("tun: reuse struct sock fields") that switched over to using 'tun->socket.sk' instead of the redundantly available (and thus removed) 'tun->sk', and 2b980dbd ("lsm: Add hooks to the TUN driver") which added a new 'tun->sk' use. Noted in 'next' by Stephen Rothwell.
Diffstat (limited to 'drivers/net/mlx4')
-rw-r--r--drivers/net/mlx4/en_main.c5
-rw-r--r--drivers/net/mlx4/en_netdev.c18
-rw-r--r--drivers/net/mlx4/en_resources.c9
-rw-r--r--drivers/net/mlx4/en_rx.c111
-rw-r--r--drivers/net/mlx4/en_tx.c8
-rw-r--r--drivers/net/mlx4/mlx4_en.h19
6 files changed, 52 insertions, 118 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 93f4abd990a9..c48b0f4b17b7 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -414,6 +414,7 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
414 unsigned long avg_pkt_size; 414 unsigned long avg_pkt_size;
415 unsigned long rx_packets; 415 unsigned long rx_packets;
416 unsigned long rx_bytes; 416 unsigned long rx_bytes;
417 unsigned long rx_byte_diff;
417 unsigned long tx_packets; 418 unsigned long tx_packets;
418 unsigned long tx_pkt_diff; 419 unsigned long tx_pkt_diff;
419 unsigned long rx_pkt_diff; 420 unsigned long rx_pkt_diff;
@@ -437,6 +438,8 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
437 rx_pkt_diff = ((unsigned long) (rx_packets - 438 rx_pkt_diff = ((unsigned long) (rx_packets -
438 priv->last_moder_packets)); 439 priv->last_moder_packets));
439 packets = max(tx_pkt_diff, rx_pkt_diff); 440 packets = max(tx_pkt_diff, rx_pkt_diff);
441 rx_byte_diff = rx_bytes - priv->last_moder_bytes;
442 rx_byte_diff = rx_byte_diff ? rx_byte_diff : 1;
440 rate = packets * HZ / period; 443 rate = packets * HZ / period;
441 avg_pkt_size = packets ? ((unsigned long) (rx_bytes - 444 avg_pkt_size = packets ? ((unsigned long) (rx_bytes -
442 priv->last_moder_bytes)) / packets : 0; 445 priv->last_moder_bytes)) / packets : 0;
@@ -447,10 +450,13 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
447 /* If tx and rx packet rates are not balanced, assume that 450 /* If tx and rx packet rates are not balanced, assume that
448 * traffic is mainly BW bound and apply maximum moderation. 451 * traffic is mainly BW bound and apply maximum moderation.
449 * Otherwise, moderate according to packet rate */ 452 * Otherwise, moderate according to packet rate */
450 if (2 * tx_pkt_diff > 3 * rx_pkt_diff || 453 if (2 * tx_pkt_diff > 3 * rx_pkt_diff &&
451 2 * rx_pkt_diff > 3 * tx_pkt_diff) { 454 rx_pkt_diff / rx_byte_diff <
455 MLX4_EN_SMALL_PKT_SIZE)
456 moder_time = priv->rx_usecs_low;
457 else if (2 * rx_pkt_diff > 3 * tx_pkt_diff)
452 moder_time = priv->rx_usecs_high; 458 moder_time = priv->rx_usecs_high;
453 } else { 459 else {
454 if (rate < priv->pkt_rate_low) 460 if (rate < priv->pkt_rate_low)
455 moder_time = priv->rx_usecs_low; 461 moder_time = priv->rx_usecs_low;
456 else if (rate > priv->pkt_rate_high) 462 else if (rate > priv->pkt_rate_high)
@@ -616,8 +622,7 @@ int mlx4_en_start_port(struct net_device *dev)
616 622
617 /* Configure ring */ 623 /* Configure ring */
618 tx_ring = &priv->tx_ring[i]; 624 tx_ring = &priv->tx_ring[i];
619 err = mlx4_en_activate_tx_ring(priv, tx_ring, cq->mcq.cqn, 625 err = mlx4_en_activate_tx_ring(priv, tx_ring, cq->mcq.cqn);
620 priv->rx_ring[0].srq.srqn);
621 if (err) { 626 if (err) {
622 en_err(priv, "Failed allocating Tx ring\n"); 627 en_err(priv, "Failed allocating Tx ring\n");
623 mlx4_en_deactivate_cq(priv, cq); 628 mlx4_en_deactivate_cq(priv, cq);
@@ -1005,9 +1010,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
1005 if (err) 1010 if (err)
1006 goto out; 1011 goto out;
1007 1012
1008 /* Populate Rx default RSS mappings */
1009 mlx4_en_set_default_rss_map(priv, &priv->rss_map, priv->rx_ring_num *
1010 RSS_FACTOR, priv->rx_ring_num);
1011 /* Allocate page for receive rings */ 1013 /* Allocate page for receive rings */
1012 err = mlx4_alloc_hwq_res(mdev->dev, &priv->res, 1014 err = mlx4_alloc_hwq_res(mdev->dev, &priv->res,
1013 MLX4_EN_PAGE_SIZE, MLX4_EN_PAGE_SIZE); 1015 MLX4_EN_PAGE_SIZE, MLX4_EN_PAGE_SIZE);
diff --git a/drivers/net/mlx4/en_resources.c b/drivers/net/mlx4/en_resources.c
index 65ca706c04bb..16256784a943 100644
--- a/drivers/net/mlx4/en_resources.c
+++ b/drivers/net/mlx4/en_resources.c
@@ -37,7 +37,7 @@
37#include "mlx4_en.h" 37#include "mlx4_en.h"
38 38
39void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride, 39void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride,
40 int is_tx, int rss, int qpn, int cqn, int srqn, 40 int is_tx, int rss, int qpn, int cqn,
41 struct mlx4_qp_context *context) 41 struct mlx4_qp_context *context)
42{ 42{
43 struct mlx4_en_dev *mdev = priv->mdev; 43 struct mlx4_en_dev *mdev = priv->mdev;
@@ -46,11 +46,12 @@ void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride,
46 context->flags = cpu_to_be32(7 << 16 | rss << 13); 46 context->flags = cpu_to_be32(7 << 16 | rss << 13);
47 context->pd = cpu_to_be32(mdev->priv_pdn); 47 context->pd = cpu_to_be32(mdev->priv_pdn);
48 context->mtu_msgmax = 0xff; 48 context->mtu_msgmax = 0xff;
49 context->rq_size_stride = 0; 49 if (!is_tx && !rss)
50 context->rq_size_stride = ilog2(size) << 3 | (ilog2(stride) - 4);
50 if (is_tx) 51 if (is_tx)
51 context->sq_size_stride = ilog2(size) << 3 | (ilog2(stride) - 4); 52 context->sq_size_stride = ilog2(size) << 3 | (ilog2(stride) - 4);
52 else 53 else
53 context->sq_size_stride = 1; 54 context->sq_size_stride = ilog2(TXBB_SIZE) - 4;
54 context->usr_page = cpu_to_be32(mdev->priv_uar.index); 55 context->usr_page = cpu_to_be32(mdev->priv_uar.index);
55 context->local_qpn = cpu_to_be32(qpn); 56 context->local_qpn = cpu_to_be32(qpn);
56 context->pri_path.ackto = 1 & 0x07; 57 context->pri_path.ackto = 1 & 0x07;
@@ -59,8 +60,6 @@ void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride,
59 context->cqn_send = cpu_to_be32(cqn); 60 context->cqn_send = cpu_to_be32(cqn);
60 context->cqn_recv = cpu_to_be32(cqn); 61 context->cqn_recv = cpu_to_be32(cqn);
61 context->db_rec_addr = cpu_to_be64(priv->res.db.dma << 2); 62 context->db_rec_addr = cpu_to_be64(priv->res.db.dma << 2);
62 if (!rss)
63 context->srqn = cpu_to_be32(MLX4_EN_USE_SRQ | srqn);
64} 63}
65 64
66 65
diff --git a/drivers/net/mlx4/en_rx.c b/drivers/net/mlx4/en_rx.c
index 3ac0404d0d11..03b781a7a182 100644
--- a/drivers/net/mlx4/en_rx.c
+++ b/drivers/net/mlx4/en_rx.c
@@ -40,16 +40,6 @@
40 40
41#include "mlx4_en.h" 41#include "mlx4_en.h"
42 42
43static void *get_wqe(struct mlx4_en_rx_ring *ring, int n)
44{
45 int offset = n << ring->srq.wqe_shift;
46 return ring->buf + offset;
47}
48
49static void mlx4_en_srq_event(struct mlx4_srq *srq, enum mlx4_event type)
50{
51 return;
52}
53 43
54static int mlx4_en_get_frag_header(struct skb_frag_struct *frags, void **mac_hdr, 44static int mlx4_en_get_frag_header(struct skb_frag_struct *frags, void **mac_hdr,
55 void **ip_hdr, void **tcpudp_hdr, 45 void **ip_hdr, void **tcpudp_hdr,
@@ -154,9 +144,6 @@ static void mlx4_en_init_rx_desc(struct mlx4_en_priv *priv,
154 int possible_frags; 144 int possible_frags;
155 int i; 145 int i;
156 146
157 /* Pre-link descriptor */
158 rx_desc->next.next_wqe_index = cpu_to_be16((index + 1) & ring->size_mask);
159
160 /* Set size and memtype fields */ 147 /* Set size and memtype fields */
161 for (i = 0; i < priv->num_frags; i++) { 148 for (i = 0; i < priv->num_frags; i++) {
162 skb_frags[i].size = priv->frag_info[i].frag_size; 149 skb_frags[i].size = priv->frag_info[i].frag_size;
@@ -294,9 +281,6 @@ int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv,
294 int err; 281 int err;
295 int tmp; 282 int tmp;
296 283
297 /* Sanity check SRQ size before proceeding */
298 if (size >= mdev->dev->caps.max_srq_wqes)
299 return -EINVAL;
300 284
301 ring->prod = 0; 285 ring->prod = 0;
302 ring->cons = 0; 286 ring->cons = 0;
@@ -304,7 +288,7 @@ int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv,
304 ring->size_mask = size - 1; 288 ring->size_mask = size - 1;
305 ring->stride = stride; 289 ring->stride = stride;
306 ring->log_stride = ffs(ring->stride) - 1; 290 ring->log_stride = ffs(ring->stride) - 1;
307 ring->buf_size = ring->size * ring->stride; 291 ring->buf_size = ring->size * ring->stride + TXBB_SIZE;
308 292
309 tmp = size * roundup_pow_of_two(MLX4_EN_MAX_RX_FRAGS * 293 tmp = size * roundup_pow_of_two(MLX4_EN_MAX_RX_FRAGS *
310 sizeof(struct skb_frag_struct)); 294 sizeof(struct skb_frag_struct));
@@ -360,15 +344,12 @@ err_ring:
360 344
361int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv) 345int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv)
362{ 346{
363 struct mlx4_en_dev *mdev = priv->mdev;
364 struct mlx4_wqe_srq_next_seg *next;
365 struct mlx4_en_rx_ring *ring; 347 struct mlx4_en_rx_ring *ring;
366 int i; 348 int i;
367 int ring_ind; 349 int ring_ind;
368 int err; 350 int err;
369 int stride = roundup_pow_of_two(sizeof(struct mlx4_en_rx_desc) + 351 int stride = roundup_pow_of_two(sizeof(struct mlx4_en_rx_desc) +
370 DS_SIZE * priv->num_frags); 352 DS_SIZE * priv->num_frags);
371 int max_gs = (stride - sizeof(struct mlx4_wqe_srq_next_seg)) / DS_SIZE;
372 353
373 for (ring_ind = 0; ring_ind < priv->rx_ring_num; ring_ind++) { 354 for (ring_ind = 0; ring_ind < priv->rx_ring_num; ring_ind++) {
374 ring = &priv->rx_ring[ring_ind]; 355 ring = &priv->rx_ring[ring_ind];
@@ -379,6 +360,9 @@ int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv)
379 ring->cqn = priv->rx_cq[ring_ind].mcq.cqn; 360 ring->cqn = priv->rx_cq[ring_ind].mcq.cqn;
380 361
381 ring->stride = stride; 362 ring->stride = stride;
363 if (ring->stride <= TXBB_SIZE)
364 ring->buf += TXBB_SIZE;
365
382 ring->log_stride = ffs(ring->stride) - 1; 366 ring->log_stride = ffs(ring->stride) - 1;
383 ring->buf_size = ring->size * ring->stride; 367 ring->buf_size = ring->size * ring->stride;
384 368
@@ -405,37 +389,10 @@ int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv)
405 ring = &priv->rx_ring[ring_ind]; 389 ring = &priv->rx_ring[ring_ind];
406 390
407 mlx4_en_update_rx_prod_db(ring); 391 mlx4_en_update_rx_prod_db(ring);
408
409 /* Configure SRQ representing the ring */
410 ring->srq.max = ring->actual_size;
411 ring->srq.max_gs = max_gs;
412 ring->srq.wqe_shift = ilog2(ring->stride);
413
414 for (i = 0; i < ring->srq.max; ++i) {
415 next = get_wqe(ring, i);
416 next->next_wqe_index =
417 cpu_to_be16((i + 1) & (ring->srq.max - 1));
418 }
419
420 err = mlx4_srq_alloc(mdev->dev, mdev->priv_pdn, &ring->wqres.mtt,
421 ring->wqres.db.dma, &ring->srq);
422 if (err){
423 en_err(priv, "Failed to allocate srq\n");
424 ring_ind--;
425 goto err_srq;
426 }
427 ring->srq.event = mlx4_en_srq_event;
428 } 392 }
429 393
430 return 0; 394 return 0;
431 395
432err_srq:
433 while (ring_ind >= 0) {
434 ring = &priv->rx_ring[ring_ind];
435 mlx4_srq_free(mdev->dev, &ring->srq);
436 ring_ind--;
437 }
438
439err_buffers: 396err_buffers:
440 for (ring_ind = 0; ring_ind < priv->rx_ring_num; ring_ind++) 397 for (ring_ind = 0; ring_ind < priv->rx_ring_num; ring_ind++)
441 mlx4_en_free_rx_buf(priv, &priv->rx_ring[ring_ind]); 398 mlx4_en_free_rx_buf(priv, &priv->rx_ring[ring_ind]);
@@ -456,7 +413,7 @@ void mlx4_en_destroy_rx_ring(struct mlx4_en_priv *priv,
456 413
457 kfree(ring->lro.lro_arr); 414 kfree(ring->lro.lro_arr);
458 mlx4_en_unmap_buffer(&ring->wqres.buf); 415 mlx4_en_unmap_buffer(&ring->wqres.buf);
459 mlx4_free_hwq_res(mdev->dev, &ring->wqres, ring->buf_size); 416 mlx4_free_hwq_res(mdev->dev, &ring->wqres, ring->buf_size + TXBB_SIZE);
460 vfree(ring->rx_info); 417 vfree(ring->rx_info);
461 ring->rx_info = NULL; 418 ring->rx_info = NULL;
462} 419}
@@ -464,10 +421,9 @@ void mlx4_en_destroy_rx_ring(struct mlx4_en_priv *priv,
464void mlx4_en_deactivate_rx_ring(struct mlx4_en_priv *priv, 421void mlx4_en_deactivate_rx_ring(struct mlx4_en_priv *priv,
465 struct mlx4_en_rx_ring *ring) 422 struct mlx4_en_rx_ring *ring)
466{ 423{
467 struct mlx4_en_dev *mdev = priv->mdev;
468
469 mlx4_srq_free(mdev->dev, &ring->srq);
470 mlx4_en_free_rx_buf(priv, ring); 424 mlx4_en_free_rx_buf(priv, ring);
425 if (ring->stride <= TXBB_SIZE)
426 ring->buf -= TXBB_SIZE;
471 mlx4_en_destroy_allocator(priv, ring); 427 mlx4_en_destroy_allocator(priv, ring);
472} 428}
473 429
@@ -836,25 +792,8 @@ void mlx4_en_calc_rx_buf(struct net_device *dev)
836 792
837/* RSS related functions */ 793/* RSS related functions */
838 794
839/* Calculate rss size and map each entry in rss table to rx ring */ 795static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn,
840void mlx4_en_set_default_rss_map(struct mlx4_en_priv *priv, 796 struct mlx4_en_rx_ring *ring,
841 struct mlx4_en_rss_map *rss_map,
842 int num_entries, int num_rings)
843{
844 int i;
845
846 rss_map->size = roundup_pow_of_two(num_entries);
847 en_dbg(DRV, priv, "Setting default RSS map of %d entires\n",
848 rss_map->size);
849
850 for (i = 0; i < rss_map->size; i++) {
851 rss_map->map[i] = i % num_rings;
852 en_dbg(DRV, priv, "Entry %d ---> ring %d\n", i, rss_map->map[i]);
853 }
854}
855
856static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv,
857 int qpn, int srqn, int cqn,
858 enum mlx4_qp_state *state, 797 enum mlx4_qp_state *state,
859 struct mlx4_qp *qp) 798 struct mlx4_qp *qp)
860{ 799{
@@ -876,13 +815,16 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv,
876 qp->event = mlx4_en_sqp_event; 815 qp->event = mlx4_en_sqp_event;
877 816
878 memset(context, 0, sizeof *context); 817 memset(context, 0, sizeof *context);
879 mlx4_en_fill_qp_context(priv, 0, 0, 0, 0, qpn, cqn, srqn, context); 818 mlx4_en_fill_qp_context(priv, ring->size, ring->stride, 0, 0,
819 qpn, ring->cqn, context);
820 context->db_rec_addr = cpu_to_be64(ring->wqres.db.dma);
880 821
881 err = mlx4_qp_to_ready(mdev->dev, &priv->res.mtt, context, qp, state); 822 err = mlx4_qp_to_ready(mdev->dev, &ring->wqres.mtt, context, qp, state);
882 if (err) { 823 if (err) {
883 mlx4_qp_remove(mdev->dev, qp); 824 mlx4_qp_remove(mdev->dev, qp);
884 mlx4_qp_free(mdev->dev, qp); 825 mlx4_qp_free(mdev->dev, qp);
885 } 826 }
827 mlx4_en_update_rx_prod_db(ring);
886out: 828out:
887 kfree(context); 829 kfree(context);
888 return err; 830 return err;
@@ -898,23 +840,22 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
898 void *ptr; 840 void *ptr;
899 int rss_xor = mdev->profile.rss_xor; 841 int rss_xor = mdev->profile.rss_xor;
900 u8 rss_mask = mdev->profile.rss_mask; 842 u8 rss_mask = mdev->profile.rss_mask;
901 int i, srqn, qpn, cqn; 843 int i, qpn;
902 int err = 0; 844 int err = 0;
903 int good_qps = 0; 845 int good_qps = 0;
904 846
905 en_dbg(DRV, priv, "Configuring rss steering\n"); 847 en_dbg(DRV, priv, "Configuring rss steering\n");
906 err = mlx4_qp_reserve_range(mdev->dev, rss_map->size, 848 err = mlx4_qp_reserve_range(mdev->dev, priv->rx_ring_num,
907 rss_map->size, &rss_map->base_qpn); 849 priv->rx_ring_num,
850 &rss_map->base_qpn);
908 if (err) { 851 if (err) {
909 en_err(priv, "Failed reserving %d qps\n", rss_map->size); 852 en_err(priv, "Failed reserving %d qps\n", priv->rx_ring_num);
910 return err; 853 return err;
911 } 854 }
912 855
913 for (i = 0; i < rss_map->size; i++) { 856 for (i = 0; i < priv->rx_ring_num; i++) {
914 cqn = priv->rx_ring[rss_map->map[i]].cqn;
915 srqn = priv->rx_ring[rss_map->map[i]].srq.srqn;
916 qpn = rss_map->base_qpn + i; 857 qpn = rss_map->base_qpn + i;
917 err = mlx4_en_config_rss_qp(priv, qpn, srqn, cqn, 858 err = mlx4_en_config_rss_qp(priv, qpn, &priv->rx_ring[i],
918 &rss_map->state[i], 859 &rss_map->state[i],
919 &rss_map->qps[i]); 860 &rss_map->qps[i]);
920 if (err) 861 if (err)
@@ -937,11 +878,11 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
937 } 878 }
938 rss_map->indir_qp.event = mlx4_en_sqp_event; 879 rss_map->indir_qp.event = mlx4_en_sqp_event;
939 mlx4_en_fill_qp_context(priv, 0, 0, 0, 1, priv->base_qpn, 880 mlx4_en_fill_qp_context(priv, 0, 0, 0, 1, priv->base_qpn,
940 priv->rx_ring[0].cqn, 0, &context); 881 priv->rx_ring[0].cqn, &context);
941 882
942 ptr = ((void *) &context) + 0x3c; 883 ptr = ((void *) &context) + 0x3c;
943 rss_context = (struct mlx4_en_rss_context *) ptr; 884 rss_context = (struct mlx4_en_rss_context *) ptr;
944 rss_context->base_qpn = cpu_to_be32(ilog2(rss_map->size) << 24 | 885 rss_context->base_qpn = cpu_to_be32(ilog2(priv->rx_ring_num) << 24 |
945 (rss_map->base_qpn)); 886 (rss_map->base_qpn));
946 rss_context->default_qpn = cpu_to_be32(rss_map->base_qpn); 887 rss_context->default_qpn = cpu_to_be32(rss_map->base_qpn);
947 rss_context->hash_fn = rss_xor & 0x3; 888 rss_context->hash_fn = rss_xor & 0x3;
@@ -968,7 +909,7 @@ rss_err:
968 mlx4_qp_remove(mdev->dev, &rss_map->qps[i]); 909 mlx4_qp_remove(mdev->dev, &rss_map->qps[i]);
969 mlx4_qp_free(mdev->dev, &rss_map->qps[i]); 910 mlx4_qp_free(mdev->dev, &rss_map->qps[i]);
970 } 911 }
971 mlx4_qp_release_range(mdev->dev, rss_map->base_qpn, rss_map->size); 912 mlx4_qp_release_range(mdev->dev, rss_map->base_qpn, priv->rx_ring_num);
972 return err; 913 return err;
973} 914}
974 915
@@ -984,13 +925,13 @@ void mlx4_en_release_rss_steer(struct mlx4_en_priv *priv)
984 mlx4_qp_free(mdev->dev, &rss_map->indir_qp); 925 mlx4_qp_free(mdev->dev, &rss_map->indir_qp);
985 mlx4_qp_release_range(mdev->dev, priv->base_qpn, 1); 926 mlx4_qp_release_range(mdev->dev, priv->base_qpn, 1);
986 927
987 for (i = 0; i < rss_map->size; i++) { 928 for (i = 0; i < priv->rx_ring_num; i++) {
988 mlx4_qp_modify(mdev->dev, NULL, rss_map->state[i], 929 mlx4_qp_modify(mdev->dev, NULL, rss_map->state[i],
989 MLX4_QP_STATE_RST, NULL, 0, 0, &rss_map->qps[i]); 930 MLX4_QP_STATE_RST, NULL, 0, 0, &rss_map->qps[i]);
990 mlx4_qp_remove(mdev->dev, &rss_map->qps[i]); 931 mlx4_qp_remove(mdev->dev, &rss_map->qps[i]);
991 mlx4_qp_free(mdev->dev, &rss_map->qps[i]); 932 mlx4_qp_free(mdev->dev, &rss_map->qps[i]);
992 } 933 }
993 mlx4_qp_release_range(mdev->dev, rss_map->base_qpn, rss_map->size); 934 mlx4_qp_release_range(mdev->dev, rss_map->base_qpn, priv->rx_ring_num);
994} 935}
995 936
996 937
diff --git a/drivers/net/mlx4/en_tx.c b/drivers/net/mlx4/en_tx.c
index 62208401c4df..8c7279965b44 100644
--- a/drivers/net/mlx4/en_tx.c
+++ b/drivers/net/mlx4/en_tx.c
@@ -150,7 +150,7 @@ void mlx4_en_destroy_tx_ring(struct mlx4_en_priv *priv,
150 150
151int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv, 151int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv,
152 struct mlx4_en_tx_ring *ring, 152 struct mlx4_en_tx_ring *ring,
153 int cq, int srqn) 153 int cq)
154{ 154{
155 struct mlx4_en_dev *mdev = priv->mdev; 155 struct mlx4_en_dev *mdev = priv->mdev;
156 int err; 156 int err;
@@ -168,7 +168,7 @@ int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv,
168 ring->doorbell_qpn = swab32(ring->qp.qpn << 8); 168 ring->doorbell_qpn = swab32(ring->qp.qpn << 8);
169 169
170 mlx4_en_fill_qp_context(priv, ring->size, ring->stride, 1, 0, ring->qpn, 170 mlx4_en_fill_qp_context(priv, ring->size, ring->stride, 1, 0, ring->qpn,
171 ring->cqn, srqn, &ring->context); 171 ring->cqn, &ring->context);
172 172
173 err = mlx4_qp_to_ready(mdev->dev, &ring->wqres.mtt, &ring->context, 173 err = mlx4_qp_to_ready(mdev->dev, &ring->wqres.mtt, &ring->context,
174 &ring->qp, &ring->qp_state); 174 &ring->qp, &ring->qp_state);
@@ -589,7 +589,7 @@ u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb)
589 return skb_tx_hash(dev, skb); 589 return skb_tx_hash(dev, skb);
590} 590}
591 591
592int mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) 592netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
593{ 593{
594 struct mlx4_en_priv *priv = netdev_priv(dev); 594 struct mlx4_en_priv *priv = netdev_priv(dev);
595 struct mlx4_en_dev *mdev = priv->mdev; 595 struct mlx4_en_dev *mdev = priv->mdev;
@@ -766,7 +766,7 @@ int mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
766 /* Poll CQ here */ 766 /* Poll CQ here */
767 mlx4_en_xmit_poll(priv, tx_ind); 767 mlx4_en_xmit_poll(priv, tx_ind);
768 768
769 return 0; 769 return NETDEV_TX_OK;
770 770
771tx_drop: 771tx_drop:
772 dev_kfree_skb_any(skb); 772 dev_kfree_skb_any(skb);
diff --git a/drivers/net/mlx4/mlx4_en.h b/drivers/net/mlx4/mlx4_en.h
index c7c5e86804ff..4376147b0ea0 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
@@ -276,13 +274,11 @@ struct mlx4_en_tx_ring {
276}; 274};
277 275
278struct mlx4_en_rx_desc { 276struct mlx4_en_rx_desc {
279 struct mlx4_wqe_srq_next_seg next;
280 /* actual number of entries depends on rx ring stride */ 277 /* actual number of entries depends on rx ring stride */
281 struct mlx4_wqe_data_seg data[0]; 278 struct mlx4_wqe_data_seg data[0];
282}; 279};
283 280
284struct mlx4_en_rx_ring { 281struct mlx4_en_rx_ring {
285 struct mlx4_srq srq;
286 struct mlx4_hwq_resources wqres; 282 struct mlx4_hwq_resources wqres;
287 struct mlx4_en_rx_alloc page_alloc[MLX4_EN_MAX_RX_FRAGS]; 283 struct mlx4_en_rx_alloc page_alloc[MLX4_EN_MAX_RX_FRAGS];
288 struct net_lro_mgr lro; 284 struct net_lro_mgr lro;
@@ -377,11 +373,9 @@ struct mlx4_en_dev {
377 373
378 374
379struct mlx4_en_rss_map { 375struct mlx4_en_rss_map {
380 int size;
381 int base_qpn; 376 int base_qpn;
382 u16 map[MAX_RSS_MAP_SIZE]; 377 struct mlx4_qp qps[MAX_RX_RINGS];
383 struct mlx4_qp qps[MAX_RSS_MAP_SIZE]; 378 enum mlx4_qp_state state[MAX_RX_RINGS];
384 enum mlx4_qp_state state[MAX_RSS_MAP_SIZE];
385 struct mlx4_qp indir_qp; 379 struct mlx4_qp indir_qp;
386 enum mlx4_qp_state indir_state; 380 enum mlx4_qp_state indir_state;
387}; 381};
@@ -524,14 +518,14 @@ int mlx4_en_arm_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
524void mlx4_en_poll_tx_cq(unsigned long data); 518void mlx4_en_poll_tx_cq(unsigned long data);
525void mlx4_en_tx_irq(struct mlx4_cq *mcq); 519void mlx4_en_tx_irq(struct mlx4_cq *mcq);
526u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb); 520u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb);
527int mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev); 521netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev);
528 522
529int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring, 523int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring,
530 u32 size, u16 stride); 524 u32 size, u16 stride);
531void mlx4_en_destroy_tx_ring(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring); 525void mlx4_en_destroy_tx_ring(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring);
532int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv, 526int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv,
533 struct mlx4_en_tx_ring *ring, 527 struct mlx4_en_tx_ring *ring,
534 int cq, int srqn); 528 int cq);
535void mlx4_en_deactivate_tx_ring(struct mlx4_en_priv *priv, 529void mlx4_en_deactivate_tx_ring(struct mlx4_en_priv *priv,
536 struct mlx4_en_tx_ring *ring); 530 struct mlx4_en_tx_ring *ring);
537 531
@@ -548,16 +542,13 @@ int mlx4_en_process_rx_cq(struct net_device *dev,
548 int budget); 542 int budget);
549int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget); 543int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget);
550void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride, 544void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride,
551 int is_tx, int rss, int qpn, int cqn, int srqn, 545 int is_tx, int rss, int qpn, int cqn,
552 struct mlx4_qp_context *context); 546 struct mlx4_qp_context *context);
553void mlx4_en_sqp_event(struct mlx4_qp *qp, enum mlx4_event event); 547void mlx4_en_sqp_event(struct mlx4_qp *qp, enum mlx4_event event);
554int mlx4_en_map_buffer(struct mlx4_buf *buf); 548int mlx4_en_map_buffer(struct mlx4_buf *buf);
555void mlx4_en_unmap_buffer(struct mlx4_buf *buf); 549void mlx4_en_unmap_buffer(struct mlx4_buf *buf);
556 550
557void mlx4_en_calc_rx_buf(struct net_device *dev); 551void 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); 552int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv);
562void mlx4_en_release_rss_steer(struct mlx4_en_priv *priv); 553void 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); 554int mlx4_en_free_tx_buf(struct net_device *dev, struct mlx4_en_tx_ring *ring);