Mellanox, mlx5 fixes 2019-06-07
Hi Dave,
This series introduces some fixes to mlx5 driver.
Please pull and let me know if there is any problem.
For -stable v4.17
('net/mlx5: Avoid reloading already removed devices')
For -stable v5.0
('net/mlx5e: Avoid detaching non-existing netdev under switchdev mode')
For -stable v5.1
('net/mlx5e: Fix source port matching in fdb peer flow rule') ('net/mlx5e: Support tagged tunnel over bond') ('net/mlx5e: Add ndo_set_feature for uplink representor') ('net/mlx5: Update pci error handler entries and command translation')
Thanks,
Saeed.
---
The following changes since commit f2c7c76c5d0a443053e94adb9f0918fa2fb85c3a:
Linux 5.2-rc3 (2019-06-02 13:55:33 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2019-06-07
for you to fetch changes up to 45e7d4c0c1727d362012a62eb57254ea71a2d591:
net/mlx5e: Support tagged tunnel over bond (2019-06-07 14:40:37 -0700)
----------------------------------------------------------------
mlx5-fixes-2019-06-07
----------------------------------------------------------------
Alaa Hleihel (2):
net/mlx5: Avoid reloading already removed devices net/mlx5e: Avoid detaching non-existing netdev under switchdev mode
Chris Mi (1):
net/mlx5e: Add ndo_set_feature for uplink representor
Edward Srouji (1):
net/mlx5: Update pci error handler entries and command translation
Eli Britstein (1):
net/mlx5e: Support tagged tunnel over bond
Raed Salem (1):
net/mlx5e: Fix source port matching in fdb peer flow rule
Shay Agroskin (1):
net/mlx5e: Replace reciprocal_scale in TX select queue function
drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 8 +++++++ drivers/net/ethernet/mellanox/mlx5/core/dev.c | 25 ++++++++++++++++++++-- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 ++ .../net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 11 +++++----- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 9 ++++++-- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 10 +++++---- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 --- drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 12 +++++------ 8 files changed, 58 insertions(+), 22 deletions(-)
PATCH 1/7 net/mlx5: Update pci error handler entries and command translation
From: Edward Srouji <[email protected]>
Add missing entries for create/destroy UCTX and UMEM commands. This could get us wrong "unknown FW command" error in flows where we unbind the device or reset the driver.
Also the translation of these commands from opcodes to string was missing.
--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +8 -0
@@ -441,6 +441,10 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,case MLX5_CMD_OP_CREATE_GENERAL_OBJECT :case MLX5_CMD_OP_MODIFY_GENERAL_OBJECT :case MLX5_CMD_OP_QUERY_GENERAL_OBJECT : +case MLX5_CMD_OP_CREATE_UCTX : +case MLX5_CMD_OP_DESTROY_UCTX : +case MLX5_CMD_OP_CREATE_UMEM : +case MLX5_CMD_OP_DESTROY_UMEM :case MLX5_CMD_OP_ALLOC_MEMIC : *status =MLX5_DRIVER_STATUS_ABORTED ; *synd =MLX5_DRIVER_SYND ;
@@ -629,6 +633,10 @@ const char *mlx5_command_str(int command)MLX5_COMMAND_STR_CASE (ALLOC_MEMIC );MLX5_COMMAND_STR_CASE (DEALLOC_MEMIC );MLX5_COMMAND_STR_CASE (QUERY_HOST_PARAMS ); +MLX5_COMMAND_STR_CASE (CREATE_UCTX ); +MLX5_COMMAND_STR_CASE (DESTROY_UCTX ); +MLX5_COMMAND_STR_CASE (CREATE_UMEM ); +MLX5_COMMAND_STR_CASE (DESTROY_UMEM );default :return "unknown command opcode" ; } }
Signature · 1 line
2.21.0
PATCH 2/7 net/mlx5: Avoid reloading already removed devices
In reply to Saeed MahameedFrom: Alaa Hleihel <[email protected]>
Prior to reloading a device we must first verify that it was not already removed. Otherwise, the attempt to remove the device will do nothing, and in that case we will end up proceeding with adding an new device that no one was expecting to remove, leaving behind used resources such as EQs that causes a failure to destroy comp EQs and syndrome (0x30f433).
Fix that by making sure that we try to remove and add a device (based on a protocol) only if the device is already added.
--- drivers/net/ethernet/mellanox/mlx5/core/dev.c | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/dev.c +23 -2
@@ -248,11 +248,32 @@ void mlx5_unregister_interface(struct mlx5_interface *intf) }EXPORT_SYMBOL (mlx5_unregister_interface); +/* Must be called with intf_mutex held */ +static bool mlx5_has_added_dev_by_protocol (struct mlx5_core_dev *mdev,int protocol) +{ +struct mlx5_device_context *dev_ctx; +struct mlx5_interface *intf; +bool found = false; + +list_for_each_entry (intf, &intf_list, list) { +if (intf->protocol == protocol) { + dev_ctx =mlx5_get_device (intf, &mdev->priv); +if (dev_ctx &&test_bit (MLX5_INTERFACE_ADDED , &dev_ctx->state)) + found = true; +break ; + } + } + +return found; +} +void mlx5_reload_interface (struct mlx5_core_dev *mdev,int protocol) {mutex_lock (&mlx5_intf_mutex); -mlx5_remove_dev_by_protocol (mdev, protocol); -mlx5_add_dev_by_protocol (mdev, protocol); +if (mlx5_has_added_dev_by_protocol (mdev, protocol)) { +mlx5_remove_dev_by_protocol (mdev, protocol); +mlx5_add_dev_by_protocol (mdev, protocol); + }mutex_unlock (&mlx5_intf_mutex); }
Signature · 1 line
2.21.0
PATCH 3/7 net/mlx5e: Add ndo_set_feature for uplink representor
In reply to Saeed MahameedFrom: Chris Mi <[email protected]>
After we have a dedicated uplink representor, the new netdev ops doesn't support ndo_set_feature. Because of that, we can't change some features, eg. rxvlan. Now add it back.
In this patch, I also do a cleanup for the features flag handling, eg. remove duplicate NETIF_F_HW_TC flag setting.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 3 +-- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -0
@@ -1112,6 +1112,7 @@ void mlx5e_del_vxlan_port(struct net_device *netdev, struct udp_tunnel_info *ti)netdev_features_t mlx5e_features_check (struct sk_buff *skb,struct net_device *netdev,netdev_features_t features); +int mlx5e_set_features (struct net_device *netdev,netdev_features_t features);#ifdef CONFIG_MLX5_ESWITCH int mlx5e_set_vf_mac (struct net_device *dev,int vf,u8 *mac);int mlx5e_set_vf_rate (struct net_device *dev,int vf,int min_tx_rate,int max_tx_rate);
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -2
@@ -3635,8 +3635,7 @@ static int mlx5e_handle_feature(struct net_device *netdev,return 0 ; } -static int mlx5e_set_features (struct net_device *netdev, -netdev_features_t features) +int mlx5e_set_features (struct net_device *netdev,netdev_features_t features) {netdev_features_t oper_features = netdev->features;int err =0 ;
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +6 -4
@@ -1351,6 +1351,7 @@ static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = { .ndo_get_vf_stats = mlx5e_get_vf_stats, .ndo_set_vf_vlan = mlx5e_uplink_rep_set_vf_vlan, .ndo_get_port_parent_id = mlx5e_rep_get_port_parent_id, + .ndo_set_features = mlx5e_set_features, };bool mlx5e_eswitch_rep (struct net_device *netdev)
@@ -1425,10 +1426,9 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev) netdev->watchdog_timeo =15 *HZ ; + netdev->features |=NETIF_F_NETNS_LOCAL ; - netdev->features |=NETIF_F_HW_TC |NETIF_F_NETNS_LOCAL ; - netdev->hw_features |=NETIF_F_HW_TC ; - + netdev->hw_features |=NETIF_F_HW_TC ; netdev->hw_features |=NETIF_F_SG ; netdev->hw_features |=NETIF_F_IP_CSUM ; netdev->hw_features |=NETIF_F_IPV6_CSUM ;
@@ -1437,7 +1437,9 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev) netdev->hw_features |=NETIF_F_TSO6 ; netdev->hw_features |=NETIF_F_RXCSUM ; -if (rep->vport !=MLX5_VPORT_UPLINK ) +if (rep->vport ==MLX5_VPORT_UPLINK ) + netdev->hw_features |=NETIF_F_HW_VLAN_CTAG_RX ; +else netdev->features |=NETIF_F_VLAN_CHALLENGED ; netdev->features |= netdev->hw_features;
Signature · 1 line
2.21.0
PATCH 4/7 net/mlx5e: Replace reciprocal_scale in TX select queue function
In reply to Saeed MahameedFrom: Shay Agroskin <[email protected]>
The TX queue index returned by the fallback function ranges between [0,NUM CHANNELS - 1] if QoS isn't set and [0, (NUM CHANNELS)*(NUM TCs) -1] otherwise.
Our HW uses different TC mapping than the fallback function (which is denoted as 'up', user priority) so we only need to extract a channel number out of the returned value.
Since (NUM CHANNELS)*(NUM TCs) is a relatively small number, using reciprocal scale almost always returns zero.
We instead access the 'txq2sq' table to extract the sq (and with it the channel number) associated with the tx queue, thus getting
a more evenly distributed channel number.
Perf:
Rx/Tx side with Intel(R) Xeon(R) Silver 4108 CPU @ 1.80GHz and ConnectX-5. Used 'iperf' UDP traffic, 10 threads, and priority 5.
Before: 0.566Mpps
After: 2.37Mpps
As expected, releasing the existing bottleneck of steering all traffic to TX queue zero significantly improves transmission rates.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 12 ++++++------ 3 files changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -0
@@ -385,6 +385,7 @@ struct mlx5e_txqsq {/* control path */ struct mlx5_wq_ctrl wq_ctrl;struct mlx5e_channel *channel; +int ch_ix;int txq_ix;u32 rate_limit;struct work_struct recover_work;
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -0
@@ -1082,6 +1082,7 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c, sq->clock = &mdev->clock; sq->mkey_be = c->mkey_be; sq->channel = c; + sq->ch_ix = c->ix; sq->txq_ix = txq_ix; sq->uar_map = mdev->mlx5e_res.bfreg.map; sq->min_inline_mode = params->tx_min_inline_mode;
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +6 -6
@@ -113,13 +113,13 @@ static inline int mlx5e_get_dscp_up(struct mlx5e_priv *priv, struct sk_buff *skbu16 mlx5e_select_queue (struct net_device *dev,struct sk_buff *skb,struct net_device *sb_dev) { -int channel_ix =netdev_pick_tx (dev, skb,NULL ); +int txq_ix =netdev_pick_tx (dev, skb,NULL );struct mlx5e_priv *priv =netdev_priv (dev);u16 num_channels;int up =0 ;if (!netdev_get_num_tc (dev)) -return channel_ix; +return txq_ix;#ifdef CONFIG_MLX5_CORE_EN_DCB if (priv->dcbx_dp.trust_state ==MLX5_QPTS_TRUST_DSCP )
@@ -129,14 +129,14 @@ u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb,if (skb_vlan_tag_present (skb)) up =skb_vlan_tag_get_prio (skb); -/* channel_ix can be larger than num_channels since +/* txq_ix can be larger than num_channels since * dev->num_real_tx_queues = num_channels * num_tc */ num_channels = priv->channels.params.num_channels; -if (channel_ix >= num_channels) - channel_ix =reciprocal_scale (channel_ix, num_channels); +if (txq_ix >= num_channels) + txq_ix = priv->txq2sq[txq_ix]->ch_ix; -return priv->channel_tc2txq[channel_ix][up]; +return priv->channel_tc2txq[txq_ix][up]; }static inline int mlx5e_skb_l2_header_offset (struct sk_buff *skb)
Signature · 1 line
2.21.0
PATCH 5/7 net/mlx5e: Fix source port matching in fdb peer flow rule
In reply to Saeed MahameedFrom: Raed Salem <[email protected]>
The cited commit changed the initialization placement of the eswitch attributes so it is done prior to parse tc actions function call, including among others the in_rep and in_mdev fields which are mistakenly reassigned inside the parse actions function.
This breaks the source port matching criteria of the peer redirect rule.
Fix by removing the now redundant reassignment of the already initialized fields.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +0 -3
@@ -2812,9 +2812,6 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,if (!flow_action_has_entries (flow_action))return -EINVAL ; - attr->in_rep = rpriv->rep; - attr->in_mdev = priv->mdev; -flow_action_for_each (i, act, flow_action) {switch (act->id) {case FLOW_ACTION_DROP :
Signature · 1 line
2.21.0
PATCH 6/7 net/mlx5e: Avoid detaching non-existing netdev under switchdev mode
In reply to Saeed MahameedFrom: Alaa Hleihel <[email protected]>
After introducing dedicated uplink representor, the netdev instance set over the esw manager vport (PF) became no longer in use, so it was removed in the cited commit once we're on switchdev mode. However, the mlx5e_detach function was not updated accordingly, and it still tries to detach a non-existing netdev, causing a kernel crash.
This patch fixes this issue.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +5 -0
@@ -5108,6 +5108,11 @@ static void mlx5e_detach(struct mlx5_core_dev *mdev, void *vpriv)struct mlx5e_priv *priv = vpriv;struct net_device *netdev = priv->netdev; +#ifdef CONFIG_MLX5_ESWITCH +if (MLX5_ESWITCH_MANAGER (mdev) && vpriv == mdev) +return ; +#endif +if (!netif_device_present (netdev))return ;
Signature · 1 line
2.21.0
PATCH 7/7 net/mlx5e: Support tagged tunnel over bond
In reply to Saeed MahameedFrom: Eli Britstein <[email protected]>
Stacked devices like bond interface may have a VLAN device on top of them. Detect lag state correctly under this condition, and return the correct routed net device, according to it the encap header is built.
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +6 -5
@@ -11,24 +11,25 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,struct net_device **route_dev, struct net_device **out_dev) { + struct net_device *uplink_dev, *uplink_upper, *real_dev;struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; -struct net_device *uplink_dev, *uplink_upper;bool dst_is_lag_dev; + real_dev =is_vlan_dev (dev) ?vlan_dev_real_dev (dev) : dev; uplink_dev =mlx5_eswitch_uplink_get_proto_dev (esw,REP_ETH ); uplink_upper =netdev_master_upper_dev_get (uplink_dev); dst_is_lag_dev = (uplink_upper &&netif_is_lag_master (uplink_upper) && - dev == uplink_upper && + real_dev == uplink_upper &&mlx5_lag_is_sriov (priv->mdev));/* if the egress device isn't on the same HW e-switch or * it's a LAG device, use the uplink */ -if (!netdev_port_same_parent_id (priv->netdev, dev) || +if (!netdev_port_same_parent_id (priv->netdev, real_dev) || dst_is_lag_dev) { - *route_dev = uplink_dev; - *out_dev = *route_dev; + *route_dev = dev; + *out_dev = uplink_dev; }else { *route_dev = dev;if (is_vlan_dev (*route_dev))
Signature · 1 line
2.21.0
Jesse Brandeburg
Reviewed-byQuoted 9 lines · On Fri, 7 Jun 2019 21:47:35 +0000 Saeed wrote:
Hi Dave,
This series introduces some fixes to mlx5 driver.
Please pull and let me know if there is any problem.
For -stable v4.17
('net/mlx5: Avoid reloading already removed devices')
Quoted 9 lines
For -stable v5.0
('net/mlx5e: Avoid detaching non-existing netdev under switchdev mode')For -stable v5.1
('net/mlx5e: Fix source port matching in fdb peer flow rule') ('net/mlx5e: Support tagged tunnel over bond') ('net/mlx5e: Addndo_set_featurefor uplink representor') ('net/mlx5: Update pci error handler entries and command translation')
For the series:
David Miller
maintainerFrom: Saeed Mahameed <[email protected]>
Date: Fri, 7 Jun 2019 21:47:35 +0000
Quoted 3 lines
This series introduces some fixes to mlx5 driver.
Please pull and let me know if there is any problem.
Pulled.
Quoted 11 lines
For -stable v4.17
('net/mlx5: Avoid reloading already removed devices')For -stable v5.0
('net/mlx5e: Avoid detaching non-existing netdev under switchdev mode')For -stable v5.1
('net/mlx5e: Fix source port matching in fdb peer flow rule') ('net/mlx5e: Support tagged tunnel over bond') ('net/mlx5e: Addndo_set_featurefor uplink representor') ('net/mlx5: Update pci error handler entries and command translation')
Queued up.
Thanks.