* [PATCH net 0/4] mlx5 misc fixes 2024-12-20
@ 2024-12-20 8:15 Tariq Toukan
2024-12-20 8:15 ` [PATCH net 1/4] net/mlx5: DR, select MSIX vector 0 for completion queue creation Tariq Toukan
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Tariq Toukan @ 2024-12-20 8:15 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet,
Andrew Lunn
Cc: netdev, Saeed Mahameed, Gal Pressman, Leon Romanovsky, Mark Bloch,
Tariq Toukan
Hi,
This small patchset provides misc bug fixes from the team to the mlx5
core and Eth drivers.
Thanks,
Tariq.
Dragos Tatulea (1):
net/mlx5e: macsec: Maintain TX SA from encoding_sa
Jianbo Liu (2):
net/mlx5e: Skip restore TC rules for vport rep without loaded flag
net/mlx5e: Keep netdev when leave switchdev for devlink set legacy
only
Shahar Shitrit (1):
net/mlx5: DR, select MSIX vector 0 for completion queue creation
.../mellanox/mlx5/core/en_accel/macsec.c | 4 ++++
.../net/ethernet/mellanox/mlx5/core/en_main.c | 19 +++++++++++++++++--
.../net/ethernet/mellanox/mlx5/core/en_rep.c | 15 +++++++++++++++
.../mellanox/mlx5/core/esw/ipsec_fs.c | 6 +++---
.../net/ethernet/mellanox/mlx5/core/eswitch.h | 3 +++
.../mellanox/mlx5/core/eswitch_offloads.c | 5 ++---
.../mellanox/mlx5/core/steering/sws/dr_send.c | 4 +---
include/linux/mlx5/driver.h | 1 +
8 files changed, 46 insertions(+), 11 deletions(-)
base-commit: b6075c80537558b16ff72861af4c0539c375e11b
--
2.45.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net 1/4] net/mlx5: DR, select MSIX vector 0 for completion queue creation
2024-12-20 8:15 [PATCH net 0/4] mlx5 misc fixes 2024-12-20 Tariq Toukan
@ 2024-12-20 8:15 ` Tariq Toukan
2024-12-20 8:15 ` [PATCH net 2/4] net/mlx5e: macsec: Maintain TX SA from encoding_sa Tariq Toukan
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Tariq Toukan @ 2024-12-20 8:15 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet,
Andrew Lunn
Cc: netdev, Saeed Mahameed, Gal Pressman, Leon Romanovsky, Mark Bloch,
Shahar Shitrit, Yevgeny Kliteynik, Tariq Toukan
From: Shahar Shitrit <shshitrit@nvidia.com>
When creating a software steering completion queue (CQ), an arbitrary
MSIX vector n is selected. This results in the CQ sharing the same
Ethernet traffic channel n associated with the chosen vector. However,
the value of n is often unpredictable, which can introduce complications
for interrupt monitoring and verification tools.
Moreover, SW steering uses polling rather than event-driven interrupts.
Therefore, there is no need to select any MSIX vector other than the
existing vector 0 for CQ creation.
In light of these factors, and to enhance predictability, we modify the
code to consistently select MSIX vector 0 for CQ creation.
Fixes: 297cccebdc5a ("net/mlx5: DR, Expose an internal API to issue RDMA operations")
Signed-off-by: Shahar Shitrit <shshitrit@nvidia.com>
Reviewed-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/steering/sws/dr_send.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_send.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_send.c
index 6fa06ba2d346..f57c84e5128b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_send.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_send.c
@@ -1067,7 +1067,6 @@ static struct mlx5dr_cq *dr_create_cq(struct mlx5_core_dev *mdev,
int inlen, err, eqn;
void *cqc, *in;
__be64 *pas;
- int vector;
u32 i;
cq = kzalloc(sizeof(*cq), GFP_KERNEL);
@@ -1096,8 +1095,7 @@ static struct mlx5dr_cq *dr_create_cq(struct mlx5_core_dev *mdev,
if (!in)
goto err_cqwq;
- vector = raw_smp_processor_id() % mlx5_comp_vectors_max(mdev);
- err = mlx5_comp_eqn_get(mdev, vector, &eqn);
+ err = mlx5_comp_eqn_get(mdev, 0, &eqn);
if (err) {
kvfree(in);
goto err_cqwq;
--
2.45.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net 2/4] net/mlx5e: macsec: Maintain TX SA from encoding_sa
2024-12-20 8:15 [PATCH net 0/4] mlx5 misc fixes 2024-12-20 Tariq Toukan
2024-12-20 8:15 ` [PATCH net 1/4] net/mlx5: DR, select MSIX vector 0 for completion queue creation Tariq Toukan
@ 2024-12-20 8:15 ` Tariq Toukan
2024-12-20 8:15 ` [PATCH net 3/4] net/mlx5e: Skip restore TC rules for vport rep without loaded flag Tariq Toukan
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Tariq Toukan @ 2024-12-20 8:15 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet,
Andrew Lunn
Cc: netdev, Saeed Mahameed, Gal Pressman, Leon Romanovsky, Mark Bloch,
Dragos Tatulea, Cosmin Ratiu, Lior Nahmanson, Tariq Toukan
From: Dragos Tatulea <dtatulea@nvidia.com>
In MACsec, it is possible to create multiple active TX SAs on a SC,
but only one such SA can be used at a time for transmission. This SA
is selected through the encoding_sa link parameter.
When there are 2 or more active TX SAs configured (encoding_sa=0):
ip macsec add macsec0 tx sa 0 pn 1 on key 00 <KEY1>
ip macsec add macsec0 tx sa 1 pn 1 on key 00 <KEY2>
... the traffic should be still sent via TX SA 0 as the encoding_sa was
not changed. However, the driver ignores the encoding_sa and overrides
it to SA 1 by installing the flow steering id of the newly created TX SA
into the SCI -> flow steering id hash map. The future packet tx
descriptors will point to the incorrect flow steering rule (SA 1).
This patch fixes the issue by avoiding the creation of the flow steering
rule for an active TX SA that is not the encoding_sa. The driver side
tx_sa object and the FW side macsec object are still created. When the
encoding_sa link parameter is changed to another active TX SA, only the
new flow steering rule will be created in the mlx5e_macsec_upd_txsa()
handler.
Fixes: 8ff0ac5be144 ("net/mlx5: Add MACsec offload Tx command support")
Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Lior Nahmanson <liorna@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
index cc9bcc420032..6ab02f3fc291 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
@@ -339,9 +339,13 @@ static int mlx5e_macsec_init_sa_fs(struct macsec_context *ctx,
{
struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
struct mlx5_macsec_fs *macsec_fs = priv->mdev->macsec_fs;
+ const struct macsec_tx_sc *tx_sc = &ctx->secy->tx_sc;
struct mlx5_macsec_rule_attrs rule_attrs;
union mlx5_macsec_rule *macsec_rule;
+ if (is_tx && tx_sc->encoding_sa != sa->assoc_num)
+ return 0;
+
rule_attrs.macsec_obj_id = sa->macsec_obj_id;
rule_attrs.sci = sa->sci;
rule_attrs.assoc_num = sa->assoc_num;
--
2.45.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net 3/4] net/mlx5e: Skip restore TC rules for vport rep without loaded flag
2024-12-20 8:15 [PATCH net 0/4] mlx5 misc fixes 2024-12-20 Tariq Toukan
2024-12-20 8:15 ` [PATCH net 1/4] net/mlx5: DR, select MSIX vector 0 for completion queue creation Tariq Toukan
2024-12-20 8:15 ` [PATCH net 2/4] net/mlx5e: macsec: Maintain TX SA from encoding_sa Tariq Toukan
@ 2024-12-20 8:15 ` Tariq Toukan
2024-12-20 8:15 ` [PATCH net 4/4] net/mlx5e: Keep netdev when leave switchdev for devlink set legacy only Tariq Toukan
2024-12-23 19:10 ` [PATCH net 0/4] mlx5 misc fixes 2024-12-20 patchwork-bot+netdevbpf
4 siblings, 0 replies; 9+ messages in thread
From: Tariq Toukan @ 2024-12-20 8:15 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet,
Andrew Lunn
Cc: netdev, Saeed Mahameed, Gal Pressman, Leon Romanovsky, Mark Bloch,
Jianbo Liu, Tariq Toukan
From: Jianbo Liu <jianbol@nvidia.com>
During driver unload, unregister_netdev is called after unloading
vport rep. So, the mlx5e_rep_priv is already freed while trying to get
rpriv->netdev, or walk rpriv->tc_ht, which results in use-after-free.
So add the checking to make sure access the data of vport rep which is
still loaded.
Fixes: d1569537a837 ("net/mlx5e: Modify and restore TC rules for IPSec TX rules")
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c | 6 +++---
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 3 +++
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 3 ---
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c
index 5a0047bdcb51..ed977ae75fab 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c
@@ -150,11 +150,11 @@ void mlx5_esw_ipsec_restore_dest_uplink(struct mlx5_core_dev *mdev)
unsigned long i;
int err;
- xa_for_each(&esw->offloads.vport_reps, i, rep) {
- rpriv = rep->rep_data[REP_ETH].priv;
- if (!rpriv || !rpriv->netdev)
+ mlx5_esw_for_each_rep(esw, i, rep) {
+ if (atomic_read(&rep->rep_data[REP_ETH].state) != REP_LOADED)
continue;
+ rpriv = rep->rep_data[REP_ETH].priv;
rhashtable_walk_enter(&rpriv->tc_ht, &iter);
rhashtable_walk_start(&iter);
while ((flow = rhashtable_walk_next(&iter)) != NULL) {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index a83d41121db6..8573d36785f4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -714,6 +714,9 @@ void mlx5e_tc_clean_fdb_peer_flows(struct mlx5_eswitch *esw);
MLX5_CAP_GEN_2((esw->dev), ec_vf_vport_base) +\
(last) - 1)
+#define mlx5_esw_for_each_rep(esw, i, rep) \
+ xa_for_each(&((esw)->offloads.vport_reps), i, rep)
+
struct mlx5_eswitch *__must_check
mlx5_devlink_eswitch_get(struct devlink *devlink);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index d5b42b3a19fd..40359f320724 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -53,9 +53,6 @@
#include "lag/lag.h"
#include "en/tc/post_meter.h"
-#define mlx5_esw_for_each_rep(esw, i, rep) \
- xa_for_each(&((esw)->offloads.vport_reps), i, rep)
-
/* There are two match-all miss flows, one for unicast dst mac and
* one for multicast.
*/
--
2.45.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net 4/4] net/mlx5e: Keep netdev when leave switchdev for devlink set legacy only
2024-12-20 8:15 [PATCH net 0/4] mlx5 misc fixes 2024-12-20 Tariq Toukan
` (2 preceding siblings ...)
2024-12-20 8:15 ` [PATCH net 3/4] net/mlx5e: Skip restore TC rules for vport rep without loaded flag Tariq Toukan
@ 2024-12-20 8:15 ` Tariq Toukan
2024-12-20 8:48 ` Przemek Kitszel
2024-12-23 19:10 ` [PATCH net 0/4] mlx5 misc fixes 2024-12-20 patchwork-bot+netdevbpf
4 siblings, 1 reply; 9+ messages in thread
From: Tariq Toukan @ 2024-12-20 8:15 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet,
Andrew Lunn
Cc: netdev, Saeed Mahameed, Gal Pressman, Leon Romanovsky, Mark Bloch,
Jianbo Liu, Tariq Toukan
From: Jianbo Liu <jianbol@nvidia.com>
In the cited commit, when changing from switchdev to legacy mode,
uplink representor's netdev is kept, and its profile is replaced with
nic profile, so netdev is detached from old profile, then attach to
new profile.
During profile change, the hardware resources allocated by the old
profile will be cleaned up. However, the cleanup is relying on the
related kernel modules. And they may need to flush themselves first,
which is triggered by netdev events, for example, NETDEV_UNREGISTER.
However, netdev is kept, or netdev_register is called after the
cleanup, which may cause troubles because the resources are still
referred by kernel modules.
The same process applies to all the caes when uplink is leaving
switchdev mode, including devlink eswitch mode set legacy, driver
unload and devlink reload. For the first one, it can be blocked and
returns failure to users, whenever possible. But it's hard for the
others. Besides, the attachment to nic profile is unnecessary as the
netdev will be unregistered anyway for such cases.
So in this patch, the original behavior is kept only for devlink
eswitch set mode legacy. For the others, moves netdev unregistration
before the profile change.
Fixes: 7a9fb35e8c3a ("net/mlx5e: Do not reload ethernet ports when changing eswitch mode")
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/en_main.c | 19 +++++++++++++++++--
.../net/ethernet/mellanox/mlx5/core/en_rep.c | 15 +++++++++++++++
.../mellanox/mlx5/core/eswitch_offloads.c | 2 ++
include/linux/mlx5/driver.h | 1 +
4 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index dd16d73000c3..0ec17c276bdd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -6542,8 +6542,23 @@ static void _mlx5e_remove(struct auxiliary_device *adev)
mlx5_core_uplink_netdev_set(mdev, NULL);
mlx5e_dcbnl_delete_app(priv);
- unregister_netdev(priv->netdev);
- _mlx5e_suspend(adev, false);
+ /* When unload driver, the netdev is in registered state
+ * if it's from legacy mode. If from switchdev mode, it
+ * is already unregistered before changing to NIC profile.
+ */
+ if (priv->netdev->reg_state == NETREG_REGISTERED) {
+ unregister_netdev(priv->netdev);
+ _mlx5e_suspend(adev, false);
+ } else {
+ struct mlx5_core_dev *pos;
+ int i;
+
+ if (test_bit(MLX5E_STATE_DESTROYING, &priv->state))
+ mlx5_sd_for_each_dev(i, mdev, pos)
+ mlx5e_destroy_mdev_resources(pos);
+ else
+ _mlx5e_suspend(adev, true);
+ }
/* Avoid cleanup if profile rollback failed. */
if (priv->profile)
priv->profile->cleanup(priv);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 554f9cb5b53f..fdff9fd8a89e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -1509,6 +1509,21 @@ mlx5e_vport_uplink_rep_unload(struct mlx5e_rep_priv *rpriv)
priv = netdev_priv(netdev);
+ /* This bit is set when using devlink to change eswitch mode from
+ * switchdev to legacy. As need to keep uplink netdev ifindex, we
+ * detach uplink representor profile and attach NIC profile only.
+ * The netdev will be unregistered later when unload NIC auxiliary
+ * driver for this case.
+ * We explicitly block devlink eswitch mode change if any IPSec rules
+ * offloaded, but can't block other cases, such as driver unload
+ * and devlink reload. We have to unregister netdev before profile
+ * change for those cases. This is to avoid resource leak because
+ * the offloaded rules don't have the chance to be unoffloaded before
+ * cleanup which is triggered by detach uplink representor profile.
+ */
+ if (!(priv->mdev->priv.flags & MLX5_PRIV_FLAGS_SWITCH_LEGACY))
+ unregister_netdev(netdev);
+
mlx5e_netdev_attach_nic_profile(priv);
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 40359f320724..06076dd9ec64 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -3777,6 +3777,8 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
esw->eswitch_operation_in_progress = true;
up_write(&esw->mode_lock);
+ if (mode == DEVLINK_ESWITCH_MODE_LEGACY)
+ esw->dev->priv.flags |= MLX5_PRIV_FLAGS_SWITCH_LEGACY;
mlx5_eswitch_disable_locked(esw);
if (mode == DEVLINK_ESWITCH_MODE_SWITCHDEV) {
if (mlx5_devlink_trap_get_num_active(esw->dev)) {
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index fc7e6153b73d..8f5991168ccd 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -524,6 +524,7 @@ enum {
* creation/deletion on drivers rescan. Unset during device attach.
*/
MLX5_PRIV_FLAGS_DETACH = 1 << 2,
+ MLX5_PRIV_FLAGS_SWITCH_LEGACY = 1 << 3,
};
struct mlx5_adev {
--
2.45.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net 4/4] net/mlx5e: Keep netdev when leave switchdev for devlink set legacy only
2024-12-20 8:15 ` [PATCH net 4/4] net/mlx5e: Keep netdev when leave switchdev for devlink set legacy only Tariq Toukan
@ 2024-12-20 8:48 ` Przemek Kitszel
2024-12-20 14:46 ` Jakub Kicinski
0 siblings, 1 reply; 9+ messages in thread
From: Przemek Kitszel @ 2024-12-20 8:48 UTC (permalink / raw)
To: Tariq Toukan, Jianbo Liu
Cc: netdev, Saeed Mahameed, Gal Pressman, Leon Romanovsky, Mark Bloch,
David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet,
Andrew Lunn
On 12/20/24 09:15, Tariq Toukan wrote:
> From: Jianbo Liu <jianbol@nvidia.com>
>
> In the cited commit, when changing from switchdev to legacy mode,
> uplink representor's netdev is kept, and its profile is replaced with
> nic profile, so netdev is detached from old profile, then attach to
> new profile.
>
> During profile change, the hardware resources allocated by the old
> profile will be cleaned up. However, the cleanup is relying on the
> related kernel modules. And they may need to flush themselves first,
> which is triggered by netdev events, for example, NETDEV_UNREGISTER.
> However, netdev is kept, or netdev_register is called after the
> cleanup, which may cause troubles because the resources are still
> referred by kernel modules.
>
> The same process applies to all the caes when uplink is leaving
case
> switchdev mode, including devlink eswitch mode set legacy, driver
> unload and devlink reload. For the first one, it can be blocked and
> returns failure to users, whenever possible. But it's hard for the
> others. Besides, the attachment to nic profile is unnecessary as the
> netdev will be unregistered anyway for such cases.
>
> So in this patch, the original behavior is kept only for devlink
> eswitch set mode legacy. For the others, moves netdev unregistration
> before the profile change.
>
> Fixes: 7a9fb35e8c3a ("net/mlx5e: Do not reload ethernet ports when changing eswitch mode")
> Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> ---
> .../net/ethernet/mellanox/mlx5/core/en_main.c | 19 +++++++++++++++++--
> .../net/ethernet/mellanox/mlx5/core/en_rep.c | 15 +++++++++++++++
> .../mellanox/mlx5/core/eswitch_offloads.c | 2 ++
> include/linux/mlx5/driver.h | 1 +
> 4 files changed, 35 insertions(+), 2 deletions(-)
>
sorry for nitpick-only review
I didn't spotted anything bad in the logic through the series OTOH
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index dd16d73000c3..0ec17c276bdd 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> @@ -6542,8 +6542,23 @@ static void _mlx5e_remove(struct auxiliary_device *adev)
>
> mlx5_core_uplink_netdev_set(mdev, NULL);
> mlx5e_dcbnl_delete_app(priv);
> - unregister_netdev(priv->netdev);
> - _mlx5e_suspend(adev, false);
> + /* When unload driver, the netdev is in registered state
/*
* Netdev dropped the special comment allowance rule,
* now you have to put one line almost blank at the front.
*/
> + * if it's from legacy mode. If from switchdev mode, it
> + * is already unregistered before changing to NIC profile.
> + */
> + if (priv->netdev->reg_state == NETREG_REGISTERED) {
> + unregister_netdev(priv->netdev);
> + _mlx5e_suspend(adev, false);
> + } else {
> + struct mlx5_core_dev *pos;
> + int i;
> +
> + if (test_bit(MLX5E_STATE_DESTROYING, &priv->state))
you have more than one statement/expression inside the if,
so you must wrap with braces
> + mlx5_sd_for_each_dev(i, mdev, pos)
> + mlx5e_destroy_mdev_resources(pos);
> + else
> + _mlx5e_suspend(adev, true);
> + }
> /* Avoid cleanup if profile rollback failed. */
> if (priv->profile)
> priv->profile->cleanup(priv);
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net 4/4] net/mlx5e: Keep netdev when leave switchdev for devlink set legacy only
2024-12-20 8:48 ` Przemek Kitszel
@ 2024-12-20 14:46 ` Jakub Kicinski
2024-12-20 15:10 ` Przemek Kitszel
0 siblings, 1 reply; 9+ messages in thread
From: Jakub Kicinski @ 2024-12-20 14:46 UTC (permalink / raw)
To: Przemek Kitszel
Cc: Tariq Toukan, Jianbo Liu, netdev, Saeed Mahameed, Gal Pressman,
Leon Romanovsky, Mark Bloch, David S. Miller, Paolo Abeni,
Eric Dumazet, Andrew Lunn
On Fri, 20 Dec 2024 09:48:11 +0100 Przemek Kitszel wrote:
> > mlx5_core_uplink_netdev_set(mdev, NULL);
> > mlx5e_dcbnl_delete_app(priv);
> > - unregister_netdev(priv->netdev);
> > - _mlx5e_suspend(adev, false);
> > + /* When unload driver, the netdev is in registered state
>
> /*
> * Netdev dropped the special comment allowance rule,
> * now you have to put one line almost blank at the front.
> */
Incorrect, we still prefer the old comment style, we just give a pass
now to people who have a strong preference the opposite way.
> > + * if it's from legacy mode. If from switchdev mode, it
> > + * is already unregistered before changing to NIC profile.
> > + */
> > + if (priv->netdev->reg_state == NETREG_REGISTERED) {
> > + unregister_netdev(priv->netdev);
> > + _mlx5e_suspend(adev, false);
> > + } else {
> > + struct mlx5_core_dev *pos;
> > + int i;
> > +
> > + if (test_bit(MLX5E_STATE_DESTROYING, &priv->state))
>
> you have more than one statement/expression inside the if,
> so you must wrap with braces
I'm not aware of that as a hard rule either.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net 4/4] net/mlx5e: Keep netdev when leave switchdev for devlink set legacy only
2024-12-20 14:46 ` Jakub Kicinski
@ 2024-12-20 15:10 ` Przemek Kitszel
0 siblings, 0 replies; 9+ messages in thread
From: Przemek Kitszel @ 2024-12-20 15:10 UTC (permalink / raw)
To: Jakub Kicinski, Alexander Lobakin
Cc: Tariq Toukan, Jianbo Liu, netdev, Saeed Mahameed, Gal Pressman,
Leon Romanovsky, Mark Bloch, David S. Miller, Paolo Abeni,
Eric Dumazet, Andrew Lunn, ITP Upstream
On 12/20/24 15:46, Jakub Kicinski wrote:
> On Fri, 20 Dec 2024 09:48:11 +0100 Przemek Kitszel wrote:
>>> mlx5_core_uplink_netdev_set(mdev, NULL);
>>> mlx5e_dcbnl_delete_app(priv);
>>> - unregister_netdev(priv->netdev);
>>> - _mlx5e_suspend(adev, false);
>>> + /* When unload driver, the netdev is in registered state
>>
>> /*
>> * Netdev dropped the special comment allowance rule,
>> * now you have to put one line almost blank at the front.
>> */
>
> Incorrect, we still prefer the old comment style, we just give a pass
> now to people who have a strong preference the opposite way.
good to know, I will pass it down to my folks
>
>>> + * if it's from legacy mode. If from switchdev mode, it
>>> + * is already unregistered before changing to NIC profile.
>>> + */
>>> + if (priv->netdev->reg_state == NETREG_REGISTERED) {
>>> + unregister_netdev(priv->netdev);
>>> + _mlx5e_suspend(adev, false);
>>> + } else {
>>> + struct mlx5_core_dev *pos;
>>> + int i;
>>> +
>>> + if (test_bit(MLX5E_STATE_DESTROYING, &priv->state))
>>
>> you have more than one statement/expression inside the if,
>> so you must wrap with braces
>
> I'm not aware of that as a hard rule either.
[1] says
"Also, use braces when a loop contains more than a single simple statement:"
And I see that here we have and if() instead of a loop, but I believe
that the intent of "the rule" (not sure how hard) was to pet the brace
in such cases.
To be clear, I don't want to stop an otherwise good PR just for this!
[1]
https://www.kernel.org/doc/html/latest/process/coding-style.html#placing-braces-and-spaces
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net 0/4] mlx5 misc fixes 2024-12-20
2024-12-20 8:15 [PATCH net 0/4] mlx5 misc fixes 2024-12-20 Tariq Toukan
` (3 preceding siblings ...)
2024-12-20 8:15 ` [PATCH net 4/4] net/mlx5e: Keep netdev when leave switchdev for devlink set legacy only Tariq Toukan
@ 2024-12-23 19:10 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 9+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-12-23 19:10 UTC (permalink / raw)
To: Tariq Toukan
Cc: davem, kuba, pabeni, edumazet, andrew+netdev, netdev, saeedm, gal,
leonro, mbloch
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 20 Dec 2024 10:15:01 +0200 you wrote:
> Hi,
>
> This small patchset provides misc bug fixes from the team to the mlx5
> core and Eth drivers.
>
> Thanks,
> Tariq.
>
> [...]
Here is the summary with links:
- [net,1/4] net/mlx5: DR, select MSIX vector 0 for completion queue creation
https://git.kernel.org/netdev/net/c/050a4c011b0d
- [net,2/4] net/mlx5e: macsec: Maintain TX SA from encoding_sa
https://git.kernel.org/netdev/net/c/8c6254479b3d
- [net,3/4] net/mlx5e: Skip restore TC rules for vport rep without loaded flag
https://git.kernel.org/netdev/net/c/5a03b368562a
- [net,4/4] net/mlx5e: Keep netdev when leave switchdev for devlink set legacy only
https://git.kernel.org/netdev/net/c/2a4f56fbcc47
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-12-23 19:10 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-20 8:15 [PATCH net 0/4] mlx5 misc fixes 2024-12-20 Tariq Toukan
2024-12-20 8:15 ` [PATCH net 1/4] net/mlx5: DR, select MSIX vector 0 for completion queue creation Tariq Toukan
2024-12-20 8:15 ` [PATCH net 2/4] net/mlx5e: macsec: Maintain TX SA from encoding_sa Tariq Toukan
2024-12-20 8:15 ` [PATCH net 3/4] net/mlx5e: Skip restore TC rules for vport rep without loaded flag Tariq Toukan
2024-12-20 8:15 ` [PATCH net 4/4] net/mlx5e: Keep netdev when leave switchdev for devlink set legacy only Tariq Toukan
2024-12-20 8:48 ` Przemek Kitszel
2024-12-20 14:46 ` Jakub Kicinski
2024-12-20 15:10 ` Przemek Kitszel
2024-12-23 19:10 ` [PATCH net 0/4] mlx5 misc fixes 2024-12-20 patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).