sfxge: change hunt specific fields of efx_nic_t to ef10
All these fields will be used in shared ef10 code, so put them in an ef10 member of a per-architecture union, rather that in the per-chip union. Submitted by: Mark Spender <mspender at solarflare.com> Reviewed by: gnn Sponsored by: Solarflare Communications, Inc. MFC after: 2 days Differential Revision: https://reviews.freebsd.org/D4865
This commit is contained in:
parent
f45757caea
commit
e7119ad9ae
@ -37,6 +37,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if (EFSYS_OPT_HUNTINGTON && EFSYS_OPT_MEDFORD)
|
||||
#define EF10_MAX_PIOBUF_NBUFS MAX(HUNT_PIOBUF_NBUFS, MEDFORD_PIOBUF_NBUFS)
|
||||
#elif EFSYS_OPT_HUNTINGTON
|
||||
#define EF10_MAX_PIOBUF_NBUFS HUNT_PIOBUF_NBUFS
|
||||
#elif EFSYS_OPT_MEDFORD
|
||||
#define EF10_MAX_PIOBUF_NBUFS MEDFORD_PIOBUF_NBUFS
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -672,26 +672,29 @@ struct efx_nic_s {
|
||||
int enu_unused;
|
||||
} siena;
|
||||
#endif /* EFSYS_OPT_SIENA */
|
||||
#if EFSYS_OPT_HUNTINGTON
|
||||
struct {
|
||||
int enu_vi_base;
|
||||
int enu_vi_count;
|
||||
#if EFSYS_OPT_VPD
|
||||
caddr_t enu_svpd;
|
||||
size_t enu_svpd_length;
|
||||
#endif /* EFSYS_OPT_VPD */
|
||||
efx_piobuf_handle_t enu_piobuf_handle[HUNT_PIOBUF_NBUFS];
|
||||
uint32_t enu_piobuf_count;
|
||||
uint32_t enu_pio_alloc_map[HUNT_PIOBUF_NBUFS];
|
||||
uint32_t enu_pio_write_vi_base;
|
||||
/* Memory BAR mapping regions */
|
||||
uint32_t enu_uc_mem_map_offset;
|
||||
size_t enu_uc_mem_map_size;
|
||||
uint32_t enu_wc_mem_map_offset;
|
||||
size_t enu_wc_mem_map_size;
|
||||
} hunt;
|
||||
#endif /* EFSYS_OPT_HUNTINGTON */
|
||||
int enu_unused;
|
||||
} en_u;
|
||||
#if (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
|
||||
union en_arch {
|
||||
struct {
|
||||
int ena_vi_base;
|
||||
int ena_vi_count;
|
||||
#if EFSYS_OPT_VPD
|
||||
caddr_t ena_svpd;
|
||||
size_t ena_svpd_length;
|
||||
#endif /* EFSYS_OPT_VPD */
|
||||
efx_piobuf_handle_t ena_piobuf_handle[EF10_MAX_PIOBUF_NBUFS];
|
||||
uint32_t ena_piobuf_count;
|
||||
uint32_t ena_pio_alloc_map[EF10_MAX_PIOBUF_NBUFS];
|
||||
uint32_t ena_pio_write_vi_base;
|
||||
/* Memory BAR mapping regions */
|
||||
uint32_t ena_uc_mem_map_offset;
|
||||
size_t ena_uc_mem_map_size;
|
||||
uint32_t ena_wc_mem_map_offset;
|
||||
size_t ena_wc_mem_map_size;
|
||||
} ef10;
|
||||
} en_arch;
|
||||
#endif /* (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) */
|
||||
};
|
||||
|
||||
|
||||
|
@ -715,30 +715,30 @@ hunt_nic_alloc_piobufs(
|
||||
efx_rc_t rc;
|
||||
|
||||
EFSYS_ASSERT3U(max_piobuf_count, <=,
|
||||
EFX_ARRAY_SIZE(enp->en_u.hunt.enu_piobuf_handle));
|
||||
EFX_ARRAY_SIZE(enp->en_arch.ef10.ena_piobuf_handle));
|
||||
|
||||
enp->en_u.hunt.enu_piobuf_count = 0;
|
||||
enp->en_arch.ef10.ena_piobuf_count = 0;
|
||||
|
||||
for (i = 0; i < max_piobuf_count; i++) {
|
||||
handlep = &enp->en_u.hunt.enu_piobuf_handle[i];
|
||||
handlep = &enp->en_arch.ef10.ena_piobuf_handle[i];
|
||||
|
||||
if ((rc = efx_mcdi_alloc_piobuf(enp, handlep)) != 0)
|
||||
goto fail1;
|
||||
|
||||
enp->en_u.hunt.enu_pio_alloc_map[i] = 0;
|
||||
enp->en_u.hunt.enu_piobuf_count++;
|
||||
enp->en_arch.ef10.ena_pio_alloc_map[i] = 0;
|
||||
enp->en_arch.ef10.ena_piobuf_count++;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
fail1:
|
||||
for (i = 0; i < enp->en_u.hunt.enu_piobuf_count; i++) {
|
||||
handlep = &enp->en_u.hunt.enu_piobuf_handle[i];
|
||||
for (i = 0; i < enp->en_arch.ef10.ena_piobuf_count; i++) {
|
||||
handlep = &enp->en_arch.ef10.ena_piobuf_handle[i];
|
||||
|
||||
efx_mcdi_free_piobuf(enp, *handlep);
|
||||
*handlep = EFX_PIOBUF_HANDLE_INVALID;
|
||||
}
|
||||
enp->en_u.hunt.enu_piobuf_count = 0;
|
||||
enp->en_arch.ef10.ena_piobuf_count = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -749,13 +749,13 @@ hunt_nic_free_piobufs(
|
||||
efx_piobuf_handle_t *handlep;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < enp->en_u.hunt.enu_piobuf_count; i++) {
|
||||
handlep = &enp->en_u.hunt.enu_piobuf_handle[i];
|
||||
for (i = 0; i < enp->en_arch.ef10.ena_piobuf_count; i++) {
|
||||
handlep = &enp->en_arch.ef10.ena_piobuf_handle[i];
|
||||
|
||||
efx_mcdi_free_piobuf(enp, *handlep);
|
||||
*handlep = EFX_PIOBUF_HANDLE_INVALID;
|
||||
}
|
||||
enp->en_u.hunt.enu_piobuf_count = 0;
|
||||
enp->en_arch.ef10.ena_piobuf_count = 0;
|
||||
}
|
||||
|
||||
/* Sub-allocate a block from a piobuf */
|
||||
@ -781,14 +781,14 @@ hunt_nic_pio_alloc(
|
||||
EFSYS_ASSERT(sizep);
|
||||
|
||||
if ((edcp->edc_pio_alloc_size == 0) ||
|
||||
(enp->en_u.hunt.enu_piobuf_count == 0)) {
|
||||
(enp->en_arch.ef10.ena_piobuf_count == 0)) {
|
||||
rc = ENOMEM;
|
||||
goto fail1;
|
||||
}
|
||||
blk_per_buf = HUNT_PIOBUF_SIZE / edcp->edc_pio_alloc_size;
|
||||
|
||||
for (buf = 0; buf < enp->en_u.hunt.enu_piobuf_count; buf++) {
|
||||
uint32_t *map = &enp->en_u.hunt.enu_pio_alloc_map[buf];
|
||||
for (buf = 0; buf < enp->en_arch.ef10.ena_piobuf_count; buf++) {
|
||||
uint32_t *map = &enp->en_arch.ef10.ena_pio_alloc_map[buf];
|
||||
|
||||
if (~(*map) == 0)
|
||||
continue;
|
||||
@ -805,7 +805,7 @@ hunt_nic_pio_alloc(
|
||||
goto fail2;
|
||||
|
||||
done:
|
||||
*handlep = enp->en_u.hunt.enu_piobuf_handle[buf];
|
||||
*handlep = enp->en_arch.ef10.ena_piobuf_handle[buf];
|
||||
*bufnump = buf;
|
||||
*blknump = blk;
|
||||
*sizep = edcp->edc_pio_alloc_size;
|
||||
@ -831,13 +831,13 @@ hunt_nic_pio_free(
|
||||
uint32_t *map;
|
||||
efx_rc_t rc;
|
||||
|
||||
if ((bufnum >= enp->en_u.hunt.enu_piobuf_count) ||
|
||||
if ((bufnum >= enp->en_arch.ef10.ena_piobuf_count) ||
|
||||
(blknum >= (8 * sizeof (*map)))) {
|
||||
rc = EINVAL;
|
||||
goto fail1;
|
||||
}
|
||||
|
||||
map = &enp->en_u.hunt.enu_pio_alloc_map[bufnum];
|
||||
map = &enp->en_arch.ef10.ena_pio_alloc_map[bufnum];
|
||||
if ((*map & (1u << blknum)) == 0) {
|
||||
rc = ENOENT;
|
||||
goto fail2;
|
||||
@ -1579,7 +1579,8 @@ hunt_nic_init(
|
||||
* each VI that is using a sub-allocated block from the piobuf.
|
||||
*/
|
||||
min_vi_count = edcp->edc_min_vi_count;
|
||||
max_vi_count = edcp->edc_max_vi_count + enp->en_u.hunt.enu_piobuf_count;
|
||||
max_vi_count =
|
||||
edcp->edc_max_vi_count + enp->en_arch.ef10.ena_piobuf_count;
|
||||
|
||||
/* Ensure that the previously attached driver's VIs are freed */
|
||||
if ((rc = efx_mcdi_free_vis(enp)) != 0)
|
||||
@ -1601,44 +1602,44 @@ hunt_nic_init(
|
||||
goto fail4;
|
||||
}
|
||||
|
||||
enp->en_u.hunt.enu_vi_base = vi_base;
|
||||
enp->en_u.hunt.enu_vi_count = vi_count;
|
||||
enp->en_arch.ef10.ena_vi_base = vi_base;
|
||||
enp->en_arch.ef10.ena_vi_count = vi_count;
|
||||
|
||||
if (vi_count < min_vi_count + enp->en_u.hunt.enu_piobuf_count) {
|
||||
if (vi_count < min_vi_count + enp->en_arch.ef10.ena_piobuf_count) {
|
||||
/* Not enough extra VIs to map piobufs */
|
||||
hunt_nic_free_piobufs(enp);
|
||||
}
|
||||
|
||||
enp->en_u.hunt.enu_pio_write_vi_base =
|
||||
vi_count - enp->en_u.hunt.enu_piobuf_count;
|
||||
enp->en_arch.ef10.ena_pio_write_vi_base =
|
||||
vi_count - enp->en_arch.ef10.ena_piobuf_count;
|
||||
|
||||
/* Save UC memory mapping details */
|
||||
enp->en_u.hunt.enu_uc_mem_map_offset = 0;
|
||||
if (enp->en_u.hunt.enu_piobuf_count > 0) {
|
||||
enp->en_u.hunt.enu_uc_mem_map_size =
|
||||
enp->en_arch.ef10.ena_uc_mem_map_offset = 0;
|
||||
if (enp->en_arch.ef10.ena_piobuf_count > 0) {
|
||||
enp->en_arch.ef10.ena_uc_mem_map_size =
|
||||
(ER_DZ_TX_PIOBUF_STEP *
|
||||
enp->en_u.hunt.enu_pio_write_vi_base);
|
||||
enp->en_arch.ef10.ena_pio_write_vi_base);
|
||||
} else {
|
||||
enp->en_u.hunt.enu_uc_mem_map_size =
|
||||
enp->en_arch.ef10.ena_uc_mem_map_size =
|
||||
(ER_DZ_TX_PIOBUF_STEP *
|
||||
enp->en_u.hunt.enu_vi_count);
|
||||
enp->en_arch.ef10.ena_vi_count);
|
||||
}
|
||||
|
||||
/* Save WC memory mapping details */
|
||||
enp->en_u.hunt.enu_wc_mem_map_offset =
|
||||
enp->en_u.hunt.enu_uc_mem_map_offset +
|
||||
enp->en_u.hunt.enu_uc_mem_map_size;
|
||||
enp->en_arch.ef10.ena_wc_mem_map_offset =
|
||||
enp->en_arch.ef10.ena_uc_mem_map_offset +
|
||||
enp->en_arch.ef10.ena_uc_mem_map_size;
|
||||
|
||||
enp->en_u.hunt.enu_wc_mem_map_size =
|
||||
enp->en_arch.ef10.ena_wc_mem_map_size =
|
||||
(ER_DZ_TX_PIOBUF_STEP *
|
||||
enp->en_u.hunt.enu_piobuf_count);
|
||||
enp->en_arch.ef10.ena_piobuf_count);
|
||||
|
||||
/* Link piobufs to extra VIs in WC mapping */
|
||||
if (enp->en_u.hunt.enu_piobuf_count > 0) {
|
||||
for (i = 0; i < enp->en_u.hunt.enu_piobuf_count; i++) {
|
||||
if (enp->en_arch.ef10.ena_piobuf_count > 0) {
|
||||
for (i = 0; i < enp->en_arch.ef10.ena_piobuf_count; i++) {
|
||||
rc = efx_mcdi_link_piobuf(enp,
|
||||
enp->en_u.hunt.enu_pio_write_vi_base + i,
|
||||
enp->en_u.hunt.enu_piobuf_handle[i]);
|
||||
enp->en_arch.ef10.ena_pio_write_vi_base + i,
|
||||
enp->en_arch.ef10.ena_piobuf_handle[i]);
|
||||
if (rc != 0)
|
||||
break;
|
||||
}
|
||||
@ -1715,7 +1716,7 @@ hunt_nic_get_vi_pool(
|
||||
* Report VIs that the client driver can use.
|
||||
* Do not include VIs used for PIO buffer writes.
|
||||
*/
|
||||
*vi_countp = enp->en_u.hunt.enu_pio_write_vi_base;
|
||||
*vi_countp = enp->en_arch.ef10.ena_pio_write_vi_base;
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -1739,14 +1740,14 @@ hunt_nic_get_bar_region(
|
||||
switch (region) {
|
||||
case EFX_REGION_VI:
|
||||
/* UC mapped memory BAR region for VI registers */
|
||||
*offsetp = enp->en_u.hunt.enu_uc_mem_map_offset;
|
||||
*sizep = enp->en_u.hunt.enu_uc_mem_map_size;
|
||||
*offsetp = enp->en_arch.ef10.ena_uc_mem_map_offset;
|
||||
*sizep = enp->en_arch.ef10.ena_uc_mem_map_size;
|
||||
break;
|
||||
|
||||
case EFX_REGION_PIO_WRITE_VI:
|
||||
/* WC mapped memory BAR region for piobuf writes */
|
||||
*offsetp = enp->en_u.hunt.enu_wc_mem_map_offset;
|
||||
*sizep = enp->en_u.hunt.enu_wc_mem_map_size;
|
||||
*offsetp = enp->en_arch.ef10.ena_wc_mem_map_offset;
|
||||
*sizep = enp->en_arch.ef10.ena_wc_mem_map_size;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1773,10 +1774,10 @@ hunt_nic_fini(
|
||||
enp->en_vport_id = 0;
|
||||
|
||||
/* Unlink piobufs from extra VIs in WC mapping */
|
||||
if (enp->en_u.hunt.enu_piobuf_count > 0) {
|
||||
for (i = 0; i < enp->en_u.hunt.enu_piobuf_count; i++) {
|
||||
if (enp->en_arch.ef10.ena_piobuf_count > 0) {
|
||||
for (i = 0; i < enp->en_arch.ef10.ena_piobuf_count; i++) {
|
||||
rc = efx_mcdi_unlink_piobuf(enp,
|
||||
enp->en_u.hunt.enu_pio_write_vi_base + i);
|
||||
enp->en_arch.ef10.ena_pio_write_vi_base + i);
|
||||
if (rc != 0)
|
||||
break;
|
||||
}
|
||||
@ -1785,7 +1786,7 @@ hunt_nic_fini(
|
||||
hunt_nic_free_piobufs(enp);
|
||||
|
||||
(void) efx_mcdi_free_vis(enp);
|
||||
enp->en_u.hunt.enu_vi_count = 0;
|
||||
enp->en_arch.ef10.ena_vi_count = 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -81,8 +81,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);
|
||||
@ -197,7 +197,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 +213,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)
|
||||
@ -254,14 +254,14 @@ hunt_vpd_reinit(
|
||||
/*
|
||||
* 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;
|
||||
@ -298,13 +298,13 @@ hunt_vpd_get(
|
||||
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON);
|
||||
|
||||
/* 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;
|
||||
@ -340,12 +340,12 @@ hunt_vpd_set(
|
||||
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON);
|
||||
|
||||
/* 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;
|
||||
@ -421,12 +421,12 @@ hunt_vpd_fini(
|
||||
{
|
||||
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define MEDFORD_PIOBUF_NBUFS (16)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
Reference in New Issue
Block a user