From 0afdf29c9779dc1ae16bbe1daa18ae7192d7dc05 Mon Sep 17 00:00:00 2001 From: Andrew Rybchenko Date: Fri, 15 Jan 2016 15:19:18 +0000 Subject: [PATCH] sfxge: convert nvram read method to use partition id Submitted by: Andy Moreton Reviewed by: gnn Sponsored by: Solarflare Communications, Inc. MFC after: 2 days Differential Revision: https://reviews.freebsd.org/D4951 --- sys/dev/sfxge/common/efx_impl.h | 4 ++-- sys/dev/sfxge/common/efx_nvram.c | 14 ++++++++++---- sys/dev/sfxge/common/hunt_impl.h | 24 ++++++++---------------- sys/dev/sfxge/common/hunt_nvram.c | 27 --------------------------- sys/dev/sfxge/common/siena_impl.h | 24 ++++++++---------------- sys/dev/sfxge/common/siena_nvram.c | 27 --------------------------- 6 files changed, 28 insertions(+), 92 deletions(-) diff --git a/sys/dev/sfxge/common/efx_impl.h b/sys/dev/sfxge/common/efx_impl.h index d21a927dccda..ecda6feda496 100644 --- a/sys/dev/sfxge/common/efx_impl.h +++ b/sys/dev/sfxge/common/efx_impl.h @@ -486,8 +486,6 @@ typedef struct efx_nvram_ops_s { #endif /* EFSYS_OPT_DIAG */ efx_rc_t (*envo_get_version)(efx_nic_t *, efx_nvram_type_t, uint32_t *, uint16_t *); - efx_rc_t (*envo_read_chunk)(efx_nic_t *, efx_nvram_type_t, - unsigned int, caddr_t, size_t); efx_rc_t (*envo_erase)(efx_nic_t *, efx_nvram_type_t); efx_rc_t (*envo_write_chunk)(efx_nic_t *, efx_nvram_type_t, unsigned int, caddr_t, size_t); @@ -499,6 +497,8 @@ typedef struct efx_nvram_ops_s { uint32_t *); efx_rc_t (*envo_partn_size)(efx_nic_t *, uint32_t, size_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); } efx_nvram_ops_t; #endif /* EFSYS_OPT_NVRAM */ diff --git a/sys/dev/sfxge/common/efx_nvram.c b/sys/dev/sfxge/common/efx_nvram.c index abb1dd7508b9..97ef37e4ee14 100644 --- a/sys/dev/sfxge/common/efx_nvram.c +++ b/sys/dev/sfxge/common/efx_nvram.c @@ -43,7 +43,6 @@ static efx_nvram_ops_t __efx_nvram_falcon_ops = { falcon_nvram_test, /* envo_test */ #endif /* EFSYS_OPT_DIAG */ falcon_nvram_get_version, /* envo_get_version */ - falcon_nvram_read_chunk, /* envo_read_chunk */ falcon_nvram_erase, /* envo_erase */ falcon_nvram_write_chunk, /* envo_write_chunk */ falcon_nvram_rw_finish, /* envo_rw_finish */ @@ -51,6 +50,7 @@ static efx_nvram_ops_t __efx_nvram_falcon_ops = { falcon_nvram_type_to_partn, /* envo_type_to_partn */ falcon_nvram_partn_size, /* envo_partn_size */ falcon_nvram_partn_rw_start, /* envo_partn_rw_start */ + falcon_nvram_partn_read, /* envo_partn_read */ }; #endif /* EFSYS_OPT_FALCON */ @@ -62,7 +62,6 @@ static efx_nvram_ops_t __efx_nvram_siena_ops = { siena_nvram_test, /* envo_test */ #endif /* EFSYS_OPT_DIAG */ siena_nvram_get_version, /* envo_get_version */ - siena_nvram_read_chunk, /* envo_read_chunk */ siena_nvram_erase, /* envo_erase */ siena_nvram_write_chunk, /* envo_write_chunk */ siena_nvram_rw_finish, /* envo_rw_finish */ @@ -70,6 +69,7 @@ static efx_nvram_ops_t __efx_nvram_siena_ops = { siena_nvram_type_to_partn, /* envo_type_to_partn */ siena_nvram_partn_size, /* envo_partn_size */ siena_nvram_partn_rw_start, /* envo_partn_rw_start */ + siena_nvram_partn_read, /* envo_partn_read */ }; #endif /* EFSYS_OPT_SIENA */ @@ -81,7 +81,6 @@ static efx_nvram_ops_t __efx_nvram_ef10_ops = { ef10_nvram_test, /* envo_test */ #endif /* EFSYS_OPT_DIAG */ ef10_nvram_get_version, /* envo_get_version */ - ef10_nvram_read_chunk, /* envo_read_chunk */ ef10_nvram_erase, /* envo_erase */ ef10_nvram_write_chunk, /* envo_write_chunk */ ef10_nvram_rw_finish, /* envo_rw_finish */ @@ -89,6 +88,7 @@ static efx_nvram_ops_t __efx_nvram_ef10_ops = { ef10_nvram_type_to_partn, /* envo_type_to_partn */ ef10_nvram_partn_size, /* envo_partn_size */ ef10_nvram_partn_rw_start, /* envo_partn_rw_start */ + ef10_nvram_partn_read, /* envo_partn_read */ }; #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ @@ -275,6 +275,7 @@ efx_nvram_read_chunk( __in size_t size) { efx_nvram_ops_t *envop = enp->en_envop; + uint32_t partn; efx_rc_t rc; EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); @@ -285,11 +286,16 @@ efx_nvram_read_chunk( EFSYS_ASSERT3U(enp->en_nvram_locked, ==, type); - if ((rc = envop->envo_read_chunk(enp, type, offset, data, size)) != 0) + if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0) goto fail1; + if ((rc = envop->envo_partn_read(enp, partn, offset, data, size)) != 0) + goto fail2; + return (0); +fail2: + EFSYS_PROBE(fail2); fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); diff --git a/sys/dev/sfxge/common/hunt_impl.h b/sys/dev/sfxge/common/hunt_impl.h index 4a2dfdba18a4..f1f8b2aa69d9 100644 --- a/sys/dev/sfxge/common/hunt_impl.h +++ b/sys/dev/sfxge/common/hunt_impl.h @@ -369,14 +369,6 @@ ef10_nvram_partn_lock( __in efx_nic_t *enp, __in uint32_t partn); -extern __checkReturn efx_rc_t -ef10_nvram_partn_read( - __in efx_nic_t *enp, - __in uint32_t partn, - __in unsigned int offset, - __out_bcount(size) caddr_t data, - __in size_t size); - extern __checkReturn efx_rc_t ef10_nvram_partn_erase( __in efx_nic_t *enp, @@ -416,14 +408,6 @@ ef10_nvram_get_version( __out uint32_t *subtypep, __out_ecount(4) uint16_t version[4]); -extern __checkReturn efx_rc_t -ef10_nvram_read_chunk( - __in efx_nic_t *enp, - __in efx_nvram_type_t type, - __in unsigned int offset, - __out_bcount(size) caddr_t data, - __in size_t size); - extern __checkReturn efx_rc_t ef10_nvram_erase( __in efx_nic_t *enp, @@ -472,6 +456,14 @@ ef10_nvram_partn_rw_start( __in uint32_t partn, __out size_t *chunk_sizep); +extern __checkReturn efx_rc_t +ef10_nvram_partn_read( + __in efx_nic_t *enp, + __in uint32_t partn, + __in unsigned int offset, + __out_bcount(size) caddr_t data, + __in size_t size); + #endif /* EFSYS_OPT_NVRAM */ diff --git a/sys/dev/sfxge/common/hunt_nvram.c b/sys/dev/sfxge/common/hunt_nvram.c index 17dc4ef122d1..3e20194e636e 100644 --- a/sys/dev/sfxge/common/hunt_nvram.c +++ b/sys/dev/sfxge/common/hunt_nvram.c @@ -1765,33 +1765,6 @@ ef10_nvram_partn_rw_start( fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); - return (rc); -} - - __checkReturn efx_rc_t -ef10_nvram_read_chunk( - __in efx_nic_t *enp, - __in efx_nvram_type_t type, - __in unsigned int offset, - __out_bcount(size) caddr_t data, - __in size_t size) -{ - uint32_t partn; - efx_rc_t rc; - - if ((rc = ef10_nvram_type_to_partn(enp, type, &partn)) != 0) - goto fail1; - - if ((rc = ef10_nvram_partn_read(enp, partn, offset, data, size)) != 0) - goto fail2; - - return (0); - -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - return (rc); } diff --git a/sys/dev/sfxge/common/siena_impl.h b/sys/dev/sfxge/common/siena_impl.h index 95c15ff2c9ac..6847544b88f2 100644 --- a/sys/dev/sfxge/common/siena_impl.h +++ b/sys/dev/sfxge/common/siena_impl.h @@ -155,14 +155,6 @@ siena_nvram_partn_lock( __in efx_nic_t *enp, __in uint32_t partn); -extern __checkReturn efx_rc_t -siena_nvram_partn_read( - __in efx_nic_t *enp, - __in uint32_t partn, - __in unsigned int offset, - __out_bcount(size) caddr_t data, - __in size_t size); - extern __checkReturn efx_rc_t siena_nvram_partn_erase( __in efx_nic_t *enp, @@ -216,14 +208,6 @@ siena_nvram_get_version( __out uint32_t *subtypep, __out_ecount(4) uint16_t version[4]); -extern __checkReturn efx_rc_t -siena_nvram_read_chunk( - __in efx_nic_t *enp, - __in efx_nvram_type_t type, - __in unsigned int offset, - __out_bcount(size) caddr_t data, - __in size_t size); - extern __checkReturn efx_rc_t siena_nvram_erase( __in efx_nic_t *enp, @@ -266,6 +250,14 @@ siena_nvram_partn_rw_start( __in uint32_t partn, __out size_t *chunk_sizep); +extern __checkReturn efx_rc_t +siena_nvram_partn_read( + __in efx_nic_t *enp, + __in uint32_t partn, + __in unsigned int offset, + __out_bcount(size) caddr_t data, + __in size_t size); + #endif /* EFSYS_OPT_NVRAM */ #if EFSYS_OPT_VPD diff --git a/sys/dev/sfxge/common/siena_nvram.c b/sys/dev/sfxge/common/siena_nvram.c index 67e689ab4436..ace5f190d630 100644 --- a/sys/dev/sfxge/common/siena_nvram.c +++ b/sys/dev/sfxge/common/siena_nvram.c @@ -590,33 +590,6 @@ siena_nvram_partn_rw_start( fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); - return (rc); -} - - __checkReturn efx_rc_t -siena_nvram_read_chunk( - __in efx_nic_t *enp, - __in efx_nvram_type_t type, - __in unsigned int offset, - __out_bcount(size) caddr_t data, - __in size_t size) -{ - uint32_t partn; - efx_rc_t rc; - - if ((rc = siena_nvram_type_to_partn(enp, type, &partn)) != 0) - goto fail1; - - if ((rc = siena_nvram_partn_read(enp, partn, offset, data, size)) != 0) - goto fail2; - - return (0); - -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - return (rc); }