Handle the set capabilities ioctl, letting the hardware checksum be
disabled (Hi netmap!). Only remove the CRC bytes from packets when the hardware tell us to do so. Fixes the 'discard frame w/o leading ethernet header' issues. Sponsored by: Rubicon Communications, LLC (Netgate)
This commit is contained in:
parent
0df67f81eb
commit
3b8977012f
@ -1395,6 +1395,16 @@ cpswp_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
||||
ifr = (struct ifreq *)data;
|
||||
|
||||
switch (command) {
|
||||
case SIOCSIFCAP:
|
||||
changed = ifp->if_capenable ^ ifr->ifr_reqcap;
|
||||
if (changed & IFCAP_HWCSUM) {
|
||||
if ((ifr->ifr_reqcap & changed) & IFCAP_HWCSUM)
|
||||
ifp->if_capenable |= IFCAP_HWCSUM;
|
||||
else
|
||||
ifp->if_capenable &= ~IFCAP_HWCSUM;
|
||||
}
|
||||
error = 0;
|
||||
break;
|
||||
case SIOCSIFFLAGS:
|
||||
CPSW_PORT_LOCK(sc);
|
||||
if (ifp->if_flags & IFF_UP) {
|
||||
@ -1632,15 +1642,22 @@ cpsw_rx_dequeue(struct cpsw_softc *sc)
|
||||
/* TODO: track SOP/EOP bits to assemble a full mbuf
|
||||
out of received fragments. */
|
||||
slot->mbuf->m_data += bd.bufoff;
|
||||
slot->mbuf->m_len = bd.pktlen - 4;
|
||||
slot->mbuf->m_pkthdr.len = bd.pktlen - 4;
|
||||
slot->mbuf->m_flags |= M_PKTHDR;
|
||||
slot->mbuf->m_pkthdr.rcvif = psc->ifp;
|
||||
slot->mbuf->m_len = bd.buflen;
|
||||
if (bd.flags & CPDMA_BD_SOP) {
|
||||
slot->mbuf->m_pkthdr.len = bd.pktlen;
|
||||
slot->mbuf->m_pkthdr.rcvif = psc->ifp;
|
||||
slot->mbuf->m_flags |= M_PKTHDR;
|
||||
}
|
||||
slot->mbuf->m_next = NULL;
|
||||
slot->mbuf->m_nextpkt = NULL;
|
||||
if (bd.flags & CPDMA_BD_PASS_CRC)
|
||||
m_adj(slot->mbuf, -ETHER_CRC_LEN);
|
||||
|
||||
if ((psc->ifp->if_capenable & IFCAP_RXCSUM) != 0) {
|
||||
/* check for valid CRC by looking into pkt_err[5:4] */
|
||||
if ((bd.flags & CPDMA_BD_PKT_ERR_MASK) == 0) {
|
||||
if ((bd.flags &
|
||||
(CPDMA_BD_SOP | CPDMA_BD_PKT_ERR_MASK)) ==
|
||||
CPDMA_BD_SOP) {
|
||||
slot->mbuf->m_pkthdr.csum_flags |= CSUM_IP_CHECKED;
|
||||
slot->mbuf->m_pkthdr.csum_flags |= CSUM_IP_VALID;
|
||||
slot->mbuf->m_pkthdr.csum_data = 0xffff;
|
||||
|
@ -191,6 +191,7 @@
|
||||
#define CPDMA_BD_OWNER (1 << 13)
|
||||
#define CPDMA_BD_EOQ (1 << 12)
|
||||
#define CPDMA_BD_TDOWNCMPLT (1 << 11)
|
||||
#define CPDMA_BD_PASS_CRC (1 << 10)
|
||||
#define CPDMA_BD_PKT_ERR_MASK (3 << 4)
|
||||
#define CPDMA_BD_TO_PORT (1 << 4)
|
||||
#define CPDMA_BD_PORT_MASK 3
|
||||
|
Loading…
Reference in New Issue
Block a user