From b0fd63cf1e9950512ef894c495ec69813d84f807 Mon Sep 17 00:00:00 2001 From: naddy Date: Tue, 5 Sep 2023 13:06:42 +0000 Subject: [PATCH] stop putting multicast addresses into the Receive Address Registers Hash them all into the Multicast Table Array. This matches what FreeBSD does. This fixes a problem where the I217-LM would fail to receive packets for some of the programmed addresses. Approach agreed by jmatthew@ dlg@ OK claudio@ --- sys/dev/pci/if_em.c | 4 ++-- sys/dev/pci/if_em_hw.c | 45 ++++-------------------------------------- sys/dev/pci/if_em_hw.h | 4 ++-- 3 files changed, 8 insertions(+), 45 deletions(-) diff --git a/sys/dev/pci/if_em.c b/sys/dev/pci/if_em.c index 5ed3332b6fa..e29b12e0bce 100644 --- a/sys/dev/pci/if_em.c +++ b/sys/dev/pci/if_em.c @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ -/* $OpenBSD: if_em.c,v 1.365 2023/02/09 21:21:27 naddy Exp $ */ +/* $OpenBSD: if_em.c,v 1.366 2023/09/05 13:06:42 naddy Exp $ */ /* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */ #include @@ -1474,7 +1474,7 @@ em_iff(struct em_softc *sc) ETHER_NEXT_MULTI(step, enm); } - em_mc_addr_list_update(&sc->hw, mta, ac->ac_multicnt, 0, 1); + em_mc_addr_list_update(&sc->hw, mta, ac->ac_multicnt, 0); } E1000_WRITE_REG(&sc->hw, RCTL, reg_rctl); diff --git a/sys/dev/pci/if_em_hw.c b/sys/dev/pci/if_em_hw.c index 7db048d482a..5cd58ebf1eb 100644 --- a/sys/dev/pci/if_em_hw.c +++ b/sys/dev/pci/if_em_hw.c @@ -31,7 +31,7 @@ *******************************************************************************/ -/* $OpenBSD: if_em_hw.c,v 1.117 2023/04/11 00:45:08 jsg Exp $ */ +/* $OpenBSD: if_em_hw.c,v 1.118 2023/09/05 13:06:42 naddy Exp $ */ /* * if_em_hw.c Shared functions for accessing and configuring the MAC */ @@ -7884,20 +7884,16 @@ em_init_rx_addrs(struct em_hw *hw) * mc_addr_list - the list of new multicast addresses * mc_addr_count - number of addresses * pad - number of bytes between addresses in the list - * rar_used_count - offset where to start adding mc addresses into the RAR's * - * The given list replaces any existing list. Clears the last 15 receive - * address registers and the multicast table. Uses receive address registers - * for the first 15 multicast addresses, and hashes the rest into the + * The given list replaces any existing list and hashes the addresses into the * multicast table. *****************************************************************************/ void em_mc_addr_list_update(struct em_hw *hw, uint8_t *mc_addr_list, - uint32_t mc_addr_count, uint32_t pad, uint32_t rar_used_count) + uint32_t mc_addr_count, uint32_t pad) { uint32_t hash_value; uint32_t i; - uint32_t num_rar_entry; uint32_t num_mta_entry; DEBUGFUNC("em_mc_addr_list_update"); /* @@ -7906,28 +7902,6 @@ em_mc_addr_list_update(struct em_hw *hw, uint8_t *mc_addr_list, */ hw->num_mc_addrs = mc_addr_count; - /* Clear RAR[1-15] */ - DEBUGOUT(" Clearing RAR[1-15]\n"); - num_rar_entry = E1000_RAR_ENTRIES; - if (IS_ICH8(hw->mac_type)) - num_rar_entry = E1000_RAR_ENTRIES_ICH8LAN; - if (hw->mac_type == em_ich8lan) - num_rar_entry -= 1; - /* - * Reserve a spot for the Locally Administered Address to work around - * an 82571 issue in which a reset on one port will reload the MAC on - * the other port. - */ - if ((hw->mac_type == em_82571) && (hw->laa_is_present == TRUE)) - num_rar_entry -= 1; - - for (i = rar_used_count; i < num_rar_entry; i++) { - E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0); - E1000_WRITE_FLUSH(hw); - E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0); - E1000_WRITE_FLUSH(hw); - } - /* Clear the MTA */ DEBUGOUT(" Clearing MTA\n"); num_mta_entry = E1000_NUM_MTA_REGISTERS; @@ -7954,18 +7928,7 @@ em_mc_addr_list_update(struct em_hw *hw, uint8_t *mc_addr_list, (i * (ETH_LENGTH_OF_ADDRESS + pad))); DEBUGOUT1(" Hash value = 0x%03X\n", hash_value); - /* - * Place this multicast address in the RAR if there is room, * - * else put it in the MTA - */ - if (rar_used_count < num_rar_entry) { - em_rar_set(hw, mc_addr_list + - (i * (ETH_LENGTH_OF_ADDRESS + pad)), - rar_used_count); - rar_used_count++; - } else { - em_mta_set(hw, hash_value); - } + em_mta_set(hw, hash_value); } DEBUGOUT("MC Update Complete\n"); } diff --git a/sys/dev/pci/if_em_hw.h b/sys/dev/pci/if_em_hw.h index 78340f3fed3..0b9f548d6b5 100644 --- a/sys/dev/pci/if_em_hw.h +++ b/sys/dev/pci/if_em_hw.h @@ -31,7 +31,7 @@ *******************************************************************************/ -/* $OpenBSD: if_em_hw.h,v 1.88 2022/11/06 18:17:56 mbuhl Exp $ */ +/* $OpenBSD: if_em_hw.h,v 1.89 2023/09/05 13:06:43 naddy Exp $ */ /* $FreeBSD: if_em_hw.h,v 1.15 2005/05/26 23:32:02 tackerman Exp $ */ /* if_em_hw.h @@ -428,7 +428,7 @@ boolean_t em_get_flash_presence_i210(struct em_hw *); /* Filters (multicast, vlan, receive) */ void em_mc_addr_list_update(struct em_hw *hw, uint8_t * mc_addr_list, uint32_t mc_addr_count, - uint32_t pad, uint32_t rar_used_count); + uint32_t pad); uint32_t em_hash_mc_addr(struct em_hw *hw, uint8_t *mc_addr); void em_mta_set(struct em_hw *hw, uint32_t hash_value); void em_rar_set(struct em_hw *hw, uint8_t *mc_addr, uint32_t rar_index); -- 2.20.1