summaryrefslogtreecommitdiffstats
path: root/sys/dev/sn/if_sn.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2006-01-07 19:29:25 +0000
committerimp <imp@FreeBSD.org>2006-01-07 19:29:25 +0000
commite1a07793db64c060a0d1491248a1e7fc5e39bb7c (patch)
tree274be48a1a30fdea288db28243c69276363a59d8 /sys/dev/sn/if_sn.c
parent642af77374c4e1d4601c53f91581854125e7fee6 (diff)
downloadFreeBSD-src-e1a07793db64c060a0d1491248a1e7fc5e39bb7c.zip
FreeBSD-src-e1a07793db64c060a0d1491248a1e7fc5e39bb7c.tar.gz
While reviewing if_sn in an attempt to understand network drivers
better, I discovered sn doing too many pointer dereferences. This driver would do silly things like: sn_foo(struct ifnet *ifp) { struct sn_softc *sc = ifp->if_softc; sc->ifp->mumble /* Other stuff */ } while /* other stuff */ usually needed sc, the extra deref isn't needed. Eliminate a few dozen of them.
Diffstat (limited to 'sys/dev/sn/if_sn.c')
-rw-r--r--sys/dev/sn/if_sn.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/sys/dev/sn/if_sn.c b/sys/dev/sn/if_sn.c
index bb3fc5e..b0306e8 100644
--- a/sys/dev/sn/if_sn.c
+++ b/sys/dev/sn/if_sn.c
@@ -373,7 +373,7 @@ snstart_locked(struct ifnet *ifp)
SN_ASSERT_LOCKED(sc);
- if (sc->ifp->if_drv_flags & IFF_DRV_OACTIVE)
+ if (ifp->if_drv_flags & IFF_DRV_OACTIVE)
return;
if (sc->pages_wanted != -1) {
if_printf(ifp, "snstart() while memory allocation pending\n");
@@ -384,7 +384,7 @@ startagain:
/*
* Sneak a peek at the next packet
*/
- m = sc->ifp->if_snd.ifq_head;
+ m = ifp->if_snd.ifq_head;
if (m == 0)
return;
/*
@@ -402,8 +402,8 @@ startagain:
*/
if (len + pad > ETHER_MAX_LEN - ETHER_CRC_LEN) {
if_printf(ifp, "large packet discarded (A)\n");
- ++sc->ifp->if_oerrors;
- IF_DEQUEUE(&sc->ifp->if_snd, m);
+ ++ifp->if_oerrors;
+ IF_DEQUEUE(&ifp->if_snd, m);
m_freem(m);
goto readcheck;
}
@@ -460,8 +460,8 @@ startagain:
CSR_WRITE_1(sc, INTR_MASK_REG_B, mask);
sc->intr_mask = mask;
- sc->ifp->if_timer = 1;
- sc->ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+ ifp->if_timer = 1;
+ ifp->if_drv_flags |= IFF_DRV_OACTIVE;
sc->pages_wanted = numPages;
return;
}
@@ -496,7 +496,7 @@ startagain:
* Get the packet from the kernel. This will include the Ethernet
* frame header, MAC Addresses etc.
*/
- IF_DEQUEUE(&sc->ifp->if_snd, m);
+ IF_DEQUEUE(&ifp->if_snd, m);
/*
* Push out the data to the card.
@@ -544,12 +544,12 @@ startagain:
CSR_WRITE_2(sc, MMU_CMD_REG_W, MMUCR_ENQUEUE);
- sc->ifp->if_drv_flags |= IFF_DRV_OACTIVE;
- sc->ifp->if_timer = 1;
+ ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+ ifp->if_timer = 1;
BPF_MTAP(ifp, top);
- sc->ifp->if_opackets++;
+ ifp->if_opackets++;
m_freem(top);
@@ -598,7 +598,7 @@ snresume(struct ifnet *ifp)
/*
* Sneak a peek at the next packet
*/
- m = sc->ifp->if_snd.ifq_head;
+ m = ifp->if_snd.ifq_head;
if (m == 0) {
if_printf(ifp, "snresume() with nothing to send\n");
return;
@@ -618,8 +618,8 @@ snresume(struct ifnet *ifp)
*/
if (len + pad > ETHER_MAX_LEN - ETHER_CRC_LEN) {
if_printf(ifp, "large packet discarded (B)\n");
- ++sc->ifp->if_oerrors;
- IF_DEQUEUE(&sc->ifp->if_snd, m);
+ ++ifp->if_oerrors;
+ IF_DEQUEUE(&ifp->if_snd, m);
m_freem(m);
return;
}
@@ -654,7 +654,7 @@ snresume(struct ifnet *ifp)
packet_no = CSR_READ_1(sc, ALLOC_RESULT_REG_B);
if (packet_no & ARR_FAILED) {
if_printf(ifp, "Memory allocation failed. Weird.\n");
- sc->ifp->if_timer = 1;
+ ifp->if_timer = 1;
goto try_start;
}
/*
@@ -695,7 +695,7 @@ snresume(struct ifnet *ifp)
* Get the packet from the kernel. This will include the Ethernet
* frame header, MAC Addresses etc.
*/
- IF_DEQUEUE(&sc->ifp->if_snd, m);
+ IF_DEQUEUE(&ifp->if_snd, m);
/*
* Push out the data to the card.
@@ -743,7 +743,7 @@ snresume(struct ifnet *ifp)
BPF_MTAP(ifp, top);
- sc->ifp->if_opackets++;
+ ifp->if_opackets++;
m_freem(top);
try_start:
@@ -751,15 +751,15 @@ try_start:
/*
* Now pass control to snstart() to queue any additional packets
*/
- sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
snstart(ifp);
/*
* We've sent something, so we're active. Set a watchdog in case the
* TX_EMPTY interrupt is lost.
*/
- sc->ifp->if_drv_flags |= IFF_DRV_OACTIVE;
- sc->ifp->if_timer = 1;
+ ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+ ifp->if_timer = 1;
return;
}
@@ -817,7 +817,7 @@ sn_intr(void *arg)
SMC_SELECT_BANK(sc, 2);
CSR_WRITE_1(sc, INTR_ACK_REG_B, IM_RX_OVRN_INT);
- ++sc->ifp->if_ierrors;
+ ++ifp->if_ierrors;
}
/*
* Got a packet.
@@ -845,8 +845,8 @@ sn_intr(void *arg)
* Disable this interrupt.
*/
mask &= ~IM_ALLOC_INT;
- sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
- snresume(sc->ifp);
+ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+ snresume(ifp);
}
/*
* TX Completion. Handle a transmit error message. This will only be
@@ -883,11 +883,11 @@ sn_intr(void *arg)
device_printf(sc->dev,
"Successful packet caused interrupt\n");
} else {
- ++sc->ifp->if_oerrors;
+ ++ifp->if_oerrors;
}
if (tx_status & EPHSR_LATCOL)
- ++sc->ifp->if_collisions;
+ ++ifp->if_collisions;
/*
* Some of these errors will have disabled transmit.
@@ -912,8 +912,8 @@ sn_intr(void *arg)
/*
* Attempt to queue more transmits.
*/
- sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
- snstart_locked(sc->ifp);
+ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+ snstart_locked(ifp);
}
/*
* Transmit underrun. We use this opportunity to update transmit
@@ -938,20 +938,20 @@ sn_intr(void *arg)
/*
* Single collisions
*/
- sc->ifp->if_collisions += card_stats & ECR_COLN_MASK;
+ ifp->if_collisions += card_stats & ECR_COLN_MASK;
/*
* Multiple collisions
*/
- sc->ifp->if_collisions += (card_stats & ECR_MCOLN_MASK) >> 4;
+ ifp->if_collisions += (card_stats & ECR_MCOLN_MASK) >> 4;
SMC_SELECT_BANK(sc, 2);
/*
* Attempt to enqueue some more stuff.
*/
- sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
- snstart_locked(sc->ifp);
+ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+ snstart_locked(ifp);
}
/*
* Some other error. Try to fix it by resetting the adapter.
@@ -1029,7 +1029,7 @@ read_another:
* Account for receive errors and discard.
*/
if (status & RS_ERRORS) {
- ++sc->ifp->if_ierrors;
+ ++ifp->if_ierrors;
goto out;
}
/*
@@ -1049,7 +1049,7 @@ read_another:
if (m == NULL)
goto out;
- m->m_pkthdr.rcvif = sc->ifp;
+ m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = m->m_len = packet_length;
/*
@@ -1062,7 +1062,7 @@ read_another:
*/
if ((m->m_flags & M_EXT) == 0) {
m_freem(m);
- ++sc->ifp->if_ierrors;
+ ++ifp->if_ierrors;
printf("sn: snread() kernel memory allocation problem\n");
goto out;
}
@@ -1077,7 +1077,7 @@ read_another:
data += packet_length & ~1;
*data = CSR_READ_1(sc, DATA_REG_B);
}
- ++sc->ifp->if_ipackets;
+ ++ifp->if_ipackets;
/*
* Remove link layer addresses and whatnot.
OpenPOWER on IntegriCloud