diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2012-02-22 20:36:17 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2012-02-22 20:36:17 -0500 |
commit | daefd89efc279b142bbb054577c2d706da211723 (patch) | |
tree | 2298056232548f6f22d7bbff2662a2bbf64520de /drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | |
parent | 6e33aceda2d82126e9d08a39e21a15be0dd00a6c (diff) | |
parent | f86bcc302a8c570dd0f5a50097a6af96a0e717c2 (diff) |
Merge branch 'for_3.4/gpio/runtime-pm-cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm into gpio/next
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx4/en_ethtool.c')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 159 |
1 files changed, 143 insertions, 16 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c index 7dbc6a230779..70346fd7f9c4 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | |||
@@ -183,10 +183,11 @@ static int mlx4_en_set_wol(struct net_device *netdev, | |||
183 | static int mlx4_en_get_sset_count(struct net_device *dev, int sset) | 183 | static int mlx4_en_get_sset_count(struct net_device *dev, int sset) |
184 | { | 184 | { |
185 | struct mlx4_en_priv *priv = netdev_priv(dev); | 185 | struct mlx4_en_priv *priv = netdev_priv(dev); |
186 | int bit_count = hweight64(priv->stats_bitmap); | ||
186 | 187 | ||
187 | switch (sset) { | 188 | switch (sset) { |
188 | case ETH_SS_STATS: | 189 | case ETH_SS_STATS: |
189 | return NUM_ALL_STATS + | 190 | return (priv->stats_bitmap ? bit_count : NUM_ALL_STATS) + |
190 | (priv->tx_ring_num + priv->rx_ring_num) * 2; | 191 | (priv->tx_ring_num + priv->rx_ring_num) * 2; |
191 | case ETH_SS_TEST: | 192 | case ETH_SS_TEST: |
192 | return MLX4_EN_NUM_SELF_TEST - !(priv->mdev->dev->caps.flags | 193 | return MLX4_EN_NUM_SELF_TEST - !(priv->mdev->dev->caps.flags |
@@ -201,14 +202,34 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev, | |||
201 | { | 202 | { |
202 | struct mlx4_en_priv *priv = netdev_priv(dev); | 203 | struct mlx4_en_priv *priv = netdev_priv(dev); |
203 | int index = 0; | 204 | int index = 0; |
204 | int i; | 205 | int i, j = 0; |
205 | 206 | ||
206 | spin_lock_bh(&priv->stats_lock); | 207 | spin_lock_bh(&priv->stats_lock); |
207 | 208 | ||
208 | for (i = 0; i < NUM_MAIN_STATS; i++) | 209 | if (!(priv->stats_bitmap)) { |
209 | data[index++] = ((unsigned long *) &priv->stats)[i]; | 210 | for (i = 0; i < NUM_MAIN_STATS; i++) |
210 | for (i = 0; i < NUM_PORT_STATS; i++) | 211 | data[index++] = |
211 | data[index++] = ((unsigned long *) &priv->port_stats)[i]; | 212 | ((unsigned long *) &priv->stats)[i]; |
213 | for (i = 0; i < NUM_PORT_STATS; i++) | ||
214 | data[index++] = | ||
215 | ((unsigned long *) &priv->port_stats)[i]; | ||
216 | for (i = 0; i < NUM_PKT_STATS; i++) | ||
217 | data[index++] = | ||
218 | ((unsigned long *) &priv->pkstats)[i]; | ||
219 | } else { | ||
220 | for (i = 0; i < NUM_MAIN_STATS; i++) { | ||
221 | if ((priv->stats_bitmap >> j) & 1) | ||
222 | data[index++] = | ||
223 | ((unsigned long *) &priv->stats)[i]; | ||
224 | j++; | ||
225 | } | ||
226 | for (i = 0; i < NUM_PORT_STATS; i++) { | ||
227 | if ((priv->stats_bitmap >> j) & 1) | ||
228 | data[index++] = | ||
229 | ((unsigned long *) &priv->port_stats)[i]; | ||
230 | j++; | ||
231 | } | ||
232 | } | ||
212 | for (i = 0; i < priv->tx_ring_num; i++) { | 233 | for (i = 0; i < priv->tx_ring_num; i++) { |
213 | data[index++] = priv->tx_ring[i].packets; | 234 | data[index++] = priv->tx_ring[i].packets; |
214 | data[index++] = priv->tx_ring[i].bytes; | 235 | data[index++] = priv->tx_ring[i].bytes; |
@@ -217,8 +238,6 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev, | |||
217 | data[index++] = priv->rx_ring[i].packets; | 238 | data[index++] = priv->rx_ring[i].packets; |
218 | data[index++] = priv->rx_ring[i].bytes; | 239 | data[index++] = priv->rx_ring[i].bytes; |
219 | } | 240 | } |
220 | for (i = 0; i < NUM_PKT_STATS; i++) | ||
221 | data[index++] = ((unsigned long *) &priv->pkstats)[i]; | ||
222 | spin_unlock_bh(&priv->stats_lock); | 241 | spin_unlock_bh(&priv->stats_lock); |
223 | 242 | ||
224 | } | 243 | } |
@@ -247,11 +266,29 @@ static void mlx4_en_get_strings(struct net_device *dev, | |||
247 | 266 | ||
248 | case ETH_SS_STATS: | 267 | case ETH_SS_STATS: |
249 | /* Add main counters */ | 268 | /* Add main counters */ |
250 | for (i = 0; i < NUM_MAIN_STATS; i++) | 269 | if (!priv->stats_bitmap) { |
251 | strcpy(data + (index++) * ETH_GSTRING_LEN, main_strings[i]); | 270 | for (i = 0; i < NUM_MAIN_STATS; i++) |
252 | for (i = 0; i< NUM_PORT_STATS; i++) | 271 | strcpy(data + (index++) * ETH_GSTRING_LEN, |
253 | strcpy(data + (index++) * ETH_GSTRING_LEN, | 272 | main_strings[i]); |
254 | main_strings[i + NUM_MAIN_STATS]); | 273 | for (i = 0; i < NUM_PORT_STATS; i++) |
274 | strcpy(data + (index++) * ETH_GSTRING_LEN, | ||
275 | main_strings[i + | ||
276 | NUM_MAIN_STATS]); | ||
277 | for (i = 0; i < NUM_PKT_STATS; i++) | ||
278 | strcpy(data + (index++) * ETH_GSTRING_LEN, | ||
279 | main_strings[i + | ||
280 | NUM_MAIN_STATS + | ||
281 | NUM_PORT_STATS]); | ||
282 | } else | ||
283 | for (i = 0; i < NUM_MAIN_STATS + NUM_PORT_STATS; i++) { | ||
284 | if ((priv->stats_bitmap >> i) & 1) { | ||
285 | strcpy(data + | ||
286 | (index++) * ETH_GSTRING_LEN, | ||
287 | main_strings[i]); | ||
288 | } | ||
289 | if (!(priv->stats_bitmap >> i)) | ||
290 | break; | ||
291 | } | ||
255 | for (i = 0; i < priv->tx_ring_num; i++) { | 292 | for (i = 0; i < priv->tx_ring_num; i++) { |
256 | sprintf(data + (index++) * ETH_GSTRING_LEN, | 293 | sprintf(data + (index++) * ETH_GSTRING_LEN, |
257 | "tx%d_packets", i); | 294 | "tx%d_packets", i); |
@@ -264,9 +301,6 @@ static void mlx4_en_get_strings(struct net_device *dev, | |||
264 | sprintf(data + (index++) * ETH_GSTRING_LEN, | 301 | sprintf(data + (index++) * ETH_GSTRING_LEN, |
265 | "rx%d_bytes", i); | 302 | "rx%d_bytes", i); |
266 | } | 303 | } |
267 | for (i = 0; i< NUM_PKT_STATS; i++) | ||
268 | strcpy(data + (index++) * ETH_GSTRING_LEN, | ||
269 | main_strings[i + NUM_MAIN_STATS + NUM_PORT_STATS]); | ||
270 | break; | 304 | break; |
271 | } | 305 | } |
272 | } | 306 | } |
@@ -479,6 +513,95 @@ static void mlx4_en_get_ringparam(struct net_device *dev, | |||
479 | param->tx_pending = priv->tx_ring[0].size; | 513 | param->tx_pending = priv->tx_ring[0].size; |
480 | } | 514 | } |
481 | 515 | ||
516 | static u32 mlx4_en_get_rxfh_indir_size(struct net_device *dev) | ||
517 | { | ||
518 | struct mlx4_en_priv *priv = netdev_priv(dev); | ||
519 | |||
520 | return priv->rx_ring_num; | ||
521 | } | ||
522 | |||
523 | static int mlx4_en_get_rxfh_indir(struct net_device *dev, u32 *ring_index) | ||
524 | { | ||
525 | struct mlx4_en_priv *priv = netdev_priv(dev); | ||
526 | struct mlx4_en_rss_map *rss_map = &priv->rss_map; | ||
527 | int rss_rings; | ||
528 | size_t n = priv->rx_ring_num; | ||
529 | int err = 0; | ||
530 | |||
531 | rss_rings = priv->prof->rss_rings ?: priv->rx_ring_num; | ||
532 | |||
533 | while (n--) { | ||
534 | ring_index[n] = rss_map->qps[n % rss_rings].qpn - | ||
535 | rss_map->base_qpn; | ||
536 | } | ||
537 | |||
538 | return err; | ||
539 | } | ||
540 | |||
541 | static int mlx4_en_set_rxfh_indir(struct net_device *dev, | ||
542 | const u32 *ring_index) | ||
543 | { | ||
544 | struct mlx4_en_priv *priv = netdev_priv(dev); | ||
545 | struct mlx4_en_dev *mdev = priv->mdev; | ||
546 | int port_up = 0; | ||
547 | int err = 0; | ||
548 | int i; | ||
549 | int rss_rings = 0; | ||
550 | |||
551 | /* Calculate RSS table size and make sure flows are spread evenly | ||
552 | * between rings | ||
553 | */ | ||
554 | for (i = 0; i < priv->rx_ring_num; i++) { | ||
555 | if (i > 0 && !ring_index[i] && !rss_rings) | ||
556 | rss_rings = i; | ||
557 | |||
558 | if (ring_index[i] != (i % (rss_rings ?: priv->rx_ring_num))) | ||
559 | return -EINVAL; | ||
560 | } | ||
561 | |||
562 | if (!rss_rings) | ||
563 | rss_rings = priv->rx_ring_num; | ||
564 | |||
565 | /* RSS table size must be an order of 2 */ | ||
566 | if (!is_power_of_2(rss_rings)) | ||
567 | return -EINVAL; | ||
568 | |||
569 | mutex_lock(&mdev->state_lock); | ||
570 | if (priv->port_up) { | ||
571 | port_up = 1; | ||
572 | mlx4_en_stop_port(dev); | ||
573 | } | ||
574 | |||
575 | priv->prof->rss_rings = rss_rings; | ||
576 | |||
577 | if (port_up) { | ||
578 | err = mlx4_en_start_port(dev); | ||
579 | if (err) | ||
580 | en_err(priv, "Failed starting port\n"); | ||
581 | } | ||
582 | |||
583 | mutex_unlock(&mdev->state_lock); | ||
584 | return err; | ||
585 | } | ||
586 | |||
587 | static int mlx4_en_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, | ||
588 | u32 *rule_locs) | ||
589 | { | ||
590 | struct mlx4_en_priv *priv = netdev_priv(dev); | ||
591 | int err = 0; | ||
592 | |||
593 | switch (cmd->cmd) { | ||
594 | case ETHTOOL_GRXRINGS: | ||
595 | cmd->data = priv->rx_ring_num; | ||
596 | break; | ||
597 | default: | ||
598 | err = -EOPNOTSUPP; | ||
599 | break; | ||
600 | } | ||
601 | |||
602 | return err; | ||
603 | } | ||
604 | |||
482 | const struct ethtool_ops mlx4_en_ethtool_ops = { | 605 | const struct ethtool_ops mlx4_en_ethtool_ops = { |
483 | .get_drvinfo = mlx4_en_get_drvinfo, | 606 | .get_drvinfo = mlx4_en_get_drvinfo, |
484 | .get_settings = mlx4_en_get_settings, | 607 | .get_settings = mlx4_en_get_settings, |
@@ -498,6 +621,10 @@ const struct ethtool_ops mlx4_en_ethtool_ops = { | |||
498 | .set_pauseparam = mlx4_en_set_pauseparam, | 621 | .set_pauseparam = mlx4_en_set_pauseparam, |
499 | .get_ringparam = mlx4_en_get_ringparam, | 622 | .get_ringparam = mlx4_en_get_ringparam, |
500 | .set_ringparam = mlx4_en_set_ringparam, | 623 | .set_ringparam = mlx4_en_set_ringparam, |
624 | .get_rxnfc = mlx4_en_get_rxnfc, | ||
625 | .get_rxfh_indir_size = mlx4_en_get_rxfh_indir_size, | ||
626 | .get_rxfh_indir = mlx4_en_get_rxfh_indir, | ||
627 | .set_rxfh_indir = mlx4_en_set_rxfh_indir, | ||
501 | }; | 628 | }; |
502 | 629 | ||
503 | 630 | ||