summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2006-02-15 19:36:47 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2006-02-15 19:36:47 +0000
commit93db90262489fd4011c9373c438b8a32d52de627 (patch)
treeeceb2de32313d4665e6bceadd029872f4d84fc09
parent246be331c73373ca973da35d730fbe182cfb5b5d (diff)
- enable jumbo frames for adapters that support it.
- extend TX DMA mappings size from MCLBYTES to NFE_JBYTES. - add initial (disabled) bits for interrupts mitigation. - add initial (disabled) bits for h/w VLAN tagging. - did some consistency tweaks while i'm here.
-rw-r--r--sys/dev/pci/if_nfe.c67
-rw-r--r--sys/dev/pci/if_nfereg.h14
-rw-r--r--sys/dev/pci/if_nfevar.h5
3 files changed, 58 insertions, 28 deletions
diff --git a/sys/dev/pci/if_nfe.c b/sys/dev/pci/if_nfe.c
index 7887d5338f4..2646ad8a206 100644
--- a/sys/dev/pci/if_nfe.c
+++ b/sys/dev/pci/if_nfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_nfe.c,v 1.36 2006/02/13 08:54:54 brad Exp $ */
+/* $OpenBSD: if_nfe.c,v 1.37 2006/02/15 19:36:46 damien Exp $ */
/*-
* Copyright (c) 2006 Damien Bergamini <damien.bergamini@free.fr>
@@ -114,7 +114,7 @@ struct cfdriver nfe_cd = {
};
#define NFE_DEBUG
-#define NFE_NO_JUMBO
+/*#define NFE_NO_JUMBO*/
#ifdef NFE_DEBUG
int nfedebug = 1;
@@ -166,17 +166,17 @@ nfe_attach(struct device *parent, struct device *self, void *aux)
switch (memtype) {
case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:
case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:
- if (pci_mapreg_map(pa, NFE_PCI_BA,
- memtype, 0, &sc->sc_memt, &sc->sc_memh,
- NULL, &memsize, 0) == 0)
+ if (pci_mapreg_map(pa, NFE_PCI_BA, memtype, 0, &sc->sc_memt,
+ &sc->sc_memh, NULL, &memsize, 0) == 0)
break;
+ /* FALLTHROUGH */
default:
- printf(": can't map mem space\n");
+ printf(": could not map mem space\n");
return;
}
if (pci_intr_map(pa, &ih) != 0) {
- printf(": couldn't map interrupt\n");
+ printf(": could not map interrupt\n");
return;
}
@@ -184,7 +184,7 @@ nfe_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, nfe_intr, sc,
sc->sc_dev.dv_xname);
if (sc->sc_ih == NULL) {
- printf(": couldn't establish interrupt");
+ printf(": could not establish interrupt");
if (intrstr != NULL)
printf(" at %s", intrstr);
printf("\n");
@@ -214,9 +214,12 @@ nfe_attach(struct device *parent, struct device *self, void *aux)
case PCI_PRODUCT_NVIDIA_CK804_LAN2:
case PCI_PRODUCT_NVIDIA_MCP04_LAN1:
case PCI_PRODUCT_NVIDIA_MCP04_LAN2:
+ sc->sc_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM;
+ break;
case PCI_PRODUCT_NVIDIA_MCP55_LAN1:
case PCI_PRODUCT_NVIDIA_MCP55_LAN2:
- sc->sc_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM;
+ sc->sc_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM |
+ NFE_HW_VLAN;
break;
}
@@ -254,7 +257,11 @@ nfe_attach(struct device *parent, struct device *self, void *aux)
IFQ_SET_READY(&ifp->if_snd);
strlcpy(ifp->if_xname, sc->sc_dev.dv_xname, IFNAMSIZ);
- ifp->if_capabilities = IFCAP_VLAN_MTU;
+#if NVLAN > 0
+ ifp->if_capabilities |= IFCAP_VLAN_MTU;
+ if (sc->sc_flags & NFE_HW_VLAN)
+ ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING;
+#endif
#ifdef NFE_CSUM
if (sc->sc_flags & NFE_HW_CSUM) {
ifp->if_capabilities |= IFCAP_CSUM_IPv4 | IFCAP_CSUM_TCPv4 |
@@ -957,6 +964,18 @@ nfe_encap(struct nfe_softc *sc, struct mbuf *m0)
desc32->flags = htole16(flags);
}
+#if NVLAN > 0
+ if (sc->sc_flags & NFE_HW_VLAN) {
+ /* setup h/w VLAN tagging */
+ if ((m0->m_flags & M_PROTO1) && m0->m_pkthdr.rcvif != NULL) {
+ struct ifvlan *ifv = m0->m_pkthdr.rcvif->if_softc;
+ desc64->vtag = htole32(NFE_TX_VTAG |
+ htons(ifv->ifv_tag));
+ } else
+ desc64->vtag = 0;
+ }
+#endif
+
data->m = m0;
data->active = map;
@@ -1083,9 +1102,16 @@ nfe_init(struct ifnet *ifp)
tmp = NFE_READ(sc, NFE_PWR_STATE);
NFE_WRITE(sc, NFE_PWR_STATE, tmp | NFE_PWR_VALID);
+#ifdef notyet
+ /* configure interrupts coalescing/mitigation */
+ NFE_WRITE(sc, NFE_IMTIMER, NFE_IM_DEFAULT);
+#else
+ /* no interrupt mitigation: one interrupt per packet */
+ NFE_WRITE(sc, NFE_IMTIMER, 970);
+#endif
+
NFE_WRITE(sc, NFE_SETUP_R1, NFE_R1_MAGIC);
NFE_WRITE(sc, NFE_SETUP_R2, NFE_R2_MAGIC);
- NFE_WRITE(sc, NFE_TIMER_INT, 970); /* XXX Magic */
NFE_WRITE(sc, NFE_SETUP_R4, NFE_R4_MAGIC);
NFE_WRITE(sc, NFE_WOL_CTL, NFE_WOL_MAGIC);
@@ -1333,16 +1359,14 @@ nfe_free_rx_ring(struct nfe_softc *sc, struct nfe_rx_ring *ring)
for (i = 0; i < NFE_RX_RING_COUNT; i++) {
data = &ring->data[i];
- if (data->m != NULL) {
+ if (data->map != NULL) {
bus_dmamap_sync(sc->sc_dmat, data->map, 0,
- data->map->dm_mapsize,
- BUS_DMASYNC_POSTREAD);
+ data->map->dm_mapsize, BUS_DMASYNC_POSTREAD);
bus_dmamap_unload(sc->sc_dmat, data->map);
- m_freem(data->m);
- }
-
- if (data->map != NULL)
bus_dmamap_destroy(sc->sc_dmat, data->map);
+ }
+ if (data->m != NULL)
+ m_freem(data->m);
}
}
@@ -1522,8 +1546,8 @@ nfe_alloc_tx_ring(struct nfe_softc *sc, struct nfe_tx_ring *ring)
ring->physaddr = ring->map->dm_segs[0].ds_addr;
for (i = 0; i < NFE_TX_RING_COUNT; i++) {
- error = bus_dmamap_create(sc->sc_dmat, MCLBYTES,
- NFE_MAX_SCATTER, MCLBYTES, 0, BUS_DMA_NOWAIT,
+ error = bus_dmamap_create(sc->sc_dmat, NFE_JBYTES,
+ NFE_MAX_SCATTER, NFE_JBYTES, 0, BUS_DMA_NOWAIT,
&ring->data[i].map);
if (error != 0) {
printf("%s: could not create DMA map\n",
@@ -1597,8 +1621,7 @@ nfe_free_tx_ring(struct nfe_softc *sc, struct nfe_tx_ring *ring)
if (data->m != NULL) {
bus_dmamap_sync(sc->sc_dmat, data->active, 0,
- data->active->dm_mapsize,
- BUS_DMASYNC_POSTWRITE);
+ data->active->dm_mapsize, BUS_DMASYNC_POSTWRITE);
bus_dmamap_unload(sc->sc_dmat, data->active);
m_freem(data->m);
}
diff --git a/sys/dev/pci/if_nfereg.h b/sys/dev/pci/if_nfereg.h
index db984c9c643..d3f8f7d10ac 100644
--- a/sys/dev/pci/if_nfereg.h
+++ b/sys/dev/pci/if_nfereg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_nfereg.h,v 1.10 2006/02/12 10:28:07 damien Exp $ */
+/* $OpenBSD: if_nfereg.h,v 1.11 2006/02/15 19:36:46 damien Exp $ */
/*-
* Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org>
@@ -30,7 +30,7 @@
#define NFE_IRQ_STATUS 0x000
#define NFE_IRQ_MASK 0x004
#define NFE_SETUP_R6 0x008
-#define NFE_TIMER_INT 0x00c
+#define NFE_IMTIMER 0x00c
#define NFE_MISC1 0x080
#define NFE_TX_CTL 0x084
#define NFE_TX_STATUS 0x088
@@ -96,14 +96,18 @@
#define NFE_RXTX_BIT1 0x0002
#define NFE_RXTX_BIT2 0x0004
#define NFE_RXTX_RESET 0x0010
+#define NFE_RXTX_VTAG_STRIP 0x0040
+#define NFE_RXTX_VTAG_INSERT 0x0080
#define NFE_RXTX_RXCHECK 0x0400
#define NFE_RXTX_V2MAGIC 0x2100
#define NFE_RXTX_V3MAGIC 0x2200
-
#define NFE_RXFILTER_MAGIC 0x007f0008
#define NFE_U2M (1 << 5)
#define NFE_PROMISC (1 << 7)
+/* default interrupt moderation timer of 128us */
+#define NFE_IM_DEFAULT ((128 * 100) / 1024)
+
#define NFE_PWR_VALID (1 << 8)
#define NFE_PWR_WAKEUP (1 << 15)
@@ -138,12 +142,14 @@ struct nfe_desc32 {
/* V2 Rx/Tx descriptor */
struct nfe_desc64 {
uint32_t physaddr[2];
- uint32_t reserved;
+ uint32_t vtag;
uint16_t length;
uint16_t flags;
#define NFE_RX_FIXME_V2 0x4300
+#define NFE_RX_VTAG (1 << 0)
#define NFE_RX_VALID_V2 (1 << 13)
#define NFE_TX_ERROR_V2 0x5c04
+#define NFE_TX_VTAG (1 << 2)
#define NFE_TX_LASTFRAG_V2 (1 << 13)
} __packed;
diff --git a/sys/dev/pci/if_nfevar.h b/sys/dev/pci/if_nfevar.h
index 6b0b160507b..f7ae53cb54e 100644
--- a/sys/dev/pci/if_nfevar.h
+++ b/sys/dev/pci/if_nfevar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_nfevar.h,v 1.8 2006/02/12 10:28:07 damien Exp $ */
+/* $OpenBSD: if_nfevar.h,v 1.9 2006/02/15 19:36:46 damien Exp $ */
/*-
* Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org>
@@ -80,7 +80,8 @@ struct nfe_softc {
#define NFE_JUMBO_SUP 0x01
#define NFE_40BIT_ADDR 0x02
#define NFE_HW_CSUM 0x04
-#define NFE_USE_JUMBO 0x08
+#define NFE_HW_VLAN 0x08
+#define NFE_USE_JUMBO 0x10
uint8_t phyaddr;