summaryrefslogtreecommitdiffstats
path: root/sys/dev/sfxge/common/hunt_vpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/sfxge/common/hunt_vpd.c')
-rw-r--r--sys/dev/sfxge/common/hunt_vpd.c151
1 files changed, 78 insertions, 73 deletions
diff --git a/sys/dev/sfxge/common/hunt_vpd.c b/sys/dev/sfxge/common/hunt_vpd.c
index 536ebbc..58e9a66 100644
--- a/sys/dev/sfxge/common/hunt_vpd.c
+++ b/sys/dev/sfxge/common/hunt_vpd.c
@@ -31,10 +31,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "efsys.h"
#include "efx.h"
-#include "efx_types.h"
-#include "efx_regs.h"
#include "efx_impl.h"
@@ -44,17 +41,18 @@ __FBSDID("$FreeBSD$");
#include "ef10_tlv_layout.h"
- __checkReturn int
-hunt_vpd_init(
+ __checkReturn efx_rc_t
+ef10_vpd_init(
__in efx_nic_t *enp)
{
caddr_t svpd;
size_t svpd_size;
uint32_t pci_pf;
- int rc;
+ efx_rc_t rc;
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
- EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON);
+ EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
+ enp->en_family == EFX_FAMILY_MEDFORD);
pci_pf = enp->en_nic_cfg.enc_pf;
/*
@@ -64,7 +62,7 @@ hunt_vpd_init(
*/
svpd = NULL;
svpd_size = 0;
- rc = hunt_nvram_partn_read_tlv(enp,
+ rc = ef10_nvram_partn_read_tlv(enp,
NVRAM_PARTITION_TYPE_STATIC_CONFIG,
TLV_TAG_PF_STATIC_VPD(pci_pf),
&svpd, &svpd_size);
@@ -81,8 +79,8 @@ hunt_vpd_init(
goto fail2;
}
- enp->en_u.hunt.enu_svpd = svpd;
- enp->en_u.hunt.enu_svpd_length = svpd_size;
+ enp->en_arch.ef10.ena_svpd = svpd;
+ enp->en_arch.ef10.ena_svpd_length = svpd_size;
out:
return (0);
@@ -92,19 +90,20 @@ fail2:
EFSYS_KMEM_FREE(enp->en_esip, svpd_size, svpd);
fail1:
- EFSYS_PROBE1(fail1, int, rc);
+ EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
- __checkReturn int
-hunt_vpd_size(
+ __checkReturn efx_rc_t
+ef10_vpd_size(
__in efx_nic_t *enp,
__out size_t *sizep)
{
- int rc;
+ efx_rc_t rc;
- EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON);
+ EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
+ enp->en_family == EFX_FAMILY_MEDFORD);
/*
* This function returns the total size the user should allocate
@@ -113,19 +112,19 @@ hunt_vpd_size(
* which is the size of the DYNAMIC_CONFIG partition.
*/
if ((rc = efx_mcdi_nvram_info(enp, NVRAM_PARTITION_TYPE_DYNAMIC_CONFIG,
- sizep, NULL, NULL)) != 0)
+ sizep, NULL, NULL, NULL)) != 0)
goto fail1;
return (0);
fail1:
- EFSYS_PROBE1(fail1, int, rc);
+ EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
- __checkReturn int
-hunt_vpd_read(
+ __checkReturn efx_rc_t
+ef10_vpd_read(
__in efx_nic_t *enp,
__out_bcount(size) caddr_t data,
__in size_t size)
@@ -133,13 +132,14 @@ hunt_vpd_read(
caddr_t dvpd;
size_t dvpd_size;
uint32_t pci_pf;
- int rc;
+ efx_rc_t rc;
- EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON);
+ EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
+ enp->en_family == EFX_FAMILY_MEDFORD);
pci_pf = enp->en_nic_cfg.enc_pf;
- if ((rc = hunt_nvram_partn_read_tlv(enp,
+ if ((rc = ef10_nvram_partn_read_tlv(enp,
NVRAM_PARTITION_TYPE_DYNAMIC_CONFIG,
TLV_TAG_PF_DYNAMIC_VPD(pci_pf),
&dvpd, &dvpd_size)) != 0)
@@ -163,13 +163,13 @@ fail2:
EFSYS_KMEM_FREE(enp->en_esip, dvpd_size, dvpd);
fail1:
- EFSYS_PROBE1(fail1, int, rc);
+ EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
- __checkReturn int
-hunt_vpd_verify(
+ __checkReturn efx_rc_t
+ef10_vpd_verify(
__in efx_nic_t *enp,
__in_bcount(size) caddr_t data,
__in size_t size)
@@ -180,14 +180,15 @@ hunt_vpd_verify(
efx_vpd_keyword_t dkey;
unsigned int scont;
unsigned int dcont;
- int rc;
+ efx_rc_t rc;
- EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON);
+ EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
+ enp->en_family == EFX_FAMILY_MEDFORD);
/*
* Strictly you could take the view that dynamic vpd is optional.
* Instead, to conform more closely to the read/verify/reinit()
- * paradigm, we require dynamic vpd. hunt_vpd_reinit() will
+ * paradigm, we require dynamic vpd. ef10_vpd_reinit() will
* reinitialize it as required.
*/
if ((rc = efx_vpd_hunk_verify(data, size, NULL)) != 0)
@@ -197,7 +198,7 @@ hunt_vpd_verify(
* Verify that there is no duplication between the static and
* dynamic cfg sectors.
*/
- if (enp->en_u.hunt.enu_svpd_length == 0)
+ if (enp->en_arch.ef10.ena_svpd_length == 0)
goto done;
dcont = 0;
@@ -213,8 +214,8 @@ hunt_vpd_verify(
_NOTE(CONSTANTCONDITION)
while (1) {
if ((rc = efx_vpd_hunk_next(
- enp->en_u.hunt.enu_svpd,
- enp->en_u.hunt.enu_svpd_length, &stag, &skey,
+ enp->en_arch.ef10.ena_svpd,
+ enp->en_arch.ef10.ena_svpd_length, &stag, &skey,
NULL, NULL, &scont)) != 0)
goto fail3;
if (scont == 0)
@@ -237,31 +238,31 @@ fail3:
fail2:
EFSYS_PROBE(fail2);
fail1:
- EFSYS_PROBE1(fail1, int, rc);
+ EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
- __checkReturn int
-hunt_vpd_reinit(
+ __checkReturn efx_rc_t
+ef10_vpd_reinit(
__in efx_nic_t *enp,
__in_bcount(size) caddr_t data,
__in size_t size)
{
boolean_t wantpid;
- int rc;
+ efx_rc_t rc;
/*
* Only create an ID string if the dynamic cfg doesn't have one
*/
- if (enp->en_u.hunt.enu_svpd_length == 0)
+ if (enp->en_arch.ef10.ena_svpd_length == 0)
wantpid = B_TRUE;
else {
unsigned int offset;
uint8_t length;
- rc = efx_vpd_hunk_get(enp->en_u.hunt.enu_svpd,
- enp->en_u.hunt.enu_svpd_length,
+ rc = efx_vpd_hunk_get(enp->en_arch.ef10.ena_svpd,
+ enp->en_arch.ef10.ena_svpd_length,
EFX_VPD_ID, 0, &offset, &length);
if (rc == 0)
wantpid = B_FALSE;
@@ -279,13 +280,13 @@ hunt_vpd_reinit(
fail2:
EFSYS_PROBE(fail2);
fail1:
- EFSYS_PROBE1(fail1, int, rc);
+ EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
- __checkReturn int
-hunt_vpd_get(
+ __checkReturn efx_rc_t
+ef10_vpd_get(
__in efx_nic_t *enp,
__in_bcount(size) caddr_t data,
__in size_t size,
@@ -293,18 +294,19 @@ hunt_vpd_get(
{
unsigned int offset;
uint8_t length;
- int rc;
+ efx_rc_t rc;
- EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON);
+ EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
+ enp->en_family == EFX_FAMILY_MEDFORD);
/* Attempt to satisfy the request from svpd first */
- if (enp->en_u.hunt.enu_svpd_length > 0) {
- if ((rc = efx_vpd_hunk_get(enp->en_u.hunt.enu_svpd,
- enp->en_u.hunt.enu_svpd_length, evvp->evv_tag,
+ if (enp->en_arch.ef10.ena_svpd_length > 0) {
+ if ((rc = efx_vpd_hunk_get(enp->en_arch.ef10.ena_svpd,
+ enp->en_arch.ef10.ena_svpd_length, evvp->evv_tag,
evvp->evv_keyword, &offset, &length)) == 0) {
evvp->evv_length = length;
memcpy(evvp->evv_value,
- enp->en_u.hunt.enu_svpd + offset, length);
+ enp->en_arch.ef10.ena_svpd + offset, length);
return (0);
} else if (rc != ENOENT)
goto fail1;
@@ -323,29 +325,30 @@ hunt_vpd_get(
fail2:
EFSYS_PROBE(fail2);
fail1:
- EFSYS_PROBE1(fail1, int, rc);
+ EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
- __checkReturn int
-hunt_vpd_set(
+ __checkReturn efx_rc_t
+ef10_vpd_set(
__in efx_nic_t *enp,
__in_bcount(size) caddr_t data,
__in size_t size,
__in efx_vpd_value_t *evvp)
{
- int rc;
+ efx_rc_t rc;
- EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON);
+ EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
+ enp->en_family == EFX_FAMILY_MEDFORD);
/* If the provided (tag,keyword) exists in svpd, then it is readonly */
- if (enp->en_u.hunt.enu_svpd_length > 0) {
+ if (enp->en_arch.ef10.ena_svpd_length > 0) {
unsigned int offset;
uint8_t length;
- if ((rc = efx_vpd_hunk_get(enp->en_u.hunt.enu_svpd,
- enp->en_u.hunt.enu_svpd_length, evvp->evv_tag,
+ if ((rc = efx_vpd_hunk_get(enp->en_arch.ef10.ena_svpd,
+ enp->en_arch.ef10.ena_svpd_length, evvp->evv_tag,
evvp->evv_keyword, &offset, &length)) == 0) {
rc = EACCES;
goto fail1;
@@ -360,13 +363,13 @@ hunt_vpd_set(
fail2:
EFSYS_PROBE(fail2);
fail1:
- EFSYS_PROBE1(fail1, int, rc);
+ EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
- __checkReturn int
-hunt_vpd_next(
+ __checkReturn efx_rc_t
+ef10_vpd_next(
__in efx_nic_t *enp,
__in_bcount(size) caddr_t data,
__in size_t size,
@@ -378,17 +381,18 @@ hunt_vpd_next(
return (ENOTSUP);
}
- __checkReturn int
-hunt_vpd_write(
+ __checkReturn efx_rc_t
+ef10_vpd_write(
__in efx_nic_t *enp,
__in_bcount(size) caddr_t data,
__in size_t size)
{
size_t vpd_length;
uint32_t pci_pf;
- int rc;
+ efx_rc_t rc;
- EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON);
+ EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
+ enp->en_family == EFX_FAMILY_MEDFORD);
pci_pf = enp->en_nic_cfg.enc_pf;
@@ -396,11 +400,11 @@ hunt_vpd_write(
if ((rc = efx_vpd_hunk_length(data, size, &vpd_length)) != 0)
goto fail1;
- /* Store new dynamic VPD in DYNAMIC_CONFIG partition */
- if ((rc = hunt_nvram_partn_write_tlv(enp,
+ /* Store new dynamic VPD in all segments in DYNAMIC_CONFIG partition */
+ if ((rc = ef10_nvram_partn_write_segment_tlv(enp,
NVRAM_PARTITION_TYPE_DYNAMIC_CONFIG,
TLV_TAG_PF_DYNAMIC_VPD(pci_pf),
- data, vpd_length)) != 0) {
+ data, vpd_length, B_TRUE)) != 0) {
goto fail2;
}
@@ -410,23 +414,24 @@ fail2:
EFSYS_PROBE(fail2);
fail1:
- EFSYS_PROBE1(fail1, int, rc);
+ EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
void
-hunt_vpd_fini(
+ef10_vpd_fini(
__in efx_nic_t *enp)
{
- EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON);
+ EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
+ enp->en_family == EFX_FAMILY_MEDFORD);
- if (enp->en_u.hunt.enu_svpd_length > 0) {
- EFSYS_KMEM_FREE(enp->en_esip, enp->en_u.hunt.enu_svpd_length,
- enp->en_u.hunt.enu_svpd);
+ if (enp->en_arch.ef10.ena_svpd_length > 0) {
+ EFSYS_KMEM_FREE(enp->en_esip, enp->en_arch.ef10.ena_svpd_length,
+ enp->en_arch.ef10.ena_svpd);
- enp->en_u.hunt.enu_svpd = NULL;
- enp->en_u.hunt.enu_svpd_length = 0;
+ enp->en_arch.ef10.ena_svpd = NULL;
+ enp->en_arch.ef10.ena_svpd_length = 0;
}
}
OpenPOWER on IntegriCloud