From owner-svn-src-user@FreeBSD.ORG Thu Jun 24 08:35:02 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D97D3106564A; Thu, 24 Jun 2010 08:35:02 +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 C88688FC14; Thu, 24 Jun 2010 08:35:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o5O8Z2JT033093; Thu, 24 Jun 2010 08:35:02 GMT (envelope-from jmallett@svn.freebsd.org) Received: (from jmallett@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o5O8Z22Q033089; Thu, 24 Jun 2010 08:35:02 GMT (envelope-from jmallett@svn.freebsd.org) Message-Id: <201006240835.o5O8Z22Q033089@svn.freebsd.org> From: Juli Mallett Date: Thu, 24 Jun 2010 08:35:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r209501 - user/jmallett/octeon/sys/mips/cavium/octe X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jun 2010 08:35:02 -0000 Author: jmallett Date: Thu Jun 24 08:35:02 2010 New Revision: 209501 URL: http://svn.freebsd.org/changeset/base/209501 Log: Handle MAC setting and promiscuous/allmulti more gracefully. Modified: user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.c user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.h user/jmallett/octeon/sys/mips/cavium/octe/octe.c Modified: user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.c ============================================================================== --- user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.c Thu Jun 24 08:08:43 2010 (r209500) +++ user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.c Thu Jun 24 08:35:02 2010 (r209501) @@ -139,10 +139,9 @@ void cvm_oct_common_set_multicast_list(s * Set the hardware MAC address for a device * * @param dev Device to change the MAC address for - * @param addr Address structure to change it too. MAC address is addr + 2. - * @return Zero on success + * @param addr Address structure to change it too. */ -static int cvm_oct_common_set_mac_address(struct ifnet *ifp, void *addr) +void cvm_oct_common_set_mac_address(struct ifnet *ifp, const void *addr) { cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc; cvmx_gmxx_prtx_cfg_t gmx_cfg; @@ -153,7 +152,7 @@ static int cvm_oct_common_set_mac_addres if ((interface < 2) && (cvmx_helper_interface_get_mode(interface) != CVMX_HELPER_INTERFACE_MODE_SPI)) { int i; - uint8_t *ptr = addr; + const uint8_t *ptr = addr; uint64_t mac = 0; for (i = 0; i < 6; i++) mac = (mac<<8) | (uint64_t)(ptr[i]); @@ -171,7 +170,6 @@ static int cvm_oct_common_set_mac_addres cvm_oct_common_set_multicast_list(ifp); cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64); } - return 0; } @@ -245,18 +243,10 @@ int cvm_oct_common_init(struct ifnet *if ifp->if_mtu = ETHERMTU; -#if 0 - if (priv->queue != -1) { - if (USE_HW_TCPUDP_CHECKSUM) - ifp->features |= NETIF_F_IP_CSUM; - } -#endif count++; #if 0 ifp->get_stats = cvm_oct_common_get_stats; - ifp->set_mac_address = cvm_oct_common_set_mac_address; - ifp->features |= NETIF_F_LLTX; /* We do our own locking, Linux doesn't need to */ #ifdef CONFIG_NET_POLL_CONTROLLER ifp->poll_controller = cvm_oct_poll_controller; #endif Modified: user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.h ============================================================================== --- user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.h Thu Jun 24 08:08:43 2010 (r209500) +++ user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.h Thu Jun 24 08:35:02 2010 (r209501) @@ -32,6 +32,7 @@ void cvm_oct_common_uninit(struct ifnet int cvm_oct_common_change_mtu(struct ifnet *ifp, int new_mtu); void cvm_oct_common_set_multicast_list(struct ifnet *ifp); +void cvm_oct_common_set_mac_address(struct ifnet *ifp, const void *); int cvm_oct_init_module(device_t); void cvm_oct_cleanup_module(void); Modified: user/jmallett/octeon/sys/mips/cavium/octe/octe.c ============================================================================== --- user/jmallett/octeon/sys/mips/cavium/octe/octe.c Thu Jun 24 08:08:43 2010 (r209500) +++ user/jmallett/octeon/sys/mips/cavium/octe/octe.c Thu Jun 24 08:35:02 2010 (r209501) @@ -53,8 +53,10 @@ #include #include #include +#include #include #include +#include #include #ifdef INET @@ -167,7 +169,13 @@ octe_attach(device_t dev) ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO); } - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + /* + * XXX + * We don't support programming the multicast filter right now, although it + * ought to be easy enough. (Presumably it's just a matter of putting + * multicast addresses in the CAM?) + */ + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST | IFF_ALLMULTI; ifp->if_init = octe_init; ifp->if_ioctl = octe_ioctl; ifp->if_start = octe_start; @@ -252,6 +260,11 @@ octe_init(void *arg) if (priv->open != NULL) priv->open(ifp); + if (((ifp->if_flags ^ priv->if_flags) & (IFF_ALLMULTI | IFF_MULTICAST | IFF_PROMISC)) != 0) + cvm_oct_common_set_multicast_list(ifp); + + cvm_oct_common_set_mac_address(ifp, IF_LLADDR(ifp)); + if (priv->miibus != NULL) mii_mediachg(device_get_softc(priv->miibus)); @@ -450,6 +463,8 @@ octe_ioctl(struct ifnet *ifp, u_long cmd return (0); case SIOCSIFFLAGS: + if (ifp->if_flags == priv->if_flags) + return (0); if ((ifp->if_flags & IFF_UP) != 0) { if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) octe_init(priv);