From owner-svn-src-head@freebsd.org Mon Oct 21 18:08:05 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 5D81615D8D0; Mon, 21 Oct 2019 18:08:05 +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 46xl445HJ4z4Zxx; Mon, 21 Oct 2019 18:08:04 +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 8ECF227B65; Mon, 21 Oct 2019 18:08:04 +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 x9LI84Ek066023; Mon, 21 Oct 2019 18:08:04 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9LI8448066021; Mon, 21 Oct 2019 18:08:04 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201910211808.x9LI8448066021@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:08:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353830 - head/sys/dev/ti X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: head/sys/dev/ti X-SVN-Commit-Revision: 353830 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:08:05 -0000 Author: glebius Date: Mon Oct 21 18:08:03 2019 New Revision: 353830 URL: https://svnweb.freebsd.org/changeset/base/353830 Log: Convert to if_foreach_llmaddr() KPI. Modified: head/sys/dev/ti/if_ti.c head/sys/dev/ti/if_tireg.h Modified: head/sys/dev/ti/if_ti.c ============================================================================== --- head/sys/dev/ti/if_ti.c Mon Oct 21 18:07:56 2019 (r353829) +++ head/sys/dev/ti/if_ti.c Mon Oct 21 18:08:03 2019 (r353830) @@ -207,8 +207,8 @@ static uint32_t ti_eeprom_putbyte(struct ti_softc *, i static uint8_t ti_eeprom_getbyte(struct ti_softc *, int, uint8_t *); static int ti_read_eeprom(struct ti_softc *, caddr_t, int, int); -static void ti_add_mcast(struct ti_softc *, struct ether_addr *); -static void ti_del_mcast(struct ti_softc *, struct ether_addr *); +static u_int ti_add_mcast(void *, struct sockaddr_dl *, u_int); +static u_int ti_del_mcast(void *, struct sockaddr_dl *, u_int); static void ti_setmulti(struct ti_softc *); static void ti_mem_read(struct ti_softc *, uint32_t, uint32_t, void *); @@ -1878,14 +1878,15 @@ ti_init_tx_ring(struct ti_softc *sc) * but we have to support the old way too so that Tigon 1 cards will * work. */ -static void -ti_add_mcast(struct ti_softc *sc, struct ether_addr *addr) +static u_int +ti_add_mcast(void *arg, struct sockaddr_dl *sdl, u_int count) { + struct ti_softc *sc = arg; struct ti_cmd_desc cmd; uint16_t *m; uint32_t ext[2] = {0, 0}; - m = (uint16_t *)&addr->octet[0]; + m = (uint16_t *)LLADDR(sdl); switch (sc->ti_hwrev) { case TI_HWREV_TIGON: @@ -1900,18 +1901,20 @@ ti_add_mcast(struct ti_softc *sc, struct ether_addr *a break; default: device_printf(sc->ti_dev, "unknown hwrev\n"); - break; + return (0); } + return (1); } -static void -ti_del_mcast(struct ti_softc *sc, struct ether_addr *addr) +static u_int +ti_del_mcast(void *arg, struct sockaddr_dl *sdl, u_int count) { + struct ti_softc *sc = arg; struct ti_cmd_desc cmd; uint16_t *m; uint32_t ext[2] = {0, 0}; - m = (uint16_t *)&addr->octet[0]; + m = (uint16_t *)LLADDR(sdl); switch (sc->ti_hwrev) { case TI_HWREV_TIGON: @@ -1926,8 +1929,10 @@ ti_del_mcast(struct ti_softc *sc, struct ether_addr *a break; default: device_printf(sc->ti_dev, "unknown hwrev\n"); - break; + return (0); } + + return (1); } /* @@ -1948,9 +1953,7 @@ static void ti_setmulti(struct ti_softc *sc) { struct ifnet *ifp; - struct ifmultiaddr *ifma; struct ti_cmd_desc cmd; - struct ti_mc_entry *mc; uint32_t intrs; TI_LOCK_ASSERT(sc); @@ -1969,30 +1972,10 @@ ti_setmulti(struct ti_softc *sc) CSR_WRITE_4(sc, TI_MB_HOSTINTR, 1); /* First, zot all the existing filters. */ - while (SLIST_FIRST(&sc->ti_mc_listhead) != NULL) { - mc = SLIST_FIRST(&sc->ti_mc_listhead); - ti_del_mcast(sc, &mc->mc_addr); - SLIST_REMOVE_HEAD(&sc->ti_mc_listhead, mc_entries); - free(mc, M_DEVBUF); - } + if_foreach_llmaddr(ifp, ti_del_mcast, sc); /* Now program new ones. */ - if_maddr_rlock(ifp); - CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - mc = malloc(sizeof(struct ti_mc_entry), M_DEVBUF, M_NOWAIT); - if (mc == NULL) { - device_printf(sc->ti_dev, - "no memory for mcast filter entry\n"); - continue; - } - bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr), - (char *)&mc->mc_addr, ETHER_ADDR_LEN); - SLIST_INSERT_HEAD(&sc->ti_mc_listhead, mc, mc_entries); - ti_add_mcast(sc, &mc->mc_addr); - } - if_maddr_runlock(ifp); + if_foreach_llmaddr(ifp, ti_add_mcast, sc); /* Re-enable interrupts. */ CSR_WRITE_4(sc, TI_MB_HOSTINTR, intrs); Modified: head/sys/dev/ti/if_tireg.h ============================================================================== --- head/sys/dev/ti/if_tireg.h Mon Oct 21 18:07:56 2019 (r353829) +++ head/sys/dev/ti/if_tireg.h Mon Oct 21 18:08:03 2019 (r353830) @@ -1010,11 +1010,6 @@ struct ti_type { #define TI_TIMEOUT 1000 #define TI_TXCONS_UNSET 0xFFFF /* impossible value */ -struct ti_mc_entry { - struct ether_addr mc_addr; - SLIST_ENTRY(ti_mc_entry) mc_entries; -}; - typedef enum { TI_FLAG_NONE = 0x00, TI_FLAG_DEBUGING = 0x01, @@ -1048,7 +1043,6 @@ struct ti_softc { int ti_std; /* current std ring head */ int ti_mini; /* current mini ring head */ int ti_jumbo; /* current jumo ring head */ - SLIST_HEAD(__ti_mchead, ti_mc_entry) ti_mc_listhead; uint32_t ti_stat_ticks; uint32_t ti_rx_coal_ticks; uint32_t ti_tx_coal_ticks;