From nobody Wed Oct 19 23:23:41 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Mt6HK4DD0z4g2b3; Wed, 19 Oct 2022 23:23:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Mt6HK3XwPz3VLQ; Wed, 19 Oct 2022 23:23:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666221821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=STcsDqMLEyl/TzfdXPNyd3o4TSSsIFRiiMmgDdTofLM=; b=x7PWbi0uW7NT29zmc1oQ9NamT1LnmjEfWQpbPddwZg3aKP4Qz2pjHw4m7zZrCwiqIw7/52 bPQzm6WaL4lRvn9HUPZKzsA8asZU7+kZVfS2cPTdjRw2DdI7M/srxTo2mFTUoT1qBIH0xh 4JqJjeZfQ17/hPDr2QKOcEQVDNmUvZo1WLsjW6g49R3B/EdFBJJzIgf7Ois545WumLXiur XBX+rulfn6M8fwhM5gq4pYCzM72gNu/zA1knZ56gxaghCWoyf09LUxs6fBRxqR/Xn8aIFl E9RzAQL582tmub9g/qO971Pa1OjVDjNL32IPfzHnRPlXM2W/53vApjMStlUFMQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Mt6HK2dfdzhDl; Wed, 19 Oct 2022 23:23:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29JNNf55021476; Wed, 19 Oct 2022 23:23:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29JNNf5S021475; Wed, 19 Oct 2022 23:23:41 GMT (envelope-from git) Date: Wed, 19 Oct 2022 23:23:41 GMT Message-Id: <202210192323.29JNNf5S021475@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Eric Joyner Subject: git: 66ff55d4830a - stable/12 - iavf(4): Replace functions with compatible implementations List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: erj X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 66ff55d4830a0b02e3b7b1c208cb3bba22cbf61a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666221821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=STcsDqMLEyl/TzfdXPNyd3o4TSSsIFRiiMmgDdTofLM=; b=r0YGd+rFtTekholvjTh/6aKQ8g11214fCT2G1KvEyqW2vWp00/mTsUsUQI8mabLpv4Wqe2 We+3oWyfC8eBX0rR7sWOR5cxTtYPdChBO63UlkS/GXFmkh3nv7quKsJmpZN0I0RhHQNUAd kJFOXx3lbPHD4M9p5ed+sEv5YDIQqxcc2QoRFp3dxwoq43BeclJH6mAG/nAXLpIIaf122n cKDaN7nLhhjWr2ihWY5Pvhp621rqZGdscSShyV6wMuO8tcmx2XhpC9W7KXT7YMtg3PM4+B F33dkd6BY/IngdHttt00YgnTo2E7nxGZVASCEZfpYhiPH1BTY9AO/ECWvR0yrQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666221821; a=rsa-sha256; cv=none; b=RCiWvWRDXzYVf3QRCvlthueSMN635irvuhxowGg6Z8014Ym+yjpxm6DvmUCPf7weyuxlm9 cryWNK0z1ILhimiHrQzkch1h3M3pmtCjtslYUbtj+EUDqs/L8oPihbYalb9R22IdFMzDZc YHplm8zAhJOwrntS2raveUpcumIVZtVgPrO6WD1oFGwQXlboPAWKMgIGz4YG0U8EBY7Gf+ e7Jouxt2du4zdMGTcAPJIsUg7OhoxLmaAFGybbFR+B6FpFjEKRyfJQYCawqpFY+QS2q96S matYPXZ6BuWLg7EUHbfxSEgqsnZRhBfJpGBlahJEHUr5WncHCjIhtUdOo+aZ1w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by erj: URL: https://cgit.FreeBSD.org/src/commit/?id=66ff55d4830a0b02e3b7b1c208cb3bba22cbf61a commit 66ff55d4830a0b02e3b7b1c208cb3bba22cbf61a Author: Eric Joyner AuthorDate: 2022-10-19 22:16:41 +0000 Commit: Eric Joyner CommitDate: 2022-10-19 22:16:41 +0000 iavf(4): Replace functions with compatible implementations Since FreeBSD 12.4 is missing functions found in newer versions, replace some of the usages of missing ones with implementations that work for 12.4. This is a direct commit to stable/12; this fix isn't necessary on newer branches. Signed-off-by: Eric Joyner --- sys/dev/iavf/iavf_lib.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/sys/dev/iavf/iavf_lib.c b/sys/dev/iavf/iavf_lib.c index 9b4ec425f1a9..e2b01b518985 100644 --- a/sys/dev/iavf/iavf_lib.c +++ b/sys/dev/iavf/iavf_lib.c @@ -43,6 +43,41 @@ static void iavf_init_hw(struct iavf_hw *hw, device_t dev); static u_int iavf_mc_filter_apply(void *arg, struct sockaddr_dl *sdl, u_int cnt); +static bool iavf_zero_mac(const uint8_t *addr); +static u_int iavf_llmaddr_count(if_t ifp); + +/** + * iavf_zero_mac - Check if MAC address is 0 or not + * + * Returns true if MAC address is all 0's + */ +static bool +iavf_zero_mac(const uint8_t *addr) +{ + uint8_t zero[ETHER_ADDR_LEN] = {0, 0, 0, 0, 0, 0}; + + return (cmp_etheraddr(addr, zero)); +} + +/** + * iavf_llmaddr_count - Return count of multicast MAC addresses in ifp + * + * Similar to "if_llmaddr_count()" found in newer FreeBSD versions + */ +static u_int +iavf_llmaddr_count(if_t ifp) +{ + struct ifmultiaddr *ifma; + int count = 0; + + if_maddr_rlock(ifp); + CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) + if (ifma->ifma_addr->sa_family == AF_LINK) + count++; + if_maddr_runlock(ifp); + + return (count); +} /** * iavf_msec_pause - Pause for at least the specified number of milliseconds @@ -540,7 +575,7 @@ iavf_set_mac_addresses(struct iavf_sc *sc) u8 addr[ETHER_ADDR_LEN]; /* If no mac address was assigned just make a random one */ - if (ETHER_IS_ZERO(hw->mac.addr)) { + if (iavf_zero_mac(hw->mac.addr)) { arc4rand(&addr, sizeof(addr), 0); addr[0] &= 0xFE; addr[0] |= 0x02; @@ -1215,7 +1250,7 @@ iavf_config_promisc(struct iavf_sc *sc, int flags) sc->promisc_flags = 0; if (flags & IFF_ALLMULTI || - if_llmaddr_count(ifp) == MAX_MULTICAST_ADDR) + iavf_llmaddr_count(ifp) >= MAX_MULTICAST_ADDR) sc->promisc_flags |= FLAG_VF_MULTICAST_PROMISC; if (flags & IFF_PROMISC) sc->promisc_flags |= FLAG_VF_UNICAST_PROMISC; @@ -1287,7 +1322,7 @@ iavf_multi_set(struct iavf_sc *sc) IOCTL_DEBUGOUT("iavf_multi_set: begin"); - mcnt = if_llmaddr_count(ifp); + mcnt = iavf_llmaddr_count(ifp); if (__predict_false(mcnt == MAX_MULTICAST_ADDR)) { /* Delete MC filters and enable mulitcast promisc instead */ iavf_init_multi(sc);