1ce110ea1SWei Hu /*- 2ce110ea1SWei Hu * SPDX-License-Identifier: BSD-2-Clause 3ce110ea1SWei Hu * 4ce110ea1SWei Hu * Copyright (c) 2021 Microsoft Corp. 5ce110ea1SWei Hu * All rights reserved. 6ce110ea1SWei Hu * 7ce110ea1SWei Hu * Redistribution and use in source and binary forms, with or without 8ce110ea1SWei Hu * modification, are permitted provided that the following conditions 9ce110ea1SWei Hu * are met: 10ce110ea1SWei Hu * 11ce110ea1SWei Hu * 1. Redistributions of source code must retain the above copyright 12ce110ea1SWei Hu * notice, this list of conditions and the following disclaimer. 13ce110ea1SWei Hu * 14ce110ea1SWei Hu * 2. Redistributions in binary form must reproduce the above copyright 15ce110ea1SWei Hu * notice, this list of conditions and the following disclaimer in the 16ce110ea1SWei Hu * documentation and/or other materials provided with the distribution. 17ce110ea1SWei Hu * 18ce110ea1SWei Hu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19ce110ea1SWei Hu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20ce110ea1SWei Hu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21ce110ea1SWei Hu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22ce110ea1SWei Hu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23ce110ea1SWei Hu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24ce110ea1SWei Hu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25ce110ea1SWei Hu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26ce110ea1SWei Hu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27ce110ea1SWei Hu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28ce110ea1SWei Hu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29ce110ea1SWei Hu */ 30ce110ea1SWei Hu #include <sys/cdefs.h> 31ce110ea1SWei Hu #include "mana_sysctl.h" 32ce110ea1SWei Hu 33ce110ea1SWei Hu static int mana_sysctl_cleanup_thread_cpu(SYSCTL_HANDLER_ARGS); 34ce110ea1SWei Hu 35ce110ea1SWei Hu int mana_log_level = MANA_ALERT | MANA_WARNING | MANA_INFO; 36ce110ea1SWei Hu 37*a18e9994SWei Hu unsigned int mana_tx_req_size; 38*a18e9994SWei Hu unsigned int mana_rx_req_size; 39*a18e9994SWei Hu 40ce110ea1SWei Hu SYSCTL_NODE(_hw, OID_AUTO, mana, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 41ce110ea1SWei Hu "MANA driver parameters"); 42ce110ea1SWei Hu 43*a18e9994SWei Hu SYSCTL_UINT(_hw_mana, OID_AUTO, tx_req_size, CTLFLAG_RWTUN, 44*a18e9994SWei Hu &mana_tx_req_size, 0, "requested number of unit of tx queue"); 45*a18e9994SWei Hu SYSCTL_UINT(_hw_mana, OID_AUTO, rx_req_size, CTLFLAG_RWTUN, 46*a18e9994SWei Hu &mana_rx_req_size, 0, "requested number of unit of rx queue"); 47*a18e9994SWei Hu 48ce110ea1SWei Hu /* 49ce110ea1SWei Hu * Logging level for changing verbosity of the output 50ce110ea1SWei Hu */ 51ce110ea1SWei Hu SYSCTL_INT(_hw_mana, OID_AUTO, log_level, CTLFLAG_RWTUN, 52ce110ea1SWei Hu &mana_log_level, 0, "Logging level indicating verbosity of the logs"); 53ce110ea1SWei Hu 54ce110ea1SWei Hu SYSCTL_CONST_STRING(_hw_mana, OID_AUTO, driver_version, CTLFLAG_RD, 55ce110ea1SWei Hu DRV_MODULE_VERSION, "MANA driver version"); 56ce110ea1SWei Hu 57b167e449SWei Hu static int 58b167e449SWei Hu mana_sysctl_rx_stat_agg_u64(SYSCTL_HANDLER_ARGS) 59b167e449SWei Hu { 60b167e449SWei Hu struct mana_port_context *apc = arg1; 61b167e449SWei Hu int offset = arg2, i, err; 62b167e449SWei Hu struct mana_rxq *rxq; 63b167e449SWei Hu uint64_t stat; 64b167e449SWei Hu 65b167e449SWei Hu stat = 0; 66b167e449SWei Hu for (i = 0; i < apc->num_queues; i++) { 67b167e449SWei Hu rxq = apc->rxqs[i]; 68b167e449SWei Hu stat += *((uint64_t *)((uint8_t *)rxq + offset)); 69b167e449SWei Hu } 70b167e449SWei Hu 71b167e449SWei Hu err = sysctl_handle_64(oidp, &stat, 0, req); 72b167e449SWei Hu if (err || req->newptr == NULL) 73b167e449SWei Hu return err; 74b167e449SWei Hu 75b167e449SWei Hu for (i = 0; i < apc->num_queues; i++) { 76b167e449SWei Hu rxq = apc->rxqs[i]; 77b167e449SWei Hu *((uint64_t *)((uint8_t *)rxq + offset)) = 0; 78b167e449SWei Hu } 79b167e449SWei Hu return 0; 80b167e449SWei Hu } 81b167e449SWei Hu 82b167e449SWei Hu static int 83b167e449SWei Hu mana_sysctl_rx_stat_u16(SYSCTL_HANDLER_ARGS) 84b167e449SWei Hu { 85b167e449SWei Hu struct mana_port_context *apc = arg1; 86b167e449SWei Hu int offset = arg2, err; 87b167e449SWei Hu struct mana_rxq *rxq; 88b167e449SWei Hu uint64_t stat; 89b167e449SWei Hu uint16_t val; 90b167e449SWei Hu 91b167e449SWei Hu rxq = apc->rxqs[0]; 92b167e449SWei Hu val = *((uint16_t *)((uint8_t *)rxq + offset)); 93b167e449SWei Hu stat = val; 94b167e449SWei Hu 95b167e449SWei Hu err = sysctl_handle_64(oidp, &stat, 0, req); 96b167e449SWei Hu if (err || req->newptr == NULL) 97b167e449SWei Hu return err; 98b167e449SWei Hu else 99b167e449SWei Hu return 0; 100b167e449SWei Hu } 101b167e449SWei Hu 102b167e449SWei Hu static int 103b167e449SWei Hu mana_sysctl_rx_stat_u32(SYSCTL_HANDLER_ARGS) 104b167e449SWei Hu { 105b167e449SWei Hu struct mana_port_context *apc = arg1; 106b167e449SWei Hu int offset = arg2, err; 107b167e449SWei Hu struct mana_rxq *rxq; 108b167e449SWei Hu uint64_t stat; 109b167e449SWei Hu uint32_t val; 110b167e449SWei Hu 111b167e449SWei Hu rxq = apc->rxqs[0]; 112b167e449SWei Hu val = *((uint32_t *)((uint8_t *)rxq + offset)); 113b167e449SWei Hu stat = val; 114b167e449SWei Hu 115b167e449SWei Hu err = sysctl_handle_64(oidp, &stat, 0, req); 116b167e449SWei Hu if (err || req->newptr == NULL) 117b167e449SWei Hu return err; 118b167e449SWei Hu else 119b167e449SWei Hu return 0; 120b167e449SWei Hu } 121b167e449SWei Hu 122b167e449SWei Hu static int 123b167e449SWei Hu mana_sysctl_tx_stat_agg_u64(SYSCTL_HANDLER_ARGS) 124b167e449SWei Hu { 125b167e449SWei Hu struct mana_port_context *apc = arg1; 126b167e449SWei Hu int offset = arg2, i, err; 127b167e449SWei Hu struct mana_txq *txq; 128b167e449SWei Hu uint64_t stat; 129b167e449SWei Hu 130b167e449SWei Hu stat = 0; 131b167e449SWei Hu for (i = 0; i < apc->num_queues; i++) { 132b167e449SWei Hu txq = &apc->tx_qp[i].txq; 133b167e449SWei Hu stat += *((uint64_t *)((uint8_t *)txq + offset)); 134b167e449SWei Hu } 135b167e449SWei Hu 136b167e449SWei Hu err = sysctl_handle_64(oidp, &stat, 0, req); 137b167e449SWei Hu if (err || req->newptr == NULL) 138b167e449SWei Hu return err; 139b167e449SWei Hu 140b167e449SWei Hu for (i = 0; i < apc->num_queues; i++) { 141b167e449SWei Hu txq = &apc->tx_qp[i].txq; 142b167e449SWei Hu *((uint64_t *)((uint8_t *)txq + offset)) = 0; 143b167e449SWei Hu } 144b167e449SWei Hu return 0; 145b167e449SWei Hu } 146b167e449SWei Hu 147ce110ea1SWei Hu void 148ce110ea1SWei Hu mana_sysctl_add_port(struct mana_port_context *apc) 149ce110ea1SWei Hu { 150ce110ea1SWei Hu struct gdma_context *gc = apc->ac->gdma_dev->gdma_context; 151ce110ea1SWei Hu device_t dev = gc->dev; 152ce110ea1SWei Hu struct sysctl_ctx_list *ctx; 153ce110ea1SWei Hu struct sysctl_oid *tree; 154ce110ea1SWei Hu struct sysctl_oid_list *child; 155ce110ea1SWei Hu struct mana_port_stats *port_stats; 156ce110ea1SWei Hu char node_name[32]; 157ce110ea1SWei Hu 158ce110ea1SWei Hu struct sysctl_oid *port_node, *stats_node; 159ce110ea1SWei Hu struct sysctl_oid_list *stats_list; 160ce110ea1SWei Hu 161ce110ea1SWei Hu ctx = device_get_sysctl_ctx(dev); 162ce110ea1SWei Hu tree = device_get_sysctl_tree(dev); 163ce110ea1SWei Hu child = SYSCTL_CHILDREN(tree); 164ce110ea1SWei Hu 165ce110ea1SWei Hu port_stats = &apc->port_stats; 166ce110ea1SWei Hu 167ce110ea1SWei Hu snprintf(node_name, 32, "port%d", apc->port_idx); 168ce110ea1SWei Hu 169ce110ea1SWei Hu port_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, 170ce110ea1SWei Hu node_name, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Port Name"); 171ce110ea1SWei Hu apc->port_list = SYSCTL_CHILDREN(port_node); 172ce110ea1SWei Hu 173ce110ea1SWei Hu SYSCTL_ADD_BOOL(ctx, apc->port_list, OID_AUTO, 174ce110ea1SWei Hu "enable_altq", CTLFLAG_RW, &apc->enable_tx_altq, 0, 175ce110ea1SWei Hu "Choose alternative txq under heavy load"); 176ce110ea1SWei Hu 177*a18e9994SWei Hu SYSCTL_ADD_UINT(ctx, apc->port_list, OID_AUTO, 178*a18e9994SWei Hu "tx_queue_size", CTLFLAG_RD, &apc->tx_queue_size, 0, 179*a18e9994SWei Hu "number of unit of tx queue"); 180*a18e9994SWei Hu 181*a18e9994SWei Hu SYSCTL_ADD_UINT(ctx, apc->port_list, OID_AUTO, 182*a18e9994SWei Hu "rx_queue_size", CTLFLAG_RD, &apc->rx_queue_size, 0, 183*a18e9994SWei Hu "number of unit of rx queue"); 184*a18e9994SWei Hu 185ce110ea1SWei Hu SYSCTL_ADD_PROC(ctx, apc->port_list, OID_AUTO, 186ce110ea1SWei Hu "bind_cleanup_thread_cpu", 187ce110ea1SWei Hu CTLTYPE_U8 | CTLFLAG_RW | CTLFLAG_MPSAFE, 188ce110ea1SWei Hu apc, 0, mana_sysctl_cleanup_thread_cpu, "I", 189ce110ea1SWei Hu "Bind cleanup thread to a cpu. 0 disables it."); 190ce110ea1SWei Hu 191ce110ea1SWei Hu stats_node = SYSCTL_ADD_NODE(ctx, apc->port_list, OID_AUTO, 192ce110ea1SWei Hu "port_stats", CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 193ce110ea1SWei Hu "Statistics of port"); 194ce110ea1SWei Hu stats_list = SYSCTL_CHILDREN(stats_node); 195ce110ea1SWei Hu 196ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, stats_list, OID_AUTO, "rx_packets", 197ce110ea1SWei Hu CTLFLAG_RD, &port_stats->rx_packets, "Packets received"); 198ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, stats_list, OID_AUTO, "tx_packets", 199ce110ea1SWei Hu CTLFLAG_RD, &port_stats->tx_packets, "Packets transmitted"); 200ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, stats_list, OID_AUTO, "rx_bytes", 201ce110ea1SWei Hu CTLFLAG_RD, &port_stats->rx_bytes, "Bytes received"); 202ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, stats_list, OID_AUTO, "tx_bytes", 203ce110ea1SWei Hu CTLFLAG_RD, &port_stats->tx_bytes, "Bytes transmitted"); 204ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, stats_list, OID_AUTO, "rx_drops", 205ce110ea1SWei Hu CTLFLAG_RD, &port_stats->rx_drops, "Receive packet drops"); 206ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, stats_list, OID_AUTO, "tx_drops", 207ce110ea1SWei Hu CTLFLAG_RD, &port_stats->tx_drops, "Transmit packet drops"); 208b167e449SWei Hu 209b167e449SWei Hu SYSCTL_ADD_PROC(ctx, stats_list, OID_AUTO, "rx_lro_queued", 210b167e449SWei Hu CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_MPSAFE | CTLFLAG_STATS, apc, 211b167e449SWei Hu __offsetof(struct mana_rxq, lro.lro_queued), 212b167e449SWei Hu mana_sysctl_rx_stat_agg_u64, "LU", "LRO queued"); 213b167e449SWei Hu SYSCTL_ADD_PROC(ctx, stats_list, OID_AUTO, "rx_lro_flushed", 214b167e449SWei Hu CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_MPSAFE | CTLFLAG_STATS, apc, 215b167e449SWei Hu __offsetof(struct mana_rxq, lro.lro_flushed), 216b167e449SWei Hu mana_sysctl_rx_stat_agg_u64, "LU", "LRO flushed"); 217b167e449SWei Hu SYSCTL_ADD_PROC(ctx, stats_list, OID_AUTO, "rx_lro_bad_csum", 218b167e449SWei Hu CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_MPSAFE | CTLFLAG_STATS, apc, 219b167e449SWei Hu __offsetof(struct mana_rxq, lro.lro_bad_csum), 220b167e449SWei Hu mana_sysctl_rx_stat_agg_u64, "LU", "LRO bad checksum"); 221b167e449SWei Hu SYSCTL_ADD_PROC(ctx, stats_list, OID_AUTO, "rx_lro_tried", 222b167e449SWei Hu CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_STATS, apc, 223b167e449SWei Hu __offsetof(struct mana_rxq, lro_tried), 224b167e449SWei Hu mana_sysctl_rx_stat_agg_u64, "LU", "LRO tried"); 225b167e449SWei Hu SYSCTL_ADD_PROC(ctx, stats_list, OID_AUTO, "rx_lro_failed", 226b167e449SWei Hu CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_STATS, apc, 227b167e449SWei Hu __offsetof(struct mana_rxq, lro_failed), 228b167e449SWei Hu mana_sysctl_rx_stat_agg_u64, "LU", "LRO failed"); 229b167e449SWei Hu 230b167e449SWei Hu SYSCTL_ADD_PROC(ctx, stats_list, OID_AUTO, "lro_ackcnt_lim", 231b167e449SWei Hu CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_STATS, apc, 232b167e449SWei Hu __offsetof(struct mana_rxq, lro.lro_ackcnt_lim), 233b167e449SWei Hu mana_sysctl_rx_stat_u16, 234b167e449SWei Hu "LU", "Max # of ACKs to be aggregated by LRO"); 235b167e449SWei Hu SYSCTL_ADD_PROC(ctx, stats_list, OID_AUTO, "lro_length_lim", 236b167e449SWei Hu CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_STATS, apc, 237b167e449SWei Hu __offsetof(struct mana_rxq, lro.lro_length_lim), 238b167e449SWei Hu mana_sysctl_rx_stat_u32, 239b167e449SWei Hu "LU", "Max len of aggregated data in byte by LRO"); 240b167e449SWei Hu SYSCTL_ADD_PROC(ctx, stats_list, OID_AUTO, "lro_cnt", 241b167e449SWei Hu CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_STATS, apc, 242b167e449SWei Hu __offsetof(struct mana_rxq, lro.lro_cnt), 243b167e449SWei Hu mana_sysctl_rx_stat_u32, 244b167e449SWei Hu "LU", "Max # or LRO packet count"); 245b167e449SWei Hu 246b167e449SWei Hu SYSCTL_ADD_PROC(ctx, stats_list, OID_AUTO, "tx_tso_packets", 247b167e449SWei Hu CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_STATS, apc, 248b167e449SWei Hu __offsetof(struct mana_txq, tso_pkts), 249b167e449SWei Hu mana_sysctl_tx_stat_agg_u64, "LU", "TSO packets"); 250b167e449SWei Hu SYSCTL_ADD_PROC(ctx, stats_list, OID_AUTO, "tx_tso_bytes", 251b167e449SWei Hu CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_STATS, apc, 252b167e449SWei Hu __offsetof(struct mana_txq, tso_bytes), 253b167e449SWei Hu mana_sysctl_tx_stat_agg_u64, "LU", "TSO bytes"); 254ce110ea1SWei Hu } 255ce110ea1SWei Hu 256ce110ea1SWei Hu void 257ce110ea1SWei Hu mana_sysctl_add_queues(struct mana_port_context *apc) 258ce110ea1SWei Hu { 259ce110ea1SWei Hu struct sysctl_ctx_list *ctx = &apc->que_sysctl_ctx; 260ce110ea1SWei Hu struct sysctl_oid_list *child = apc->port_list; 261ce110ea1SWei Hu 262ce110ea1SWei Hu struct sysctl_oid *queue_node, *tx_node, *rx_node; 263ce110ea1SWei Hu struct sysctl_oid_list *queue_list, *tx_list, *rx_list; 264ce110ea1SWei Hu struct mana_txq *txq; 265ce110ea1SWei Hu struct mana_rxq *rxq; 266ce110ea1SWei Hu struct mana_stats *tx_stats, *rx_stats; 267ce110ea1SWei Hu char que_name[32]; 268ce110ea1SWei Hu int i; 269ce110ea1SWei Hu 270ce110ea1SWei Hu sysctl_ctx_init(ctx); 271ce110ea1SWei Hu 272ce110ea1SWei Hu for (i = 0; i < apc->num_queues; i++) { 273ce110ea1SWei Hu rxq = apc->rxqs[i]; 274ce110ea1SWei Hu txq = &apc->tx_qp[i].txq; 275ce110ea1SWei Hu 276ce110ea1SWei Hu snprintf(que_name, 32, "queue%d", i); 277ce110ea1SWei Hu 278ce110ea1SWei Hu queue_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, 279ce110ea1SWei Hu que_name, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Queue Name"); 280ce110ea1SWei Hu queue_list = SYSCTL_CHILDREN(queue_node); 281ce110ea1SWei Hu 282ce110ea1SWei Hu /* TX stats */ 283ce110ea1SWei Hu tx_node = SYSCTL_ADD_NODE(ctx, queue_list, OID_AUTO, 284ce110ea1SWei Hu "txq", CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "TX queue"); 285ce110ea1SWei Hu tx_list = SYSCTL_CHILDREN(tx_node); 286ce110ea1SWei Hu 287ce110ea1SWei Hu tx_stats = &txq->stats; 288ce110ea1SWei Hu 289ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, tx_list, OID_AUTO, "count", 290ce110ea1SWei Hu CTLFLAG_RD, &tx_stats->packets, "Packets sent"); 291ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, tx_list, OID_AUTO, "bytes", 292ce110ea1SWei Hu CTLFLAG_RD, &tx_stats->bytes, "Bytes sent"); 293ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, tx_list, OID_AUTO, "queue_wakeups", 294ce110ea1SWei Hu CTLFLAG_RD, &tx_stats->wakeup, "Queue wakeups"); 295ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, tx_list, OID_AUTO, "queue_stops", 296ce110ea1SWei Hu CTLFLAG_RD, &tx_stats->stop, "Queue stops"); 297ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, tx_list, OID_AUTO, "mbuf_collapse", 298ce110ea1SWei Hu CTLFLAG_RD, &tx_stats->collapse, "Mbuf collapse count"); 299ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, tx_list, OID_AUTO, 300ce110ea1SWei Hu "mbuf_collapse_err", CTLFLAG_RD, 301ce110ea1SWei Hu &tx_stats->collapse_err, "Mbuf collapse failures"); 302ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, tx_list, OID_AUTO, 303ce110ea1SWei Hu "dma_mapping_err", CTLFLAG_RD, 304ce110ea1SWei Hu &tx_stats->dma_mapping_err, "DMA mapping failures"); 305ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, tx_list, OID_AUTO, 306ce110ea1SWei Hu "alt_chg", CTLFLAG_RD, 307ce110ea1SWei Hu &tx_stats->alt_chg, "Switch to alternative txq"); 308ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, tx_list, OID_AUTO, 309ce110ea1SWei Hu "alt_reset", CTLFLAG_RD, 310ce110ea1SWei Hu &tx_stats->alt_reset, "Reset to self txq"); 311516b5059SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, tx_list, OID_AUTO, 312516b5059SWei Hu "cqe_err", CTLFLAG_RD, 313516b5059SWei Hu &tx_stats->cqe_err, "Error CQE count"); 314516b5059SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, tx_list, OID_AUTO, 315516b5059SWei Hu "cqe_unknown_type", CTLFLAG_RD, 316516b5059SWei Hu &tx_stats->cqe_unknown_type, "Unknown CQE count"); 317ce110ea1SWei Hu 318ce110ea1SWei Hu /* RX stats */ 319ce110ea1SWei Hu rx_node = SYSCTL_ADD_NODE(ctx, queue_list, OID_AUTO, 320ce110ea1SWei Hu "rxq", CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "RX queue"); 321ce110ea1SWei Hu rx_list = SYSCTL_CHILDREN(rx_node); 322ce110ea1SWei Hu 323ce110ea1SWei Hu rx_stats = &rxq->stats; 324ce110ea1SWei Hu 325ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, rx_list, OID_AUTO, "count", 326ce110ea1SWei Hu CTLFLAG_RD, &rx_stats->packets, "Packets received"); 327ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, rx_list, OID_AUTO, "bytes", 328ce110ea1SWei Hu CTLFLAG_RD, &rx_stats->bytes, "Bytes received"); 329ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, rx_list, OID_AUTO, 330ce110ea1SWei Hu "mbuf_alloc_fail", CTLFLAG_RD, 331ce110ea1SWei Hu &rx_stats->mbuf_alloc_fail, "Failed mbuf allocs"); 332ce110ea1SWei Hu SYSCTL_ADD_COUNTER_U64(ctx, rx_list, OID_AUTO, 333ce110ea1SWei Hu "dma_mapping_err", CTLFLAG_RD, 334ce110ea1SWei Hu &rx_stats->dma_mapping_err, "DMA mapping errors"); 335ce110ea1SWei Hu } 336ce110ea1SWei Hu } 337ce110ea1SWei Hu 338ce110ea1SWei Hu /* 339ce110ea1SWei Hu * Free all queues' sysctl trees attached to the port's tree. 340ce110ea1SWei Hu */ 341ce110ea1SWei Hu void 342ce110ea1SWei Hu mana_sysctl_free_queues(struct mana_port_context *apc) 343ce110ea1SWei Hu { 344ce110ea1SWei Hu sysctl_ctx_free(&apc->que_sysctl_ctx); 345ce110ea1SWei Hu } 346ce110ea1SWei Hu 347ce110ea1SWei Hu static int 348ce110ea1SWei Hu mana_sysctl_cleanup_thread_cpu(SYSCTL_HANDLER_ARGS) 349ce110ea1SWei Hu { 350ce110ea1SWei Hu struct mana_port_context *apc = arg1; 351ce110ea1SWei Hu bool bind_cpu = false; 352ce110ea1SWei Hu uint8_t val; 353ce110ea1SWei Hu int err; 354ce110ea1SWei Hu 355ce110ea1SWei Hu val = 0; 356ce110ea1SWei Hu err = sysctl_wire_old_buffer(req, sizeof(val)); 357ce110ea1SWei Hu if (err == 0) { 358ce110ea1SWei Hu val = apc->bind_cleanup_thread_cpu; 359ce110ea1SWei Hu err = sysctl_handle_8(oidp, &val, 0, req); 360ce110ea1SWei Hu } 361ce110ea1SWei Hu 362ce110ea1SWei Hu if (err != 0 || req->newptr == NULL) 363ce110ea1SWei Hu return (err); 364ce110ea1SWei Hu 365ce110ea1SWei Hu if (val != 0) 366ce110ea1SWei Hu bind_cpu = true; 367ce110ea1SWei Hu 368ce110ea1SWei Hu if (bind_cpu != apc->bind_cleanup_thread_cpu) { 369ce110ea1SWei Hu apc->bind_cleanup_thread_cpu = bind_cpu; 370ce110ea1SWei Hu err = mana_restart(apc); 371ce110ea1SWei Hu } 372ce110ea1SWei Hu 373ce110ea1SWei Hu return (err); 374ce110ea1SWei Hu } 375