Date: Sun, 11 Mar 2012 00:34:15 +0000 (UTC) From: Juli Mallett <jmallett@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r232803 - head/sys/mips/cavium Message-ID: <201203110034.q2B0YFDX085495@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203110034.q2B0YFDX085495>