2008-10-23 06:47:49 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Mellanox Technologies. All rights reserved.
|
|
|
|
*
|
|
|
|
* This software is available to you under a choice of one of two
|
|
|
|
* licenses. You may choose to be licensed under the terms of the GNU
|
|
|
|
* General Public License (GPL) Version 2, available from the file
|
|
|
|
* COPYING in the main directory of this source tree, or the
|
|
|
|
* OpenIB.org BSD license below:
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or
|
|
|
|
* without modification, are permitted provided that the following
|
|
|
|
* conditions are met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer.
|
|
|
|
*
|
|
|
|
* - Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials
|
|
|
|
* provided with the distribution.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <linux/if_vlan.h>
|
|
|
|
|
|
|
|
#include <linux/mlx4/device.h>
|
|
|
|
#include <linux/mlx4/cmd.h>
|
|
|
|
|
|
|
|
#include "en_port.h"
|
|
|
|
#include "mlx4_en.h"
|
|
|
|
|
|
|
|
|
2011-07-20 12:54:22 +08:00
|
|
|
int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, struct mlx4_en_priv *priv)
|
2008-10-23 06:47:49 +08:00
|
|
|
{
|
|
|
|
struct mlx4_cmd_mailbox *mailbox;
|
|
|
|
struct mlx4_set_vlan_fltr_mbox *filter;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int index = 0;
|
|
|
|
u32 entry;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
mailbox = mlx4_alloc_cmd_mailbox(dev);
|
|
|
|
if (IS_ERR(mailbox))
|
|
|
|
return PTR_ERR(mailbox);
|
|
|
|
|
|
|
|
filter = mailbox->buf;
|
2011-07-20 12:54:22 +08:00
|
|
|
for (i = VLAN_FLTR_SIZE - 1; i >= 0; i--) {
|
|
|
|
entry = 0;
|
|
|
|
for (j = 0; j < 32; j++)
|
|
|
|
if (test_bit(index++, priv->active_vlans))
|
|
|
|
entry |= 1 << j;
|
|
|
|
filter->entry[i] = cpu_to_be32(entry);
|
2008-10-23 06:47:49 +08:00
|
|
|
}
|
2011-07-20 12:54:22 +08:00
|
|
|
err = mlx4_cmd(dev, mailbox->dma, priv->port, 0, MLX4_CMD_SET_VLAN_FLTR,
|
2011-12-13 12:10:51 +08:00
|
|
|
MLX4_CMD_TIME_CLASS_B, MLX4_CMD_WRAPPED);
|
2008-10-23 06:47:49 +08:00
|
|
|
mlx4_free_cmd_mailbox(dev, mailbox);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2010-08-24 11:46:18 +08:00
|
|
|
int mlx4_en_QUERY_PORT(struct mlx4_en_dev *mdev, u8 port)
|
|
|
|
{
|
|
|
|
struct mlx4_en_query_port_context *qport_context;
|
|
|
|
struct mlx4_en_priv *priv = netdev_priv(mdev->pndev[port]);
|
|
|
|
struct mlx4_en_port_state *state = &priv->port_state;
|
|
|
|
struct mlx4_cmd_mailbox *mailbox;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
mailbox = mlx4_alloc_cmd_mailbox(mdev->dev);
|
|
|
|
if (IS_ERR(mailbox))
|
|
|
|
return PTR_ERR(mailbox);
|
|
|
|
err = mlx4_cmd_box(mdev->dev, 0, mailbox->dma, port, 0,
|
2011-12-13 12:10:51 +08:00
|
|
|
MLX4_CMD_QUERY_PORT, MLX4_CMD_TIME_CLASS_B,
|
|
|
|
MLX4_CMD_WRAPPED);
|
2010-08-24 11:46:18 +08:00
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
qport_context = mailbox->buf;
|
|
|
|
|
|
|
|
/* This command is always accessed from Ethtool context
|
|
|
|
* already synchronized, no need in locking */
|
|
|
|
state->link_state = !!(qport_context->link_up & MLX4_EN_LINK_UP_MASK);
|
2011-10-09 13:29:42 +08:00
|
|
|
switch (qport_context->link_speed & MLX4_EN_SPEED_MASK) {
|
2014-10-27 17:37:39 +08:00
|
|
|
case MLX4_EN_100M_SPEED:
|
|
|
|
state->link_speed = SPEED_100;
|
|
|
|
break;
|
2011-10-09 13:29:42 +08:00
|
|
|
case MLX4_EN_1G_SPEED:
|
2014-10-27 17:37:39 +08:00
|
|
|
state->link_speed = SPEED_1000;
|
2011-10-09 13:29:42 +08:00
|
|
|
break;
|
|
|
|
case MLX4_EN_10G_SPEED_XAUI:
|
|
|
|
case MLX4_EN_10G_SPEED_XFI:
|
2014-10-27 17:37:39 +08:00
|
|
|
state->link_speed = SPEED_10000;
|
|
|
|
break;
|
|
|
|
case MLX4_EN_20G_SPEED:
|
|
|
|
state->link_speed = SPEED_20000;
|
2011-10-09 13:29:42 +08:00
|
|
|
break;
|
|
|
|
case MLX4_EN_40G_SPEED:
|
2014-10-27 17:37:39 +08:00
|
|
|
state->link_speed = SPEED_40000;
|
|
|
|
break;
|
|
|
|
case MLX4_EN_56G_SPEED:
|
|
|
|
state->link_speed = SPEED_56000;
|
2011-10-09 13:29:42 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
state->link_speed = -1;
|
|
|
|
break;
|
|
|
|
}
|
2014-10-27 17:37:40 +08:00
|
|
|
|
|
|
|
state->transceiver = qport_context->transceiver;
|
|
|
|
|
|
|
|
state->flags = 0; /* Reset and recalculate the port flags */
|
|
|
|
state->flags |= (qport_context->link_up & MLX4_EN_ANC_MASK) ?
|
|
|
|
MLX4_EN_PORT_ANC : 0;
|
|
|
|
state->flags |= (qport_context->autoneg & MLX4_EN_AUTONEG_MASK) ?
|
|
|
|
MLX4_EN_PORT_ANE : 0;
|
2010-08-24 11:46:18 +08:00
|
|
|
|
|
|
|
out:
|
|
|
|
mlx4_free_cmd_mailbox(mdev->dev, mailbox);
|
|
|
|
return err;
|
|
|
|
}
|
2008-10-23 06:47:49 +08:00
|
|
|
|
2015-03-30 22:45:26 +08:00
|
|
|
/* Each counter set is located in struct mlx4_en_stat_out_mbox
|
|
|
|
* with a const offset between its prio components.
|
|
|
|
* This function runs over a counter set and sum all of it's prio components.
|
|
|
|
*/
|
|
|
|
static unsigned long en_stats_adder(__be64 *start, __be64 *next, int num)
|
|
|
|
{
|
|
|
|
__be64 *curr = start;
|
|
|
|
unsigned long ret = 0;
|
|
|
|
int i;
|
|
|
|
int offset = next - start;
|
|
|
|
|
2015-05-05 22:07:11 +08:00
|
|
|
for (i = 0; i < num; i++) {
|
2015-03-30 22:45:26 +08:00
|
|
|
ret += be64_to_cpu(*curr);
|
|
|
|
curr += offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-11-25 23:46:20 +08:00
|
|
|
void mlx4_en_fold_software_stats(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct mlx4_en_priv *priv = netdev_priv(dev);
|
|
|
|
struct mlx4_en_dev *mdev = priv->mdev;
|
|
|
|
unsigned long packets, bytes;
|
|
|
|
int i;
|
|
|
|
|
2016-12-01 21:02:06 +08:00
|
|
|
if (!priv->port_up || mlx4_is_master(mdev->dev))
|
2016-11-25 23:46:20 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
packets = 0;
|
|
|
|
bytes = 0;
|
|
|
|
for (i = 0; i < priv->rx_ring_num; i++) {
|
|
|
|
const struct mlx4_en_rx_ring *ring = priv->rx_ring[i];
|
|
|
|
|
|
|
|
packets += READ_ONCE(ring->packets);
|
|
|
|
bytes += READ_ONCE(ring->bytes);
|
|
|
|
}
|
|
|
|
dev->stats.rx_packets = packets;
|
|
|
|
dev->stats.rx_bytes = bytes;
|
|
|
|
|
|
|
|
packets = 0;
|
|
|
|
bytes = 0;
|
|
|
|
for (i = 0; i < priv->tx_ring_num[TX]; i++) {
|
|
|
|
const struct mlx4_en_tx_ring *ring = priv->tx_ring[TX][i];
|
|
|
|
|
|
|
|
packets += READ_ONCE(ring->packets);
|
|
|
|
bytes += READ_ONCE(ring->bytes);
|
|
|
|
}
|
|
|
|
dev->stats.tx_packets = packets;
|
|
|
|
dev->stats.tx_bytes = bytes;
|
|
|
|
}
|
|
|
|
|
2008-10-23 06:47:49 +08:00
|
|
|
int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
|
|
|
|
{
|
2015-06-15 22:59:06 +08:00
|
|
|
struct mlx4_counter tmp_counter_stats;
|
2008-10-23 06:47:49 +08:00
|
|
|
struct mlx4_en_stat_out_mbox *mlx4_en_stats;
|
2015-03-30 22:45:25 +08:00
|
|
|
struct mlx4_en_stat_out_flow_control_mbox *flowstats;
|
2016-05-26 00:50:39 +08:00
|
|
|
struct net_device *dev = mdev->pndev[port];
|
|
|
|
struct mlx4_en_priv *priv = netdev_priv(dev);
|
|
|
|
struct net_device_stats *stats = &dev->stats;
|
2008-10-23 06:47:49 +08:00
|
|
|
struct mlx4_cmd_mailbox *mailbox;
|
|
|
|
u64 in_mod = reset << 8 | port;
|
|
|
|
int err;
|
2015-06-15 22:59:06 +08:00
|
|
|
int i, counter_index;
|
2016-11-25 23:46:20 +08:00
|
|
|
unsigned long sw_tx_dropped = 0;
|
2016-04-20 21:01:18 +08:00
|
|
|
unsigned long sw_rx_dropped = 0;
|
2008-10-23 06:47:49 +08:00
|
|
|
|
|
|
|
mailbox = mlx4_alloc_cmd_mailbox(mdev->dev);
|
|
|
|
if (IS_ERR(mailbox))
|
|
|
|
return PTR_ERR(mailbox);
|
|
|
|
err = mlx4_cmd_box(mdev->dev, 0, mailbox->dma, in_mod, 0,
|
2011-12-13 12:10:51 +08:00
|
|
|
MLX4_CMD_DUMP_ETH_STATS, MLX4_CMD_TIME_CLASS_B,
|
net/mlx4_en: Fix potential deadlock in port statistics flow
mlx4_en_DUMP_ETH_STATS took the *counter mutex* and then
called the FW command, with WRAPPED attribute. As a result, the fw command
is wrapped on the Hypervisor when it calls mlx4_en_DUMP_ETH_STATS.
The FW command wrapper flow on the hypervisor takes the *slave_cmd_mutex*
during processing.
At the same time, a VF could be in the process of coming up, and could
call mlx4_QUERY_FUNC_CAP. On the hypervisor, the command flow takes the
*slave_cmd_mutex*, then executes mlx4_QUERY_FUNC_CAP_wrapper.
mlx4_QUERY_FUNC_CAP wrapper calls mlx4_get_default_counter_index(),
which takes the *counter mutex*. DEADLOCK.
The fix is that the DUMP_ETH_STATS fw command should be called with
the NATIVE attribute, so that on the hypervisor, this command does not
enter the wrapper flow.
Since the Hypervisor no longer goes through the wrapper code, we also
simply return 0 in mlx4_DUMP_ETH_STATS_wrapper (i.e.the function succeeds,
but the returned data will be all zeroes).
No need to test if it is the Hypervisor going through the wrapper.
Fixes: f9baff509f8a ("mlx4_core: Add "native" argument to mlx4_cmd ...")
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-27 21:27:21 +08:00
|
|
|
MLX4_CMD_NATIVE);
|
2008-10-23 06:47:49 +08:00
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mlx4_en_stats = mailbox->buf;
|
|
|
|
|
|
|
|
spin_lock_bh(&priv->stats_lock);
|
|
|
|
|
2016-11-25 23:46:20 +08:00
|
|
|
mlx4_en_fold_software_stats(dev);
|
|
|
|
|
2011-10-18 09:50:56 +08:00
|
|
|
priv->port_stats.rx_chksum_good = 0;
|
|
|
|
priv->port_stats.rx_chksum_none = 0;
|
2014-11-09 19:51:53 +08:00
|
|
|
priv->port_stats.rx_chksum_complete = 0;
|
2017-03-09 00:17:14 +08:00
|
|
|
priv->port_stats.rx_alloc_pages = 0;
|
2016-11-02 23:12:25 +08:00
|
|
|
priv->xdp_stats.rx_xdp_drop = 0;
|
|
|
|
priv->xdp_stats.rx_xdp_tx = 0;
|
|
|
|
priv->xdp_stats.rx_xdp_tx_full = 0;
|
2009-04-20 12:34:38 +08:00
|
|
|
for (i = 0; i < priv->rx_ring_num; i++) {
|
2016-11-25 23:46:20 +08:00
|
|
|
const struct mlx4_en_rx_ring *ring = priv->rx_ring[i];
|
|
|
|
|
|
|
|
sw_rx_dropped += READ_ONCE(ring->dropped);
|
|
|
|
priv->port_stats.rx_chksum_good += READ_ONCE(ring->csum_ok);
|
|
|
|
priv->port_stats.rx_chksum_none += READ_ONCE(ring->csum_none);
|
|
|
|
priv->port_stats.rx_chksum_complete += READ_ONCE(ring->csum_complete);
|
2017-03-09 00:17:14 +08:00
|
|
|
priv->port_stats.rx_alloc_pages += READ_ONCE(ring->rx_alloc_pages);
|
2016-11-25 23:46:20 +08:00
|
|
|
priv->xdp_stats.rx_xdp_drop += READ_ONCE(ring->xdp_drop);
|
|
|
|
priv->xdp_stats.rx_xdp_tx += READ_ONCE(ring->xdp_tx);
|
|
|
|
priv->xdp_stats.rx_xdp_tx_full += READ_ONCE(ring->xdp_tx_full);
|
2009-04-20 12:34:38 +08:00
|
|
|
}
|
2011-10-18 09:50:56 +08:00
|
|
|
priv->port_stats.tx_chksum_offload = 0;
|
2014-03-02 16:25:00 +08:00
|
|
|
priv->port_stats.queue_stopped = 0;
|
|
|
|
priv->port_stats.wake_queue = 0;
|
2014-10-02 23:24:21 +08:00
|
|
|
priv->port_stats.tso_packets = 0;
|
|
|
|
priv->port_stats.xmit_more = 0;
|
2014-03-02 16:25:00 +08:00
|
|
|
|
2016-11-02 23:12:24 +08:00
|
|
|
for (i = 0; i < priv->tx_ring_num[TX]; i++) {
|
|
|
|
const struct mlx4_en_tx_ring *ring = priv->tx_ring[TX][i];
|
2014-10-02 23:24:21 +08:00
|
|
|
|
2016-11-25 23:46:20 +08:00
|
|
|
sw_tx_dropped += READ_ONCE(ring->tx_dropped);
|
|
|
|
priv->port_stats.tx_chksum_offload += READ_ONCE(ring->tx_csum);
|
|
|
|
priv->port_stats.queue_stopped += READ_ONCE(ring->queue_stopped);
|
|
|
|
priv->port_stats.wake_queue += READ_ONCE(ring->wake_queue);
|
|
|
|
priv->port_stats.tso_packets += READ_ONCE(ring->tso_packets);
|
|
|
|
priv->port_stats.xmit_more += READ_ONCE(ring->xmit_more);
|
2009-04-20 12:34:38 +08:00
|
|
|
}
|
2016-11-25 23:46:20 +08:00
|
|
|
|
2015-06-23 22:14:13 +08:00
|
|
|
if (mlx4_is_master(mdev->dev)) {
|
|
|
|
stats->rx_packets = en_stats_adder(&mlx4_en_stats->RTOT_prio_0,
|
|
|
|
&mlx4_en_stats->RTOT_prio_1,
|
|
|
|
NUM_PRIORITIES);
|
|
|
|
stats->tx_packets = en_stats_adder(&mlx4_en_stats->TTOT_prio_0,
|
|
|
|
&mlx4_en_stats->TTOT_prio_1,
|
|
|
|
NUM_PRIORITIES);
|
|
|
|
stats->rx_bytes = en_stats_adder(&mlx4_en_stats->ROCT_prio_0,
|
|
|
|
&mlx4_en_stats->ROCT_prio_1,
|
|
|
|
NUM_PRIORITIES);
|
|
|
|
stats->tx_bytes = en_stats_adder(&mlx4_en_stats->TOCT_prio_0,
|
|
|
|
&mlx4_en_stats->TOCT_prio_1,
|
|
|
|
NUM_PRIORITIES);
|
|
|
|
}
|
2008-10-23 06:47:49 +08:00
|
|
|
|
2015-03-30 22:45:26 +08:00
|
|
|
/* net device stats */
|
2008-10-23 06:47:49 +08:00
|
|
|
stats->rx_errors = be64_to_cpu(mlx4_en_stats->PCS) +
|
|
|
|
be32_to_cpu(mlx4_en_stats->RJBBR) +
|
|
|
|
be32_to_cpu(mlx4_en_stats->RCRC) +
|
2015-03-30 22:45:26 +08:00
|
|
|
be32_to_cpu(mlx4_en_stats->RRUNT) +
|
|
|
|
be64_to_cpu(mlx4_en_stats->RInRangeLengthErr) +
|
|
|
|
be64_to_cpu(mlx4_en_stats->ROutRangeLengthErr) +
|
|
|
|
be32_to_cpu(mlx4_en_stats->RSHORT) +
|
|
|
|
en_stats_adder(&mlx4_en_stats->RGIANT_prio_0,
|
|
|
|
&mlx4_en_stats->RGIANT_prio_1,
|
|
|
|
NUM_PRIORITIES);
|
|
|
|
stats->tx_errors = en_stats_adder(&mlx4_en_stats->TGIANT_prio_0,
|
|
|
|
&mlx4_en_stats->TGIANT_prio_1,
|
|
|
|
NUM_PRIORITIES);
|
|
|
|
stats->multicast = en_stats_adder(&mlx4_en_stats->MCAST_prio_0,
|
|
|
|
&mlx4_en_stats->MCAST_prio_1,
|
|
|
|
NUM_PRIORITIES);
|
2016-04-20 21:01:18 +08:00
|
|
|
stats->rx_dropped = be32_to_cpu(mlx4_en_stats->RDROP) +
|
|
|
|
sw_rx_dropped;
|
2008-10-23 06:47:49 +08:00
|
|
|
stats->rx_length_errors = be32_to_cpu(mlx4_en_stats->RdropLength);
|
|
|
|
stats->rx_crc_errors = be32_to_cpu(mlx4_en_stats->RCRC);
|
|
|
|
stats->rx_fifo_errors = be32_to_cpu(mlx4_en_stats->RdropOvflw);
|
2016-11-25 23:46:20 +08:00
|
|
|
stats->tx_dropped = be32_to_cpu(mlx4_en_stats->TDROP) +
|
|
|
|
sw_tx_dropped;
|
2015-03-30 22:45:26 +08:00
|
|
|
|
|
|
|
/* RX stats */
|
|
|
|
priv->pkstats.rx_multicast_packets = stats->multicast;
|
|
|
|
priv->pkstats.rx_broadcast_packets =
|
|
|
|
en_stats_adder(&mlx4_en_stats->RBCAST_prio_0,
|
|
|
|
&mlx4_en_stats->RBCAST_prio_1,
|
|
|
|
NUM_PRIORITIES);
|
|
|
|
priv->pkstats.rx_jabbers = be32_to_cpu(mlx4_en_stats->RJBBR);
|
|
|
|
priv->pkstats.rx_in_range_length_error =
|
|
|
|
be64_to_cpu(mlx4_en_stats->RInRangeLengthErr);
|
|
|
|
priv->pkstats.rx_out_range_length_error =
|
|
|
|
be64_to_cpu(mlx4_en_stats->ROutRangeLengthErr);
|
|
|
|
|
|
|
|
/* Tx stats */
|
|
|
|
priv->pkstats.tx_multicast_packets =
|
|
|
|
en_stats_adder(&mlx4_en_stats->TMCAST_prio_0,
|
|
|
|
&mlx4_en_stats->TMCAST_prio_1,
|
|
|
|
NUM_PRIORITIES);
|
|
|
|
priv->pkstats.tx_broadcast_packets =
|
|
|
|
en_stats_adder(&mlx4_en_stats->TBCAST_prio_0,
|
|
|
|
&mlx4_en_stats->TBCAST_prio_1,
|
|
|
|
NUM_PRIORITIES);
|
|
|
|
|
|
|
|
priv->pkstats.rx_prio[0][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_0);
|
|
|
|
priv->pkstats.rx_prio[0][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_0);
|
|
|
|
priv->pkstats.rx_prio[1][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_1);
|
|
|
|
priv->pkstats.rx_prio[1][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_1);
|
|
|
|
priv->pkstats.rx_prio[2][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_2);
|
|
|
|
priv->pkstats.rx_prio[2][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_2);
|
|
|
|
priv->pkstats.rx_prio[3][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_3);
|
|
|
|
priv->pkstats.rx_prio[3][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_3);
|
|
|
|
priv->pkstats.rx_prio[4][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_4);
|
|
|
|
priv->pkstats.rx_prio[4][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_4);
|
|
|
|
priv->pkstats.rx_prio[5][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_5);
|
|
|
|
priv->pkstats.rx_prio[5][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_5);
|
|
|
|
priv->pkstats.rx_prio[6][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_6);
|
|
|
|
priv->pkstats.rx_prio[6][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_6);
|
|
|
|
priv->pkstats.rx_prio[7][0] = be64_to_cpu(mlx4_en_stats->RTOT_prio_7);
|
|
|
|
priv->pkstats.rx_prio[7][1] = be64_to_cpu(mlx4_en_stats->ROCT_prio_7);
|
|
|
|
priv->pkstats.rx_prio[8][0] = be64_to_cpu(mlx4_en_stats->RTOT_novlan);
|
|
|
|
priv->pkstats.rx_prio[8][1] = be64_to_cpu(mlx4_en_stats->ROCT_novlan);
|
|
|
|
priv->pkstats.tx_prio[0][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_0);
|
|
|
|
priv->pkstats.tx_prio[0][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_0);
|
|
|
|
priv->pkstats.tx_prio[1][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_1);
|
|
|
|
priv->pkstats.tx_prio[1][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_1);
|
|
|
|
priv->pkstats.tx_prio[2][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_2);
|
|
|
|
priv->pkstats.tx_prio[2][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_2);
|
|
|
|
priv->pkstats.tx_prio[3][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_3);
|
|
|
|
priv->pkstats.tx_prio[3][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_3);
|
|
|
|
priv->pkstats.tx_prio[4][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_4);
|
|
|
|
priv->pkstats.tx_prio[4][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_4);
|
|
|
|
priv->pkstats.tx_prio[5][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_5);
|
|
|
|
priv->pkstats.tx_prio[5][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_5);
|
|
|
|
priv->pkstats.tx_prio[6][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_6);
|
|
|
|
priv->pkstats.tx_prio[6][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_6);
|
|
|
|
priv->pkstats.tx_prio[7][0] = be64_to_cpu(mlx4_en_stats->TTOT_prio_7);
|
|
|
|
priv->pkstats.tx_prio[7][1] = be64_to_cpu(mlx4_en_stats->TOCT_prio_7);
|
|
|
|
priv->pkstats.tx_prio[8][0] = be64_to_cpu(mlx4_en_stats->TTOT_novlan);
|
|
|
|
priv->pkstats.tx_prio[8][1] = be64_to_cpu(mlx4_en_stats->TOCT_novlan);
|
2008-10-23 06:47:49 +08:00
|
|
|
|
|
|
|
spin_unlock_bh(&priv->stats_lock);
|
|
|
|
|
2015-06-15 22:59:06 +08:00
|
|
|
memset(&tmp_counter_stats, 0, sizeof(tmp_counter_stats));
|
|
|
|
counter_index = mlx4_get_default_counter_index(mdev->dev, port);
|
|
|
|
err = mlx4_get_counter_stats(mdev->dev, counter_index,
|
|
|
|
&tmp_counter_stats, reset);
|
|
|
|
|
2015-03-30 22:45:25 +08:00
|
|
|
/* 0xffs indicates invalid value */
|
|
|
|
memset(mailbox->buf, 0xff, sizeof(*flowstats) * MLX4_NUM_PRIORITIES);
|
|
|
|
|
|
|
|
if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN) {
|
|
|
|
memset(mailbox->buf, 0,
|
|
|
|
sizeof(*flowstats) * MLX4_NUM_PRIORITIES);
|
|
|
|
err = mlx4_cmd_box(mdev->dev, 0, mailbox->dma,
|
|
|
|
in_mod | MLX4_DUMP_ETH_STATS_FLOW_CONTROL,
|
|
|
|
0, MLX4_CMD_DUMP_ETH_STATS,
|
net/mlx4_en: Fix potential deadlock in port statistics flow
mlx4_en_DUMP_ETH_STATS took the *counter mutex* and then
called the FW command, with WRAPPED attribute. As a result, the fw command
is wrapped on the Hypervisor when it calls mlx4_en_DUMP_ETH_STATS.
The FW command wrapper flow on the hypervisor takes the *slave_cmd_mutex*
during processing.
At the same time, a VF could be in the process of coming up, and could
call mlx4_QUERY_FUNC_CAP. On the hypervisor, the command flow takes the
*slave_cmd_mutex*, then executes mlx4_QUERY_FUNC_CAP_wrapper.
mlx4_QUERY_FUNC_CAP wrapper calls mlx4_get_default_counter_index(),
which takes the *counter mutex*. DEADLOCK.
The fix is that the DUMP_ETH_STATS fw command should be called with
the NATIVE attribute, so that on the hypervisor, this command does not
enter the wrapper flow.
Since the Hypervisor no longer goes through the wrapper code, we also
simply return 0 in mlx4_DUMP_ETH_STATS_wrapper (i.e.the function succeeds,
but the returned data will be all zeroes).
No need to test if it is the Hypervisor going through the wrapper.
Fixes: f9baff509f8a ("mlx4_core: Add "native" argument to mlx4_cmd ...")
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-27 21:27:21 +08:00
|
|
|
MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
|
2015-03-30 22:45:25 +08:00
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
flowstats = mailbox->buf;
|
|
|
|
|
|
|
|
spin_lock_bh(&priv->stats_lock);
|
|
|
|
|
2015-06-15 22:59:06 +08:00
|
|
|
if (tmp_counter_stats.counter_mode == 0) {
|
|
|
|
priv->pf_stats.rx_bytes = be64_to_cpu(tmp_counter_stats.rx_bytes);
|
|
|
|
priv->pf_stats.tx_bytes = be64_to_cpu(tmp_counter_stats.tx_bytes);
|
|
|
|
priv->pf_stats.rx_packets = be64_to_cpu(tmp_counter_stats.rx_frames);
|
|
|
|
priv->pf_stats.tx_packets = be64_to_cpu(tmp_counter_stats.tx_frames);
|
|
|
|
}
|
|
|
|
|
2015-03-30 22:45:25 +08:00
|
|
|
for (i = 0; i < MLX4_NUM_PRIORITIES; i++) {
|
|
|
|
priv->rx_priority_flowstats[i].rx_pause =
|
|
|
|
be64_to_cpu(flowstats[i].rx_pause);
|
|
|
|
priv->rx_priority_flowstats[i].rx_pause_duration =
|
|
|
|
be64_to_cpu(flowstats[i].rx_pause_duration);
|
|
|
|
priv->rx_priority_flowstats[i].rx_pause_transition =
|
|
|
|
be64_to_cpu(flowstats[i].rx_pause_transition);
|
|
|
|
priv->tx_priority_flowstats[i].tx_pause =
|
|
|
|
be64_to_cpu(flowstats[i].tx_pause);
|
|
|
|
priv->tx_priority_flowstats[i].tx_pause_duration =
|
|
|
|
be64_to_cpu(flowstats[i].tx_pause_duration);
|
|
|
|
priv->tx_priority_flowstats[i].tx_pause_transition =
|
|
|
|
be64_to_cpu(flowstats[i].tx_pause_transition);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if pfc is not in use, all priorities counters have the same value */
|
|
|
|
priv->rx_flowstats.rx_pause =
|
|
|
|
be64_to_cpu(flowstats[0].rx_pause);
|
|
|
|
priv->rx_flowstats.rx_pause_duration =
|
|
|
|
be64_to_cpu(flowstats[0].rx_pause_duration);
|
|
|
|
priv->rx_flowstats.rx_pause_transition =
|
|
|
|
be64_to_cpu(flowstats[0].rx_pause_transition);
|
|
|
|
priv->tx_flowstats.tx_pause =
|
|
|
|
be64_to_cpu(flowstats[0].tx_pause);
|
|
|
|
priv->tx_flowstats.tx_pause_duration =
|
|
|
|
be64_to_cpu(flowstats[0].tx_pause_duration);
|
|
|
|
priv->tx_flowstats.tx_pause_transition =
|
|
|
|
be64_to_cpu(flowstats[0].tx_pause_transition);
|
|
|
|
|
|
|
|
spin_unlock_bh(&priv->stats_lock);
|
|
|
|
|
2008-10-23 06:47:49 +08:00
|
|
|
out:
|
|
|
|
mlx4_free_cmd_mailbox(mdev->dev, mailbox);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|