Date: Thu, 24 Jun 2010 08:35:02 +0000 (UTC) From: Juli Mallett <jmallett@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r209501 - user/jmallett/octeon/sys/mips/cavium/octe Message-ID: <201006240835.o5O8Z22Q033089@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <net/bpf.h> #include <net/ethernet.h> #include <net/if.h> +#include <net/if_dl.h> #include <net/if_media.h> #include <net/if_types.h> +#include <net/if_var.h> #include <net/if_vlan_var.h> #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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006240835.o5O8Z22Q033089>