Page MenuHomeFreeBSD

D4909.id12239.diff
No OneTemporary

D4909.id12239.diff

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
@@ -456,8 +456,8 @@
typedef struct efx_mcdi_ops_s {
efx_rc_t (*emco_init)(efx_nic_t *, const efx_mcdi_transport_t *);
- void (*emco_request_copyin)(efx_nic_t *, efx_mcdi_req_t *,
- unsigned int, boolean_t, boolean_t);
+ void (*emco_send_request)(efx_nic_t *, void *, size_t,
+ void *, size_t);
void (*emco_request_copyout)(efx_nic_t *, efx_mcdi_req_t *);
efx_rc_t (*emco_poll_reboot)(efx_nic_t *);
boolean_t (*emco_poll_response)(efx_nic_t *);
Index: head/sys/dev/sfxge/common/efx_mcdi.c
===================================================================
--- head/sys/dev/sfxge/common/efx_mcdi.c
+++ head/sys/dev/sfxge/common/efx_mcdi.c
@@ -40,12 +40,32 @@
#if EFSYS_OPT_MCDI
+/*
+ * There are three versions of the MCDI interface:
+ * - MCDIv0: Siena BootROM. Transport uses MCDIv1 headers.
+ * - MCDIv1: Siena firmware and Huntington BootROM.
+ * - MCDIv2: EF10 firmware (Huntington/Medford) and Medford BootROM.
+ * Transport uses MCDIv2 headers.
+ *
+ * MCDIv2 Header NOT_EPOCH flag
+ * ----------------------------
+ * A new epoch begins at initial startup or after an MC reboot, and defines when
+ * the MC should reject stale MCDI requests.
+ *
+ * The first MCDI request sent by the host should contain NOT_EPOCH=0, and all
+ * subsequent requests (until the next MC reboot) should contain NOT_EPOCH=1.
+ *
+ * After rebooting the MC will fail all requests with NOT_EPOCH=1 by writing a
+ * response with ERROR=1 and DATALEN=0 until a request is seen with NOT_EPOCH=0.
+ */
+
+
#if EFSYS_OPT_SIENA
static efx_mcdi_ops_t __efx_mcdi_siena_ops = {
siena_mcdi_init, /* emco_init */
- siena_mcdi_request_copyin, /* emco_request_copyin */
+ siena_mcdi_send_request, /* emco_send_request */
siena_mcdi_request_copyout, /* emco_request_copyout */
siena_mcdi_poll_reboot, /* emco_poll_reboot */
siena_mcdi_poll_response, /* emco_poll_response */
@@ -60,7 +80,7 @@
static efx_mcdi_ops_t __efx_mcdi_ef10_ops = {
ef10_mcdi_init, /* emco_init */
- ef10_mcdi_request_copyin, /* emco_request_copyin */
+ ef10_mcdi_send_request, /* emco_send_request */
ef10_mcdi_request_copyout, /* emco_request_copyout */
ef10_mcdi_poll_reboot, /* emco_poll_reboot */
ef10_mcdi_poll_response, /* emco_poll_response */
@@ -183,16 +203,16 @@
}
static void
-efx_mcdi_request_copyin(
+efx_mcdi_send_request(
__in efx_nic_t *enp,
- __in efx_mcdi_req_t *emrp,
- __in unsigned int seq,
- __in boolean_t ev_cpl,
- __in boolean_t new_epoch)
+ __in void *hdrp,
+ __in size_t hdr_len,
+ __in void *sdup,
+ __in size_t sdu_len)
{
efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
- emcop->emco_request_copyin(enp, emrp, seq, ev_cpl, new_epoch);
+ emcop->emco_send_request(enp, hdrp, hdr_len, sdup, sdu_len);
}
static void
@@ -245,8 +265,15 @@
__in efx_mcdi_req_t *emrp,
__in boolean_t ev_cpl)
{
+#if EFSYS_OPT_MCDI_LOGGING
+ const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
+#endif
efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
+ efx_dword_t hdr[2];
+ size_t hdr_len;
+ unsigned int max_version;
unsigned int seq;
+ unsigned int xflags;
boolean_t new_epoch;
int state;
@@ -273,9 +300,60 @@
emip->emi_poll_cnt = 0;
seq = emip->emi_seq++ & EFX_MASK32(MCDI_HEADER_SEQ);
new_epoch = emip->emi_new_epoch;
+ max_version = emip->emi_max_version;
EFSYS_UNLOCK(enp->en_eslp, state);
- efx_mcdi_request_copyin(enp, emrp, seq, ev_cpl, new_epoch);
+ xflags = 0;
+ if (ev_cpl)
+ xflags |= MCDI_HEADER_XFLAGS_EVREQ;
+
+ /*
+ * Huntington firmware supports MCDIv2, but the Huntington BootROM only
+ * supports MCDIv1. Use MCDIv1 headers for MCDIv1 commands where
+ * possible to support this.
+ */
+ if ((max_version >= 2) &&
+ ((emrp->emr_cmd > MC_CMD_CMD_SPACE_ESCAPE_7) ||
+ (emrp->emr_in_length > MCDI_CTL_SDU_LEN_MAX_V1))) {
+ /* Construct MCDI v2 header */
+ hdr_len = sizeof (hdr);
+ EFX_POPULATE_DWORD_8(hdr[0],
+ MCDI_HEADER_CODE, MC_CMD_V2_EXTN,
+ MCDI_HEADER_RESYNC, 1,
+ MCDI_HEADER_DATALEN, 0,
+ MCDI_HEADER_SEQ, seq,
+ MCDI_HEADER_NOT_EPOCH, new_epoch ? 0 : 1,
+ MCDI_HEADER_ERROR, 0,
+ MCDI_HEADER_RESPONSE, 0,
+ MCDI_HEADER_XFLAGS, xflags);
+
+ EFX_POPULATE_DWORD_2(hdr[1],
+ MC_CMD_V2_EXTN_IN_EXTENDED_CMD, emrp->emr_cmd,
+ MC_CMD_V2_EXTN_IN_ACTUAL_LEN, emrp->emr_in_length);
+ } else {
+ /* Construct MCDI v1 header */
+ hdr_len = sizeof (hdr[0]);
+ EFX_POPULATE_DWORD_8(hdr[0],
+ MCDI_HEADER_CODE, emrp->emr_cmd,
+ MCDI_HEADER_RESYNC, 1,
+ MCDI_HEADER_DATALEN, emrp->emr_in_length,
+ MCDI_HEADER_SEQ, seq,
+ MCDI_HEADER_NOT_EPOCH, new_epoch ? 0 : 1,
+ MCDI_HEADER_ERROR, 0,
+ MCDI_HEADER_RESPONSE, 0,
+ MCDI_HEADER_XFLAGS, xflags);
+ }
+
+#if EFSYS_OPT_MCDI_LOGGING
+ if (emtp->emt_logger != NULL) {
+ emtp->emt_logger(emtp->emt_context, EFX_LOG_MCDI_REQUEST,
+ &hdr, hdr_len,
+ emrp->emr_in_buf, emrp->emr_in_length);
+ }
+#endif /* EFSYS_OPT_MCDI_LOGGING */
+
+ efx_mcdi_send_request(enp, &hdr[0], hdr_len,
+ emrp->emr_in_buf, emrp->emr_in_length);
}
Index: head/sys/dev/sfxge/common/hunt_impl.h
===================================================================
--- head/sys/dev/sfxge/common/hunt_impl.h
+++ head/sys/dev/sfxge/common/hunt_impl.h
@@ -276,12 +276,12 @@
__in efx_nic_t *enp);
extern void
-ef10_mcdi_request_copyin(
+ef10_mcdi_send_request(
__in efx_nic_t *enp,
- __in efx_mcdi_req_t *emrp,
- __in unsigned int seq,
- __in boolean_t ev_cpl,
- __in boolean_t new_epoch);
+ __in void *hdrp,
+ __in size_t hdr_len,
+ __in void *sdup,
+ __in size_t sdu_len);
extern __checkReturn boolean_t
ef10_mcdi_poll_response(
Index: head/sys/dev/sfxge/common/hunt_mcdi.c
===================================================================
--- head/sys/dev/sfxge/common/hunt_mcdi.c
+++ head/sys/dev/sfxge/common/hunt_mcdi.c
@@ -44,37 +44,6 @@
#error "WITH_MCDI_V2 required for EF10 MCDIv2 commands."
#endif
-typedef enum efx_mcdi_header_type_e {
- EFX_MCDI_HEADER_TYPE_V1, /* MCDIv0 (BootROM), MCDIv1 commands */
- EFX_MCDI_HEADER_TYPE_V2, /* MCDIv2 commands */
-} efx_mcdi_header_type_t;
-
-/*
- * Return the header format to use for sending an MCDI request.
- *
- * An MCDIv1 (Siena compatible) command should use MCDIv2 encapsulation if the
- * request input buffer or response output buffer are too large for the MCDIv1
- * format. An MCDIv2 command must always be sent using MCDIv2 encapsulation.
- */
-#define EFX_MCDI_HEADER_TYPE(_cmd, _length) \
- ((((_cmd) & ~EFX_MASK32(MCDI_HEADER_CODE)) || \
- ((_length) & ~EFX_MASK32(MCDI_HEADER_DATALEN))) ? \
- EFX_MCDI_HEADER_TYPE_V2 : EFX_MCDI_HEADER_TYPE_V1)
-
-
-/*
- * MCDI Header NOT_EPOCH flag
- * ==========================
- * A new epoch begins at initial startup or after an MC reboot, and defines when
- * the MC should reject stale MCDI requests.
- *
- * The first MCDI request sent by the host should contain NOT_EPOCH=0, and all
- * subsequent requests (until the next MC reboot) should contain NOT_EPOCH=1.
- *
- * After rebooting the MC will fail all requests with NOT_EPOCH=1 by writing a
- * response with ERROR=1 and DATALEN=0 until a request is seen with NOT_EPOCH=0.
- */
-
__checkReturn efx_rc_t
ef10_mcdi_init(
@@ -140,7 +109,7 @@
emip->emi_new_epoch = B_FALSE;
}
-static void
+ void
ef10_mcdi_send_request(
__in efx_nic_t *enp,
__in void *hdrp,
@@ -183,74 +152,6 @@
}
void
-ef10_mcdi_request_copyin(
- __in efx_nic_t *enp,
- __in efx_mcdi_req_t *emrp,
- __in unsigned int seq,
- __in boolean_t ev_cpl,
- __in boolean_t new_epoch)
-{
-#if EFSYS_OPT_MCDI_LOGGING
- const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
-#endif /* EFSYS_OPT_MCDI_LOGGING */
- efx_mcdi_header_type_t hdr_type;
- efx_dword_t hdr[2];
- size_t hdr_len;
- unsigned int xflags;
-
- EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
- enp->en_family == EFX_FAMILY_MEDFORD);
-
- xflags = 0;
- if (ev_cpl)
- xflags |= MCDI_HEADER_XFLAGS_EVREQ;
-
- hdr_type = EFX_MCDI_HEADER_TYPE(emrp->emr_cmd,
- MAX(emrp->emr_in_length, emrp->emr_out_length));
-
- if (hdr_type == EFX_MCDI_HEADER_TYPE_V2) {
- /* Construct MCDI v2 header */
- hdr_len = sizeof (hdr);
- EFX_POPULATE_DWORD_8(hdr[0],
- MCDI_HEADER_CODE, MC_CMD_V2_EXTN,
- MCDI_HEADER_RESYNC, 1,
- MCDI_HEADER_DATALEN, 0,
- MCDI_HEADER_SEQ, seq,
- MCDI_HEADER_NOT_EPOCH, new_epoch ? 0 : 1,
- MCDI_HEADER_ERROR, 0,
- MCDI_HEADER_RESPONSE, 0,
- MCDI_HEADER_XFLAGS, xflags);
-
- EFX_POPULATE_DWORD_2(hdr[1],
- MC_CMD_V2_EXTN_IN_EXTENDED_CMD, emrp->emr_cmd,
- MC_CMD_V2_EXTN_IN_ACTUAL_LEN, emrp->emr_in_length);
- } else {
- /* Construct MCDI v1 header */
- hdr_len = sizeof (hdr[0]);
- EFX_POPULATE_DWORD_8(hdr[0],
- MCDI_HEADER_CODE, emrp->emr_cmd,
- MCDI_HEADER_RESYNC, 1,
- MCDI_HEADER_DATALEN, emrp->emr_in_length,
- MCDI_HEADER_SEQ, seq,
- MCDI_HEADER_NOT_EPOCH, new_epoch ? 0 : 1,
- MCDI_HEADER_ERROR, 0,
- MCDI_HEADER_RESPONSE, 0,
- MCDI_HEADER_XFLAGS, xflags);
- }
-
-#if EFSYS_OPT_MCDI_LOGGING
- if (emtp->emt_logger != NULL) {
- emtp->emt_logger(emtp->emt_context, EFX_LOG_MCDI_REQUEST,
- &hdr, hdr_len,
- emrp->emr_in_buf, emrp->emr_in_length);
- }
-#endif /* EFSYS_OPT_MCDI_LOGGING */
-
- ef10_mcdi_send_request(enp, &hdr[0], hdr_len,
- emrp->emr_in_buf, emrp->emr_in_length);
-}
-
- void
ef10_mcdi_request_copyout(
__in efx_nic_t *enp,
__in efx_mcdi_req_t *emrp)
Index: head/sys/dev/sfxge/common/siena_impl.h
===================================================================
--- head/sys/dev/sfxge/common/siena_impl.h
+++ head/sys/dev/sfxge/common/siena_impl.h
@@ -114,12 +114,12 @@
__in const efx_mcdi_transport_t *mtp);
extern void
-siena_mcdi_request_copyin(
+siena_mcdi_send_request(
__in efx_nic_t *enp,
- __in efx_mcdi_req_t *emrp,
- __in unsigned int seq,
- __in boolean_t ev_cpl,
- __in boolean_t new_epoch);
+ __in void *hdrp,
+ __in size_t hdr_len,
+ __in void *sdup,
+ __in size_t sdu_len);
extern __checkReturn boolean_t
siena_mcdi_poll_response(
Index: head/sys/dev/sfxge/common/siena_mcdi.c
===================================================================
--- head/sys/dev/sfxge/common/siena_mcdi.c
+++ head/sys/dev/sfxge/common/siena_mcdi.c
@@ -53,7 +53,7 @@
: MC_SMEM_P1_STATUS_OFST >> 2)
-static void
+ void
siena_mcdi_send_request(
__in efx_nic_t *enp,
__in void *hdrp,
@@ -91,50 +91,6 @@
}
void
-siena_mcdi_request_copyin(
- __in efx_nic_t *enp,
- __in efx_mcdi_req_t *emrp,
- __in unsigned int seq,
- __in boolean_t ev_cpl,
- __in boolean_t new_epoch)
-{
-#if EFSYS_OPT_MCDI_LOGGING
- const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
-#endif
- efx_dword_t hdr;
- size_t hdr_len;
- unsigned int xflags;
-
- EFSYS_ASSERT(enp->en_family == EFX_FAMILY_SIENA);
- _NOTE(ARGUNUSED(new_epoch))
-
- xflags = 0;
- if (ev_cpl)
- xflags |= MCDI_HEADER_XFLAGS_EVREQ;
-
- /* Construct the header */
- hdr_len = sizeof (hdr);
- EFX_POPULATE_DWORD_6(hdr,
- MCDI_HEADER_CODE, emrp->emr_cmd,
- MCDI_HEADER_RESYNC, 1,
- MCDI_HEADER_DATALEN, emrp->emr_in_length,
- MCDI_HEADER_SEQ, seq,
- MCDI_HEADER_RESPONSE, 0,
- MCDI_HEADER_XFLAGS, xflags);
-
-#if EFSYS_OPT_MCDI_LOGGING
- if (emtp->emt_logger != NULL) {
- emtp->emt_logger(emtp->emt_context, EFX_LOG_MCDI_REQUEST,
- &hdr, sizeof (hdr),
- emrp->emr_in_buf, emrp->emr_in_length);
- }
-#endif /* EFSYS_OPT_MCDI_LOGGING */
-
- siena_mcdi_send_request(enp, &hdr, hdr_len,
- emrp->emr_in_buf, emrp->emr_in_length);
-}
-
- void
siena_mcdi_request_copyout(
__in efx_nic_t *enp,
__in efx_mcdi_req_t *emrp)

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 12:12 AM (2 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15536594
Default Alt Text
D4909.id12239.diff (11 KB)

Event Timeline