From owner-svn-src-all@FreeBSD.ORG Sun Mar 11 00:34:15 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6DD1C1065672; Sun, 11 Mar 2012 00:34:15 +0000 (UTC) (envelope-from jmallett@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3E0FA8FC08; Sun, 11 Mar 2012 00:34:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q2B0YFZE085497; Sun, 11 Mar 2012 00:34:15 GMT (envelope-from jmallett@svn.freebsd.org) Received: (from jmallett@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2B0YFDX085495; Sun, 11 Mar 2012 00:34:15 GMT (envelope-from jmallett@svn.freebsd.org) Message-Id: <201203110034.q2B0YFDX085495@svn.freebsd.org> From: Juli Mallett Date: Sun, 11 Mar 2012 00:34:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232803 - head/sys/mips/cavium X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Mar 2012 00:34:15 -0000 Author: jmallett Date: Sun Mar 11 00:34:14 2012 New Revision: 232803 URL: http://svn.freebsd.org/changeset/base/232803 Log: Fix promiscuous mode with if_octm: o) The MAC set must occur before the multicast list is set up as the former will enable the CAM unconditionally, while promiscuous mode disables it, so if promiscuous mode is to be set this must occur after the MAC is programmed. o) The multicast list must be set up unconditionally as even if flags have not changed, if the interface has gone through a reinitialization, the state of the CAM as changed by the MAC initialization could be incorrect. o) Call octm_init when flags change, even if the interface is already running. Modified: head/sys/mips/cavium/if_octm.c Modified: head/sys/mips/cavium/if_octm.c ============================================================================== --- head/sys/mips/cavium/if_octm.c Sun Mar 11 00:33:54 2012 (r232802) +++ head/sys/mips/cavium/if_octm.c Sun Mar 11 00:34:14 2012 (r232803) @@ -298,19 +298,27 @@ octm_init(void *arg) ifp->if_drv_flags &= ~IFF_DRV_RUNNING; } - if (((ifp->if_flags ^ sc->sc_flags) & (IFF_ALLMULTI | IFF_MULTICAST | IFF_PROMISC)) != 0) { - flags = 0; - if ((ifp->if_flags & IFF_ALLMULTI) != 0) - flags |= CVMX_IFF_ALLMULTI; - if ((ifp->if_flags & IFF_PROMISC) != 0) - flags |= CVMX_IFF_PROMISC; - cvmx_mgmt_port_set_multicast_list(sc->sc_port, flags); - } - + /* + * NB: + * MAC must be set before allmulti and promisc below, as + * cvmx_mgmt_port_set_mac will always enable the CAM, and turning on + * promiscuous mode only works with the CAM disabled. + */ mac = 0; memcpy((u_int8_t *)&mac + 2, IF_LLADDR(ifp), 6); cvmx_mgmt_port_set_mac(sc->sc_port, mac); + /* + * This is done unconditionally, rather than only if sc_flags have + * changed because of set_mac's effect on the CAM noted above. + */ + flags = 0; + if ((ifp->if_flags & IFF_ALLMULTI) != 0) + flags |= CVMX_IFF_ALLMULTI; + if ((ifp->if_flags & IFF_PROMISC) != 0) + flags |= CVMX_IFF_PROMISC; + cvmx_mgmt_port_set_multicast_list(sc->sc_port, flags); + /* XXX link state? */ if ((ifp->if_flags & IFF_UP) != 0) @@ -444,8 +452,7 @@ octm_ioctl(struct ifnet *ifp, u_long cmd if (ifp->if_flags == sc->sc_flags) return (0); if ((ifp->if_flags & IFF_UP) != 0) { - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) - octm_init(sc); + octm_init(sc); } else { if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { cvmx_mgmt_port_disable(sc->sc_port);