cxgb_main.c (fc5a2e51fb49ec3cbe8f670d6c1000abecf6df27) | cxgb_main.c (8090c9f504c0c19831713ab2392d0993a5fc5b36) |
---|---|
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 --- 30 unchanged lines hidden (view full) --- 39#include <sys/conf.h> 40#include <machine/bus.h> 41#include <machine/resource.h> 42#include <sys/bus_dma.h> 43#include <sys/rman.h> 44#include <sys/ioccom.h> 45#include <sys/mbuf.h> 46#include <sys/linker.h> | 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 --- 30 unchanged lines hidden (view full) --- 39#include <sys/conf.h> 40#include <machine/bus.h> 41#include <machine/resource.h> 42#include <sys/bus_dma.h> 43#include <sys/rman.h> 44#include <sys/ioccom.h> 45#include <sys/mbuf.h> 46#include <sys/linker.h> |
47#include <sys/syslog.h> | |
48#include <sys/firmware.h> 49#include <sys/socket.h> 50#include <sys/sockio.h> 51#include <sys/smp.h> 52#include <sys/sysctl.h> | 47#include <sys/firmware.h> 48#include <sys/socket.h> 49#include <sys/sockio.h> 50#include <sys/smp.h> 51#include <sys/sysctl.h> |
52#include <sys/syslog.h> |
|
53#include <sys/queue.h> 54#include <sys/taskqueue.h> | 53#include <sys/queue.h> 54#include <sys/taskqueue.h> |
55#include <sys/proc.h> |
|
55 56#include <net/bpf.h> 57#include <net/ethernet.h> 58#include <net/if.h> 59#include <net/if_arp.h> 60#include <net/if_dl.h> 61#include <net/if_media.h> 62#include <net/if_types.h> --- 5 unchanged lines hidden (view full) --- 68#include <netinet/ip.h> 69#include <netinet/tcp.h> 70#include <netinet/udp.h> 71 72#include <dev/pci/pcireg.h> 73#include <dev/pci/pcivar.h> 74#include <dev/pci/pci_private.h> 75 | 56 57#include <net/bpf.h> 58#include <net/ethernet.h> 59#include <net/if.h> 60#include <net/if_arp.h> 61#include <net/if_dl.h> 62#include <net/if_media.h> 63#include <net/if_types.h> --- 5 unchanged lines hidden (view full) --- 69#include <netinet/ip.h> 70#include <netinet/tcp.h> 71#include <netinet/udp.h> 72 73#include <dev/pci/pcireg.h> 74#include <dev/pci/pcivar.h> 75#include <dev/pci/pci_private.h> 76 |
76 77#include <vm/vm.h> 78#include <vm/vm_page.h> 79#include <vm/vm_map.h> 80 | |
81#ifdef CONFIG_DEFINED 82#include <cxgb_include.h> | 77#ifdef CONFIG_DEFINED 78#include <cxgb_include.h> |
83#include <sys/mvec.h> | |
84#else 85#include <dev/cxgb/cxgb_include.h> | 79#else 80#include <dev/cxgb/cxgb_include.h> |
86#include <dev/cxgb/sys/mvec.h> | |
87#endif 88 89#ifdef PRIV_SUPPORTED 90#include <sys/priv.h> 91#endif 92 | 81#endif 82 83#ifdef PRIV_SUPPORTED 84#include <sys/priv.h> 85#endif 86 |
87#include <machine/intr_machdep.h> 88 |
|
93static int cxgb_setup_msix(adapter_t *, int); 94static void cxgb_teardown_msix(adapter_t *); 95static void cxgb_init(void *); 96static void cxgb_init_locked(struct port_info *); 97static void cxgb_stop_locked(struct port_info *); 98static void cxgb_set_rxmode(struct port_info *); 99static int cxgb_ioctl(struct ifnet *, unsigned long, caddr_t); | 89static int cxgb_setup_msix(adapter_t *, int); 90static void cxgb_teardown_msix(adapter_t *); 91static void cxgb_init(void *); 92static void cxgb_init_locked(struct port_info *); 93static void cxgb_stop_locked(struct port_info *); 94static void cxgb_set_rxmode(struct port_info *); 95static int cxgb_ioctl(struct ifnet *, unsigned long, caddr_t); |
100static void cxgb_start(struct ifnet *); 101static void cxgb_start_proc(void *, int ncount); | |
102static int cxgb_media_change(struct ifnet *); 103static void cxgb_media_status(struct ifnet *, struct ifmediareq *); 104static int setup_sge_qsets(adapter_t *); 105static void cxgb_async_intr(void *); 106static void cxgb_ext_intr_handler(void *, int); 107static void cxgb_tick_handler(void *, int); 108static void cxgb_down_locked(struct adapter *sc); 109static void cxgb_tick(void *); 110static void setup_rss(adapter_t *sc); 111 | 96static int cxgb_media_change(struct ifnet *); 97static void cxgb_media_status(struct ifnet *, struct ifmediareq *); 98static int setup_sge_qsets(adapter_t *); 99static void cxgb_async_intr(void *); 100static void cxgb_ext_intr_handler(void *, int); 101static void cxgb_tick_handler(void *, int); 102static void cxgb_down_locked(struct adapter *sc); 103static void cxgb_tick(void *); 104static void setup_rss(adapter_t *sc); 105 |
106#ifndef IFNET_MULTIQUEUE 107static void cxgb_start_proc(void *, int ncount); 108#endif 109 |
|
112/* Attachment glue for the PCI controller end of the device. Each port of 113 * the device is attached separately, as defined later. 114 */ 115static int cxgb_controller_probe(device_t); 116static int cxgb_controller_attach(device_t); 117static int cxgb_controller_detach(device_t); 118static void cxgb_free(struct adapter *); 119static __inline void reg_block_dump(struct adapter *ap, uint8_t *buf, unsigned int start, 120 unsigned int end); 121static void cxgb_get_regs(adapter_t *sc, struct ifconf_regs *regs, uint8_t *buf); 122static int cxgb_get_regs_len(void); 123static int offload_open(struct port_info *pi); 124static void touch_bars(device_t dev); | 110/* Attachment glue for the PCI controller end of the device. Each port of 111 * the device is attached separately, as defined later. 112 */ 113static int cxgb_controller_probe(device_t); 114static int cxgb_controller_attach(device_t); 115static int cxgb_controller_detach(device_t); 116static void cxgb_free(struct adapter *); 117static __inline void reg_block_dump(struct adapter *ap, uint8_t *buf, unsigned int start, 118 unsigned int end); 119static void cxgb_get_regs(adapter_t *sc, struct ifconf_regs *regs, uint8_t *buf); 120static int cxgb_get_regs_len(void); 121static int offload_open(struct port_info *pi); 122static void touch_bars(device_t dev); |
125 126#ifdef notyet | |
127static int offload_close(struct t3cdev *tdev); | 123static int offload_close(struct t3cdev *tdev); |
128#endif | |
129 | 124 |
130 | |
131static device_method_t cxgb_controller_methods[] = { 132 DEVMETHOD(device_probe, cxgb_controller_probe), 133 DEVMETHOD(device_attach, cxgb_controller_attach), 134 DEVMETHOD(device_detach, cxgb_controller_detach), 135 136 /* bus interface */ 137 DEVMETHOD(bus_print_child, bus_generic_print_child), 138 DEVMETHOD(bus_driver_added, bus_generic_driver_added), --- 44 unchanged lines hidden (view full) --- 183 .d_name = "cxgb", 184}; 185 186static devclass_t cxgb_port_devclass; 187DRIVER_MODULE(cxgb, cxgbc, cxgb_port_driver, cxgb_port_devclass, 0, 0); 188 189#define SGE_MSIX_COUNT (SGE_QSETS + 1) 190 | 125static device_method_t cxgb_controller_methods[] = { 126 DEVMETHOD(device_probe, cxgb_controller_probe), 127 DEVMETHOD(device_attach, cxgb_controller_attach), 128 DEVMETHOD(device_detach, cxgb_controller_detach), 129 130 /* bus interface */ 131 DEVMETHOD(bus_print_child, bus_generic_print_child), 132 DEVMETHOD(bus_driver_added, bus_generic_driver_added), --- 44 unchanged lines hidden (view full) --- 177 .d_name = "cxgb", 178}; 179 180static devclass_t cxgb_port_devclass; 181DRIVER_MODULE(cxgb, cxgbc, cxgb_port_driver, cxgb_port_devclass, 0, 0); 182 183#define SGE_MSIX_COUNT (SGE_QSETS + 1) 184 |
191extern int collapse_mbufs; | |
192/* 193 * The driver uses the best interrupt scheme available on a platform in the 194 * order MSI-X, MSI, legacy pin interrupts. This parameter determines which 195 * of these schemes the driver may consider as follows: 196 * 197 * msi = 2: choose from among all three options 198 * msi = 1 : only consider MSI and pin interrupts 199 * msi = 0: force pin interrupts --- 13 unchanged lines hidden (view full) --- 213TUNABLE_INT("hw.cxgb.ofld_disable", &ofld_disable); 214SYSCTL_UINT(_hw_cxgb, OID_AUTO, ofld_disable, CTLFLAG_RDTUN, &ofld_disable, 0, 215 "disable ULP offload"); 216 217/* 218 * The driver uses an auto-queue algorithm by default. 219 * To disable it and force a single queue-set per port, use singleq = 1. 220 */ | 185/* 186 * The driver uses the best interrupt scheme available on a platform in the 187 * order MSI-X, MSI, legacy pin interrupts. This parameter determines which 188 * of these schemes the driver may consider as follows: 189 * 190 * msi = 2: choose from among all three options 191 * msi = 1 : only consider MSI and pin interrupts 192 * msi = 0: force pin interrupts --- 13 unchanged lines hidden (view full) --- 206TUNABLE_INT("hw.cxgb.ofld_disable", &ofld_disable); 207SYSCTL_UINT(_hw_cxgb, OID_AUTO, ofld_disable, CTLFLAG_RDTUN, &ofld_disable, 0, 208 "disable ULP offload"); 209 210/* 211 * The driver uses an auto-queue algorithm by default. 212 * To disable it and force a single queue-set per port, use singleq = 1. 213 */ |
221static int singleq = 1; | 214static int singleq = 0; |
222TUNABLE_INT("hw.cxgb.singleq", &singleq); 223SYSCTL_UINT(_hw_cxgb, OID_AUTO, singleq, CTLFLAG_RDTUN, &singleq, 0, 224 "use a single queue-set per port"); 225 | 215TUNABLE_INT("hw.cxgb.singleq", &singleq); 216SYSCTL_UINT(_hw_cxgb, OID_AUTO, singleq, CTLFLAG_RDTUN, &singleq, 0, 217 "use a single queue-set per port"); 218 |
219#ifndef IFNET_MULTIQUEUE 220int cxgb_txq_buf_ring_size = 0; 221#endif 222 |
|
226enum { 227 MAX_TXQ_ENTRIES = 16384, 228 MAX_CTRL_TXQ_ENTRIES = 1024, 229 MAX_RSPQ_ENTRIES = 16384, 230 MAX_RX_BUFFERS = 16384, 231 MAX_RX_JUMBO_BUFFERS = 16384, 232 MIN_TXQ_ENTRIES = 4, 233 MIN_CTRL_TXQ_ENTRIES = 4, --- 42 unchanged lines hidden (view full) --- 276 {PCI_VENDOR_ID_CHELSIO, 0x0026, 2, "T310X"}, 277 {PCI_VENDOR_ID_CHELSIO, 0x0030, 2, "T3B10"}, 278 {PCI_VENDOR_ID_CHELSIO, 0x0031, 3, "T3B20"}, 279 {PCI_VENDOR_ID_CHELSIO, 0x0032, 1, "T3B02"}, 280 {PCI_VENDOR_ID_CHELSIO, 0x0033, 4, "T3B04"}, 281 {0, 0, 0, NULL} 282}; 283 | 223enum { 224 MAX_TXQ_ENTRIES = 16384, 225 MAX_CTRL_TXQ_ENTRIES = 1024, 226 MAX_RSPQ_ENTRIES = 16384, 227 MAX_RX_BUFFERS = 16384, 228 MAX_RX_JUMBO_BUFFERS = 16384, 229 MIN_TXQ_ENTRIES = 4, 230 MIN_CTRL_TXQ_ENTRIES = 4, --- 42 unchanged lines hidden (view full) --- 273 {PCI_VENDOR_ID_CHELSIO, 0x0026, 2, "T310X"}, 274 {PCI_VENDOR_ID_CHELSIO, 0x0030, 2, "T3B10"}, 275 {PCI_VENDOR_ID_CHELSIO, 0x0031, 3, "T3B20"}, 276 {PCI_VENDOR_ID_CHELSIO, 0x0032, 1, "T3B02"}, 277 {PCI_VENDOR_ID_CHELSIO, 0x0033, 4, "T3B04"}, 278 {0, 0, 0, NULL} 279}; 280 |
284 | |
285static int set_eeprom(struct port_info *pi, const uint8_t *data, int len, int offset); 286 | 281static int set_eeprom(struct port_info *pi, const uint8_t *data, int len, int offset); 282 |
287static inline char | 283static __inline void 284check_pkt_coalesce(struct sge_qset *qs) 285{ 286 struct adapter *sc; 287 struct sge_txq *txq; 288 289 txq = &qs->txq[TXQ_ETH]; 290 sc = qs->port->adapter; 291 292 if (sc->tunq_fill[qs->idx] && (txq->in_use < (txq->size - (txq->size>>2)))) 293 sc->tunq_fill[qs->idx] = 0; 294 else if (!sc->tunq_fill[qs->idx] && (txq->in_use > (txq->size - (txq->size>>2)))) 295 sc->tunq_fill[qs->idx] = 1; 296} 297 298static __inline char |
288t3rev2char(struct adapter *adapter) 289{ 290 char rev = 'z'; 291 292 switch(adapter->params.rev) { 293 case T3_REV_A: 294 rev = 'a'; 295 break; --- 281 unchanged lines hidden (view full) --- 577 pi = &sc->port[i]; 578 pi->adapter = sc; 579 pi->nqsets = port_qsets; 580 pi->first_qset = i*port_qsets; 581 pi->port_id = i; 582 pi->tx_chan = i >= ai->nports0; 583 pi->txpkt_intf = pi->tx_chan ? 2 * (i - ai->nports0) + 1 : 2 * i; 584 sc->rxpkt_map[pi->txpkt_intf] = i; | 299t3rev2char(struct adapter *adapter) 300{ 301 char rev = 'z'; 302 303 switch(adapter->params.rev) { 304 case T3_REV_A: 305 rev = 'a'; 306 break; --- 281 unchanged lines hidden (view full) --- 588 pi = &sc->port[i]; 589 pi->adapter = sc; 590 pi->nqsets = port_qsets; 591 pi->first_qset = i*port_qsets; 592 pi->port_id = i; 593 pi->tx_chan = i >= ai->nports0; 594 pi->txpkt_intf = pi->tx_chan ? 2 * (i - ai->nports0) + 1 : 2 * i; 595 sc->rxpkt_map[pi->txpkt_intf] = i; |
596 sc->port[i].tx_chan = i >= ai->nports0; |
|
585 sc->portdev[i] = child; 586 device_set_softc(child, pi); 587 } 588 if ((error = bus_generic_attach(dev)) != 0) 589 goto out; 590 591 /* 592 * XXX need to poll for link status --- 13 unchanged lines hidden (view full) --- 606 error = t3_get_fw_version(sc, &vers); 607 if (error) 608 goto out; 609 610 snprintf(&sc->fw_version[0], sizeof(sc->fw_version), "%d.%d.%d", 611 G_FW_VERSION_MAJOR(vers), G_FW_VERSION_MINOR(vers), 612 G_FW_VERSION_MICRO(vers)); 613 | 597 sc->portdev[i] = child; 598 device_set_softc(child, pi); 599 } 600 if ((error = bus_generic_attach(dev)) != 0) 601 goto out; 602 603 /* 604 * XXX need to poll for link status --- 13 unchanged lines hidden (view full) --- 618 error = t3_get_fw_version(sc, &vers); 619 if (error) 620 goto out; 621 622 snprintf(&sc->fw_version[0], sizeof(sc->fw_version), "%d.%d.%d", 623 G_FW_VERSION_MAJOR(vers), G_FW_VERSION_MINOR(vers), 624 G_FW_VERSION_MICRO(vers)); 625 |
614 t3_add_sysctls(sc); | 626 t3_add_attach_sysctls(sc); |
615out: 616 if (error) 617 cxgb_free(sc); 618 619 return (error); 620} 621 622static int --- 8 unchanged lines hidden (view full) --- 631 return (0); 632} 633 634static void 635cxgb_free(struct adapter *sc) 636{ 637 int i; 638 | 627out: 628 if (error) 629 cxgb_free(sc); 630 631 return (error); 632} 633 634static int --- 8 unchanged lines hidden (view full) --- 643 return (0); 644} 645 646static void 647cxgb_free(struct adapter *sc) 648{ 649 int i; 650 |
651 652#ifdef IFNET_MULTIQUEUE 653 cxgb_pcpu_shutdown_threads(sc); 654#endif |
|
639 ADAPTER_LOCK(sc); | 655 ADAPTER_LOCK(sc); |
640 /* 641 * drops the lock 642 */ | 656/* 657 * drops the lock 658 */ |
643 cxgb_down_locked(sc); 644 645#ifdef MSI_SUPPORTED 646 if (sc->flags & (USING_MSI | USING_MSIX)) { 647 device_printf(sc->dev, "releasing msi message(s)\n"); 648 pci_release_msi(sc->dev); 649 } else { 650 device_printf(sc->dev, "no msi message to release\n"); --- 8 unchanged lines hidden (view full) --- 659 taskqueue_drain(sc->tq, &sc->ext_intr_task); 660 taskqueue_drain(sc->tq, &sc->tick_task); 661 } 662 t3_sge_deinit_sw(sc); 663 /* 664 * Wait for last callout 665 */ 666 | 659 cxgb_down_locked(sc); 660 661#ifdef MSI_SUPPORTED 662 if (sc->flags & (USING_MSI | USING_MSIX)) { 663 device_printf(sc->dev, "releasing msi message(s)\n"); 664 pci_release_msi(sc->dev); 665 } else { 666 device_printf(sc->dev, "no msi message to release\n"); --- 8 unchanged lines hidden (view full) --- 675 taskqueue_drain(sc->tq, &sc->ext_intr_task); 676 taskqueue_drain(sc->tq, &sc->tick_task); 677 } 678 t3_sge_deinit_sw(sc); 679 /* 680 * Wait for last callout 681 */ 682 |
667 tsleep(&sc, 0, "cxgb unload", 3*hz); | 683 DELAY(hz*100); |
668 669 for (i = 0; i < (sc)->params.nports; ++i) { 670 if (sc->portdev[i] != NULL) 671 device_delete_child(sc->dev, sc->portdev[i]); 672 } 673 674 bus_generic_detach(sc->dev); 675 if (sc->tq != NULL) 676 taskqueue_free(sc->tq); | 684 685 for (i = 0; i < (sc)->params.nports; ++i) { 686 if (sc->portdev[i] != NULL) 687 device_delete_child(sc->dev, sc->portdev[i]); 688 } 689 690 bus_generic_detach(sc->dev); 691 if (sc->tq != NULL) 692 taskqueue_free(sc->tq); |
677#ifdef notyet | |
678 if (is_offload(sc)) { 679 cxgb_adapter_unofld(sc); 680 if (isset(&sc->open_device_map, OFFLOAD_DEVMAP_BIT)) 681 offload_close(&sc->tdev); | 693 if (is_offload(sc)) { 694 cxgb_adapter_unofld(sc); 695 if (isset(&sc->open_device_map, OFFLOAD_DEVMAP_BIT)) 696 offload_close(&sc->tdev); |
682 } 683#endif 684 | 697 else 698 printf("cxgb_free: DEVMAP_BIT not set\n"); 699 } else 700 printf("not offloading set\n"); 701#ifndef IFNET_MULTIQUEUE |
685 t3_free_sge_resources(sc); | 702 t3_free_sge_resources(sc); |
703#endif |
|
686 free(sc->filters, M_DEVBUF); 687 t3_sge_free(sc); 688 689 cxgb_offload_exit(); 690 691 if (sc->regs_res != NULL) 692 bus_release_resource(sc->dev, SYS_RES_MEMORY, sc->regs_rid, 693 sc->regs_res); 694 695 MTX_DESTROY(&sc->mdio_lock); 696 MTX_DESTROY(&sc->sge.reg_lock); 697 MTX_DESTROY(&sc->elmer_lock); 698 ADAPTER_LOCK_DEINIT(sc); | 704 free(sc->filters, M_DEVBUF); 705 t3_sge_free(sc); 706 707 cxgb_offload_exit(); 708 709 if (sc->regs_res != NULL) 710 bus_release_resource(sc->dev, SYS_RES_MEMORY, sc->regs_rid, 711 sc->regs_res); 712 713 MTX_DESTROY(&sc->mdio_lock); 714 MTX_DESTROY(&sc->sge.reg_lock); 715 MTX_DESTROY(&sc->elmer_lock); 716 ADAPTER_LOCK_DEINIT(sc); |
699 700 return; | |
701} 702 703/** 704 * setup_sge_qsets - configure SGE Tx/Rx/response queues 705 * @sc: the controller softc 706 * 707 * Determines how many sets of SGE queues to use and initializes them. 708 * We support multiple queue sets per port if we have MSI-X, otherwise --- 89 unchanged lines hidden (view full) --- 798 device_printf(sc->dev, "Cannot allocate " 799 "interrupt for message %d\n", rid); 800 return (EINVAL); 801 } 802 sc->msix_irq_rid[k] = rid; 803 printf("setting up interrupt for port=%d\n", 804 qs->port->port_id); 805 if (bus_setup_intr(sc->dev, sc->msix_irq_res[k], | 717} 718 719/** 720 * setup_sge_qsets - configure SGE Tx/Rx/response queues 721 * @sc: the controller softc 722 * 723 * Determines how many sets of SGE queues to use and initializes them. 724 * We support multiple queue sets per port if we have MSI-X, otherwise --- 89 unchanged lines hidden (view full) --- 814 device_printf(sc->dev, "Cannot allocate " 815 "interrupt for message %d\n", rid); 816 return (EINVAL); 817 } 818 sc->msix_irq_rid[k] = rid; 819 printf("setting up interrupt for port=%d\n", 820 qs->port->port_id); 821 if (bus_setup_intr(sc->dev, sc->msix_irq_res[k], |
806 INTR_MPSAFE|INTR_TYPE_NET, | 822 INTR_MPSAFE|INTR_TYPE_NET, |
807#ifdef INTR_FILTERS 808 NULL, 809#endif 810 t3_intr_msix, qs, &sc->msix_intr_tag[k])) { 811 device_printf(sc->dev, "Cannot set up " 812 "interrupt for message %d\n", rid); 813 return (EINVAL); 814 } | 823#ifdef INTR_FILTERS 824 NULL, 825#endif 826 t3_intr_msix, qs, &sc->msix_intr_tag[k])) { 827 device_printf(sc->dev, "Cannot set up " 828 "interrupt for message %d\n", rid); 829 return (EINVAL); 830 } |
831#ifdef IFNET_MULTIQUEUE 832 if (singleq == 0) { 833 int vector = rman_get_start(sc->msix_irq_res[k]); 834 if (bootverbose) 835 device_printf(sc->dev, "binding vector=%d to cpu=%d\n", vector, k % mp_ncpus); 836 intr_bind(vector, k % mp_ncpus); 837 } 838#endif |
|
815 } 816 } 817 | 839 } 840 } 841 |
818 | |
819 return (0); 820} 821 822static int 823cxgb_port_probe(device_t dev) 824{ 825 struct port_info *p; 826 char buf[80]; --- 60 unchanged lines hidden (view full) --- 887 * Note that there is currently no watchdog timer. 888 */ 889 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 890 ifp->if_init = cxgb_init; 891 ifp->if_softc = p; 892 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; 893 ifp->if_ioctl = cxgb_ioctl; 894 ifp->if_start = cxgb_start; | 842 return (0); 843} 844 845static int 846cxgb_port_probe(device_t dev) 847{ 848 struct port_info *p; 849 char buf[80]; --- 60 unchanged lines hidden (view full) --- 910 * Note that there is currently no watchdog timer. 911 */ 912 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 913 ifp->if_init = cxgb_init; 914 ifp->if_softc = p; 915 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; 916 ifp->if_ioctl = cxgb_ioctl; 917 ifp->if_start = cxgb_start; |
918 919#ifdef IFNET_MULTIQUEUE 920 ifp->if_flags |= IFF_MULTIQ; 921 ifp->if_mq_start = cxgb_pcpu_start; 922#endif 923 |
|
895 ifp->if_timer = 0; /* Disable ifnet watchdog */ 896 ifp->if_watchdog = NULL; 897 898 ifp->if_snd.ifq_drv_maxlen = TX_ETH_Q_SIZE; 899 IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); 900 IFQ_SET_READY(&ifp->if_snd); 901 902 ifp->if_hwassist = ifp->if_capabilities = ifp->if_capenable = 0; --- 57 unchanged lines hidden (view full) --- 960 /* Create a port for handling TX without starvation */ 961 p->tq = taskqueue_create(p->taskqbuf, M_NOWAIT, 962 taskqueue_thread_enqueue, &p->tq); 963#else 964 /* Create a port for handling TX without starvation */ 965 p->tq = taskqueue_create_fast(p->taskqbuf, M_NOWAIT, 966 taskqueue_thread_enqueue, &p->tq); 967#endif | 924 ifp->if_timer = 0; /* Disable ifnet watchdog */ 925 ifp->if_watchdog = NULL; 926 927 ifp->if_snd.ifq_drv_maxlen = TX_ETH_Q_SIZE; 928 IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); 929 IFQ_SET_READY(&ifp->if_snd); 930 931 ifp->if_hwassist = ifp->if_capabilities = ifp->if_capenable = 0; --- 57 unchanged lines hidden (view full) --- 989 /* Create a port for handling TX without starvation */ 990 p->tq = taskqueue_create(p->taskqbuf, M_NOWAIT, 991 taskqueue_thread_enqueue, &p->tq); 992#else 993 /* Create a port for handling TX without starvation */ 994 p->tq = taskqueue_create_fast(p->taskqbuf, M_NOWAIT, 995 taskqueue_thread_enqueue, &p->tq); 996#endif |
968 | 997#ifndef IFNET_MULTIQUEUE |
969 if (p->tq == NULL) { 970 device_printf(dev, "failed to allocate port task queue\n"); 971 return (ENOMEM); 972 } 973 taskqueue_start_threads(&p->tq, 1, PI_NET, "%s taskq", 974 device_get_nameunit(dev)); 975 976 TASK_INIT(&p->start_task, 0, cxgb_start_proc, ifp); | 998 if (p->tq == NULL) { 999 device_printf(dev, "failed to allocate port task queue\n"); 1000 return (ENOMEM); 1001 } 1002 taskqueue_start_threads(&p->tq, 1, PI_NET, "%s taskq", 1003 device_get_nameunit(dev)); 1004 1005 TASK_INIT(&p->start_task, 0, cxgb_start_proc, ifp); |
977 | 1006#endif |
978 t3_sge_init_port(p); 979 980 return (0); 981} 982 983static int 984cxgb_port_detach(device_t dev) 985{ --- 8 unchanged lines hidden (view full) --- 994 995 if (p->tq != NULL) { 996 taskqueue_drain(p->tq, &p->start_task); 997 taskqueue_free(p->tq); 998 p->tq = NULL; 999 } 1000 1001 ether_ifdetach(p->ifp); | 1007 t3_sge_init_port(p); 1008 1009 return (0); 1010} 1011 1012static int 1013cxgb_port_detach(device_t dev) 1014{ --- 8 unchanged lines hidden (view full) --- 1023 1024 if (p->tq != NULL) { 1025 taskqueue_drain(p->tq, &p->start_task); 1026 taskqueue_free(p->tq); 1027 p->tq = NULL; 1028 } 1029 1030 ether_ifdetach(p->ifp); |
1031 printf("waiting for callout to stop ..."); 1032 DELAY(1000000); 1033 printf("done\n"); |
|
1002 /* 1003 * the lock may be acquired in ifdetach 1004 */ 1005 PORT_LOCK_DEINIT(p); 1006 if_free(p->ifp); 1007 1008 if (p->port_cdev != NULL) 1009 destroy_dev(p->port_cdev); --- 232 unchanged lines hidden (view full) --- 1242 * Sends an mbuf to an offload queue driver 1243 * after dealing with any active network taps. 1244 */ 1245static inline int 1246offload_tx(struct t3cdev *tdev, struct mbuf *m) 1247{ 1248 int ret; 1249 | 1034 /* 1035 * the lock may be acquired in ifdetach 1036 */ 1037 PORT_LOCK_DEINIT(p); 1038 if_free(p->ifp); 1039 1040 if (p->port_cdev != NULL) 1041 destroy_dev(p->port_cdev); --- 232 unchanged lines hidden (view full) --- 1274 * Sends an mbuf to an offload queue driver 1275 * after dealing with any active network taps. 1276 */ 1277static inline int 1278offload_tx(struct t3cdev *tdev, struct mbuf *m) 1279{ 1280 int ret; 1281 |
1250 critical_enter(); | |
1251 ret = t3_offload_tx(tdev, m); | 1282 ret = t3_offload_tx(tdev, m); |
1252 critical_exit(); | |
1253 return (ret); 1254} 1255 1256static int 1257write_smt_entry(struct adapter *adapter, int idx) 1258{ 1259 struct port_info *pi = &adapter->port[idx]; 1260 struct cpl_smt_write_req *req; 1261 struct mbuf *m; 1262 1263 if ((m = m_gethdr(M_NOWAIT, MT_DATA)) == NULL) 1264 return (ENOMEM); 1265 1266 req = mtod(m, struct cpl_smt_write_req *); | 1283 return (ret); 1284} 1285 1286static int 1287write_smt_entry(struct adapter *adapter, int idx) 1288{ 1289 struct port_info *pi = &adapter->port[idx]; 1290 struct cpl_smt_write_req *req; 1291 struct mbuf *m; 1292 1293 if ((m = m_gethdr(M_NOWAIT, MT_DATA)) == NULL) 1294 return (ENOMEM); 1295 1296 req = mtod(m, struct cpl_smt_write_req *); |
1297 m->m_pkthdr.len = m->m_len = sizeof(struct cpl_smt_write_req); 1298 |
|
1267 req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); 1268 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SMT_WRITE_REQ, idx)); 1269 req->mtu_idx = NMTUS - 1; /* should be 0 but there's a T3 bug */ 1270 req->iff = idx; 1271 memset(req->src_mac1, 0, sizeof(req->src_mac1)); 1272 memcpy(req->src_mac0, pi->hw_addr, ETHER_ADDR_LEN); 1273 1274 m_set_priority(m, 1); --- 45 unchanged lines hidden (view full) --- 1320 } 1321} 1322 1323static void 1324bind_qsets(adapter_t *sc) 1325{ 1326 int i, j; 1327 | 1299 req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); 1300 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SMT_WRITE_REQ, idx)); 1301 req->mtu_idx = NMTUS - 1; /* should be 0 but there's a T3 bug */ 1302 req->iff = idx; 1303 memset(req->src_mac1, 0, sizeof(req->src_mac1)); 1304 memcpy(req->src_mac0, pi->hw_addr, ETHER_ADDR_LEN); 1305 1306 m_set_priority(m, 1); --- 45 unchanged lines hidden (view full) --- 1352 } 1353} 1354 1355static void 1356bind_qsets(adapter_t *sc) 1357{ 1358 int i, j; 1359 |
1360#ifdef IFNET_MULTIQUEUE 1361 cxgb_pcpu_startup_threads(sc); 1362#endif 1363 |
|
1328 for (i = 0; i < (sc)->params.nports; ++i) { 1329 const struct port_info *pi = adap2pinfo(sc, i); 1330 1331 for (j = 0; j < pi->nqsets; ++j) { 1332 send_pktsched_cmd(sc, 1, pi->first_qset + j, -1, 1333 -1, pi->tx_chan); 1334 1335 } --- 132 unchanged lines hidden (view full) --- 1468 1469 t3_write_reg(sc, A_ULPRX_TDDP_PSZ, V_HPZ0(PAGE_SHIFT - 12)); 1470 1471 err = setup_sge_qsets(sc); 1472 if (err) 1473 goto out; 1474 1475 setup_rss(sc); | 1364 for (i = 0; i < (sc)->params.nports; ++i) { 1365 const struct port_info *pi = adap2pinfo(sc, i); 1366 1367 for (j = 0; j < pi->nqsets; ++j) { 1368 send_pktsched_cmd(sc, 1, pi->first_qset + j, -1, 1369 -1, pi->tx_chan); 1370 1371 } --- 132 unchanged lines hidden (view full) --- 1504 1505 t3_write_reg(sc, A_ULPRX_TDDP_PSZ, V_HPZ0(PAGE_SHIFT - 12)); 1506 1507 err = setup_sge_qsets(sc); 1508 if (err) 1509 goto out; 1510 1511 setup_rss(sc); |
1512 t3_add_configured_sysctls(sc); |
|
1476 sc->flags |= FULL_INIT_DONE; 1477 } 1478 1479 t3_intr_clear(sc); 1480 1481 /* If it's MSI or INTx, allocate a single interrupt for everything */ 1482 if ((sc->flags & USING_MSIX) == 0) { 1483 if ((sc->irq_res = bus_alloc_resource_any(sc->dev, SYS_RES_IRQ, --- 56 unchanged lines hidden (view full) --- 1540 sc->irq_res); 1541 sc->irq_res = NULL; 1542 } 1543 1544 if (sc->flags & USING_MSIX) 1545 cxgb_teardown_msix(sc); 1546 ADAPTER_UNLOCK(sc); 1547 | 1513 sc->flags |= FULL_INIT_DONE; 1514 } 1515 1516 t3_intr_clear(sc); 1517 1518 /* If it's MSI or INTx, allocate a single interrupt for everything */ 1519 if ((sc->flags & USING_MSIX) == 0) { 1520 if ((sc->irq_res = bus_alloc_resource_any(sc->dev, SYS_RES_IRQ, --- 56 unchanged lines hidden (view full) --- 1577 sc->irq_res); 1578 sc->irq_res = NULL; 1579 } 1580 1581 if (sc->flags & USING_MSIX) 1582 cxgb_teardown_msix(sc); 1583 ADAPTER_UNLOCK(sc); 1584 |
1585 callout_stop(&sc->cxgb_tick_ch); 1586 callout_stop(&sc->sge_timer_ch); |
|
1548 callout_drain(&sc->cxgb_tick_ch); 1549 callout_drain(&sc->sge_timer_ch); 1550 1551 if (sc->tq != NULL) { 1552 taskqueue_drain(sc->tq, &sc->slow_intr_task); 1553 for (i = 0; i < sc->params.nports; i++) 1554 taskqueue_drain(sc->tq, &sc->port[i].timer_reclaim_task); 1555 } | 1587 callout_drain(&sc->cxgb_tick_ch); 1588 callout_drain(&sc->sge_timer_ch); 1589 1590 if (sc->tq != NULL) { 1591 taskqueue_drain(sc->tq, &sc->slow_intr_task); 1592 for (i = 0; i < sc->params.nports; i++) 1593 taskqueue_drain(sc->tq, &sc->port[i].timer_reclaim_task); 1594 } |
1556#ifdef notyet 1557 1558 if (sc->port[i].tq != NULL) 1559#endif 1560 | |
1561} 1562 1563static int 1564offload_open(struct port_info *pi) 1565{ 1566 struct adapter *adapter = pi->adapter; | 1595} 1596 1597static int 1598offload_open(struct port_info *pi) 1599{ 1600 struct adapter *adapter = pi->adapter; |
1567 struct t3cdev *tdev = TOEDEV(pi->ifp); | 1601 struct t3cdev *tdev = &adapter->tdev; 1602#ifdef notyet 1603 T3CDEV(pi->ifp); 1604#endif |
1568 int adap_up = adapter->open_device_map & PORT_MASK; 1569 int err = 0; 1570 | 1605 int adap_up = adapter->open_device_map & PORT_MASK; 1606 int err = 0; 1607 |
1608 printf("device_map=0x%x\n", adapter->open_device_map); |
|
1571 if (atomic_cmpset_int(&adapter->open_device_map, | 1609 if (atomic_cmpset_int(&adapter->open_device_map, |
1572 (adapter->open_device_map & ~OFFLOAD_DEVMAP_BIT), 1573 (adapter->open_device_map | OFFLOAD_DEVMAP_BIT)) == 0) | 1610 (adapter->open_device_map & ~(1<<OFFLOAD_DEVMAP_BIT)), 1611 (adapter->open_device_map | (1<<OFFLOAD_DEVMAP_BIT))) == 0) |
1574 return (0); 1575 | 1612 return (0); 1613 |
1614 1615 if (!isset(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT)) 1616 printf("offload_open: DEVMAP_BIT did not get set 0x%x\n", adapter->open_device_map); |
|
1576 ADAPTER_LOCK(pi->adapter); 1577 if (!adap_up) 1578 err = cxgb_up(adapter); 1579 ADAPTER_UNLOCK(pi->adapter); 1580 if (err) 1581 return (err); 1582 1583 t3_tp_set_offload_mode(adapter, 1); | 1617 ADAPTER_LOCK(pi->adapter); 1618 if (!adap_up) 1619 err = cxgb_up(adapter); 1620 ADAPTER_UNLOCK(pi->adapter); 1621 if (err) 1622 return (err); 1623 1624 t3_tp_set_offload_mode(adapter, 1); |
1584 tdev->lldev = adapter->port[0].ifp; | 1625 tdev->lldev = pi->ifp; |
1585 err = cxgb_offload_activate(adapter); 1586 if (err) 1587 goto out; 1588 1589 init_port_mtus(adapter); 1590 t3_load_mtus(adapter, adapter->params.mtus, adapter->params.a_wnd, 1591 adapter->params.b_wnd, 1592 adapter->params.rev == 0 ? --- 7 unchanged lines hidden (view full) --- 1600 /* restore them in case the offload module has changed them */ 1601 if (err) { 1602 t3_tp_set_offload_mode(adapter, 0); 1603 clrbit(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT); 1604 cxgb_set_dummy_ops(tdev); 1605 } 1606 return (err); 1607} | 1626 err = cxgb_offload_activate(adapter); 1627 if (err) 1628 goto out; 1629 1630 init_port_mtus(adapter); 1631 t3_load_mtus(adapter, adapter->params.mtus, adapter->params.a_wnd, 1632 adapter->params.b_wnd, 1633 adapter->params.rev == 0 ? --- 7 unchanged lines hidden (view full) --- 1641 /* restore them in case the offload module has changed them */ 1642 if (err) { 1643 t3_tp_set_offload_mode(adapter, 0); 1644 clrbit(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT); 1645 cxgb_set_dummy_ops(tdev); 1646 } 1647 return (err); 1648} |
1608#ifdef notyet | 1649 |
1609static int | 1650static int |
1610offload_close(struct t3cev *tdev) | 1651offload_close(struct t3cdev *tdev) |
1611{ 1612 struct adapter *adapter = tdev2adap(tdev); 1613 | 1652{ 1653 struct adapter *adapter = tdev2adap(tdev); 1654 |
1614 if (!isset(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT)) | 1655 if (!isset(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT)) { 1656 printf("offload_close: DEVMAP_BIT not set\n"); 1657 |
1615 return (0); | 1658 return (0); |
1616 | 1659 } 1660 |
1617 /* Call back all registered clients */ 1618 cxgb_remove_clients(tdev); 1619 tdev->lldev = NULL; 1620 cxgb_set_dummy_ops(tdev); 1621 t3_tp_set_offload_mode(adapter, 0); 1622 clrbit(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT); 1623 | 1661 /* Call back all registered clients */ 1662 cxgb_remove_clients(tdev); 1663 tdev->lldev = NULL; 1664 cxgb_set_dummy_ops(tdev); 1665 t3_tp_set_offload_mode(adapter, 0); 1666 clrbit(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT); 1667 |
1668 ADAPTER_LOCK(adapter); |
|
1624 if (!adapter->open_device_map) | 1669 if (!adapter->open_device_map) |
1625 cxgb_down(adapter); 1626 | 1670 cxgb_down_locked(adapter); 1671 else 1672 ADAPTER_UNLOCK(adapter); |
1627 cxgb_offload_deactivate(adapter); 1628 return (0); 1629} | 1673 cxgb_offload_deactivate(adapter); 1674 return (0); 1675} |
1630#endif | |
1631 | 1676 |
1677 |
|
1632static void 1633cxgb_init(void *arg) 1634{ 1635 struct port_info *p = arg; 1636 1637 PORT_LOCK(p); 1638 cxgb_init_locked(p); 1639 PORT_UNLOCK(p); --- 22 unchanged lines hidden (view full) --- 1662 setbit(&p->adapter->open_device_map, p->port_id); 1663 ADAPTER_UNLOCK(p->adapter); 1664 1665 if (is_offload(sc) && !ofld_disable) { 1666 err = offload_open(p); 1667 if (err) 1668 log(LOG_WARNING, 1669 "Could not initialize offload capabilities\n"); | 1678static void 1679cxgb_init(void *arg) 1680{ 1681 struct port_info *p = arg; 1682 1683 PORT_LOCK(p); 1684 cxgb_init_locked(p); 1685 PORT_UNLOCK(p); --- 22 unchanged lines hidden (view full) --- 1708 setbit(&p->adapter->open_device_map, p->port_id); 1709 ADAPTER_UNLOCK(p->adapter); 1710 1711 if (is_offload(sc) && !ofld_disable) { 1712 err = offload_open(p); 1713 if (err) 1714 log(LOG_WARNING, 1715 "Could not initialize offload capabilities\n"); |
1716 else 1717 printf("offload opened\n"); |
|
1670 } 1671 cxgb_link_start(p); 1672 t3_link_changed(sc, p->port_id); 1673 ifp->if_baudrate = p->link_config.speed * 1000000; 1674 1675 device_printf(sc->dev, "enabling interrupts on port=%d\n", p->port_id); 1676 t3_port_intr_enable(sc, p->port_id); 1677 | 1718 } 1719 cxgb_link_start(p); 1720 t3_link_changed(sc, p->port_id); 1721 ifp->if_baudrate = p->link_config.speed * 1000000; 1722 1723 device_printf(sc->dev, "enabling interrupts on port=%d\n", p->port_id); 1724 t3_port_intr_enable(sc, p->port_id); 1725 |
1678 callout_reset(&sc->cxgb_tick_ch, sc->params.stats_update_period * hz, 1679 cxgb_tick, sc); | 1726 callout_reset(&sc->cxgb_tick_ch, hz, cxgb_tick, sc); |
1680 1681 ifp->if_drv_flags |= IFF_DRV_RUNNING; 1682 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 1683} 1684 1685static void 1686cxgb_set_rxmode(struct port_info *p) 1687{ --- 10 unchanged lines hidden (view full) --- 1698cxgb_stop_locked(struct port_info *p) 1699{ 1700 struct ifnet *ifp; 1701 1702 PORT_LOCK_ASSERT_OWNED(p); 1703 ADAPTER_LOCK_ASSERT_NOTOWNED(p->adapter); 1704 1705 ifp = p->ifp; | 1727 1728 ifp->if_drv_flags |= IFF_DRV_RUNNING; 1729 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 1730} 1731 1732static void 1733cxgb_set_rxmode(struct port_info *p) 1734{ --- 10 unchanged lines hidden (view full) --- 1745cxgb_stop_locked(struct port_info *p) 1746{ 1747 struct ifnet *ifp; 1748 1749 PORT_LOCK_ASSERT_OWNED(p); 1750 ADAPTER_LOCK_ASSERT_NOTOWNED(p->adapter); 1751 1752 ifp = p->ifp; |
1706 | |
1707 t3_port_intr_disable(p->adapter, p->port_id); 1708 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); 1709 p->phy.ops->power_down(&p->phy, 1); 1710 t3_mac_disable(&p->mac, MAC_DIRECTION_TX | MAC_DIRECTION_RX); 1711 1712 ADAPTER_LOCK(p->adapter); 1713 clrbit(&p->adapter->open_device_map, p->port_id); 1714 | 1753 t3_port_intr_disable(p->adapter, p->port_id); 1754 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); 1755 p->phy.ops->power_down(&p->phy, 1); 1756 t3_mac_disable(&p->mac, MAC_DIRECTION_TX | MAC_DIRECTION_RX); 1757 1758 ADAPTER_LOCK(p->adapter); 1759 clrbit(&p->adapter->open_device_map, p->port_id); 1760 |
1715 | |
1716 if (p->adapter->open_device_map == 0) { 1717 cxgb_down_locked(p->adapter); 1718 } else 1719 ADAPTER_UNLOCK(p->adapter); 1720 1721} 1722 1723static int --- 57 unchanged lines hidden (view full) --- 1781 } else 1782 cxgb_init_locked(p); 1783 p->if_flags = ifp->if_flags; 1784 } else if (ifp->if_drv_flags & IFF_DRV_RUNNING) 1785 cxgb_stop_locked(p); 1786 1787 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { 1788 adapter_t *sc = p->adapter; | 1761 if (p->adapter->open_device_map == 0) { 1762 cxgb_down_locked(p->adapter); 1763 } else 1764 ADAPTER_UNLOCK(p->adapter); 1765 1766} 1767 1768static int --- 57 unchanged lines hidden (view full) --- 1826 } else 1827 cxgb_init_locked(p); 1828 p->if_flags = ifp->if_flags; 1829 } else if (ifp->if_drv_flags & IFF_DRV_RUNNING) 1830 cxgb_stop_locked(p); 1831 1832 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { 1833 adapter_t *sc = p->adapter; |
1789 callout_reset(&sc->cxgb_tick_ch, 1790 sc->params.stats_update_period * hz, | 1834 callout_reset(&sc->cxgb_tick_ch, hz, |
1791 cxgb_tick, sc); 1792 } 1793 PORT_UNLOCK(p); 1794 break; 1795 case SIOCSIFMEDIA: 1796 case SIOCGIFMEDIA: 1797 error = ifmedia_ioctl(ifp, ifr, &p->media, command); 1798 break; --- 34 unchanged lines hidden (view full) --- 1833 break; 1834 default: 1835 error = ether_ioctl(ifp, command, data); 1836 break; 1837 } 1838 return (error); 1839} 1840 | 1835 cxgb_tick, sc); 1836 } 1837 PORT_UNLOCK(p); 1838 break; 1839 case SIOCSIFMEDIA: 1840 case SIOCGIFMEDIA: 1841 error = ifmedia_ioctl(ifp, ifr, &p->media, command); 1842 break; --- 34 unchanged lines hidden (view full) --- 1877 break; 1878 default: 1879 error = ether_ioctl(ifp, command, data); 1880 break; 1881 } 1882 return (error); 1883} 1884 |
1841static int 1842cxgb_start_tx(struct ifnet *ifp, uint32_t txmax) | 1885int 1886cxgb_tx_common(struct ifnet *ifp, struct sge_qset *qs, uint32_t txmax) |
1843{ | 1887{ |
1844 struct sge_qset *qs; | |
1845 struct sge_txq *txq; | 1888 struct sge_txq *txq; |
1846 struct port_info *p = ifp->if_softc; 1847 struct mbuf *m = NULL; 1848 int err, in_use_init, free; | 1889 int err, in_use_init, count; 1890 struct mbuf **m_vec; |
1849 | 1891 |
1850 if (!p->link_config.link_ok) 1851 return (ENXIO); 1852 1853 if (IFQ_DRV_IS_EMPTY(&ifp->if_snd)) 1854 return (ENOBUFS); 1855 1856 qs = &p->adapter->sge.qs[p->first_qset]; | |
1857 txq = &qs->txq[TXQ_ETH]; | 1892 txq = &qs->txq[TXQ_ETH]; |
1858 err = 0; 1859 1860 if (txq->flags & TXQ_TRANSMITTING) 1861 return (EINPROGRESS); 1862 1863 mtx_lock(&txq->lock); 1864 txq->flags |= TXQ_TRANSMITTING; | 1893 m_vec = txq->txq_m_vec; |
1865 in_use_init = txq->in_use; | 1894 in_use_init = txq->in_use; |
1895 err = 0; |
|
1866 while ((txq->in_use - in_use_init < txmax) && 1867 (txq->size > txq->in_use + TX_MAX_DESC)) { | 1896 while ((txq->in_use - in_use_init < txmax) && 1897 (txq->size > txq->in_use + TX_MAX_DESC)) { |
1868 free = 0; 1869 IFQ_DRV_DEQUEUE(&ifp->if_snd, m); 1870 if (m == NULL) | 1898 check_pkt_coalesce(qs); 1899 count = cxgb_dequeue_packet(ifp, txq, m_vec); 1900 if (count == 0) |
1871 break; | 1901 break; |
1872 /* 1873 * Convert chain to M_IOVEC 1874 */ 1875 KASSERT((m->m_flags & M_IOVEC) == 0, ("IOVEC set too early")); 1876#ifdef notyet 1877 m0 = m; 1878 if (collapse_mbufs && m->m_pkthdr.len > MCLBYTES && 1879 m_collapse(m, TX_MAX_SEGS, &m0) == EFBIG) { 1880 if ((m0 = m_defrag(m, M_NOWAIT)) != NULL) { 1881 m = m0; 1882 m_collapse(m, TX_MAX_SEGS, &m0); 1883 } else 1884 break; 1885 } 1886 m = m0; 1887#endif 1888 if ((err = t3_encap(p, &m, &free)) != 0) | 1902 ETHER_BPF_MTAP(ifp, m_vec[0]); 1903 1904 if ((err = t3_encap(qs, m_vec, count)) != 0) |
1889 break; | 1905 break; |
1890 BPF_MTAP(ifp, m); 1891 if (free) 1892 m_freem(m); | 1906 txq->txq_enqueued += count; |
1893 } | 1907 } |
1894 txq->flags &= ~TXQ_TRANSMITTING; 1895 mtx_unlock(&txq->lock); 1896 | 1908#ifndef IFNET_MULTIQUEUE |
1897 if (__predict_false(err)) { 1898 if (err == ENOMEM) { 1899 ifp->if_drv_flags |= IFF_DRV_OACTIVE; 1900 IFQ_LOCK(&ifp->if_snd); | 1909 if (__predict_false(err)) { 1910 if (err == ENOMEM) { 1911 ifp->if_drv_flags |= IFF_DRV_OACTIVE; 1912 IFQ_LOCK(&ifp->if_snd); |
1901 IFQ_DRV_PREPEND(&ifp->if_snd, m); | 1913 IFQ_DRV_PREPEND(&ifp->if_snd, m_vec[0]); |
1902 IFQ_UNLOCK(&ifp->if_snd); 1903 } 1904 } | 1914 IFQ_UNLOCK(&ifp->if_snd); 1915 } 1916 } |
1905 if (err == 0 && m == NULL) | 1917 if (err == 0 && m_vec[0] == NULL) { |
1906 err = ENOBUFS; | 1918 err = ENOBUFS; |
1919 } |
|
1907 else if ((err == 0) && (txq->size <= txq->in_use + TX_MAX_DESC) && 1908 (ifp->if_drv_flags & IFF_DRV_OACTIVE) == 0) { 1909 ifp->if_drv_flags |= IFF_DRV_OACTIVE; 1910 err = ENOSPC; 1911 } | 1920 else if ((err == 0) && (txq->size <= txq->in_use + TX_MAX_DESC) && 1921 (ifp->if_drv_flags & IFF_DRV_OACTIVE) == 0) { 1922 ifp->if_drv_flags |= IFF_DRV_OACTIVE; 1923 err = ENOSPC; 1924 } |
1925#else 1926 if ((err == 0) && (txq->size <= txq->in_use + TX_MAX_DESC)) { 1927 err = ENOSPC; 1928 setbit(&qs->txq_stopped, TXQ_ETH); 1929 } 1930 if (err == ENOMEM) { 1931 int i; 1932 /* 1933 * Sub-optimal :-/ 1934 */ 1935 for (i = 0; i < count; i++) 1936 m_freem(m_vec[i]); 1937 } 1938#endif |
|
1912 return (err); 1913} 1914 | 1939 return (err); 1940} 1941 |
1942#ifndef IFNET_MULTIQUEUE 1943static int 1944cxgb_start_tx(struct ifnet *ifp, uint32_t txmax) 1945{ 1946 struct sge_qset *qs; 1947 struct sge_txq *txq; 1948 struct port_info *p = ifp->if_softc; 1949 int err; 1950 1951 if (!p->link_config.link_ok) 1952 return (ENXIO); 1953 1954 if (IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { 1955 return (ENOBUFS); 1956 } 1957 1958 qs = &p->adapter->sge.qs[p->first_qset]; 1959 txq = &qs->txq[TXQ_ETH]; 1960 err = 0; 1961 1962 if (txq->flags & TXQ_TRANSMITTING) 1963 return (EINPROGRESS); 1964 1965 mtx_lock(&txq->lock); 1966 txq->flags |= TXQ_TRANSMITTING; 1967 cxgb_tx_common(ifp, qs, txmax); 1968 txq->flags &= ~TXQ_TRANSMITTING; 1969 mtx_unlock(&txq->lock); 1970 1971 return (err); 1972} 1973 |
|
1915static void 1916cxgb_start_proc(void *arg, int ncount) 1917{ 1918 struct ifnet *ifp = arg; 1919 struct port_info *pi = ifp->if_softc; 1920 struct sge_qset *qs; 1921 struct sge_txq *txq; 1922 int error; --- 4 unchanged lines hidden (view full) --- 1927 do { 1928 if (desc_reclaimable(txq) > TX_CLEAN_MAX_DESC >> 2) 1929 taskqueue_enqueue(pi->tq, &txq->qreclaim_task); 1930 1931 error = cxgb_start_tx(ifp, TX_START_MAX_DESC); 1932 } while (error == 0); 1933} 1934 | 1974static void 1975cxgb_start_proc(void *arg, int ncount) 1976{ 1977 struct ifnet *ifp = arg; 1978 struct port_info *pi = ifp->if_softc; 1979 struct sge_qset *qs; 1980 struct sge_txq *txq; 1981 int error; --- 4 unchanged lines hidden (view full) --- 1986 do { 1987 if (desc_reclaimable(txq) > TX_CLEAN_MAX_DESC >> 2) 1988 taskqueue_enqueue(pi->tq, &txq->qreclaim_task); 1989 1990 error = cxgb_start_tx(ifp, TX_START_MAX_DESC); 1991 } while (error == 0); 1992} 1993 |
1935static void | 1994int 1995cxgb_dequeue_packet(struct ifnet *ifp, struct sge_txq *unused, struct mbuf **m_vec) 1996{ 1997 1998 IFQ_DRV_DEQUEUE(&ifp->if_snd, m_vec[0]); 1999 return (m_vec[0] ? 1 : 0); 2000} 2001 2002void |
1936cxgb_start(struct ifnet *ifp) 1937{ 1938 struct port_info *pi = ifp->if_softc; 1939 struct sge_qset *qs; 1940 struct sge_txq *txq; 1941 int err; 1942 1943 qs = &pi->adapter->sge.qs[pi->first_qset]; 1944 txq = &qs->txq[TXQ_ETH]; 1945 1946 if (desc_reclaimable(txq) > TX_CLEAN_MAX_DESC >> 2) 1947 taskqueue_enqueue(pi->tq, 1948 &txq->qreclaim_task); 1949 1950 err = cxgb_start_tx(ifp, TX_START_MAX_DESC); 1951 1952 if (err == 0) 1953 taskqueue_enqueue(pi->tq, &pi->start_task); 1954} | 2003cxgb_start(struct ifnet *ifp) 2004{ 2005 struct port_info *pi = ifp->if_softc; 2006 struct sge_qset *qs; 2007 struct sge_txq *txq; 2008 int err; 2009 2010 qs = &pi->adapter->sge.qs[pi->first_qset]; 2011 txq = &qs->txq[TXQ_ETH]; 2012 2013 if (desc_reclaimable(txq) > TX_CLEAN_MAX_DESC >> 2) 2014 taskqueue_enqueue(pi->tq, 2015 &txq->qreclaim_task); 2016 2017 err = cxgb_start_tx(ifp, TX_START_MAX_DESC); 2018 2019 if (err == 0) 2020 taskqueue_enqueue(pi->tq, &pi->start_task); 2021} |
2022#endif |
|
1955 | 2023 |
1956 | |
1957static int 1958cxgb_media_change(struct ifnet *ifp) 1959{ 1960 if_printf(ifp, "media change not supported\n"); 1961 return (ENXIO); 1962} 1963 1964static void --- 108 unchanged lines hidden (view full) --- 2073 PORT_UNLOCK(p); 2074 } 2075} 2076 2077static void 2078cxgb_tick(void *arg) 2079{ 2080 adapter_t *sc = (adapter_t *)arg; | 2024static int 2025cxgb_media_change(struct ifnet *ifp) 2026{ 2027 if_printf(ifp, "media change not supported\n"); 2028 return (ENXIO); 2029} 2030 2031static void --- 108 unchanged lines hidden (view full) --- 2140 PORT_UNLOCK(p); 2141 } 2142} 2143 2144static void 2145cxgb_tick(void *arg) 2146{ 2147 adapter_t *sc = (adapter_t *)arg; |
2148 int i, running = 0; 2149 2150 for_each_port(sc, i) { 2151 2152 struct port_info *p = &sc->port[i]; 2153 struct ifnet *ifp = p->ifp; 2154 PORT_LOCK(p); |
|
2081 | 2155 |
2156 if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) 2157 running = 1; 2158 PORT_UNLOCK(p); 2159 } 2160 2161 if (running == 0) 2162 return; 2163 |
|
2082 taskqueue_enqueue(sc->tq, &sc->tick_task); 2083 2084 if (sc->open_device_map != 0) | 2164 taskqueue_enqueue(sc->tq, &sc->tick_task); 2165 2166 if (sc->open_device_map != 0) |
2085 callout_reset(&sc->cxgb_tick_ch, sc->params.stats_update_period * hz, 2086 cxgb_tick, sc); | 2167 callout_reset(&sc->cxgb_tick_ch, hz, cxgb_tick, sc); |
2087} 2088 2089static void 2090cxgb_tick_handler(void *arg, int count) 2091{ 2092 adapter_t *sc = (adapter_t *)arg; 2093 const struct adapter_params *p = &sc->params; 2094 --- 378 unchanged lines hidden (view full) --- 2473 * bits 10..15: chip revision 2474 */ 2475 t->version = 3 | (sc->params.rev << 10); 2476 2477 /* 2478 * Read 256 bytes at a time as len can be large and we don't 2479 * want to use huge intermediate buffers. 2480 */ | 2168} 2169 2170static void 2171cxgb_tick_handler(void *arg, int count) 2172{ 2173 adapter_t *sc = (adapter_t *)arg; 2174 const struct adapter_params *p = &sc->params; 2175 --- 378 unchanged lines hidden (view full) --- 2554 * bits 10..15: chip revision 2555 */ 2556 t->version = 3 | (sc->params.rev << 10); 2557 2558 /* 2559 * Read 256 bytes at a time as len can be large and we don't 2560 * want to use huge intermediate buffers. 2561 */ |
2481 useraddr = (uint8_t *)(t + 1); /* advance to start of buffer */ | 2562 useraddr = (uint8_t *)t->buf; |
2482 while (t->len) { 2483 unsigned int chunk = min(t->len, sizeof(buf)); 2484 2485 error = t3_mc7_bd_read(mem, t->addr / 8, chunk / 8, buf); 2486 if (error) 2487 return (-error); 2488 if (copyout(buf, useraddr, chunk)) 2489 return (EFAULT); --- 147 unchanged lines hidden --- | 2563 while (t->len) { 2564 unsigned int chunk = min(t->len, sizeof(buf)); 2565 2566 error = t3_mc7_bd_read(mem, t->addr / 8, chunk / 8, buf); 2567 if (error) 2568 return (-error); 2569 if (copyout(buf, useraddr, chunk)) 2570 return (EFAULT); --- 147 unchanged lines hidden --- |