Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Mar 2010 02:56:45 +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: r205061 - head/sys/mips/cavium/dev/rgmii
Message-ID:  <201003120256.o2C2ujLm069264@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jmallett
Date: Fri Mar 12 02:56:45 2010
New Revision: 205061
URL: http://svn.freebsd.org/changeset/base/205061

Log:
  o) Send packets being queued for transmission up to BPF if there's a listener.
  o) Properly configure the CAM to handle IFF_PROMISC and note where IFF_ALLMULTI
     handling would go if we didn't already force the NIC to receive all
     multicast traffic.
  
  Reviewed by:	imp
  Sponsored by:	Packet Forensics

Modified:
  head/sys/mips/cavium/dev/rgmii/octeon_rgmx.c

Modified: head/sys/mips/cavium/dev/rgmii/octeon_rgmx.c
==============================================================================
--- head/sys/mips/cavium/dev/rgmii/octeon_rgmx.c	Fri Mar 12 02:55:10 2010	(r205060)
+++ head/sys/mips/cavium/dev/rgmii/octeon_rgmx.c	Fri Mar 12 02:56:45 2010	(r205061)
@@ -209,6 +209,7 @@ static int octeon_rgmx_intr(void *arg);
 /* Standard driver entry points.  These can be static.  */
 static void  octeon_rgmx_init	      (void *);
 //static driver_intr_t    rgmx_intr;
+static void  octeon_rgmx_config_cam   (struct ifnet *);
 static int   octeon_rgmx_ioctl        (struct ifnet *, u_long, caddr_t);
 static void  octeon_rgmx_output_start (struct ifnet *);
 static void  octeon_rgmx_output_start_locked (struct ifnet *);
@@ -1225,6 +1226,8 @@ static void octeon_rgmx_output_start_loc
                 for (ii = 0; ii < len; ii++) printf(" %X", dc[ii]); printf("\n");
 #endif
 
+		ETHER_BPF_MTAP(ifp, m);
+
         	IF_ENQUEUE(&sc->tx_pending_queue, m);
 
                 /*
@@ -1681,6 +1684,60 @@ static void octeon_rgmx_medstat (struct 
 	RGMX_UNLOCK(sc);
 }
 
+static void octeon_rgmx_config_cam(struct ifnet *ifp)
+{
+	struct rgmx_softc_dev *sc = ifp->if_softc;
+	u_int port = sc->port;
+	int index = INDEX(port);
+        int iface = INTERFACE(port);
+	u_int last_enabled;
+	uint64_t adr_ctl;
+
+	last_enabled = octeon_rgmx_stop_port(port);
+
+	adr_ctl = oct_read64(OCTEON_RGMX_RXX_ADR_CTL(index, iface));
+
+	/*
+	 * Always accept broadcast traffic.
+	 */
+	if ((adr_ctl & OCTEON_RGMX_ADRCTL_ACCEPT_BROADCAST) == 0)
+		adr_ctl |= OCTEON_RGMX_ADRCTL_ACCEPT_BROADCAST;
+
+	/*
+	 * Accept all multicast in all multicast mode and in
+	 * promiscuous mode.
+	 *
+	 * XXX Since we don't handle programming the CAM for
+	 * multicast filtering, always accept all multicast.
+	 */
+	adr_ctl &= ~OCTEON_RGMX_ADRCTL_REJECT_ALL_MULTICAST;
+	adr_ctl |= OCTEON_RGMX_ADRCTL_ACCEPT_ALL_MULTICAST;
+
+	/*
+	 * In promiscuous mode, the CAM is shut off, so reject everything.
+	 * Otherwise, filter using the CAM.
+	 */
+	if ((ifp->if_flags & IFF_PROMISC) != 0) {
+		adr_ctl &= ~OCTEON_RGMX_ADRCTL_CAM_MODE_ACCEPT_DMAC;
+		adr_ctl |= OCTEON_RGMX_ADRCTL_CAM_MODE_REJECT_DMAC;
+	} else {
+		adr_ctl &= ~OCTEON_RGMX_ADRCTL_CAM_MODE_REJECT_DMAC;
+		adr_ctl |= OCTEON_RGMX_ADRCTL_CAM_MODE_ACCEPT_DMAC;
+	}
+
+	oct_write64(OCTEON_RGMX_RXX_ADR_CTL(index, iface), adr_ctl);
+
+	/*
+	 * If in promiscuous mode, disable the CAM.
+	 */
+	if ((ifp->if_flags & IFF_PROMISC) != 0)
+		oct_write64(OCTEON_RGMX_RXX_ADR_CAM_EN(index, iface), 0);
+	else
+		oct_write64(OCTEON_RGMX_RXX_ADR_CAM_EN(index, iface), 1);
+
+	if (last_enabled) octeon_rgmx_start_port(port);
+}
+
 static int octeon_rgmx_ioctl (struct ifnet * ifp, u_long command, caddr_t data)
 {
     	struct rgmx_softc_dev *sc = ifp->if_softc;
@@ -1699,8 +1756,6 @@ static int octeon_rgmx_ioctl (struct ifn
                      * "stopped", reflecting the UP flag.
                      */
                     if (ifp->if_flags & IFF_UP) {
-
-
                         /*
                          * New state is IFF_UP
                          * Restart or Start now, if driver is not running currently.
@@ -1708,6 +1763,7 @@ static int octeon_rgmx_ioctl (struct ifn
                         if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
                             octeon_rgmx_init(sc);
                         }
+			octeon_rgmx_config_cam(ifp);
                     } else {
                         /*
                          * New state is IFF_DOWN.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201003120256.o2C2ujLm069264>