1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2007-2018 Solarflare Communications Inc.
10 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
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);
100 #define MATCH_MASK(match) (EFX_MASK32(match) << EFX_LOW_BIT(match))
101 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_REM_HOST ==
102 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_SRC_IP));
103 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_LOC_HOST ==
104 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_DST_IP));
105 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_REM_MAC ==
106 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_SRC_MAC));
107 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_REM_PORT ==
108 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_SRC_PORT));
109 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_LOC_MAC ==
110 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_DST_MAC));
111 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_LOC_PORT ==
112 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_DST_PORT));
113 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_ETHER_TYPE ==
114 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_ETHER_TYPE));
115 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_INNER_VID ==
116 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_INNER_VLAN));
117 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_OUTER_VID ==
118 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_OUTER_VLAN));
119 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_IP_PROTO ==
120 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_IP_PROTO));
121 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_IFRM_UNKNOWN_MCAST_DST ==
122 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_IFRM_UNKNOWN_MCAST_DST));
123 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_IFRM_UNKNOWN_UCAST_DST ==
124 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_IFRM_UNKNOWN_UCAST_DST));
125 EFX_STATIC_ASSERT(EFX_FILTER_MATCH_UNKNOWN_MCAST_DST ==
126 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_UNKNOWN_MCAST_DST));
127 EFX_STATIC_ASSERT((uint32_t)EFX_FILTER_MATCH_UNKNOWN_UCAST_DST ==
128 MATCH_MASK(MC_CMD_FILTER_OP_EXT_IN_MATCH_UNKNOWN_UCAST_DST));
131 EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (ef10_filter_table_t), eftp);
138 enp->en_filter.ef_ef10_filter_table = eftp;
143 EFSYS_PROBE1(fail1, efx_rc_t, rc);
152 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
153 enp->en_family == EFX_FAMILY_MEDFORD);
155 if (enp->en_filter.ef_ef10_filter_table != NULL) {
156 EFSYS_KMEM_FREE(enp->en_esip, sizeof (ef10_filter_table_t),
157 enp->en_filter.ef_ef10_filter_table);
161 static __checkReturn efx_rc_t
162 efx_mcdi_filter_op_add(
164 __in efx_filter_spec_t *spec,
165 __in unsigned int filter_op,
166 __inout ef10_filter_handle_t *handle)
169 uint8_t payload[MAX(MC_CMD_FILTER_OP_EXT_IN_LEN,
170 MC_CMD_FILTER_OP_EXT_OUT_LEN)];
173 memset(payload, 0, sizeof (payload));
174 req.emr_cmd = MC_CMD_FILTER_OP;
175 req.emr_in_buf = payload;
176 req.emr_in_length = MC_CMD_FILTER_OP_EXT_IN_LEN;
177 req.emr_out_buf = payload;
178 req.emr_out_length = MC_CMD_FILTER_OP_EXT_OUT_LEN;
181 case MC_CMD_FILTER_OP_IN_OP_REPLACE:
182 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_HANDLE_LO,
184 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_HANDLE_HI,
187 case MC_CMD_FILTER_OP_IN_OP_INSERT:
188 case MC_CMD_FILTER_OP_IN_OP_SUBSCRIBE:
189 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_OP, filter_op);
197 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_PORT_ID,
198 EVB_PORT_ID_ASSIGNED);
199 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_MATCH_FIELDS,
200 spec->efs_match_flags);
201 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_RX_DEST,
202 MC_CMD_FILTER_OP_EXT_IN_RX_DEST_HOST);
203 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_RX_QUEUE,
206 #if EFSYS_OPT_RX_SCALE
207 if (spec->efs_flags & EFX_FILTER_FLAG_RX_RSS) {
208 uint32_t rss_context;
210 if (spec->efs_rss_context == EFX_RSS_CONTEXT_DEFAULT)
211 rss_context = enp->en_rss_context;
213 rss_context = spec->efs_rss_context;
214 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_RX_CONTEXT,
219 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_RX_MODE,
220 spec->efs_flags & EFX_FILTER_FLAG_RX_RSS ?
221 MC_CMD_FILTER_OP_EXT_IN_RX_MODE_RSS :
222 MC_CMD_FILTER_OP_EXT_IN_RX_MODE_SIMPLE);
223 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_TX_DEST,
224 MC_CMD_FILTER_OP_EXT_IN_TX_DEST_DEFAULT);
226 if (filter_op != MC_CMD_FILTER_OP_IN_OP_REPLACE) {
228 * NOTE: Unlike most MCDI requests, the filter fields
229 * are presented in network (big endian) byte order.
231 memcpy(MCDI_IN2(req, uint8_t, FILTER_OP_EXT_IN_SRC_MAC),
232 spec->efs_rem_mac, EFX_MAC_ADDR_LEN);
233 memcpy(MCDI_IN2(req, uint8_t, FILTER_OP_EXT_IN_DST_MAC),
234 spec->efs_loc_mac, EFX_MAC_ADDR_LEN);
236 MCDI_IN_SET_WORD(req, FILTER_OP_EXT_IN_SRC_PORT,
237 __CPU_TO_BE_16(spec->efs_rem_port));
238 MCDI_IN_SET_WORD(req, FILTER_OP_EXT_IN_DST_PORT,
239 __CPU_TO_BE_16(spec->efs_loc_port));
241 MCDI_IN_SET_WORD(req, FILTER_OP_EXT_IN_ETHER_TYPE,
242 __CPU_TO_BE_16(spec->efs_ether_type));
244 MCDI_IN_SET_WORD(req, FILTER_OP_EXT_IN_INNER_VLAN,
245 __CPU_TO_BE_16(spec->efs_inner_vid));
246 MCDI_IN_SET_WORD(req, FILTER_OP_EXT_IN_OUTER_VLAN,
247 __CPU_TO_BE_16(spec->efs_outer_vid));
249 /* IP protocol (in low byte, high byte is zero) */
250 MCDI_IN_SET_BYTE(req, FILTER_OP_EXT_IN_IP_PROTO,
253 EFX_STATIC_ASSERT(sizeof (spec->efs_rem_host) ==
254 MC_CMD_FILTER_OP_EXT_IN_SRC_IP_LEN);
255 EFX_STATIC_ASSERT(sizeof (spec->efs_loc_host) ==
256 MC_CMD_FILTER_OP_EXT_IN_DST_IP_LEN);
258 memcpy(MCDI_IN2(req, uint8_t, FILTER_OP_EXT_IN_SRC_IP),
259 &spec->efs_rem_host.eo_byte[0],
260 MC_CMD_FILTER_OP_EXT_IN_SRC_IP_LEN);
261 memcpy(MCDI_IN2(req, uint8_t, FILTER_OP_EXT_IN_DST_IP),
262 &spec->efs_loc_host.eo_byte[0],
263 MC_CMD_FILTER_OP_EXT_IN_DST_IP_LEN);
266 * On Medford, filters for encapsulated packets match based on
267 * the ether type and IP protocol in the outer frame. In
268 * addition we need to fill in the VNI or VSID type field.
270 switch (spec->efs_encap_type) {
271 case EFX_TUNNEL_PROTOCOL_NONE:
273 case EFX_TUNNEL_PROTOCOL_VXLAN:
274 case EFX_TUNNEL_PROTOCOL_GENEVE:
275 MCDI_IN_POPULATE_DWORD_1(req,
276 FILTER_OP_EXT_IN_VNI_OR_VSID,
277 FILTER_OP_EXT_IN_VNI_TYPE,
278 spec->efs_encap_type == EFX_TUNNEL_PROTOCOL_VXLAN ?
279 MC_CMD_FILTER_OP_EXT_IN_VNI_TYPE_VXLAN :
280 MC_CMD_FILTER_OP_EXT_IN_VNI_TYPE_GENEVE);
282 case EFX_TUNNEL_PROTOCOL_NVGRE:
283 MCDI_IN_POPULATE_DWORD_1(req,
284 FILTER_OP_EXT_IN_VNI_OR_VSID,
285 FILTER_OP_EXT_IN_VSID_TYPE,
286 MC_CMD_FILTER_OP_EXT_IN_VSID_TYPE_NVGRE);
295 efx_mcdi_execute(enp, &req);
297 if (req.emr_rc != 0) {
302 if (req.emr_out_length_used < MC_CMD_FILTER_OP_EXT_OUT_LEN) {
307 handle->efh_lo = MCDI_OUT_DWORD(req, FILTER_OP_EXT_OUT_HANDLE_LO);
308 handle->efh_hi = MCDI_OUT_DWORD(req, FILTER_OP_EXT_OUT_HANDLE_HI);
319 EFSYS_PROBE1(fail1, efx_rc_t, rc);
325 static __checkReturn efx_rc_t
326 efx_mcdi_filter_op_delete(
328 __in unsigned int filter_op,
329 __inout ef10_filter_handle_t *handle)
332 uint8_t payload[MAX(MC_CMD_FILTER_OP_EXT_IN_LEN,
333 MC_CMD_FILTER_OP_EXT_OUT_LEN)];
336 memset(payload, 0, sizeof (payload));
337 req.emr_cmd = MC_CMD_FILTER_OP;
338 req.emr_in_buf = payload;
339 req.emr_in_length = MC_CMD_FILTER_OP_EXT_IN_LEN;
340 req.emr_out_buf = payload;
341 req.emr_out_length = MC_CMD_FILTER_OP_EXT_OUT_LEN;
344 case MC_CMD_FILTER_OP_IN_OP_REMOVE:
345 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_OP,
346 MC_CMD_FILTER_OP_IN_OP_REMOVE);
348 case MC_CMD_FILTER_OP_IN_OP_UNSUBSCRIBE:
349 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_OP,
350 MC_CMD_FILTER_OP_IN_OP_UNSUBSCRIBE);
358 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_HANDLE_LO, handle->efh_lo);
359 MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_HANDLE_HI, handle->efh_hi);
361 efx_mcdi_execute_quiet(enp, &req);
363 if (req.emr_rc != 0) {
368 if (req.emr_out_length_used < MC_CMD_FILTER_OP_EXT_OUT_LEN) {
381 EFSYS_PROBE1(fail1, efx_rc_t, rc);
386 static __checkReturn boolean_t
388 __in const efx_filter_spec_t *left,
389 __in const efx_filter_spec_t *right)
391 /* FIXME: Consider rx vs tx filters (look at efs_flags) */
392 if (left->efs_match_flags != right->efs_match_flags)
394 if (!EFX_OWORD_IS_EQUAL(left->efs_rem_host, right->efs_rem_host))
396 if (!EFX_OWORD_IS_EQUAL(left->efs_loc_host, right->efs_loc_host))
398 if (memcmp(left->efs_rem_mac, right->efs_rem_mac, EFX_MAC_ADDR_LEN))
400 if (memcmp(left->efs_loc_mac, right->efs_loc_mac, EFX_MAC_ADDR_LEN))
402 if (left->efs_rem_port != right->efs_rem_port)
404 if (left->efs_loc_port != right->efs_loc_port)
406 if (left->efs_inner_vid != right->efs_inner_vid)
408 if (left->efs_outer_vid != right->efs_outer_vid)
410 if (left->efs_ether_type != right->efs_ether_type)
412 if (left->efs_ip_proto != right->efs_ip_proto)
414 if (left->efs_encap_type != right->efs_encap_type)
421 static __checkReturn boolean_t
422 ef10_filter_same_dest(
423 __in const efx_filter_spec_t *left,
424 __in const efx_filter_spec_t *right)
426 if ((left->efs_flags & EFX_FILTER_FLAG_RX_RSS) &&
427 (right->efs_flags & EFX_FILTER_FLAG_RX_RSS)) {
428 if (left->efs_rss_context == right->efs_rss_context)
430 } else if ((~(left->efs_flags) & EFX_FILTER_FLAG_RX_RSS) &&
431 (~(right->efs_flags) & EFX_FILTER_FLAG_RX_RSS)) {
432 if (left->efs_dmaq_id == right->efs_dmaq_id)
438 static __checkReturn uint32_t
440 __in efx_filter_spec_t *spec)
442 EFX_STATIC_ASSERT((sizeof (efx_filter_spec_t) % sizeof (uint32_t))
444 EFX_STATIC_ASSERT((EFX_FIELD_OFFSET(efx_filter_spec_t, efs_outer_vid) %
445 sizeof (uint32_t)) == 0);
448 * As the area of the efx_filter_spec_t we need to hash is DWORD
449 * aligned and an exact number of DWORDs in size we can use the
450 * optimised efx_hash_dwords() rather than efx_hash_bytes()
452 return (efx_hash_dwords((const uint32_t *)&spec->efs_outer_vid,
453 (sizeof (efx_filter_spec_t) -
454 EFX_FIELD_OFFSET(efx_filter_spec_t, efs_outer_vid)) /
455 sizeof (uint32_t), 0));
459 * Decide whether a filter should be exclusive or else should allow
460 * delivery to additional recipients. Currently we decide that
461 * filters for specific local unicast MAC and IP addresses are
464 static __checkReturn boolean_t
465 ef10_filter_is_exclusive(
466 __in efx_filter_spec_t *spec)
468 if ((spec->efs_match_flags & EFX_FILTER_MATCH_LOC_MAC) &&
469 !EFX_MAC_ADDR_IS_MULTICAST(spec->efs_loc_mac))
472 if ((spec->efs_match_flags &
473 (EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_LOC_HOST)) ==
474 (EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_LOC_HOST)) {
475 if ((spec->efs_ether_type == EFX_ETHER_TYPE_IPV4) &&
476 ((spec->efs_loc_host.eo_u8[0] & 0xf) != 0xe))
478 if ((spec->efs_ether_type == EFX_ETHER_TYPE_IPV6) &&
479 (spec->efs_loc_host.eo_u8[0] != 0xff))
486 __checkReturn efx_rc_t
491 efx_filter_spec_t *spec;
492 ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
494 efsys_lock_state_t state;
497 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
498 enp->en_family == EFX_FAMILY_MEDFORD);
500 for (tbl_id = 0; tbl_id < EFX_EF10_FILTER_TBL_ROWS; tbl_id++) {
502 EFSYS_LOCK(enp->en_eslp, state);
504 spec = ef10_filter_entry_spec(eftp, tbl_id);
507 } else if (ef10_filter_entry_is_busy(eftp, tbl_id)) {
508 /* Ignore busy entries. */
511 ef10_filter_set_entry_busy(eftp, tbl_id);
515 EFSYS_UNLOCK(enp->en_eslp, state);
517 if (restoring == B_FALSE)
520 if (ef10_filter_is_exclusive(spec)) {
521 rc = efx_mcdi_filter_op_add(enp, spec,
522 MC_CMD_FILTER_OP_IN_OP_INSERT,
523 &eftp->eft_entry[tbl_id].efe_handle);
525 rc = efx_mcdi_filter_op_add(enp, spec,
526 MC_CMD_FILTER_OP_IN_OP_SUBSCRIBE,
527 &eftp->eft_entry[tbl_id].efe_handle);
533 EFSYS_LOCK(enp->en_eslp, state);
535 ef10_filter_set_entry_not_busy(eftp, tbl_id);
537 EFSYS_UNLOCK(enp->en_eslp, state);
543 EFSYS_PROBE1(fail1, efx_rc_t, rc);
549 * An arbitrary search limit for the software hash table. As per the linux net
552 #define EF10_FILTER_SEARCH_LIMIT 200
554 static __checkReturn efx_rc_t
555 ef10_filter_add_internal(
557 __inout efx_filter_spec_t *spec,
558 __in boolean_t may_replace,
559 __out_opt uint32_t *filter_id)
562 ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
563 efx_filter_spec_t *saved_spec;
567 boolean_t replacing = B_FALSE;
569 efsys_lock_state_t state;
570 boolean_t locked = B_FALSE;
572 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
573 enp->en_family == EFX_FAMILY_MEDFORD);
575 hash = ef10_filter_hash(spec);
578 * FIXME: Add support for inserting filters of different priorities
579 * and removing lower priority multicast filters (bug 42378)
583 * Find any existing filters with the same match tuple or
584 * else a free slot to insert at. If any of them are busy,
585 * we have to wait and retry.
590 EFSYS_LOCK(enp->en_eslp, state);
594 i = (hash + depth) & (EFX_EF10_FILTER_TBL_ROWS - 1);
595 saved_spec = ef10_filter_entry_spec(eftp, i);
601 } else if (ef10_filter_equal(spec, saved_spec)) {
602 if (ef10_filter_entry_is_busy(eftp, i))
604 if (saved_spec->efs_priority
605 == EFX_FILTER_PRI_AUTO) {
608 } else if (ef10_filter_is_exclusive(spec)) {
622 * Once we reach the maximum search depth, use
623 * the first suitable slot or return EBUSY if
626 if (depth == EF10_FILTER_SEARCH_LIMIT) {
635 EFSYS_UNLOCK(enp->en_eslp, state);
641 * Create a software table entry if necessary, and mark it
642 * busy. We might yet fail to insert, but any attempt to
643 * insert a conflicting filter while we're waiting for the
644 * firmware must find the busy entry.
646 saved_spec = ef10_filter_entry_spec(eftp, ins_index);
648 if (saved_spec->efs_priority == EFX_FILTER_PRI_AUTO) {
649 /* This is a filter we are refreshing */
650 ef10_filter_set_entry_not_auto_old(eftp, ins_index);
656 EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (*spec), saved_spec);
662 ef10_filter_set_entry(eftp, ins_index, saved_spec);
664 ef10_filter_set_entry_busy(eftp, ins_index);
666 EFSYS_UNLOCK(enp->en_eslp, state);
670 * On replacing the filter handle may change after after a successful
674 rc = efx_mcdi_filter_op_add(enp, spec,
675 MC_CMD_FILTER_OP_IN_OP_REPLACE,
676 &eftp->eft_entry[ins_index].efe_handle);
677 } else if (ef10_filter_is_exclusive(spec)) {
678 rc = efx_mcdi_filter_op_add(enp, spec,
679 MC_CMD_FILTER_OP_IN_OP_INSERT,
680 &eftp->eft_entry[ins_index].efe_handle);
682 rc = efx_mcdi_filter_op_add(enp, spec,
683 MC_CMD_FILTER_OP_IN_OP_SUBSCRIBE,
684 &eftp->eft_entry[ins_index].efe_handle);
690 EFSYS_LOCK(enp->en_eslp, state);
694 /* Update the fields that may differ */
695 saved_spec->efs_priority = spec->efs_priority;
696 saved_spec->efs_flags = spec->efs_flags;
697 saved_spec->efs_rss_context = spec->efs_rss_context;
698 saved_spec->efs_dmaq_id = spec->efs_dmaq_id;
701 ef10_filter_set_entry_not_busy(eftp, ins_index);
705 EFSYS_UNLOCK(enp->en_eslp, state);
709 *filter_id = ins_index;
717 EFSYS_KMEM_FREE(enp->en_esip, sizeof (*spec), saved_spec);
720 ef10_filter_set_entry_not_busy(eftp, ins_index);
721 ef10_filter_set_entry(eftp, ins_index, NULL);
730 EFSYS_PROBE1(fail1, efx_rc_t, rc);
733 EFSYS_UNLOCK(enp->en_eslp, state);
738 __checkReturn efx_rc_t
741 __inout efx_filter_spec_t *spec,
742 __in boolean_t may_replace)
746 rc = ef10_filter_add_internal(enp, spec, may_replace, NULL);
753 EFSYS_PROBE1(fail1, efx_rc_t, rc);
759 static __checkReturn efx_rc_t
760 ef10_filter_delete_internal(
762 __in uint32_t filter_id)
765 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
766 efx_filter_spec_t *spec;
767 efsys_lock_state_t state;
768 uint32_t filter_idx = filter_id % EFX_EF10_FILTER_TBL_ROWS;
771 * Find the software table entry and mark it busy. Don't
772 * remove it yet; any attempt to update while we're waiting
773 * for the firmware must find the busy entry.
775 * FIXME: What if the busy flag is never cleared?
777 EFSYS_LOCK(enp->en_eslp, state);
778 while (ef10_filter_entry_is_busy(table, filter_idx)) {
779 EFSYS_UNLOCK(enp->en_eslp, state);
781 EFSYS_LOCK(enp->en_eslp, state);
783 if ((spec = ef10_filter_entry_spec(table, filter_idx)) != NULL) {
784 ef10_filter_set_entry_busy(table, filter_idx);
786 EFSYS_UNLOCK(enp->en_eslp, state);
794 * Try to remove the hardware filter. This may fail if the MC has
795 * rebooted (which frees all hardware filter resources).
797 if (ef10_filter_is_exclusive(spec)) {
798 rc = efx_mcdi_filter_op_delete(enp,
799 MC_CMD_FILTER_OP_IN_OP_REMOVE,
800 &table->eft_entry[filter_idx].efe_handle);
802 rc = efx_mcdi_filter_op_delete(enp,
803 MC_CMD_FILTER_OP_IN_OP_UNSUBSCRIBE,
804 &table->eft_entry[filter_idx].efe_handle);
807 /* Free the software table entry */
808 EFSYS_LOCK(enp->en_eslp, state);
809 ef10_filter_set_entry_not_busy(table, filter_idx);
810 ef10_filter_set_entry(table, filter_idx, NULL);
811 EFSYS_UNLOCK(enp->en_eslp, state);
813 EFSYS_KMEM_FREE(enp->en_esip, sizeof (*spec), spec);
815 /* Check result of hardware filter removal */
825 EFSYS_PROBE1(fail1, efx_rc_t, rc);
830 __checkReturn efx_rc_t
833 __inout efx_filter_spec_t *spec)
836 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
837 efx_filter_spec_t *saved_spec;
841 efsys_lock_state_t state;
842 boolean_t locked = B_FALSE;
844 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
845 enp->en_family == EFX_FAMILY_MEDFORD);
847 hash = ef10_filter_hash(spec);
849 EFSYS_LOCK(enp->en_eslp, state);
854 i = (hash + depth) & (EFX_EF10_FILTER_TBL_ROWS - 1);
855 saved_spec = ef10_filter_entry_spec(table, i);
856 if (saved_spec && ef10_filter_equal(spec, saved_spec) &&
857 ef10_filter_same_dest(spec, saved_spec)) {
860 if (depth == EF10_FILTER_SEARCH_LIMIT) {
867 EFSYS_UNLOCK(enp->en_eslp, state);
870 rc = ef10_filter_delete_internal(enp, i);
880 EFSYS_PROBE1(fail1, efx_rc_t, rc);
883 EFSYS_UNLOCK(enp->en_eslp, state);
888 static __checkReturn efx_rc_t
889 efx_mcdi_get_parser_disp_info(
891 __out_ecount(buffer_length) uint32_t *buffer,
892 __in size_t buffer_length,
893 __out size_t *list_lengthp)
896 uint8_t payload[MAX(MC_CMD_GET_PARSER_DISP_INFO_IN_LEN,
897 MC_CMD_GET_PARSER_DISP_INFO_OUT_LENMAX)];
898 size_t matches_count;
902 (void) memset(payload, 0, sizeof (payload));
903 req.emr_cmd = MC_CMD_GET_PARSER_DISP_INFO;
904 req.emr_in_buf = payload;
905 req.emr_in_length = MC_CMD_GET_PARSER_DISP_INFO_IN_LEN;
906 req.emr_out_buf = payload;
907 req.emr_out_length = MC_CMD_GET_PARSER_DISP_INFO_OUT_LENMAX;
909 MCDI_IN_SET_DWORD(req, GET_PARSER_DISP_INFO_OUT_OP,
910 MC_CMD_GET_PARSER_DISP_INFO_IN_OP_GET_SUPPORTED_RX_MATCHES);
912 efx_mcdi_execute(enp, &req);
914 if (req.emr_rc != 0) {
919 matches_count = MCDI_OUT_DWORD(req,
920 GET_PARSER_DISP_INFO_OUT_NUM_SUPPORTED_MATCHES);
922 if (req.emr_out_length_used <
923 MC_CMD_GET_PARSER_DISP_INFO_OUT_LEN(matches_count)) {
928 *list_lengthp = matches_count;
930 if (buffer_length < matches_count) {
936 * Check that the elements in the list in the MCDI response are the size
937 * we expect, so we can just copy them directly. Any conversion of the
938 * flags is handled by the caller.
940 EFX_STATIC_ASSERT(sizeof (uint32_t) ==
941 MC_CMD_GET_PARSER_DISP_INFO_OUT_SUPPORTED_MATCHES_LEN);
943 list_size = matches_count *
944 MC_CMD_GET_PARSER_DISP_INFO_OUT_SUPPORTED_MATCHES_LEN;
946 MCDI_OUT2(req, uint32_t,
947 GET_PARSER_DISP_INFO_OUT_SUPPORTED_MATCHES),
957 EFSYS_PROBE1(fail1, efx_rc_t, rc);
962 __checkReturn efx_rc_t
963 ef10_filter_supported_filters(
965 __out_ecount(buffer_length) uint32_t *buffer,
966 __in size_t buffer_length,
967 __out size_t *list_lengthp)
970 size_t mcdi_list_length;
974 efx_filter_match_flags_t all_filter_flags =
975 (EFX_FILTER_MATCH_REM_HOST | EFX_FILTER_MATCH_LOC_HOST |
976 EFX_FILTER_MATCH_REM_MAC | EFX_FILTER_MATCH_REM_PORT |
977 EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_PORT |
978 EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_INNER_VID |
979 EFX_FILTER_MATCH_OUTER_VID | EFX_FILTER_MATCH_IP_PROTO |
980 EFX_FILTER_MATCH_UNKNOWN_MCAST_DST |
981 EFX_FILTER_MATCH_UNKNOWN_UCAST_DST);
983 rc = efx_mcdi_get_parser_disp_info(enp, buffer, buffer_length,
987 /* Pass through mcdi_list_length for the list length */
988 *list_lengthp = mcdi_list_length;
994 * The static assertions in ef10_filter_init() ensure that the values of
995 * the EFX_FILTER_MATCH flags match those used by MCDI, so they don't
996 * need to be converted.
998 * In case support is added to MCDI for additional flags, remove any
999 * matches from the list which include flags we don't support. The order
1000 * of the matches is preserved as they are ordered from highest to
1003 EFSYS_ASSERT(mcdi_list_length <= buffer_length);
1005 for (i = 0; i < mcdi_list_length; i++) {
1006 if ((buffer[i] & ~all_filter_flags) == 0) {
1007 buffer[list_length] = buffer[i];
1012 *list_lengthp = list_length;
1017 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1022 static __checkReturn efx_rc_t
1023 ef10_filter_insert_unicast(
1024 __in efx_nic_t *enp,
1025 __in_ecount(6) uint8_t const *addr,
1026 __in efx_filter_flags_t filter_flags)
1028 ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
1029 efx_filter_spec_t spec;
1032 /* Insert the filter for the local station address */
1033 efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO,
1035 eftp->eft_default_rxq);
1036 efx_filter_spec_set_eth_local(&spec, EFX_FILTER_SPEC_VID_UNSPEC, addr);
1038 rc = ef10_filter_add_internal(enp, &spec, B_TRUE,
1039 &eftp->eft_unicst_filter_indexes[eftp->eft_unicst_filter_count]);
1043 eftp->eft_unicst_filter_count++;
1044 EFSYS_ASSERT(eftp->eft_unicst_filter_count <=
1045 EFX_EF10_FILTER_UNICAST_FILTERS_MAX);
1050 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1054 static __checkReturn efx_rc_t
1055 ef10_filter_insert_all_unicast(
1056 __in efx_nic_t *enp,
1057 __in efx_filter_flags_t filter_flags)
1059 ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
1060 efx_filter_spec_t spec;
1063 /* Insert the unknown unicast filter */
1064 efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO,
1066 eftp->eft_default_rxq);
1067 efx_filter_spec_set_uc_def(&spec);
1068 rc = ef10_filter_add_internal(enp, &spec, B_TRUE,
1069 &eftp->eft_unicst_filter_indexes[eftp->eft_unicst_filter_count]);
1073 eftp->eft_unicst_filter_count++;
1074 EFSYS_ASSERT(eftp->eft_unicst_filter_count <=
1075 EFX_EF10_FILTER_UNICAST_FILTERS_MAX);
1080 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1084 static __checkReturn efx_rc_t
1085 ef10_filter_insert_multicast_list(
1086 __in efx_nic_t *enp,
1087 __in boolean_t mulcst,
1088 __in boolean_t brdcst,
1089 __in_ecount(6*count) uint8_t const *addrs,
1090 __in uint32_t count,
1091 __in efx_filter_flags_t filter_flags,
1092 __in boolean_t rollback)
1094 ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
1095 efx_filter_spec_t spec;
1098 uint32_t filter_index;
1099 uint32_t filter_count;
1102 if (mulcst == B_FALSE)
1105 if (count + (brdcst ? 1 : 0) >
1106 EFX_ARRAY_SIZE(eftp->eft_mulcst_filter_indexes)) {
1107 /* Too many MAC addresses */
1112 /* Insert/renew multicast address list filters */
1114 for (i = 0; i < count; i++) {
1115 efx_filter_spec_init_rx(&spec,
1116 EFX_FILTER_PRI_AUTO,
1118 eftp->eft_default_rxq);
1120 efx_filter_spec_set_eth_local(&spec,
1121 EFX_FILTER_SPEC_VID_UNSPEC,
1122 &addrs[i * EFX_MAC_ADDR_LEN]);
1124 rc = ef10_filter_add_internal(enp, &spec, B_TRUE,
1128 eftp->eft_mulcst_filter_indexes[filter_count] =
1131 } else if (rollback == B_TRUE) {
1132 /* Only stop upon failure if told to rollback */
1138 if (brdcst == B_TRUE) {
1139 /* Insert/renew broadcast address filter */
1140 efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO,
1142 eftp->eft_default_rxq);
1144 EFX_MAC_BROADCAST_ADDR_SET(addr);
1145 efx_filter_spec_set_eth_local(&spec, EFX_FILTER_SPEC_VID_UNSPEC,
1148 rc = ef10_filter_add_internal(enp, &spec, B_TRUE,
1152 eftp->eft_mulcst_filter_indexes[filter_count] =
1155 } else if (rollback == B_TRUE) {
1156 /* Only stop upon failure if told to rollback */
1161 eftp->eft_mulcst_filter_count = filter_count;
1162 eftp->eft_using_all_mulcst = B_FALSE;
1167 /* Remove any filters we have inserted */
1170 (void) ef10_filter_delete_internal(enp,
1171 eftp->eft_mulcst_filter_indexes[i]);
1173 eftp->eft_mulcst_filter_count = 0;
1176 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1181 static __checkReturn efx_rc_t
1182 ef10_filter_insert_all_multicast(
1183 __in efx_nic_t *enp,
1184 __in efx_filter_flags_t filter_flags)
1186 ef10_filter_table_t *eftp = enp->en_filter.ef_ef10_filter_table;
1187 efx_filter_spec_t spec;
1190 /* Insert the unknown multicast filter */
1191 efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO,
1193 eftp->eft_default_rxq);
1194 efx_filter_spec_set_mc_def(&spec);
1196 rc = ef10_filter_add_internal(enp, &spec, B_TRUE,
1197 &eftp->eft_mulcst_filter_indexes[0]);
1201 eftp->eft_mulcst_filter_count = 1;
1202 eftp->eft_using_all_mulcst = B_TRUE;
1205 * FIXME: If brdcst == B_FALSE, add a filter to drop broadcast traffic.
1211 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1216 typedef struct ef10_filter_encap_entry_s {
1217 uint16_t ether_type;
1218 efx_tunnel_protocol_t encap_type;
1219 uint32_t inner_frame_match;
1220 } ef10_filter_encap_entry_t;
1222 #define EF10_ENCAP_FILTER_ENTRY(ipv, encap_type, inner_frame_match) \
1223 { EFX_ETHER_TYPE_##ipv, EFX_TUNNEL_PROTOCOL_##encap_type, \
1224 EFX_FILTER_INNER_FRAME_MATCH_UNKNOWN_##inner_frame_match }
1226 static ef10_filter_encap_entry_t ef10_filter_encap_list[] = {
1227 EF10_ENCAP_FILTER_ENTRY(IPV4, VXLAN, UCAST_DST),
1228 EF10_ENCAP_FILTER_ENTRY(IPV4, VXLAN, MCAST_DST),
1229 EF10_ENCAP_FILTER_ENTRY(IPV6, VXLAN, UCAST_DST),
1230 EF10_ENCAP_FILTER_ENTRY(IPV6, VXLAN, MCAST_DST),
1232 EF10_ENCAP_FILTER_ENTRY(IPV4, GENEVE, UCAST_DST),
1233 EF10_ENCAP_FILTER_ENTRY(IPV4, GENEVE, MCAST_DST),
1234 EF10_ENCAP_FILTER_ENTRY(IPV6, GENEVE, UCAST_DST),
1235 EF10_ENCAP_FILTER_ENTRY(IPV6, GENEVE, MCAST_DST),
1237 EF10_ENCAP_FILTER_ENTRY(IPV4, NVGRE, UCAST_DST),
1238 EF10_ENCAP_FILTER_ENTRY(IPV4, NVGRE, MCAST_DST),
1239 EF10_ENCAP_FILTER_ENTRY(IPV6, NVGRE, UCAST_DST),
1240 EF10_ENCAP_FILTER_ENTRY(IPV6, NVGRE, MCAST_DST),
1243 #undef EF10_ENCAP_FILTER_ENTRY
1245 static __checkReturn efx_rc_t
1246 ef10_filter_insert_encap_filters(
1247 __in efx_nic_t *enp,
1248 __in boolean_t mulcst,
1249 __in efx_filter_flags_t filter_flags)
1251 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
1255 EFX_STATIC_ASSERT(EFX_ARRAY_SIZE(ef10_filter_encap_list) <=
1256 EFX_ARRAY_SIZE(table->eft_encap_filter_indexes));
1259 * On Medford, full-featured firmware can identify packets as being
1260 * tunnel encapsulated, even if no encapsulated packet offloads are in
1261 * use. When packets are identified as such, ordinary filters are not
1262 * applied, only ones specific to encapsulated packets. Hence we need to
1263 * insert filters for encapsulated packets in order to receive them.
1265 * Separate filters need to be inserted for each ether type,
1266 * encapsulation type, and inner frame type (unicast or multicast). To
1267 * keep things simple and reduce the number of filters needed, catch-all
1268 * filters for all combinations of types are inserted, even if
1269 * all_unicst or all_mulcst have not been set. (These catch-all filters
1270 * may well, however, fail to insert on unprivileged functions.)
1272 table->eft_encap_filter_count = 0;
1273 for (i = 0; i < EFX_ARRAY_SIZE(ef10_filter_encap_list); i++) {
1274 efx_filter_spec_t spec;
1275 ef10_filter_encap_entry_t *encap_filter =
1276 &ef10_filter_encap_list[i];
1279 * Skip multicast filters if we've not been asked for
1280 * any multicast traffic.
1282 if ((mulcst == B_FALSE) &&
1283 (encap_filter->inner_frame_match ==
1284 EFX_FILTER_INNER_FRAME_MATCH_UNKNOWN_MCAST_DST))
1287 efx_filter_spec_init_rx(&spec, EFX_FILTER_PRI_AUTO,
1289 table->eft_default_rxq);
1290 efx_filter_spec_set_ether_type(&spec, encap_filter->ether_type);
1291 rc = efx_filter_spec_set_encap_type(&spec,
1292 encap_filter->encap_type,
1293 encap_filter->inner_frame_match);
1297 rc = ef10_filter_add_internal(enp, &spec, B_TRUE,
1298 &table->eft_encap_filter_indexes[
1299 table->eft_encap_filter_count]);
1304 table->eft_encap_filter_count++;
1313 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1319 ef10_filter_remove_old(
1320 __in efx_nic_t *enp)
1322 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
1325 for (i = 0; i < EFX_ARRAY_SIZE(table->eft_entry); i++) {
1326 if (ef10_filter_entry_is_auto_old(table, i)) {
1327 (void) ef10_filter_delete_internal(enp, i);
1333 static __checkReturn efx_rc_t
1334 ef10_filter_get_workarounds(
1335 __in efx_nic_t *enp)
1337 efx_nic_cfg_t *encp = &enp->en_nic_cfg;
1338 uint32_t implemented = 0;
1339 uint32_t enabled = 0;
1342 rc = efx_mcdi_get_workarounds(enp, &implemented, &enabled);
1344 /* Check if chained multicast filter support is enabled */
1345 if (implemented & enabled & MC_CMD_GET_WORKAROUNDS_OUT_BUG26807)
1346 encp->enc_bug26807_workaround = B_TRUE;
1348 encp->enc_bug26807_workaround = B_FALSE;
1349 } else if (rc == ENOTSUP) {
1351 * Firmware is too old to support GET_WORKAROUNDS, and support
1352 * for this workaround was implemented later.
1354 encp->enc_bug26807_workaround = B_FALSE;
1362 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1370 * Reconfigure all filters.
1371 * If all_unicst and/or all mulcst filters cannot be applied then
1372 * return ENOTSUP (Note the filters for the specified addresses are
1373 * still applied in this case).
1375 __checkReturn efx_rc_t
1376 ef10_filter_reconfigure(
1377 __in efx_nic_t *enp,
1378 __in_ecount(6) uint8_t const *mac_addr,
1379 __in boolean_t all_unicst,
1380 __in boolean_t mulcst,
1381 __in boolean_t all_mulcst,
1382 __in boolean_t brdcst,
1383 __in_ecount(6*count) uint8_t const *addrs,
1384 __in uint32_t count)
1386 efx_nic_cfg_t *encp = &enp->en_nic_cfg;
1387 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
1388 efx_filter_flags_t filter_flags;
1390 efx_rc_t all_unicst_rc = 0;
1391 efx_rc_t all_mulcst_rc = 0;
1394 if (table->eft_default_rxq == NULL) {
1396 * Filters direct traffic to the default RXQ, and so cannot be
1397 * inserted until it is available. Any currently configured
1398 * filters must be removed (ignore errors in case the MC
1399 * has rebooted, which removes hardware filters).
1401 for (i = 0; i < table->eft_unicst_filter_count; i++) {
1402 (void) ef10_filter_delete_internal(enp,
1403 table->eft_unicst_filter_indexes[i]);
1405 table->eft_unicst_filter_count = 0;
1407 for (i = 0; i < table->eft_mulcst_filter_count; i++) {
1408 (void) ef10_filter_delete_internal(enp,
1409 table->eft_mulcst_filter_indexes[i]);
1411 table->eft_mulcst_filter_count = 0;
1413 for (i = 0; i < table->eft_encap_filter_count; i++) {
1414 (void) ef10_filter_delete_internal(enp,
1415 table->eft_encap_filter_indexes[i]);
1417 table->eft_encap_filter_count = 0;
1422 if (table->eft_using_rss)
1423 filter_flags = EFX_FILTER_FLAG_RX_RSS;
1427 /* Mark old filters which may need to be removed */
1428 for (i = 0; i < table->eft_unicst_filter_count; i++) {
1429 ef10_filter_set_entry_auto_old(table,
1430 table->eft_unicst_filter_indexes[i]);
1432 for (i = 0; i < table->eft_mulcst_filter_count; i++) {
1433 ef10_filter_set_entry_auto_old(table,
1434 table->eft_mulcst_filter_indexes[i]);
1436 for (i = 0; i < table->eft_encap_filter_count; i++) {
1437 ef10_filter_set_entry_auto_old(table,
1438 table->eft_encap_filter_indexes[i]);
1442 * Insert or renew unicast filters.
1444 * Frimware does not perform chaining on unicast filters. As traffic is
1445 * therefore only delivered to the first matching filter, we should
1446 * always insert the specific filter for our MAC address, to try and
1447 * ensure we get that traffic.
1449 * (If the filter for our MAC address has already been inserted by
1450 * another function, we won't receive traffic sent to us, even if we
1451 * insert a unicast mismatch filter. To prevent traffic stealing, this
1452 * therefore relies on the privilege model only allowing functions to
1453 * insert filters for their own MAC address unless explicitly given
1454 * additional privileges by the user. This also means that, even on a
1455 * priviliged function, inserting a unicast mismatch filter may not
1456 * catch all traffic in multi PCI function scenarios.)
1458 table->eft_unicst_filter_count = 0;
1459 rc = ef10_filter_insert_unicast(enp, mac_addr, filter_flags);
1460 if (all_unicst || (rc != 0)) {
1461 all_unicst_rc = ef10_filter_insert_all_unicast(enp,
1463 if ((rc != 0) && (all_unicst_rc != 0))
1468 * WORKAROUND_BUG26807 controls firmware support for chained multicast
1469 * filters, and can only be enabled or disabled when the hardware filter
1472 * Chained multicast filters require support from the datapath firmware,
1473 * and may not be available (e.g. low-latency variants or old Huntington
1476 * Firmware will reset (FLR) functions which have inserted filters in
1477 * the hardware filter table when the workaround is enabled/disabled.
1478 * Functions without any hardware filters are not reset.
1480 * Re-check if the workaround is enabled after adding unicast hardware
1481 * filters. This ensures that encp->enc_bug26807_workaround matches the
1482 * firmware state, and that later changes to enable/disable the
1483 * workaround will result in this function seeing a reset (FLR).
1485 * In common-code drivers, we only support multiple PCI function
1486 * scenarios with firmware that supports multicast chaining, so we can
1487 * assume it is enabled for such cases and hence simplify the filter
1488 * insertion logic. Firmware that does not support multicast chaining
1489 * does not support multiple PCI function configurations either, so
1490 * filter insertion is much simpler and the same strategies can still be
1493 if ((rc = ef10_filter_get_workarounds(enp)) != 0)
1496 if ((table->eft_using_all_mulcst != all_mulcst) &&
1497 (encp->enc_bug26807_workaround == B_TRUE)) {
1499 * Multicast filter chaining is enabled, so traffic that matches
1500 * more than one multicast filter will be replicated and
1501 * delivered to multiple recipients. To avoid this duplicate
1502 * delivery, remove old multicast filters before inserting new
1503 * multicast filters.
1505 ef10_filter_remove_old(enp);
1508 /* Insert or renew multicast filters */
1509 if (all_mulcst == B_TRUE) {
1511 * Insert the all multicast filter. If that fails, try to insert
1512 * all of our multicast filters (but without rollback on
1515 all_mulcst_rc = ef10_filter_insert_all_multicast(enp,
1517 if (all_mulcst_rc != 0) {
1518 rc = ef10_filter_insert_multicast_list(enp, B_TRUE,
1519 brdcst, addrs, count, filter_flags, B_FALSE);
1525 * Insert filters for multicast addresses.
1526 * If any insertion fails, then rollback and try to insert the
1527 * all multicast filter instead.
1528 * If that also fails, try to insert all of the multicast
1529 * filters (but without rollback on failure).
1531 rc = ef10_filter_insert_multicast_list(enp, mulcst, brdcst,
1532 addrs, count, filter_flags, B_TRUE);
1534 if ((table->eft_using_all_mulcst == B_FALSE) &&
1535 (encp->enc_bug26807_workaround == B_TRUE)) {
1537 * Multicast filter chaining is on, so remove
1538 * old filters before inserting the multicast
1539 * all filter to avoid duplicate delivery caused
1540 * by packets matching multiple filters.
1542 ef10_filter_remove_old(enp);
1545 rc = ef10_filter_insert_all_multicast(enp,
1548 rc = ef10_filter_insert_multicast_list(enp,
1550 addrs, count, filter_flags, B_FALSE);
1557 if (encp->enc_tunnel_encapsulations_supported != 0) {
1558 /* Try to insert filters for encapsulated packets. */
1559 (void) ef10_filter_insert_encap_filters(enp,
1560 mulcst || all_mulcst || brdcst,
1564 /* Remove old filters which were not renewed */
1565 ef10_filter_remove_old(enp);
1567 /* report if any optional flags were rejected */
1568 if (((all_unicst != B_FALSE) && (all_unicst_rc != 0)) ||
1569 ((all_mulcst != B_FALSE) && (all_mulcst_rc != 0))) {
1582 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1584 /* Clear auto old flags */
1585 for (i = 0; i < EFX_ARRAY_SIZE(table->eft_entry); i++) {
1586 if (ef10_filter_entry_is_auto_old(table, i)) {
1587 ef10_filter_set_entry_not_auto_old(table, i);
1595 ef10_filter_get_default_rxq(
1596 __in efx_nic_t *enp,
1597 __out efx_rxq_t **erpp,
1598 __out boolean_t *using_rss)
1600 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
1602 *erpp = table->eft_default_rxq;
1603 *using_rss = table->eft_using_rss;
1608 ef10_filter_default_rxq_set(
1609 __in efx_nic_t *enp,
1610 __in efx_rxq_t *erp,
1611 __in boolean_t using_rss)
1613 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
1615 #if EFSYS_OPT_RX_SCALE
1616 EFSYS_ASSERT((using_rss == B_FALSE) ||
1617 (enp->en_rss_context != EF10_RSS_CONTEXT_INVALID));
1618 table->eft_using_rss = using_rss;
1620 EFSYS_ASSERT(using_rss == B_FALSE);
1621 table->eft_using_rss = B_FALSE;
1623 table->eft_default_rxq = erp;
1627 ef10_filter_default_rxq_clear(
1628 __in efx_nic_t *enp)
1630 ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
1632 table->eft_default_rxq = NULL;
1633 table->eft_using_rss = B_FALSE;
1637 #endif /* EFSYS_OPT_FILTER */
1639 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */