aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugenia Emantayev <eugenia@mellanox.com>2013-11-07 05:19:52 -0500
committerDavid S. Miller <davem@davemloft.net>2013-11-07 19:22:48 -0500
commit41d942d56cfd21058fba465804e14ba349541442 (patch)
treef377a2454a9a9e1ed117851ddf335354e6e3120a
parentf0f829bf42cdeb027234a1d0e1e5f62d77380a4d (diff)
net/mlx4_en: Datapath resources allocated dynamically
Currently all TX/RX rings and completion queues are part of the netdev priv structure and are allocated statically. This patch will change the priv to hold only arrays of pointers and therefore all TX/RX rings and completetion queues will be allocated dynamically. This is in preparation for NUMA aware allocations. Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.com> Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com> Reviewed-by: Hadar Hen Zion <hadarh@mellanox.com> Signed-off-by: Amir Vadai <amirv@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_cq.c34
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_ethtool.c36
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c87
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_port.c14
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c57
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_selftest.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c32
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4_en.h27
8 files changed, 178 insertions, 111 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_cq.c b/drivers/net/ethernet/mellanox/mlx4/en_cq.c
index 3e2d5047cdb3..d203f11b9edf 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_cq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_cq.c
@@ -44,12 +44,19 @@ static void mlx4_en_cq_event(struct mlx4_cq *cq, enum mlx4_event event)
44 44
45 45
46int mlx4_en_create_cq(struct mlx4_en_priv *priv, 46int mlx4_en_create_cq(struct mlx4_en_priv *priv,
47 struct mlx4_en_cq *cq, 47 struct mlx4_en_cq **pcq,
48 int entries, int ring, enum cq_type mode) 48 int entries, int ring, enum cq_type mode)
49{ 49{
50 struct mlx4_en_dev *mdev = priv->mdev; 50 struct mlx4_en_dev *mdev = priv->mdev;
51 struct mlx4_en_cq *cq;
51 int err; 52 int err;
52 53
54 cq = kzalloc(sizeof(*cq), GFP_KERNEL);
55 if (!cq) {
56 en_err(priv, "Failed to allocate CQ structure\n");
57 return -ENOMEM;
58 }
59
53 cq->size = entries; 60 cq->size = entries;
54 cq->buf_size = cq->size * mdev->dev->caps.cqe_size; 61 cq->buf_size = cq->size * mdev->dev->caps.cqe_size;
55 62
@@ -60,14 +67,22 @@ int mlx4_en_create_cq(struct mlx4_en_priv *priv,
60 err = mlx4_alloc_hwq_res(mdev->dev, &cq->wqres, 67 err = mlx4_alloc_hwq_res(mdev->dev, &cq->wqres,
61 cq->buf_size, 2 * PAGE_SIZE); 68 cq->buf_size, 2 * PAGE_SIZE);
62 if (err) 69 if (err)
63 return err; 70 goto err_cq;
64 71
65 err = mlx4_en_map_buffer(&cq->wqres.buf); 72 err = mlx4_en_map_buffer(&cq->wqres.buf);
66 if (err) 73 if (err)
67 mlx4_free_hwq_res(mdev->dev, &cq->wqres, cq->buf_size); 74 goto err_res;
68 else 75
69 cq->buf = (struct mlx4_cqe *) cq->wqres.buf.direct.buf; 76 cq->buf = (struct mlx4_cqe *)cq->wqres.buf.direct.buf;
77 *pcq = cq;
70 78
79 return 0;
80
81err_res:
82 mlx4_free_hwq_res(mdev->dev, &cq->wqres, cq->buf_size);
83err_cq:
84 kfree(cq);
85 *pcq = NULL;
71 return err; 86 return err;
72} 87}
73 88
@@ -117,12 +132,12 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq,
117 struct mlx4_en_cq *rx_cq; 132 struct mlx4_en_cq *rx_cq;
118 133
119 cq_idx = cq_idx % priv->rx_ring_num; 134 cq_idx = cq_idx % priv->rx_ring_num;
120 rx_cq = &priv->rx_cq[cq_idx]; 135 rx_cq = priv->rx_cq[cq_idx];
121 cq->vector = rx_cq->vector; 136 cq->vector = rx_cq->vector;
122 } 137 }
123 138
124 if (!cq->is_tx) 139 if (!cq->is_tx)
125 cq->size = priv->rx_ring[cq->ring].actual_size; 140 cq->size = priv->rx_ring[cq->ring]->actual_size;
126 141
127 if ((cq->is_tx && priv->hwtstamp_config.tx_type) || 142 if ((cq->is_tx && priv->hwtstamp_config.tx_type) ||
128 (!cq->is_tx && priv->hwtstamp_config.rx_filter)) 143 (!cq->is_tx && priv->hwtstamp_config.rx_filter))
@@ -146,9 +161,10 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq,
146 return 0; 161 return 0;
147} 162}
148 163
149void mlx4_en_destroy_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq) 164void mlx4_en_destroy_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq **pcq)
150{ 165{
151 struct mlx4_en_dev *mdev = priv->mdev; 166 struct mlx4_en_dev *mdev = priv->mdev;
167 struct mlx4_en_cq *cq = *pcq;
152 168
153 mlx4_en_unmap_buffer(&cq->wqres.buf); 169 mlx4_en_unmap_buffer(&cq->wqres.buf);
154 mlx4_free_hwq_res(mdev->dev, &cq->wqres, cq->buf_size); 170 mlx4_free_hwq_res(mdev->dev, &cq->wqres, cq->buf_size);
@@ -157,6 +173,8 @@ void mlx4_en_destroy_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq)
157 cq->vector = 0; 173 cq->vector = 0;
158 cq->buf_size = 0; 174 cq->buf_size = 0;
159 cq->buf = NULL; 175 cq->buf = NULL;
176 kfree(cq);
177 *pcq = NULL;
160} 178}
161 179
162void mlx4_en_deactivate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq) 180void mlx4_en_deactivate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index 0c750985f47e..0596f9f85a0e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -51,10 +51,10 @@ static int mlx4_en_moderation_update(struct mlx4_en_priv *priv)
51 int err = 0; 51 int err = 0;
52 52
53 for (i = 0; i < priv->tx_ring_num; i++) { 53 for (i = 0; i < priv->tx_ring_num; i++) {
54 priv->tx_cq[i].moder_cnt = priv->tx_frames; 54 priv->tx_cq[i]->moder_cnt = priv->tx_frames;
55 priv->tx_cq[i].moder_time = priv->tx_usecs; 55 priv->tx_cq[i]->moder_time = priv->tx_usecs;
56 if (priv->port_up) { 56 if (priv->port_up) {
57 err = mlx4_en_set_cq_moder(priv, &priv->tx_cq[i]); 57 err = mlx4_en_set_cq_moder(priv, priv->tx_cq[i]);
58 if (err) 58 if (err)
59 return err; 59 return err;
60 } 60 }
@@ -64,11 +64,11 @@ static int mlx4_en_moderation_update(struct mlx4_en_priv *priv)
64 return 0; 64 return 0;
65 65
66 for (i = 0; i < priv->rx_ring_num; i++) { 66 for (i = 0; i < priv->rx_ring_num; i++) {
67 priv->rx_cq[i].moder_cnt = priv->rx_frames; 67 priv->rx_cq[i]->moder_cnt = priv->rx_frames;
68 priv->rx_cq[i].moder_time = priv->rx_usecs; 68 priv->rx_cq[i]->moder_time = priv->rx_usecs;
69 priv->last_moder_time[i] = MLX4_EN_AUTO_CONF; 69 priv->last_moder_time[i] = MLX4_EN_AUTO_CONF;
70 if (priv->port_up) { 70 if (priv->port_up) {
71 err = mlx4_en_set_cq_moder(priv, &priv->rx_cq[i]); 71 err = mlx4_en_set_cq_moder(priv, priv->rx_cq[i]);
72 if (err) 72 if (err)
73 return err; 73 return err;
74 } 74 }
@@ -274,16 +274,16 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,
274 } 274 }
275 } 275 }
276 for (i = 0; i < priv->tx_ring_num; i++) { 276 for (i = 0; i < priv->tx_ring_num; i++) {
277 data[index++] = priv->tx_ring[i].packets; 277 data[index++] = priv->tx_ring[i]->packets;
278 data[index++] = priv->tx_ring[i].bytes; 278 data[index++] = priv->tx_ring[i]->bytes;
279 } 279 }
280 for (i = 0; i < priv->rx_ring_num; i++) { 280 for (i = 0; i < priv->rx_ring_num; i++) {
281 data[index++] = priv->rx_ring[i].packets; 281 data[index++] = priv->rx_ring[i]->packets;
282 data[index++] = priv->rx_ring[i].bytes; 282 data[index++] = priv->rx_ring[i]->bytes;
283#ifdef CONFIG_NET_RX_BUSY_POLL 283#ifdef CONFIG_NET_RX_BUSY_POLL
284 data[index++] = priv->rx_ring[i].yields; 284 data[index++] = priv->rx_ring[i]->yields;
285 data[index++] = priv->rx_ring[i].misses; 285 data[index++] = priv->rx_ring[i]->misses;
286 data[index++] = priv->rx_ring[i].cleaned; 286 data[index++] = priv->rx_ring[i]->cleaned;
287#endif 287#endif
288 } 288 }
289 spin_unlock_bh(