1 /*- 2 * Broadcom NetXtreme-C/E network driver. 3 * 4 * Copyright (c) 2016 Broadcom, All Rights Reserved. 5 * The term Broadcom refers to Broadcom Limited and/or its subsidiaries 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS' 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 * THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #include <sys/cdefs.h> 30 __FBSDID("$FreeBSD$"); 31 32 #include <sys/types.h> 33 #include <sys/sysctl.h> 34 35 #include "bnxt.h" 36 #include "bnxt_hwrm.h" 37 #include "bnxt_sysctl.h" 38 39 static int bnxt_vlan_only_sysctl(SYSCTL_HANDLER_ARGS); 40 /* 41 * We want to create: 42 * dev.bnxt.0.hwstats.txq0 43 * dev.bnxt.0.hwstats.txq0.txmbufs 44 * dev.bnxt.0.hwstats.rxq0 45 * dev.bnxt.0.hwstats.txq0.rxmbufs 46 * so the hwstats ctx list needs to be created in attach_post and populated 47 * during init. 48 * 49 * Then, it needs to be cleaned up in stop. 50 */ 51 52 int 53 bnxt_init_sysctl_ctx(struct bnxt_softc *softc) 54 { 55 struct sysctl_ctx_list *ctx; 56 57 sysctl_ctx_init(&softc->hw_stats); 58 ctx = device_get_sysctl_ctx(softc->dev); 59 softc->hw_stats_oid = SYSCTL_ADD_NODE(ctx, 60 SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO, 61 "hwstats", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "hardware statistics"); 62 if (!softc->hw_stats_oid) { 63 sysctl_ctx_free(&softc->hw_stats); 64 return ENOMEM; 65 } 66 67 sysctl_ctx_init(&softc->ver_info->ver_ctx); 68 ctx = device_get_sysctl_ctx(softc->dev); 69 softc->ver_info->ver_oid = SYSCTL_ADD_NODE(ctx, 70 SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO, 71 "ver", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 72 "hardware/firmware version information"); 73 if (!softc->ver_info->ver_oid) { 74 sysctl_ctx_free(&softc->ver_info->ver_ctx); 75 return ENOMEM; 76 } 77 78 if (BNXT_PF(softc)) { 79 sysctl_ctx_init(&softc->nvm_info->nvm_ctx); 80 ctx = device_get_sysctl_ctx(softc->dev); 81 softc->nvm_info->nvm_oid = SYSCTL_ADD_NODE(ctx, 82 SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO, 83 "nvram", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 84 "nvram information"); 85 if (!softc->nvm_info->nvm_oid) { 86 sysctl_ctx_free(&softc->nvm_info->nvm_ctx); 87 return ENOMEM; 88 } 89 } 90 91 sysctl_ctx_init(&softc->hw_lro_ctx); 92 ctx = device_get_sysctl_ctx(softc->dev); 93 softc->hw_lro_oid = SYSCTL_ADD_NODE(ctx, 94 SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO, 95 "hw_lro", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "hardware lro"); 96 if (!softc->hw_lro_oid) { 97 sysctl_ctx_free(&softc->hw_lro_ctx); 98 return ENOMEM; 99 } 100 101 sysctl_ctx_init(&softc->flow_ctrl_ctx); 102 ctx = device_get_sysctl_ctx(softc->dev); 103 softc->flow_ctrl_oid = SYSCTL_ADD_NODE(ctx, 104 SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO, 105 "fc", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "flow ctrl"); 106 if (!softc->flow_ctrl_oid) { 107 sysctl_ctx_free(&softc->flow_ctrl_ctx); 108 return ENOMEM; 109 } 110 111 return 0; 112 } 113 114 int 115 bnxt_free_sysctl_ctx(struct bnxt_softc *softc) 116 { 117 int orc; 118 int rc = 0; 119 120 if (softc->hw_stats_oid != NULL) { 121 orc = sysctl_ctx_free(&softc->hw_stats); 122 if (orc) 123 rc = orc; 124 else 125 softc->hw_stats_oid = NULL; 126 } 127 if (softc->ver_info->ver_oid != NULL) { 128 orc = sysctl_ctx_free(&softc->ver_info->ver_ctx); 129 if (orc) 130 rc = orc; 131 else 132 softc->ver_info->ver_oid = NULL; 133 } 134 if (BNXT_PF(softc) && softc->nvm_info->nvm_oid != NULL) { 135 orc = sysctl_ctx_free(&softc->nvm_info->nvm_ctx); 136 if (orc) 137 rc = orc; 138 else 139 softc->nvm_info->nvm_oid = NULL; 140 } 141 if (softc->hw_lro_oid != NULL) { 142 orc = sysctl_ctx_free(&softc->hw_lro_ctx); 143 if (orc) 144 rc = orc; 145 else 146 softc->hw_lro_oid = NULL; 147 } 148 149 if (softc->flow_ctrl_oid != NULL) { 150 orc = sysctl_ctx_free(&softc->flow_ctrl_ctx); 151 if (orc) 152 rc = orc; 153 else 154 softc->flow_ctrl_oid = NULL; 155 } 156 157 return rc; 158 } 159 160 int 161 bnxt_create_tx_sysctls(struct bnxt_softc *softc, int txr) 162 { 163 struct sysctl_oid *oid; 164 struct ctx_hw_stats *tx_stats = (void *)softc->tx_stats.idi_vaddr; 165 char name[32]; 166 char desc[64]; 167 168 sprintf(name, "txq%d", txr); 169 sprintf(desc, "transmit queue %d", txr); 170 oid = SYSCTL_ADD_NODE(&softc->hw_stats, 171 SYSCTL_CHILDREN(softc->hw_stats_oid), OID_AUTO, name, 172 CTLFLAG_RD | CTLFLAG_MPSAFE, 0, desc); 173 if (!oid) 174 return ENOMEM; 175 176 177 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 178 "ucast_pkts", CTLFLAG_RD, &tx_stats[txr].tx_ucast_pkts, 179 "unicast packets sent"); 180 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 181 "mcast_pkts", CTLFLAG_RD, &tx_stats[txr].tx_mcast_pkts, 182 "multicast packets sent"); 183 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 184 "bcast_pkts", CTLFLAG_RD, &tx_stats[txr].tx_bcast_pkts, 185 "broadcast packets sent"); 186 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 187 "discard_pkts", CTLFLAG_RD, 188 &tx_stats[txr].tx_discard_pkts, "discarded transmit packets"); 189 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 190 "drop_pkts", CTLFLAG_RD, &tx_stats[txr].tx_drop_pkts, 191 "dropped transmit packets"); 192 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 193 "ucast_bytes", CTLFLAG_RD, &tx_stats[txr].tx_ucast_bytes, 194 "unicast bytes sent"); 195 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 196 "mcast_bytes", CTLFLAG_RD, &tx_stats[txr].tx_mcast_bytes, 197 "multicast bytes sent"); 198 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 199 "bcast_bytes", CTLFLAG_RD, &tx_stats[txr].tx_bcast_bytes, 200 "broadcast bytes sent"); 201 202 return 0; 203 } 204 205 int 206 bnxt_create_port_stats_sysctls(struct bnxt_softc *softc) 207 { 208 struct sysctl_oid *oid; 209 char name[32]; 210 char desc[64]; 211 212 sprintf(name, "port_stats"); 213 sprintf(desc, "Port Stats"); 214 oid = SYSCTL_ADD_NODE(&softc->hw_stats, 215 SYSCTL_CHILDREN(softc->hw_stats_oid), OID_AUTO, name, 216 CTLFLAG_RD | CTLFLAG_MPSAFE, 0, desc); 217 if (!oid) 218 return ENOMEM; 219 220 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 221 "tx_64b_frames", CTLFLAG_RD, 222 &softc->tx_port_stats->tx_64b_frames, "Transmitted 64b frames"); 223 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 224 "tx_65b_127b_frames", CTLFLAG_RD, 225 &softc->tx_port_stats->tx_65b_127b_frames, 226 "Transmitted 65b 127b frames"); 227 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 228 "tx_128b_255b_frames", CTLFLAG_RD, 229 &softc->tx_port_stats->tx_128b_255b_frames, 230 "Transmitted 128b 255b frames"); 231 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 232 "tx_256b_511b_frames", CTLFLAG_RD, 233 &softc->tx_port_stats->tx_256b_511b_frames, 234 "Transmitted 256b 511b frames"); 235 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 236 "tx_512b_1023b_frames", CTLFLAG_RD, 237 &softc->tx_port_stats->tx_512b_1023b_frames, 238 "Transmitted 512b 1023b frames"); 239 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 240 "tx_1024b_1518_frames", CTLFLAG_RD, 241 &softc->tx_port_stats->tx_1024b_1518_frames, 242 "Transmitted 1024b 1518 frames"); 243 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 244 "tx_good_vlan_frames", CTLFLAG_RD, 245 &softc->tx_port_stats->tx_good_vlan_frames, 246 "Transmitted good vlan frames"); 247 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 248 "tx_1519b_2047_frames", CTLFLAG_RD, 249 &softc->tx_port_stats->tx_1519b_2047_frames, 250 "Transmitted 1519b 2047 frames"); 251 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 252 "tx_2048b_4095b_frames", CTLFLAG_RD, 253 &softc->tx_port_stats->tx_2048b_4095b_frames, 254 "Transmitted 2048b 4095b frames"); 255 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 256 "tx_4096b_9216b_frames", CTLFLAG_RD, 257 &softc->tx_port_stats->tx_4096b_9216b_frames, 258 "Transmitted 4096b 9216b frames"); 259 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 260 "tx_9217b_16383b_frames", CTLFLAG_RD, 261 &softc->tx_port_stats->tx_9217b_16383b_frames, 262 "Transmitted 9217b 16383b frames"); 263 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 264 "tx_good_frames", CTLFLAG_RD, 265 &softc->tx_port_stats->tx_good_frames, "Transmitted good frames"); 266 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 267 "tx_total_frames", CTLFLAG_RD, 268 &softc->tx_port_stats->tx_total_frames, "Transmitted total frames"); 269 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 270 "tx_ucast_frames", CTLFLAG_RD, 271 &softc->tx_port_stats->tx_ucast_frames, "Transmitted ucast frames"); 272 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 273 "tx_mcast_frames", CTLFLAG_RD, 274 &softc->tx_port_stats->tx_mcast_frames, "Transmitted mcast frames"); 275 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 276 "tx_bcast_frames", CTLFLAG_RD, 277 &softc->tx_port_stats->tx_bcast_frames, "Transmitted bcast frames"); 278 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 279 "tx_pause_frames", CTLFLAG_RD, 280 &softc->tx_port_stats->tx_pause_frames, "Transmitted pause frames"); 281 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 282 "tx_pfc_frames", CTLFLAG_RD, 283 &softc->tx_port_stats->tx_pfc_frames, "Transmitted pfc frames"); 284 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 285 "tx_jabber_frames", CTLFLAG_RD, 286 &softc->tx_port_stats->tx_jabber_frames, "Transmitted jabber frames"); 287 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 288 "tx_fcs_err_frames", CTLFLAG_RD, 289 &softc->tx_port_stats->tx_fcs_err_frames, 290 "Transmitted fcs err frames"); 291 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 292 "tx_control_frames", CTLFLAG_RD, 293 &softc->tx_port_stats->tx_control_frames, 294 "Transmitted control frames"); 295 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 296 "tx_oversz_frames", CTLFLAG_RD, 297 &softc->tx_port_stats->tx_oversz_frames, "Transmitted oversz frames"); 298 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 299 "tx_single_dfrl_frames", CTLFLAG_RD, 300 &softc->tx_port_stats->tx_single_dfrl_frames, 301 "Transmitted single dfrl frames"); 302 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 303 "tx_multi_dfrl_frames", CTLFLAG_RD, 304 &softc->tx_port_stats->tx_multi_dfrl_frames, 305 "Transmitted multi dfrl frames"); 306 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 307 "tx_single_coll_frames", CTLFLAG_RD, 308 &softc->tx_port_stats->tx_single_coll_frames, 309 "Transmitted single coll frames"); 310 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 311 "tx_multi_coll_frames", CTLFLAG_RD, 312 &softc->tx_port_stats->tx_multi_coll_frames, 313 "Transmitted multi coll frames"); 314 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 315 "tx_late_coll_frames", CTLFLAG_RD, 316 &softc->tx_port_stats->tx_late_coll_frames, 317 "Transmitted late coll frames"); 318 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 319 "tx_excessive_coll_frames", CTLFLAG_RD, 320 &softc->tx_port_stats->tx_excessive_coll_frames, 321 "Transmitted excessive coll frames"); 322 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 323 "tx_frag_frames", CTLFLAG_RD, 324 &softc->tx_port_stats->tx_frag_frames, "Transmitted frag frames"); 325 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 326 "tx_err", CTLFLAG_RD, 327 &softc->tx_port_stats->tx_err, "Transmitted err"); 328 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 329 "tx_tagged_frames", CTLFLAG_RD, 330 &softc->tx_port_stats->tx_tagged_frames, "Transmitted tagged frames"); 331 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 332 "tx_dbl_tagged_frames", CTLFLAG_RD, 333 &softc->tx_port_stats->tx_dbl_tagged_frames, 334 "Transmitted dbl tagged frames"); 335 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 336 "tx_runt_frames", CTLFLAG_RD, 337 &softc->tx_port_stats->tx_runt_frames, "Transmitted runt frames"); 338 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 339 "tx_fifo_underruns", CTLFLAG_RD, 340 &softc->tx_port_stats->tx_fifo_underruns, 341 "Transmitted fifo underruns"); 342 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 343 "tx_pfc_ena_frames_pri0", CTLFLAG_RD, 344 &softc->tx_port_stats->tx_pfc_ena_frames_pri0, 345 "Transmitted pfc ena frames pri0"); 346 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 347 "tx_pfc_ena_frames_pri1", CTLFLAG_RD, 348 &softc->tx_port_stats->tx_pfc_ena_frames_pri1, 349 "Transmitted pfc ena frames pri1"); 350 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 351 "tx_pfc_ena_frames_pri2", CTLFLAG_RD, 352 &softc->tx_port_stats->tx_pfc_ena_frames_pri2, 353 "Transmitted pfc ena frames pri2"); 354 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 355 "tx_pfc_ena_frames_pri3", CTLFLAG_RD, 356 &softc->tx_port_stats->tx_pfc_ena_frames_pri3, 357 "Transmitted pfc ena frames pri3"); 358 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 359 "tx_pfc_ena_frames_pri4", CTLFLAG_RD, 360 &softc->tx_port_stats->tx_pfc_ena_frames_pri4, 361 "Transmitted pfc ena frames pri4"); 362 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 363 "tx_pfc_ena_frames_pri5", CTLFLAG_RD, 364 &softc->tx_port_stats->tx_pfc_ena_frames_pri5, 365 "Transmitted pfc ena frames pri5"); 366 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 367 "tx_pfc_ena_frames_pri6", CTLFLAG_RD, 368 &softc->tx_port_stats->tx_pfc_ena_frames_pri6, 369 "Transmitted pfc ena frames pri6"); 370 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 371 "tx_pfc_ena_frames_pri7", CTLFLAG_RD, 372 &softc->tx_port_stats->tx_pfc_ena_frames_pri7, 373 "Transmitted pfc ena frames pri7"); 374 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 375 "tx_eee_lpi_events", CTLFLAG_RD, 376 &softc->tx_port_stats->tx_eee_lpi_events, 377 "Transmitted eee lpi events"); 378 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 379 "tx_eee_lpi_duration", CTLFLAG_RD, 380 &softc->tx_port_stats->tx_eee_lpi_duration, 381 "Transmitted eee lpi duration"); 382 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 383 "tx_llfc_logical_msgs", CTLFLAG_RD, 384 &softc->tx_port_stats->tx_llfc_logical_msgs, 385 "Transmitted llfc logical msgs"); 386 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 387 "tx_hcfc_msgs", CTLFLAG_RD, 388 &softc->tx_port_stats->tx_hcfc_msgs, "Transmitted hcfc msgs"); 389 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 390 "tx_total_collisions", CTLFLAG_RD, 391 &softc->tx_port_stats->tx_total_collisions, 392 "Transmitted total collisions"); 393 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 394 "tx_bytes", CTLFLAG_RD, 395 &softc->tx_port_stats->tx_bytes, "Transmitted bytes"); 396 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 397 "tx_xthol_frames", CTLFLAG_RD, 398 &softc->tx_port_stats->tx_xthol_frames, "Transmitted xthol frames"); 399 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 400 "tx_stat_discard", CTLFLAG_RD, 401 &softc->tx_port_stats->tx_stat_discard, "Transmitted stat discard"); 402 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 403 "tx_stat_error", CTLFLAG_RD, 404 &softc->tx_port_stats->tx_stat_error, "Transmitted stat error"); 405 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 406 "rx_64b_frames", CTLFLAG_RD, 407 &softc->rx_port_stats->rx_64b_frames, "Received 64b frames"); 408 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 409 "rx_65b_127b_frames", CTLFLAG_RD, 410 &softc->rx_port_stats->rx_65b_127b_frames, "Received 65b 127b frames"); 411 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 412 "rx_128b_255b_frames", CTLFLAG_RD, 413 &softc->rx_port_stats->rx_128b_255b_frames, 414 "Received 128b 255b frames"); 415 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 416 "rx_256b_511b_frames", CTLFLAG_RD, 417 &softc->rx_port_stats->rx_256b_511b_frames, 418 "Received 256b 511b frames"); 419 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 420 "rx_512b_1023b_frames", CTLFLAG_RD, 421 &softc->rx_port_stats->rx_512b_1023b_frames, 422 "Received 512b 1023b frames"); 423 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 424 "rx_1024b_1518_frames", CTLFLAG_RD, 425 &softc->rx_port_stats->rx_1024b_1518_frames, 426 "Received 1024b 1518 frames"); 427 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 428 "rx_good_vlan_frames", CTLFLAG_RD, 429 &softc->rx_port_stats->rx_good_vlan_frames, 430 "Received good vlan frames"); 431 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 432 "rx_1519b_2047b_frames", CTLFLAG_RD, 433 &softc->rx_port_stats->rx_1519b_2047b_frames, 434 "Received 1519b 2047b frames"); 435 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 436 "rx_2048b_4095b_frames", CTLFLAG_RD, 437 &softc->rx_port_stats->rx_2048b_4095b_frames, 438 "Received 2048b 4095b frames"); 439 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 440 "rx_4096b_9216b_frames", CTLFLAG_RD, 441 &softc->rx_port_stats->rx_4096b_9216b_frames, 442 "Received 4096b 9216b frames"); 443 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 444 "rx_9217b_16383b_frames", CTLFLAG_RD, 445 &softc->rx_port_stats->rx_9217b_16383b_frames, 446 "Received 9217b 16383b frames"); 447 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 448 "rx_total_frames", CTLFLAG_RD, 449 &softc->rx_port_stats->rx_total_frames, "Received total frames"); 450 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 451 "rx_ucast_frames", CTLFLAG_RD, 452 &softc->rx_port_stats->rx_ucast_frames, "Received ucast frames"); 453 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 454 "rx_mcast_frames", CTLFLAG_RD, 455 &softc->rx_port_stats->rx_mcast_frames, "Received mcast frames"); 456 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 457 "rx_bcast_frames", CTLFLAG_RD, 458 &softc->rx_port_stats->rx_bcast_frames, "Received bcast frames"); 459 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 460 "rx_fcs_err_frames", CTLFLAG_RD, 461 &softc->rx_port_stats->rx_fcs_err_frames, "Received fcs err frames"); 462 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 463 "rx_ctrl_frames", CTLFLAG_RD, 464 &softc->rx_port_stats->rx_ctrl_frames, "Received ctrl frames"); 465 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 466 "rx_pause_frames", CTLFLAG_RD, 467 &softc->rx_port_stats->rx_pause_frames, "Received pause frames"); 468 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 469 "rx_pfc_frames", CTLFLAG_RD, 470 &softc->rx_port_stats->rx_pfc_frames, "Received pfc frames"); 471 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 472 "rx_unsupported_opcode_frames", CTLFLAG_RD, 473 &softc->rx_port_stats->rx_unsupported_opcode_frames, 474 "Received unsupported opcode frames"); 475 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 476 "rx_unsupported_da_pausepfc_frames", CTLFLAG_RD, 477 &softc->rx_port_stats->rx_unsupported_da_pausepfc_frames, 478 "Received unsupported da pausepfc frames"); 479 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 480 "rx_wrong_sa_frames", CTLFLAG_RD, 481 &softc->rx_port_stats->rx_wrong_sa_frames, 482 "Received wrong sa frames"); 483 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 484 "rx_align_err_frames", CTLFLAG_RD, 485 &softc->rx_port_stats->rx_align_err_frames, 486 "Received align err frames"); 487 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 488 "rx_oor_len_frames", CTLFLAG_RD, 489 &softc->rx_port_stats->rx_oor_len_frames, 490 "Received oor len frames"); 491 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 492 "rx_code_err_frames", CTLFLAG_RD, 493 &softc->rx_port_stats->rx_code_err_frames, 494 "Received code err frames"); 495 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 496 "rx_false_carrier_frames", CTLFLAG_RD, 497 &softc->rx_port_stats->rx_false_carrier_frames, 498 "Received false carrier frames"); 499 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 500 "rx_ovrsz_frames", CTLFLAG_RD, 501 &softc->rx_port_stats->rx_ovrsz_frames, 502 "Received ovrsz frames"); 503 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 504 "rx_jbr_frames", CTLFLAG_RD, 505 &softc->rx_port_stats->rx_jbr_frames, 506 "Received jbr frames"); 507 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 508 "rx_mtu_err_frames", CTLFLAG_RD, 509 &softc->rx_port_stats->rx_mtu_err_frames, 510 "Received mtu err frames"); 511 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 512 "rx_match_crc_frames", CTLFLAG_RD, 513 &softc->rx_port_stats->rx_match_crc_frames, 514 "Received match crc frames"); 515 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 516 "rx_promiscuous_frames", CTLFLAG_RD, 517 &softc->rx_port_stats->rx_promiscuous_frames, 518 "Received promiscuous frames"); 519 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 520 "rx_tagged_frames", CTLFLAG_RD, 521 &softc->rx_port_stats->rx_tagged_frames, 522 "Received tagged frames"); 523 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 524 "rx_double_tagged_frames", CTLFLAG_RD, 525 &softc->rx_port_stats->rx_double_tagged_frames, 526 "Received double tagged frames"); 527 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 528 "rx_trunc_frames", CTLFLAG_RD, 529 &softc->rx_port_stats->rx_trunc_frames, 530 "Received trunc frames"); 531 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 532 "rx_good_frames", CTLFLAG_RD, 533 &softc->rx_port_stats->rx_good_frames, 534 "Received good frames"); 535 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 536 "rx_pfc_xon2xoff_frames_pri0", CTLFLAG_RD, 537 &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri0, 538 "Received pfc xon2xoff frames pri0"); 539 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 540 "rx_pfc_xon2xoff_frames_pri1", CTLFLAG_RD, 541 &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri1, 542 "Received pfc xon2xoff frames pri1"); 543 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 544 "rx_pfc_xon2xoff_frames_pri2", CTLFLAG_RD, 545 &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri2, 546 "Received pfc xon2xoff frames pri2"); 547 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 548 "rx_pfc_xon2xoff_frames_pri3", CTLFLAG_RD, 549 &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri3, 550 "Received pfc xon2xoff frames pri3"); 551 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 552 "rx_pfc_xon2xoff_frames_pri4", CTLFLAG_RD, 553 &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri4, 554 "Received pfc xon2xoff frames pri4"); 555 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 556 "rx_pfc_xon2xoff_frames_pri5", CTLFLAG_RD, 557 &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri5, 558 "Received pfc xon2xoff frames pri5"); 559 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 560 "rx_pfc_xon2xoff_frames_pri6", CTLFLAG_RD, 561 &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri6, 562 "Received pfc xon2xoff frames pri6"); 563 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 564 "rx_pfc_xon2xoff_frames_pri7", CTLFLAG_RD, 565 &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri7, 566 "Received pfc xon2xoff frames pri7"); 567 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 568 "rx_pfc_ena_frames_pri0", CTLFLAG_RD, 569 &softc->rx_port_stats->rx_pfc_ena_frames_pri0, 570 "Received pfc ena frames pri0"); 571 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 572 "rx_pfc_ena_frames_pri1", CTLFLAG_RD, 573 &softc->rx_port_stats->rx_pfc_ena_frames_pri1, 574 "Received pfc ena frames pri1"); 575 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 576 "rx_pfc_ena_frames_pri2", CTLFLAG_RD, 577 &softc->rx_port_stats->rx_pfc_ena_frames_pri2, 578 "Received pfc ena frames pri2"); 579 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 580 "rx_pfc_ena_frames_pri3", CTLFLAG_RD, 581 &softc->rx_port_stats->rx_pfc_ena_frames_pri3, 582 "Received pfc ena frames pri3"); 583 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 584 "rx_pfc_ena_frames_pri4", CTLFLAG_RD, 585 &softc->rx_port_stats->rx_pfc_ena_frames_pri4, 586 "Received pfc ena frames pri4"); 587 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 588 "rx_pfc_ena_frames_pri5", CTLFLAG_RD, 589 &softc->rx_port_stats->rx_pfc_ena_frames_pri5, 590 "Received pfc ena frames pri5"); 591 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 592 "rx_pfc_ena_frames_pri6", CTLFLAG_RD, 593 &softc->rx_port_stats->rx_pfc_ena_frames_pri6, 594 "Received pfc ena frames pri6"); 595 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 596 "rx_pfc_ena_frames_pri7", CTLFLAG_RD, 597 &softc->rx_port_stats->rx_pfc_ena_frames_pri7, 598 "Received pfc ena frames pri7"); 599 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 600 "rx_sch_crc_err_frames", CTLFLAG_RD, 601 &softc->rx_port_stats->rx_sch_crc_err_frames, 602 "Received sch crc err frames"); 603 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 604 "rx_undrsz_frames", CTLFLAG_RD, 605 &softc->rx_port_stats->rx_undrsz_frames, "Received undrsz frames"); 606 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 607 "rx_frag_frames", CTLFLAG_RD, 608 &softc->rx_port_stats->rx_frag_frames, "Received frag frames"); 609 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 610 "rx_eee_lpi_events", CTLFLAG_RD, 611 &softc->rx_port_stats->rx_eee_lpi_events, "Received eee lpi events"); 612 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 613 "rx_eee_lpi_duration", CTLFLAG_RD, 614 &softc->rx_port_stats->rx_eee_lpi_duration, 615 "Received eee lpi duration"); 616 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 617 "rx_llfc_physical_msgs", CTLFLAG_RD, 618 &softc->rx_port_stats->rx_llfc_physical_msgs, 619 "Received llfc physical msgs"); 620 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 621 "rx_llfc_logical_msgs", CTLFLAG_RD, 622 &softc->rx_port_stats->rx_llfc_logical_msgs, 623 "Received llfc logical msgs"); 624 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 625 "rx_llfc_msgs_with_crc_err", CTLFLAG_RD, 626 &softc->rx_port_stats->rx_llfc_msgs_with_crc_err, 627 "Received llfc msgs with crc err"); 628 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 629 "rx_hcfc_msgs", CTLFLAG_RD, 630 &softc->rx_port_stats->rx_hcfc_msgs, "Received hcfc msgs"); 631 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 632 "rx_hcfc_msgs_with_crc_err", CTLFLAG_RD, 633 &softc->rx_port_stats->rx_hcfc_msgs_with_crc_err, 634 "Received hcfc msgs with crc err"); 635 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 636 "rx_bytes", CTLFLAG_RD, 637 &softc->rx_port_stats->rx_bytes, "Received bytes"); 638 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 639 "rx_runt_bytes", CTLFLAG_RD, 640 &softc->rx_port_stats->rx_runt_bytes, "Received runt bytes"); 641 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 642 "rx_runt_frames", CTLFLAG_RD, 643 &softc->rx_port_stats->rx_runt_frames, "Received runt frames"); 644 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 645 "rx_stat_discard", CTLFLAG_RD, 646 &softc->rx_port_stats->rx_stat_discard, "Received stat discard"); 647 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 648 "rx_stat_err", CTLFLAG_RD, 649 &softc->rx_port_stats->rx_stat_err, "Received stat err"); 650 651 return 0; 652 } 653 654 655 int 656 bnxt_create_rx_sysctls(struct bnxt_softc *softc, int rxr) 657 { 658 struct sysctl_oid *oid; 659 struct ctx_hw_stats *rx_stats = (void *)softc->rx_stats.idi_vaddr; 660 char name[32]; 661 char desc[64]; 662 663 sprintf(name, "rxq%d", rxr); 664 sprintf(desc, "receive queue %d", rxr); 665 oid = SYSCTL_ADD_NODE(&softc->hw_stats, 666 SYSCTL_CHILDREN(softc->hw_stats_oid), OID_AUTO, name, 667 CTLFLAG_RD | CTLFLAG_MPSAFE, 0, desc); 668 if (!oid) 669 return ENOMEM; 670 671 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 672 "ucast_pkts", CTLFLAG_RD, &rx_stats[rxr].rx_ucast_pkts, 673 "unicast packets received"); 674 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 675 "mcast_pkts", CTLFLAG_RD, &rx_stats[rxr].rx_mcast_pkts, 676 "multicast packets received"); 677 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 678 "bcast_pkts", CTLFLAG_RD, &rx_stats[rxr].rx_bcast_pkts, 679 "broadcast packets received"); 680 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 681 "discard_pkts", CTLFLAG_RD, 682 &rx_stats[rxr].rx_discard_pkts, "discarded receive packets"); 683 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 684 "drop_pkts", CTLFLAG_RD, &rx_stats[rxr].rx_drop_pkts, 685 "dropped receive packets"); 686 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 687 "ucast_bytes", CTLFLAG_RD, &rx_stats[rxr].rx_ucast_bytes, 688 "unicast bytes received"); 689 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 690 "mcast_bytes", CTLFLAG_RD, &rx_stats[rxr].rx_mcast_bytes, 691 "multicast bytes received"); 692 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 693 "bcast_bytes", CTLFLAG_RD, &rx_stats[rxr].rx_bcast_bytes, 694 "broadcast bytes received"); 695 696 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 697 "tpa_pkts", CTLFLAG_RD, &rx_stats[rxr].tpa_pkts, 698 "TPA packets"); 699 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 700 "tpa_bytes", CTLFLAG_RD, &rx_stats[rxr].tpa_bytes, 701 "TPA bytes"); 702 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 703 "tpa_events", CTLFLAG_RD, &rx_stats[rxr].tpa_events, 704 "TPA events"); 705 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO, 706 "tpa_aborts", CTLFLAG_RD, &rx_stats[rxr].tpa_aborts, 707 "TPA aborts"); 708 709 return 0; 710 } 711 712 static char *bnxt_chip_type[] = { 713 "ASIC", 714 "FPGA", 715 "Palladium", 716 "Unknown" 717 }; 718 #define MAX_CHIP_TYPE 3 719 720 static int 721 bnxt_package_ver_sysctl(SYSCTL_HANDLER_ARGS) 722 { 723 struct bnxt_softc *softc = arg1; 724 struct iflib_dma_info dma_data; 725 char *pkglog = NULL; 726 char *p; 727 char *next; 728 char unk[] = "<unknown>"; 729 char *buf = unk; 730 int rc; 731 int field; 732 uint16_t ordinal = BNX_DIR_ORDINAL_FIRST; 733 uint16_t index; 734 uint32_t data_len; 735 736 rc = bnxt_hwrm_nvm_find_dir_entry(softc, BNX_DIR_TYPE_PKG_LOG, 737 &ordinal, BNX_DIR_EXT_NONE, &index, false, 738 HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_EQ, 739 &data_len, NULL, NULL); 740 dma_data.idi_vaddr = NULL; 741 if (rc == 0 && data_len) { 742 rc = iflib_dma_alloc(softc->ctx, data_len, &dma_data, 743 BUS_DMA_NOWAIT); 744 if (rc == 0) { 745 rc = bnxt_hwrm_nvm_read(softc, index, 0, data_len, 746 &dma_data); 747 if (rc == 0) { 748 pkglog = dma_data.idi_vaddr; 749 /* NULL terminate (removes last \n) */ 750 pkglog[data_len-1] = 0; 751 752 /* Set p = start of last line */ 753 p = strrchr(pkglog, '\n'); 754 if (p == NULL) 755 p = pkglog; 756 757 /* Now find the correct tab delimited field */ 758 for (field = 0, next = p, 759 p = strsep(&next, "\t"); 760 field < 761 BNX_PKG_LOG_FIELD_IDX_PKG_VERSION && p; 762 p = strsep(&next, "\t")) { 763 field++; 764 } 765 if (field == BNX_PKG_LOG_FIELD_IDX_PKG_VERSION) 766 buf = p; 767 } 768 } 769 else 770 dma_data.idi_vaddr = NULL; 771 } 772 773 rc = sysctl_handle_string(oidp, buf, 0, req); 774 if (dma_data.idi_vaddr) 775 iflib_dma_free(&dma_data); 776 return rc; 777 } 778 779 static int 780 bnxt_hwrm_min_ver_sysctl(SYSCTL_HANDLER_ARGS) 781 { 782 struct bnxt_softc *softc = arg1; 783 char buf[16]; 784 uint8_t newver[3]; 785 int rc; 786 787 sprintf(buf, "%hhu.%hhu.%hhu", softc->ver_info->hwrm_min_major, 788 softc->ver_info->hwrm_min_minor, softc->ver_info->hwrm_min_update); 789 790 rc = sysctl_handle_string(oidp, buf, sizeof(buf), req); 791 if (rc || req->newptr == NULL) 792 return rc; 793 if (sscanf(buf, "%hhu.%hhu.%hhu%*c", &newver[0], &newver[1], 794 &newver[2]) != 3) 795 return EINVAL; 796 softc->ver_info->hwrm_min_major = newver[0]; 797 softc->ver_info->hwrm_min_minor = newver[1]; 798 softc->ver_info->hwrm_min_update = newver[2]; 799 bnxt_check_hwrm_version(softc); 800 801 return rc; 802 } 803 804 int 805 bnxt_create_ver_sysctls(struct bnxt_softc *softc) 806 { 807 struct bnxt_ver_info *vi = softc->ver_info; 808 struct sysctl_oid *oid = vi->ver_oid; 809 810 if (!oid) 811 return ENOMEM; 812 813 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 814 "hwrm_if", CTLFLAG_RD, vi->hwrm_if_ver, 0, 815 "HWRM interface version"); 816 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 817 "driver_hwrm_if", CTLFLAG_RD, vi->driver_hwrm_if_ver, 0, 818 "HWRM firmware version"); 819 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 820 "hwrm_fw", CTLFLAG_RD, vi->hwrm_fw_ver, 0, 821 "HWRM firmware version"); 822 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 823 "mgmt_fw", CTLFLAG_RD, vi->mgmt_fw_ver, 0, 824 "management firmware version"); 825 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 826 "netctrl_fw", CTLFLAG_RD, vi->netctrl_fw_ver, 0, 827 "network control firmware version"); 828 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 829 "roce_fw", CTLFLAG_RD, vi->roce_fw_ver, 0, 830 "RoCE firmware version"); 831 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 832 "phy", CTLFLAG_RD, vi->phy_ver, 0, 833 "PHY version"); 834 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 835 "hwrm_fw_name", CTLFLAG_RD, vi->hwrm_fw_name, 0, 836 "HWRM firmware name"); 837 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 838 "mgmt_fw_name", CTLFLAG_RD, vi->mgmt_fw_name, 0, 839 "management firmware name"); 840 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 841 "netctrl_fw_name", CTLFLAG_RD, vi->netctrl_fw_name, 0, 842 "network control firmware name"); 843 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 844 "roce_fw_name", CTLFLAG_RD, vi->roce_fw_name, 0, 845 "RoCE firmware name"); 846 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 847 "phy_vendor", CTLFLAG_RD, vi->phy_vendor, 0, 848 "PHY vendor name"); 849 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 850 "phy_partnumber", CTLFLAG_RD, vi->phy_partnumber, 0, 851 "PHY vendor part number"); 852 SYSCTL_ADD_U16(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 853 "chip_num", CTLFLAG_RD, &vi->chip_num, 0, "chip number"); 854 SYSCTL_ADD_U8(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 855 "chip_rev", CTLFLAG_RD, &vi->chip_rev, 0, "chip revision"); 856 SYSCTL_ADD_U8(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 857 "chip_metal", CTLFLAG_RD, &vi->chip_metal, 0, "chip metal number"); 858 SYSCTL_ADD_U8(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 859 "chip_bond_id", CTLFLAG_RD, &vi->chip_bond_id, 0, 860 "chip bond id"); 861 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 862 "chip_type", CTLFLAG_RD, vi->chip_type > MAX_CHIP_TYPE ? 863 bnxt_chip_type[MAX_CHIP_TYPE] : bnxt_chip_type[vi->chip_type], 0, 864 "RoCE firmware name"); 865 SYSCTL_ADD_PROC(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 866 "package_ver", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, 867 softc, 0, bnxt_package_ver_sysctl, "A", 868 "currently installed package version"); 869 SYSCTL_ADD_PROC(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 870 "hwrm_min_ver", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, 871 softc, 0, bnxt_hwrm_min_ver_sysctl, "A", 872 "minimum hwrm API vesion to support"); 873 874 return 0; 875 } 876 877 int 878 bnxt_create_nvram_sysctls(struct bnxt_nvram_info *ni) 879 { 880 struct sysctl_oid *oid = ni->nvm_oid; 881 882 if (!oid) 883 return ENOMEM; 884 885 SYSCTL_ADD_U16(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 886 "mfg_id", CTLFLAG_RD, &ni->mfg_id, 0, "manufacturer id"); 887 SYSCTL_ADD_U16(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 888 "device_id", CTLFLAG_RD, &ni->device_id, 0, "device id"); 889 SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 890 "sector_size", CTLFLAG_RD, &ni->sector_size, 0, "sector size"); 891 SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 892 "size", CTLFLAG_RD, &ni->size, 0, "nvram total size"); 893 SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 894 "reserved_size", CTLFLAG_RD, &ni->reserved_size, 0, 895 "total reserved space"); 896 SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 897 "available_size", CTLFLAG_RD, &ni->available_size, 0, 898 "total available space"); 899 900 return 0; 901 } 902 903 static int 904 bnxt_rss_key_sysctl(SYSCTL_HANDLER_ARGS) 905 { 906 struct bnxt_softc *softc = arg1; 907 char buf[HW_HASH_KEY_SIZE*2+1] = {0}; 908 char *p; 909 int i; 910 int rc; 911 912 for (p = buf, i=0; i<HW_HASH_KEY_SIZE; i++) 913 p += sprintf(p, "%02x", softc->vnic_info.rss_hash_key[i]); 914 915 rc = sysctl_handle_string(oidp, buf, sizeof(buf), req); 916 if (rc || req->newptr == NULL) 917 return rc; 918 919 if (strspn(buf, "0123456789abcdefABCDEF") != (HW_HASH_KEY_SIZE * 2)) 920 return EINVAL; 921 922 for (p = buf, i=0; i<HW_HASH_KEY_SIZE; i++) { 923 if (sscanf(p, "%02hhx", &softc->vnic_info.rss_hash_key[i]) != 1) 924 return EINVAL; 925 p += 2; 926 } 927 928 if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING) 929 bnxt_hwrm_rss_cfg(softc, &softc->vnic_info, 930 softc->vnic_info.rss_hash_type); 931 932 return rc; 933 } 934 935 static const char *bnxt_hash_types[] = {"ipv4", "tcp_ipv4", "udp_ipv4", "ipv6", 936 "tcp_ipv6", "udp_ipv6", NULL}; 937 938 static int bnxt_get_rss_type_str_bit(char *str) 939 { 940 int i; 941 942 for (i=0; bnxt_hash_types[i]; i++) 943 if (strcmp(bnxt_hash_types[i], str) == 0) 944 return i; 945 946 return -1; 947 } 948 949 static int 950 bnxt_rss_type_sysctl(SYSCTL_HANDLER_ARGS) 951 { 952 struct bnxt_softc *softc = arg1; 953 char buf[256] = {0}; 954 char *p; 955 char *next; 956 int rc; 957 int type; 958 int bit; 959 960 for (type = softc->vnic_info.rss_hash_type; type; 961 type &= ~(1<<bit)) { 962 bit = ffs(type) - 1; 963 if (bit >= sizeof(bnxt_hash_types) / sizeof(const char *)) 964 continue; 965 if (type != softc->vnic_info.rss_hash_type) 966 strcat(buf, ","); 967 strcat(buf, bnxt_hash_types[bit]); 968 } 969 970 rc = sysctl_handle_string(oidp, buf, sizeof(buf), req); 971 if (rc || req->newptr == NULL) 972 return rc; 973 974 for (type = 0, next = buf, p = strsep(&next, " ,"); p; 975 p = strsep(&next, " ,")) { 976 bit = bnxt_get_rss_type_str_bit(p); 977 if (bit == -1) 978 return EINVAL; 979 type |= 1<<bit; 980 } 981 if (type != softc->vnic_info.rss_hash_type) { 982 softc->vnic_info.rss_hash_type = type; 983 if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING) 984 bnxt_hwrm_rss_cfg(softc, &softc->vnic_info, 985 softc->vnic_info.rss_hash_type); 986 } 987 988 return rc; 989 } 990 991 static int 992 bnxt_rx_stall_sysctl(SYSCTL_HANDLER_ARGS) { 993 struct bnxt_softc *softc = arg1; 994 int rc; 995 int val; 996 997 if (softc == NULL) 998 return EBUSY; 999 1000 val = (bool)(softc->vnic_info.flags & BNXT_VNIC_FLAG_BD_STALL); 1001 rc = sysctl_handle_int(oidp, &val, 0, req); 1002 if (rc || !req->newptr) 1003 return rc; 1004 1005 if (val) 1006 softc->vnic_info.flags |= BNXT_VNIC_FLAG_BD_STALL; 1007 else 1008 softc->vnic_info.flags &= ~BNXT_VNIC_FLAG_BD_STALL; 1009 1010 if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING) 1011 rc = bnxt_hwrm_vnic_cfg(softc, &softc->vnic_info); 1012 1013 return rc; 1014 } 1015 1016 static int 1017 bnxt_vlan_strip_sysctl(SYSCTL_HANDLER_ARGS) { 1018 struct bnxt_softc *softc = arg1; 1019 int rc; 1020 int val; 1021 1022 if (softc == NULL) 1023 return EBUSY; 1024 1025 val = (bool)(softc->vnic_info.flags & BNXT_VNIC_FLAG_VLAN_STRIP); 1026 rc = sysctl_handle_int(oidp, &val, 0, req); 1027 if (rc || !req->newptr) 1028 return rc; 1029 1030 if (val) 1031 softc->vnic_info.flags |= BNXT_VNIC_FLAG_VLAN_STRIP; 1032 else 1033 softc->vnic_info.flags &= ~BNXT_VNIC_FLAG_VLAN_STRIP; 1034 1035 if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING) 1036 rc = bnxt_hwrm_vnic_cfg(softc, &softc->vnic_info); 1037 1038 return rc; 1039 } 1040 1041 static int 1042 bnxt_set_coal_rx_usecs(SYSCTL_HANDLER_ARGS) { 1043 struct bnxt_softc *softc = arg1; 1044 int rc; 1045 int val; 1046 1047 if (softc == NULL) 1048 return EBUSY; 1049 1050 val = softc->rx_coal_usecs; 1051 rc = sysctl_handle_int(oidp, &val, 0, req); 1052 if (rc || !req->newptr) 1053 return rc; 1054 1055 softc->rx_coal_usecs = val; 1056 rc = bnxt_hwrm_set_coal(softc); 1057 1058 return rc; 1059 } 1060 1061 static int 1062 bnxt_set_coal_rx_frames(SYSCTL_HANDLER_ARGS) { 1063 struct bnxt_softc *softc = arg1; 1064 int rc; 1065 int val; 1066 1067 if (softc == NULL) 1068 return EBUSY; 1069 1070 val = softc->rx_coal_frames; 1071 rc = sysctl_handle_int(oidp, &val, 0, req); 1072 if (rc || !req->newptr) 1073 return rc; 1074 1075 softc->rx_coal_frames = val; 1076 rc = bnxt_hwrm_set_coal(softc); 1077 1078 return rc; 1079 } 1080 1081 static int 1082 bnxt_set_coal_rx_usecs_irq(SYSCTL_HANDLER_ARGS) { 1083 struct bnxt_softc *softc = arg1; 1084 int rc; 1085 int val; 1086 1087 if (softc == NULL) 1088 return EBUSY; 1089 1090 val = softc->rx_coal_usecs_irq; 1091 rc = sysctl_handle_int(oidp, &val, 0, req); 1092 if (rc || !req->newptr) 1093 return rc; 1094 1095 softc->rx_coal_usecs_irq = val; 1096 rc = bnxt_hwrm_set_coal(softc); 1097 1098 return rc; 1099 } 1100 1101 static int 1102 bnxt_set_coal_rx_frames_irq(SYSCTL_HANDLER_ARGS) { 1103 struct bnxt_softc *softc = arg1; 1104 int rc; 1105 int val; 1106 1107 if (softc == NULL) 1108 return EBUSY; 1109 1110 val = softc->rx_coal_frames_irq; 1111 rc = sysctl_handle_int(oidp, &val, 0, req); 1112 if (rc || !req->newptr) 1113 return rc; 1114 1115 softc->rx_coal_frames_irq = val; 1116 rc = bnxt_hwrm_set_coal(softc); 1117 1118 return rc; 1119 } 1120 1121 static int 1122 bnxt_set_coal_tx_usecs(SYSCTL_HANDLER_ARGS) { 1123 struct bnxt_softc *softc = arg1; 1124 int rc; 1125 int val; 1126 1127 if (softc == NULL) 1128 return EBUSY; 1129 1130 val = softc->tx_coal_usecs; 1131 rc = sysctl_handle_int(oidp, &val, 0, req); 1132 if (rc || !req->newptr) 1133 return rc; 1134 1135 softc->tx_coal_usecs = val; 1136 rc = bnxt_hwrm_set_coal(softc); 1137 1138 return rc; 1139 } 1140 1141 static int 1142 bnxt_set_coal_tx_frames(SYSCTL_HANDLER_ARGS) { 1143 struct bnxt_softc *softc = arg1; 1144 int rc; 1145 int val; 1146 1147 if (softc == NULL) 1148 return EBUSY; 1149 1150 val = softc->tx_coal_frames; 1151 rc = sysctl_handle_int(oidp, &val, 0, req); 1152 if (rc || !req->newptr) 1153 return rc; 1154 1155 softc->tx_coal_frames = val; 1156 rc = bnxt_hwrm_set_coal(softc); 1157 1158 return rc; 1159 } 1160 1161 static int 1162 bnxt_set_coal_tx_usecs_irq(SYSCTL_HANDLER_ARGS) { 1163 struct bnxt_softc *softc = arg1; 1164 int rc; 1165 int val; 1166 1167 if (softc == NULL) 1168 return EBUSY; 1169 1170 val = softc->tx_coal_usecs_irq; 1171 rc = sysctl_handle_int(oidp, &val, 0, req); 1172 if (rc || !req->newptr) 1173 return rc; 1174 1175 softc->tx_coal_usecs_irq = val; 1176 rc = bnxt_hwrm_set_coal(softc); 1177 1178 return rc; 1179 } 1180 1181 static int 1182 bnxt_set_coal_tx_frames_irq(SYSCTL_HANDLER_ARGS) { 1183 struct bnxt_softc *softc = arg1; 1184 int rc; 1185 int val; 1186 1187 if (softc == NULL) 1188 return EBUSY; 1189 1190 val = softc->tx_coal_frames_irq; 1191 rc = sysctl_handle_int(oidp, &val, 0, req); 1192 if (rc || !req->newptr) 1193 return rc; 1194 1195 softc->tx_coal_frames_irq = val; 1196 rc = bnxt_hwrm_set_coal(softc); 1197 1198 return rc; 1199 } 1200 1201 int 1202 bnxt_create_config_sysctls_pre(struct bnxt_softc *softc) 1203 { 1204 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(softc->dev); 1205 struct sysctl_oid_list *children; 1206 1207 children = SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)); 1208 1209 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rss_key", 1210 CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1211 bnxt_rss_key_sysctl, "A", "RSS key"); 1212 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rss_type", 1213 CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1214 bnxt_rss_type_sysctl, "A", "RSS type bits"); 1215 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rx_stall", 1216 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1217 bnxt_rx_stall_sysctl, "I", 1218 "buffer rx packets in hardware until the host posts new buffers"); 1219 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "vlan_strip", 1220 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1221 bnxt_vlan_strip_sysctl, "I", "strip VLAN tag in the RX path"); 1222 SYSCTL_ADD_STRING(ctx, children, OID_AUTO, "if_name", CTLFLAG_RD, 1223 iflib_get_ifp(softc->ctx)->if_xname, 0, "interface name"); 1224 1225 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_usecs", 1226 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1227 bnxt_set_coal_rx_usecs, "I", "interrupt coalescing Rx Usecs"); 1228 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_frames", 1229 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1230 bnxt_set_coal_rx_frames, "I", "interrupt coalescing Rx Frames"); 1231 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_usecs_irq", 1232 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1233 bnxt_set_coal_rx_usecs_irq, "I", 1234 "interrupt coalescing Rx Usecs IRQ"); 1235 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_frames_irq", 1236 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1237 bnxt_set_coal_rx_frames_irq, "I", 1238 "interrupt coalescing Rx Frames IRQ"); 1239 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_usecs", 1240 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1241 bnxt_set_coal_tx_usecs, "I", "interrupt coalescing Tx Usces"); 1242 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_frames", 1243 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1244 bnxt_set_coal_tx_frames, "I", "interrupt coalescing Tx Frames"); 1245 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_usecs_irq", 1246 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1247 bnxt_set_coal_tx_usecs_irq, "I", 1248 "interrupt coalescing Tx Usecs IRQ"); 1249 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_frames_irq", 1250 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1251 bnxt_set_coal_tx_frames_irq, "I", 1252 "interrupt coalescing Tx Frames IRQ"); 1253 1254 return 0; 1255 } 1256 1257 #define BNXT_HW_LRO_FN(fn_name, arg) \ 1258 static int \ 1259 fn_name(SYSCTL_HANDLER_ARGS) { \ 1260 struct bnxt_softc *softc = arg1; \ 1261 int rc; \ 1262 int val; \ 1263 \ 1264 if (softc == NULL) \ 1265 return EBUSY; \ 1266 \ 1267 val = softc->hw_lro.arg; \ 1268 rc = sysctl_handle_int(oidp, &val, 0, req); \ 1269 if (rc || !req->newptr) \ 1270 return rc; \ 1271 \ 1272 if ((if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING)) \ 1273 return EBUSY; \ 1274 \ 1275 softc->hw_lro.arg = val; \ 1276 bnxt_validate_hw_lro_settings(softc); \ 1277 rc = bnxt_hwrm_vnic_tpa_cfg(softc); \ 1278 \ 1279 return rc; \ 1280 } 1281 1282 BNXT_HW_LRO_FN(bnxt_hw_lro_enable_disable, enable) 1283 BNXT_HW_LRO_FN(bnxt_hw_lro_set_mode, is_mode_gro) 1284 BNXT_HW_LRO_FN(bnxt_hw_lro_set_max_agg_segs, max_agg_segs) 1285 BNXT_HW_LRO_FN(bnxt_hw_lro_set_max_aggs, max_aggs) 1286 BNXT_HW_LRO_FN(bnxt_hw_lro_set_min_agg_len, min_agg_len) 1287 1288 #define BNXT_FLOW_CTRL_FN(fn_name, arg) \ 1289 static int \ 1290 fn_name(SYSCTL_HANDLER_ARGS) { \ 1291 struct bnxt_softc *softc = arg1; \ 1292 int rc; \ 1293 int val; \ 1294 \ 1295 if (softc == NULL) \ 1296 return EBUSY; \ 1297 \ 1298 val = softc->link_info.flow_ctrl.arg; \ 1299 rc = sysctl_handle_int(oidp, &val, 0, req); \ 1300 if (rc || !req->newptr) \ 1301 return rc; \ 1302 \ 1303 if (val) \ 1304 val = 1; \ 1305 \ 1306 if (softc->link_info.flow_ctrl.arg != val) { \ 1307 softc->link_info.flow_ctrl.arg = val; \ 1308 rc = bnxt_hwrm_set_link_setting(softc, true, false, false);\ 1309 rc = bnxt_hwrm_port_phy_qcfg(softc); \ 1310 } \ 1311 \ 1312 return rc; \ 1313 } 1314 1315 BNXT_FLOW_CTRL_FN(bnxt_flow_ctrl_tx, tx) 1316 BNXT_FLOW_CTRL_FN(bnxt_flow_ctrl_rx, rx) 1317 BNXT_FLOW_CTRL_FN(bnxt_flow_ctrl_autoneg, autoneg) 1318 int 1319 bnxt_create_pause_fc_sysctls(struct bnxt_softc *softc) 1320 { 1321 struct sysctl_oid *oid = softc->flow_ctrl_oid; 1322 1323 if (!oid) 1324 return ENOMEM; 1325 1326 SYSCTL_ADD_PROC(&softc->flow_ctrl_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 1327 "tx", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1328 bnxt_flow_ctrl_tx, "A", "Enable or Disable Tx Flow Ctrl: 0 / 1"); 1329 1330 SYSCTL_ADD_PROC(&softc->flow_ctrl_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 1331 "rx", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1332 bnxt_flow_ctrl_rx, "A", "Enable or Disable Tx Flow Ctrl: 0 / 1"); 1333 1334 SYSCTL_ADD_PROC(&softc->flow_ctrl_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 1335 "autoneg", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 1336 0, bnxt_flow_ctrl_autoneg, "A", 1337 "Enable or Disable Autoneg Flow Ctrl: 0 / 1"); 1338 1339 return 0; 1340 } 1341 1342 int 1343 bnxt_create_hw_lro_sysctls(struct bnxt_softc *softc) 1344 { 1345 struct sysctl_oid *oid = softc->hw_lro_oid; 1346 1347 if (!oid) 1348 return ENOMEM; 1349 1350 SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 1351 "enable", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 1352 0, bnxt_hw_lro_enable_disable, "A", 1353 "Enable or Disable HW LRO: 0 / 1"); 1354 1355 SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 1356 "gro_mode", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 1357 0, bnxt_hw_lro_set_mode, "A", 1358 "Set mode: 1 = GRO mode, 0 = RSC mode"); 1359 1360 SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 1361 "max_agg_segs", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, 1362 softc, 0, bnxt_hw_lro_set_max_agg_segs, "A", 1363 "Set Max Agg Seg Value (unit is Log2): " 1364 "0 (= 1 seg) / 1 (= 2 segs) / ... / 31 (= 2^31 segs)"); 1365 1366 SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 1367 "max_aggs", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, 1368 softc, 0, bnxt_hw_lro_set_max_aggs, "A", 1369 "Set Max Aggs Value (unit is Log2): " 1370 "0 (= 1 agg) / 1 (= 2 aggs) / ... / 7 (= 2^7 segs)"); 1371 1372 SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 1373 "min_agg_len", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, 1374 softc, 0, bnxt_hw_lro_set_min_agg_len, "A", 1375 "Min Agg Len: 1 to 9000"); 1376 1377 return 0; 1378 } 1379 static int 1380 bnxt_vlan_only_sysctl(SYSCTL_HANDLER_ARGS) { 1381 struct bnxt_softc *softc = arg1; 1382 int rc; 1383 int val; 1384 1385 if (softc == NULL) 1386 return EBUSY; 1387 1388 val = softc->vnic_info.vlan_only; 1389 rc = sysctl_handle_int(oidp, &val, 0, req); 1390 if (rc || !req->newptr) 1391 return rc; 1392 1393 if (val) 1394 val = 1; 1395 1396 if (val != softc->vnic_info.vlan_only) { 1397 softc->vnic_info.vlan_only = val; 1398 if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING) 1399 rc = bnxt_hwrm_cfa_l2_set_rx_mask(softc, 1400 &softc->vnic_info); 1401 } 1402 1403 return rc; 1404 } 1405 1406 int 1407 bnxt_create_config_sysctls_post(struct bnxt_softc *softc) 1408 { 1409 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(softc->dev); 1410 struct sysctl_oid_list *children; 1411 1412 children = SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)); 1413 1414 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "vlan_only", 1415 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, softc, 0, 1416 bnxt_vlan_only_sysctl, "I", 1417 "require vlan tag on received packets when vlan is enabled"); 1418 1419 return 0; 1420 } 1421