Index: head/sys/dev/sfxge/common/ef10_impl.h =================================================================== --- head/sys/dev/sfxge/common/ef10_impl.h +++ head/sys/dev/sfxge/common/ef10_impl.h @@ -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 Index: head/sys/dev/sfxge/common/efx_impl.h =================================================================== --- head/sys/dev/sfxge/common/efx_impl.h +++ head/sys/dev/sfxge/common/efx_impl.h @@ -672,26 +672,29 @@ int enu_unused; } siena; #endif /* EFSYS_OPT_SIENA */ -#if EFSYS_OPT_HUNTINGTON + int enu_unused; + } en_u; +#if (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) + union en_arch { struct { - int enu_vi_base; - int enu_vi_count; + int ena_vi_base; + int ena_vi_count; #if EFSYS_OPT_VPD - caddr_t enu_svpd; - size_t enu_svpd_length; + caddr_t ena_svpd; + size_t ena_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; + 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 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 */ - } en_u; + 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) */ }; Index: head/sys/dev/sfxge/common/hunt_nic.c =================================================================== --- head/sys/dev/sfxge/common/hunt_nic.c +++ head/sys/dev/sfxge/common/hunt_nic.c @@ -715,30 +715,30 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ * 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 @@ 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 @@ 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_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 Index: head/sys/dev/sfxge/common/hunt_vpd.c =================================================================== --- head/sys/dev/sfxge/common/hunt_vpd.c +++ head/sys/dev/sfxge/common/hunt_vpd.c @@ -81,8 +81,8 @@ 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 @@ * 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 @@ _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 @@ /* * 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 @@ 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 @@ 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 @@ { 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; } } Index: head/sys/dev/sfxge/common/medford_impl.h =================================================================== --- head/sys/dev/sfxge/common/medford_impl.h +++ head/sys/dev/sfxge/common/medford_impl.h @@ -37,7 +37,7 @@ extern "C" { #endif - +#define MEDFORD_PIOBUF_NBUFS (16) #ifdef __cplusplus