Deleted Added
sdiff udiff text old ( 185329 ) new ( 185330 )
full compact
1/*-
2 * Copyright (c) 1995, David Greenman
3 * Copyright (c) 2001 Jonathan Lemon <jlemon@freebsd.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 14 unchanged lines hidden (view full) ---

23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/fxp/if_fxp.c 185329 2008-11-26 06:36:53Z yongari $");
32
33/*
34 * Intel EtherExpress Pro/100B PCI Fast Ethernet driver
35 */
36
37#ifdef HAVE_KERNEL_OPTION_HEADERS
38#include "opt_device_polling.h"
39#endif

--- 574 unchanged lines hidden (view full) ---

614 sc->rfa_size = sizeof (struct fxp_rfa) - FXP_RFAX_LEN;
615 sc->tx_cmd = FXP_CB_COMMAND_XMIT;
616 }
617
618 /*
619 * Allocate DMA tags and DMA safe memory.
620 */
621 sc->maxtxseg = FXP_NTXSEG;
622 if (sc->flags & FXP_FLAG_EXT_RFA)
623 sc->maxtxseg--;
624 error = bus_dma_tag_create(bus_get_dma_tag(dev), 2, 0,
625 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
626 MCLBYTES * sc->maxtxseg, sc->maxtxseg, MCLBYTES, 0,
627 busdma_lock_mutex, &Giant, &sc->fxp_mtag);
628 if (error) {
629 device_printf(dev, "could not allocate dma tag\n");
630 goto fail;
631 }
632
633 error = bus_dma_tag_create(bus_get_dma_tag(dev), 4, 0,
634 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,

--- 140 unchanged lines hidden (view full) ---

775 ifp->if_init = fxp_init;
776 ifp->if_softc = sc;
777 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
778 ifp->if_ioctl = fxp_ioctl;
779 ifp->if_start = fxp_start;
780
781 ifp->if_capabilities = ifp->if_capenable = 0;
782
783 /* Enable checksum offload for 82550 or better chips */
784 if (sc->flags & FXP_FLAG_EXT_RFA) {
785 ifp->if_hwassist = FXP_CSUM_FEATURES;
786 ifp->if_capabilities |= IFCAP_HWCSUM;
787 ifp->if_capenable |= IFCAP_HWCSUM;
788 }
789
790 if (sc->flags & FXP_FLAG_82559_RXCSUM) {
791 ifp->if_capabilities |= IFCAP_RXCSUM;
792 ifp->if_capenable |= IFCAP_RXCSUM;
793 }
794
795#ifdef DEVICE_POLLING

--- 474 unchanged lines hidden (view full) ---

1270
1271static int
1272fxp_encap(struct fxp_softc *sc, struct mbuf **m_head)
1273{
1274 struct ifnet *ifp;
1275 struct mbuf *m;
1276 struct fxp_tx *txp;
1277 struct fxp_cb_tx *cbp;
1278 bus_dma_segment_t segs[FXP_NTXSEG];
1279 int error, i, nseg;
1280
1281 FXP_LOCK_ASSERT(sc, MA_OWNED);
1282 ifp = sc->ifp;
1283
1284 /*
1285 * Get pointer to next available tx desc.
1286 */
1287 txp = sc->fxp_desc.tx_last->tx_next;
1288
1289 /*
1290 * A note in Appendix B of the Intel 8255x 10/100 Mbps
1291 * Ethernet Controller Family Open Source Software

--- 61 unchanged lines hidden (view full) ---

1353 FXP_IPCB_HARDWAREPARSING_ENABLE;
1354 txp->tx_cb->ipcb_ip_schedule |=
1355 FXP_IPCB_IP_CHECKSUM_ENABLE;
1356 }
1357 }
1358#endif
1359 }
1360
1361 error = bus_dmamap_load_mbuf_sg(sc->fxp_mtag, txp->tx_map, *m_head,
1362 segs, &nseg, 0);
1363 if (error == EFBIG) {
1364 m = m_collapse(*m_head, M_DONTWAIT, sc->maxtxseg);
1365 if (m == NULL) {
1366 m_freem(*m_head);
1367 *m_head = NULL;
1368 return (ENOMEM);

--- 14 unchanged lines hidden (view full) ---

1383 return (EIO);
1384 }
1385
1386 KASSERT(nseg <= sc->maxtxseg, ("too many DMA segments"));
1387 bus_dmamap_sync(sc->fxp_mtag, txp->tx_map, BUS_DMASYNC_PREWRITE);
1388
1389 cbp = txp->tx_cb;
1390 for (i = 0; i < nseg; i++) {
1391 KASSERT(segs[i].ds_len <= MCLBYTES, ("segment size too large"));
1392 /*
1393 * If this is an 82550/82551, then we're using extended
1394 * TxCBs _and_ we're using checksum offload. This means
1395 * that the TxCB is really an IPCB. One major difference
1396 * between the two is that with plain extended TxCBs,
1397 * the bottom half of the TxCB contains two entries from
1398 * the TBD array, whereas IPCBs contain just one entry:
1399 * one entry (8 bytes) has been sacrificed for the TCP/IP
1400 * checksum offload control bits. So to make things work
1401 * right, we have to start filling in the TBD array
1402 * starting from a different place depending on whether
1403 * the chip is an 82550/82551 or not.
1404 */
1405 if (sc->flags & FXP_FLAG_EXT_RFA) {
1406 cbp->tbd[i + 1].tb_addr = htole32(segs[i].ds_addr);
1407 cbp->tbd[i + 1].tb_size = htole32(segs[i].ds_len);
1408 } else {
1409 cbp->tbd[i].tb_addr = htole32(segs[i].ds_addr);
1410 cbp->tbd[i].tb_size = htole32(segs[i].ds_len);
1411 }
1412 }
1413 cbp->tbd_number = nseg;
1414
1415 txp->tx_mbuf = m;
1416 txp->tx_cb->cb_status = 0;
1417 txp->tx_cb->byte_count = 0;
1418 if (sc->tx_queued != FXP_CXINT_THRESH - 1)
1419 txp->tx_cb->cb_command =
1420 htole16(sc->tx_cmd | FXP_CB_COMMAND_SF |
1421 FXP_CB_COMMAND_S);
1422 else
1423 txp->tx_cb->cb_command =
1424 htole16(sc->tx_cmd | FXP_CB_COMMAND_SF |
1425 FXP_CB_COMMAND_S | FXP_CB_COMMAND_I);
1426 txp->tx_cb->tx_threshold = tx_threshold;
1427
1428 /*
1429 * Advance the end of list forward.
1430 */
1431
1432#ifdef __alpha__
1433 /*
1434 * On platforms which can't access memory in 16-bit

--- 657 unchanged lines hidden (view full) ---

2092 cbp->ci_int = 1; /* interrupt on CU idle */
2093 cbp->ext_txcb_dis = sc->flags & FXP_FLAG_EXT_TXCB ? 0 : 1;
2094 cbp->ext_stats_dis = 1; /* disable extended counters */
2095 cbp->keep_overrun_rx = 0; /* don't pass overrun frames to host */
2096 cbp->save_bf = sc->flags & FXP_FLAG_SAVE_BAD ? 1 : prm;
2097 cbp->disc_short_rx = !prm; /* discard short packets */
2098 cbp->underrun_retry = 1; /* retry mode (once) on DMA underrun */
2099 cbp->two_frames = 0; /* do not limit FIFO to 2 frames */
2100 cbp->dyn_tbd = 0; /* (no) dynamic TBD mode */
2101 cbp->ext_rfa = sc->flags & FXP_FLAG_EXT_RFA ? 1 : 0;
2102 cbp->mediatype = sc->flags & FXP_FLAG_SERIAL_MEDIA ? 0 : 1;
2103 cbp->csma_dis = 0; /* (don't) disable link */
2104 cbp->tcp_udp_cksum = ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0 &&
2105 (ifp->if_capenable & IFCAP_RXCSUM) != 0) ? 1 : 0;
2106 cbp->vlan_tco = 0; /* (don't) enable vlan wakeup */
2107 cbp->link_wake_en = 0; /* (don't) assert PME# on link change */
2108 cbp->arp_wake_en = 0; /* (don't) assert PME# on arp */

--- 475 unchanged lines hidden (view full) ---

2584 ifp->if_hwassist &= ~FXP_CSUM_FEATURES;
2585 }
2586 if ((mask & IFCAP_RXCSUM) != 0 &&
2587 (ifp->if_capabilities & IFCAP_RXCSUM) != 0) {
2588 ifp->if_capenable ^= IFCAP_RXCSUM;
2589 if ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0)
2590 reinit++;
2591 }
2592 if ((mask & IFCAP_VLAN_MTU) != 0 &&
2593 (ifp->if_capabilities & IFCAP_VLAN_MTU) != 0) {
2594 ifp->if_capenable ^= IFCAP_VLAN_MTU;
2595 if (sc->revision != FXP_REV_82557)
2596 flag = FXP_FLAG_LONG_PKT_EN;
2597 else /* a hack to get long frames on the old chip */
2598 flag = FXP_FLAG_SAVE_BAD;
2599 sc->flags ^= flag;

--- 259 unchanged lines hidden ---