sfxge_port.c (280522) | sfxge_port.c (280523) |
---|---|
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: stable/10/sys/dev/sfxge/sfxge_port.c 280522 2015-03-25 10:27:54Z arybchik $"); | 31__FBSDID("$FreeBSD: stable/10/sys/dev/sfxge/sfxge_port.c 280523 2015-03-25 10:29:08Z arybchik $"); |
32 33#include <sys/types.h> 34#include <sys/limits.h> 35#include <net/ethernet.h> 36#include <net/if_dl.h> 37 38#include "common/efx.h" 39 40#include "sfxge.h" 41 42static int 43sfxge_mac_stat_update(struct sfxge_softc *sc) 44{ 45 struct sfxge_port *port = &sc->port; 46 efsys_mem_t *esmp = &(port->mac_stats.dma_buf); 47 clock_t now; 48 unsigned int count; 49 int rc; 50 | 32 33#include <sys/types.h> 34#include <sys/limits.h> 35#include <net/ethernet.h> 36#include <net/if_dl.h> 37 38#include "common/efx.h" 39 40#include "sfxge.h" 41 42static int 43sfxge_mac_stat_update(struct sfxge_softc *sc) 44{ 45 struct sfxge_port *port = &sc->port; 46 efsys_mem_t *esmp = &(port->mac_stats.dma_buf); 47 clock_t now; 48 unsigned int count; 49 int rc; 50 |
51 SFXGE_PORT_LOCK(port); | 51 SFXGE_PORT_LOCK_ASSERT_OWNED(port); |
52 53 if (port->init_state != SFXGE_PORT_STARTED) { 54 rc = 0; 55 goto out; 56 } 57 58 now = ticks; 59 if (now - port->mac_stats.update_time < hz) { --- 17 unchanged lines hidden (view full) --- 77 port->mac_stats.decode_buf, NULL)) != EAGAIN) 78 goto out; 79 80 DELAY(100); 81 } 82 83 rc = ETIMEDOUT; 84out: | 52 53 if (port->init_state != SFXGE_PORT_STARTED) { 54 rc = 0; 55 goto out; 56 } 57 58 now = ticks; 59 if (now - port->mac_stats.update_time < hz) { --- 17 unchanged lines hidden (view full) --- 77 port->mac_stats.decode_buf, NULL)) != EAGAIN) 78 goto out; 79 80 DELAY(100); 81 } 82 83 rc = ETIMEDOUT; 84out: |
85 SFXGE_PORT_UNLOCK(port); | |
86 return (rc); 87} 88 89static int 90sfxge_mac_stat_handler(SYSCTL_HANDLER_ARGS) 91{ 92 struct sfxge_softc *sc = arg1; 93 unsigned int id = arg2; 94 int rc; 95 | 85 return (rc); 86} 87 88static int 89sfxge_mac_stat_handler(SYSCTL_HANDLER_ARGS) 90{ 91 struct sfxge_softc *sc = arg1; 92 unsigned int id = arg2; 93 int rc; 94 |
95 SFXGE_PORT_LOCK(&sc->port); |
|
96 if ((rc = sfxge_mac_stat_update(sc)) != 0) | 96 if ((rc = sfxge_mac_stat_update(sc)) != 0) |
97 return (rc); | 97 goto out; |
98 | 98 |
99 return (SYSCTL_OUT(req, 100 (uint64_t *)sc->port.mac_stats.decode_buf + id, 101 sizeof(uint64_t))); | 99 rc = SYSCTL_OUT(req, 100 (uint64_t *)sc->port.mac_stats.decode_buf + id, 101 sizeof(uint64_t)); 102out: 103 SFXGE_PORT_UNLOCK(&sc->port); 104 return (rc); |
102} 103 104static void 105sfxge_mac_stat_init(struct sfxge_softc *sc) 106{ 107 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->dev); 108 struct sysctl_oid_list *stat_list; 109 unsigned int id; --- 338 unchanged lines hidden (view full) --- 448sfxge_phy_stat_update(struct sfxge_softc *sc) 449{ 450 struct sfxge_port *port = &sc->port; 451 efsys_mem_t *esmp = &port->phy_stats.dma_buf; 452 clock_t now; 453 unsigned int count; 454 int rc; 455 | 105} 106 107static void 108sfxge_mac_stat_init(struct sfxge_softc *sc) 109{ 110 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->dev); 111 struct sysctl_oid_list *stat_list; 112 unsigned int id; --- 338 unchanged lines hidden (view full) --- 451sfxge_phy_stat_update(struct sfxge_softc *sc) 452{ 453 struct sfxge_port *port = &sc->port; 454 efsys_mem_t *esmp = &port->phy_stats.dma_buf; 455 clock_t now; 456 unsigned int count; 457 int rc; 458 |
456 SFXGE_PORT_LOCK(port); | 459 SFXGE_PORT_LOCK_ASSERT_OWNED(port); |
457 458 if (port->init_state != SFXGE_PORT_STARTED) { 459 rc = 0; 460 goto out; 461 } 462 463 now = ticks; 464 if (now - port->phy_stats.update_time < hz) { --- 17 unchanged lines hidden (view full) --- 482 port->phy_stats.decode_buf)) != EAGAIN) 483 goto out; 484 485 DELAY(100); 486 } 487 488 rc = ETIMEDOUT; 489out: | 460 461 if (port->init_state != SFXGE_PORT_STARTED) { 462 rc = 0; 463 goto out; 464 } 465 466 now = ticks; 467 if (now - port->phy_stats.update_time < hz) { --- 17 unchanged lines hidden (view full) --- 485 port->phy_stats.decode_buf)) != EAGAIN) 486 goto out; 487 488 DELAY(100); 489 } 490 491 rc = ETIMEDOUT; 492out: |
490 SFXGE_PORT_UNLOCK(port); | |
491 return (rc); 492} 493 494static int 495sfxge_phy_stat_handler(SYSCTL_HANDLER_ARGS) 496{ 497 struct sfxge_softc *sc = arg1; 498 unsigned int id = arg2; 499 int rc; 500 | 493 return (rc); 494} 495 496static int 497sfxge_phy_stat_handler(SYSCTL_HANDLER_ARGS) 498{ 499 struct sfxge_softc *sc = arg1; 500 unsigned int id = arg2; 501 int rc; 502 |
503 SFXGE_PORT_LOCK(&sc->port); |
|
501 if ((rc = sfxge_phy_stat_update(sc)) != 0) | 504 if ((rc = sfxge_phy_stat_update(sc)) != 0) |
502 return (rc); | 505 goto out; |
503 | 506 |
504 return (SYSCTL_OUT(req, 505 (uint32_t *)sc->port.phy_stats.decode_buf + id, 506 sizeof(uint32_t))); | 507 rc = SYSCTL_OUT(req, 508 (uint32_t *)sc->port.phy_stats.decode_buf + id, 509 sizeof(uint32_t)); 510out: 511 SFXGE_PORT_UNLOCK(&sc->port); 512 return (rc); |
507} 508 509static void 510sfxge_phy_stat_init(struct sfxge_softc *sc) 511{ 512 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->dev); 513 struct sysctl_oid_list *stat_list; 514 unsigned int id; --- 284 unchanged lines hidden --- | 513} 514 515static void 516sfxge_phy_stat_init(struct sfxge_softc *sc) 517{ 518 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->dev); 519 struct sysctl_oid_list *stat_list; 520 unsigned int id; --- 284 unchanged lines hidden --- |