1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-11 14:10:34 +00:00

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
This commit is contained in:
Juli Mallett 2010-03-12 02:56:45 +00:00
parent 5007b59f26
commit f1112d2f47
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=205061

View File

@ -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.