From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 4CAE4A0495 for ; Mon, 10 Jun 2019 09:42:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DBCFB1BF45; Mon, 10 Jun 2019 09:39:40 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id 26B6B1BE8D for ; Mon, 10 Jun 2019 09:38:59 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 32374140058 for ; Mon, 10 Jun 2019 07:38:58 +0000 (UTC) Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 10 Jun 2019 00:38:51 -0700 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Mon, 10 Jun 2019 00:38:50 -0700 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id x5A7cnmh008780; Mon, 10 Jun 2019 08:38:49 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 63E171627D7; Mon, 10 Jun 2019 08:38:49 +0100 (BST) From: Andrew Rybchenko To: CC: Richard Houldsworth Date: Mon, 10 Jun 2019 08:38:24 +0100 Message-ID: <1560152324-20538-10-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1560152324-20538-1-git-send-email-arybchenko@solarflare.com> References: <1560152324-20538-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24664.003 X-TM-AS-Result: No-5.850700-4.000000-10 X-TMASE-MatchedRID: gPHG3QhDFSZSQAJO4/Vvl3YZxYoZm58FEwOwAhdI3QO3ltgdOztD8KEG Khm9baaNzgG6q5uVl29TvVffeIwvQ8HVNeDWrWSGB8Lglj0iCAA/pOSL72dTfwdkFovAReUoLPJ tWpbJjY16sTzJDZX20UymwL6ADf586sEU5+BT/F0Pe5gzF3TVt6uVOrDvB8LTNN1jIkOk1JfJUF bx9STukyO7mPP5e5uv/xrkZhZF1M978ZKYQ4N2coicBKfMHlV8fS0Ip2eEHnz3IzXlXlpamPoLR 4+zsDTtifGCYEa4FxeD1xXyFt3U8nYs5m2o/yWSHCDzB3jb03kIbWuRtkzLyw== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--5.850700-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24664.003 X-MDID: 1560152338-pg6j-67F73fR Subject: [dpdk-dev] [PATCH 09/29] net/sfc/base: add NVRAM info to API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Richard Houldsworth Add function to query partition characteristics. Refactor efx_nvram_size to share implementation. Signed-off-by: Richard Houldsworth Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/base/ef10_impl.h | 6 +++++ drivers/net/sfc/base/ef10_nvram.c | 36 +++++++++++++++++++++-------- drivers/net/sfc/base/efx.h | 6 +++++ drivers/net/sfc/base/efx_impl.h | 3 ++- drivers/net/sfc/base/efx_nvram.c | 46 +++++++++++++++++++++++++++++++++----- drivers/net/sfc/base/siena_impl.h | 6 +++++ drivers/net/sfc/base/siena_nvram.c | 23 +++++++++++++++++++ 7 files changed, 110 insertions(+), 16 deletions(-) diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h index fae94fe..0cfbf59 100644 --- a/drivers/net/sfc/base/ef10_impl.h +++ b/drivers/net/sfc/base/ef10_impl.h @@ -452,6 +452,12 @@ __out size_t *sizep); extern __checkReturn efx_rc_t +ef10_nvram_partn_info( + __in efx_nic_t *enp, + __in uint32_t partn, + __out efx_nvram_info_t * enip); + +extern __checkReturn efx_rc_t ef10_nvram_partn_rw_start( __in efx_nic_t *enp, __in uint32_t partn, diff --git a/drivers/net/sfc/base/ef10_nvram.c b/drivers/net/sfc/base/ef10_nvram.c index 2aed421..a618c75 100644 --- a/drivers/net/sfc/base/ef10_nvram.c +++ b/drivers/net/sfc/base/ef10_nvram.c @@ -1960,6 +1960,29 @@ static uint32_t checksum_tlv_partition( } __checkReturn efx_rc_t +ef10_nvram_partn_info( + __in efx_nic_t *enp, + __in uint32_t partn, + __out efx_nvram_info_t *enip) +{ + efx_rc_t rc; + + if ((rc = efx_mcdi_nvram_info_ex(enp, partn, enip)) != 0) + goto fail1; + + if (enip->eni_write_size == 0) + enip->eni_write_size = EF10_NVRAM_CHUNK; + + return (0); + +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + + return (rc); +} + + + __checkReturn efx_rc_t ef10_nvram_partn_lock( __in efx_nic_t *enp, __in uint32_t partn) @@ -2439,22 +2462,17 @@ static uint32_t checksum_tlv_partition( __in uint32_t partn, __out size_t *chunk_sizep) { - uint32_t write_size = 0; + efx_nvram_info_t eni = { 0 }; efx_rc_t rc; - if ((rc = efx_mcdi_nvram_info(enp, partn, NULL, NULL, - NULL, &write_size)) != 0) + if ((rc = ef10_nvram_partn_info(enp, partn, &eni)) != 0) goto fail1; if ((rc = ef10_nvram_partn_lock(enp, partn)) != 0) goto fail2; - if (chunk_sizep != NULL) { - if (write_size == 0) - *chunk_sizep = EF10_NVRAM_CHUNK; - else - *chunk_sizep = write_size; - } + if (chunk_sizep != NULL) + *chunk_sizep = eni.eni_write_size; return (0); diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h index a5342af..4905918 100644 --- a/drivers/net/sfc/base/efx.h +++ b/drivers/net/sfc/base/efx.h @@ -1635,6 +1635,12 @@ enum { __out size_t *sizep); extern __checkReturn efx_rc_t +efx_nvram_info( + __in efx_nic_t *enp, + __in efx_nvram_type_t type, + __out efx_nvram_info_t *enip); + +extern __checkReturn efx_rc_t efx_nvram_rw_start( __in efx_nic_t *enp, __in efx_nvram_type_t type, diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h index 684403f..577d5aa 100644 --- a/drivers/net/sfc/base/efx_impl.h +++ b/drivers/net/sfc/base/efx_impl.h @@ -501,7 +501,8 @@ #endif /* EFSYS_OPT_DIAG */ efx_rc_t (*envo_type_to_partn)(efx_nic_t *, efx_nvram_type_t, uint32_t *); - efx_rc_t (*envo_partn_size)(efx_nic_t *, uint32_t, size_t *); + efx_rc_t (*envo_partn_info)(efx_nic_t *, uint32_t, + efx_nvram_info_t *); efx_rc_t (*envo_partn_rw_start)(efx_nic_t *, uint32_t, size_t *); efx_rc_t (*envo_partn_read)(efx_nic_t *, uint32_t, unsigned int, caddr_t, size_t); diff --git a/drivers/net/sfc/base/efx_nvram.c b/drivers/net/sfc/base/efx_nvram.c index df7e851..b817cb6 100644 --- a/drivers/net/sfc/base/efx_nvram.c +++ b/drivers/net/sfc/base/efx_nvram.c @@ -16,7 +16,7 @@ siena_nvram_test, /* envo_test */ #endif /* EFSYS_OPT_DIAG */ siena_nvram_type_to_partn, /* envo_type_to_partn */ - siena_nvram_partn_size, /* envo_partn_size */ + siena_nvram_partn_info, /* envo_partn_info */ siena_nvram_partn_rw_start, /* envo_partn_rw_start */ siena_nvram_partn_read, /* envo_partn_read */ siena_nvram_partn_read, /* envo_partn_read_backup */ @@ -37,7 +37,7 @@ ef10_nvram_test, /* envo_test */ #endif /* EFSYS_OPT_DIAG */ ef10_nvram_type_to_partn, /* envo_type_to_partn */ - ef10_nvram_partn_size, /* envo_partn_size */ + ef10_nvram_partn_info, /* envo_partn_info */ ef10_nvram_partn_rw_start, /* envo_partn_rw_start */ ef10_nvram_partn_read, /* envo_partn_read */ ef10_nvram_partn_read_backup, /* envo_partn_read_backup */ @@ -138,6 +138,7 @@ __out size_t *sizep) { const efx_nvram_ops_t *envop = enp->en_envop; + efx_nvram_info_t eni = { 0 }; uint32_t partn; efx_rc_t rc; @@ -147,9 +148,11 @@ if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0) goto fail1; - if ((rc = envop->envo_partn_size(enp, partn, sizep)) != 0) + if ((rc = envop->envo_partn_info(enp, partn, &eni)) != 0) goto fail2; + *sizep = eni.eni_partn_size; + return (0); fail2: @@ -161,6 +164,36 @@ return (rc); } +extern __checkReturn efx_rc_t +efx_nvram_info( + __in efx_nic_t *enp, + __in efx_nvram_type_t type, + __out efx_nvram_info_t *enip) +{ + const efx_nvram_ops_t *envop = enp->en_envop; + uint32_t partn; + efx_rc_t rc; + + EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); + EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NVRAM); + + if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0) + goto fail1; + + if ((rc = envop->envo_partn_info(enp, partn, enip)) != 0) + goto fail2; + + return (0); + +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + + return (rc); +} + + __checkReturn efx_rc_t efx_nvram_get_version( __in efx_nic_t *enp, @@ -305,7 +338,7 @@ { const efx_nvram_ops_t *envop = enp->en_envop; unsigned int offset = 0; - size_t size = 0; + efx_nvram_info_t eni = { 0 }; uint32_t partn; efx_rc_t rc; @@ -317,10 +350,11 @@ EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, partn); - if ((rc = envop->envo_partn_size(enp, partn, &size)) != 0) + if ((rc = envop->envo_partn_info(enp, partn, &eni)) != 0) goto fail2; - if ((rc = envop->envo_partn_erase(enp, partn, offset, size)) != 0) + if ((rc = envop->envo_partn_erase(enp, partn, offset, + eni.eni_partn_size)) != 0) goto fail3; return (0); diff --git a/drivers/net/sfc/base/siena_impl.h b/drivers/net/sfc/base/siena_impl.h index 1adb8a4..38d0289 100644 --- a/drivers/net/sfc/base/siena_impl.h +++ b/drivers/net/sfc/base/siena_impl.h @@ -192,6 +192,12 @@ __out size_t *sizep); extern __checkReturn efx_rc_t +siena_nvram_partn_info( + __in efx_nic_t *enp, + __in uint32_t partn, + __out efx_nvram_info_t * enip); + +extern __checkReturn efx_rc_t siena_nvram_partn_rw_start( __in efx_nic_t *enp, __in uint32_t partn, diff --git a/drivers/net/sfc/base/siena_nvram.c b/drivers/net/sfc/base/siena_nvram.c index b8ea8a7..7d423d2 100644 --- a/drivers/net/sfc/base/siena_nvram.c +++ b/drivers/net/sfc/base/siena_nvram.c @@ -40,6 +40,29 @@ } __checkReturn efx_rc_t +siena_nvram_partn_info( + __in efx_nic_t *enp, + __in uint32_t partn, + __out efx_nvram_info_t * enip) +{ + efx_rc_t rc; + + if ((rc = efx_mcdi_nvram_info_ex(enp, partn, enip)) != 0) + goto fail1; + + if (enip->eni_write_size == 0) + enip->eni_write_size = SIENA_NVRAM_CHUNK; + + return (0); + +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + + return (rc); +} + + + __checkReturn efx_rc_t siena_nvram_partn_lock( __in efx_nic_t *enp, __in uint32_t partn) -- 1.8.3.1