* [pull request][net 0/6] Mellanox, mlx5 fixes 2017-05-12
@ 2017-05-12 11:56 Saeed Mahameed
2017-05-12 11:56 ` [net 1/6] net/mlx5e: Use a spinlock to synchronize statistics Saeed Mahameed
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: Saeed Mahameed @ 2017-05-12 11:56 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Saeed Mahameed
Hi Dave,
This series contains some mlx5 fixes for net.
Please pull and let me know if there's any problem.
For -stable:
("net/mlx5e: Fix ethtool pause support and advertise reporting") kernels >= 4.8
("net/mlx5e: Use the correct pause values for ethtool advertising") kernels >= 4.8
Thanks,
Saeed.
---
The following changes since commit df0c8d911abf6ba97b2c2fc3c5a12769e0b081a3:
net: phy: Call bus->reset() after releasing PHYs from reset (2017-05-11 23:06:18 -0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2017-05-12
for you to fetch changes up to 5405a3d4687a3e2fad41a59c3cecbd33b7200fa1:
net/mlx5: Use underlay QPN from the root name space (2017-05-12 14:18:41 +0300)
----------------------------------------------------------------
mlx5-fixes-2017-05-12
Misc mlx5 fixes
----------------------------------------------------------------
Gal Pressman (3):
net/mlx5e: Use a spinlock to synchronize statistics
net/mlx5e: Use the correct pause values for ethtool advertising
net/mlx5e: Fix ethtool pause support and advertise reporting
Saeed Mahameed (2):
net/mlx5e: Fix setup TC ndo
net/mlx5e: IPoIB, Only support regular RQ for now
Yishai Hadas (1):
net/mlx5: Use underlay QPN from the root name space
drivers/net/ethernet/mellanox/mlx5/core/en.h | 3 +-
.../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 21 +++++++---
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 5 +--
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 47 ++++++++++++++++------
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 9 ++---
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h | 3 +-
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 25 ++++++++++--
drivers/net/ethernet/mellanox/mlx5/core/fs_core.h | 2 +-
drivers/net/ethernet/mellanox/mlx5/core/ipoib.c | 11 ++++-
include/linux/mlx5/fs.h | 4 +-
10 files changed, 93 insertions(+), 37 deletions(-)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [net 1/6] net/mlx5e: Use a spinlock to synchronize statistics
2017-05-12 11:56 [pull request][net 0/6] Mellanox, mlx5 fixes 2017-05-12 Saeed Mahameed
@ 2017-05-12 11:56 ` Saeed Mahameed
2017-05-12 16:13 ` David Miller
2017-05-15 22:51 ` Stephen Hemminger
2017-05-12 11:56 ` [net 2/6] net/mlx5e: Use the correct pause values for ethtool advertising Saeed Mahameed
` (4 subsequent siblings)
5 siblings, 2 replies; 11+ messages in thread
From: Saeed Mahameed @ 2017-05-12 11:56 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Gal Pressman, kernel-team, Saeed Mahameed
From: Gal Pressman <galp@mellanox.com>
Add a spinlock to prevent races when querying statistics, for example
querying counters in the middle of a non atomic memcpy() operation in
mlx5e_update_stats().
This RW lock should be held when accessing priv->stats, to prevent other
reads/writes.
Fixes: 9218b44dcc05 ("net/mlx5e: Statistics handling refactoring")
Signed-off-by: Gal Pressman <galp@mellanox.com>
Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: kernel-team@fb.com
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 +
.../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 12 ++++--
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 45 ++++++++++++++++------
3 files changed, 44 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 0099a3e397bc..c41cf7e82795 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -756,6 +756,7 @@ struct mlx5e_priv {
struct mlx5_core_dev *mdev;
struct net_device *netdev;
struct mlx5e_stats stats;
+ rwlock_t stats_lock;
struct mlx5e_tstamp tstamp;
u16 q_counter;
#ifdef CONFIG_MLX5_CORE_EN_DCB
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index ce7b09d72ff6..0a7734761ece 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -305,6 +305,7 @@ static void mlx5e_get_ethtool_stats(struct net_device *dev,
struct mlx5_priv *mlx5_priv;
int i, j, tc, prio, idx = 0;
unsigned long pfc_combined;
+ bool global_pause;
if (!data)
return;
@@ -313,8 +314,11 @@ static void mlx5e_get_ethtool_stats(struct net_device *dev,
if (test_bit(MLX5E_STATE_OPENED, &priv->state))
mlx5e_update_stats(priv);
channels = &priv->channels;
+ pfc_combined = mlx5e_query_pfc_combined(priv);
+ global_pause = mlx5e_query_global_pause_combined(priv);
mutex_unlock(&priv->state_lock);
+ read_lock(&priv->stats_lock);
for (i = 0; i < NUM_SW_COUNTERS; i++)
data[idx++] = MLX5E_READ_CTR64_CPU(&priv->stats.sw,
sw_stats_desc, i);
@@ -353,7 +357,6 @@ static void mlx5e_get_ethtool_stats(struct net_device *dev,
pport_per_prio_traffic_stats_desc, i);
}
- pfc_combined = mlx5e_query_pfc_combined(priv);
for_each_set_bit(prio, &pfc_combined, NUM_PPORT_PRIO) {
for (i = 0; i < NUM_PPORT_PER_PRIO_PFC_COUNTERS; i++) {
data[idx++] = MLX5E_READ_CTR64_BE(&priv->stats.pport.per_prio_counters[prio],
@@ -361,7 +364,7 @@ static void mlx5e_get_ethtool_stats(struct net_device *dev,
}
}
- if (mlx5e_query_global_pause_combined(priv)) {
+ if (global_pause) {
for (i = 0; i < NUM_PPORT_PER_PRIO_PFC_COUNTERS; i++) {
data[idx++] = MLX5E_READ_CTR64_BE(&priv->stats.pport.per_prio_counters[0],
pport_per_prio_pfc_stats_desc, i);
@@ -379,7 +382,7 @@ static void mlx5e_get_ethtool_stats(struct net_device *dev,
mlx5e_pme_error_desc, i);
if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
- return;
+ goto out;
/* per channel counters */
for (i = 0; i < channels->num; i++)
@@ -393,6 +396,9 @@ static void mlx5e_get_ethtool_stats(struct net_device *dev,
for (j = 0; j < NUM_SQ_STATS; j++)
data[idx++] = MLX5E_READ_CTR64_CPU(&channels->c[i]->sq[tc].stats,
sq_stats_desc, j);
+
+out:
+ read_unlock(&priv->stats_lock);
}
static u32 mlx5e_rx_wqes_to_packets(struct mlx5e_priv *priv, int rq_wq_type,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index a61b71b6fff3..7ac6bcc0e227 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -166,6 +166,13 @@ static void mlx5e_tx_timeout_work(struct work_struct *work)
rtnl_unlock();
}
+#define MLX5E_STATS_WRITE(priv, name, s) \
+ do { \
+ write_lock(&(priv)->stats_lock); \
+ memcpy(&(priv)->stats.name, (s), sizeof(*(s))); \
+ write_unlock(&(priv)->stats_lock); \
+ } while (0)
+
static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
{
struct mlx5e_sw_stats temp, *s = &temp;
@@ -222,17 +229,21 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
s->tx_csum_partial = s->tx_packets - tx_offload_none - s->tx_csum_partial_inner;
s->rx_csum_unnecessary = s->rx_packets - s->rx_csum_none - s->rx_csum_complete;
+ read_lock(&priv->stats_lock);
s->link_down_events_phy = MLX5_GET(ppcnt_reg,
priv->stats.pport.phy_counters,
counter_set.phys_layer_cntrs.link_down_events);
- memcpy(&priv->stats.sw, s, sizeof(*s));
+ read_unlock(&priv->stats_lock);
+
+ MLX5E_STATS_WRITE(priv, sw, s);
}
static void mlx5e_update_vport_counters(struct mlx5e_priv *priv)
{
int outlen = MLX5_ST_SZ_BYTES(query_vport_counter_out);
- u32 *out = (u32 *)priv->stats.vport.query_vport_out;
u32 in[MLX5_ST_SZ_DW(query_vport_counter_in)] = {0};
+ struct mlx5e_vport_stats vstats;
+ u32 *out = (u32 *)vstats.query_vport_out;
struct mlx5_core_dev *mdev = priv->mdev;
MLX5_SET(query_vport_counter_in, in, opcode,
@@ -241,19 +252,22 @@ static void mlx5e_update_vport_counters(struct mlx5e_priv *priv)
MLX5_SET(query_vport_counter_in, in, other_vport, 0);
mlx5_cmd_exec(mdev, in, sizeof(in), out, outlen);
+
+ MLX5E_STATS_WRITE(priv, vport, &vstats);
}
static void mlx5e_update_pport_counters(struct mlx5e_priv *priv)
{
- struct mlx5e_pport_stats *pstats = &priv->stats.pport;
struct mlx5_core_dev *mdev = priv->mdev;
int sz = MLX5_ST_SZ_BYTES(ppcnt_reg);
- int prio;
+ struct mlx5e_pport_stats *pstats;
void *out;
+ int prio;
u32 *in;
- in = mlx5_vzalloc(sz);
- if (!in)
+ in = mlx5_vzalloc(sz);
+ pstats = mlx5_vzalloc(sizeof(*pstats));
+ if (!in || !pstats)
goto free_out;
MLX5_SET(ppcnt_reg, in, local_port, 1);
@@ -288,26 +302,31 @@ static void mlx5e_update_pport_counters(struct mlx5e_priv *priv)
MLX5_REG_PPCNT, 0, 0);
}
+ MLX5E_STATS_WRITE(priv, pport, pstats);
+
free_out:
kvfree(in);
+ kvfree(pstats);
}
static void mlx5e_update_q_counter(struct mlx5e_priv *priv)
{
- struct mlx5e_qcounter_stats *qcnt = &priv->stats.qcnt;
+ struct mlx5e_qcounter_stats qcnt;
if (!priv->q_counter)
return;
mlx5_core_query_out_of_buffer(priv->mdev, priv->q_counter,
- &qcnt->rx_out_of_buffer);
+ &qcnt.rx_out_of_buffer);
+
+ MLX5E_STATS_WRITE(priv, qcnt, &qcnt);
}
static void mlx5e_update_pcie_counters(struct mlx5e_priv *priv)
{
- struct mlx5e_pcie_stats *pcie_stats = &priv->stats.pcie;
struct mlx5_core_dev *mdev = priv->mdev;
int sz = MLX5_ST_SZ_BYTES(mpcnt_reg);
+ struct mlx5e_pcie_stats pcie_stats;
void *out;
u32 *in;
@@ -318,10 +337,12 @@ static void mlx5e_update_pcie_counters(struct mlx5e_priv *priv)
if (!in)
return;
- out = pcie_stats->pcie_perf_counters;
+ out = pcie_stats.pcie_perf_counters;
MLX5_SET(mpcnt_reg, in, grp, MLX5_PCIE_PERFORMANCE_COUNTERS_GROUP);
mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_MPCNT, 0, 0);
+ MLX5E_STATS_WRITE(priv, pcie, &pcie_stats);
+
kvfree(in);
}
@@ -3030,6 +3051,7 @@ mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
struct mlx5e_vport_stats *vstats = &priv->stats.vport;
struct mlx5e_pport_stats *pstats = &priv->stats.pport;
+ read_lock(&priv->stats_lock);
if (mlx5e_is_uplink_rep(priv)) {
stats->rx_packets = PPORT_802_3_GET(pstats, a_frames_received_ok);
stats->rx_bytes = PPORT_802_3_GET(pstats, a_octets_received_ok);
@@ -3064,7 +3086,7 @@ mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
*/
stats->multicast =
VPORT_COUNTER_GET(vstats, received_eth_multicast.packets);
-
+ read_unlock(&priv->stats_lock);
}
static void mlx5e_set_rx_mode(struct net_device *dev)
@@ -3901,6 +3923,7 @@ static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev,
mlx5e_build_nic_params(mdev, &priv->channels.params, profile->max_nch(mdev));
mutex_init(&priv->state_lock);
+ rwlock_init(&priv->stats_lock);
INIT_WORK(&priv->update_carrier_work, mlx5e_update_carrier_work);
INIT_WORK(&priv->set_rx_mode_work, mlx5e_set_rx_mode_work);
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [net 2/6] net/mlx5e: Use the correct pause values for ethtool advertising
2017-05-12 11:56 [pull request][net 0/6] Mellanox, mlx5 fixes 2017-05-12 Saeed Mahameed
2017-05-12 11:56 ` [net 1/6] net/mlx5e: Use a spinlock to synchronize statistics Saeed Mahameed
@ 2017-05-12 11:56 ` Saeed Mahameed
2017-05-12 11:56 ` [net 3/6] net/mlx5e: Fix ethtool pause support and advertise reporting Saeed Mahameed
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Saeed Mahameed @ 2017-05-12 11:56 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Gal Pressman, kernel-team, Saeed Mahameed
From: Gal Pressman <galp@mellanox.com>
Query the operational pause from firmware (PFCC register) instead of
always passing zeros.
Fixes: 665bc53969d7 ("net/mlx5e: Use new ethtool get/set link ksettings API")
Signed-off-by: Gal Pressman <galp@mellanox.com>
Cc: kernel-team@fb.com
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 0a7734761ece..87a7a66363de 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -855,6 +855,8 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev,
struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5_core_dev *mdev = priv->mdev;
u32 out[MLX5_ST_SZ_DW(ptys_reg)] = {0};
+ u32 rx_pause = 0;
+ u32 tx_pause = 0;
u32 eth_proto_cap;
u32 eth_proto_admin;
u32 eth_proto_lp;
@@ -877,11 +879,13 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev,
an_disable_admin = MLX5_GET(ptys_reg, out, an_disable_admin);
an_status = MLX5_GET(ptys_reg, out, an_status);
+ mlx5_query_port_pause(mdev, &rx_pause, &tx_pause);
+
ethtool_link_ksettings_zero_link_mode(link_ksettings, supported);
ethtool_link_ksettings_zero_link_mode(link_ksettings, advertising);
get_supported(eth_proto_cap, link_ksettings);
- get_advertising(eth_proto_admin, 0, 0, link_ksettings);
+ get_advertising(eth_proto_admin, tx_pause, rx_pause, link_ksettings);
get_speed_duplex(netdev, eth_proto_oper, link_ksettings);
eth_proto_oper = eth_proto_oper ? eth_proto_oper : eth_proto_cap;
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [net 3/6] net/mlx5e: Fix ethtool pause support and advertise reporting
2017-05-12 11:56 [pull request][net 0/6] Mellanox, mlx5 fixes 2017-05-12 Saeed Mahameed
2017-05-12 11:56 ` [net 1/6] net/mlx5e: Use a spinlock to synchronize statistics Saeed Mahameed
2017-05-12 11:56 ` [net 2/6] net/mlx5e: Use the correct pause values for ethtool advertising Saeed Mahameed
@ 2017-05-12 11:56 ` Saeed Mahameed
2017-05-12 11:56 ` [net 4/6] net/mlx5e: Fix setup TC ndo Saeed Mahameed
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Saeed Mahameed @ 2017-05-12 11:56 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Gal Pressman, kernel-team, Saeed Mahameed
From: Gal Pressman <galp@mellanox.com>
Pause bit should set when RX pause is on, not TX pause.
Also, setting Asym_Pause is incorrect, and should be turned off.
Fixes: 665bc53969d7 ("net/mlx5e: Use new ethtool get/set link ksettings API")
Signed-off-by: Gal Pressman <galp@mellanox.com>
Cc: kernel-team@fb.com
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 87a7a66363de..e235ff9a00c8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -800,7 +800,6 @@ static void get_supported(u32 eth_proto_cap,
ptys2ethtool_supported_port(link_ksettings, eth_proto_cap);
ptys2ethtool_supported_link(supported, eth_proto_cap);
ethtool_link_ksettings_add_link_mode(link_ksettings, supported, Pause);
- ethtool_link_ksettings_add_link_mode(link_ksettings, supported, Asym_Pause);
}
static void get_advertising(u32 eth_proto_cap, u8 tx_pause,
@@ -810,7 +809,7 @@ static void get_advertising(u32 eth_proto_cap, u8 tx_pause,
unsigned long *advertising = link_ksettings->link_modes.advertising;
ptys2ethtool_adver_link(advertising, eth_proto_cap);
- if (tx_pause)
+ if (rx_pause)
ethtool_link_ksettings_add_link_mode(link_ksettings, advertising, Pause);
if (tx_pause ^ rx_pause)
ethtool_link_ksettings_add_link_mode(link_ksettings, advertising, Asym_Pause);
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [net 4/6] net/mlx5e: Fix setup TC ndo
2017-05-12 11:56 [pull request][net 0/6] Mellanox, mlx5 fixes 2017-05-12 Saeed Mahameed
` (2 preceding siblings ...)
2017-05-12 11:56 ` [net 3/6] net/mlx5e: Fix ethtool pause support and advertise reporting Saeed Mahameed
@ 2017-05-12 11:56 ` Saeed Mahameed
2017-05-12 11:56 ` [net 5/6] net/mlx5e: IPoIB, Only support regular RQ for now Saeed Mahameed
2017-05-12 11:56 ` [net 6/6] net/mlx5: Use underlay QPN from the root name space Saeed Mahameed
5 siblings, 0 replies; 11+ messages in thread
From: Saeed Mahameed @ 2017-05-12 11:56 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Saeed Mahameed
Fail-safe support patches introduced a trivial bug,
setup tc callback is doing a wrong check of the netdevice state,
the fix is simply to invert the condition.
Fixes: 6f9485af4020 ("net/mlx5e: Fail safe tc setup")
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 7ac6bcc0e227..c416155115c5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2997,7 +2997,7 @@ static int mlx5e_setup_tc(struct net_device *netdev, u8 tc)
new_channels.params = priv->channels.params;
new_channels.params.num_tc = tc ? tc : 1;
- if (test_bit(MLX5E_STATE_OPENED, &priv->state)) {
+ if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
priv->channels.params = new_channels.params;
goto out;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [net 5/6] net/mlx5e: IPoIB, Only support regular RQ for now
2017-05-12 11:56 [pull request][net 0/6] Mellanox, mlx5 fixes 2017-05-12 Saeed Mahameed
` (3 preceding siblings ...)
2017-05-12 11:56 ` [net 4/6] net/mlx5e: Fix setup TC ndo Saeed Mahameed
@ 2017-05-12 11:56 ` Saeed Mahameed
2017-05-12 11:56 ` [net 6/6] net/mlx5: Use underlay QPN from the root name space Saeed Mahameed
5 siblings, 0 replies; 11+ messages in thread
From: Saeed Mahameed @ 2017-05-12 11:56 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Saeed Mahameed
IPoIB doesn't support striding RQ at the moment, for this
we need to explicitly choose non striding RQ in IPoIB init,
even if the HW supports it.
Fixes: 8f493ffd88ea ("net/mlx5e: IPoIB, RX steering RSS RQTs and TIRs")
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/ipoib.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib.c
index 019c230da498..56bff3540954 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib.c
@@ -66,6 +66,10 @@ static void mlx5i_init(struct mlx5_core_dev *mdev,
mlx5e_build_nic_params(mdev, &priv->channels.params, profile->max_nch(mdev));
+ /* Override RQ params as IPoIB supports only LINKED LIST RQ for now */
+ mlx5e_set_rq_type_params(mdev, &priv->channels.params, MLX5_WQ_TYPE_LINKED_LIST);
+ priv->channels.params.lro_en = false;
+
mutex_init(&priv->state_lock);
netdev->hw_features |= NETIF_F_SG;
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [net 6/6] net/mlx5: Use underlay QPN from the root name space
2017-05-12 11:56 [pull request][net 0/6] Mellanox, mlx5 fixes 2017-05-12 Saeed Mahameed
` (4 preceding siblings ...)
2017-05-12 11:56 ` [net 5/6] net/mlx5e: IPoIB, Only support regular RQ for now Saeed Mahameed
@ 2017-05-12 11:56 ` Saeed Mahameed
5 siblings, 0 replies; 11+ messages in thread
From: Saeed Mahameed @ 2017-05-12 11:56 UTC (permalink / raw)
To: David S. Miller
Cc: netdev, Yishai Hadas, Erez Shitrit, Maor Gottlieb, Saeed Mahameed
From: Yishai Hadas <yishaih@mellanox.com>
Root flow table is dynamically changed by the underlying flow steering
layer, and IPoIB/ULPs have no idea what will be the root flow table in
the future, hence we need a dynamic infrastructure to move Underlay QPs
with the root flow table.
Fixes: b3ba51498bdd ("net/mlx5: Refactor create flow table method to accept underlay QP")
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +-
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 5 ++---
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 9 +++-----
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h | 3 ++-
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 25 +++++++++++++++++++----
drivers/net/ethernet/mellanox/mlx5/core/fs_core.h | 2 +-
drivers/net/ethernet/mellanox/mlx5/core/ipoib.c | 7 +++++--
include/linux/mlx5/fs.h | 4 +++-
8 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index c41cf7e82795..34d3377a6147 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -1004,7 +1004,7 @@ int mlx5e_create_direct_tirs(struct mlx5e_priv *priv);
void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv);
void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt);
-int mlx5e_create_ttc_table(struct mlx5e_priv *priv, u32 underlay_qpn);
+int mlx5e_create_ttc_table(struct mlx5e_priv *priv);
void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv);
int mlx5e_create_tis(struct mlx5_core_dev *mdev, int tc,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
index 576d6787b484..53ed58320a24 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
@@ -800,7 +800,7 @@ void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv)
mlx5e_destroy_flow_table(&ttc->ft);
}
-int mlx5e_create_ttc_table(struct mlx5e_priv *priv, u32 underlay_qpn)
+int mlx5e_create_ttc_table(struct mlx5e_priv *priv)
{
struct mlx5e_ttc_table *ttc = &priv->fs.ttc;
struct mlx5_flow_table_attr ft_attr = {};
@@ -810,7 +810,6 @@ int mlx5e_create_ttc_table(struct mlx5e_priv *priv, u32 underlay_qpn)
ft_attr.max_fte = MLX5E_TTC_TABLE_SIZE;
ft_attr.level = MLX5E_TTC_FT_LEVEL;
ft_attr.prio = MLX5E_NIC_PRIO;
- ft_attr.underlay_qpn = underlay_qpn;
ft->t = mlx5_create_flow_table(priv->fs.ns, &ft_attr);
if (IS_ERR(ft->t)) {
@@ -1147,7 +1146,7 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv)
priv->netdev->hw_features &= ~NETIF_F_NTUPLE;
}
- err = mlx5e_create_ttc_table(priv, 0);
+ err = mlx5e_create_ttc_table(priv);
if (err) {
netdev_err(priv->netdev, "Failed to create ttc table, err=%d\n",
err);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
index 19e3d2fc2099..fcec7bedd3cd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
@@ -40,28 +40,25 @@
#include "eswitch.h"
int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev,
- struct mlx5_flow_table *ft)
+ struct mlx5_flow_table *ft, u32 underlay_qpn)
{
u32 in[MLX5_ST_SZ_DW(set_flow_table_root_in)] = {0};
u32 out[MLX5_ST_SZ_DW(set_flow_table_root_out)] = {0};
if ((MLX5_CAP_GEN(dev, port_type) == MLX5_CAP_PORT_TYPE_IB) &&
- ft->underlay_qpn == 0)
+ underlay_qpn == 0)
return 0;
MLX5_SET(set_flow_table_root_in, in, opcode,
MLX5_CMD_OP_SET_FLOW_TABLE_ROOT);
MLX5_SET(set_flow_table_root_in, in, table_type, ft->type);
MLX5_SET(set_flow_table_root_in, in, table_id, ft->id);
+ MLX5_SET(set_flow_table_root_in, in, underlay_qpn, underlay_qpn);
if (ft->vport) {
MLX5_SET(set_flow_table_root_in, in, vport_number, ft->vport);
MLX5_SET(set_flow_table_root_in, in, other_vport, 1);
}
- if ((MLX5_CAP_GEN(dev, port_type) == MLX5_CAP_PORT_TYPE_IB) &&
- ft->underlay_qpn != 0)
- MLX5_SET(set_flow_table_root_in, in, underlay_qpn, ft->underlay_qpn);
-
return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h
index 8fad80688536..0f98a7cf4877 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h
@@ -71,7 +71,8 @@ int mlx5_cmd_delete_fte(struct mlx5_core_dev *dev,
unsigned int index);
int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev,
- struct mlx5_flow_table *ft);
+ struct mlx5_flow_table *ft,
+ u32 underlay_qpn);
int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u16 *id);
int mlx5_cmd_fc_free(struct mlx5_core_dev *dev, u16 id);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index b8a176503d38..0e487e8ca634 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -650,7 +650,7 @@ static int update_root_ft_create(struct mlx5_flow_table *ft, struct fs_prio
if (ft->level >= min_level)
return 0;
- err = mlx5_cmd_update_root_ft(root->dev, ft);
+ err = mlx5_cmd_update_root_ft(root->dev, ft, root->underlay_qpn);
if (err)
mlx5_core_warn(root->dev, "Update root flow table of id=%u failed\n",
ft->id);
@@ -818,8 +818,6 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa
goto unlock_root;
}
- ft->underlay_qpn = ft_attr->underlay_qpn;
-
tree_init_node(&ft->node, 1, del_flow_table);
log_table_sz = ft->max_fte ? ilog2(ft->max_fte) : 0;
next_ft = find_next_chained_ft(fs_prio);
@@ -1489,7 +1487,8 @@ static int update_root_ft_destroy(struct mlx5_flow_table *ft)
new_root_ft = find_next_ft(ft);
if (new_root_ft) {
- int err = mlx5_cmd_update_root_ft(root->dev, new_root_ft);
+ int err = mlx5_cmd_update_root_ft(root->dev, new_root_ft,
+ root->underlay_qpn);
if (err) {
mlx5_core_warn(root->dev, "Update root flow table of id=%u failed\n",
@@ -2062,3 +2061,21 @@ int mlx5_init_fs(struct mlx5_core_dev *dev)
mlx5_cleanup_fs(dev);
return err;
}
+
+int mlx5_fs_add_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn)
+{
+ struct mlx5_flow_root_namespace *root = dev->priv.steering->root_ns;
+
+ root->underlay_qpn = underlay_qpn;
+ return 0;
+}
+EXPORT_SYMBOL(mlx5_fs_add_rx_underlay_qpn);
+
+int mlx5_fs_remove_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn)
+{
+ struct mlx5_flow_root_namespace *root = dev->priv.steering->root_ns;
+
+ root->underlay_qpn = 0;
+ return 0;
+}
+EXPORT_SYMBOL(mlx5_fs_remove_rx_underlay_qpn);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
index 81eafc7b9dd9..990acee6fb09 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
@@ -118,7 +118,6 @@ struct mlx5_flow_table {
/* FWD rules that point on this flow table */
struct list_head fwd_rules;
u32 flags;
- u32 underlay_qpn;
};
struct mlx5_fc_cache {
@@ -195,6 +194,7 @@ struct mlx5_flow_root_namespace {
struct mlx5_flow_table *root_ft;
/* Should be held when chaining flow tables */
struct mutex chain_lock;
+ u32 underlay_qpn;
};
int mlx5_init_fc_stats(struct mlx5_core_dev *dev);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib.c
index 56bff3540954..cc1858752e70 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib.c
@@ -160,6 +160,8 @@ static int mlx5i_create_underlay_qp(struct mlx5_core_dev *mdev, struct mlx5_core
static void mlx5i_destroy_underlay_qp(struct mlx5_core_dev *mdev, struct mlx5_core_qp *qp)
{
+ mlx5_fs_remove_rx_underlay_qpn(mdev, qp->qpn);
+
mlx5_core_destroy_qp(mdev, qp);
}
@@ -174,6 +176,8 @@ static int mlx5i_init_tx(struct mlx5e_priv *priv)
return err;
}
+ mlx5_fs_add_rx_underlay_qpn(priv->mdev, ipriv->qp.qpn);
+
err = mlx5e_create_tis(priv->mdev, 0 /* tc */, ipriv->qp.qpn, &priv->tisn[0]);
if (err) {
mlx5_core_warn(priv->mdev, "create tis failed, %d\n", err);
@@ -193,7 +197,6 @@ static void mlx5i_cleanup_tx(struct mlx5e_priv *priv)
static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)
{
- struct mlx5i_priv *ipriv = priv->ppriv;
int err;
priv->fs.ns = mlx5_get_flow_namespace(priv->mdev,
@@ -209,7 +212,7 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)
priv->netdev->hw_features &= ~NETIF_F_NTUPLE;
}
- err = mlx5e_create_ttc_table(priv, ipriv->qp.qpn);
+ err = mlx5e_create_ttc_table(priv);
if (err) {
netdev_err(priv->netdev, "Failed to create ttc table, err=%d\n",
err);
diff --git a/include/linux/mlx5/fs.h b/include/linux/mlx5/fs.h
index 1b166d2e19c5..b25e7baa273e 100644
--- a/include/linux/mlx5/fs.h
+++ b/include/linux/mlx5/fs.h
@@ -109,7 +109,6 @@ struct mlx5_flow_table_attr {
int max_fte;
u32 level;
u32 flags;
- u32 underlay_qpn;
};
struct mlx5_flow_table *
@@ -167,4 +166,7 @@ struct mlx5_fc *mlx5_fc_create(struct mlx5_core_dev *dev, bool aging);
void mlx5_fc_destroy(struct mlx5_core_dev *dev, struct mlx5_fc *counter);
void mlx5_fc_query_cached(struct mlx5_fc *counter,
u64 *bytes, u64 *packets, u64 *lastuse);
+int mlx5_fs_add_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn);
+int mlx5_fs_remove_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn);
+
#endif
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [net 1/6] net/mlx5e: Use a spinlock to synchronize statistics
2017-05-12 11:56 ` [net 1/6] net/mlx5e: Use a spinlock to synchronize statistics Saeed Mahameed
@ 2017-05-12 16:13 ` David Miller
2017-05-14 8:52 ` Saeed Mahameed
2017-05-15 22:51 ` Stephen Hemminger
1 sibling, 1 reply; 11+ messages in thread
From: David Miller @ 2017-05-12 16:13 UTC (permalink / raw)
To: saeedm; +Cc: netdev, galp, kernel-team
From: Saeed Mahameed <saeedm@mellanox.com>
Date: Fri, 12 May 2017 14:56:45 +0300
> From: Gal Pressman <galp@mellanox.com>
>
> Add a spinlock to prevent races when querying statistics, for example
> querying counters in the middle of a non atomic memcpy() operation in
> mlx5e_update_stats().
>
> This RW lock should be held when accessing priv->stats, to prevent other
> reads/writes.
>
> Fixes: 9218b44dcc05 ("net/mlx5e: Statistics handling refactoring")
> Signed-off-by: Gal Pressman <galp@mellanox.com>
> Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: kernel-team@fb.com
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
This is overkill, and that rwlock is going to show up in perf for some
workloads.
Furthermore, two kzalloc()'s for a single state update operation?
That's not reasonable either.
Use a seqlock, which is the primitive for handling this kind of
situation cheaply, and adds no atomics to the read path.
Thank you.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [net 1/6] net/mlx5e: Use a spinlock to synchronize statistics
2017-05-12 16:13 ` David Miller
@ 2017-05-14 8:52 ` Saeed Mahameed
2017-05-15 18:39 ` David Miller
0 siblings, 1 reply; 11+ messages in thread
From: Saeed Mahameed @ 2017-05-14 8:52 UTC (permalink / raw)
To: David Miller; +Cc: Saeed Mahameed, Linux Netdev List, Gal Pressman, Kernel Team
On Fri, May 12, 2017 at 7:13 PM, David Miller <davem@davemloft.net> wrote:
> From: Saeed Mahameed <saeedm@mellanox.com>
> Date: Fri, 12 May 2017 14:56:45 +0300
>
>> From: Gal Pressman <galp@mellanox.com>
>>
>> Add a spinlock to prevent races when querying statistics, for example
>> querying counters in the middle of a non atomic memcpy() operation in
>> mlx5e_update_stats().
>>
>> This RW lock should be held when accessing priv->stats, to prevent other
>> reads/writes.
>>
>> Fixes: 9218b44dcc05 ("net/mlx5e: Statistics handling refactoring")
>> Signed-off-by: Gal Pressman <galp@mellanox.com>
>> Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
>> Cc: kernel-team@fb.com
>> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
>
> This is overkill, and that rwlock is going to show up in perf for some
> workloads.
>
> Furthermore, two kzalloc()'s for a single state update operation?
> That's not reasonable either.
>
Hi Dave,
Well, the idea of the patch is to minimize the stats update to a
single safe copy operation under stats_lock
for that we need a temp buffer to store stats FW commands output, and
then safely -under stats_lock- copy it to
the buffer ethtool is going to report.
I agree, it is really ridiculous that we allocate/free a couple of
buffers on each update_stats operations, regardless of this patch.
Is it ok if we use a temp buffer under netdev_priv for such usages or
even use kmemcache ?
> Use a seqlock, which is the primitive for handling this kind of
> situation cheaply, and adds no atomics to the read path.
>
Will change this. Thanks for the tip.
I will drop this patch for now and I will resend it later once Gal
addresses all of the above comments.
Thanks,
Saeed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [net 1/6] net/mlx5e: Use a spinlock to synchronize statistics
2017-05-14 8:52 ` Saeed Mahameed
@ 2017-05-15 18:39 ` David Miller
0 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2017-05-15 18:39 UTC (permalink / raw)
To: saeedm; +Cc: saeedm, netdev, galp, kernel-team
From: Saeed Mahameed <saeedm@dev.mellanox.co.il>
Date: Sun, 14 May 2017 11:52:13 +0300
> I agree, it is really ridiculous that we allocate/free a couple of
> buffers on each update_stats operations, regardless of this patch.
> Is it ok if we use a temp buffer under netdev_priv for such usages or
> even use kmemcache ?
If you can safely use a pre-allocated tmp buffer, yes that would be
preferred.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [net 1/6] net/mlx5e: Use a spinlock to synchronize statistics
2017-05-12 11:56 ` [net 1/6] net/mlx5e: Use a spinlock to synchronize statistics Saeed Mahameed
2017-05-12 16:13 ` David Miller
@ 2017-05-15 22:51 ` Stephen Hemminger
1 sibling, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2017-05-15 22:51 UTC (permalink / raw)
To: Saeed Mahameed; +Cc: David S. Miller, netdev, Gal Pressman, kernel-team
On Fri, 12 May 2017 14:56:45 +0300
Saeed Mahameed <saeedm@mellanox.com> wrote:
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
> index 0099a3e397bc..c41cf7e82795 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
> @@ -756,6 +756,7 @@ struct mlx5e_priv {
> struct mlx5_core_dev *mdev;
> struct net_device *netdev;
> struct mlx5e_stats stats;
> + rwlock_t stats_lock;
A reader-writer lock is slower than a spin_lock.
The only case where reader/writer lock is preferred is when writer
will hold onto the lock for a significant amount of time.
Also you only need each statistic to be atomic, the network device API
never guarantees transactional update across multiple statistics.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2017-05-15 22:51 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-12 11:56 [pull request][net 0/6] Mellanox, mlx5 fixes 2017-05-12 Saeed Mahameed
2017-05-12 11:56 ` [net 1/6] net/mlx5e: Use a spinlock to synchronize statistics Saeed Mahameed
2017-05-12 16:13 ` David Miller
2017-05-14 8:52 ` Saeed Mahameed
2017-05-15 18:39 ` David Miller
2017-05-15 22:51 ` Stephen Hemminger
2017-05-12 11:56 ` [net 2/6] net/mlx5e: Use the correct pause values for ethtool advertising Saeed Mahameed
2017-05-12 11:56 ` [net 3/6] net/mlx5e: Fix ethtool pause support and advertise reporting Saeed Mahameed
2017-05-12 11:56 ` [net 4/6] net/mlx5e: Fix setup TC ndo Saeed Mahameed
2017-05-12 11:56 ` [net 5/6] net/mlx5e: IPoIB, Only support regular RQ for now Saeed Mahameed
2017-05-12 11:56 ` [net 6/6] net/mlx5: Use underlay QPN from the root name space Saeed Mahameed
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.