1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2007-2018 Solarflare Communications Inc.
10 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
14 #define EFE_SPEC(eftp, index) ((eftp)->eft_entry[(index)].efe_spec)
16 static efx_filter_spec_t *
17 ef10_filter_entry_spec(
18 __in const ef10_filter_table_t *eftp,
19 __in unsigned int index)
21 return ((efx_filter_spec_t *)(EFE_SPEC(eftp, index) &
22 ~(uintptr_t)EFX_EF10_FILTER_FLAGS));
26 ef10_filter_entry_is_busy(
27 __in const ef10_filter_table_t *eftp,
28 __in unsigned int index)
30 if (EFE_SPEC(eftp, index) & EFX_EF10_FILTER_FLAG_BUSY)
37 ef10_filter_entry_is_auto_old(
38 __in const ef10_filter_table_t *eftp,
39 __in unsigned int index)
41 if (EFE_SPEC(eftp, index) & EFX_EF10_FILTER_FLAG_AUTO_OLD)
48 ef10_filter_set_entry(
49 __inout ef10_filter_table_t *eftp,
50 __in unsigned int index,
51 __in_opt const efx_filter_spec_t *efsp)
53 EFE_SPEC(eftp, index) = (uintptr_t)efsp;
57 ef10_filter_set_entry_busy(
58 __inout ef10_filter_table_t *eftp,
59 __in unsigned int index)
61 EFE_SPEC(eftp, index) |= (uintptr_t)EFX_EF10_FILTER_FLAG_BUSY;
65 ef10_filter_set_entry_not_busy(
66 __inout ef10_filter_table_t *eftp,
67 __in unsigned int index)
69 EFE_SPEC(eftp, index) &= ~(uintptr_t)EFX_EF10_FILTER_FLAG_BUSY;
73 ef10_filter_set_entry_auto_old(
74 __inout ef10_filter_table_t *eftp,
75 __in unsigned int index)
77 EFSYS_ASSERT(ef10_filter_entry_spec(eftp, index) != NULL);
78 EFE_SPEC(eftp, index) |= (uintptr_t)EFX_EF10_FILTER_FLAG_AUTO_OLD;
82 ef10_filter_set_entry_not_auto_old(
83 __inout ef10_filter_table_t *eftp,
84 __in unsigned int index)
86 EFE_SPEC(eftp, index) &= ~(uintptr_t)EFX_EF10_FILTER_FLAG_AUTO_OLD;
87 EFSYS_ASSERT(ef10_filter_entry_spec(eftp, index) != NULL);
90 __checkReturn efx_rc_t
95 ef10_filter_table_t *eftp;
97 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
98 enp->en_family == EFX_FAMILY_MEDFORD ||
99 enp->en_family == EFX_FAMILY_MEDFORD2);
101 #define MATCH_MASK(match) (EFX_MASK32(match) << EFX_LOW_BIT(match))
102 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_REM_HOST ==
103 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_SRC_IP));
104 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_LOC_HOST ==
105 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_DST_IP));
106 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_REM_MAC ==
107 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_SRC_MAC));
108 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_REM_PORT ==
109 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_SRC_PORT));
110 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_LOC_MAC ==
111 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_DST_MAC));
112 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_LOC_PORT ==
113 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_DST_PORT));
114 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_ETHER_TYPE ==
115 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_ETHER_TYPE));
116 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_INNER_VID ==
117 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_INNER_VLAN));
118 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_OUTER_VID ==
119 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_OUTER_VLAN));
120 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_IP_PROTO ==
121 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_IP_PROTO));
122 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_IFRM_UNKNOWN_MCAST_DST ==
123 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_IFRM_UNKNOWN_MCAST_DST));
124 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_IFRM_UNKNOWN_UCAST_DST ==
125 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_IFRM_UNKNOWN_UCAST_DST));
126 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_UNKNOWN_MCAST_DST ==
127 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_UNKNOWN_MCAST_DST));
128 EFX_STATIC_ASSERT((uint32_t)EFX_FILTER_MATCH_UNKNOWN_UCAST_DST ==
129 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_UNKNOWN_UCAST_DST));
132 EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (ef10_filter_table_t), eftp);
139 enp->en_filter.ef_ef10_filter_table = eftp;
144 EFSYS_PROBE1(fail1, efx_rc_t, rc);
153 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
154 enp->en_family == EFX_FAMILY_MEDFORD ||
155 enp->en_family == EFX_FAMILY_MEDFORD2);
157 if (enp->en_filter.ef_ef10_filter_table != NULL) {
158 EFSYS_KMEM_FREE(enp->en_esip, sizeof (ef10_filter_table_t),
159 enp->en_filter.ef_ef10_filter_table);
163 static __checkReturn efx_rc_t
164 efx_mcdi_filter_op_add(
166 __in efx_filter_spec_t *spec,
167 __in unsigned int filter_op,
168 __inout ef10_filter_handle_t *handle)
171 uint8_t payload[MAX(MC_CMD_FILTER_OP_EXT_IN_LEN,
172 MC_CMD_FILTER_OP_EXT_OUT_LEN)];
175 memset(payload, 0, sizeof (payload));
176 req.emr_cmd = MC_CMD_FILTER_OP;
177 req.emr_in_buf = payload;
178 req.emr_in_length = MC_CMD_FILTER_OP_EXT_IN_LEN;
179 req.emr_out_buf = payload;
180 req.emr_out_length = MC_CMD_FILTER_OP_EXT_OUT_LEN;
183 case MC_CMD_FILTER_OP_IN_OP_REPLACE:
184 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_HANDLE_LO,
186 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_HANDLE_HI,
189 case MC_CMD_FILTER_OP_IN_OP_INSERT:
190 case MC_CMD_FILTER_OP_IN_OP_SUBSCRIBE:
191 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_OP, filter_op);
199 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_PORT_ID,
200 EVB_PORT_ID_ASSIGNED);
201 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_MATCH_FIELDS,
202 spec->efs_match_flags);
203 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_RX_DEST,
204 MC_CMD_FILTER_OP_EXT_IN_RX_DEST_HOST);
205 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_RX_QUEUE,
208 #if EFSYS_OPT_RX_SCALE
209 if (spec->efs_flags & EFX_FILTER_FLAG_RX_RSS) {
210 uint32_t rss_context;
212 if (spec->efs_rss_context == EFX_RSS_CONTEXT_DEFAULT)
213 rss_context = enp->en_rss_context;
215 rss_context = spec->efs_rss_context;
216 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_RX_CONTEXT,
221 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_RX_MODE,
222 spec->efs_flags & EFX_FILTER_FLAG_RX_RSS ?
223 MC_CMD_FILTER_OP_EXT_IN_RX_MODE_RSS :
224 MC_CMD_FILTER_OP_EXT_IN_RX_MODE_SIMPLE);
225 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_TX_DEST,
226 MC_CMD_FILTER_OP_EXT_IN_TX_DEST_DEFAULT);
228 if (filter_op != MC_CMD_FILTER_OP_IN_OP_REPLACE) {
230 * NOTE: Unlike most MCDI requests, the filter fields
231 * are presented in network (big endian) byte order.
233 memcpy(MCDI_IN2(req, uint8_t, FILTER_OP_EXT_IN_SRC_MAC),
234 spec->efs_rem_mac, EFX_MAC_ADDR_LEN);
235 memcpy(MCDI_IN2(req, uint8_t, FILTER_OP_EXT_IN_DST_MAC),
236 spec->efs_loc_mac, EFX_MAC_ADDR_LEN);
238 MCDI_IN_SET_WORD(req, FILTER_OP_EXT_IN_SRC_PORT,
239 __CPU_TO_BE_16(spec->efs_rem_port));
240 MCDI_IN_SET_WORD(req, FILTER_OP_EXT_IN_DST_PORT,
241 __CPU_TO_BE_16(spec->efs_loc_port));
243 MCDI_IN_SET_WORD(req, FILTER_OP_EXT_IN_ETHER_TYPE,
244 __CPU_TO_BE_16(spec->efs_ether_type));
246 MCDI_IN_SET_WORD(req, FILTER_OP_EXT_IN_INNER_VLAN,
247 __CPU_TO_BE_16(spec->efs_inner_vid));
248 MCDI_IN_SET_WORD(req, FILTER_OP_EXT_IN_OUTER_VLAN,
249 __CPU_TO_BE_16(spec->efs_outer_vid));
251 /* IP protocol (in low byte, high byte is zero) */
252 MCDI_IN_SET_BYTE(req, FILTER_OP_EXT_IN_IP_PROTO,
255 EFX_STATIC_ASSERT(sizeof (spec->efs_rem_host) ==
256 MC_CMD_FILTER_OP_EXT_IN_SRC_IP_LEN);
257 EFX_STATIC_ASSERT(sizeof (spec->efs_loc_host) ==
258 MC_CMD_FILTER_OP_EXT_IN_DST_IP_LEN);
260 memcpy(MCDI_IN2(req, uint8_t, FILTER_OP_EXT_IN_SRC_IP),
261 &spec->efs_rem_host.eo_byte[0],
262 MC_CMD_FILTER_OP_EXT_IN_SRC_IP_LEN);
263 memcpy(MCDI_IN2(req, uint8_t, FILTER_OP_EXT_IN_DST_IP),
264 &spec->efs_loc_host.eo_byte[0],
265 MC_CMD_FILTER_OP_EXT_IN_DST_IP_LEN);
268 * On Medford, filters for encapsulated packets match based on
269 * the ether type and IP protocol in the outer frame. In
270 * addition we need to fill in the VNI or VSID type field.
272 switch (spec->efs_encap_type) {
273 case EFX_TUNNEL_PROTOCOL_NONE:
275 case EFX_TUNNEL_PROTOCOL_VXLAN:
276 case EFX_TUNNEL_PROTOCOL_GENEVE:
277 MCDI_IN_POPULATE_DWORD_1(req,
278 FILTER_OP_EXT_IN_VNI_OR_VSID,
279 FILTER_OP_EXT_IN_VNI_TYPE,
280 spec->efs_encap_type == EFX_TUNNEL_PROTOCOL_VXLAN ?
281 MC_CMD_FILTER_OP_EXT_IN_VNI_TYPE_VXLAN :
282 MC_CMD_FILTER_OP_EXT_IN_VNI_TYPE_GENEVE);
284 case EFX_TUNNEL_PROTOCOL_NVGRE:
285 MCDI_IN_POPULATE_DWORD_1(req,
286 FILTER_OP_EXT_IN_VNI_OR_VSID,
287 FILTER_OP_EXT_IN_VSID_TYPE,
288 MC_CMD_FILTER_OP_EXT_IN_VSID_TYPE_NVGRE);
297 efx_mcdi_execute(enp, &req);
299 if (req.emr_rc != 0) {
304 if (req.emr_out_length_used < MC_CMD_FILTER_OP_EXT_OUT_LEN) {
309 handle->efh_lo = MCDI_OUT_DWORD(req, FILTER_OP_EXT_OUT_HANDLE_LO);
310 handle->efh_hi = MCDI_OUT_DWORD(req, FILTER_OP_EXT_OUT_HANDLE_HI);
321 EFSYS_PROBE1(fail1, efx_rc_t, rc);
327 static __checkReturn efx_rc_t
328 efx_mcdi_filter_op_delete(
330 __in unsigned int filter_op,
331 __inout ef10_filter_handle_t *handle)
334 uint8_t payload[MAX(MC_CMD_FILTER_OP_EXT_IN_LEN,
335 MC_CMD_FILTER_OP_EXT_OUT_LEN)];
338 memset(payload, 0, sizeof (payload));
339 req.emr_cmd = MC_CMD_FILTER_OP;
340 req.emr_in_buf = payload;
341 req.emr_in_length = MC_CMD_FILTER_OP_EXT_IN_LEN;
342 req.emr_out_buf = payload;
343 req.emr_out_length = MC_CMD_FILTER_OP_EXT_OUT_LEN;
346 case MC_CMD_FILTER_OP_IN_OP_REMOVE:
347 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_OP,
348 MC_CMD_FILTER_OP_IN_OP_REMOVE);
350 case MC_CMD_FILTER_OP_IN_OP_UNSUBSCRIBE:
351 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_OP,
352 MC_CMD_FILTER_OP_IN_OP_UNSUBSCRIBE);
360 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_HANDLE_LO, handle->efh_lo);
361 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_HANDLE_HI, handle->efh_hi);
363 efx_mcdi_execute_quiet(enp, &req);
365 if (req.emr_rc != 0) {
370 if (req.emr_out_length_used < MC_CMD_FILTER_OP_EXT_OUT_LEN) {
383 EFSYS_PROBE1(fail1, efx_rc_t, rc);
388 static __checkReturn boolean_t
390 __in const efx_filter_spec_t *left,
391 __in const efx_filter_spec_t *right)
393 /* FIXME: Consider rx vs tx filters (look at efs_flags) */
394 if (left->efs_match_flags != right->efs_match_flags)
396 if (!EFX_OWORD_IS_EQUAL(left->efs_rem_host, right->efs_rem_host))
398 if (!EFX_OWORD_IS_EQUAL(left->efs_loc_host, right->efs_loc_host))
400 if (memcmp(left->efs_rem_mac, right->efs_rem_mac, EFX_MAC_ADDR_LEN))
402 if (memcmp(left->efs_loc_mac, right->efs_loc_mac, EFX_MAC_ADDR_LEN))
404 if (left->efs_rem_port != right->efs_rem_port)
406 if (left->efs_loc_port != right->efs_loc_port)
408 if (left->efs_inner_vid != right->efs_inner_vid)
410 if (left->efs_outer_vid != right->efs_outer_vid)
412 if (left->efs_ether_type != right->efs_ether_type)
414 if (left->efs_ip_proto != right->efs_ip_proto)
416 if (left->efs_encap_type != right->efs_encap_type)
423 static __checkReturn boolean_t
424 ef10_filter_same_dest(
425 __in const efx_filter_spec_t *left,
426 __in const efx_filter_spec_t *right)
428 if ((left->efs_flags & EFX_FILTER_FLAG_RX_RSS) &&
429 (right->efs_flags & EFX_FILTER_FLAG_RX_RSS)) {
430 if (left->efs_rss_context == right->efs_rss_context)
432 } else if ((~(left->efs_flags) & EFX_FILTER_FLAG_RX_RSS) &&
433 (~(right->efs_flags) & EFX_FILTER_FLAG_RX_RSS)) {
434 if (left->efs_dmaq_id == right->efs_dmaq_id)
440 static __checkReturn uint32_t
442 __in efx_filter_spec_t *spec)
444 EFX_STATIC_ASSERT((sizeof (efx_filter_spec_t) % sizeof (uint32_t))
446 EFX_STATIC_ASSERT((EFX_FIELD_OFFSET(efx_filter_spec_t, efs_outer_vid) %
447 sizeof (uint32_t)) == 0);
450 * As the area of the efx_filter_spec_t we need to hash is DWORD
451 * aligned and an exact number of DWORDs in size we can use the
452 * optimised efx_hash_dwords() rather than efx_hash_bytes()
454 return (efx_hash_dwords((const uint32_t *)&spec->efs_outer_vid,
455 (sizeof (efx_filter_spec_t) -
456 EFX_FIELD_OFFSET(efx_filter_spec_t, efs_outer_vid)) /
457 sizeof (uint32_t), 0));
461 * Decide whether a filter should be exclusive or else should allow
462 * delivery to additional recipients. Currently we decide that
463 * filters for specific local unicast MAC and IP addresses are
466 static __checkReturn boolean_t
467 ef10_filter_is_exclusive(
468 __in efx_filter_spec_t *spec)
470 if ((spec->efs_match_flags & EFX_FILTER_MATCH_LOC_MAC) &&
471 !EFX_MAC_ADDR_IS_MULTICAST(spec->efs_loc_mac))
474 if ((spec->efs_match_flags &
475 (EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_LOC_HOST)) ==
476 (EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_LOC_HOST)) {
477 if ((spec->efs_ether_type == EFX_ETHER_TYPE_IPV4) &&
478 ((spec->efs_loc_host.eo_u8[0] & 0xf) != 0xe))
480 if ((spec->efs_ether_type == EFX_ETHER_TYPE_IPV6) &&
481 (spec->efs_loc_host.eo_u8[0] != 0xff))
488 __checkReturn efx_rc_t
493 efx_filter_spec_t *spec;
494 ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
496 efsys_lock_state_t state;
499 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
500 enp->en_family == EFX_FAMILY_MEDFORD ||
501 enp->en_family == EFX_FAMILY_MEDFORD2);
503 for (tbl_id = 0; tbl_id < EFX_EF10_FILTER_TBL_ROWS; tbl_id++) {
505 EFSYS_LOCK(enp->en_eslp, state);
507 spec = ef10_filter_entry_spec(eftp, tbl_id);
510 } else if (ef10_filter_entry_is_busy(eftp, tbl_id)) {
511 /* Ignore busy entries. */
514 ef10_filter_set_entry_busy(eftp, tbl_id);
518 EFSYS_UNLOCK(enp->en_eslp, state);
520 if (restoring == B_FALSE)
523 if (ef10_filter_is_exclusive(spec)) {
524 rc = efx_mcdi_filter_op_add(enp, spec,
525 MC_CMD_FILTER_OP_IN_OP_INSERT,
526 &eftp->eft_entry[tbl_id].efe_handle);
528 rc = efx_mcdi_filter_op_add(enp, spec,
529 MC_CMD_FILTER_OP_IN_OP_SUBSCRIBE,
530 &eftp->eft_entry[tbl_id].efe_handle);
536 EFSYS_LOCK(enp->en_eslp, state);
538 ef10_filter_set_entry_not_busy(eftp, tbl_id);
540 EFSYS_UNLOCK(enp->en_eslp, state);
546 EFSYS_PROBE1(fail1, efx_rc_t, rc);
552 * An arbitrary search limit for the software hash table. As per the linux net
555 #define EF10_FILTER_SEARCH_LIMIT 200
557 static __checkReturn efx_rc_t
558 ef10_filter_add_internal(
560 __inout efx_filter_spec_t *spec,
561 __in boolean_t may_replace,
562 __out_opt uint32_t *filter_id)
565 ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
566 efx_filter_spec_t *saved_spec;
570 boolean_t replacing = B_FALSE;
572 efsys_lock_state_t state;
573 boolean_t locked = B_FALSE;
575 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
576 enp->en_family == EFX_FAMILY_MEDFORD ||
577 enp->en_family == EFX_FAMILY_MEDFORD2);
579 hash = ef10_filter_hash(spec);
582 * FIXME: Add support for inserting filters of different priorities
583 * and removing lower priority multicast filters (bug 42378)
587 * Find any existing filters with the same match tuple or
588 * else a free slot to insert at. If any of them are busy,
589 * we have to wait and retry.
594 EFSYS_LOCK(enp->en_eslp, state);
598 i = (hash + depth) & (EFX_EF10_FILTER_TBL_ROWS - 1);
599 saved_spec = ef10_filter_entry_spec(eftp, i);
605 } else if (ef10_filter_equal(spec, saved_spec)) {
606 if (ef10_filter_entry_is_busy(eftp, i))
608 if (saved_spec->efs_priority
609 == EFX_FILTER_PRI_AUTO) {
612 } else if (ef10_filter_is_exclusive(spec)) {
626 * Once we reach the maximum search depth, use
627 * the first suitable slot or return EBUSY if
630 if (depth == EF10_FILTER_SEARCH_LIMIT) {
639 EFSYS_UNLOCK(enp->en_eslp, state);
645 * Create a software table entry if necessary, and mark it
646 * busy. We might yet fail to insert, but any attempt to
647 * insert a conflicting filter while we're waiting for the
648 * firmware must find the busy entry.
650 saved_spec = ef10_filter_entry_spec(eftp, ins_index);
652 if (saved_spec->efs_priority == EFX_FILTER_PRI_AUTO) {
653 /* This is a filter we are refreshing */
654 ef10_filter_set_entry_not_auto_old(eftp, ins_index);
660 EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (*spec), saved_spec);
666 ef10_filter_set_entry(eftp, ins_index, saved_spec);
668 ef10_filter_set_entry_busy(eftp, ins_index);
670 EFSYS_UNLOCK(enp->en_eslp, state);
674 * On replacing the filter handle may change after after a successful
678 rc = efx_mcdi_filter_op_add(enp, spec,
679 MC_CMD_FILTER_OP_IN_OP_REPLACE,
680 &eftp->eft_entry[ins_index].efe_handle);
681 } else if (ef10_filter_is_exclusive(spec)) {
682 rc = efx_mcdi_filter_op_add(enp, spec,
683 MC_CMD_FILTER_OP_IN_OP_INSERT,
684 &eftp->eft_entry[ins_index].efe_handle);
686 rc = efx_mcdi_filter_op_add(enp, spec,
687 MC_CMD_FILTER_OP_IN_OP_SUBSCRIBE,
688 &eftp->eft_entry[ins_index].efe_handle);
694 EFSYS_LOCK(enp->en_eslp, state);
698 /* Update the fields that may differ */
699 saved_spec->efs_priority = spec->efs_priority;
700 saved_spec->efs_flags = spec->efs_flags;
701 saved_spec->efs_rss_context = spec->efs_rss_context;
702 saved_spec->efs_dmaq_id = spec->efs_dmaq_id;
705 ef10_filter_set_entry_not_busy(eftp, ins_index);
709 EFSYS_UNLOCK(enp->en_eslp, state);
713 *filter_id = ins_index;
721 EFSYS_KMEM_FREE(enp->en_esip, sizeof (*spec), saved_spec);
724 ef10_filter_set_entry_not_busy(eftp, ins_index);
725 ef10_filter_set_entry(eftp, ins_index, NULL);
734 EFSYS_PROBE1(fail1, efx_rc_t, rc);
737 EFSYS_UNLOCK(enp->en_eslp, state);
742 __checkReturn efx_rc_t
745 __inout efx_filter_spec_t *spec,
746 __in boolean_t may_replace)
750 rc = ef10_filter_add_internal(enp, spec, may_replace, NULL);
757 EFSYS_PROBE1(fail1, efx_rc_t, rc);
763 static __checkReturn efx_rc_t
764 ef10_filter_delete_internal(
766 __in uint32_t filter_id)
769 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
770 efx_filter_spec_t *spec;
771 efsys_lock_state_t state;
772 uint32_t filter_idx = filter_id % EFX_EF10_FILTER_TBL_ROWS;
775 * Find the software table entry and mark it busy. Don't
776 * remove it yet; any attempt to update while we're waiting
777 * for the firmware must find the busy entry.
779 * FIXME: What if the busy flag is never cleared?
781 EFSYS_LOCK(enp->en_eslp, state);
782 while (ef10_filter_entry_is_busy(table, filter_idx)) {
783 EFSYS_UNLOCK(enp->en_eslp, state);
785 EFSYS_LOCK(enp->en_eslp, state);
787 if ((spec = ef10_filter_entry_spec(table, filter_idx)) != NULL) {
788 ef10_filter_set_entry_busy(table, filter_idx);
790 EFSYS_UNLOCK(enp->en_eslp, state);
798 * Try to remove the hardware filter. This may fail if the MC has
799 * rebooted (which frees all hardware filter resources).
801 if (ef10_filter_is_exclusive(spec)) {
802 rc = efx_mcdi_filter_op_delete(enp,
803 MC_CMD_FILTER_OP_IN_OP_REMOVE,
804 &table->eft_entry[filter_idx].efe_handle);
806 rc = efx_mcdi_filter_op_delete(enp,
807 MC_CMD_FILTER_OP_IN_OP_UNSUBSCRIBE,
808 &table->eft_entry[filter_idx].efe_handle);
811 /* Free the software table entry */
812 EFSYS_LOCK(enp->en_eslp, state);
813 ef10_filter_set_entry_not_busy(table, filter_idx);
814 ef10_filter_set_entry(table, filter_idx, NULL);
815 EFSYS_UNLOCK(enp->en_eslp, state);
817 EFSYS_KMEM_FREE(enp->en_esip, sizeof (*spec), spec);
819 /* Check result of hardware filter removal */
829 EFSYS_PROBE1(fail1, efx_rc_t, rc);
834 __checkReturn efx_rc_t
837 __inout efx_filter_spec_t *spec)
840 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
841 efx_filter_spec_t *saved_spec;
845 efsys_lock_state_t state;
846 boolean_t locked = B_FALSE;
848 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
849 enp->en_family == EFX_FAMILY_MEDFORD ||
850 enp->en_family == EFX_FAMILY_MEDFORD2);
852 hash = ef10_filter_hash(spec);
854 EFSYS_LOCK(enp->en_eslp, state);
859 i = (hash + depth) & (EFX_EF10_FILTER_TBL_ROWS - 1);
860 saved_spec = ef10_filter_entry_spec(table, i);
861 if (saved_spec && ef10_filter_equal(spec, saved_spec) &&
862 ef10_filter_same_dest(spec, saved_spec)) {
865 if (depth == EF10_FILTER_SEARCH_LIMIT) {
872 EFSYS_UNLOCK(enp->en_eslp, state);
875 rc = ef10_filter_delete_internal(enp, i);
885 EFSYS_PROBE1(fail1, efx_rc_t, rc);
888 EFSYS_UNLOCK(enp->en_eslp, state);
893 static __checkReturn efx_rc_t
894 efx_mcdi_get_parser_disp_info(
896 __out_ecount(buffer_length) uint32_t *buffer,
897 __in size_t buffer_length,
898 __out size_t *list_lengthp)
901 uint8_t payload[MAX(MC_CMD_GET_PARSER_DISP_INFO_IN_LEN,
902 MC_CMD_GET_PARSER_DISP_INFO_OUT_LENMAX)];
903 size_t matches_count;
907 (void) memset(payload, 0, sizeof (payload));
908 req.emr_cmd = MC_CMD_GET_PARSER_DISP_INFO;
909 req.emr_in_buf = payload;
910 req.emr_in_length = MC_CMD_GET_PARSER_DISP_INFO_IN_LEN;
911 req.emr_out_buf = payload;
912 req.emr_out_length = MC_CMD_GET_PARSER_DISP_INFO_OUT_LENMAX;
914 MCDI_IN_SET_DWORD(req, GET_PARSER_DISP_INFO_OUT_OP,
915 MC_CMD_GET_PARSER_DISP_INFO_IN_OP_GET_SUPPORTED_RX_MATCHES);
917 efx_mcdi_execute(enp, &req);
919 if (req.emr_rc != 0) {
924 matches_count = MCDI_OUT_DWORD(req,
925 GET_PARSER_DISP_INFO_OUT_NUM_SUPPORTED_MATCHES);
927 if (req.emr_out_length_used <
928 MC_CMD_GET_PARSER_DISP_INFO_OUT_LEN(matches_count)) {
933 *list_lengthp = matches_count;
935 if (buffer_length < matches_count) {
941 * Check that the elements in the list in the MCDI response are the size
942 * we expect, so we can just copy them directly. Any conversion of the
943 * flags is handled by the caller.
945 EFX_STATIC_ASSERT(sizeof (uint32_t) ==
946 MC_CMD_GET_PARSER_DISP_INFO_OUT_SUPPORTED_MATCHES_LEN);
948 list_size = matches_count *
949 MC_CMD_GET_PARSER_DISP_INFO_OUT_SUPPORTED_MATCHES_LEN;
951 MCDI_OUT2(req, uint32_t,
952 GET_PARSER_DISP_INFO_OUT_SUPPORTED_MATCHES),
962 EFSYS_PROBE1(fail1, efx_rc_t, rc);
967 __checkReturn efx_rc_t
968 ef10_filter_supported_filters(
970 __out_ecount(buffer_length) uint32_t *buffer,
971 __in size_t buffer_length,
972 __out size_t *list_lengthp)
975 size_t mcdi_list_length;
979 efx_filter_match_flags_t all_filter_flags =
980 (EFX_FILTER_MATCH_REM_HOST | EFX_FILTER_MATCH_LOC_HOST |
981 EFX_FILTER_MATCH_REM_MAC | EFX_FILTER_MATCH_REM_PORT |
982 EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_PORT |
983 EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_INNER_VID |
984 EFX_FILTER_MATCH_OUTER_VID | EFX_FILTER_MATCH_IP_PROTO |
985 EFX_FILTER_MATCH_UNKNOWN_MCAST_DST |
986 EFX_FILTER_MATCH_UNKNOWN_UCAST_DST);
988 rc = efx_mcdi_get_parser_disp_info(enp, buffer, buffer_length,
992 /* Pass through mcdi_list_length for the list length */
993 *list_lengthp = mcdi_list_length;
999 * The static assertions in ef10_filter_init() ensure that the values of
1000 * the EFX_FILTER_MATCH flags match those used by MCDI, so they don't
1001 * need to be converted.
1003 * In case support is added to MCDI for additional flags, remove any
1004 * matches from the list which include flags we don't support. The order
1005 * of the matches is preserved as they are ordered from highest to
1008 EFSYS_ASSERT(mcdi_list_length <= buffer_length);
1010 for (i = 0; i < mcdi_list_length; i++) {
1011 if ((buffer[i] & ~all_filter_flags) == 0) {
1012 buffer[list_length] = buffer[i];
1017 *list_lengthp = list_length;
1022 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1027 static __checkReturn efx_rc_t
1028 ef10_filter_insert_unicast(
1029 __in efx_nic_t *enp,
1030 __in_ecount(6) uint8_t const *addr,
1031 __in efx_filter_flags_t filter_flags)
1033 ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
1034 efx_filter_spec_t spec;
1037 /* Insert the filter for the local station address */
1038 efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO,
1040 eftp->eft_default_rxq);
1041 efx_filter_spec_set_eth_local(&spec, EFX_FILTER_SPEC_VID_UNSPEC, addr);
1043 rc = ef10_filter_add_internal(enp, &spec, B_TRUE,
1044 &eftp->eft_unicst_filter_indexes[eftp->eft_unicst_filter_count]);
1048 eftp->eft_unicst_filter_count++;
1049 EFSYS_ASSERT(eftp->eft_unicst_filter_count <=
1050 EFX_EF10_FILTER_UNICAST_FILTERS_MAX);
1055 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1059 static __checkReturn efx_rc_t
1060 ef10_filter_insert_all_unicast(
1061 __in efx_nic_t *enp,
1062 __in efx_filter_flags_t filter_flags)
1064 ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
1065 efx_filter_spec_t spec;
1068 /* Insert the unknown unicast filter */
1069 efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO,
1071 eftp->eft_default_rxq);
1072 efx_filter_spec_set_uc_def(&spec);
1073 rc = ef10_filter_add_internal(enp, &spec, B_TRUE,
1074 &eftp->eft_unicst_filter_indexes[eftp->eft_unicst_filter_count]);
1078 eftp->eft_unicst_filter_count++;
1079 EFSYS_ASSERT(eftp->eft_unicst_filter_count <=
1080 EFX_EF10_FILTER_UNICAST_FILTERS_MAX);
1085 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1089 static __checkReturn efx_rc_t
1090 ef10_filter_insert_multicast_list(
1091 __in efx_nic_t *enp,
1092 __in boolean_t mulcst,
1093 __in boolean_t brdcst,
1094 __in_ecount(6*count) uint8_t const *addrs,
1095 __in uint32_t count,
1096 __in efx_filter_flags_t filter_flags,
1097 __in boolean_t rollback)
1099 ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
1100 efx_filter_spec_t spec;
1103 uint32_t filter_index;
1104 uint32_t filter_count;
1107 if (mulcst == B_FALSE)
1110 if (count + (brdcst ? 1 : 0) >
1111 EFX_ARRAY_SIZE(eftp->eft_mulcst_filter_indexes)) {
1112 /* Too many MAC addresses */
1117 /* Insert/renew multicast address list filters */
1119 for (i = 0; i < count; i++) {
1120 efx_filter_spec_init_rx(&spec,
1121 EFX_FILTER_PRI_AUTO,
1123 eftp->eft_default_rxq);
1125 efx_filter_spec_set_eth_local(&spec,
1126 EFX_FILTER_SPEC_VID_UNSPEC,
1127 &addrs[i * EFX_MAC_ADDR_LEN]);
1129 rc = ef10_filter_add_internal(enp, &spec, B_TRUE,
1133 eftp->eft_mulcst_filter_indexes[filter_count] =
1136 } else if (rollback == B_TRUE) {
1137 /* Only stop upon failure if told to rollback */
1143 if (brdcst == B_TRUE) {
1144 /* Insert/renew broadcast address filter */
1145 efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO,
1147 eftp->eft_default_rxq);
1149 EFX_MAC_BROADCAST_ADDR_SET(addr);
1150 efx_filter_spec_set_eth_local(&spec, EFX_FILTER_SPEC_VID_UNSPEC,
1153 rc = ef10_filter_add_internal(enp, &spec, B_TRUE,
1157 eftp->eft_mulcst_filter_indexes[filter_count] =
1160 } else if (rollback == B_TRUE) {
1161 /* Only stop upon failure if told to rollback */
1166 eftp->eft_mulcst_filter_count = filter_count;
1167 eftp->eft_using_all_mulcst = B_FALSE;
1172 /* Remove any filters we have inserted */
1175 (void) ef10_filter_delete_internal(enp,
1176 eftp->eft_mulcst_filter_indexes[i]);
1178 eftp->eft_mulcst_filter_count = 0;
1181 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1186 static __checkReturn efx_rc_t
1187 ef10_filter_insert_all_multicast(
1188 __in efx_nic_t *enp,
1189 __in efx_filter_flags_t filter_flags)
1191 ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
1192 efx_filter_spec_t spec;
1195 /* Insert the unknown multicast filter */
1196 efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO,
1198 eftp->eft_default_rxq);
1199 efx_filter_spec_set_mc_def(&spec);
1201 rc = ef10_filter_add_internal(enp, &spec, B_TRUE,
1202 &eftp->eft_mulcst_filter_indexes[0]);
1206 eftp->eft_mulcst_filter_count = 1;
1207 eftp->eft_using_all_mulcst = B_TRUE;
1210 * FIXME: If brdcst == B_FALSE, add a filter to drop broadcast traffic.
1216 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1221 typedef struct ef10_filter_encap_entry_s {
1222 uint16_t ether_type;
1223 efx_tunnel_protocol_t encap_type;
1224 uint32_t inner_frame_match;
1225 } ef10_filter_encap_entry_t;
1227 #define EF10_ENCAP_FILTER_ENTRY(ipv, encap_type, inner_frame_match) \
1228 { EFX_ETHER_TYPE_##ipv, EFX_TUNNEL_PROTOCOL_##encap_type, \
1229 EFX_FILTER_INNER_FRAME_MATCH_UNKNOWN_##inner_frame_match }
1231 static ef10_filter_encap_entry_t ef10_filter_encap_list[] = {
1232 EF10_ENCAP_FILTER_ENTRY(IPV4, VXLAN, UCAST_DST),
1233 EF10_ENCAP_FILTER_ENTRY(IPV4, VXLAN, MCAST_DST),
1234 EF10_ENCAP_FILTER_ENTRY(IPV6, VXLAN, UCAST_DST),
1235 EF10_ENCAP_FILTER_ENTRY(IPV6, VXLAN, MCAST_DST),
1237 EF10_ENCAP_FILTER_ENTRY(IPV4, GENEVE, UCAST_DST),
1238 EF10_ENCAP_FILTER_ENTRY(IPV4, GENEVE, MCAST_DST),
1239 EF10_ENCAP_FILTER_ENTRY(IPV6, GENEVE, UCAST_DST),
1240 EF10_ENCAP_FILTER_ENTRY(IPV6, GENEVE, MCAST_DST),
1242 EF10_ENCAP_FILTER_ENTRY(IPV4, NVGRE, UCAST_DST),
1243 EF10_ENCAP_FILTER_ENTRY(IPV4, NVGRE, MCAST_DST),
1244 EF10_ENCAP_FILTER_ENTRY(IPV6, NVGRE, UCAST_DST),
1245 EF10_ENCAP_FILTER_ENTRY(IPV6, NVGRE, MCAST_DST),
1248 #undef EF10_ENCAP_FILTER_ENTRY
1250 static __checkReturn efx_rc_t
1251 ef10_filter_insert_encap_filters(
1252 __in efx_nic_t *enp,
1253 __in boolean_t mulcst,
1254 __in efx_filter_flags_t filter_flags)
1256 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
1260 EFX_STATIC_ASSERT(EFX_ARRAY_SIZE(ef10_filter_encap_list) <=
1261 EFX_ARRAY_SIZE(table->eft_encap_filter_indexes));
1264 * On Medford, full-featured firmware can identify packets as being
1265 * tunnel encapsulated, even if no encapsulated packet offloads are in
1266 * use. When packets are identified as such, ordinary filters are not
1267 * applied, only ones specific to encapsulated packets. Hence we need to
1268 * insert filters for encapsulated packets in order to receive them.
1270 * Separate filters need to be inserted for each ether type,
1271 * encapsulation type, and inner frame type (unicast or multicast). To
1272 * keep things simple and reduce the number of filters needed, catch-all
1273 * filters for all combinations of types are inserted, even if
1274 * all_unicst or all_mulcst have not been set. (These catch-all filters
1275 * may well, however, fail to insert on unprivileged functions.)
1277 table->eft_encap_filter_count = 0;
1278 for (i = 0; i < EFX_ARRAY_SIZE(ef10_filter_encap_list); i++) {
1279 efx_filter_spec_t spec;
1280 ef10_filter_encap_entry_t *encap_filter =
1281 &ef10_filter_encap_list[i];
1284 * Skip multicast filters if we've not been asked for
1285 * any multicast traffic.
1287 if ((mulcst == B_FALSE) &&
1288 (encap_filter->inner_frame_match ==
1289 EFX_FILTER_INNER_FRAME_MATCH_UNKNOWN_MCAST_DST))
1292 efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO,
1294 table->eft_default_rxq);
1295 efx_filter_spec_set_ether_type(&spec, encap_filter->ether_type);
1296 rc = efx_filter_spec_set_encap_type(&spec,
1297 encap_filter->encap_type,
1298 encap_filter->inner_frame_match);
1302 rc = ef10_filter_add_internal(enp, &spec, B_TRUE,
1303 &table->eft_encap_filter_indexes[
1304 table->eft_encap_filter_count]);
1309 table->eft_encap_filter_count++;
1318 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1324 ef10_filter_remove_old(
1325 __in efx_nic_t *enp)
1327 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
1330 for (i = 0; i < EFX_ARRAY_SIZE(table->eft_entry); i++) {
1331 if (ef10_filter_entry_is_auto_old(table, i)) {
1332 (void) ef10_filter_delete_internal(enp, i);
1338 static __checkReturn efx_rc_t
1339 ef10_filter_get_workarounds(
1340 __in efx_nic_t *enp)
1342 efx_nic_cfg_t *encp = &enp->en_nic_cfg;
1343 uint32_t implemented = 0;
1344 uint32_t enabled = 0;
1347 rc = efx_mcdi_get_workarounds(enp, &implemented, &enabled);
1349 /* Check if chained multicast filter support is enabled */
1350 if (implemented & enabled & MC_CMD_GET_WORKAROUNDS_OUT_BUG26807)
1351 encp->enc_bug26807_workaround = B_TRUE;
1353 encp->enc_bug26807_workaround = B_FALSE;
1354 } else if (rc == ENOTSUP) {
1356 * Firmware is too old to support GET_WORKAROUNDS, and support
1357 * for this workaround was implemented later.
1359 encp->enc_bug26807_workaround = B_FALSE;
1367 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1375 * Reconfigure all filters.
1376 * If all_unicst and/or all mulcst filters cannot be applied then
1377 * return ENOTSUP (Note the filters for the specified addresses are
1378 * still applied in this case).
1380 __checkReturn efx_rc_t
1381 ef10_filter_reconfigure(
1382 __in efx_nic_t *enp,
1383 __in_ecount(6) uint8_t const *mac_addr,
1384 __in boolean_t all_unicst,
1385 __in boolean_t mulcst,
1386 __in boolean_t all_mulcst,
1387 __in boolean_t brdcst,
1388 __in_ecount(6*count) uint8_t const *addrs,
1389 __in uint32_t count)
1391 efx_nic_cfg_t *encp = &enp->en_nic_cfg;
1392 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
1393 efx_filter_flags_t filter_flags;
1395 efx_rc_t all_unicst_rc = 0;
1396 efx_rc_t all_mulcst_rc = 0;
1399 if (table->eft_default_rxq == NULL) {
1401 * Filters direct traffic to the default RXQ, and so cannot be
1402 * inserted until it is available. Any currently configured
1403 * filters must be removed (ignore errors in case the MC
1404 * has rebooted, which removes hardware filters).
1406 for (i = 0; i < table->eft_unicst_filter_count; i++) {
1407 (void) ef10_filter_delete_internal(enp,
1408 table->eft_unicst_filter_indexes[i]);
1410 table->eft_unicst_filter_count = 0;
1412 for (i = 0; i < table->eft_mulcst_filter_count; i++) {
1413 (void) ef10_filter_delete_internal(enp,
1414 table->eft_mulcst_filter_indexes[i]);
1416 table->eft_mulcst_filter_count = 0;
1418 for (i = 0; i < table->eft_encap_filter_count; i++) {
1419 (void) ef10_filter_delete_internal(enp,
1420 table->eft_encap_filter_indexes[i]);
1422 table->eft_encap_filter_count = 0;
1427 if (table->eft_using_rss)
1428 filter_flags = EFX_FILTER_FLAG_RX_RSS;
1432 /* Mark old filters which may need to be removed */
1433 for (i = 0; i < table->eft_unicst_filter_count; i++) {
1434 ef10_filter_set_entry_auto_old(table,
1435 table->eft_unicst_filter_indexes[i]);
1437 for (i = 0; i < table->eft_mulcst_filter_count; i++) {
1438 ef10_filter_set_entry_auto_old(table,
1439 table->eft_mulcst_filter_indexes[i]);
1441 for (i = 0; i < table->eft_encap_filter_count; i++) {
1442 ef10_filter_set_entry_auto_old(table,
1443 table->eft_encap_filter_indexes[i]);
1447 * Insert or renew unicast filters.
1449 * Frimware does not perform chaining on unicast filters. As traffic is
1450 * therefore only delivered to the first matching filter, we should
1451 * always insert the specific filter for our MAC address, to try and
1452 * ensure we get that traffic.
1454 * (If the filter for our MAC address has already been inserted by
1455 * another function, we won't receive traffic sent to us, even if we
1456 * insert a unicast mismatch filter. To prevent traffic stealing, this
1457 * therefore relies on the privilege model only allowing functions to
1458 * insert filters for their own MAC address unless explicitly given
1459 * additional privileges by the user. This also means that, even on a
1460 * priviliged function, inserting a unicast mismatch filter may not
1461 * catch all traffic in multi PCI function scenarios.)
1463 table->eft_unicst_filter_count = 0;
1464 rc = ef10_filter_insert_unicast(enp, mac_addr, filter_flags);
1465 if (all_unicst || (rc != 0)) {
1466 all_unicst_rc = ef10_filter_insert_all_unicast(enp,
1468 if ((rc != 0) && (all_unicst_rc != 0))
1473 * WORKAROUND_BUG26807 controls firmware support for chained multicast
1474 * filters, and can only be enabled or disabled when the hardware filter
1477 * Chained multicast filters require support from the datapath firmware,
1478 * and may not be available (e.g. low-latency variants or old Huntington
1481 * Firmware will reset (FLR) functions which have inserted filters in
1482 * the hardware filter table when the workaround is enabled/disabled.
1483 * Functions without any hardware filters are not reset.
1485 * Re-check if the workaround is enabled after adding unicast hardware
1486 * filters. This ensures that encp->enc_bug26807_workaround matches the
1487 * firmware state, and that later changes to enable/disable the
1488 * workaround will result in this function seeing a reset (FLR).
1490 * In common-code drivers, we only support multiple PCI function
1491 * scenarios with firmware that supports multicast chaining, so we can
1492 * assume it is enabled for such cases and hence simplify the filter
1493 * insertion logic. Firmware that does not support multicast chaining
1494 * does not support multiple PCI function configurations either, so
1495 * filter insertion is much simpler and the same strategies can still be
1498 if ((rc = ef10_filter_get_workarounds(enp)) != 0)
1501 if ((table->eft_using_all_mulcst != all_mulcst) &&
1502 (encp->enc_bug26807_workaround == B_TRUE)) {
1504 * Multicast filter chaining is enabled, so traffic that matches
1505 * more than one multicast filter will be replicated and
1506 * delivered to multiple recipients. To avoid this duplicate
1507 * delivery, remove old multicast filters before inserting new
1508 * multicast filters.
1510 ef10_filter_remove_old(enp);
1513 /* Insert or renew multicast filters */
1514 if (all_mulcst == B_TRUE) {
1516 * Insert the all multicast filter. If that fails, try to insert
1517 * all of our multicast filters (but without rollback on
1520 all_mulcst_rc = ef10_filter_insert_all_multicast(enp,
1522 if (all_mulcst_rc != 0) {
1523 rc = ef10_filter_insert_multicast_list(enp, B_TRUE,
1524 brdcst, addrs, count, filter_flags, B_FALSE);
1530 * Insert filters for multicast addresses.
1531 * If any insertion fails, then rollback and try to insert the
1532 * all multicast filter instead.
1533 * If that also fails, try to insert all of the multicast
1534 * filters (but without rollback on failure).
1536 rc = ef10_filter_insert_multicast_list(enp, mulcst, brdcst,
1537 addrs, count, filter_flags, B_TRUE);
1539 if ((table->eft_using_all_mulcst == B_FALSE) &&
1540 (encp->enc_bug26807_workaround == B_TRUE)) {
1542 * Multicast filter chaining is on, so remove
1543 * old filters before inserting the multicast
1544 * all filter to avoid duplicate delivery caused
1545 * by packets matching multiple filters.
1547 ef10_filter_remove_old(enp);
1550 rc = ef10_filter_insert_all_multicast(enp,
1553 rc = ef10_filter_insert_multicast_list(enp,
1555 addrs, count, filter_flags, B_FALSE);
1562 if (encp->enc_tunnel_encapsulations_supported != 0) {
1563 /* Try to insert filters for encapsulated packets. */
1564 (void) ef10_filter_insert_encap_filters(enp,
1565 mulcst || all_mulcst || brdcst,
1569 /* Remove old filters which were not renewed */
1570 ef10_filter_remove_old(enp);
1572 /* report if any optional flags were rejected */
1573 if (((all_unicst != B_FALSE) && (all_unicst_rc != 0)) ||
1574 ((all_mulcst != B_FALSE) && (all_mulcst_rc != 0))) {
1587 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1589 /* Clear auto old flags */
1590 for (i = 0; i < EFX_ARRAY_SIZE(table->eft_entry); i++) {
1591 if (ef10_filter_entry_is_auto_old(table, i)) {
1592 ef10_filter_set_entry_not_auto_old(table, i);
1600 ef10_filter_get_default_rxq(
1601 __in efx_nic_t *enp,
1602 __out efx_rxq_t **erpp,
1603 __out boolean_t *using_rss)
1605 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
1607 *erpp = table->eft_default_rxq;
1608 *using_rss = table->eft_using_rss;
1613 ef10_filter_default_rxq_set(
1614 __in efx_nic_t *enp,
1615 __in efx_rxq_t *erp,
1616 __in boolean_t using_rss)
1618 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
1620 #if EFSYS_OPT_RX_SCALE
1621 EFSYS_ASSERT((using_rss == B_FALSE) ||
1622 (enp->en_rss_context != EF10_RSS_CONTEXT_INVALID));
1623 table->eft_using_rss = using_rss;
1625 EFSYS_ASSERT(using_rss == B_FALSE);
1626 table->eft_using_rss = B_FALSE;
1628 table->eft_default_rxq = erp;
1632 ef10_filter_default_rxq_clear(
1633 __in efx_nic_t *enp)
1635 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
1637 table->eft_default_rxq = NULL;
1638 table->eft_using_rss = B_FALSE;
1642 #endif /* EFSYS_OPT_FILTER */
1644 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */