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 AF12AA0495 for ; Mon, 10 Jun 2019 09:39:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CCB541BEB9; Mon, 10 Jun 2019 09:39:07 +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 2F0C61BE8C for ; Mon, 10 Jun 2019 09:38:55 +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-us5.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 3765F4C005D for ; Mon, 10 Jun 2019 07:38:54 +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 x5A7cn77008792; 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 87C511616E0; Mon, 10 Jun 2019 08:38:49 +0100 (BST) From: Andrew Rybchenko To: CC: Richard Houldsworth Date: Mon, 10 Jun 2019 08:38:27 +0100 Message-ID: <1560152324-20538-13-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-3.914700-4.000000-10 X-TMASE-MatchedRID: m5OjDIbmcT9tJ5HtYGckb4QHGus7Cfv1mGheEvjzATvBSouFRjh0Aq2L obuNU2ek0pjhOiE8kTdTvVffeIwvQ8HVNeDWrWSGXrumkbea2Mk/pOSL72dTfwdkFovAReUoilv Ab18i4hNWkAzeYr3deqkshZJNRaqN56XkomU2m5VIcJTn2HkqsfngX/aL8PCNCkKOpUQuXBWvpK 1251ntyLedRuu+nkCTGKpaxRNmG5ibII6cSoXys0NuJSeNFwKYqV3VmuIFNEs+0zQnFXpU+nYM2 AZgEFG98Hvdz7S04K6AMSNP1w8cRYZmskxZzd/WngIgpj8eDcAZ1CdBJOsoY8RB0bsfrpPInxMy eYT53Rl4mjaLB+Or6U44QID+nYPcFuyP6ZrfLxx4cvcfu1iizU4a5qeeI6ziKHMssfVxXG5Gpob 1v3OnWzjTSL5EeglIVePgUA+TiUGTdSRXlCnjBIjjlF305EnAWUm8SESyzd+8353hqEyjk1Zca9 RSYo/b X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--3.914700-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24664.003 X-MDID: 1560152334-q0fl3c4JsAfw Subject: [dpdk-dev] [PATCH 12/29] net/sfc/base: support direct FW update for bundle partitions 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 All signed images other than for the MCFW partition should be written fully to the partition with no rearrangement. Signed-off-by: Richard Houldsworth Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/base/ef10_image.c | 74 ++++++++++++++++++++++++--------------- drivers/net/sfc/base/efx.h | 1 + 2 files changed, 47 insertions(+), 28 deletions(-) diff --git a/drivers/net/sfc/base/ef10_image.c b/drivers/net/sfc/base/ef10_image.c index c035e0d..a19df7f 100644 --- a/drivers/net/sfc/base/ef10_image.c +++ b/drivers/net/sfc/base/ef10_image.c @@ -7,6 +7,8 @@ #include "efx.h" #include "efx_impl.h" +#include "ef10_firmware_ids.h" + #if EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 #if EFSYS_OPT_IMAGE_LAYOUT @@ -429,54 +431,59 @@ static __checkReturn efx_rc_t efx_check_unsigned_image( - __in void *bufferp, - __in uint32_t buffer_size) + __in void *bufferp, + __in uint32_t buffer_size, + __out efx_image_header_t **headerpp, + __out efx_image_trailer_t **trailerpp) { - efx_image_header_t *header; - efx_image_trailer_t *trailer; + efx_image_header_t *headerp; + efx_image_trailer_t *trailerp; uint32_t crc; efx_rc_t rc; - EFX_STATIC_ASSERT(sizeof (*header) == EFX_IMAGE_HEADER_SIZE); - EFX_STATIC_ASSERT(sizeof (*trailer) == EFX_IMAGE_TRAILER_SIZE); + EFX_STATIC_ASSERT(sizeof (*headerp) == EFX_IMAGE_HEADER_SIZE); + EFX_STATIC_ASSERT(sizeof (*trailerp) == EFX_IMAGE_TRAILER_SIZE); /* Must have at least enough space for required image header fields */ if (buffer_size < (EFX_FIELD_OFFSET(efx_image_header_t, eih_size) + - sizeof (header->eih_size))) { + sizeof (headerp->eih_size))) { rc = ENOSPC; goto fail1; } - header = (efx_image_header_t *)bufferp; + headerp = (efx_image_header_t *)bufferp; - if (header->eih_magic != EFX_IMAGE_HEADER_MAGIC) { - rc = EINVAL; + /* Buffer must have space for image header, code and image trailer. */ + if (buffer_size < (headerp->eih_size + headerp->eih_code_size + + EFX_IMAGE_TRAILER_SIZE)) { + rc = ENOSPC; goto fail2; } + trailerp = (efx_image_trailer_t *)((uint8_t *)headerp + + headerp->eih_size + headerp->eih_code_size); + + *headerpp = headerp; + *trailerpp = trailerp; + + if (headerp->eih_magic != EFX_IMAGE_HEADER_MAGIC) { + rc = EINVAL; + goto fail3; + } + /* * Check image header version is same or higher than lowest required * version. */ - if (header->eih_version < EFX_IMAGE_HEADER_VERSION) { + if (headerp->eih_version < EFX_IMAGE_HEADER_VERSION) { rc = EINVAL; - goto fail3; - } - - /* Buffer must have space for image header, code and image trailer. */ - if (buffer_size < (header->eih_size + header->eih_code_size + - EFX_IMAGE_TRAILER_SIZE)) { - rc = ENOSPC; goto fail4; } /* Check CRC from image buffer matches computed CRC. */ - trailer = (efx_image_trailer_t *)((uint8_t *)header + - header->eih_size + header->eih_code_size); + crc = efx_crc32_calculate(0, (uint8_t *)headerp, + (headerp->eih_size + headerp->eih_code_size)); - crc = efx_crc32_calculate(0, (uint8_t *)header, - (header->eih_size + header->eih_code_size)); - - if (trailer->eit_crc != crc) { + if (trailerp->eit_crc != crc) { rc = EINVAL; goto fail5; } @@ -507,9 +514,10 @@ uint32_t image_offset; uint32_t image_size; void *imagep; + efx_image_header_t *headerp; + efx_image_trailer_t *trailerp; efx_rc_t rc; - EFSYS_ASSERT(infop != NULL); if (infop == NULL) { rc = EINVAL; @@ -531,7 +539,7 @@ if (rc == 0) { /* * Buffer holds signed image format. Check that the encapsulated - * content is in unsigned image format. + * content contains an unsigned image format header. */ format = EFX_IMAGE_FORMAT_SIGNED; } else { @@ -546,11 +554,21 @@ } imagep = (uint8_t *)bufferp + image_offset; - /* Check unsigned image layout (image header, code, image trailer) */ - rc = efx_check_unsigned_image(imagep, image_size); + /* Check image layout (image header, code, image trailer) */ + rc = efx_check_unsigned_image(imagep, image_size, &headerp, &trailerp); if (rc != 0) goto fail4; + /* + * Signed images are packages consumed directly by the firmware, + * with the exception of MC firmware, where the image must be + * rearranged for booting purposes. + */ + if (format == EFX_IMAGE_FORMAT_SIGNED) { + if (headerp->eih_type != FIRMWARE_TYPE_MCFW) + format = EFX_IMAGE_FORMAT_SIGNED_PACKAGE; + } + /* Return image details */ infop->eii_format = format; infop->eii_imagep = bufferp; diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h index 4905918..d46e650 100644 --- a/drivers/net/sfc/base/efx.h +++ b/drivers/net/sfc/base/efx.h @@ -1889,6 +1889,7 @@ enum { EFX_IMAGE_FORMAT_INVALID, EFX_IMAGE_FORMAT_UNSIGNED, EFX_IMAGE_FORMAT_SIGNED, + EFX_IMAGE_FORMAT_SIGNED_PACKAGE } efx_image_format_t; typedef struct efx_image_info_s { -- 1.8.3.1