Subject: Re: [PATCH v3 net-next 2/8] sfc: add devlink info support for ef100

From: Martin Habets <[email-masked]>
Date: Fri, 27 Jan 2023 12:26:58 +0000

On Fri, Jan 27, 2023 at 11:29:08AM +0000, Lucero Palau, Alejandro wrote:
> 
> On 1/27/23 11:20, Martin Habets wrote:
> > On Fri, Jan 27, 2023 at 09:36:45AM +0000, [email-masked] wrote:
> >> From: Alejandro Lucero <[email-masked]>
> >>
> >> Support for devlink info command.
> >>
> >> Signed-off-by: Alejandro Lucero <[email-masked]>
> >> ---
> >>   Documentation/networking/devlink/sfc.rst |  57 ++++
> >>   drivers/net/ethernet/sfc/efx_devlink.c   | 404 +++++++++++++++++++++++
> >>   drivers/net/ethernet/sfc/efx_devlink.h   |  17 +
> >>   drivers/net/ethernet/sfc/mcdi.c          |  72 ++++
> >>   drivers/net/ethernet/sfc/mcdi.h          |   3 +
> >>   5 files changed, 553 insertions(+)
> >>   create mode 100644 Documentation/networking/devlink/sfc.rst
> >>

<snip>

> >> index af338208eae9..328cae82a7d8 100644
> >> --- a/drivers/net/ethernet/sfc/mcdi.c
> >> +++ b/drivers/net/ethernet/sfc/mcdi.c
> >> @@ -2308,6 +2308,78 @@ static int efx_mcdi_nvram_update_finish(struct efx_nic *efx, unsigned int type)
> >>   	return rc;
> >>   }
> >>   
> >> +int efx_mcdi_nvram_metadata(struct efx_nic *efx, unsigned int type,
> >> +			    u32 *subtype, u16 version[4], char *desc,
> >> +			    size_t descsize)
> > This is inside an #ifdef CONFIG_SFC_MTD
> > which is why the kernel test robot is reporting the modpost
> > errors.
> > Move it outside of that ifdef.
> >
> > Martin
> 
> 
> I can not see this error report. Maybe, is it coming with further builds 
> not reported yet by patchwork?

See https://lore.kernel.org/netdev/[email-masked]/
To reproduce it disable CONFIG_SFC_MTD in your .config, and build with
this series.

Martin

> 
> 
> 
> >
> >> +{
> >> +	MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_METADATA_IN_LEN);
> >> +	efx_dword_t *outbuf;
> >> +	size_t outlen;
> >> +	u32 flags;
> >> +	int rc;
> >> +
> >> +	outbuf = kzalloc(MC_CMD_NVRAM_METADATA_OUT_LENMAX_MCDI2, GFP_KERNEL);
> >> +	if (!outbuf)
> >> +		return -ENOMEM;
> >> +
> >> +	MCDI_SET_DWORD(inbuf, NVRAM_METADATA_IN_TYPE, type);
> >> +
> >> +	rc = efx_mcdi_rpc_quiet(efx, MC_CMD_NVRAM_METADATA, inbuf,
> >> +				sizeof(inbuf), outbuf,
> >> +				MC_CMD_NVRAM_METADATA_OUT_LENMAX_MCDI2,
> >> +				&outlen);
> >> +	if (rc)
> >> +		goto out_free;
> >> +	if (outlen < MC_CMD_NVRAM_METADATA_OUT_LENMIN) {
> >> +		rc = -EIO;
> >> +		goto out_free;
> >> +	}
> >> +
> >> +	flags = MCDI_DWORD(outbuf, NVRAM_METADATA_OUT_FLAGS);
> >> +
> >> +	if (desc && descsize > 0) {
> >> +		if (flags & BIT(MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_VALID_LBN)) {
> >> +			if (descsize <=
> >> +			    MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_NUM(outlen)) {
> >> +				rc = -E2BIG;
> >> +				goto out_free;
> >> +			}
> >> +
> >> +			strncpy(desc,
> >> +				MCDI_PTR(outbuf, NVRAM_METADATA_OUT_DESCRIPTION),
> >> +				MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_NUM(outlen));
> >> +			desc[MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_NUM(outlen)] = '\0';
> >> +		} else {
> >> +			desc[0] = '\0';
> >> +		}
> >> +	}
> >> +
> >> +	if (subtype) {
> >> +		if (flags & BIT(MC_CMD_NVRAM_METADATA_OUT_SUBTYPE_VALID_LBN))
> >> +			*subtype = MCDI_DWORD(outbuf, NVRAM_METADATA_OUT_SUBTYPE);
> >> +		else
> >> +			*subtype = 0;
> >> +	}
> >> +
> >> +	if (version) {
> >> +		if (flags & BIT(MC_CMD_NVRAM_METADATA_OUT_VERSION_VALID_LBN)) {
> >> +			version[0] = MCDI_WORD(outbuf, NVRAM_METADATA_OUT_VERSION_W);
> >> +			version[1] = MCDI_WORD(outbuf, NVRAM_METADATA_OUT_VERSION_X);
> >> +			version[2] = MCDI_WORD(outbuf, NVRAM_METADATA_OUT_VERSION_Y);
> >> +			version[3] = MCDI_WORD(outbuf, NVRAM_METADATA_OUT_VERSION_Z);
> >> +		} else {
> >> +			version[0] = 0;
> >> +			version[1] = 0;
> >> +			version[2] = 0;
> >> +			version[3] = 0;
> >> +		}
> >> +	}
> >> +
> >> +out_free:
> >> +	kfree(outbuf);
> >> +	return rc;
> >> +}
> >> +
> >>   int efx_mcdi_mtd_read(struct mtd_info *mtd, loff_t start,
> >>   		      size_t len, size_t *retlen, u8 *buffer)
> >>   {
> >> diff --git a/drivers/net/ethernet/sfc/mcdi.h b/drivers/net/ethernet/sfc/mcdi.h
> >> index 7e35fec9da35..5cb202684858 100644
> >> --- a/drivers/net/ethernet/sfc/mcdi.h
> >> +++ b/drivers/net/ethernet/sfc/mcdi.h
> >> @@ -378,6 +378,9 @@ int efx_mcdi_nvram_info(struct efx_nic *efx, unsigned int type,
> >>   			size_t *size_out, size_t *erase_size_out,
> >>   			bool *protected_out);
> >>   int efx_new_mcdi_nvram_test_all(struct efx_nic *efx);
> >> +int efx_mcdi_nvram_metadata(struct efx_nic *efx, unsigned int type,
> >> +			    u32 *subtype, u16 version[4], char *desc,
> >> +			    size_t descsize);
> >>   int efx_mcdi_nvram_test_all(struct efx_nic *efx);
> >>   int efx_mcdi_handle_assertion(struct efx_nic *efx);
> >>   int efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode);
> >> -- 
> >> 2.17.1
>