]> git.baikalelectronics.ru Git - kernel.git/commitdiff
octeontx2-af: Fix devlink unregister
authorRatheesh Kannoth <rkannoth@marvell.com>
Tue, 31 Jan 2023 06:16:59 +0000 (11:46 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2023 10:28:09 +0000 (11:28 +0100)
[ Upstream commit 917d5e04d4dd2bbbf36fc6976ba442e284ccc42d ]

Exact match feature is only available in CN10K-B.
Unregister exact match devlink entry only for
this silicon variant.

Fixes: fa3a069f0a81 ("octeontx2-af: Debugsfs support for exact match.")
Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/20230131061659.1025137-1-rkannoth@marvell.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c

index 88dee589cb217c0d4b1245baf01cd662eaa048d5..dc7bd2ce78f7d04a0a97d12eb9d661901a3a45f0 100644 (file)
@@ -1500,6 +1500,9 @@ static const struct devlink_param rvu_af_dl_params[] = {
                             BIT(DEVLINK_PARAM_CMODE_RUNTIME),
                             rvu_af_dl_dwrr_mtu_get, rvu_af_dl_dwrr_mtu_set,
                             rvu_af_dl_dwrr_mtu_validate),
+};
+
+static const struct devlink_param rvu_af_dl_param_exact_match[] = {
        DEVLINK_PARAM_DRIVER(RVU_AF_DEVLINK_PARAM_ID_NPC_EXACT_FEATURE_DISABLE,
                             "npc_exact_feature_disable", DEVLINK_PARAM_TYPE_STRING,
                             BIT(DEVLINK_PARAM_CMODE_RUNTIME),
@@ -1563,7 +1566,6 @@ int rvu_register_dl(struct rvu *rvu)
 {
        struct rvu_devlink *rvu_dl;
        struct devlink *dl;
-       size_t size;
        int err;
 
        dl = devlink_alloc(&rvu_devlink_ops, sizeof(struct rvu_devlink),
@@ -1585,21 +1587,32 @@ int rvu_register_dl(struct rvu *rvu)
                goto err_dl_health;
        }
 
+       err = devlink_params_register(dl, rvu_af_dl_params, ARRAY_SIZE(rvu_af_dl_params));
+       if (err) {
+               dev_err(rvu->dev,
+                       "devlink params register failed with error %d", err);
+               goto err_dl_health;
+       }
+
        /* Register exact match devlink only for CN10K-B */
-       size = ARRAY_SIZE(rvu_af_dl_params);
        if (!rvu_npc_exact_has_match_table(rvu))
-               size -= 1;
+               goto done;
 
-       err = devlink_params_register(dl, rvu_af_dl_params, size);
+       err = devlink_params_register(dl, rvu_af_dl_param_exact_match,
+                                     ARRAY_SIZE(rvu_af_dl_param_exact_match));
        if (err) {
                dev_err(rvu->dev,
-                       "devlink params register failed with error %d", err);
-               goto err_dl_health;
+                       "devlink exact match params register failed with error %d", err);
+               goto err_dl_exact_match;
        }
 
+done:
        devlink_register(dl);
        return 0;
 
+err_dl_exact_match:
+       devlink_params_unregister(dl, rvu_af_dl_params, ARRAY_SIZE(rvu_af_dl_params));
+
 err_dl_health:
        rvu_health_reporters_destroy(rvu);
        devlink_free(dl);
@@ -1612,8 +1625,14 @@ void rvu_unregister_dl(struct rvu *rvu)
        struct devlink *dl = rvu_dl->dl;
 
        devlink_unregister(dl);
-       devlink_params_unregister(dl, rvu_af_dl_params,
-                                 ARRAY_SIZE(rvu_af_dl_params));
+
+       devlink_params_unregister(dl, rvu_af_dl_params, ARRAY_SIZE(rvu_af_dl_params));
+
+       /* Unregister exact match devlink only for CN10K-B */
+       if (rvu_npc_exact_has_match_table(rvu))
+               devlink_params_unregister(dl, rvu_af_dl_param_exact_match,
+                                         ARRAY_SIZE(rvu_af_dl_param_exact_match));
+
        rvu_health_reporters_destroy(rvu);
        devlink_free(dl);
 }