diff options
author | gnn <gnn@FreeBSD.org> | 2010-07-23 17:53:39 +0000 |
---|---|---|
committer | gnn <gnn@FreeBSD.org> | 2010-07-23 17:53:39 +0000 |
commit | 33843d3a844a40bffb8c41095c5ba177ffcc9503 (patch) | |
tree | 67dfad915616526cfc797f3c96d1c79a05ed0668 /sys/dev/e1000 | |
parent | 4663240679e5321f72d4dd7715ead1d58829e211 (diff) | |
download | FreeBSD-src-33843d3a844a40bffb8c41095c5ba177ffcc9503.zip FreeBSD-src-33843d3a844a40bffb8c41095c5ba177ffcc9503.tar.gz |
Fix a bug in the statistics code for tracking the head and
tail pointers of the tx and rx queues. We needed a SYSCTL_PROC
to correctly get the values at run time.
Submitted by: Andrew Boyer aboyer at averesystems.com
MFC after: 1 week
Diffstat (limited to 'sys/dev/e1000')
-rw-r--r-- | sys/dev/e1000/if_igb.c | 92 |
1 files changed, 82 insertions, 10 deletions
diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c index eb3906b..acb161d 100644 --- a/sys/dev/e1000/if_igb.c +++ b/sys/dev/e1000/if_igb.c @@ -4927,6 +4927,74 @@ igb_update_vf_stats_counters(struct adapter *adapter) } +/** igb_sysctl_tdh_handler - Handler function + * Retrieves the TDH value from the hardware + */ +static int igb_sysctl_tdh_handler(SYSCTL_HANDLER_ARGS) +{ + int error; + + struct tx_ring *txr = ((struct tx_ring *)oidp->oid_arg1); + if (!txr) return 0; + + unsigned val = E1000_READ_REG(&txr->adapter->hw, E1000_TDH(txr->me)); + error = sysctl_handle_int(oidp, &val, 0, req); + if (error || !req->newptr) + return error; + return 0; +} + +/** igb_sysctl_tdt_handler - Handler function + * Retrieves the TDT value from the hardware + */ +static int igb_sysctl_tdt_handler(SYSCTL_HANDLER_ARGS) +{ + int error; + + struct tx_ring *txr = ((struct tx_ring *)oidp->oid_arg1); + if (!txr) return 0; + + unsigned val = E1000_READ_REG(&txr->adapter->hw, E1000_TDT(txr->me)); + error = sysctl_handle_int(oidp, &val, 0, req); + if (error || !req->newptr) + return error; + return 0; +} + +/** igb_sysctl_rdh_handler - Handler function + * Retrieves the RDH value from the hardware + */ +static int igb_sysctl_rdh_handler(SYSCTL_HANDLER_ARGS) +{ + int error; + + struct rx_ring *rxr = ((struct rx_ring *)oidp->oid_arg1); + if (!rxr) return 0; + + unsigned val = E1000_READ_REG(&rxr->adapter->hw, E1000_RDH(rxr->me)); + error = sysctl_handle_int(oidp, &val, 0, req); + if (error || !req->newptr) + return error; + return 0; +} + +/** igb_sysctl_rdt_handler - Handler function + * Retrieves the RDT value from the hardware + */ +static int igb_sysctl_rdt_handler(SYSCTL_HANDLER_ARGS) +{ + int error; + + struct rx_ring *rxr = ((struct rx_ring *)oidp->oid_arg1); + if (!rxr) return 0; + + unsigned val = E1000_READ_REG(&rxr->adapter->hw, E1000_RDT(rxr->me)); + error = sysctl_handle_int(oidp, &val, 0, req); + if (error || !req->newptr) + return error; + return 0; +} + /* * Add sysctl variables, one per statistic, to the system. */ @@ -4992,12 +5060,14 @@ igb_add_hw_stats(struct adapter *adapter) CTLFLAG_RD, NULL, "Queue Name"); queue_list = SYSCTL_CHILDREN(queue_node); - SYSCTL_ADD_UINT(ctx, queue_list, OID_AUTO, "txd_head", - CTLFLAG_RD, &txr->tdh, 0, - "Transmit Descriptor Head"); - SYSCTL_ADD_UINT(ctx, queue_list, OID_AUTO, "txd_tail", - CTLFLAG_RD, &txr->tdt, 0, - "Transmit Descriptor Tail"); + SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "txd_head", + CTLFLAG_RD, txr, sizeof(txr), + igb_sysctl_tdh_handler, "IU", + "Transmit Descriptor Head"); + SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "txd_tail", + CTLFLAG_RD, txr, sizeof(txr), + igb_sysctl_tdt_handler, "IU", + "Transmit Descriptor Tail"); SYSCTL_ADD_QUAD(ctx, queue_list, OID_AUTO, "no_desc_avail", CTLFLAG_RD, &txr->no_desc_avail, "Queue No Descriptor Available"); @@ -5019,11 +5089,13 @@ igb_add_hw_stats(struct adapter *adapter) CTLFLAG_RD, NULL, "Queue Name"); queue_list = SYSCTL_CHILDREN(queue_node); - SYSCTL_ADD_UINT(ctx, queue_list, OID_AUTO, "rxd_head", - CTLFLAG_RD, &rxr->rdh, 0, + SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "rxd_head", + CTLFLAG_RD, rxr, sizeof(rxr), + igb_sysctl_rdh_handler, "IU", "Receive Descriptor Head"); - SYSCTL_ADD_UINT(ctx, queue_list, OID_AUTO, "rxd_tail", - CTLFLAG_RD, &rxr->rdt, 0, + SYSCTL_ADD_PROC(ctx, queue_list, OID_AUTO, "rxd_tail", + CTLFLAG_RD, rxr, sizeof(rxr), + igb_sysctl_rdt_handler, "IU", "Receive Descriptor Tail"); SYSCTL_ADD_QUAD(ctx, queue_list, OID_AUTO, "rx_packets", CTLFLAG_RD, &rxr->rx_packets, |