2 * Copyright (c) 2012-2016 Solarflare Communications Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * The views and conclusions contained in the software and documentation are
27 * those of the authors and should not be interpreted as representing official
28 * policies, either expressed or implied, of the FreeBSD Project.
35 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
38 static __checkReturn efx_rc_t
42 __in uint32_t target_evq,
44 __in uint32_t instance,
45 __in efsys_mem_t *esmp,
46 __in boolean_t disable_scatter,
47 __in uint32_t ps_bufsize)
50 uint8_t payload[MAX(MC_CMD_INIT_RXQ_EXT_IN_LEN,
51 MC_CMD_INIT_RXQ_EXT_OUT_LEN)];
52 int npages = EFX_RXQ_NBUFS(size);
54 efx_qword_t *dma_addr;
59 /* If this changes, then the payload size might need to change. */
60 EFSYS_ASSERT3U(MC_CMD_INIT_RXQ_OUT_LEN, ==, 0);
61 EFSYS_ASSERT3U(size, <=, EFX_RXQ_MAXNDESCS);
64 dma_mode = MC_CMD_INIT_RXQ_EXT_IN_PACKED_STREAM;
66 dma_mode = MC_CMD_INIT_RXQ_EXT_IN_SINGLE_PACKET;
68 (void) memset(payload, 0, sizeof (payload));
69 req.emr_cmd = MC_CMD_INIT_RXQ;
70 req.emr_in_buf = payload;
71 req.emr_in_length = MC_CMD_INIT_RXQ_EXT_IN_LEN;
72 req.emr_out_buf = payload;
73 req.emr_out_length = MC_CMD_INIT_RXQ_EXT_OUT_LEN;
75 MCDI_IN_SET_DWORD(req, INIT_RXQ_EXT_IN_SIZE, size);
76 MCDI_IN_SET_DWORD(req, INIT_RXQ_EXT_IN_TARGET_EVQ, target_evq);
77 MCDI_IN_SET_DWORD(req, INIT_RXQ_EXT_IN_LABEL, label);
78 MCDI_IN_SET_DWORD(req, INIT_RXQ_EXT_IN_INSTANCE, instance);
79 MCDI_IN_POPULATE_DWORD_8(req, INIT_RXQ_EXT_IN_FLAGS,
80 INIT_RXQ_EXT_IN_FLAG_BUFF_MODE, 0,
81 INIT_RXQ_EXT_IN_FLAG_HDR_SPLIT, 0,
82 INIT_RXQ_EXT_IN_FLAG_TIMESTAMP, 0,
83 INIT_RXQ_EXT_IN_CRC_MODE, 0,
84 INIT_RXQ_EXT_IN_FLAG_PREFIX, 1,
85 INIT_RXQ_EXT_IN_FLAG_DISABLE_SCATTER, disable_scatter,
86 INIT_RXQ_EXT_IN_DMA_MODE,
88 INIT_RXQ_EXT_IN_PACKED_STREAM_BUFF_SIZE, ps_bufsize);
89 MCDI_IN_SET_DWORD(req, INIT_RXQ_EXT_IN_OWNER_ID, 0);
90 MCDI_IN_SET_DWORD(req, INIT_RXQ_EXT_IN_PORT_ID, EVB_PORT_ID_ASSIGNED);
92 dma_addr = MCDI_IN2(req, efx_qword_t, INIT_RXQ_IN_DMA_ADDR);
93 addr = EFSYS_MEM_ADDR(esmp);
95 for (i = 0; i < npages; i++) {
96 EFX_POPULATE_QWORD_2(*dma_addr,
97 EFX_DWORD_1, (uint32_t)(addr >> 32),
98 EFX_DWORD_0, (uint32_t)(addr & 0xffffffff));
101 addr += EFX_BUF_SIZE;
104 efx_mcdi_execute(enp, &req);
106 if (req.emr_rc != 0) {
114 EFSYS_PROBE1(fail1, efx_rc_t, rc);
119 static __checkReturn efx_rc_t
122 __in uint32_t instance)
125 uint8_t payload[MAX(MC_CMD_FINI_RXQ_IN_LEN,
126 MC_CMD_FINI_RXQ_OUT_LEN)];
129 (void) memset(payload, 0, sizeof (payload));
130 req.emr_cmd = MC_CMD_FINI_RXQ;
131 req.emr_in_buf = payload;
132 req.emr_in_length = MC_CMD_FINI_RXQ_IN_LEN;
133 req.emr_out_buf = payload;
134 req.emr_out_length = MC_CMD_FINI_RXQ_OUT_LEN;
136 MCDI_IN_SET_DWORD(req, FINI_RXQ_IN_INSTANCE, instance);
138 efx_mcdi_execute_quiet(enp, &req);
140 if (req.emr_rc != 0) {
149 * EALREADY is not an error, but indicates that the MC has rebooted and
150 * that the RXQ has already been destroyed.
153 EFSYS_PROBE1(fail1, efx_rc_t, rc);
158 #if EFSYS_OPT_RX_SCALE
159 static __checkReturn efx_rc_t
160 efx_mcdi_rss_context_alloc(
162 __in efx_rx_scale_context_type_t type,
163 __in uint32_t num_queues,
164 __out uint32_t *rss_contextp)
167 uint8_t payload[MAX(MC_CMD_RSS_CONTEXT_ALLOC_IN_LEN,
168 MC_CMD_RSS_CONTEXT_ALLOC_OUT_LEN)];
169 uint32_t rss_context;
170 uint32_t context_type;
173 if (num_queues > EFX_MAXRSS) {
179 case EFX_RX_SCALE_EXCLUSIVE:
180 context_type = MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_EXCLUSIVE;
182 case EFX_RX_SCALE_SHARED:
183 context_type = MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_SHARED;
190 (void) memset(payload, 0, sizeof (payload));
191 req.emr_cmd = MC_CMD_RSS_CONTEXT_ALLOC;
192 req.emr_in_buf = payload;
193 req.emr_in_length = MC_CMD_RSS_CONTEXT_ALLOC_IN_LEN;
194 req.emr_out_buf = payload;
195 req.emr_out_length = MC_CMD_RSS_CONTEXT_ALLOC_OUT_LEN;
197 MCDI_IN_SET_DWORD(req, RSS_CONTEXT_ALLOC_IN_UPSTREAM_PORT_ID,
198 EVB_PORT_ID_ASSIGNED);
199 MCDI_IN_SET_DWORD(req, RSS_CONTEXT_ALLOC_IN_TYPE, context_type);
200 /* NUM_QUEUES is only used to validate indirection table offsets */
201 MCDI_IN_SET_DWORD(req, RSS_CONTEXT_ALLOC_IN_NUM_QUEUES, num_queues);
203 efx_mcdi_execute(enp, &req);
205 if (req.emr_rc != 0) {
210 if (req.emr_out_length_used < MC_CMD_RSS_CONTEXT_ALLOC_OUT_LEN) {
215 rss_context = MCDI_OUT_DWORD(req, RSS_CONTEXT_ALLOC_OUT_RSS_CONTEXT_ID);
216 if (rss_context == EF10_RSS_CONTEXT_INVALID) {
221 *rss_contextp = rss_context;
234 EFSYS_PROBE1(fail1, efx_rc_t, rc);
238 #endif /* EFSYS_OPT_RX_SCALE */
240 #if EFSYS_OPT_RX_SCALE
242 efx_mcdi_rss_context_free(
244 __in uint32_t rss_context)
247 uint8_t payload[MAX(MC_CMD_RSS_CONTEXT_FREE_IN_LEN,
248 MC_CMD_RSS_CONTEXT_FREE_OUT_LEN)];
251 if (rss_context == EF10_RSS_CONTEXT_INVALID) {
256 (void) memset(payload, 0, sizeof (payload));
257 req.emr_cmd = MC_CMD_RSS_CONTEXT_FREE;
258 req.emr_in_buf = payload;
259 req.emr_in_length = MC_CMD_RSS_CONTEXT_FREE_IN_LEN;
260 req.emr_out_buf = payload;
261 req.emr_out_length = MC_CMD_RSS_CONTEXT_FREE_OUT_LEN;
263 MCDI_IN_SET_DWORD(req, RSS_CONTEXT_FREE_IN_RSS_CONTEXT_ID, rss_context);
265 efx_mcdi_execute_quiet(enp, &req);
267 if (req.emr_rc != 0) {
277 EFSYS_PROBE1(fail1, efx_rc_t, rc);
281 #endif /* EFSYS_OPT_RX_SCALE */
283 #if EFSYS_OPT_RX_SCALE
285 efx_mcdi_rss_context_set_flags(
287 __in uint32_t rss_context,
288 __in efx_rx_hash_type_t type)
291 uint8_t payload[MAX(MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_LEN,
292 MC_CMD_RSS_CONTEXT_SET_FLAGS_OUT_LEN)];
295 if (rss_context == EF10_RSS_CONTEXT_INVALID) {
300 (void) memset(payload, 0, sizeof (payload));
301 req.emr_cmd = MC_CMD_RSS_CONTEXT_SET_FLAGS;
302 req.emr_in_buf = payload;
303 req.emr_in_length = MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_LEN;
304 req.emr_out_buf = payload;
305 req.emr_out_length = MC_CMD_RSS_CONTEXT_SET_FLAGS_OUT_LEN;
307 MCDI_IN_SET_DWORD(req, RSS_CONTEXT_SET_FLAGS_IN_RSS_CONTEXT_ID,
310 MCDI_IN_POPULATE_DWORD_4(req, RSS_CONTEXT_SET_FLAGS_IN_FLAGS,
311 RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_IPV4_EN,
312 (type & EFX_RX_HASH_IPV4) ? 1 : 0,
313 RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_TCPV4_EN,
314 (type & EFX_RX_HASH_TCPIPV4) ? 1 : 0,
315 RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_IPV6_EN,
316 (type & EFX_RX_HASH_IPV6) ? 1 : 0,
317 RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_TCPV6_EN,
318 (type & EFX_RX_HASH_TCPIPV6) ? 1 : 0);
320 efx_mcdi_execute(enp, &req);
322 if (req.emr_rc != 0) {
332 EFSYS_PROBE1(fail1, efx_rc_t, rc);
336 #endif /* EFSYS_OPT_RX_SCALE */
338 #if EFSYS_OPT_RX_SCALE
340 efx_mcdi_rss_context_set_key(
342 __in uint32_t rss_context,
343 __in_ecount(n) uint8_t *key,
347 uint8_t payload[MAX(MC_CMD_RSS_CONTEXT_SET_KEY_IN_LEN,
348 MC_CMD_RSS_CONTEXT_SET_KEY_OUT_LEN)];
351 if (rss_context == EF10_RSS_CONTEXT_INVALID) {
356 (void) memset(payload, 0, sizeof (payload));
357 req.emr_cmd = MC_CMD_RSS_CONTEXT_SET_KEY;
358 req.emr_in_buf = payload;
359 req.emr_in_length = MC_CMD_RSS_CONTEXT_SET_KEY_IN_LEN;
360 req.emr_out_buf = payload;
361 req.emr_out_length = MC_CMD_RSS_CONTEXT_SET_KEY_OUT_LEN;
363 MCDI_IN_SET_DWORD(req, RSS_CONTEXT_SET_KEY_IN_RSS_CONTEXT_ID,
366 EFSYS_ASSERT3U(n, ==, MC_CMD_RSS_CONTEXT_SET_KEY_IN_TOEPLITZ_KEY_LEN);
367 if (n != MC_CMD_RSS_CONTEXT_SET_KEY_IN_TOEPLITZ_KEY_LEN) {
372 memcpy(MCDI_IN2(req, uint8_t, RSS_CONTEXT_SET_KEY_IN_TOEPLITZ_KEY),
375 efx_mcdi_execute(enp, &req);
377 if (req.emr_rc != 0) {
389 EFSYS_PROBE1(fail1, efx_rc_t, rc);
393 #endif /* EFSYS_OPT_RX_SCALE */
395 #if EFSYS_OPT_RX_SCALE
397 efx_mcdi_rss_context_set_table(
399 __in uint32_t rss_context,
400 __in_ecount(n) unsigned int *table,
404 uint8_t payload[MAX(MC_CMD_RSS_CONTEXT_SET_TABLE_IN_LEN,
405 MC_CMD_RSS_CONTEXT_SET_TABLE_OUT_LEN)];
409 if (rss_context == EF10_RSS_CONTEXT_INVALID) {
414 (void) memset(payload, 0, sizeof (payload));
415 req.emr_cmd = MC_CMD_RSS_CONTEXT_SET_TABLE;
416 req.emr_in_buf = payload;
417 req.emr_in_length = MC_CMD_RSS_CONTEXT_SET_TABLE_IN_LEN;
418 req.emr_out_buf = payload;
419 req.emr_out_length = MC_CMD_RSS_CONTEXT_SET_TABLE_OUT_LEN;
421 MCDI_IN_SET_DWORD(req, RSS_CONTEXT_SET_TABLE_IN_RSS_CONTEXT_ID,
425 MCDI_IN2(req, uint8_t, RSS_CONTEXT_SET_TABLE_IN_INDIRECTION_TABLE);
428 i < MC_CMD_RSS_CONTEXT_SET_TABLE_IN_INDIRECTION_TABLE_LEN;
430 req_table[i] = (n > 0) ? (uint8_t)table[i % n] : 0;
433 efx_mcdi_execute(enp, &req);
435 if (req.emr_rc != 0) {
445 EFSYS_PROBE1(fail1, efx_rc_t, rc);
449 #endif /* EFSYS_OPT_RX_SCALE */
452 __checkReturn efx_rc_t
456 #if EFSYS_OPT_RX_SCALE
458 if (efx_mcdi_rss_context_alloc(enp, EFX_RX_SCALE_EXCLUSIVE, EFX_MAXRSS,
459 &enp->en_rss_context) == 0) {
461 * Allocated an exclusive RSS context, which allows both the
462 * indirection table and key to be modified.
464 enp->en_rss_context_type = EFX_RX_SCALE_EXCLUSIVE;
465 enp->en_hash_support = EFX_RX_HASH_AVAILABLE;
468 * Failed to allocate an exclusive RSS context. Continue
469 * operation without support for RSS. The pseudo-header in
470 * received packets will not contain a Toeplitz hash value.
472 enp->en_rss_context_type = EFX_RX_SCALE_UNAVAILABLE;
473 enp->en_hash_support = EFX_RX_HASH_UNAVAILABLE;
476 #endif /* EFSYS_OPT_RX_SCALE */
481 #if EFSYS_OPT_RX_SCATTER
482 __checkReturn efx_rc_t
483 ef10_rx_scatter_enable(
485 __in unsigned int buf_size)
487 _NOTE(ARGUNUSED(enp, buf_size))
490 #endif /* EFSYS_OPT_RX_SCATTER */
492 #if EFSYS_OPT_RX_SCALE
493 __checkReturn efx_rc_t
494 ef10_rx_scale_context_alloc(
496 __in efx_rx_scale_context_type_t type,
497 __in uint32_t num_queues,
498 __out uint32_t *rss_contextp)
502 rc = efx_mcdi_rss_context_alloc(enp, type, num_queues, rss_contextp);
509 EFSYS_PROBE1(fail1, efx_rc_t, rc);
512 #endif /* EFSYS_OPT_RX_SCALE */
514 #if EFSYS_OPT_RX_SCALE
515 __checkReturn efx_rc_t
516 ef10_rx_scale_context_free(
518 __in uint32_t rss_context)
522 rc = efx_mcdi_rss_context_free(enp, rss_context);
529 EFSYS_PROBE1(fail1, efx_rc_t, rc);
532 #endif /* EFSYS_OPT_RX_SCALE */
534 #if EFSYS_OPT_RX_SCALE
535 __checkReturn efx_rc_t
536 ef10_rx_scale_mode_set(
538 __in uint32_t rss_context,
539 __in efx_rx_hash_alg_t alg,
540 __in efx_rx_hash_type_t type,
541 __in boolean_t insert)
545 EFSYS_ASSERT3U(alg, ==, EFX_RX_HASHALG_TOEPLITZ);
546 EFSYS_ASSERT3U(insert, ==, B_TRUE);
548 if ((alg != EFX_RX_HASHALG_TOEPLITZ) || (insert == B_FALSE)) {
553 if (rss_context == EFX_RSS_CONTEXT_DEFAULT) {
554 if (enp->en_rss_context_type == EFX_RX_SCALE_UNAVAILABLE) {
558 rss_context = enp->en_rss_context;
561 if ((rc = efx_mcdi_rss_context_set_flags(enp,
562 rss_context, type)) != 0)
572 EFSYS_PROBE1(fail1, efx_rc_t, rc);
576 #endif /* EFSYS_OPT_RX_SCALE */
578 #if EFSYS_OPT_RX_SCALE
579 __checkReturn efx_rc_t
580 ef10_rx_scale_key_set(
582 __in uint32_t rss_context,
583 __in_ecount(n) uint8_t *key,
588 EFX_STATIC_ASSERT(EFX_RSS_KEY_SIZE ==
589 MC_CMD_RSS_CONTEXT_SET_KEY_IN_TOEPLITZ_KEY_LEN);
591 if (rss_context == EFX_RSS_CONTEXT_DEFAULT) {
592 if (enp->en_rss_context_type == EFX_RX_SCALE_UNAVAILABLE) {
596 rss_context = enp->en_rss_context;
599 if ((rc = efx_mcdi_rss_context_set_key(enp, rss_context, key, n)) != 0)
607 EFSYS_PROBE1(fail1, efx_rc_t, rc);
611 #endif /* EFSYS_OPT_RX_SCALE */
613 #if EFSYS_OPT_RX_SCALE
614 __checkReturn efx_rc_t
615 ef10_rx_scale_tbl_set(
617 __in uint32_t rss_context,
618 __in_ecount(n) unsigned int *table,
624 if (rss_context == EFX_RSS_CONTEXT_DEFAULT) {
625 if (enp->en_rss_context_type == EFX_RX_SCALE_UNAVAILABLE) {
629 rss_context = enp->en_rss_context;
632 if ((rc = efx_mcdi_rss_context_set_table(enp,
633 rss_context, table, n)) != 0)
641 EFSYS_PROBE1(fail1, efx_rc_t, rc);
645 #endif /* EFSYS_OPT_RX_SCALE */
649 * EF10 RX pseudo-header
650 * ---------------------
652 * Receive packets are prefixed by an (optional) 14 byte pseudo-header:
654 * +00: Toeplitz hash value.
655 * (32bit little-endian)
656 * +04: Outer VLAN tag. Zero if the packet did not have an outer VLAN tag.
658 * +06: Inner VLAN tag. Zero if the packet did not have an inner VLAN tag.
660 * +08: Packet Length. Zero if the RX datapath was in cut-through mode.
661 * (16bit little-endian)
662 * +10: MAC timestamp. Zero if timestamping is not enabled.
663 * (32bit little-endian)
665 * See "The RX Pseudo-header" in SF-109306-TC.
668 __checkReturn efx_rc_t
669 ef10_rx_prefix_pktlen(
671 __in uint8_t *buffer,
672 __out uint16_t *lengthp)
674 _NOTE(ARGUNUSED(enp))
677 * The RX pseudo-header contains the packet length, excluding the
678 * pseudo-header. If the hardware receive datapath was operating in
679 * cut-through mode then the length in the RX pseudo-header will be
680 * zero, and the packet length must be obtained from the DMA length
681 * reported in the RX event.
683 *lengthp = buffer[8] | (buffer[9] << 8);
687 #if EFSYS_OPT_RX_SCALE
688 __checkReturn uint32_t
691 __in efx_rx_hash_alg_t func,
692 __in uint8_t *buffer)
694 _NOTE(ARGUNUSED(enp))
697 case EFX_RX_HASHALG_TOEPLITZ:
708 #endif /* EFSYS_OPT_RX_SCALE */
713 __in_ecount(n) efsys_dma_addr_t *addrp,
716 __in unsigned int completed,
717 __in unsigned int added)
724 /* The client driver must not overfill the queue */
725 EFSYS_ASSERT3U(added - completed + n, <=,
726 EFX_RXQ_LIMIT(erp->er_mask + 1));
728 id = added & (erp->er_mask);
729 for (i = 0; i < n; i++) {
730 EFSYS_PROBE4(rx_post, unsigned int, erp->er_index,
731 unsigned int, id, efsys_dma_addr_t, addrp[i],
734 EFX_POPULATE_QWORD_3(qword,
735 ESF_DZ_RX_KER_BYTE_CNT, (uint32_t)(size),
736 ESF_DZ_RX_KER_BUF_ADDR_DW0,
737 (uint32_t)(addrp[i] & 0xffffffff),
738 ESF_DZ_RX_KER_BUF_ADDR_DW1,
739 (uint32_t)(addrp[i] >> 32));
741 offset = id * sizeof (efx_qword_t);
742 EFSYS_MEM_WRITEQ(erp->er_esmp, offset, &qword);
744 id = (id + 1) & (erp->er_mask);
751 __in unsigned int added,
752 __inout unsigned int *pushedp)
754 efx_nic_t *enp = erp->er_enp;
755 unsigned int pushed = *pushedp;
759 /* Hardware has alignment restriction for WPTR */
760 wptr = P2ALIGN(added, EF10_RX_WPTR_ALIGN);
766 /* Push the populated descriptors out */
767 wptr &= erp->er_mask;
769 EFX_POPULATE_DWORD_1(dword, ERF_DZ_RX_DESC_WPTR, wptr);
771 /* Guarantee ordering of memory (descriptors) and PIO (doorbell) */
772 EFX_DMA_SYNC_QUEUE_FOR_DEVICE(erp->er_esmp, erp->er_mask + 1,
773 wptr, pushed & erp->er_mask);
774 EFSYS_PIO_WRITE_BARRIER();
775 EFX_BAR_TBL_WRITED(enp, ER_DZ_RX_DESC_UPD_REG,
776 erp->er_index, &dword, B_FALSE);
779 #if EFSYS_OPT_RX_PACKED_STREAM
782 ef10_rx_qps_update_credits(
785 efx_nic_t *enp = erp->er_enp;
787 efx_evq_rxq_state_t *rxq_state =
788 &erp->er_eep->ee_rxq_state[erp->er_label];
790 EFSYS_ASSERT(rxq_state->eers_rx_packed_stream);
792 if (rxq_state->eers_rx_packed_stream_credits == 0)
795 EFX_POPULATE_DWORD_3(dword,
796 ERF_DZ_RX_DESC_MAGIC_DOORBELL, 1,
797 ERF_DZ_RX_DESC_MAGIC_CMD,
798 ERE_DZ_RX_DESC_MAGIC_CMD_PS_CREDITS,
799 ERF_DZ_RX_DESC_MAGIC_DATA,
800 rxq_state->eers_rx_packed_stream_credits);
801 EFX_BAR_TBL_WRITED(enp, ER_DZ_RX_DESC_UPD_REG,
802 erp->er_index, &dword, B_FALSE);
804 rxq_state->eers_rx_packed_stream_credits = 0;
807 __checkReturn uint8_t *
808 ef10_rx_qps_packet_info(
810 __in uint8_t *buffer,
811 __in uint32_t buffer_length,
812 __in uint32_t current_offset,
813 __out uint16_t *lengthp,
814 __out uint32_t *next_offsetp,
815 __out uint32_t *timestamp)
820 efx_evq_rxq_state_t *rxq_state =
821 &erp->er_eep->ee_rxq_state[erp->er_label];
823 EFSYS_ASSERT(rxq_state->eers_rx_packed_stream);
825 buffer += current_offset;
826 pkt_start = buffer + EFX_RX_PACKED_STREAM_RX_PREFIX_SIZE;
828 qwordp = (efx_qword_t *)buffer;
829 *timestamp = EFX_QWORD_FIELD(*qwordp, ES_DZ_PS_RX_PREFIX_TSTAMP);
830 *lengthp = EFX_QWORD_FIELD(*qwordp, ES_DZ_PS_RX_PREFIX_ORIG_LEN);
831 buf_len = EFX_QWORD_FIELD(*qwordp, ES_DZ_PS_RX_PREFIX_CAP_LEN);
833 buf_len = P2ROUNDUP(buf_len + EFX_RX_PACKED_STREAM_RX_PREFIX_SIZE,
834 EFX_RX_PACKED_STREAM_ALIGNMENT);
836 current_offset + buf_len + EFX_RX_PACKED_STREAM_ALIGNMENT;
838 EFSYS_ASSERT3U(*next_offsetp, <=, buffer_length);
839 EFSYS_ASSERT3U(current_offset + *lengthp, <, *next_offsetp);
841 if ((*next_offsetp ^ current_offset) &
842 EFX_RX_PACKED_STREAM_MEM_PER_CREDIT) {
843 if (rxq_state->eers_rx_packed_stream_credits <
844 EFX_RX_PACKED_STREAM_MAX_CREDITS)
845 rxq_state->eers_rx_packed_stream_credits++;
854 __checkReturn efx_rc_t
858 efx_nic_t *enp = erp->er_enp;
861 if ((rc = efx_mcdi_fini_rxq(enp, erp->er_index)) != 0)
868 * EALREADY is not an error, but indicates that the MC has rebooted and
869 * that the RXQ has already been destroyed. Callers need to know that
870 * the RXQ flush has completed to avoid waiting until timeout for a
871 * flush done event that will not be delivered.
874 EFSYS_PROBE1(fail1, efx_rc_t, rc);
884 _NOTE(ARGUNUSED(erp))
888 __checkReturn efx_rc_t
891 __in unsigned int index,
892 __in unsigned int label,
893 __in efx_rxq_type_t type,
894 __in efsys_mem_t *esmp,
900 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
902 boolean_t disable_scatter;
903 unsigned int ps_buf_size;
905 _NOTE(ARGUNUSED(id, erp))
907 EFX_STATIC_ASSERT(EFX_EV_RX_NLABELS == (1 << ESF_DZ_RX_QLABEL_WIDTH));
908 EFSYS_ASSERT3U(label, <, EFX_EV_RX_NLABELS);
909 EFSYS_ASSERT3U(enp->en_rx_qcount + 1, <, encp->enc_rxq_limit);
911 EFX_STATIC_ASSERT(ISP2(EFX_RXQ_MAXNDESCS));
912 EFX_STATIC_ASSERT(ISP2(EFX_RXQ_MINNDESCS));
914 if (!ISP2(n) || (n < EFX_RXQ_MINNDESCS) || (n > EFX_RXQ_MAXNDESCS)) {
918 if (index >= encp->enc_rxq_limit) {
924 case EFX_RXQ_TYPE_DEFAULT:
925 case EFX_RXQ_TYPE_SCATTER:
928 #if EFSYS_OPT_RX_PACKED_STREAM
929 case EFX_RXQ_TYPE_PACKED_STREAM_1M:
930 ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_1M;
932 case EFX_RXQ_TYPE_PACKED_STREAM_512K:
933 ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_512K;
935 case EFX_RXQ_TYPE_PACKED_STREAM_256K:
936 ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_256K;
938 case EFX_RXQ_TYPE_PACKED_STREAM_128K:
939 ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_128K;
941 case EFX_RXQ_TYPE_PACKED_STREAM_64K:
942 ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_64K;
944 #endif /* EFSYS_OPT_RX_PACKED_STREAM */
950 #if EFSYS_OPT_RX_PACKED_STREAM
951 if (ps_buf_size != 0) {
952 /* Check if datapath firmware supports packed stream mode */
953 if (encp->enc_rx_packed_stream_supported == B_FALSE) {
957 /* Check if packed stream allows configurable buffer sizes */
958 if ((type != EFX_RXQ_TYPE_PACKED_STREAM_1M) &&
959 (encp->enc_rx_var_packed_stream_supported == B_FALSE)) {
964 #else /* EFSYS_OPT_RX_PACKED_STREAM */
965 EFSYS_ASSERT(ps_buf_size == 0);
966 #endif /* EFSYS_OPT_RX_PACKED_STREAM */
968 /* Scatter can only be disabled if the firmware supports doing so */
969 if (type == EFX_RXQ_TYPE_SCATTER)
970 disable_scatter = B_FALSE;
972 disable_scatter = encp->enc_rx_disable_scatter_supported;
974 if ((rc = efx_mcdi_init_rxq(enp, n, eep->ee_index, label, index,
975 esmp, disable_scatter, ps_buf_size)) != 0)
979 erp->er_label = label;
981 ef10_ev_rxlabel_init(eep, erp, label, ps_buf_size != 0);
987 #if EFSYS_OPT_RX_PACKED_STREAM
992 #endif /* EFSYS_OPT_RX_PACKED_STREAM */
998 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1005 __in efx_rxq_t *erp)
1007 efx_nic_t *enp = erp->er_enp;
1008 efx_evq_t *eep = erp->er_eep;
1009 unsigned int label = erp->er_label;
1011 ef10_ev_rxlabel_fini(eep, label);
1013 EFSYS_ASSERT(enp->en_rx_qcount != 0);
1014 --enp->en_rx_qcount;
1016 EFSYS_KMEM_FREE(enp->en_esip, sizeof (efx_rxq_t), erp);
1021 __in efx_nic_t *enp)
1023 #if EFSYS_OPT_RX_SCALE
1024 if (enp->en_rss_context_type != EFX_RX_SCALE_UNAVAILABLE)
1025 (void) efx_mcdi_rss_context_free(enp, enp->en_rss_context);
1026 enp->en_rss_context = 0;
1027 enp->en_rss_context_type = EFX_RX_SCALE_UNAVAILABLE;
1029 _NOTE(ARGUNUSED(enp))
1030 #endif /* EFSYS_OPT_RX_SCALE */
1033 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */