sfxge.c (272325) | sfxge.c (272328) |
---|---|
1/*- 2 * Copyright (c) 2010-2011 Solarflare Communications, Inc. 3 * All rights reserved. 4 * 5 * This software was developed in part by Philip Paeps under contract for 6 * Solarflare Communications, Inc. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2010-2011 Solarflare Communications, Inc. 3 * All rights reserved. 4 * 5 * This software was developed in part by Philip Paeps under contract for 6 * Solarflare Communications, Inc. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/dev/sfxge/sfxge.c 272325 2014-09-30 20:18:10Z gnn $"); | 31__FBSDID("$FreeBSD: head/sys/dev/sfxge/sfxge.c 272328 2014-09-30 20:36:07Z gnn $"); |
32 33#include <sys/param.h> 34#include <sys/kernel.h> 35#include <sys/bus.h> 36#include <sys/rman.h> 37#include <sys/lock.h> 38#include <sys/module.h> 39#include <sys/mutex.h> 40#include <sys/smp.h> 41#include <sys/socket.h> 42#include <sys/taskqueue.h> 43#include <sys/sockio.h> 44#include <sys/sysctl.h> | 32 33#include <sys/param.h> 34#include <sys/kernel.h> 35#include <sys/bus.h> 36#include <sys/rman.h> 37#include <sys/lock.h> 38#include <sys/module.h> 39#include <sys/mutex.h> 40#include <sys/smp.h> 41#include <sys/socket.h> 42#include <sys/taskqueue.h> 43#include <sys/sockio.h> 44#include <sys/sysctl.h> |
45#include <sys/syslog.h> |
|
45 46#include <dev/pci/pcireg.h> 47#include <dev/pci/pcivar.h> 48 49#include <net/ethernet.h> 50#include <net/if.h> 51#include <net/if_var.h> 52#include <net/if_media.h> --- 9 unchanged lines hidden (view full) --- 62 IFCAP_JUMBO_MTU | IFCAP_LRO | \ 63 IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE) 64#define SFXGE_CAP_ENABLE SFXGE_CAP 65#define SFXGE_CAP_FIXED (IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM | \ 66 IFCAP_JUMBO_MTU | IFCAP_LINKSTATE) 67 68MALLOC_DEFINE(M_SFXGE, "sfxge", "Solarflare 10GigE driver"); 69 | 46 47#include <dev/pci/pcireg.h> 48#include <dev/pci/pcivar.h> 49 50#include <net/ethernet.h> 51#include <net/if.h> 52#include <net/if_var.h> 53#include <net/if_media.h> --- 9 unchanged lines hidden (view full) --- 63 IFCAP_JUMBO_MTU | IFCAP_LRO | \ 64 IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE) 65#define SFXGE_CAP_ENABLE SFXGE_CAP 66#define SFXGE_CAP_FIXED (IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM | \ 67 IFCAP_JUMBO_MTU | IFCAP_LINKSTATE) 68 69MALLOC_DEFINE(M_SFXGE, "sfxge", "Solarflare 10GigE driver"); 70 |
71 72SYSCTL_NODE(_hw, OID_AUTO, sfxge, CTLFLAG_RD, 0, 73 "SFXGE driver parameters"); 74 75#define SFXGE_PARAM_RX_RING SFXGE_PARAM(rx_ring) 76static int sfxge_rx_ring_entries = SFXGE_NDESCS; 77TUNABLE_INT(SFXGE_PARAM_RX_RING, &sfxge_rx_ring_entries); 78SYSCTL_INT(_hw_sfxge, OID_AUTO, rx_ring, CTLFLAG_RDTUN, 79 &sfxge_rx_ring_entries, 0, 80 "Maximum number of descriptors in a receive ring"); 81 82#define SFXGE_PARAM_TX_RING SFXGE_PARAM(tx_ring) 83static int sfxge_tx_ring_entries = SFXGE_NDESCS; 84TUNABLE_INT(SFXGE_PARAM_TX_RING, &sfxge_tx_ring_entries); 85SYSCTL_INT(_hw_sfxge, OID_AUTO, tx_ring, CTLFLAG_RDTUN, 86 &sfxge_tx_ring_entries, 0, 87 "Maximum number of descriptors in a transmit ring"); 88 89 |
|
70static void 71sfxge_reset(void *arg, int npending); 72 73static int 74sfxge_start(struct sfxge_softc *sc) 75{ 76 int rc; 77 --- 231 unchanged lines hidden (view full) --- 309 310 ether_ifattach(ifp, encp->enc_mac_addr); 311 312#ifdef SFXGE_HAVE_MQ 313 ifp->if_transmit = sfxge_if_transmit; 314 ifp->if_qflush = sfxge_if_qflush; 315#else 316 ifp->if_start = sfxge_if_start; | 90static void 91sfxge_reset(void *arg, int npending); 92 93static int 94sfxge_start(struct sfxge_softc *sc) 95{ 96 int rc; 97 --- 231 unchanged lines hidden (view full) --- 329 330 ether_ifattach(ifp, encp->enc_mac_addr); 331 332#ifdef SFXGE_HAVE_MQ 333 ifp->if_transmit = sfxge_if_transmit; 334 ifp->if_qflush = sfxge_if_qflush; 335#else 336 ifp->if_start = sfxge_if_start; |
317 IFQ_SET_MAXLEN(&ifp->if_snd, SFXGE_NDESCS - 1); 318 ifp->if_snd.ifq_drv_maxlen = SFXGE_NDESCS - 1; | 337 IFQ_SET_MAXLEN(&ifp->if_snd, sc->txq_entries - 1); 338 ifp->if_snd.ifq_drv_maxlen = sc->txq_entries - 1; |
319 IFQ_SET_READY(&ifp->if_snd); 320 321 mtx_init(&sc->tx_lock, "txq", NULL, MTX_DEF); 322#endif 323 324 if ((rc = sfxge_port_ifmedia_init(sc)) != 0) 325 goto fail; 326 --- 82 unchanged lines hidden (view full) --- 409 410 /* Create the common code nic object. */ 411 mtx_init(&sc->enp_lock, "sfxge_nic", NULL, MTX_DEF); 412 if ((error = efx_nic_create(sc->family, (efsys_identifier_t *)sc, 413 &sc->bar, &sc->enp_lock, &enp)) != 0) 414 goto fail3; 415 sc->enp = enp; 416 | 339 IFQ_SET_READY(&ifp->if_snd); 340 341 mtx_init(&sc->tx_lock, "txq", NULL, MTX_DEF); 342#endif 343 344 if ((rc = sfxge_port_ifmedia_init(sc)) != 0) 345 goto fail; 346 --- 82 unchanged lines hidden (view full) --- 429 430 /* Create the common code nic object. */ 431 mtx_init(&sc->enp_lock, "sfxge_nic", NULL, MTX_DEF); 432 if ((error = efx_nic_create(sc->family, (efsys_identifier_t *)sc, 433 &sc->bar, &sc->enp_lock, &enp)) != 0) 434 goto fail3; 435 sc->enp = enp; 436 |
437 if (!ISP2(sfxge_rx_ring_entries) || 438 !(sfxge_rx_ring_entries & EFX_RXQ_NDESCS_MASK)) { 439 log(LOG_ERR, "%s=%d must be power of 2 from %u to %u", 440 SFXGE_PARAM_RX_RING, sfxge_rx_ring_entries, 441 EFX_RXQ_MINNDESCS, EFX_RXQ_MAXNDESCS); 442 error = EINVAL; 443 goto fail_rx_ring_entries; 444 } 445 sc->rxq_entries = sfxge_rx_ring_entries; 446 447 if (!ISP2(sfxge_tx_ring_entries) || 448 !(sfxge_tx_ring_entries & EFX_TXQ_NDESCS_MASK)) { 449 log(LOG_ERR, "%s=%d must be power of 2 from %u to %u", 450 SFXGE_PARAM_TX_RING, sfxge_tx_ring_entries, 451 EFX_TXQ_MINNDESCS, EFX_TXQ_MAXNDESCS); 452 error = EINVAL; 453 goto fail_tx_ring_entries; 454 } 455 sc->txq_entries = sfxge_tx_ring_entries; 456 |
|
417 /* Initialize MCDI to talk to the microcontroller. */ 418 if ((error = sfxge_mcdi_init(sc)) != 0) 419 goto fail4; 420 421 /* Probe the NIC and build the configuration data area. */ 422 if ((error = efx_nic_probe(enp)) != 0) 423 goto fail5; 424 --- 56 unchanged lines hidden (view full) --- 481 482fail6: 483 efx_nic_unprobe(enp); 484 485fail5: 486 sfxge_mcdi_fini(sc); 487 488fail4: | 457 /* Initialize MCDI to talk to the microcontroller. */ 458 if ((error = sfxge_mcdi_init(sc)) != 0) 459 goto fail4; 460 461 /* Probe the NIC and build the configuration data area. */ 462 if ((error = efx_nic_probe(enp)) != 0) 463 goto fail5; 464 --- 56 unchanged lines hidden (view full) --- 521 522fail6: 523 efx_nic_unprobe(enp); 524 525fail5: 526 sfxge_mcdi_fini(sc); 527 528fail4: |
529fail_tx_ring_entries: 530fail_rx_ring_entries: |
|
489 sc->enp = NULL; 490 efx_nic_destroy(enp); 491 mtx_destroy(&sc->enp_lock); 492 493fail3: 494 sfxge_bar_fini(sc); 495 (void) pci_disable_busmaster(sc->dev); 496 --- 276 unchanged lines hidden --- | 531 sc->enp = NULL; 532 efx_nic_destroy(enp); 533 mtx_destroy(&sc->enp_lock); 534 535fail3: 536 sfxge_bar_fini(sc); 537 (void) pci_disable_busmaster(sc->dev); 538 --- 276 unchanged lines hidden --- |