* [dpdk-dev] [PATCH] net/nfp: read chip model from PluDevice register
@ 2021-01-25 15:25 Heinrich Kuhn
2021-01-29 11:35 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Kuhn @ 2021-01-25 15:25 UTC (permalink / raw)
To: dev; +Cc: Heinrich Kuhn, stable, Louis Peens, Simon Horman
For newer smartNIC NVRAM versions the chip model should be read from the
PluDevice register as it provides the authoritative chip model/revision.
This method of reading the chip model is backwards compatible with
legacy NVRAM versions too.
Since the model number is purely used for reporting purposes, follow the
hardware team convention of subtracting 0x10 from the PluDevice register
to obtain the chip model/revision number.
Fixes: c7e9729da ("net/nfp: support CPP")
Cc: stable@dpdk.org
Signed-off-by: Heinrich Kuhn <heinrich.kuhn@netronome.com>
Reviewed-by: Louis Peens <louis.peens@netronome.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
drivers/net/nfp/nfpcore/nfp_cpp.h | 2 +-
drivers/net/nfp/nfpcore/nfp_cppcore.c | 49 ++++++++++++---------------
2 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/drivers/net/nfp/nfpcore/nfp_cpp.h b/drivers/net/nfp/nfpcore/nfp_cpp.h
index 1427954c1..08d656da1 100644
--- a/drivers/net/nfp/nfpcore/nfp_cpp.h
+++ b/drivers/net/nfp/nfpcore/nfp_cpp.h
@@ -170,7 +170,7 @@ void *nfp_cpp_priv(struct nfp_cpp *cpp);
*/
void *nfp_cpp_area_priv(struct nfp_cpp_area *cpp_area);
-uint32_t __nfp_cpp_model_autodetect(struct nfp_cpp *cpp);
+uint32_t __nfp_cpp_model_autodetect(struct nfp_cpp *cpp, uint32_t *model);
/*
* NFP CPP core interface for CPP clients.
diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c
index dec4a8b6d..6d629430d 100644
--- a/drivers/net/nfp/nfpcore/nfp_cppcore.c
+++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c
@@ -22,8 +22,9 @@
#define NFP_PL_DEVICE_ID 0x00000004
#define NFP_PL_DEVICE_ID_MASK 0xff
-
-#define NFP6000_ARM_GCSR_SOFTMODEL0 0x00400144
+#define NFP_PL_DEVICE_PART_MASK 0xffff0000
+#define NFP_PL_DEVICE_MODEL_MASK (NFP_PL_DEVICE_PART_MASK | \
+ NFP_PL_DEVICE_ID_MASK)
void
nfp_cpp_priv_set(struct nfp_cpp *cpp, void *priv)
@@ -46,13 +47,18 @@ nfp_cpp_model_set(struct nfp_cpp *cpp, uint32_t model)
uint32_t
nfp_cpp_model(struct nfp_cpp *cpp)
{
+ int err;
+ uint32_t model;
+
if (!cpp)
return NFP_CPP_MODEL_INVALID;
- if (cpp->model == 0)
- cpp->model = __nfp_cpp_model_autodetect(cpp);
+ err = __nfp_cpp_model_autodetect(cpp, &model);
- return cpp->model;
+ if (err < 0)
+ return err;
+
+ return model;
}
void
@@ -389,9 +395,6 @@ nfp_xpb_to_cpp(struct nfp_cpp *cpp, uint32_t *xpb_addr)
uint32_t xpb;
int island;
- if (!NFP_CPP_MODEL_IS_6000(cpp->model))
- return 0;
-
xpb = NFP_CPP_ID(14, NFP_CPP_ACTION_RW, 0);
/*
@@ -796,29 +799,21 @@ nfp_cpp_area_fill(struct nfp_cpp_area *area, unsigned long offset,
* as those are model-specific
*/
uint32_t
-__nfp_cpp_model_autodetect(struct nfp_cpp *cpp)
+__nfp_cpp_model_autodetect(struct nfp_cpp *cpp, uint32_t *model)
{
- uint32_t arm_id = NFP_CPP_ID(NFP_CPP_TARGET_ARM, 0, 0);
- uint32_t model = 0;
-
- if (nfp_cpp_readl(cpp, arm_id, NFP6000_ARM_GCSR_SOFTMODEL0, &model))
- return 0;
-
- if (NFP_CPP_MODEL_IS_6000(model)) {
- uint32_t tmp;
-
- nfp_cpp_model_set(cpp, model);
+ uint32_t reg;
+ int err;
- /* The PL's PluDeviceID revision code is authoratative */
- model &= ~0xff;
- if (nfp_xpb_readl(cpp, NFP_XPB_DEVICE(1, 1, 16) +
- NFP_PL_DEVICE_ID, &tmp))
- return 0;
+ err = nfp_xpb_readl(cpp, NFP_XPB_DEVICE(1, 1, 16) + NFP_PL_DEVICE_ID,
+ ®);
+ if (err < 0)
+ return err;
- model |= (NFP_PL_DEVICE_ID_MASK & tmp) - 0x10;
- }
+ *model = reg & NFP_PL_DEVICE_MODEL_MASK;
+ if (*model & NFP_PL_DEVICE_ID_MASK)
+ *model -= 0x10;
- return model;
+ return 0;
}
/*
--
2.30.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [dpdk-stable] [PATCH] net/nfp: read chip model from PluDevice register
2021-01-25 15:25 [dpdk-dev] [PATCH] net/nfp: read chip model from PluDevice register Heinrich Kuhn
@ 2021-01-29 11:35 ` Ferruh Yigit
0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2021-01-29 11:35 UTC (permalink / raw)
To: Heinrich Kuhn, dev; +Cc: stable, Louis Peens, Simon Horman
On 1/25/2021 3:25 PM, Heinrich Kuhn wrote:
> For newer smartNIC NVRAM versions the chip model should be read from the
> PluDevice register as it provides the authoritative chip model/revision.
> This method of reading the chip model is backwards compatible with
> legacy NVRAM versions too.
>
> Since the model number is purely used for reporting purposes, follow the
> hardware team convention of subtracting 0x10 from the PluDevice register
> to obtain the chip model/revision number.
>
> Fixes: c7e9729da ("net/nfp: support CPP")
> Cc: stable@dpdk.org
>
> Signed-off-by: Heinrich Kuhn <heinrich.kuhn@netronome.com>
> Reviewed-by: Louis Peens <louis.peens@netronome.com>
> Signed-off-by: Simon Horman <simon.horman@netronome.com>
Applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-29 11:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 15:25 [dpdk-dev] [PATCH] net/nfp: read chip model from PluDevice register Heinrich Kuhn
2021-01-29 11:35 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
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).