From: Ido Schimmel <idosch@mellanox.com>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
Jiri Pirko <jiri@mellanox.com>, mlxsw <mlxsw@mellanox.com>,
Michael Chan <michael.chan@broadcom.com>,
Tariq Toukan <tariqt@mellanox.com>,
Ido Schimmel <idosch@mellanox.com>
Subject: [PATCH net-next 01/14] devlink: publish params only after driver init is done
Date: Thu, 7 Feb 2019 11:22:45 +0000 [thread overview]
Message-ID: <20190207112211.10375-2-idosch@mellanox.com> (raw)
In-Reply-To: <20190207112211.10375-1-idosch@mellanox.com>
From: Jiri Pirko <jiri@mellanox.com>
Currently, user can do dump or get of param values right after the
devlink params are registered. However the driver may not be initialized
which is an issue. The same problem happens during notification
upon param registration. Allow driver to publish devlink params
whenever it is ready to handle get() ops. Note that this cannot
be resolved by init reordering, as the "driverinit" params have
to be available before the driver is initialized (it needs the param
values there).
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Cc: Michael Chan <michael.chan@broadcom.com>
Cc: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
.../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 3 ++
drivers/net/ethernet/mellanox/mlx4/main.c | 1 +
drivers/net/ethernet/mellanox/mlxsw/core.c | 5 ++
include/net/devlink.h | 11 +++++
net/core/devlink.c | 48 ++++++++++++++++++-
5 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
index a6abfa4fb168..2955e404fd18 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
@@ -258,6 +258,9 @@ int bnxt_dl_register(struct bnxt *bp)
netdev_err(bp->dev, "devlink_port_params_register failed");
goto err_dl_port_unreg;
}
+
+ devlink_params_publish(dl);
+
return 0;
err_dl_port_unreg:
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index bdb8dd161923..1f6e16d5ea6b 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -3981,6 +3981,7 @@ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
if (ret)
goto err_params_unregister;
+ devlink_params_publish(devlink);
pci_save_state(pdev);
return 0;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index 4f6fa515394e..b505d3858235 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -1062,6 +1062,9 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
goto err_driver_init;
}
+ if (mlxsw_driver->params_register && !reload)
+ devlink_params_publish(devlink);
+
return 0;
err_driver_init:
@@ -1131,6 +1134,8 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
return;
}
+ if (mlxsw_core->driver->params_unregister && !reload)
+ devlink_params_unpublish(devlink);
if (mlxsw_core->driver->fini)
mlxsw_core->driver->fini(mlxsw_core);
mlxsw_thermal_fini(mlxsw_core->thermal);
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 74d992a68a06..ce66e92b559f 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -357,6 +357,7 @@ struct devlink_param_item {
const struct devlink_param *param;
union devlink_param_value driverinit_value;
bool driverinit_value_valid;
+ bool published;
};
enum devlink_param_generic_id {
@@ -594,6 +595,8 @@ int devlink_params_register(struct devlink *devlink,
void devlink_params_unregister(struct devlink *devlink,
const struct devlink_param *params,
size_t params_count);
+void devlink_params_publish(struct devlink *devlink);
+void devlink_params_unpublish(struct devlink *devlink);
int devlink_port_params_register(struct devlink_port *devlink_port,
const struct devlink_param *params,
size_t params_count);
@@ -656,6 +659,14 @@ static inline void devlink_unregister(struct devlink *devlink)
{
}
+static inline void devlink_params_publish(struct devlink *devlink)
+{
+}
+
+static inline void devlink_params_unpublish(struct devlink *devlink)
+{
+}
+
static inline void devlink_free(struct devlink *devlink)
{
kfree(devlink);
diff --git a/net/core/devlink.c b/net/core/devlink.c
index cd0d393bc62d..08775cda11f8 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -2858,6 +2858,7 @@ static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink,
u32 portid, u32 seq, int flags)
{
union devlink_param_value param_value[DEVLINK_PARAM_CMODE_MAX + 1];
+ bool param_value_set[DEVLINK_PARAM_CMODE_MAX + 1] = {};
const struct devlink_param *param = param_item->param;
struct devlink_param_gset_ctx ctx;
struct nlattr *param_values_list;
@@ -2876,12 +2877,15 @@ static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink,
return -EOPNOTSUPP;
param_value[i] = param_item->driverinit_value;
} else {
+ if (!param_item->published)
+ continue;
ctx.cmode = i;
err = devlink_param_get(devlink, param, &ctx);
if (err)
return err;
param_value[i] = ctx.val;
}
+ param_value_set[i] = true;
}
hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd);
@@ -2916,7 +2920,7 @@ static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink,
goto param_nest_cancel;
for (i = 0; i <= DEVLINK_PARAM_CMODE_MAX; i++) {
- if (!devlink_param_cmode_is_supported(param, i))
+ if (!param_value_set[i])
continue;
err = devlink_nl_param_value_fill_one(msg, param->type,
i, param_value[i]);
@@ -4878,6 +4882,48 @@ void devlink_params_unregister(struct devlink *devlink,
}
EXPORT_SYMBOL_GPL(devlink_params_unregister);
+/**
+ * devlink_params_publish - publish configuration parameters
+ *
+ * @devlink: devlink
+ *
+ * Publish previously registered configuration parameters.
+ */
+void devlink_params_publish(struct devlink *devlink)
+{
+ struct devlink_param_item *param_item;
+
+ list_for_each_entry(param_item, &devlink->param_list, list) {
+ if (param_item->published)
+ continue;
+ param_item->published = true;
+ devlink_param_notify(devlink, 0, param_item,
+ DEVLINK_CMD_PARAM_NEW);
+ }
+}
+EXPORT_SYMBOL_GPL(devlink_params_publish);
+
+/**
+ * devlink_params_unpublish - unpublish configuration parameters
+ *
+ * @devlink: devlink
+ *
+ * Unpublish previously registered configuration parameters.
+ */
+void devlink_params_unpublish(struct devlink *devlink)
+{
+ struct devlink_param_item *param_item;
+
+ list_for_each_entry(param_item, &devlink->param_list, list) {
+ if (!param_item->published)
+ continue;
+ param_item->published = false;
+ devlink_param_notify(devlink, 0, param_item,
+ DEVLINK_CMD_PARAM_DEL);
+ }
+}
+EXPORT_SYMBOL_GPL(devlink_params_unpublish);
+
/**
* devlink_port_params_register - register port configuration parameters
*
--
2.20.1
next prev parent reply other threads:[~2019-02-07 11:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-07 11:22 [PATCH net-next 00/14] mlxsw: Implement periodic ERP rehash Ido Schimmel
2019-02-07 11:22 ` Ido Schimmel [this message]
2019-02-07 11:22 ` [PATCH net-next 03/14] lib: objagg: fix typo in objagg_stats_put() docstring Ido Schimmel
2019-02-07 11:22 ` [PATCH net-next 02/14] lib: objagg: implement optimization hints assembly and use hints for object creation Ido Schimmel
2019-02-07 11:22 ` [PATCH net-next 04/14] lib: objagg: add root count to stats Ido Schimmel
2019-02-07 11:22 ` [PATCH net-next 05/14] mlxsw: spectrum_acl: Split region struct into region and vregion Ido Schimmel
2019-02-07 11:22 ` [PATCH net-next 06/14] mlxsw: spectrum_acl: Split chunk struct into chunk and vchunk Ido Schimmel
2019-02-07 11:22 ` [PATCH net-next 07/14] mlxsw: spectrum_acl: Split entry struct into entry and ventry Ido Schimmel
2019-02-07 11:22 ` [PATCH net-next 08/14] mlxsw: spectrum_acl: Implement basic ERP rehash hits creation Ido Schimmel
2019-02-07 11:22 ` [PATCH net-next 09/14] mlxsw: spectrum_acl: Pass hints priv all the way to ERP code Ido Schimmel
2019-02-07 11:22 ` [PATCH net-next 10/14] mlxsw: reg: Add multi field to PAGT register Ido Schimmel
2019-02-07 11:22 ` [PATCH net-next 11/14] mlxsw: spectrum_acl: Implement region migration according to hints Ido Schimmel
2019-02-07 11:22 ` [PATCH net-next 13/14] mlxsw: spectrum_acl: Add couple of vregion rehash tracepoints Ido Schimmel
2019-02-07 11:22 ` [PATCH net-next 12/14] mlxsw: spectrum: add "acl_region_rehash_interval" devlink param Ido Schimmel
2019-02-07 11:22 ` [PATCH net-next 14/14] selftests: mlxsw: spectrum-2: Add simple delta rehash test Ido Schimmel
2019-02-08 23:03 ` [PATCH net-next 00/14] mlxsw: Implement periodic ERP rehash David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190207112211.10375-2-idosch@mellanox.com \
--to=idosch@mellanox.com \
--cc=davem@davemloft.net \
--cc=jiri@mellanox.com \
--cc=michael.chan@broadcom.com \
--cc=mlxsw@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=tariqt@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox