[PATCH v4 2/6] pds_core: add support for identity version 2
From: Nikhil P. Rao <hidden>
Date: 2026-06-14 05:01:22
Subsystem:
amd pds core driver, networking drivers, the rest · Maintainers:
Brett Creeley, Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds
From: Brett Creeley <brett.creeley@amd.com> Add a new capabilities field in struct pds_core_dev_identity, which requires bumping the identity version to 2, i.e. PDS_CORE_IDENTITY_VERSION_2. If version 2 negotiation fails, then quietly fall back to version 1. If version 1 negotiation fails, then driver load will fail. Another patch in the series will make use of the capabilities field. Signed-off-by: Brett Creeley <brett.creeley@amd.com> --- drivers/net/ethernet/amd/pds_core/dev.c | 39 ++++++++++++++++++++----- include/linux/pds/pds_core_if.h | 4 +++ 2 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/amd/pds_core/dev.c b/drivers/net/ethernet/amd/pds_core/dev.c
index dd9989cfe6b3..5c0ca3d0b000 100644
--- a/drivers/net/ethernet/amd/pds_core/dev.c
+++ b/drivers/net/ethernet/amd/pds_core/dev.c@@ -250,15 +250,17 @@ int pdsc_devcmd_reset(struct pdsc *pdsc) return pdsc_devcmd(pdsc, &cmd, &comp, pdsc->devcmd_timeout); } -static int pdsc_devcmd_identify_locked(struct pdsc *pdsc) +static int pdsc_devcmd_identify_locked(struct pdsc *pdsc, u8 drv_ident_ver, + bool do_msg) { union pds_core_dev_comp comp = {}; union pds_core_dev_cmd cmd = { .identify.opcode = PDS_CORE_CMD_IDENTIFY, - .identify.ver = PDS_CORE_IDENTITY_VERSION_1, + .identify.ver = drv_ident_ver, }; - return pdsc_devcmd_locked(pdsc, &cmd, &comp, pdsc->devcmd_timeout); + return __pdsc_devcmd_locked(pdsc, &cmd, &comp, pdsc->devcmd_timeout, + do_msg); } static void pdsc_init_devinfo(struct pdsc *pdsc)
@@ -281,8 +283,9 @@ static void pdsc_init_devinfo(struct pdsc *pdsc) dev_dbg(pdsc->dev, "fw_version %s\n", pdsc->dev_info.fw_version); } -static int pdsc_identify(struct pdsc *pdsc) +static int pdsc_identify_ver(struct pdsc *pdsc, u8 drv_ident_ver) { + bool do_msg = drv_ident_ver == PDS_CORE_IDENTITY_VERSION_1; struct pds_core_drv_identity drv = {}; size_t sz; int err;
@@ -305,17 +308,24 @@ static int pdsc_identify(struct pdsc *pdsc) sz = min_t(size_t, sizeof(drv), sizeof(pdsc->cmd_regs->data)); memcpy_toio(&pdsc->cmd_regs->data, &drv, sz); - err = pdsc_devcmd_identify_locked(pdsc); + err = pdsc_devcmd_identify_locked(pdsc, drv_ident_ver, do_msg); if (!err) { sz = min_t(size_t, sizeof(pdsc->dev_ident), sizeof(pdsc->cmd_regs->data)); memcpy_fromio(&pdsc->dev_ident, &pdsc->cmd_regs->data, sz); + + /* V1 firmware doesn't set capabilities, so the field may + * contain garbage from the outgoing driver identity. + */ + if (pdsc->dev_ident.version < PDS_CORE_IDENTITY_VERSION_2) + pdsc->dev_ident.capabilities = 0; } mutex_unlock(&pdsc->devcmd_lock); if (err) { - dev_err(pdsc->dev, "Cannot identify device: %pe\n", - ERR_PTR(err)); + if (do_msg) + dev_err(pdsc->dev, "Cannot identify device: %pe\n", + ERR_PTR(err)); return err; }
@@ -334,6 +344,21 @@ static int pdsc_identify(struct pdsc *pdsc) return 0; } +static int pdsc_identify(struct pdsc *pdsc) +{ + int err; + + /* Older firmware rejects anything but PDS_CORE_IDENTITY_VERSION_1 + * instead of returning the max supported identity version, so retry if + * firmware doesn't support PDS_CORE_IDENTITY_VERSION_2 + */ + err = pdsc_identify_ver(pdsc, PDS_CORE_IDENTITY_VERSION_2); + if (err) + err = pdsc_identify_ver(pdsc, PDS_CORE_IDENTITY_VERSION_1); + + return err; +} + void pdsc_dev_uninit(struct pdsc *pdsc) { if (pdsc->intr_info) {
diff --git a/include/linux/pds/pds_core_if.h b/include/linux/pds/pds_core_if.h
index 17a87c1a55d7..619186f26b5b 100644
--- a/include/linux/pds/pds_core_if.h
+++ b/include/linux/pds/pds_core_if.h@@ -119,6 +119,8 @@ struct pds_core_drv_identity { * value in usecs to device units using: * device units = usecs * mult / div * @vif_types: How many of each VIF device type is supported + * @capabilities: Device capabilities + * only supported on version >= PDS_CORE_IDENTITY_VERSION_2 */ struct pds_core_dev_identity { u8 version;
@@ -131,9 +133,11 @@ struct pds_core_dev_identity { __le32 intr_coal_mult; __le32 intr_coal_div; __le16 vif_types[PDS_DEV_TYPE_MAX]; + __le64 capabilities; }; #define PDS_CORE_IDENTITY_VERSION_1 1 +#define PDS_CORE_IDENTITY_VERSION_2 2 /** * struct pds_core_dev_identify_cmd - Driver/device identify command
--
2.43.0