Deleted Added
sdiff udiff text old ( 172105 ) new ( 172109 )
full compact
1/**************************************************************************
2
3Copyright (c) 2007, Chelsio Inc.
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8

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

23INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26POSSIBILITY OF SUCH DAMAGE.
27
28***************************************************************************/
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/cxgb/cxgb_main.c 172109 2007-09-10 00:59:51Z kmacy $");
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/kernel.h>
36#include <sys/bus.h>
37#include <sys/module.h>
38#include <sys/pciio.h>
39#include <sys/conf.h>

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

382}
383
384static int
385cxgb_controller_attach(device_t dev)
386{
387 device_t child;
388 const struct adapter_info *ai;
389 struct adapter *sc;
390 int i, error = 0;
391 uint32_t vers;
392 int port_qsets = 1;
393#ifdef MSI_SUPPORTED
394 int msi_needed, reg;
395#endif
396 sc = device_get_softc(dev);
397 sc->dev = dev;
398 sc->msi_count = 0;
399 ai = cxgb_get_adapter_info(dev);
400
401 /*
402 * XXX not really related but a recent addition
403 */
404#ifdef MSI_SUPPORTED
405 /* find the PCIe link width and set max read request to 4KB*/
406 if (pci_find_extcap(dev, PCIY_EXPRESS, &reg) == 0) {
407 uint16_t lnk, pectl;
408 lnk = pci_read_config(dev, reg + 0x12, 2);
409 sc->link_width = (lnk >> 4) & 0x3f;
410
411 pectl = pci_read_config(dev, reg + 0x8, 2);
412 pectl = (pectl & ~0x7000) | (5 << 12);
413 pci_write_config(dev, reg + 0x8, pectl, 2);
414 }
415
416 if (sc->link_width != 0 && sc->link_width <= 4 &&
417 (ai->nports0 + ai->nports1) <= 2) {
418 device_printf(sc->dev,
419 "PCIe x%d Link, expect reduced performance\n",
420 sc->link_width);
421 }
422#endif
423 touch_bars(dev);
424 pci_enable_busmaster(dev);
425 /*
426 * Allocate the registers and make them available to the driver.
427 * The registers that we care about for NIC mode are in BAR 0
428 */
429 sc->regs_rid = PCIR_BAR(0);
430 if ((sc->regs_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,

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

1330
1331 }
1332 }
1333}
1334
1335static void
1336update_tpeeprom(struct adapter *adap)
1337{
1338#ifdef FIRMWARE_LATEST
1339 const struct firmware *tpeeprom;
1340#else
1341 struct firmware *tpeeprom;
1342#endif
1343
1344 char buf[64];
1345 uint32_t version;
1346 unsigned int major, minor;
1347 int ret, len;
1348 char rev;
1349
1350 t3_seeprom_read(adap, TP_SRAM_OFFSET, &version);
1351

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

1391 firmware_put(tpeeprom, FIRMWARE_UNLOAD);
1392
1393 return;
1394}
1395
1396static int
1397update_tpsram(struct adapter *adap)
1398{
1399#ifdef FIRMWARE_LATEST
1400 const struct firmware *tpsram;
1401#else
1402 struct firmware *tpsram;
1403#endif
1404 char buf[64];
1405 int ret;
1406 char rev;
1407
1408 rev = t3rev2char(adap);
1409 if (!rev)
1410 return 0;
1411

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

1835}
1836
1837static int
1838cxgb_start_tx(struct ifnet *ifp, uint32_t txmax)
1839{
1840 struct sge_qset *qs;
1841 struct sge_txq *txq;
1842 struct port_info *p = ifp->if_softc;
1843 struct mbuf *m = NULL;
1844 int err, in_use_init, free;
1845
1846 if (!p->link_config.link_ok)
1847 return (ENXIO);
1848
1849 if (IFQ_DRV_IS_EMPTY(&ifp->if_snd))
1850 return (ENOBUFS);
1851

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

1864 free = 0;
1865 IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
1866 if (m == NULL)
1867 break;
1868 /*
1869 * Convert chain to M_IOVEC
1870 */
1871 KASSERT((m->m_flags & M_IOVEC) == 0, ("IOVEC set too early"));
1872#ifdef notyet
1873 m0 = m;
1874 if (collapse_mbufs && m->m_pkthdr.len > MCLBYTES &&
1875 m_collapse(m, TX_MAX_SEGS, &m0) == EFBIG) {
1876 if ((m0 = m_defrag(m, M_NOWAIT)) != NULL) {
1877 m = m0;
1878 m_collapse(m, TX_MAX_SEGS, &m0);
1879 } else
1880 break;
1881 }
1882 m = m0;
1883#endif
1884 if ((err = t3_encap(p, &m, &free)) != 0)
1885 break;
1886 BPF_MTAP(ifp, m);
1887 if (free)
1888 m_freem(m);
1889 }
1890 txq->flags &= ~TXQ_TRANSMITTING;
1891 mtx_unlock(&txq->lock);

--- 741 unchanged lines hidden ---