summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2010-03-12 02:56:45 +0000
committerjmallett <jmallett@FreeBSD.org>2010-03-12 02:56:45 +0000
commit378ca3a5ee2f392fc8f567764968d46621df5a66 (patch)
treee75b94b1dd58ecfe4afbfce7ee19f5bcaabaa5f9
parent0d5da117aaa01aa61b32dccc13e04e1f70a12694 (diff)
downloadFreeBSD-src-378ca3a5ee2f392fc8f567764968d46621df5a66.zip
FreeBSD-src-378ca3a5ee2f392fc8f567764968d46621df5a66.tar.gz
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
-rw-r--r--sys/mips/cavium/dev/rgmii/octeon_rgmx.c60
1 files changed, 58 insertions, 2 deletions
diff --git a/sys/mips/cavium/dev/rgmii/octeon_rgmx.c b/sys/mips/cavium/dev/rgmii/octeon_rgmx.c
index 44cddf7..b18c83a 100644
--- a/sys/mips/cavium/dev/rgmii/octeon_rgmx.c
+++ b/sys/mips/cavium/dev/rgmii/octeon_rgmx.c
@@ -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_locked (struct ifnet *ifp)
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 ifnet *ifp, struct ifmediareq *ifm)
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 ifnet * ifp, u_long command, caddr_t data)
* "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 ifnet * ifp, u_long command, caddr_t data)
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
octeon_rgmx_init(sc);
}
+ octeon_rgmx_config_cam(ifp);
} else {
/*
* New state is IFF_DOWN.
OpenPOWER on IntegriCloud