common/sfc_efx/base: add API to get Rx prefix information
[dpdk.git] / drivers / common / sfc_efx / base / ef10_rx.c
index 2f0d2d2..43d545b 100644 (file)
@@ -549,8 +549,8 @@ fail1:
 #if EFX_OPTS_EF10()
 
 /*
- * EF10 RX pseudo-header
- * ---------------------
+ * EF10 RX pseudo-header (aka Rx prefix)
+ * -------------------------------------
  *
  * Receive packets are prefixed by an (optional) 14 byte pseudo-header:
  *
@@ -566,7 +566,77 @@ fail1:
  *       (32bit little-endian)
  *
  * See "The RX Pseudo-header" in SF-109306-TC.
+ *
+ * EF10 does not support Rx prefix choice using MC_CMD_GET_RX_PREFIX_ID
+ * and query its layout using MC_CMD_QUERY_RX_PREFIX_ID.
  */
+static const efx_rx_prefix_layout_t ef10_default_rx_prefix_layout = {
+       .erpl_id        = 0,
+       .erpl_length    = 14,
+       .erpl_fields    = {
+               [EFX_RX_PREFIX_FIELD_RSS_HASH]                  =
+                   { 0,  32, B_FALSE },
+               [EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI]            =
+                   { 32, 16, B_TRUE },
+               [EFX_RX_PREFIX_FIELD_INNER_VLAN_STRIP_TCI]      =
+                   { 48, 16, B_TRUE },
+               [EFX_RX_PREFIX_FIELD_LENGTH]                    =
+                   { 64, 16, B_FALSE },
+               [EFX_RX_PREFIX_FIELD_PARTIAL_TSTAMP]            =
+                   { 80, 32, B_FALSE },
+       }
+};
+
+#if EFSYS_OPT_RX_PACKED_STREAM
+
+/*
+ * EF10 packed stream Rx prefix layout.
+ *
+ * See SF-112241-TC Full speed capture for Huntington and Medford section 4.5.
+ */
+static const efx_rx_prefix_layout_t ef10_packed_stream_rx_prefix_layout = {
+       .erpl_id        = 0,
+       .erpl_length    = 8,
+       .erpl_fields    = {
+#define        EF10_PS_RX_PREFIX_FIELD(_efx, _ef10) \
+       EFX_RX_PREFIX_FIELD(_efx, ES_DZ_PS_RX_PREFIX_ ## _ef10, B_FALSE)
+
+               EF10_PS_RX_PREFIX_FIELD(PARTIAL_TSTAMP, TSTAMP),
+               EF10_PS_RX_PREFIX_FIELD(LENGTH, CAP_LEN),
+               EF10_PS_RX_PREFIX_FIELD(ORIG_LENGTH, ORIG_LEN),
+
+#undef EF10_PS_RX_PREFIX_FIELD
+       }
+};
+
+#endif /* EFSYS_OPT_RX_PACKED_STREAM */
+
+#if EFSYS_OPT_RX_ES_SUPER_BUFFER
+
+/*
+ * EF10 equal stride super-buffer Rx prefix layout.
+ *
+ * See SF-119419-TC DPDK Firmware Driver Interface section 3.4.
+ */
+static const efx_rx_prefix_layout_t ef10_essb_rx_prefix_layout = {
+       .erpl_id        = 0,
+       .erpl_length    = ES_EZ_ESSB_RX_PREFIX_LEN,
+       .erpl_fields    = {
+#define        EF10_ESSB_RX_PREFIX_FIELD(_efx, _ef10) \
+       EFX_RX_PREFIX_FIELD(_efx, ES_EZ_ESSB_RX_PREFIX_ ## _ef10, B_FALSE)
+
+               EF10_ESSB_RX_PREFIX_FIELD(LENGTH, DATA_LEN),
+               EF10_ESSB_RX_PREFIX_FIELD(USER_MARK, MARK),
+               EF10_ESSB_RX_PREFIX_FIELD(RSS_HASH_VALID, HASH_VALID),
+               EF10_ESSB_RX_PREFIX_FIELD(USER_MARK_VALID, MARK_VALID),
+               EF10_ESSB_RX_PREFIX_FIELD(USER_FLAG, MATCH_FLAG),
+               EF10_ESSB_RX_PREFIX_FIELD(RSS_HASH, HASH),
+
+#undef EF10_ESSB_RX_PREFIX_FIELD
+       }
+};
+
+#endif /* EFSYS_OPT_RX_ES_SUPER_BUFFER */
 
        __checkReturn   efx_rc_t
 ef10_rx_prefix_pktlen(
@@ -836,6 +906,7 @@ ef10_rx_qcreate(
        __in            efx_rxq_t *erp)
 {
        efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
+       const efx_rx_prefix_layout_t *erpl;
        efx_rc_t rc;
        boolean_t disable_scatter;
        boolean_t want_inner_classes;
@@ -852,6 +923,7 @@ ef10_rx_qcreate(
 
        switch (type) {
        case EFX_RXQ_TYPE_DEFAULT:
+               erpl = &ef10_default_rx_prefix_layout;
                if (type_data == NULL) {
                        rc = EINVAL;
                        goto fail1;
@@ -861,6 +933,7 @@ ef10_rx_qcreate(
                break;
 #if EFSYS_OPT_RX_PACKED_STREAM
        case EFX_RXQ_TYPE_PACKED_STREAM:
+               erpl = &ef10_packed_stream_rx_prefix_layout;
                if (type_data == NULL) {
                        rc = EINVAL;
                        goto fail2;
@@ -890,6 +963,7 @@ ef10_rx_qcreate(
 #endif /* EFSYS_OPT_RX_PACKED_STREAM */
 #if EFSYS_OPT_RX_ES_SUPER_BUFFER
        case EFX_RXQ_TYPE_ES_SUPER_BUFFER:
+               erpl = &ef10_essb_rx_prefix_layout;
                if (type_data == NULL) {
                        rc = EINVAL;
                        goto fail4;
@@ -973,6 +1047,8 @@ ef10_rx_qcreate(
 
        erp->er_ev_qstate = &erp->er_eep->ee_rxq_state[label];
 
+       erp->er_prefix_layout = *erpl;
+
        return (0);
 
 fail11: