sfxge.c (278221) | sfxge.c (278250) |
---|---|
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 278221 2015-02-04 20:03:57Z arybchik $"); | 31__FBSDID("$FreeBSD: head/sys/dev/sfxge/sfxge.c 278250 2015-02-05 11:39:15Z arybchik $"); |
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> --- 293 unchanged lines hidden (view full) --- 333 ifp->if_transmit = sfxge_if_transmit; 334 ifp->if_qflush = sfxge_if_qflush; 335#else 336 ifp->if_start = sfxge_if_start; 337 IFQ_SET_MAXLEN(&ifp->if_snd, sc->txq_entries - 1); 338 ifp->if_snd.ifq_drv_maxlen = sc->txq_entries - 1; 339 IFQ_SET_READY(&ifp->if_snd); 340 | 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> --- 293 unchanged lines hidden (view full) --- 333 ifp->if_transmit = sfxge_if_transmit; 334 ifp->if_qflush = sfxge_if_qflush; 335#else 336 ifp->if_start = sfxge_if_start; 337 IFQ_SET_MAXLEN(&ifp->if_snd, sc->txq_entries - 1); 338 ifp->if_snd.ifq_drv_maxlen = sc->txq_entries - 1; 339 IFQ_SET_READY(&ifp->if_snd); 340 |
341 mtx_init(&sc->tx_lock, "txq", NULL, MTX_DEF); | 341 snprintf(sc->tx_lock_name, sizeof(sc->tx_lock_name), 342 "%s:tx", device_get_nameunit(sc->dev)); 343 mtx_init(&sc->tx_lock, sc->tx_lock_name, NULL, MTX_DEF); |
342#endif 343 344 if ((rc = sfxge_port_ifmedia_init(sc)) != 0) 345 goto fail; 346 347 return (0); 348 349fail: --- 21 unchanged lines hidden (view full) --- 371 if ((esbp->esb_res = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, 372 &esbp->esb_rid, RF_ACTIVE)) == NULL) { 373 device_printf(sc->dev, "Cannot allocate BAR region %d\n", 374 EFX_MEM_BAR); 375 return (ENXIO); 376 } 377 esbp->esb_tag = rman_get_bustag(esbp->esb_res); 378 esbp->esb_handle = rman_get_bushandle(esbp->esb_res); | 344#endif 345 346 if ((rc = sfxge_port_ifmedia_init(sc)) != 0) 347 goto fail; 348 349 return (0); 350 351fail: --- 21 unchanged lines hidden (view full) --- 373 if ((esbp->esb_res = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, 374 &esbp->esb_rid, RF_ACTIVE)) == NULL) { 375 device_printf(sc->dev, "Cannot allocate BAR region %d\n", 376 EFX_MEM_BAR); 377 return (ENXIO); 378 } 379 esbp->esb_tag = rman_get_bustag(esbp->esb_res); 380 esbp->esb_handle = rman_get_bushandle(esbp->esb_res); |
379 SFXGE_BAR_LOCK_INIT(esbp, "sfxge_efsys_bar"); | |
380 | 381 |
382 SFXGE_BAR_LOCK_INIT(esbp, device_get_nameunit(sc->dev)); 383 |
|
381 return (0); 382} 383 384static void 385sfxge_bar_fini(struct sfxge_softc *sc) 386{ 387 efsys_bar_t *esbp = &sc->bar; 388 --- 7 unchanged lines hidden (view full) --- 396{ 397 device_t dev; 398 efx_nic_t *enp; 399 int error; 400 char rss_param_name[sizeof(SFXGE_PARAM(%d.max_rss_channels))]; 401 402 dev = sc->dev; 403 | 384 return (0); 385} 386 387static void 388sfxge_bar_fini(struct sfxge_softc *sc) 389{ 390 efsys_bar_t *esbp = &sc->bar; 391 --- 7 unchanged lines hidden (view full) --- 399{ 400 device_t dev; 401 efx_nic_t *enp; 402 int error; 403 char rss_param_name[sizeof(SFXGE_PARAM(%d.max_rss_channels))]; 404 405 dev = sc->dev; 406 |
404 SFXGE_ADAPTER_LOCK_INIT(sc, "sfxge_softc"); | 407 SFXGE_ADAPTER_LOCK_INIT(sc, device_get_nameunit(sc->dev)); |
405 406 sc->max_rss_channels = 0; 407 snprintf(rss_param_name, sizeof(rss_param_name), 408 SFXGE_PARAM(%d.max_rss_channels), 409 (int)device_get_unit(dev)); 410 TUNABLE_INT_FETCH(rss_param_name, &sc->max_rss_channels); 411 412 sc->stats_node = SYSCTL_ADD_NODE( --- 17 unchanged lines hidden (view full) --- 430 if ((error = sfxge_bar_init(sc)) != 0) 431 goto fail; 432 433 error = efx_family(pci_get_vendor(dev), pci_get_device(dev), 434 &sc->family); 435 KASSERT(error == 0, ("Family should be filtered by sfxge_probe()")); 436 437 /* Create the common code nic object. */ | 408 409 sc->max_rss_channels = 0; 410 snprintf(rss_param_name, sizeof(rss_param_name), 411 SFXGE_PARAM(%d.max_rss_channels), 412 (int)device_get_unit(dev)); 413 TUNABLE_INT_FETCH(rss_param_name, &sc->max_rss_channels); 414 415 sc->stats_node = SYSCTL_ADD_NODE( --- 17 unchanged lines hidden (view full) --- 433 if ((error = sfxge_bar_init(sc)) != 0) 434 goto fail; 435 436 error = efx_family(pci_get_vendor(dev), pci_get_device(dev), 437 &sc->family); 438 KASSERT(error == 0, ("Family should be filtered by sfxge_probe()")); 439 440 /* Create the common code nic object. */ |
438 mtx_init(&sc->enp_lock, "sfxge_nic", NULL, MTX_DEF); | 441 SFXGE_EFSYS_LOCK_INIT(&sc->enp_lock, 442 device_get_nameunit(sc->dev), "nic"); |
439 if ((error = efx_nic_create(sc->family, (efsys_identifier_t *)sc, 440 &sc->bar, &sc->enp_lock, &enp)) != 0) 441 goto fail3; 442 sc->enp = enp; 443 444 if (!ISP2(sfxge_rx_ring_entries) || 445 !(sfxge_rx_ring_entries & EFX_RXQ_NDESCS_MASK)) { 446 log(LOG_ERR, "%s=%d must be power of 2 from %u to %u", --- 85 unchanged lines hidden (view full) --- 532fail5: 533 sfxge_mcdi_fini(sc); 534 535fail4: 536fail_tx_ring_entries: 537fail_rx_ring_entries: 538 sc->enp = NULL; 539 efx_nic_destroy(enp); | 443 if ((error = efx_nic_create(sc->family, (efsys_identifier_t *)sc, 444 &sc->bar, &sc->enp_lock, &enp)) != 0) 445 goto fail3; 446 sc->enp = enp; 447 448 if (!ISP2(sfxge_rx_ring_entries) || 449 !(sfxge_rx_ring_entries & EFX_RXQ_NDESCS_MASK)) { 450 log(LOG_ERR, "%s=%d must be power of 2 from %u to %u", --- 85 unchanged lines hidden (view full) --- 536fail5: 537 sfxge_mcdi_fini(sc); 538 539fail4: 540fail_tx_ring_entries: 541fail_rx_ring_entries: 542 sc->enp = NULL; 543 efx_nic_destroy(enp); |
540 mtx_destroy(&sc->enp_lock); | 544 SFXGE_EFSYS_LOCK_DESTROY(&sc->enp_lock); |
541 542fail3: 543 sfxge_bar_fini(sc); 544 (void) pci_disable_busmaster(sc->dev); 545 546fail: 547 sc->dev = NULL; 548 SFXGE_ADAPTER_LOCK_DESTROY(sc); --- 273 unchanged lines hidden --- | 545 546fail3: 547 sfxge_bar_fini(sc); 548 (void) pci_disable_busmaster(sc->dev); 549 550fail: 551 sc->dev = NULL; 552 SFXGE_ADAPTER_LOCK_DESTROY(sc); --- 273 unchanged lines hidden --- |