From owner-svn-src-head@freebsd.org Mon Oct 21 18:06:32 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B5DC815D206; Mon, 21 Oct 2019 18:06:32 +0000 (UTC) (envelope-from glebius@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46xl2J3wMPz4Xr6; Mon, 21 Oct 2019 18:06:32 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 683EF27B54; Mon, 21 Oct 2019 18:06:32 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9LI6Wb7065129; Mon, 21 Oct 2019 18:06:32 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9LI6Wtq065127; Mon, 21 Oct 2019 18:06:32 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201910211806.x9LI6Wtq065127@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Mon, 21 Oct 2019 18:06:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353813 - head/sys/dev/bxe X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: head/sys/dev/bxe X-SVN-Commit-Revision: 353813 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Oct 2019 18:06:33 -0000 Author: glebius Date: Mon Oct 21 18:06:31 2019 New Revision: 353813 URL: https://svnweb.freebsd.org/changeset/base/353813 Log: Convert to if_foreach_llmaddr() KPI. Modified: head/sys/dev/bxe/bxe.c head/sys/dev/bxe/bxe.h Modified: head/sys/dev/bxe/bxe.c ============================================================================== --- head/sys/dev/bxe/bxe.c Mon Oct 21 18:06:26 2019 (r353812) +++ head/sys/dev/bxe/bxe.c Mon Oct 21 18:06:31 2019 (r353813) @@ -12065,27 +12065,31 @@ bxe_initial_phy_init(struct bxe_softc *sc, return (rc); } -/* must be called under IF_ADDR_LOCK */ +static u_int +bxe_push_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + struct ecore_mcast_list_elem *mc_mac = arg; + + mc_mac += cnt; + mc_mac->mac = (uint8_t *)LLADDR(sdl); + + return (1); +} + static int bxe_init_mcast_macs_list(struct bxe_softc *sc, struct ecore_mcast_ramrod_params *p) { if_t ifp = sc->ifp; - int mc_count = 0; - struct ifmultiaddr *ifma; + int mc_count; struct ecore_mcast_list_elem *mc_mac; - CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) { - continue; - } - - mc_count++; - } - ECORE_LIST_INIT(&p->mcast_list); p->mcast_list_len = 0; + /* XXXGL: multicast count may change later */ + mc_count = if_llmaddr_count(ifp); + if (!mc_count) { return (0); } @@ -12097,20 +12101,15 @@ bxe_init_mcast_macs_list(struct bxe_softc return (-1); } bzero(mc_mac, (sizeof(*mc_mac) * mc_count)); + if_foreach_llmaddr(ifp, bxe_push_maddr, mc_mac); - CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) { - continue; - } - - mc_mac->mac = (uint8_t *)LLADDR((struct sockaddr_dl *)ifma->ifma_addr); - ECORE_LIST_PUSH_TAIL(&mc_mac->link, &p->mcast_list); - + for (int i = 0; i < mc_count; i ++) { + ECORE_LIST_PUSH_TAIL(&mc_mac[i].link, &p->mcast_list); BLOGD(sc, DBG_LOAD, "Setting MCAST %02X:%02X:%02X:%02X:%02X:%02X and mc_count %d\n", - mc_mac->mac[0], mc_mac->mac[1], mc_mac->mac[2], - mc_mac->mac[3], mc_mac->mac[4], mc_mac->mac[5], mc_count); - mc_mac++; + mc_mac[i].mac[0], mc_mac[i].mac[1], mc_mac[i].mac[2], + mc_mac[i].mac[3], mc_mac[i].mac[4], mc_mac[i].mac[5], + mc_count); } p->mcast_list_len = mc_count; @@ -12171,69 +12170,59 @@ bxe_set_mc_list(struct bxe_softc *sc) return (rc); } +struct bxe_set_addr_ctx { + struct bxe_softc *sc; + unsigned long ramrod_flags; + int rc; +}; + +static u_int +bxe_set_addr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + struct bxe_set_addr_ctx *ctx = arg; + struct ecore_vlan_mac_obj *mac_obj = &ctx->sc->sp_objs->mac_obj; + int rc; + + if (ctx->rc < 0) + return (0); + + rc = bxe_set_mac_one(ctx->sc, (uint8_t *)LLADDR(sdl), mac_obj, TRUE, + ECORE_UC_LIST_MAC, &ctx->ramrod_flags); + + /* do not treat adding same MAC as an error */ + if (rc == -EEXIST) + BLOGD(ctx->sc, DBG_SP, "Failed to schedule ADD operations (EEXIST)\n"); + else if (rc < 0) { + BLOGE(ctx->sc, "Failed to schedule ADD operations (%d)\n", rc); + ctx->rc = rc; + } + + return (1); +} + static int bxe_set_uc_list(struct bxe_softc *sc) { if_t ifp = sc->ifp; struct ecore_vlan_mac_obj *mac_obj = &sc->sp_objs->mac_obj; - struct ifaddr *ifa; - unsigned long ramrod_flags = 0; + struct bxe_set_addr_ctx ctx = { sc, 0, 0 }; int rc; -#if __FreeBSD_version < 800000 - IF_ADDR_LOCK(ifp); -#else - if_addr_rlock(ifp); -#endif - /* first schedule a cleanup up of old configuration */ rc = bxe_del_all_macs(sc, mac_obj, ECORE_UC_LIST_MAC, FALSE); if (rc < 0) { BLOGE(sc, "Failed to schedule delete of all ETH MACs (%d)\n", rc); -#if __FreeBSD_version < 800000 - IF_ADDR_UNLOCK(ifp); -#else - if_addr_runlock(ifp); -#endif return (rc); } - ifa = if_getifaddr(ifp); /* XXX Is this structure */ - while (ifa) { - if (ifa->ifa_addr->sa_family != AF_LINK) { - ifa = CK_STAILQ_NEXT(ifa, ifa_link); - continue; - } + if_foreach_lladdr(ifp, bxe_set_addr, &ctx); + if (ctx.rc < 0) + return (ctx.rc); - rc = bxe_set_mac_one(sc, (uint8_t *)LLADDR((struct sockaddr_dl *)ifa->ifa_addr), - mac_obj, TRUE, ECORE_UC_LIST_MAC, &ramrod_flags); - if (rc == -EEXIST) { - BLOGD(sc, DBG_SP, "Failed to schedule ADD operations (EEXIST)\n"); - /* do not treat adding same MAC as an error */ - rc = 0; - } else if (rc < 0) { - BLOGE(sc, "Failed to schedule ADD operations (%d)\n", rc); -#if __FreeBSD_version < 800000 - IF_ADDR_UNLOCK(ifp); -#else - if_addr_runlock(ifp); -#endif - return (rc); - } - - ifa = CK_STAILQ_NEXT(ifa, ifa_link); - } - -#if __FreeBSD_version < 800000 - IF_ADDR_UNLOCK(ifp); -#else - if_addr_runlock(ifp); -#endif - /* Execute the pending commands */ - bit_set(&ramrod_flags, RAMROD_CONT); + bit_set(&ctx.ramrod_flags, RAMROD_CONT); return (bxe_set_mac_one(sc, NULL, mac_obj, FALSE /* don't care */, - ECORE_UC_LIST_MAC, &ramrod_flags)); + ECORE_UC_LIST_MAC, &ctx.ramrod_flags)); } static void Modified: head/sys/dev/bxe/bxe.h ============================================================================== --- head/sys/dev/bxe/bxe.h Mon Oct 21 18:06:26 2019 (r353812) +++ head/sys/dev/bxe/bxe.h Mon Oct 21 18:06:31 2019 (r353813) @@ -1492,29 +1492,8 @@ struct bxe_softc { #define BXE_STATS_UNLOCK(sc) mtx_unlock(&sc->stats_mtx) #define BXE_STATS_LOCK_ASSERT(sc) mtx_assert(&sc->stats_mtx, MA_OWNED) -#if __FreeBSD_version < 800000 -#define BXE_MCAST_LOCK(sc) \ - do { \ - mtx_lock(&sc->mcast_mtx); \ - IF_ADDR_LOCK(sc->ifp); \ - } while (0) -#define BXE_MCAST_UNLOCK(sc) \ - do { \ - IF_ADDR_UNLOCK(sc->ifp); \ - mtx_unlock(&sc->mcast_mtx); \ - } while (0) -#else -#define BXE_MCAST_LOCK(sc) \ - do { \ - mtx_lock(&sc->mcast_mtx); \ - if_maddr_rlock(sc->ifp); \ - } while (0) -#define BXE_MCAST_UNLOCK(sc) \ - do { \ - if_maddr_runlock(sc->ifp); \ - mtx_unlock(&sc->mcast_mtx); \ - } while (0) -#endif +#define BXE_MCAST_LOCK(sc) mtx_lock(&sc->mcast_mtx); +#define BXE_MCAST_UNLOCK(sc) mtx_unlock(&sc->mcast_mtx); #define BXE_MCAST_LOCK_ASSERT(sc) mtx_assert(&sc->mcast_mtx, MA_OWNED) int dmae_ready;