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_mac_siena_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_LOOPBACK
54 siena_mac_loopback_set, /* emo_loopback_set */
55 #endif /* EFSYS_OPT_LOOPBACK */
56 #if EFSYS_OPT_MAC_STATS
57 siena_mac_stats_get_mask, /* emo_stats_get_mask */
58 efx_mcdi_mac_stats_clear, /* emo_stats_clear */
59 efx_mcdi_mac_stats_upload, /* emo_stats_upload */
60 efx_mcdi_mac_stats_periodic, /* emo_stats_periodic */
61 siena_mac_stats_update /* emo_stats_update */
62 #endif /* EFSYS_OPT_MAC_STATS */
64 #endif /* EFSYS_OPT_SIENA */
66 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
67 static const efx_mac_ops_t __efx_mac_ef10_ops = {
68 ef10_mac_poll, /* emo_poll */
69 ef10_mac_up, /* emo_up */
70 ef10_mac_addr_set, /* emo_addr_set */
71 ef10_mac_pdu_set, /* emo_pdu_set */
72 ef10_mac_pdu_get, /* emo_pdu_get */
73 ef10_mac_reconfigure, /* emo_reconfigure */
74 ef10_mac_multicast_list_set, /* emo_multicast_list_set */
75 ef10_mac_filter_default_rxq_set, /* emo_filter_default_rxq_set */
76 ef10_mac_filter_default_rxq_clear,
77 /* emo_filter_default_rxq_clear */
78 #if EFSYS_OPT_LOOPBACK
79 ef10_mac_loopback_set, /* emo_loopback_set */
80 #endif /* EFSYS_OPT_LOOPBACK */
81 #if EFSYS_OPT_MAC_STATS
82 ef10_mac_stats_get_mask, /* emo_stats_get_mask */
83 efx_mcdi_mac_stats_clear, /* emo_stats_clear */
84 efx_mcdi_mac_stats_upload, /* emo_stats_upload */
85 efx_mcdi_mac_stats_periodic, /* emo_stats_periodic */
86 ef10_mac_stats_update /* emo_stats_update */
87 #endif /* EFSYS_OPT_MAC_STATS */
89 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
91 __checkReturn efx_rc_t
96 efx_port_t *epp = &(enp->en_port);
97 const efx_mac_ops_t *emop = epp->ep_emop;
101 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
102 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
103 EFSYS_ASSERT(emop != NULL);
105 if (pdu < EFX_MAC_PDU_MIN) {
110 if (pdu > EFX_MAC_PDU_MAX) {
115 old_pdu = epp->ep_mac_pdu;
116 epp->ep_mac_pdu = (uint32_t)pdu;
117 if ((rc = emop->emo_pdu_set(enp)) != 0)
125 epp->ep_mac_pdu = old_pdu;
130 EFSYS_PROBE1(fail1, efx_rc_t, rc);
135 __checkReturn efx_rc_t
140 efx_port_t *epp = &(enp->en_port);
141 const efx_mac_ops_t *emop = epp->ep_emop;
144 if ((rc = emop->emo_pdu_get(enp, pdu)) != 0)
150 EFSYS_PROBE1(fail1, efx_rc_t, rc);
155 __checkReturn efx_rc_t
160 efx_port_t *epp = &(enp->en_port);
161 const efx_mac_ops_t *emop = epp->ep_emop;
166 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
167 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
169 if (EFX_MAC_ADDR_IS_MULTICAST(addr)) {
174 oui = addr[0] << 16 | addr[1] << 8 | addr[2];
175 if (oui == 0x000000) {
180 EFX_MAC_ADDR_COPY(old_addr, epp->ep_mac_addr);
181 EFX_MAC_ADDR_COPY(epp->ep_mac_addr, addr);
182 if ((rc = emop->emo_addr_set(enp)) != 0)
190 EFX_MAC_ADDR_COPY(epp->ep_mac_addr, old_addr);
195 EFSYS_PROBE1(fail1, efx_rc_t, rc);
200 __checkReturn efx_rc_t
203 __in boolean_t all_unicst,
204 __in boolean_t mulcst,
205 __in boolean_t all_mulcst,
206 __in boolean_t brdcst)
208 efx_port_t *epp = &(enp->en_port);
209 const efx_mac_ops_t *emop = epp->ep_emop;
210 boolean_t old_all_unicst;
211 boolean_t old_mulcst;
212 boolean_t old_all_mulcst;
213 boolean_t old_brdcst;
216 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
217 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
219 old_all_unicst = epp->ep_all_unicst;
220 old_mulcst = epp->ep_mulcst;
221 old_all_mulcst = epp->ep_all_mulcst;
222 old_brdcst = epp->ep_brdcst;
224 epp->ep_all_unicst = all_unicst;
225 epp->ep_mulcst = mulcst;
226 epp->ep_all_mulcst = all_mulcst;
227 epp->ep_brdcst = brdcst;
229 if ((rc = emop->emo_reconfigure(enp)) != 0)
235 EFSYS_PROBE1(fail1, efx_rc_t, rc);
237 epp->ep_all_unicst = old_all_unicst;
238 epp->ep_mulcst = old_mulcst;
239 epp->ep_all_mulcst = old_all_mulcst;
240 epp->ep_brdcst = old_brdcst;
245 __checkReturn efx_rc_t
248 __in boolean_t enabled)
250 efx_port_t *epp = &(enp->en_port);
251 const efx_mac_ops_t *emop = epp->ep_emop;
254 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
255 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
256 EFSYS_ASSERT(emop != NULL);
258 if (epp->ep_mac_drain == enabled)
261 epp->ep_mac_drain = enabled;
263 if ((rc = emop->emo_reconfigure(enp)) != 0)
269 EFSYS_PROBE1(fail1, efx_rc_t, rc);
274 __checkReturn efx_rc_t
277 __out boolean_t *mac_upp)
279 efx_port_t *epp = &(enp->en_port);
280 const efx_mac_ops_t *emop = epp->ep_emop;
283 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
284 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
286 if ((rc = emop->emo_up(enp, mac_upp)) != 0)
292 EFSYS_PROBE1(fail1, efx_rc_t, rc);
297 __checkReturn efx_rc_t
300 __in unsigned int fcntl,
301 __in boolean_t autoneg)
303 efx_port_t *epp = &(enp->en_port);
304 const efx_mac_ops_t *emop = epp->ep_emop;
305 const efx_phy_ops_t *epop = epp->ep_epop;
306 unsigned int old_fcntl;
307 boolean_t old_autoneg;
308 unsigned int old_adv_cap;
311 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
312 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
314 if ((fcntl & ~(EFX_FCNTL_RESPOND | EFX_FCNTL_GENERATE)) != 0) {
320 * Ignore a request to set flow control auto-negotiation
321 * if the PHY doesn't support it.
323 if (~epp->ep_phy_cap_mask & (1 << EFX_PHY_CAP_AN))
326 old_fcntl = epp->ep_fcntl;
327 old_autoneg = epp->ep_fcntl_autoneg;
328 old_adv_cap = epp->ep_adv_cap_mask;
330 epp->ep_fcntl = fcntl;
331 epp->ep_fcntl_autoneg = autoneg;
334 * Always encode the flow control settings in the advertised
335 * capabilities even if we are not trying to auto-negotiate
336 * them and reconfigure both the PHY and the MAC.
338 if (fcntl & EFX_FCNTL_RESPOND)
339 epp->ep_adv_cap_mask |= (1 << EFX_PHY_CAP_PAUSE |
340 1 << EFX_PHY_CAP_ASYM);
342 epp->ep_adv_cap_mask &= ~(1 << EFX_PHY_CAP_PAUSE |
343 1 << EFX_PHY_CAP_ASYM);
345 if (fcntl & EFX_FCNTL_GENERATE)
346 epp->ep_adv_cap_mask ^= (1 << EFX_PHY_CAP_ASYM);
348 if ((rc = epop->epo_reconfigure(enp)) != 0)
351 if ((rc = emop->emo_reconfigure(enp)) != 0)
362 epp->ep_fcntl = old_fcntl;
363 epp->ep_fcntl_autoneg = old_autoneg;
364 epp->ep_adv_cap_mask = old_adv_cap;
367 EFSYS_PROBE1(fail1, efx_rc_t, rc);
375 __out unsigned int *fcntl_wantedp,
376 __out unsigned int *fcntl_linkp)
378 efx_port_t *epp = &(enp->en_port);
379 unsigned int wanted = 0;
381 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
382 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
385 * Decode the requested flow control settings from the PHY
386 * advertised capabilities.
388 if (epp->ep_adv_cap_mask & (1 << EFX_PHY_CAP_PAUSE))
389 wanted = EFX_FCNTL_RESPOND | EFX_FCNTL_GENERATE;
390 if (epp->ep_adv_cap_mask & (1 << EFX_PHY_CAP_ASYM))
391 wanted ^= EFX_FCNTL_GENERATE;
393 *fcntl_linkp = epp->ep_fcntl;
394 *fcntl_wantedp = wanted;
397 __checkReturn efx_rc_t
398 efx_mac_multicast_list_set(
400 __in_ecount(6*count) uint8_t const *addrs,
403 efx_port_t *epp = &(enp->en_port);
404 const efx_mac_ops_t *emop = epp->ep_emop;
405 uint8_t *old_mulcst_addr_list = NULL;
406 uint32_t old_mulcst_addr_count;
409 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
410 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
412 if (count > EFX_MAC_MULTICAST_LIST_MAX) {
417 old_mulcst_addr_count = epp->ep_mulcst_addr_count;
418 if (old_mulcst_addr_count > 0) {
419 /* Allocate memory to store old list (instead of using stack) */
420 EFSYS_KMEM_ALLOC(enp->en_esip,
421 old_mulcst_addr_count * EFX_MAC_ADDR_LEN,
422 old_mulcst_addr_list);
423 if (old_mulcst_addr_list == NULL) {
428 /* Save the old list in case we need to rollback */
429 memcpy(old_mulcst_addr_list, epp->ep_mulcst_addr_list,
430 old_mulcst_addr_count * EFX_MAC_ADDR_LEN);
433 /* Store the new list */
434 memcpy(epp->ep_mulcst_addr_list, addrs,
435 count * EFX_MAC_ADDR_LEN);
436 epp->ep_mulcst_addr_count = count;
438 if ((rc = emop->emo_multicast_list_set(enp)) != 0)
441 if (old_mulcst_addr_count > 0) {
442 EFSYS_KMEM_FREE(enp->en_esip,
443 old_mulcst_addr_count * EFX_MAC_ADDR_LEN,
444 old_mulcst_addr_list);
452 /* Restore original list on failure */
453 epp->ep_mulcst_addr_count = old_mulcst_addr_count;
454 if (old_mulcst_addr_count > 0) {
455 memcpy(epp->ep_mulcst_addr_list, old_mulcst_addr_list,
456 old_mulcst_addr_count * EFX_MAC_ADDR_LEN);
458 EFSYS_KMEM_FREE(enp->en_esip,
459 old_mulcst_addr_count * EFX_MAC_ADDR_LEN,
460 old_mulcst_addr_list);
467 EFSYS_PROBE1(fail1, efx_rc_t, rc);
473 __checkReturn efx_rc_t
474 efx_mac_filter_default_rxq_set(
477 __in boolean_t using_rss)
479 efx_port_t *epp = &(enp->en_port);
480 const efx_mac_ops_t *emop = epp->ep_emop;
483 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
484 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
486 if (emop->emo_filter_default_rxq_set != NULL) {
487 rc = emop->emo_filter_default_rxq_set(enp, erp, using_rss);
495 EFSYS_PROBE1(fail1, efx_rc_t, rc);
501 efx_mac_filter_default_rxq_clear(
504 efx_port_t *epp = &(enp->en_port);
505 const efx_mac_ops_t *emop = epp->ep_emop;
507 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
508 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
510 if (emop->emo_filter_default_rxq_clear != NULL)
511 emop->emo_filter_default_rxq_clear(enp);
515 #if EFSYS_OPT_MAC_STATS
519 /* START MKCONFIG GENERATED EfxMacStatNamesBlock c11b91b42f922516 */
520 static const char * const __efx_mac_stat_name[] = {
529 "rx_128_to_255_pkts",
530 "rx_256_to_511_pkts",
531 "rx_512_to_1023_pkts",
532 "rx_1024_to_15xx_pkts",
537 "rx_false_carrier_errors",
540 "rx_internal_errors",
551 "rx_nodesc_drop_cnt",
560 "tx_128_to_255_pkts",
561 "tx_256_to_511_pkts",
562 "tx_512_to_1023_pkts",
563 "tx_1024_to_15xx_pkts",
572 "pm_trunc_bb_overflow",
573 "pm_discard_bb_overflow",
574 "pm_trunc_vfifo_full",
575 "pm_discard_vfifo_full",
578 "pm_discard_mapping",
579 "rxdp_q_disabled_pkts",
580 "rxdp_di_dropped_pkts",
581 "rxdp_streaming_pkts",
584 "vadapter_rx_unicast_packets",
585 "vadapter_rx_unicast_bytes",
586 "vadapter_rx_multicast_packets",
587 "vadapter_rx_multicast_bytes",
588 "vadapter_rx_broadcast_packets",
589 "vadapter_rx_broadcast_bytes",
590 "vadapter_rx_bad_packets",
591 "vadapter_rx_bad_bytes",
592 "vadapter_rx_overflow",
593 "vadapter_tx_unicast_packets",
594 "vadapter_tx_unicast_bytes",
595 "vadapter_tx_multicast_packets",
596 "vadapter_tx_multicast_bytes",
597 "vadapter_tx_broadcast_packets",
598 "vadapter_tx_broadcast_bytes",
599 "vadapter_tx_bad_packets",
600 "vadapter_tx_bad_bytes",
601 "vadapter_tx_overflow",
603 /* END MKCONFIG GENERATED EfxMacStatNamesBlock */
605 __checkReturn const char *
608 __in unsigned int id)
610 _NOTE(ARGUNUSED(enp))
611 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
613 EFSYS_ASSERT3U(id, <, EFX_MAC_NSTATS);
614 return (__efx_mac_stat_name[id]);
617 #endif /* EFSYS_OPT_NAMES */
620 efx_mac_stats_mask_add_range(
621 __inout_bcount(mask_size) uint32_t *maskp,
622 __in size_t mask_size,
623 __in const struct efx_mac_stats_range *rngp)
625 unsigned int mask_npages = mask_size / sizeof (*maskp);
634 if ((mask_npages * EFX_MAC_STATS_MASK_BITS_PER_PAGE) <=
635 (unsigned int)rngp->last) {
640 EFSYS_ASSERT3U(rngp->first, <=, rngp->last);
641 EFSYS_ASSERT3U(rngp->last, <, EFX_MAC_NSTATS);
643 for (el = 0; el < mask_npages; ++el) {
644 el_min = el * EFX_MAC_STATS_MASK_BITS_PER_PAGE;
646 el_min + (EFX_MAC_STATS_MASK_BITS_PER_PAGE - 1);
647 if ((unsigned int)rngp->first > el_max ||
648 (unsigned int)rngp->last < el_min)
650 low = MAX((unsigned int)rngp->first, el_min);
651 high = MIN((unsigned int)rngp->last, el_max);
652 width = high - low + 1;
654 (width == EFX_MAC_STATS_MASK_BITS_PER_PAGE) ?
655 (~0ULL) : (((1ULL << width) - 1) << (low - el_min));
661 EFSYS_PROBE1(fail1, efx_rc_t, rc);
667 efx_mac_stats_mask_add_ranges(
668 __inout_bcount(mask_size) uint32_t *maskp,
669 __in size_t mask_size,
670 __in_ecount(rng_count) const struct efx_mac_stats_range *rngp,
671 __in unsigned int rng_count)
676 for (i = 0; i < rng_count; ++i) {
677 if ((rc = efx_mac_stats_mask_add_range(maskp, mask_size,
685 EFSYS_PROBE1(fail1, efx_rc_t, rc);
690 __checkReturn efx_rc_t
691 efx_mac_stats_get_mask(
693 __out_bcount(mask_size) uint32_t *maskp,
694 __in size_t mask_size)
696 efx_port_t *epp = &(enp->en_port);
697 const efx_mac_ops_t *emop = epp->ep_emop;
700 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
701 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
702 EFSYS_ASSERT(maskp != NULL);
703 EFSYS_ASSERT(mask_size % sizeof (maskp[0]) == 0);
705 (void) memset(maskp, 0, mask_size);
707 if ((rc = emop->emo_stats_get_mask(enp, maskp, mask_size)) != 0)
713 EFSYS_PROBE1(fail1, efx_rc_t, rc);
718 __checkReturn efx_rc_t
722 efx_port_t *epp = &(enp->en_port);
723 const efx_mac_ops_t *emop = epp->ep_emop;
726 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
727 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
728 EFSYS_ASSERT(emop != NULL);
730 if ((rc = emop->emo_stats_clear(enp)) != 0)
736 EFSYS_PROBE1(fail1, efx_rc_t, rc);
741 __checkReturn efx_rc_t
742 efx_mac_stats_upload(
744 __in efsys_mem_t *esmp)
746 efx_port_t *epp = &(enp->en_port);
747 const efx_mac_ops_t *emop = epp->ep_emop;
750 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
751 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
752 EFSYS_ASSERT(emop != NULL);
754 if ((rc = emop->emo_stats_upload(enp, esmp)) != 0)
760 EFSYS_PROBE1(fail1, efx_rc_t, rc);
765 __checkReturn efx_rc_t
766 efx_mac_stats_periodic(
768 __in efsys_mem_t *esmp,
769 __in uint16_t period_ms,
770 __in boolean_t events)
772 efx_port_t *epp = &(enp->en_port);
773 const efx_mac_ops_t *emop = epp->ep_emop;
776 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
777 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
779 EFSYS_ASSERT(emop != NULL);
781 if (emop->emo_stats_periodic == NULL) {
786 if ((rc = emop->emo_stats_periodic(enp, esmp, period_ms, events)) != 0)
794 EFSYS_PROBE1(fail1, efx_rc_t, rc);
800 __checkReturn efx_rc_t
801 efx_mac_stats_update(
803 __in efsys_mem_t *esmp,
804 __inout_ecount(EFX_MAC_NSTATS) efsys_stat_t *essp,
805 __inout_opt uint32_t *generationp)
807 efx_port_t *epp = &(enp->en_port);
808 const efx_mac_ops_t *emop = epp->ep_emop;
811 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
812 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
813 EFSYS_ASSERT(emop != NULL);
815 rc = emop->emo_stats_update(enp, esmp, essp, generationp);
820 #endif /* EFSYS_OPT_MAC_STATS */
822 __checkReturn efx_rc_t
826 efx_port_t *epp = &(enp->en_port);
827 efx_mac_type_t type = EFX_MAC_INVALID;
828 const efx_mac_ops_t *emop;
831 switch (enp->en_family) {
833 case EFX_FAMILY_SIENA:
834 emop = &__efx_mac_siena_ops;
835 type = EFX_MAC_SIENA;
837 #endif /* EFSYS_OPT_SIENA */
839 #if EFSYS_OPT_HUNTINGTON
840 case EFX_FAMILY_HUNTINGTON:
841 emop = &__efx_mac_ef10_ops;
842 type = EFX_MAC_HUNTINGTON;
844 #endif /* EFSYS_OPT_HUNTINGTON */
846 #if EFSYS_OPT_MEDFORD
847 case EFX_FAMILY_MEDFORD:
848 emop = &__efx_mac_ef10_ops;
849 type = EFX_MAC_MEDFORD;
851 #endif /* EFSYS_OPT_MEDFORD */
858 EFSYS_ASSERT(type != EFX_MAC_INVALID);
859 EFSYS_ASSERT3U(type, <, EFX_MAC_NTYPES);
860 EFSYS_ASSERT(emop != NULL);
863 epp->ep_mac_type = type;
868 EFSYS_PROBE1(fail1, efx_rc_t, rc);
876 #define EFX_MAC_HASH_BITS (1 << 8)
878 /* Compute the multicast hash as used on Falcon and Siena. */
880 siena_mac_multicast_hash_compute(
881 __in_ecount(6*count) uint8_t const *addrs,
883 __out efx_oword_t *hash_low,
884 __out efx_oword_t *hash_high)
889 EFSYS_ASSERT(hash_low != NULL);
890 EFSYS_ASSERT(hash_high != NULL);
892 EFX_ZERO_OWORD(*hash_low);
893 EFX_ZERO_OWORD(*hash_high);
895 for (i = 0; i < count; i++) {
896 /* Calculate hash bucket (IEEE 802.3 CRC32 of the MAC addr) */
897 crc = efx_crc32_calculate(0xffffffff, addrs, EFX_MAC_ADDR_LEN);
898 index = crc % EFX_MAC_HASH_BITS;
900 EFX_SET_OWORD_BIT(*hash_low, index);
902 EFX_SET_OWORD_BIT(*hash_high, index - 128);
905 addrs += EFX_MAC_ADDR_LEN;
909 static __checkReturn efx_rc_t
910 siena_mac_multicast_list_set(
913 efx_port_t *epp = &(enp->en_port);
914 const efx_mac_ops_t *emop = epp->ep_emop;
915 efx_oword_t old_hash[2];
918 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
919 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
921 memcpy(old_hash, epp->ep_multicst_hash, sizeof (old_hash));
923 siena_mac_multicast_hash_compute(
924 epp->ep_mulcst_addr_list,
925 epp->ep_mulcst_addr_count,
926 &epp->ep_multicst_hash[0],
927 &epp->ep_multicst_hash[1]);
929 if ((rc = emop->emo_reconfigure(enp)) != 0)
935 EFSYS_PROBE1(fail1, efx_rc_t, rc);
937 memcpy(epp->ep_multicst_hash, old_hash, sizeof (old_hash));
942 #endif /* EFSYS_OPT_SIENA */