2 * Copyright (c) 2007-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.
36 static __checkReturn efx_rc_t
37 siena_mac_multicast_list_set(
40 #endif /* EFSYS_OPT_SIENA */
43 static const efx_mac_ops_t __efx_siena_mac_ops = {
44 siena_mac_poll, /* emo_poll */
45 siena_mac_up, /* emo_up */
46 siena_mac_reconfigure, /* emo_addr_set */
47 siena_mac_reconfigure, /* emo_pdu_set */
48 siena_mac_pdu_get, /* emo_pdu_get */
49 siena_mac_reconfigure, /* emo_reconfigure */
50 siena_mac_multicast_list_set, /* emo_multicast_list_set */
51 NULL, /* emo_filter_set_default_rxq */
52 NULL, /* emo_filter_default_rxq_clear */
53 #if EFSYS_OPT_MAC_STATS
54 siena_mac_stats_get_mask, /* emo_stats_get_mask */
55 efx_mcdi_mac_stats_upload, /* emo_stats_upload */
56 efx_mcdi_mac_stats_periodic, /* emo_stats_periodic */
57 siena_mac_stats_update /* emo_stats_update */
58 #endif /* EFSYS_OPT_MAC_STATS */
60 #endif /* EFSYS_OPT_SIENA */
62 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
63 static const efx_mac_ops_t __efx_ef10_mac_ops = {
64 ef10_mac_poll, /* emo_poll */
65 ef10_mac_up, /* emo_up */
66 ef10_mac_addr_set, /* emo_addr_set */
67 ef10_mac_pdu_set, /* emo_pdu_set */
68 ef10_mac_pdu_get, /* emo_pdu_get */
69 ef10_mac_reconfigure, /* emo_reconfigure */
70 ef10_mac_multicast_list_set, /* emo_multicast_list_set */
71 ef10_mac_filter_default_rxq_set, /* emo_filter_default_rxq_set */
72 ef10_mac_filter_default_rxq_clear,
73 /* emo_filter_default_rxq_clear */
74 #if EFSYS_OPT_MAC_STATS
75 ef10_mac_stats_get_mask, /* emo_stats_get_mask */
76 efx_mcdi_mac_stats_upload, /* emo_stats_upload */
77 efx_mcdi_mac_stats_periodic, /* emo_stats_periodic */
78 ef10_mac_stats_update /* emo_stats_update */
79 #endif /* EFSYS_OPT_MAC_STATS */
81 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
83 __checkReturn efx_rc_t
88 efx_port_t *epp = &(enp->en_port);
89 const efx_mac_ops_t *emop = epp->ep_emop;
93 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
94 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
95 EFSYS_ASSERT(emop != NULL);
97 if (pdu < EFX_MAC_PDU_MIN) {
102 if (pdu > EFX_MAC_PDU_MAX) {
107 old_pdu = epp->ep_mac_pdu;
108 epp->ep_mac_pdu = (uint32_t)pdu;
109 if ((rc = emop->emo_pdu_set(enp)) != 0)
117 epp->ep_mac_pdu = old_pdu;
122 EFSYS_PROBE1(fail1, efx_rc_t, rc);
127 __checkReturn efx_rc_t
132 efx_port_t *epp = &(enp->en_port);
133 const efx_mac_ops_t *emop = epp->ep_emop;
136 if ((rc = emop->emo_pdu_get(enp, pdu)) != 0)
142 EFSYS_PROBE1(fail1, efx_rc_t, rc);
147 __checkReturn efx_rc_t
152 efx_port_t *epp = &(enp->en_port);
153 const efx_mac_ops_t *emop = epp->ep_emop;
158 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
159 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
161 if (EFX_MAC_ADDR_IS_MULTICAST(addr)) {
166 oui = addr[0] << 16 | addr[1] << 8 | addr[2];
167 if (oui == 0x000000) {
172 EFX_MAC_ADDR_COPY(old_addr, epp->ep_mac_addr);
173 EFX_MAC_ADDR_COPY(epp->ep_mac_addr, addr);
174 if ((rc = emop->emo_addr_set(enp)) != 0)
182 EFX_MAC_ADDR_COPY(epp->ep_mac_addr, old_addr);
187 EFSYS_PROBE1(fail1, efx_rc_t, rc);
192 __checkReturn efx_rc_t
195 __in boolean_t all_unicst,
196 __in boolean_t mulcst,
197 __in boolean_t all_mulcst,
198 __in boolean_t brdcst)
200 efx_port_t *epp = &(enp->en_port);
201 const efx_mac_ops_t *emop = epp->ep_emop;
202 boolean_t old_all_unicst;
203 boolean_t old_mulcst;
204 boolean_t old_all_mulcst;
205 boolean_t old_brdcst;
208 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
209 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
211 old_all_unicst = epp->ep_all_unicst;
212 old_mulcst = epp->ep_mulcst;
213 old_all_mulcst = epp->ep_all_mulcst;
214 old_brdcst = epp->ep_brdcst;
216 epp->ep_all_unicst = all_unicst;
217 epp->ep_mulcst = mulcst;
218 epp->ep_all_mulcst = all_mulcst;
219 epp->ep_brdcst = brdcst;
221 if ((rc = emop->emo_reconfigure(enp)) != 0)
227 EFSYS_PROBE1(fail1, efx_rc_t, rc);
229 epp->ep_all_unicst = old_all_unicst;
230 epp->ep_mulcst = old_mulcst;
231 epp->ep_all_mulcst = old_all_mulcst;
232 epp->ep_brdcst = old_brdcst;
237 __checkReturn efx_rc_t
240 __in boolean_t enabled)
242 efx_port_t *epp = &(enp->en_port);
243 const efx_mac_ops_t *emop = epp->ep_emop;
246 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
247 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
248 EFSYS_ASSERT(emop != NULL);
250 if (epp->ep_mac_drain == enabled)
253 epp->ep_mac_drain = enabled;
255 if ((rc = emop->emo_reconfigure(enp)) != 0)
261 EFSYS_PROBE1(fail1, efx_rc_t, rc);
266 __checkReturn efx_rc_t
269 __out boolean_t *mac_upp)
271 efx_port_t *epp = &(enp->en_port);
272 const efx_mac_ops_t *emop = epp->ep_emop;
275 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
276 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
278 if ((rc = emop->emo_up(enp, mac_upp)) != 0)
284 EFSYS_PROBE1(fail1, efx_rc_t, rc);
289 __checkReturn efx_rc_t
292 __in unsigned int fcntl,
293 __in boolean_t autoneg)
295 efx_port_t *epp = &(enp->en_port);
296 const efx_mac_ops_t *emop = epp->ep_emop;
297 const efx_phy_ops_t *epop = epp->ep_epop;
298 unsigned int old_fcntl;
299 boolean_t old_autoneg;
300 unsigned int old_adv_cap;
303 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
304 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
306 if ((fcntl & ~(EFX_FCNTL_RESPOND | EFX_FCNTL_GENERATE)) != 0) {
312 * Ignore a request to set flow control auto-negotiation
313 * if the PHY doesn't support it.
315 if (~epp->ep_phy_cap_mask & (1 << EFX_PHY_CAP_AN))
318 old_fcntl = epp->ep_fcntl;
319 old_autoneg = epp->ep_fcntl_autoneg;
320 old_adv_cap = epp->ep_adv_cap_mask;
322 epp->ep_fcntl = fcntl;
323 epp->ep_fcntl_autoneg = autoneg;
326 * Always encode the flow control settings in the advertised
327 * capabilities even if we are not trying to auto-negotiate
328 * them and reconfigure both the PHY and the MAC.
330 if (fcntl & EFX_FCNTL_RESPOND)
331 epp->ep_adv_cap_mask |= (1 << EFX_PHY_CAP_PAUSE |
332 1 << EFX_PHY_CAP_ASYM);
334 epp->ep_adv_cap_mask &= ~(1 << EFX_PHY_CAP_PAUSE |
335 1 << EFX_PHY_CAP_ASYM);
337 if (fcntl & EFX_FCNTL_GENERATE)
338 epp->ep_adv_cap_mask ^= (1 << EFX_PHY_CAP_ASYM);
340 if ((rc = epop->epo_reconfigure(enp)) != 0)
343 if ((rc = emop->emo_reconfigure(enp)) != 0)
354 epp->ep_fcntl = old_fcntl;
355 epp->ep_fcntl_autoneg = old_autoneg;
356 epp->ep_adv_cap_mask = old_adv_cap;
359 EFSYS_PROBE1(fail1, efx_rc_t, rc);
367 __out unsigned int *fcntl_wantedp,
368 __out unsigned int *fcntl_linkp)
370 efx_port_t *epp = &(enp->en_port);
371 unsigned int wanted = 0;
373 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
374 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
377 * Decode the requested flow control settings from the PHY
378 * advertised capabilities.
380 if (epp->ep_adv_cap_mask & (1 << EFX_PHY_CAP_PAUSE))
381 wanted = EFX_FCNTL_RESPOND | EFX_FCNTL_GENERATE;
382 if (epp->ep_adv_cap_mask & (1 << EFX_PHY_CAP_ASYM))
383 wanted ^= EFX_FCNTL_GENERATE;
385 *fcntl_linkp = epp->ep_fcntl;
386 *fcntl_wantedp = wanted;
389 __checkReturn efx_rc_t
390 efx_mac_multicast_list_set(
392 __in_ecount(6*count) uint8_t const *addrs,
395 efx_port_t *epp = &(enp->en_port);
396 const efx_mac_ops_t *emop = epp->ep_emop;
397 uint8_t *old_mulcst_addr_list = NULL;
398 uint32_t old_mulcst_addr_count;
401 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
402 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
404 if (count > EFX_MAC_MULTICAST_LIST_MAX) {
409 old_mulcst_addr_count = epp->ep_mulcst_addr_count;
410 if (old_mulcst_addr_count > 0) {
411 /* Allocate memory to store old list (instead of using stack) */
412 EFSYS_KMEM_ALLOC(enp->en_esip,
413 old_mulcst_addr_count * EFX_MAC_ADDR_LEN,
414 old_mulcst_addr_list);
415 if (old_mulcst_addr_list == NULL) {
420 /* Save the old list in case we need to rollback */
421 memcpy(old_mulcst_addr_list, epp->ep_mulcst_addr_list,
422 old_mulcst_addr_count * EFX_MAC_ADDR_LEN);
425 /* Store the new list */
426 memcpy(epp->ep_mulcst_addr_list, addrs,
427 count * EFX_MAC_ADDR_LEN);
428 epp->ep_mulcst_addr_count = count;
430 if ((rc = emop->emo_multicast_list_set(enp)) != 0)
433 if (old_mulcst_addr_count > 0) {
434 EFSYS_KMEM_FREE(enp->en_esip,
435 old_mulcst_addr_count * EFX_MAC_ADDR_LEN,
436 old_mulcst_addr_list);
444 /* Restore original list on failure */
445 epp->ep_mulcst_addr_count = old_mulcst_addr_count;
446 if (old_mulcst_addr_count > 0) {
447 memcpy(epp->ep_mulcst_addr_list, old_mulcst_addr_list,
448 old_mulcst_addr_count * EFX_MAC_ADDR_LEN);
450 EFSYS_KMEM_FREE(enp->en_esip,
451 old_mulcst_addr_count * EFX_MAC_ADDR_LEN,
452 old_mulcst_addr_list);
459 EFSYS_PROBE1(fail1, efx_rc_t, rc);
465 __checkReturn efx_rc_t
466 efx_mac_filter_default_rxq_set(
469 __in boolean_t using_rss)
471 efx_port_t *epp = &(enp->en_port);
472 const efx_mac_ops_t *emop = epp->ep_emop;
475 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
476 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
478 if (emop->emo_filter_default_rxq_set != NULL) {
479 rc = emop->emo_filter_default_rxq_set(enp, erp, using_rss);
487 EFSYS_PROBE1(fail1, efx_rc_t, rc);
493 efx_mac_filter_default_rxq_clear(
496 efx_port_t *epp = &(enp->en_port);
497 const efx_mac_ops_t *emop = epp->ep_emop;
499 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
500 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
502 if (emop->emo_filter_default_rxq_clear != NULL)
503 emop->emo_filter_default_rxq_clear(enp);
507 #if EFSYS_OPT_MAC_STATS
511 /* START MKCONFIG GENERATED EfxMacStatNamesBlock c11b91b42f922516 */
512 static const char * const __efx_mac_stat_name[] = {
521 "rx_128_to_255_pkts",
522 "rx_256_to_511_pkts",
523 "rx_512_to_1023_pkts",
524 "rx_1024_to_15xx_pkts",
529 "rx_false_carrier_errors",
532 "rx_internal_errors",
543 "rx_nodesc_drop_cnt",
552 "tx_128_to_255_pkts",
553 "tx_256_to_511_pkts",
554 "tx_512_to_1023_pkts",
555 "tx_1024_to_15xx_pkts",
564 "pm_trunc_bb_overflow",
565 "pm_discard_bb_overflow",
566 "pm_trunc_vfifo_full",
567 "pm_discard_vfifo_full",
570 "pm_discard_mapping",
571 "rxdp_q_disabled_pkts",
572 "rxdp_di_dropped_pkts",
573 "rxdp_streaming_pkts",
576 "vadapter_rx_unicast_packets",
577 "vadapter_rx_unicast_bytes",
578 "vadapter_rx_multicast_packets",
579 "vadapter_rx_multicast_bytes",
580 "vadapter_rx_broadcast_packets",
581 "vadapter_rx_broadcast_bytes",
582 "vadapter_rx_bad_packets",
583 "vadapter_rx_bad_bytes",
584 "vadapter_rx_overflow",
585 "vadapter_tx_unicast_packets",
586 "vadapter_tx_unicast_bytes",
587 "vadapter_tx_multicast_packets",
588 "vadapter_tx_multicast_bytes",
589 "vadapter_tx_broadcast_packets",
590 "vadapter_tx_broadcast_bytes",
591 "vadapter_tx_bad_packets",
592 "vadapter_tx_bad_bytes",
593 "vadapter_tx_overflow",
595 /* END MKCONFIG GENERATED EfxMacStatNamesBlock */
597 __checkReturn const char *
600 __in unsigned int id)
602 _NOTE(ARGUNUSED(enp))
603 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
605 EFSYS_ASSERT3U(id, <, EFX_MAC_NSTATS);
606 return (__efx_mac_stat_name[id]);
609 #endif /* EFSYS_OPT_NAMES */
612 efx_mac_stats_mask_add_range(
613 __inout_bcount(mask_size) uint32_t *maskp,
614 __in size_t mask_size,
615 __in const struct efx_mac_stats_range *rngp)
617 unsigned int mask_npages = mask_size / sizeof (*maskp);
626 if ((mask_npages * EFX_MAC_STATS_MASK_BITS_PER_PAGE) <=
627 (unsigned int)rngp->last) {
632 EFSYS_ASSERT3U(rngp->first, <=, rngp->last);
633 EFSYS_ASSERT3U(rngp->last, <, EFX_MAC_NSTATS);
635 for (el = 0; el < mask_npages; ++el) {
636 el_min = el * EFX_MAC_STATS_MASK_BITS_PER_PAGE;
638 el_min + (EFX_MAC_STATS_MASK_BITS_PER_PAGE - 1);
639 if ((unsigned int)rngp->first > el_max ||
640 (unsigned int)rngp->last < el_min)
642 low = MAX((unsigned int)rngp->first, el_min);
643 high = MIN((unsigned int)rngp->last, el_max);
644 width = high - low + 1;
646 (width == EFX_MAC_STATS_MASK_BITS_PER_PAGE) ?
647 (~0ULL) : (((1ULL << width) - 1) << (low - el_min));
653 EFSYS_PROBE1(fail1, efx_rc_t, rc);
659 efx_mac_stats_mask_add_ranges(
660 __inout_bcount(mask_size) uint32_t *maskp,
661 __in size_t mask_size,
662 __in_ecount(rng_count) const struct efx_mac_stats_range *rngp,
663 __in unsigned int rng_count)
668 for (i = 0; i < rng_count; ++i) {
669 if ((rc = efx_mac_stats_mask_add_range(maskp, mask_size,
677 EFSYS_PROBE1(fail1, efx_rc_t, rc);
682 __checkReturn efx_rc_t
683 efx_mac_stats_get_mask(
685 __out_bcount(mask_size) uint32_t *maskp,
686 __in size_t mask_size)
688 efx_port_t *epp = &(enp->en_port);
689 const efx_mac_ops_t *emop = epp->ep_emop;
692 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
693 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
694 EFSYS_ASSERT(maskp != NULL);
695 EFSYS_ASSERT(mask_size % sizeof (maskp[0]) == 0);
697 (void) memset(maskp, 0, mask_size);
699 if ((rc = emop->emo_stats_get_mask(enp, maskp, mask_size)) != 0)
705 EFSYS_PROBE1(fail1, efx_rc_t, rc);
710 __checkReturn efx_rc_t
711 efx_mac_stats_upload(
713 __in efsys_mem_t *esmp)
715 efx_port_t *epp = &(enp->en_port);
716 const efx_mac_ops_t *emop = epp->ep_emop;
719 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
720 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
721 EFSYS_ASSERT(emop != NULL);
724 * Don't assert !ep_mac_stats_pending, because the client might
725 * have failed to finalise statistics when previously stopping
728 if ((rc = emop->emo_stats_upload(enp, esmp)) != 0)
731 epp->ep_mac_stats_pending = B_TRUE;
736 EFSYS_PROBE1(fail1, efx_rc_t, rc);
741 __checkReturn efx_rc_t
742 efx_mac_stats_periodic(
744 __in efsys_mem_t *esmp,
745 __in uint16_t period_ms,
746 __in boolean_t events)
748 efx_port_t *epp = &(enp->en_port);
749 const efx_mac_ops_t *emop = epp->ep_emop;
752 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
753 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
755 EFSYS_ASSERT(emop != NULL);
757 if (emop->emo_stats_periodic == NULL) {
762 if ((rc = emop->emo_stats_periodic(enp, esmp, period_ms, events)) != 0)
770 EFSYS_PROBE1(fail1, efx_rc_t, rc);
776 __checkReturn efx_rc_t
777 efx_mac_stats_update(
779 __in efsys_mem_t *esmp,
780 __inout_ecount(EFX_MAC_NSTATS) efsys_stat_t *essp,
781 __inout_opt uint32_t *generationp)
783 efx_port_t *epp = &(enp->en_port);
784 const efx_mac_ops_t *emop = epp->ep_emop;
787 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
788 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
789 EFSYS_ASSERT(emop != NULL);
791 rc = emop->emo_stats_update(enp, esmp, essp, generationp);
793 epp->ep_mac_stats_pending = B_FALSE;
798 #endif /* EFSYS_OPT_MAC_STATS */
800 __checkReturn efx_rc_t
804 efx_port_t *epp = &(enp->en_port);
805 efx_mac_type_t type = EFX_MAC_INVALID;
806 const efx_mac_ops_t *emop;
809 switch (enp->en_family) {
811 case EFX_FAMILY_SIENA:
812 emop = &__efx_siena_mac_ops;
813 type = EFX_MAC_SIENA;
815 #endif /* EFSYS_OPT_SIENA */
817 #if EFSYS_OPT_HUNTINGTON
818 case EFX_FAMILY_HUNTINGTON:
819 emop = &__efx_ef10_mac_ops;
820 type = EFX_MAC_HUNTINGTON;
822 #endif /* EFSYS_OPT_HUNTINGTON */
824 #if EFSYS_OPT_MEDFORD
825 case EFX_FAMILY_MEDFORD:
826 emop = &__efx_ef10_mac_ops;
827 type = EFX_MAC_MEDFORD;
829 #endif /* EFSYS_OPT_MEDFORD */
836 EFSYS_ASSERT(type != EFX_MAC_INVALID);
837 EFSYS_ASSERT3U(type, <, EFX_MAC_NTYPES);
838 EFSYS_ASSERT(emop != NULL);
841 epp->ep_mac_type = type;
846 EFSYS_PROBE1(fail1, efx_rc_t, rc);
854 #define EFX_MAC_HASH_BITS (1 << 8)
856 /* Compute the multicast hash as used on Falcon and Siena. */
858 siena_mac_multicast_hash_compute(
859 __in_ecount(6*count) uint8_t const *addrs,
861 __out efx_oword_t *hash_low,
862 __out efx_oword_t *hash_high)
867 EFSYS_ASSERT(hash_low != NULL);
868 EFSYS_ASSERT(hash_high != NULL);
870 EFX_ZERO_OWORD(*hash_low);
871 EFX_ZERO_OWORD(*hash_high);
873 for (i = 0; i < count; i++) {
874 /* Calculate hash bucket (IEEE 802.3 CRC32 of the MAC addr) */
875 crc = efx_crc32_calculate(0xffffffff, addrs, EFX_MAC_ADDR_LEN);
876 index = crc % EFX_MAC_HASH_BITS;
878 EFX_SET_OWORD_BIT(*hash_low, index);
880 EFX_SET_OWORD_BIT(*hash_high, index - 128);
883 addrs += EFX_MAC_ADDR_LEN;
887 static __checkReturn efx_rc_t
888 siena_mac_multicast_list_set(
891 efx_port_t *epp = &(enp->en_port);
892 const efx_mac_ops_t *emop = epp->ep_emop;
893 efx_oword_t old_hash[2];
896 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
897 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
899 memcpy(old_hash, epp->ep_multicst_hash, sizeof (old_hash));
901 siena_mac_multicast_hash_compute(
902 epp->ep_mulcst_addr_list,
903 epp->ep_mulcst_addr_count,
904 &epp->ep_multicst_hash[0],
905 &epp->ep_multicst_hash[1]);
907 if ((rc = emop->emo_reconfigure(enp)) != 0)
913 EFSYS_PROBE1(fail1, efx_rc_t, rc);
915 memcpy(epp->ep_multicst_hash, old_hash, sizeof (old_hash));
920 #endif /* EFSYS_OPT_SIENA */