Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci No functional change:



details:   https://anonhg.NetBSD.org/src/rev/760f423c268d
branches:  trunk
changeset: 330832:760f423c268d
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Jul 23 10:48:16 2014 +0000

description:
No functional change:
- Grouping functions.
- KNF.

diffstat:

 sys/dev/pci/if_wm.c |  7607 +++++++++++++++++++++++++-------------------------
 1 files changed, 3803 insertions(+), 3804 deletions(-)

diffs (truncated from 7952 to 300 lines):

diff -r 51e28f0b1330 -r 760f423c268d sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Wed Jul 23 09:44:52 2014 +0000
+++ b/sys/dev/pci/if_wm.c       Wed Jul 23 10:48:16 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.280 2014/07/23 09:44:52 msaitoh Exp $      */
+/*     $NetBSD: if_wm.c,v 1.281 2014/07/23 10:48:16 msaitoh Exp $      */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.280 2014/07/23 09:44:52 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.281 2014/07/23 10:48:16 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -265,7 +265,7 @@
        pci_chipset_tag_t sc_pc;
        pcitag_t sc_pcitag;
        int sc_bus_speed;               /* PCI/PCIX bus speed */
-       int sc_pcixe_capoff;            /* PCI[Xe] capability register offset */
+       int sc_pcixe_capoff;            /* PCI[Xe] capability reg offset */
 
        const struct wm_product *sc_wmp; /* Pointer to the wm_product entry */
        wm_chip_type sc_type;           /* MAC type */
@@ -286,16 +286,12 @@
        int sc_ich8_flash_bank_size;
        int sc_nvm_k1_enabled;
 
-       /*
-        * Software state for the transmit and receive descriptors.
-        */
+       /* Software state for the transmit and receive descriptors. */
        int sc_txnum;                   /* must be a power of two */
        struct wm_txsoft sc_txsoft[WM_TXQUEUELEN_MAX];
        struct wm_rxsoft sc_rxsoft[WM_NRXDESC];
 
-       /*
-        * Control data structures.
-        */
+       /* Control data structures. */
        int sc_ntxdesc;                 /* must be a power of two */
        struct wm_control_data_82544 *sc_control_data;
        bus_dmamap_t sc_cddmamap;       /* control data DMA map */
@@ -1216,16 +1212,6 @@
                wa->wa_high = 0;
 }
 
-static void
-wm_set_spiaddrbits(struct wm_softc *sc)
-{
-       uint32_t reg;
-
-       sc->sc_flags |= WM_F_EEPROM_SPI;
-       reg = CSR_READ(sc, WMREG_EECD);
-       sc->sc_ee_addrbits = (reg & EECD_EE_ABITS) ? 16 : 8;
-}
-
 /*
  * Device driver interface functions and commonly used functions.
  * match, attach, detach, init, start, stop, ioctl, watchdog and so on.
@@ -1603,9 +1589,7 @@
                goto fail_3;
        }
 
-       /*
-        * Create the transmit buffer DMA maps.
-        */
+       /* Create the transmit buffer DMA maps. */
        WM_TXQUEUELEN(sc) =
            (sc->sc_type == WM_T_82547 || sc->sc_type == WM_T_82547_2) ?
            WM_TXQUEUELEN_MAX_82547 : WM_TXQUEUELEN_MAX;
@@ -1620,9 +1604,7 @@
                }
        }
 
-       /*
-        * Create the receive buffer DMA maps.
-        */
+       /* Create the receive buffer DMA maps. */
        for (i = 0; i < WM_NRXDESC; i++) {
                if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1,
                            MCLBYTES, 0, 0,
@@ -1644,14 +1626,10 @@
            || (sc->sc_type == WM_T_PCH_LPT))
                wm_smbustopci(sc);
 
-       /*
-        * Reset the chip to a known state.
-        */
+       /* Reset the chip to a known state. */
        wm_reset(sc);
 
-       /*
-        * Get some information about the EEPROM.
-        */
+       /* Get some information about the EEPROM. */
        switch (sc->sc_type) {
        case WM_T_82542_2_0:
        case WM_T_82542_2_1:
@@ -2139,9 +2117,7 @@
                break;
        }
 
-       /*
-        * If we're a i82543 or greater, we can support VLANs.
-        */
+       /* If we're a i82543 or greater, we can support VLANs. */
        if (sc->sc_type >= WM_T_82543)
                sc->sc_ethercom.ec_capabilities |=
                    ETHERCAP_VLAN_MTU | ETHERCAP_VLAN_HWTAGGING;
@@ -2188,9 +2164,7 @@
        sc->sc_txrx_lock = NULL;
 #endif
 
-       /*
-        * Attach the interface.
-        */
+       /* Attach the interface. */
        if_attach(ifp);
        ether_ifattach(ifp, enaddr);
        ether_set_ifflags_cb(&sc->sc_ethercom, wm_ifflags_cb);
@@ -2373,1152 +2347,28 @@
        return 0;
 }
 
-/*
- * wm_tx_offload:
- *
- *     Set up TCP/IP checksumming parameters for the
- *     specified packet.
- */
-static int
-wm_tx_offload(struct wm_softc *sc, struct wm_txsoft *txs, uint32_t *cmdp,
-    uint8_t *fieldsp)
-{
-       struct mbuf *m0 = txs->txs_mbuf;
-       struct livengood_tcpip_ctxdesc *t;
-       uint32_t ipcs, tucs, cmd, cmdlen, seg;
-       uint32_t ipcse;
-       struct ether_header *eh;
-       int offset, iphl;
-       uint8_t fields;
-
-       /*
-        * XXX It would be nice if the mbuf pkthdr had offset
-        * fields for the protocol headers.
-        */
-
-       eh = mtod(m0, struct ether_header *);
-       switch (htons(eh->ether_type)) {
-       case ETHERTYPE_IP:
-       case ETHERTYPE_IPV6:
-               offset = ETHER_HDR_LEN;
-               break;
-
-       case ETHERTYPE_VLAN:
-               offset = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN;
-               break;
-
-       default:
-               /*
-                * Don't support this protocol or encapsulation.
-                */
-               *fieldsp = 0;
-               *cmdp = 0;
-               return 0;
-       }
-
-       if ((m0->m_pkthdr.csum_flags &
-           (M_CSUM_TSOv4|M_CSUM_UDPv4|M_CSUM_TCPv4)) != 0) {
-               iphl = M_CSUM_DATA_IPv4_IPHL(m0->m_pkthdr.csum_data);
-       } else {
-               iphl = M_CSUM_DATA_IPv6_HL(m0->m_pkthdr.csum_data);
-       }
-       ipcse = offset + iphl - 1;
-
-       cmd = WTX_CMD_DEXT | WTX_DTYP_D;
-       cmdlen = WTX_CMD_DEXT | WTX_DTYP_C | WTX_CMD_IDE;
-       seg = 0;
-       fields = 0;
-
-       if ((m0->m_pkthdr.csum_flags & (M_CSUM_TSOv4 | M_CSUM_TSOv6)) != 0) {
-               int hlen = offset + iphl;
-               bool v4 = (m0->m_pkthdr.csum_flags & M_CSUM_TSOv4) != 0;
-
-               if (__predict_false(m0->m_len <
-                                   (hlen + sizeof(struct tcphdr)))) {
-                       /*
-                        * TCP/IP headers are not in the first mbuf; we need
-                        * to do this the slow and painful way.  Let's just
-                        * hope this doesn't happen very often.
-                        */
-                       struct tcphdr th;
-
-                       WM_EVCNT_INCR(&sc->sc_ev_txtsopain);
-
-                       m_copydata(m0, hlen, sizeof(th), &th);
-                       if (v4) {
-                               struct ip ip;
-
-                               m_copydata(m0, offset, sizeof(ip), &ip);
-                               ip.ip_len = 0;
-                               m_copyback(m0,
-                                   offset + offsetof(struct ip, ip_len),
-                                   sizeof(ip.ip_len), &ip.ip_len);
-                               th.th_sum = in_cksum_phdr(ip.ip_src.s_addr,
-                                   ip.ip_dst.s_addr, htons(IPPROTO_TCP));
-                       } else {
-                               struct ip6_hdr ip6;
-
-                               m_copydata(m0, offset, sizeof(ip6), &ip6);
-                               ip6.ip6_plen = 0;
-                               m_copyback(m0,
-                                   offset + offsetof(struct ip6_hdr, ip6_plen),
-                                   sizeof(ip6.ip6_plen), &ip6.ip6_plen);
-                               th.th_sum = in6_cksum_phdr(&ip6.ip6_src,
-                                   &ip6.ip6_dst, 0, htonl(IPPROTO_TCP));
-                       }
-                       m_copyback(m0, hlen + offsetof(struct tcphdr, th_sum),
-                           sizeof(th.th_sum), &th.th_sum);
-
-                       hlen += th.th_off << 2;
-               } else {
-                       /*
-                        * TCP/IP headers are in the first mbuf; we can do
-                        * this the easy way.
-                        */
-                       struct tcphdr *th;
-
-                       if (v4) {
-                               struct ip *ip =
-                                   (void *)(mtod(m0, char *) + offset);
-                               th = (void *)(mtod(m0, char *) + hlen);
-
-                               ip->ip_len = 0;
-                               th->th_sum = in_cksum_phdr(ip->ip_src.s_addr,
-                                   ip->ip_dst.s_addr, htons(IPPROTO_TCP));
-                       } else {
-                               struct ip6_hdr *ip6 =
-                                   (void *)(mtod(m0, char *) + offset);
-                               th = (void *)(mtod(m0, char *) + hlen);
-
-                               ip6->ip6_plen = 0;
-                               th->th_sum = in6_cksum_phdr(&ip6->ip6_src,
-                                   &ip6->ip6_dst, 0, htonl(IPPROTO_TCP));
-                       }
-                       hlen += th->th_off << 2;
-               }
-
-               if (v4) {
-                       WM_EVCNT_INCR(&sc->sc_ev_txtso);
-                       cmdlen |= WTX_TCPIP_CMD_IP;
-               } else {
-                       WM_EVCNT_INCR(&sc->sc_ev_txtso6);
-                       ipcse = 0;
-               }
-               cmd |= WTX_TCPIP_CMD_TSE;
-               cmdlen |= WTX_TCPIP_CMD_TSE |
-                   WTX_TCPIP_CMD_TCP | (m0->m_pkthdr.len - hlen);
-               seg = WTX_TCPIP_SEG_HDRLEN(hlen) |
-                   WTX_TCPIP_SEG_MSS(m0->m_pkthdr.segsz);
-       }
-
-       /*
-        * NOTE: Even if we're not using the IP or TCP/UDP checksum
-        * offload feature, if we load the context descriptor, we
-        * MUST provide valid values for IPCSS and TUCSS fields.
-        */
-
-       ipcs = WTX_TCPIP_IPCSS(offset) |
-           WTX_TCPIP_IPCSO(offset + offsetof(struct ip, ip_sum)) |
-           WTX_TCPIP_IPCSE(ipcse);
-       if (m0->m_pkthdr.csum_flags & (M_CSUM_IPv4|M_CSUM_TSOv4)) {
-               WM_EVCNT_INCR(&sc->sc_ev_txipsum);
-               fields |= WTX_IXSM;
-       }
-
-       offset += iphl;
-
-       if (m0->m_pkthdr.csum_flags &
-           (M_CSUM_TCPv4|M_CSUM_UDPv4|M_CSUM_TSOv4)) {
-               WM_EVCNT_INCR(&sc->sc_ev_txtusum);
-               fields |= WTX_TXSM;
-               tucs = WTX_TCPIP_TUCSS(offset) |
-                   WTX_TCPIP_TUCSO(offset +
-                   M_CSUM_DATA_IPv4_OFFSET(m0->m_pkthdr.csum_data)) |
-                   WTX_TCPIP_TUCSE(0) /* rest of packet */;
-       } else if ((m0->m_pkthdr.csum_flags &
-           (M_CSUM_TCPv6|M_CSUM_UDPv6|M_CSUM_TSOv6)) != 0) {
-               WM_EVCNT_INCR(&sc->sc_ev_txtusum6);
-               fields |= WTX_TXSM;
-               tucs = WTX_TCPIP_TUCSS(offset) |
-                   WTX_TCPIP_TUCSO(offset +
-                   M_CSUM_DATA_IPv6_OFFSET(m0->m_pkthdr.csum_data)) |
-                   WTX_TCPIP_TUCSE(0) /* rest of packet */;
-       } else {
-               /* Just initialize it to a valid TCP context. */



Home | Main Index | Thread Index | Old Index