From: Shannon Nelson <shannon.nelson@amd.com>
To: <shannon.nelson@amd.com>, <brett.creeley@amd.com>,
<davem@davemloft.net>, <netdev@vger.kernel.org>,
<kuba@kernel.org>
Cc: <drivers@pensando.io>, <leon@kernel.org>, <jiri@resnulli.us>
Subject: [PATCH v6 net-next 11/14] pds_core: devlink params for enabling VIF support
Date: Fri, 24 Mar 2023 12:02:40 -0700 [thread overview]
Message-ID: <20230324190243.27722-12-shannon.nelson@amd.com> (raw)
In-Reply-To: <20230324190243.27722-1-shannon.nelson@amd.com>
Add the devlink parameter switches so the user can enable
the features supported by the VFs.
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
drivers/net/ethernet/amd/pds_core/devlink.c | 90 ++++++++++++++++++++-
1 file changed, 89 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/amd/pds_core/devlink.c b/drivers/net/ethernet/amd/pds_core/devlink.c
index 17464b063009..45ab7e2e6528 100644
--- a/drivers/net/ethernet/amd/pds_core/devlink.c
+++ b/drivers/net/ethernet/amd/pds_core/devlink.c
@@ -7,6 +7,87 @@
#include <linux/pci.h>
#include "core.h"
+#include <linux/pds/pds_auxbus.h>
+
+static struct
+pdsc_viftype *pdsc_dl_find_viftype_by_id(struct pdsc *pdsc,
+ enum devlink_param_type dl_id)
+{
+ int vt;
+
+ for (vt = 0; vt < PDS_DEV_TYPE_MAX; vt++) {
+ if (pdsc->viftype_status[vt].dl_id == dl_id)
+ return &pdsc->viftype_status[vt];
+ }
+
+ return NULL;
+}
+
+static int pdsc_dl_enable_get(struct devlink *dl, u32 id,
+ struct devlink_param_gset_ctx *ctx)
+{
+ struct pdsc *pdsc = devlink_priv(dl);
+ struct pdsc_viftype *vt_entry;
+
+ vt_entry = pdsc_dl_find_viftype_by_id(pdsc, id);
+ if (!vt_entry)
+ return -ENOENT;
+
+ ctx->val.vbool = vt_entry->enabled;
+
+ return 0;
+}
+
+static int pdsc_dl_enable_set(struct devlink *dl, u32 id,
+ struct devlink_param_gset_ctx *ctx)
+{
+ struct pdsc *pdsc = devlink_priv(dl);
+ struct pdsc_viftype *vt_entry;
+ int err = 0;
+ int vf_id;
+
+ vt_entry = pdsc_dl_find_viftype_by_id(pdsc, id);
+ if (!vt_entry || !vt_entry->supported)
+ return -EOPNOTSUPP;
+
+ if (vt_entry->enabled == ctx->val.vbool)
+ return 0;
+
+ vt_entry->enabled = ctx->val.vbool;
+ for (vf_id = 0; vf_id < pdsc->num_vfs; vf_id++) {
+ struct pdsc *vf = pdsc->vfs[vf_id].vf;
+
+ err = ctx->val.vbool ? pdsc_auxbus_dev_add_vf(vf, pdsc) :
+ pdsc_auxbus_dev_del_vf(vf, pdsc);
+ }
+
+ return err;
+}
+
+static int pdsc_dl_enable_validate(struct devlink *dl, u32 id,
+ union devlink_param_value val,
+ struct netlink_ext_ack *extack)
+{
+ struct pdsc *pdsc = devlink_priv(dl);
+ struct pdsc_viftype *vt_entry;
+
+ vt_entry = pdsc_dl_find_viftype_by_id(pdsc, id);
+ if (!vt_entry || !vt_entry->supported)
+ return -EOPNOTSUPP;
+
+ if (!pdsc->viftype_status[vt_entry->vif_id].supported)
+ return -ENODEV;
+
+ return 0;
+}
+
+static const struct devlink_param pdsc_dl_params[] = {
+ DEVLINK_PARAM_GENERIC(ENABLE_VNET,
+ BIT(DEVLINK_PARAM_CMODE_RUNTIME),
+ pdsc_dl_enable_get,
+ pdsc_dl_enable_set,
+ pdsc_dl_enable_validate),
+};
static int pdsc_dl_flash_update(struct devlink *dl,
struct devlink_flash_update_params *params,
@@ -162,9 +243,16 @@ void pdsc_dl_free(struct pdsc *pdsc)
int pdsc_dl_register(struct pdsc *pdsc)
{
struct devlink *dl = priv_to_devlink(pdsc);
+ int err;
+
+ if (!pdsc->pdev->is_virtfn) {
+ err = devlink_params_register(dl, pdsc_dl_params,
+ ARRAY_SIZE(pdsc_dl_params));
+ if (err)
+ return err;
- if (!pdsc->pdev->is_virtfn)
pdsc_dl_reporters_create(pdsc);
+ }
devlink_register(dl);
--
2.17.1
next prev parent reply other threads:[~2023-03-24 19:03 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-24 19:02 [PATCH v6 net-next 00/14] pds_core driver Shannon Nelson
2023-03-24 19:02 ` [PATCH v6 net-next 01/14] pds_core: initial framework for pds_core PF driver Shannon Nelson
2023-03-25 23:39 ` Jakub Kicinski
2023-03-26 4:07 ` Shannon Nelson
2023-03-28 0:43 ` Jakub Kicinski
2023-03-28 6:19 ` Shannon Nelson
2023-03-28 22:17 ` Jakub Kicinski
2023-03-29 20:53 ` Shannon Nelson
2023-03-30 2:27 ` Jakub Kicinski
2023-03-30 7:02 ` Leon Romanovsky
2023-03-30 7:43 ` Shannon Nelson
2023-03-30 16:46 ` Jakub Kicinski
2023-03-24 19:02 ` [PATCH v6 net-next 02/14] pds_core: add devcmd device interfaces Shannon Nelson
2023-03-24 19:02 ` [PATCH v6 net-next 03/14] pds_core: health timer and workqueue Shannon Nelson
2023-03-24 19:02 ` [PATCH v6 net-next 04/14] pds_core: add devlink health facilities Shannon Nelson
2023-03-24 19:02 ` [PATCH v6 net-next 05/14] pds_core: set up device and adminq Shannon Nelson
2023-03-24 19:02 ` [PATCH v6 net-next 06/14] pds_core: Add adminq processing and commands Shannon Nelson
2023-03-24 19:02 ` [PATCH v6 net-next 07/14] pds_core: add FW update feature to devlink Shannon Nelson
2023-03-24 19:02 ` [PATCH v6 net-next 08/14] pds_core: set up the VIF definitions and defaults Shannon Nelson
2023-03-24 19:02 ` [PATCH v6 net-next 09/14] pds_core: add initial VF device handling Shannon Nelson
2023-03-24 19:02 ` [PATCH v6 net-next 10/14] pds_core: add auxiliary_bus devices Shannon Nelson
2023-03-24 19:02 ` Shannon Nelson [this message]
2023-03-24 19:02 ` [PATCH v6 net-next 12/14] pds_core: add the aux client API Shannon Nelson
2023-03-24 19:02 ` [PATCH v6 net-next 13/14] pds_core: publish events to the clients Shannon Nelson
2023-03-24 19:02 ` [PATCH v6 net-next 14/14] pds_core: Kconfig and pds_core.rst Shannon Nelson
2023-03-25 20:40 ` kernel test robot
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=20230324190243.27722-12-shannon.nelson@amd.com \
--to=shannon.nelson@amd.com \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=drivers@pensando.io \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).