1/*-
2 * Copyright (C) 2013 Emulex
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the Emulex Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * Contact Information:
32 * freebsd-drivers@emulex.com
33 *
34 * Emulex
35 * 3333 Susan Street
36 * Costa Mesa, CA 92626
37 */
38
39/* $FreeBSD: head/sys/dev/oce/oce_sysctl.c 252869 2013-07-06 08:30:45Z delphij $ */
40
41
42#include "oce_if.h"
43
44static void copy_stats_to_sc_xe201(POCE_SOFTC sc);
45static void copy_stats_to_sc_be3(POCE_SOFTC sc);
46static void copy_stats_to_sc_be2(POCE_SOFTC sc);
47static int oce_sysctl_loopback(SYSCTL_HANDLER_ARGS);
48static int oce_be3_fwupgrade(POCE_SOFTC sc, const struct firmware *fw);
49static int oce_sys_fwupgrade(SYSCTL_HANDLER_ARGS);
50static int oce_be3_flashdata(POCE_SOFTC sc, const struct firmware
51 *fw, int num_imgs);
52static int oce_lancer_fwupgrade(POCE_SOFTC sc, const struct firmware *fw);
53static int oce_sysctl_sfp_vpd_dump(SYSCTL_HANDLER_ARGS);
54static boolean_t oce_phy_flashing_required(POCE_SOFTC sc);
55static boolean_t oce_img_flashing_required(POCE_SOFTC sc, const char *p,
56 int img_optype, uint32_t img_offset,
57 uint32_t img_size, uint32_t hdrs_size);
58static void oce_add_stats_sysctls_be3(POCE_SOFTC sc,
59 struct sysctl_ctx_list *ctx,
60 struct sysctl_oid *stats_node);
61static void oce_add_stats_sysctls_xe201(POCE_SOFTC sc,
62 struct sysctl_ctx_list *ctx,
63 struct sysctl_oid *stats_node);
64
65extern char component_revision[32];
66uint32_t sfp_vpd_dump_buffer[TRANSCEIVER_DATA_NUM_ELE];
67
68void
69oce_add_sysctls(POCE_SOFTC sc)
70{
71
72 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->dev);
73 struct sysctl_oid *tree = device_get_sysctl_tree(sc->dev);
74 struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
75 struct sysctl_oid *stats_node;
76
77 SYSCTL_ADD_STRING(ctx, child,
78 OID_AUTO, "component_revision",
79 CTLTYPE_INT | CTLFLAG_RD,
80 &component_revision,
81 sizeof(component_revision),
82 "EMULEX One-Connect device driver revision");
83
84 SYSCTL_ADD_STRING(ctx, child,
85 OID_AUTO, "firmware_version",
86 CTLTYPE_INT | CTLFLAG_RD,
87 &sc->fw_version,
88 sizeof(sc->fw_version),
89 "EMULEX One-Connect Firmware Version");
90
91 SYSCTL_ADD_INT(ctx, child,
92 OID_AUTO, "max_rsp_handled",
93 CTLTYPE_INT | CTLFLAG_RW,
94 &oce_max_rsp_handled,
95 sizeof(oce_max_rsp_handled),
96 "Maximum receive frames handled per interupt");
97
98 if ((sc->function_mode & FNM_FLEX10_MODE) ||
99 (sc->function_mode & FNM_UMC_MODE))
100 SYSCTL_ADD_UINT(ctx, child,
101 OID_AUTO, "speed",
102 CTLFLAG_RD,
103 &sc->qos_link_speed,
104 0,"QOS Speed");
105 else
106 SYSCTL_ADD_UINT(ctx, child,
107 OID_AUTO, "speed",
108 CTLFLAG_RD,
109 &sc->speed,
110 0,"Link Speed");
111
112 if (sc->function_mode & FNM_UMC_MODE)
113 SYSCTL_ADD_UINT(ctx, child,
114 OID_AUTO, "pvid",
115 CTLFLAG_RD,
116 &sc->pvid,
117 0,"PVID");
118
119 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "loop_back",
120 CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0,
121 oce_sysctl_loopback, "I", "Loop Back Tests");
122
123 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "fw_upgrade",
124 CTLTYPE_STRING | CTLFLAG_RW, (void *)sc, 0,
125 oce_sys_fwupgrade, "A", "Firmware ufi file");
126
127 /*
128 * Dumps Transceiver data
129 * "sysctl dev.oce.0.sfp_vpd_dump=0"
130 * "sysctl -x dev.oce.0.sfp_vpd_dump_buffer" for hex dump
131 * "sysctl -b dev.oce.0.sfp_vpd_dump_buffer > sfp.bin" for binary dump
132 */
133 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "sfp_vpd_dump",
134 CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, oce_sysctl_sfp_vpd_dump,
135 "I", "Initiate a sfp_vpd_dump operation");
136 SYSCTL_ADD_OPAQUE(ctx, child, OID_AUTO, "sfp_vpd_dump_buffer",
137 CTLFLAG_RD, sfp_vpd_dump_buffer,
138 TRANSCEIVER_DATA_SIZE, "IU", "Access sfp_vpd_dump buffer");
139
140 stats_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats",
141 CTLFLAG_RD, NULL, "Ethernet Statistics");
142
143 if (IS_BE(sc) || IS_SH(sc))
144 oce_add_stats_sysctls_be3(sc, ctx, stats_node);
145 else
146 oce_add_stats_sysctls_xe201(sc, ctx, stats_node);
147
148
149}
150
151
152static uint32_t
153oce_loopback_test(struct oce_softc *sc, uint8_t loopback_type)
154{
155 uint32_t status = 0;
156
157 oce_mbox_cmd_set_loopback(sc, sc->if_id, loopback_type, 1);
158 status = oce_mbox_cmd_test_loopback(sc, sc->if_id, loopback_type,
159 1500, 2, 0xabc);
160 oce_mbox_cmd_set_loopback(sc, sc->if_id, OCE_NO_LOOPBACK, 1);
161
162 return status;
163}
164
165static int
166oce_sysctl_loopback(SYSCTL_HANDLER_ARGS)
167{
168 int value = 0;
169 uint32_t status;
170 struct oce_softc *sc = (struct oce_softc *)arg1;
171
172 status = sysctl_handle_int(oidp, &value, 0, req);
173 if (status || !req->newptr)
174 return status;
175
176 if (value != 1) {
177 device_printf(sc->dev,
178 "Not a Valid value. Set to loop_back=1 to run tests\n");
179 return 0;
180 }
181
182 if ((status = oce_loopback_test(sc, OCE_MAC_LOOPBACK))) {
183 device_printf(sc->dev,
184 "MAC Loopback Test = Failed (Error status = %d)\n",
185 status);
186 } else
187 device_printf(sc->dev, "MAC Loopback Test = Success\n");
188
189 if ((status = oce_loopback_test(sc, OCE_PHY_LOOPBACK))) {
190 device_printf(sc->dev,
191 "PHY Loopback Test = Failed (Error status = %d)\n",
192 status);
193 } else
194 device_printf(sc->dev, "PHY Loopback Test = Success\n");
195
196 if ((status = oce_loopback_test(sc, OCE_ONE_PORT_EXT_LOOPBACK))) {
197 device_printf(sc->dev,
198 "EXT Loopback Test = Failed (Error status = %d)\n",
199 status);
200 } else
201 device_printf(sc->dev, "EXT Loopback Test = Success\n");
202
203 return 0;
204}
205
206
207static int
208oce_sys_fwupgrade(SYSCTL_HANDLER_ARGS)
209{
210 char ufiname[256] = {0};
211 uint32_t status = 1;
212 struct oce_softc *sc = (struct oce_softc *)arg1;
213 const struct firmware *fw;
214
215 status = sysctl_handle_string(oidp, ufiname, sizeof(ufiname), req);
216 if (status || !req->newptr)
217 return status;
218
219 fw = firmware_get(ufiname);
220 if (fw == NULL) {
221 device_printf(sc->dev, "Unable to get Firmware. "
222 "Make sure %s is copied to /boot/modules\n", ufiname);
223 return ENOENT;
224 }
225
226 if (IS_BE(sc) || IS_SH(sc)) {
227 if ((sc->flags & OCE_FLAGS_BE2)) {
228 device_printf(sc->dev,
229 "Flashing not supported for BE2 yet.\n");
230 status = 1;
231 goto done;
232 }
233 status = oce_be3_fwupgrade(sc, fw);
234 } else
235 status = oce_lancer_fwupgrade(sc, fw);
236done:
237 if (status) {
238 device_printf(sc->dev, "Firmware Upgrade failed\n");
239 } else {
240 device_printf(sc->dev, "Firmware Flashed successfully\n");
241 }
242
243 /* Release Firmware*/
244 firmware_put(fw, FIRMWARE_UNLOAD);
245
246 return status;
247}
248
249
250static int
251oce_be3_fwupgrade(POCE_SOFTC sc, const struct firmware *fw)
252{
253 int rc = 0, num_imgs = 0, i = 0;
254 const struct flash_file_hdr *fhdr;
255 const struct image_hdr *img_ptr;
256
257 fhdr = (const struct flash_file_hdr *)fw->data;
258 if (fhdr->build[0] != '3') {
259 device_printf(sc->dev, "Invalid BE3 firmware image\n");
260 return EINVAL;
261 }
262 /* Display flash version */
263 device_printf(sc->dev, "Flashing Firmware %s\n", &fhdr->build[2]);
264
265 num_imgs = fhdr->num_imgs;
266 for (i = 0; i < num_imgs; i++) {
267 img_ptr = (const struct image_hdr *)((const char *)fw->data +
268 sizeof(struct flash_file_hdr) +
269 (i * sizeof(struct image_hdr)));
270 if (img_ptr->imageid == 1) {
271 rc = oce_be3_flashdata(sc, fw, num_imgs);
272 break;
273 }
274 }
275
276 return rc;
277}
278
279
280static int
281oce_be3_flashdata(POCE_SOFTC sc, const struct firmware *fw, int num_imgs)
282{
283 char cookie[2][16] = {"*** SE FLAS", "H DIRECTORY *** "};
284 const char *p = (const char *)fw->data;
285 const struct flash_sec_info *fsec = NULL;
286 struct mbx_common_read_write_flashrom *req;
287 int rc = 0, i, img_type, bin_offset = 0;
288 boolean_t skip_image;
289 uint32_t optype = 0, size = 0, start = 0, num_bytes = 0;
290 uint32_t opcode = 0;
291 OCE_DMA_MEM dma_mem;
292
293 /* Validate Cookie */
294 bin_offset = (sizeof(struct flash_file_hdr) +
295 (num_imgs * sizeof(struct image_hdr)));
296 p += bin_offset;
297 while (p < ((const char *)fw->data + fw->datasize)) {
298 fsec = (const struct flash_sec_info *)p;
299 if (!memcmp(cookie, fsec->cookie, sizeof(cookie)))
300 break;
301 fsec = NULL;
302 p += 32;
303 }
304
305 if (!fsec) {
306 device_printf(sc->dev,
307 "Invalid Cookie. Firmware image corrupted ?\n");
308 return EINVAL;
309 }
310
311 rc = oce_dma_alloc(sc, sizeof(struct mbx_common_read_write_flashrom)
312 + 32*1024, &dma_mem, 0);
313 if (rc) {
314 device_printf(sc->dev,
315 "Memory allocation failure while flashing\n");
316 return ENOMEM;
317 }
318 req = OCE_DMAPTR(&dma_mem, struct mbx_common_read_write_flashrom);
319
320 for (i = 0; i < MAX_FLASH_COMP; i++) {
321
322 img_type = fsec->fsec_entry[i].type;
323 skip_image = FALSE;
324 switch (img_type) {
325 case IMG_ISCSI:
326 optype = 0;
327 size = 2097152;
328 start = 2097152;
329 break;
330 case IMG_REDBOOT:
331 optype = 1;
332 size = 1048576;
333 start = 262144;
334 if (!oce_img_flashing_required(sc, fw->data,
335 optype, start, size, bin_offset))
336 skip_image = TRUE;
337 break;
338 case IMG_BIOS:
339 optype = 2;
340 size = 524288;
341 start = 12582912;
342 break;
343 case IMG_PXEBIOS:
344 optype = 3;
345 size = 524288;
346 start = 13107200;
347 break;
348 case IMG_FCOEBIOS:
349 optype = 8;
350 size = 524288;
351 start = 13631488;
352 break;
353 case IMG_ISCSI_BAK:
354 optype = 9;
355 size = 2097152;
356 start = 4194304;
357 break;
358 case IMG_FCOE:
359 optype = 10;
360 size = 2097152;
361 start = 6291456;
362 break;
363 case IMG_FCOE_BAK:
364 optype = 11;
365 size = 2097152;
366 start = 8388608;
367 break;
368 case IMG_NCSI:
369 optype = 13;
370 size = 262144;
371 start = 15990784;
372 break;
373 case IMG_PHY:
374 optype = 99;
375 size = 262144;
376 start = 1310720;
377 if (!oce_phy_flashing_required(sc))
378 skip_image = TRUE;
379 break;
380 default:
381 skip_image = TRUE;
382 break;
383 }
384 if (skip_image)
385 continue;
386
387 p = fw->data;
388 p = p + bin_offset + start;
389 if ((p + size) > ((const char *)fw->data + fw->datasize)) {
390 rc = 1;
391 goto ret;
392 }
393
394 while (size) {
395
396 if (size > 32*1024)
397 num_bytes = 32*1024;
398 else
399 num_bytes = size;
400 size -= num_bytes;
401
402 if (!size)
403 opcode = FLASHROM_OPER_FLASH;
404 else
405 opcode = FLASHROM_OPER_SAVE;
406
407 memcpy(req->data_buffer, p, num_bytes);
408 p += num_bytes;
409
410 rc = oce_mbox_write_flashrom(sc, optype, opcode,
411 &dma_mem, num_bytes);
412 if (rc) {
413 device_printf(sc->dev,
414 "cmd to write to flash rom failed.\n");
415 rc = EIO;
416 goto ret;
417 }
418 /* Leave the CPU for others for some time */
419 pause("yield", 10);
420
421 }
422 }
423ret:
424 oce_dma_free(sc, &dma_mem);
425 return rc;
426
427}
428
429
430static boolean_t
431oce_phy_flashing_required(POCE_SOFTC sc)
432{
433 int status = 0;
434 struct oce_phy_info phy_info;
435
436 status = oce_mbox_get_phy_info(sc, &phy_info);
437 if (status)
438 return FALSE;
439
440 if ((phy_info.phy_type == TN_8022) &&
441 (phy_info.interface_type == PHY_TYPE_BASET_10GB)) {
442 return TRUE;
443 }
444
445 return FALSE;
446}
447
448
449static boolean_t
450oce_img_flashing_required(POCE_SOFTC sc, const char *p,
451 int img_optype, uint32_t img_offset,
452 uint32_t img_size, uint32_t hdrs_size)
453{
454 uint32_t crc_offset;
455 uint8_t flashed_crc[4];
456 int status;
457
458 crc_offset = hdrs_size + img_offset + img_size - 4;
459
460 p += crc_offset;
461
462 status = oce_mbox_get_flashrom_crc(sc, flashed_crc,
463 (img_size - 4), img_optype);
464 if (status)
465 return TRUE; /* Some thing worng. ReFlash */
466
467 /*update redboot only if crc does not match*/
468 if (bcmp(flashed_crc, p, 4))
469 return TRUE;
470 else
471 return FALSE;
472}
473
474
475static int
476oce_lancer_fwupgrade(POCE_SOFTC sc, const struct firmware *fw)
477{
478
479 int rc = 0;
480 OCE_DMA_MEM dma_mem;
481 const uint8_t *data = NULL;
482 uint8_t *dest_image_ptr = NULL;
483 size_t size = 0;
484 uint32_t data_written = 0, chunk_size = 0;
485 uint32_t offset = 0, add_status = 0;
486
487 if (!IS_ALIGNED(fw->datasize, sizeof(uint32_t))) {
488 device_printf(sc->dev,
489 "Lancer FW image is not 4 byte aligned.");
490 return EINVAL;
491 }
492
493 rc = oce_dma_alloc(sc, 32*1024, &dma_mem, 0);
494 if (rc) {
495 device_printf(sc->dev,
496 "Memory allocation failure while flashing Lancer\n");
497 return ENOMEM;
498 }
499
500 size = fw->datasize;
501 data = fw->data;
502 dest_image_ptr = OCE_DMAPTR(&dma_mem, uint8_t);
503
504 while (size) {
505 chunk_size = MIN(size, (32*1024));
506
507 bcopy(data, dest_image_ptr, chunk_size);
508
509 rc = oce_mbox_lancer_write_flashrom(sc, chunk_size, offset,
510 &dma_mem, &data_written, &add_status);
511
512 if (rc)
513 break;
514
515 size -= data_written;
516 data += data_written;
517 offset += data_written;
518 pause("yield", 10);
519
520 }
521
522 if (!rc)
523 /* Commit the firmware*/
524 rc = oce_mbox_lancer_write_flashrom(sc, 0, offset, &dma_mem,
525 &data_written, &add_status);
526 if (rc) {
527 device_printf(sc->dev, "Lancer firmware load error. "
528 "Addstatus = 0x%x, status = %d \n", add_status, rc);
529 rc = EIO;
530 }
531 oce_dma_free(sc, &dma_mem);
532 return rc;
533
534}
535
536
537static void
538oce_add_stats_sysctls_be3(POCE_SOFTC sc,
539 struct sysctl_ctx_list *ctx,
540 struct sysctl_oid *stats_node)
541{
542 struct sysctl_oid *rx_stats_node, *tx_stats_node;
543 struct sysctl_oid_list *rx_stat_list, *tx_stat_list;
544 struct sysctl_oid_list *queue_stats_list;
545 struct sysctl_oid *queue_stats_node;
546 struct oce_drv_stats *stats;
547 char prefix[32];
548 int i;
549
550 stats = &sc->oce_stats_info;
551
552 rx_stats_node = SYSCTL_ADD_NODE(ctx,
553 SYSCTL_CHILDREN(stats_node),
554 OID_AUTO,"rx", CTLFLAG_RD,
555 NULL, "RX Ethernet Statistics");
556 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
557
558
559 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_pkts",
560 CTLFLAG_RD, &stats->rx.t_rx_pkts,
561 "Total Received Packets");
562 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_bytes",
563 CTLFLAG_RD, &stats->rx.t_rx_bytes,
564 "Total Received Bytes");
565 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags",
566 CTLFLAG_RD, &stats->rx.t_rx_frags, 0,
567 "Total Received Fragements");
568 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts",
569 CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0,
570 "Total Received Multicast Packets");
571 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_ucast_pkts",
572 CTLFLAG_RD, &stats->rx.t_rx_ucast_pkts, 0,
573 "Total Received Unicast Packets");
574 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_rxcp_errs",
575 CTLFLAG_RD, &stats->rx.t_rxcp_errs, 0,
576 "Total Receive completion errors");
577 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pause_frames",
578 CTLFLAG_RD, &stats->u0.be.rx_pause_frames, 0,
579 "Pause Frames");
580 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "priority_pause_frames",
581 CTLFLAG_RD, &stats->u0.be.rx_priority_pause_frames, 0,
582 "Priority Pause Frames");
583 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "control_frames",
584 CTLFLAG_RD, &stats->u0.be.rx_control_frames, 0,
585 "Control Frames");
586
587 for (i = 0; i < sc->nrqs; i++) {
588 sprintf(prefix, "queue%d",i);
589 queue_stats_node = SYSCTL_ADD_NODE(ctx,
590 SYSCTL_CHILDREN(rx_stats_node),
591 OID_AUTO, prefix, CTLFLAG_RD,
592 NULL, "Queue name");
593 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
594
595 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_pkts",
596 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_pkts,
597 "Receive Packets");
598 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes",
599 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes,
600 "Recived Bytes");
601 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags",
602 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0,
603 "Received Fragments");
604 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
605 "rx_mcast_pkts", CTLFLAG_RD,
606 &sc->rq[i]->rx_stats.rx_mcast_pkts, 0,
607 "Received Multicast Packets");
608 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
609 "rx_ucast_pkts", CTLFLAG_RD,
610 &sc->rq[i]->rx_stats.rx_ucast_pkts, 0,
611 "Received Unicast Packets");
612 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rxcp_err",
613 CTLFLAG_RD, &sc->rq[i]->rx_stats.rxcp_err, 0,
614 "Received Completion Errors");
615
616 }
617
618 rx_stats_node = SYSCTL_ADD_NODE(ctx,
619 SYSCTL_CHILDREN(rx_stats_node),
620 OID_AUTO, "err", CTLFLAG_RD,
621 NULL, "Receive Error Stats");
622 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
623
624 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "crc_errs",
625 CTLFLAG_RD, &stats->u0.be.rx_crc_errors, 0,
626 "CRC Errors");
627 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pbuf_errors",
628 CTLFLAG_RD, &stats->u0.be.rx_drops_no_pbuf, 0,
629 "Drops due to pbuf full");
630 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "erx_errors",
631 CTLFLAG_RD, &stats->u0.be.rx_drops_no_erx_descr, 0,
632 "ERX Errors");
633 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors",
634 CTLFLAG_RD, &stats->u0.be.rx_drops_too_many_frags, 0,
635 "RX Alignmnet Errors");
636 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors",
637 CTLFLAG_RD, &stats->u0.be.rx_in_range_errors, 0,
638 "In Range Errors");
639 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "out_range_errors",
640 CTLFLAG_RD, &stats->u0.be.rx_out_range_errors, 0,
641 "Out Range Errors");
642 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "frame_too_long",
643 CTLFLAG_RD, &stats->u0.be.rx_frame_too_long, 0,
644 "Frame Too Long");
645 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "address_match_errors",
646 CTLFLAG_RD, &stats->u0.be.rx_address_match_errors, 0,
647 "Address Match Errors");
648 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_small",
649 CTLFLAG_RD, &stats->u0.be.rx_dropped_too_small, 0,
650 "Dropped Too Small");
651 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_short",
652 CTLFLAG_RD, &stats->u0.be.rx_dropped_too_short, 0,
653 "Dropped Too Short");
654 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
655 "dropped_header_too_small", CTLFLAG_RD,
656 &stats->u0.be.rx_dropped_header_too_small, 0,
657 "Dropped Header Too Small");
658 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_tcp_length",
659 CTLFLAG_RD, &stats->u0.be.rx_dropped_tcp_length, 0,
660 "Dropped TCP Length");
661 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_runt",
662 CTLFLAG_RD, &stats->u0.be.rx_dropped_runt, 0,
663 "Dropped runt");
664 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "ip_checksum_errs",
665 CTLFLAG_RD, &stats->u0.be.rx_ip_checksum_errs, 0,
666 "IP Checksum Errors");
667 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "tcp_checksum_errs",
668 CTLFLAG_RD, &stats->u0.be.rx_tcp_checksum_errs, 0,
669 "TCP Checksum Errors");
670 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "udp_checksum_errs",
671 CTLFLAG_RD, &stats->u0.be.rx_udp_checksum_errs, 0,
672 "UDP Checksum Errors");
673 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "fifo_overflow_drop",
674 CTLFLAG_RD, &stats->u0.be.rxpp_fifo_overflow_drop, 0,
675 "FIFO Overflow Drop");
676 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
677 "input_fifo_overflow_drop", CTLFLAG_RD,
678 &stats->u0.be.rx_input_fifo_overflow_drop, 0,
679 "Input FIFO Overflow Drop");
680
681 tx_stats_node = SYSCTL_ADD_NODE(ctx,
682 SYSCTL_CHILDREN(stats_node), OID_AUTO,
683 "tx",CTLFLAG_RD, NULL,
684 "TX Ethernet Statistics");
685 tx_stat_list = SYSCTL_CHILDREN(tx_stats_node);
686
687 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_pkts",
688 CTLFLAG_RD, &stats->tx.t_tx_pkts,
689 "Total Transmit Packets");
690 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_bytes",
691 CTLFLAG_RD, &stats->tx.t_tx_bytes,
692 "Total Transmit Bytes");
693 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_reqs",
694 CTLFLAG_RD, &stats->tx.t_tx_reqs, 0,
695 "Total Transmit Requests");
696 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_stops",
697 CTLFLAG_RD, &stats->tx.t_tx_stops, 0,
698 "Total Transmit Stops");
699 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_wrbs",
700 CTLFLAG_RD, &stats->tx.t_tx_wrbs, 0,
701 "Total Transmit WRB's");
702 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_compl",
703 CTLFLAG_RD, &stats->tx.t_tx_compl, 0,
704 "Total Transmit Completions");
705 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO,
706 "total_ipv6_ext_hdr_tx_drop", CTLFLAG_RD,
707 &stats->tx.t_ipv6_ext_hdr_tx_drop, 0,
708 "Total Transmit IPV6 Drops");
709 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "pauseframes",
710 CTLFLAG_RD, &stats->u0.be.tx_pauseframes, 0,
711 "Pause Frames");
712 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "priority_pauseframes",
713 CTLFLAG_RD, &stats->u0.be.tx_priority_pauseframes, 0,
714 "Priority Pauseframes");
715 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "controlframes",
716 CTLFLAG_RD, &stats->u0.be.tx_controlframes, 0,
717 "Tx Control Frames");
718
719 for (i = 0; i < sc->nwqs; i++) {
720 sprintf(prefix, "queue%d",i);
721 queue_stats_node = SYSCTL_ADD_NODE(ctx,
722 SYSCTL_CHILDREN(tx_stats_node),
723 OID_AUTO, prefix, CTLFLAG_RD,
724 NULL, "Queue name");
725 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
726
727 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_pkts",
728 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_pkts,
729 "Transmit Packets");
730 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_bytes",
731 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_bytes,
732 "Transmit Bytes");
733 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_reqs",
734 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_reqs, 0,
735 "Transmit Requests");
736 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_stops",
737 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_stops, 0,
738 "Transmit Stops");
739 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_wrbs",
740 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_wrbs, 0,
741 "Transmit WRB's");
742 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_compl",
743 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_compl, 0,
744 "Transmit Completions");
745 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
746 "ipv6_ext_hdr_tx_drop",CTLFLAG_RD,
747 &sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop, 0,
748 "Transmit IPV6 Ext Header Drop");
749
750 }
751 return;
752}
753
754
755static void
756oce_add_stats_sysctls_xe201(POCE_SOFTC sc,
757 struct sysctl_ctx_list *ctx,
758 struct sysctl_oid *stats_node)
759{
760 struct sysctl_oid *rx_stats_node, *tx_stats_node;
761 struct sysctl_oid_list *rx_stat_list, *tx_stat_list;
762 struct sysctl_oid_list *queue_stats_list;
763 struct sysctl_oid *queue_stats_node;
764 struct oce_drv_stats *stats;
765 char prefix[32];
766 int i;
767
768 stats = &sc->oce_stats_info;
769
770 rx_stats_node = SYSCTL_ADD_NODE(ctx,
771 SYSCTL_CHILDREN(stats_node),
772 OID_AUTO, "rx", CTLFLAG_RD,
773 NULL, "RX Ethernet Statistics");
774 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
775
776
777 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_pkts",
778 CTLFLAG_RD, &stats->rx.t_rx_pkts,
779 "Total Received Packets");
780 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_bytes",
781 CTLFLAG_RD, &stats->rx.t_rx_bytes,
782 "Total Received Bytes");
783 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags",
784 CTLFLAG_RD, &stats->rx.t_rx_frags, 0,
785 "Total Received Fragements");
786 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts",
787 CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0,
788 "Total Received Multicast Packets");
789 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_ucast_pkts",
790 CTLFLAG_RD, &stats->rx.t_rx_ucast_pkts, 0,
791 "Total Received Unicast Packets");
792 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_rxcp_errs",
793 CTLFLAG_RD, &stats->rx.t_rxcp_errs, 0,
794 "Total Receive completion errors");
795 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pause_frames",
796 CTLFLAG_RD, &stats->u0.xe201.rx_pause_frames, 0,
797 "Pause Frames");
798 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "control_frames",
799 CTLFLAG_RD, &stats->u0.xe201.rx_control_frames, 0,
800 "Control Frames");
801
802 for (i = 0; i < sc->nrqs; i++) {
803 sprintf(prefix, "queue%d",i);
804 queue_stats_node = SYSCTL_ADD_NODE(ctx,
805 SYSCTL_CHILDREN(rx_stats_node),
806 OID_AUTO, prefix, CTLFLAG_RD,
807 NULL, "Queue name");
808 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
809
810 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_pkts",
811 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_pkts,
812 "Receive Packets");
813 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes",
814 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes,
815 "Recived Bytes");
816 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags",
817 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0,
818 "Received Fragments");
819 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
820 "rx_mcast_pkts", CTLFLAG_RD,
821 &sc->rq[i]->rx_stats.rx_mcast_pkts, 0,
822 "Received Multicast Packets");
823 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
824 "rx_ucast_pkts",CTLFLAG_RD,
825 &sc->rq[i]->rx_stats.rx_ucast_pkts, 0,
826 "Received Unicast Packets");
827 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rxcp_err",
828 CTLFLAG_RD, &sc->rq[i]->rx_stats.rxcp_err, 0,
829 "Received Completion Errors");
830
831 }
832
833 rx_stats_node = SYSCTL_ADD_NODE(ctx,
834 SYSCTL_CHILDREN(rx_stats_node),
835 OID_AUTO, "err", CTLFLAG_RD,
836 NULL, "Receive Error Stats");
837 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
838
839 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "crc_errs",
840 CTLFLAG_RD, &stats->u0.xe201.rx_crc_errors, 0,
841 "CRC Errors");
842 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors",
843 CTLFLAG_RD, &stats->u0.xe201.rx_alignment_errors, 0,
844 "RX Alignmnet Errors");
845 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors",
846 CTLFLAG_RD, &stats->u0.xe201.rx_in_range_errors, 0,
847 "In Range Errors");
848 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "out_range_errors",
849 CTLFLAG_RD, &stats->u0.xe201.rx_out_of_range_errors, 0,
850 "Out Range Errors");
851 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "frame_too_long",
852 CTLFLAG_RD, &stats->u0.xe201.rx_frames_too_long, 0,
853 "Frame Too Long");
854 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "address_match_errors",
855 CTLFLAG_RD, &stats->u0.xe201.rx_address_match_errors, 0,
856 "Address Match Errors");
857 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_small",
858 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_too_small, 0,
859 "Dropped Too Small");
860 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_short",
861 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_too_short, 0,
862 "Dropped Too Short");
863 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
864 "dropped_header_too_small", CTLFLAG_RD,
865 &stats->u0.xe201.rx_dropped_header_too_small, 0,
866 "Dropped Header Too Small");
867 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
868 "dropped_tcp_length", CTLFLAG_RD,
869 &stats->u0.xe201.rx_dropped_invalid_tcp_length, 0,
870 "Dropped TCP Length");
871 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_runt",
872 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_runt, 0,
873 "Dropped runt");
874 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "ip_checksum_errs",
875 CTLFLAG_RD, &stats->u0.xe201.rx_ip_checksum_errors, 0,
876 "IP Checksum Errors");
877 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "tcp_checksum_errs",
878 CTLFLAG_RD, &stats->u0.xe201.rx_tcp_checksum_errors, 0,
879 "TCP Checksum Errors");
880 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "udp_checksum_errs",
881 CTLFLAG_RD, &stats->u0.xe201.rx_udp_checksum_errors, 0,
882 "UDP Checksum Errors");
883 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "input_fifo_overflow_drop",
884 CTLFLAG_RD, &stats->u0.xe201.rx_fifo_overflow, 0,
885 "Input FIFO Overflow Drop");
886
887 tx_stats_node = SYSCTL_ADD_NODE(ctx,
888 SYSCTL_CHILDREN(stats_node),
889 OID_AUTO, "tx", CTLFLAG_RD,
890 NULL, "TX Ethernet Statistics");
891 tx_stat_list = SYSCTL_CHILDREN(tx_stats_node);
892
893 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_pkts",
894 CTLFLAG_RD, &stats->tx.t_tx_pkts,
895 "Total Transmit Packets");
896 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_bytes",
897 CTLFLAG_RD, &stats->tx.t_tx_bytes,
898 "Total Transmit Bytes");
899 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_reqs",
900 CTLFLAG_RD, &stats->tx.t_tx_reqs, 0,
901 "Total Transmit Requests");
902 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_stops",
903 CTLFLAG_RD, &stats->tx.t_tx_stops, 0,
904 "Total Transmit Stops");
905 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_wrbs",
906 CTLFLAG_RD, &stats->tx.t_tx_wrbs, 0,
907 "Total Transmit WRB's");
908 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_compl",
909 CTLFLAG_RD, &stats->tx.t_tx_compl, 0,
910 "Total Transmit Completions");
911 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO,
912 "total_ipv6_ext_hdr_tx_drop",
913 CTLFLAG_RD, &stats->tx.t_ipv6_ext_hdr_tx_drop, 0,
914 "Total Transmit IPV6 Drops");
915 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "pauseframes",
916 CTLFLAG_RD, &stats->u0.xe201.tx_pause_frames, 0,
917 "Pause Frames");
918 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "controlframes",
919 CTLFLAG_RD, &stats->u0.xe201.tx_control_frames, 0,
920 "Tx Control Frames");
921
922 for (i = 0; i < sc->nwqs; i++) {
923 sprintf(prefix, "queue%d",i);
924 queue_stats_node = SYSCTL_ADD_NODE(ctx,
925 SYSCTL_CHILDREN(tx_stats_node),
926 OID_AUTO, prefix, CTLFLAG_RD,
927 NULL, "Queue name");
928 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
929
930 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_pkts",
931 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_pkts,
932 "Transmit Packets");
933 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_bytes",
934 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_bytes,
935 "Transmit Bytes");
936 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_reqs",
937 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_reqs, 0,
938 "Transmit Requests");
939 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_stops",
940 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_stops, 0,
941 "Transmit Stops");
942 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_wrbs",
943 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_wrbs, 0,
944 "Transmit WRB's");
945 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_compl",
946 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_compl, 0,
947 "Transmit Completions");
948 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
949 "ipv6_ext_hdr_tx_drop", CTLFLAG_RD,
950 &sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop, 0,
951 "Transmit IPV6 Ext Header Drop");
952
953 }
954 return;
955}
956
957
958void
959oce_refresh_queue_stats(POCE_SOFTC sc)
960{
961 struct oce_drv_stats *adapter_stats;
962 int i;
963
964 adapter_stats = &sc->oce_stats_info;
965
966 /* Caluculate total TX and TXstats from all queues */
967
968 bzero(&adapter_stats->rx, sizeof(struct oce_rx_stats));
969 for (i = 0; i < sc->nrqs; i++) {
970
971 adapter_stats->rx.t_rx_pkts += sc->rq[i]->rx_stats.rx_pkts;
972 adapter_stats->rx.t_rx_bytes += sc->rq[i]->rx_stats.rx_bytes;
973 adapter_stats->rx.t_rx_frags += sc->rq[i]->rx_stats.rx_frags;
974 adapter_stats->rx.t_rx_mcast_pkts +=
975 sc->rq[i]->rx_stats.rx_mcast_pkts;
976 adapter_stats->rx.t_rx_ucast_pkts +=
977 sc->rq[i]->rx_stats.rx_ucast_pkts;
978 adapter_stats->rx.t_rxcp_errs += sc-> rq[i]->rx_stats.rxcp_err;
979 }
980
981 bzero(&adapter_stats->tx, sizeof(struct oce_tx_stats));
982 for (i = 0; i < sc->nwqs; i++) {
983 adapter_stats->tx.t_tx_reqs += sc->wq[i]->tx_stats.tx_reqs;
984 adapter_stats->tx.t_tx_stops += sc->wq[i]->tx_stats.tx_stops;
985 adapter_stats->tx.t_tx_wrbs += sc->wq[i]->tx_stats.tx_wrbs;
986 adapter_stats->tx.t_tx_compl += sc->wq[i]->tx_stats.tx_compl;
987 adapter_stats->tx.t_tx_bytes += sc->wq[i]->tx_stats.tx_bytes;
988 adapter_stats->tx.t_tx_pkts += sc->wq[i]->tx_stats.tx_pkts;
989 adapter_stats->tx.t_ipv6_ext_hdr_tx_drop +=
990 sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop;
991 }
992
993}
994
995
996
997static void
998copy_stats_to_sc_xe201(POCE_SOFTC sc)
999{
1000 struct oce_xe201_stats *adapter_stats;
1001 struct mbx_get_pport_stats *nic_mbx;
1002 struct pport_stats *port_stats;
1003
1004 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_pport_stats);
1005 port_stats = &nic_mbx->params.rsp.pps;
1006 adapter_stats = &sc->oce_stats_info.u0.xe201;
1007
1008 adapter_stats->tx_pkts = port_stats->tx_pkts;
1009 adapter_stats->tx_unicast_pkts = port_stats->tx_unicast_pkts;
1010 adapter_stats->tx_multicast_pkts = port_stats->tx_multicast_pkts;
1011 adapter_stats->tx_broadcast_pkts = port_stats->tx_broadcast_pkts;
1012 adapter_stats->tx_bytes = port_stats->tx_bytes;
1013 adapter_stats->tx_unicast_bytes = port_stats->tx_unicast_bytes;
1014 adapter_stats->tx_multicast_bytes = port_stats->tx_multicast_bytes;
1015 adapter_stats->tx_broadcast_bytes = port_stats->tx_broadcast_bytes;
1016 adapter_stats->tx_discards = port_stats->tx_discards;
1017 adapter_stats->tx_errors = port_stats->tx_errors;
1018 adapter_stats->tx_pause_frames = port_stats->tx_pause_frames;
1019 adapter_stats->tx_pause_on_frames = port_stats->tx_pause_on_frames;
1020 adapter_stats->tx_pause_off_frames = port_stats->tx_pause_off_frames;
1021 adapter_stats->tx_internal_mac_errors =
1022 port_stats->tx_internal_mac_errors;
1023 adapter_stats->tx_control_frames = port_stats->tx_control_frames;
1024 adapter_stats->tx_pkts_64_bytes = port_stats->tx_pkts_64_bytes;
1025 adapter_stats->tx_pkts_65_to_127_bytes =
1026 port_stats->tx_pkts_65_to_127_bytes;
1027 adapter_stats->tx_pkts_128_to_255_bytes =
1028 port_stats->tx_pkts_128_to_255_bytes;
1029 adapter_stats->tx_pkts_256_to_511_bytes =
1030 port_stats->tx_pkts_256_to_511_bytes;
1031 adapter_stats->tx_pkts_512_to_1023_bytes =
1032 port_stats->tx_pkts_512_to_1023_bytes;
1033 adapter_stats->tx_pkts_1024_to_1518_bytes =
1034 port_stats->tx_pkts_1024_to_1518_bytes;
1035 adapter_stats->tx_pkts_1519_to_2047_bytes =
1036 port_stats->tx_pkts_1519_to_2047_bytes;
1037 adapter_stats->tx_pkts_2048_to_4095_bytes =
1038 port_stats->tx_pkts_2048_to_4095_bytes;
1039 adapter_stats->tx_pkts_4096_to_8191_bytes =
1040 port_stats->tx_pkts_4096_to_8191_bytes;
1041 adapter_stats->tx_pkts_8192_to_9216_bytes =
1042 port_stats->tx_pkts_8192_to_9216_bytes;
1043 adapter_stats->tx_lso_pkts = port_stats->tx_lso_pkts;
1044 adapter_stats->rx_pkts = port_stats->rx_pkts;
1045 adapter_stats->rx_unicast_pkts = port_stats->rx_unicast_pkts;
1046 adapter_stats->rx_multicast_pkts = port_stats->rx_multicast_pkts;
1047 adapter_stats->rx_broadcast_pkts = port_stats->rx_broadcast_pkts;
1048 adapter_stats->rx_bytes = port_stats->rx_bytes;
1049 adapter_stats->rx_unicast_bytes = port_stats->rx_unicast_bytes;
1050 adapter_stats->rx_multicast_bytes = port_stats->rx_multicast_bytes;
1051 adapter_stats->rx_broadcast_bytes = port_stats->rx_broadcast_bytes;
1052 adapter_stats->rx_unknown_protos = port_stats->rx_unknown_protos;
1053 adapter_stats->rx_discards = port_stats->rx_discards;
1054 adapter_stats->rx_errors = port_stats->rx_errors;
1055 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1056 adapter_stats->rx_alignment_errors = port_stats->rx_alignment_errors;
1057 adapter_stats->rx_symbol_errors = port_stats->rx_symbol_errors;
1058 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1059 adapter_stats->rx_pause_on_frames = port_stats->rx_pause_on_frames;
1060 adapter_stats->rx_pause_off_frames = port_stats->rx_pause_off_frames;
1061 adapter_stats->rx_frames_too_long = port_stats->rx_frames_too_long;
1062 adapter_stats->rx_internal_mac_errors =
1063 port_stats->rx_internal_mac_errors;
1064 adapter_stats->rx_undersize_pkts = port_stats->rx_undersize_pkts;
1065 adapter_stats->rx_oversize_pkts = port_stats->rx_oversize_pkts;
1066 adapter_stats->rx_fragment_pkts = port_stats->rx_fragment_pkts;
1067 adapter_stats->rx_jabbers = port_stats->rx_jabbers;
1068 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1069 adapter_stats->rx_control_frames_unknown_opcode =
1070 port_stats->rx_control_frames_unknown_opcode;
1071 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1072 adapter_stats->rx_out_of_range_errors =
1073 port_stats->rx_out_of_range_errors;
1074 adapter_stats->rx_address_match_errors =
1075 port_stats->rx_address_match_errors;
1076 adapter_stats->rx_vlan_mismatch_errors =
1077 port_stats->rx_vlan_mismatch_errors;
1078 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1079 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1080 adapter_stats->rx_dropped_header_too_small =
1081 port_stats->rx_dropped_header_too_small;
1082 adapter_stats->rx_dropped_invalid_tcp_length =
1083 port_stats->rx_dropped_invalid_tcp_length;
1084 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1085 adapter_stats->rx_ip_checksum_errors =
1086 port_stats->rx_ip_checksum_errors;
1087 adapter_stats->rx_tcp_checksum_errors =
1088 port_stats->rx_tcp_checksum_errors;
1089 adapter_stats->rx_udp_checksum_errors =
1090 port_stats->rx_udp_checksum_errors;
1091 adapter_stats->rx_non_rss_pkts = port_stats->rx_non_rss_pkts;
1092 adapter_stats->rx_ipv4_pkts = port_stats->rx_ipv4_pkts;
1093 adapter_stats->rx_ipv6_pkts = port_stats->rx_ipv6_pkts;
1094 adapter_stats->rx_ipv4_bytes = port_stats->rx_ipv4_bytes;
1095 adapter_stats->rx_ipv6_bytes = port_stats->rx_ipv6_bytes;
1096 adapter_stats->rx_nic_pkts = port_stats->rx_nic_pkts;
1097 adapter_stats->rx_tcp_pkts = port_stats->rx_tcp_pkts;
1098 adapter_stats->rx_iscsi_pkts = port_stats->rx_iscsi_pkts;
1099 adapter_stats->rx_management_pkts = port_stats->rx_management_pkts;
1100 adapter_stats->rx_switched_unicast_pkts =
1101 port_stats->rx_switched_unicast_pkts;
1102 adapter_stats->rx_switched_multicast_pkts =
1103 port_stats->rx_switched_multicast_pkts;
1104 adapter_stats->rx_switched_broadcast_pkts =
1105 port_stats->rx_switched_broadcast_pkts;
1106 adapter_stats->num_forwards = port_stats->num_forwards;
1107 adapter_stats->rx_fifo_overflow = port_stats->rx_fifo_overflow;
1108 adapter_stats->rx_input_fifo_overflow =
1109 port_stats->rx_input_fifo_overflow;
1110 adapter_stats->rx_drops_too_many_frags =
1111 port_stats->rx_drops_too_many_frags;
1112 adapter_stats->rx_drops_invalid_queue =
1113 port_stats->rx_drops_invalid_queue;
1114 adapter_stats->rx_drops_mtu = port_stats->rx_drops_mtu;
1115 adapter_stats->rx_pkts_64_bytes = port_stats->rx_pkts_64_bytes;
1116 adapter_stats->rx_pkts_65_to_127_bytes =
1117 port_stats->rx_pkts_65_to_127_bytes;
1118 adapter_stats->rx_pkts_128_to_255_bytes =
1119 port_stats->rx_pkts_128_to_255_bytes;
1120 adapter_stats->rx_pkts_256_to_511_bytes =
1121 port_stats->rx_pkts_256_to_511_bytes;
1122 adapter_stats->rx_pkts_512_to_1023_bytes =
1123 port_stats->rx_pkts_512_to_1023_bytes;
1124 adapter_stats->rx_pkts_1024_to_1518_bytes =
1125 port_stats->rx_pkts_1024_to_1518_bytes;
1126 adapter_stats->rx_pkts_1519_to_2047_bytes =
1127 port_stats->rx_pkts_1519_to_2047_bytes;
1128 adapter_stats->rx_pkts_2048_to_4095_bytes =
1129 port_stats->rx_pkts_2048_to_4095_bytes;
1130 adapter_stats->rx_pkts_4096_to_8191_bytes =
1131 port_stats->rx_pkts_4096_to_8191_bytes;
1132 adapter_stats->rx_pkts_8192_to_9216_bytes =
1133 port_stats->rx_pkts_8192_to_9216_bytes;
1134}
1135
1136
1137
1138static void
1139copy_stats_to_sc_be2(POCE_SOFTC sc)
1140{
1141 struct oce_be_stats *adapter_stats;
1142 struct oce_pmem_stats *pmem;
1143 struct oce_rxf_stats_v0 *rxf_stats;
1144 struct oce_port_rxf_stats_v0 *port_stats;
1145 struct mbx_get_nic_stats_v0 *nic_mbx;
1146 uint32_t port = sc->port_id;
1147
1148 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_nic_stats_v0);
1149 pmem = &nic_mbx->params.rsp.stats.pmem;
1150 rxf_stats = &nic_mbx->params.rsp.stats.rxf;
1151 port_stats = &nic_mbx->params.rsp.stats.rxf.port[port];
1152
1153 adapter_stats = &sc->oce_stats_info.u0.be;
1154
1155
1156 /* Update stats */
1157 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1158 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1159 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1160 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1161 adapter_stats->rx_frame_too_long = port_stats->rx_frame_too_long;
1162 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1163 adapter_stats->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs;
1164 adapter_stats->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs;
1165 adapter_stats->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs;
1166 adapter_stats->rxpp_fifo_overflow_drop =
1167 port_stats->rxpp_fifo_overflow_drop;
1168 adapter_stats->rx_dropped_tcp_length =
1169 port_stats->rx_dropped_tcp_length;
1170 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1171 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1172 adapter_stats->rx_out_range_errors = port_stats->rx_out_range_errors;
1173 adapter_stats->rx_dropped_header_too_small =
1174 port_stats->rx_dropped_header_too_small;
1175 adapter_stats->rx_input_fifo_overflow_drop =
1176 port_stats->rx_input_fifo_overflow_drop;
1177 adapter_stats->rx_address_match_errors =
1178 port_stats->rx_address_match_errors;
1179 adapter_stats->rx_alignment_symbol_errors =
1180 port_stats->rx_alignment_symbol_errors;
1181 adapter_stats->tx_pauseframes = port_stats->tx_pauseframes;
1182 adapter_stats->tx_controlframes = port_stats->tx_controlframes;
1183
1184 if (sc->if_id)
1185 adapter_stats->jabber_events = rxf_stats->port1_jabber_events;
1186 else
1187 adapter_stats->jabber_events = rxf_stats->port0_jabber_events;
1188
1189 adapter_stats->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf;
1190 adapter_stats->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb;
1191 adapter_stats->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr;
1192 adapter_stats->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring;
1193 adapter_stats->forwarded_packets = rxf_stats->forwarded_packets;
1194 adapter_stats->rx_drops_mtu = rxf_stats->rx_drops_mtu;
1195 adapter_stats->rx_drops_no_tpre_descr =
1196 rxf_stats->rx_drops_no_tpre_descr;
1197 adapter_stats->rx_drops_too_many_frags =
1198 rxf_stats->rx_drops_too_many_frags;
1199 adapter_stats->eth_red_drops = pmem->eth_red_drops;
1200}
1201
1202
1203static void
1204copy_stats_to_sc_be3(POCE_SOFTC sc)
1205{
1206 struct oce_be_stats *adapter_stats;
1207 struct oce_pmem_stats *pmem;
1208 struct oce_rxf_stats_v1 *rxf_stats;
1209 struct oce_port_rxf_stats_v1 *port_stats;
1210 struct mbx_get_nic_stats *nic_mbx;
1211 uint32_t port = sc->port_id;
1212
1213 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_nic_stats);
1214 pmem = &nic_mbx->params.rsp.stats.pmem;
1215 rxf_stats = &nic_mbx->params.rsp.stats.rxf;
1216 port_stats = &nic_mbx->params.rsp.stats.rxf.port[port];
1217
1218 adapter_stats = &sc->oce_stats_info.u0.be;
1219
1220 /* Update stats */
1221 adapter_stats->pmem_fifo_overflow_drop =
1222 port_stats->pmem_fifo_overflow_drop;
1223 adapter_stats->rx_priority_pause_frames =
1224 port_stats->rx_priority_pause_frames;
1225 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1226 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1227 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1228 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1229 adapter_stats->rx_frame_too_long = port_stats->rx_frame_too_long;
1230 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1231 adapter_stats->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs;
1232 adapter_stats->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs;
1233 adapter_stats->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs;
1234 adapter_stats->rx_dropped_tcp_length =
1235 port_stats->rx_dropped_tcp_length;
1236 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1237 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1238 adapter_stats->rx_out_range_errors = port_stats->rx_out_range_errors;
1239 adapter_stats->rx_dropped_header_too_small =
1240 port_stats->rx_dropped_header_too_small;
1241 adapter_stats->rx_input_fifo_overflow_drop =
1242 port_stats->rx_input_fifo_overflow_drop;
1243 adapter_stats->rx_address_match_errors =
1244 port_stats->rx_address_match_errors;
1245 adapter_stats->rx_alignment_symbol_errors =
1246 port_stats->rx_alignment_symbol_errors;
1247 adapter_stats->rxpp_fifo_overflow_drop =
1248 port_stats->rxpp_fifo_overflow_drop;
1249 adapter_stats->tx_pauseframes = port_stats->tx_pauseframes;
1250 adapter_stats->tx_controlframes = port_stats->tx_controlframes;
1251 adapter_stats->jabber_events = port_stats->jabber_events;
1252
1253 adapter_stats->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf;
1254 adapter_stats->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb;
1255 adapter_stats->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr;
1256 adapter_stats->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring;
1257 adapter_stats->forwarded_packets = rxf_stats->forwarded_packets;
1258 adapter_stats->rx_drops_mtu = rxf_stats->rx_drops_mtu;
1259 adapter_stats->rx_drops_no_tpre_descr =
1260 rxf_stats->rx_drops_no_tpre_descr;
1261 adapter_stats->rx_drops_too_many_frags =
1262 rxf_stats->rx_drops_too_many_frags;
1263
1264 adapter_stats->eth_red_drops = pmem->eth_red_drops;
1265}
1266
1267
1268int
1269oce_stats_init(POCE_SOFTC sc)
1270{
1271 int rc = 0, sz;
1272
1273 if (IS_BE(sc) || IS_SH(sc)) {
1274 if (sc->flags & OCE_FLAGS_BE2)
1275 sz = sizeof(struct mbx_get_nic_stats_v0);
1276 else
1277 sz = sizeof(struct mbx_get_nic_stats);
1278 } else
1279 sz = sizeof(struct mbx_get_pport_stats);
1280
1281 rc = oce_dma_alloc(sc, sz, &sc->stats_mem, 0);
1282
1283 return rc;
1284}
1285
1286
1287void
1288oce_stats_free(POCE_SOFTC sc)
1289{
1290
1291 oce_dma_free(sc, &sc->stats_mem);
1292
1293}
1294
1295
1296int
1297oce_refresh_nic_stats(POCE_SOFTC sc)
1298{
1299 int rc = 0, reset = 0;
1300
1301 if (IS_BE(sc) || IS_SH(sc)) {
1302 if (sc->flags & OCE_FLAGS_BE2) {
1303 rc = oce_mbox_get_nic_stats_v0(sc, &sc->stats_mem);
1304 if (!rc)
1305 copy_stats_to_sc_be2(sc);
1306 } else {
1307 rc = oce_mbox_get_nic_stats(sc, &sc->stats_mem);
1308 if (!rc)
1309 copy_stats_to_sc_be3(sc);
1310 }
1311
1312 } else {
1313 rc = oce_mbox_get_pport_stats(sc, &sc->stats_mem, reset);
1314 if (!rc)
1315 copy_stats_to_sc_xe201(sc);
1316 }
1317
1318 return rc;
1319}
1320
1321static int
1322oce_sysctl_sfp_vpd_dump(SYSCTL_HANDLER_ARGS)
1323{
1324 int result = 0, error;
1325 int rc = 0;
1326 POCE_SOFTC sc = (POCE_SOFTC) arg1;
1327
1328 /* sysctl default handler */
1329 error = sysctl_handle_int(oidp, &result, 0, req);
1330 if (error || !req->newptr)
1331 return (error);
1332
1333 if(result == -1) {
1334 return EINVAL;
1335 }
1336 bzero((char *)sfp_vpd_dump_buffer, TRANSCEIVER_DATA_SIZE);
1337
1338 rc = oce_mbox_read_transrecv_data(sc, PAGE_NUM_A0);
1339 if(rc)
1340 return rc;
1341
1342 rc = oce_mbox_read_transrecv_data(sc, PAGE_NUM_A2);
1343 if(rc)
1344 return rc;
1345
1346 return rc;
1347}
2 * Copyright (C) 2013 Emulex
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the Emulex Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * Contact Information:
32 * freebsd-drivers@emulex.com
33 *
34 * Emulex
35 * 3333 Susan Street
36 * Costa Mesa, CA 92626
37 */
38
39/* $FreeBSD: head/sys/dev/oce/oce_sysctl.c 252869 2013-07-06 08:30:45Z delphij $ */
40
41
42#include "oce_if.h"
43
44static void copy_stats_to_sc_xe201(POCE_SOFTC sc);
45static void copy_stats_to_sc_be3(POCE_SOFTC sc);
46static void copy_stats_to_sc_be2(POCE_SOFTC sc);
47static int oce_sysctl_loopback(SYSCTL_HANDLER_ARGS);
48static int oce_be3_fwupgrade(POCE_SOFTC sc, const struct firmware *fw);
49static int oce_sys_fwupgrade(SYSCTL_HANDLER_ARGS);
50static int oce_be3_flashdata(POCE_SOFTC sc, const struct firmware
51 *fw, int num_imgs);
52static int oce_lancer_fwupgrade(POCE_SOFTC sc, const struct firmware *fw);
53static int oce_sysctl_sfp_vpd_dump(SYSCTL_HANDLER_ARGS);
54static boolean_t oce_phy_flashing_required(POCE_SOFTC sc);
55static boolean_t oce_img_flashing_required(POCE_SOFTC sc, const char *p,
56 int img_optype, uint32_t img_offset,
57 uint32_t img_size, uint32_t hdrs_size);
58static void oce_add_stats_sysctls_be3(POCE_SOFTC sc,
59 struct sysctl_ctx_list *ctx,
60 struct sysctl_oid *stats_node);
61static void oce_add_stats_sysctls_xe201(POCE_SOFTC sc,
62 struct sysctl_ctx_list *ctx,
63 struct sysctl_oid *stats_node);
64
65extern char component_revision[32];
66uint32_t sfp_vpd_dump_buffer[TRANSCEIVER_DATA_NUM_ELE];
67
68void
69oce_add_sysctls(POCE_SOFTC sc)
70{
71
72 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->dev);
73 struct sysctl_oid *tree = device_get_sysctl_tree(sc->dev);
74 struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
75 struct sysctl_oid *stats_node;
76
77 SYSCTL_ADD_STRING(ctx, child,
78 OID_AUTO, "component_revision",
79 CTLTYPE_INT | CTLFLAG_RD,
80 &component_revision,
81 sizeof(component_revision),
82 "EMULEX One-Connect device driver revision");
83
84 SYSCTL_ADD_STRING(ctx, child,
85 OID_AUTO, "firmware_version",
86 CTLTYPE_INT | CTLFLAG_RD,
87 &sc->fw_version,
88 sizeof(sc->fw_version),
89 "EMULEX One-Connect Firmware Version");
90
91 SYSCTL_ADD_INT(ctx, child,
92 OID_AUTO, "max_rsp_handled",
93 CTLTYPE_INT | CTLFLAG_RW,
94 &oce_max_rsp_handled,
95 sizeof(oce_max_rsp_handled),
96 "Maximum receive frames handled per interupt");
97
98 if ((sc->function_mode & FNM_FLEX10_MODE) ||
99 (sc->function_mode & FNM_UMC_MODE))
100 SYSCTL_ADD_UINT(ctx, child,
101 OID_AUTO, "speed",
102 CTLFLAG_RD,
103 &sc->qos_link_speed,
104 0,"QOS Speed");
105 else
106 SYSCTL_ADD_UINT(ctx, child,
107 OID_AUTO, "speed",
108 CTLFLAG_RD,
109 &sc->speed,
110 0,"Link Speed");
111
112 if (sc->function_mode & FNM_UMC_MODE)
113 SYSCTL_ADD_UINT(ctx, child,
114 OID_AUTO, "pvid",
115 CTLFLAG_RD,
116 &sc->pvid,
117 0,"PVID");
118
119 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "loop_back",
120 CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0,
121 oce_sysctl_loopback, "I", "Loop Back Tests");
122
123 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "fw_upgrade",
124 CTLTYPE_STRING | CTLFLAG_RW, (void *)sc, 0,
125 oce_sys_fwupgrade, "A", "Firmware ufi file");
126
127 /*
128 * Dumps Transceiver data
129 * "sysctl dev.oce.0.sfp_vpd_dump=0"
130 * "sysctl -x dev.oce.0.sfp_vpd_dump_buffer" for hex dump
131 * "sysctl -b dev.oce.0.sfp_vpd_dump_buffer > sfp.bin" for binary dump
132 */
133 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "sfp_vpd_dump",
134 CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, oce_sysctl_sfp_vpd_dump,
135 "I", "Initiate a sfp_vpd_dump operation");
136 SYSCTL_ADD_OPAQUE(ctx, child, OID_AUTO, "sfp_vpd_dump_buffer",
137 CTLFLAG_RD, sfp_vpd_dump_buffer,
138 TRANSCEIVER_DATA_SIZE, "IU", "Access sfp_vpd_dump buffer");
139
140 stats_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats",
141 CTLFLAG_RD, NULL, "Ethernet Statistics");
142
143 if (IS_BE(sc) || IS_SH(sc))
144 oce_add_stats_sysctls_be3(sc, ctx, stats_node);
145 else
146 oce_add_stats_sysctls_xe201(sc, ctx, stats_node);
147
148
149}
150
151
152static uint32_t
153oce_loopback_test(struct oce_softc *sc, uint8_t loopback_type)
154{
155 uint32_t status = 0;
156
157 oce_mbox_cmd_set_loopback(sc, sc->if_id, loopback_type, 1);
158 status = oce_mbox_cmd_test_loopback(sc, sc->if_id, loopback_type,
159 1500, 2, 0xabc);
160 oce_mbox_cmd_set_loopback(sc, sc->if_id, OCE_NO_LOOPBACK, 1);
161
162 return status;
163}
164
165static int
166oce_sysctl_loopback(SYSCTL_HANDLER_ARGS)
167{
168 int value = 0;
169 uint32_t status;
170 struct oce_softc *sc = (struct oce_softc *)arg1;
171
172 status = sysctl_handle_int(oidp, &value, 0, req);
173 if (status || !req->newptr)
174 return status;
175
176 if (value != 1) {
177 device_printf(sc->dev,
178 "Not a Valid value. Set to loop_back=1 to run tests\n");
179 return 0;
180 }
181
182 if ((status = oce_loopback_test(sc, OCE_MAC_LOOPBACK))) {
183 device_printf(sc->dev,
184 "MAC Loopback Test = Failed (Error status = %d)\n",
185 status);
186 } else
187 device_printf(sc->dev, "MAC Loopback Test = Success\n");
188
189 if ((status = oce_loopback_test(sc, OCE_PHY_LOOPBACK))) {
190 device_printf(sc->dev,
191 "PHY Loopback Test = Failed (Error status = %d)\n",
192 status);
193 } else
194 device_printf(sc->dev, "PHY Loopback Test = Success\n");
195
196 if ((status = oce_loopback_test(sc, OCE_ONE_PORT_EXT_LOOPBACK))) {
197 device_printf(sc->dev,
198 "EXT Loopback Test = Failed (Error status = %d)\n",
199 status);
200 } else
201 device_printf(sc->dev, "EXT Loopback Test = Success\n");
202
203 return 0;
204}
205
206
207static int
208oce_sys_fwupgrade(SYSCTL_HANDLER_ARGS)
209{
210 char ufiname[256] = {0};
211 uint32_t status = 1;
212 struct oce_softc *sc = (struct oce_softc *)arg1;
213 const struct firmware *fw;
214
215 status = sysctl_handle_string(oidp, ufiname, sizeof(ufiname), req);
216 if (status || !req->newptr)
217 return status;
218
219 fw = firmware_get(ufiname);
220 if (fw == NULL) {
221 device_printf(sc->dev, "Unable to get Firmware. "
222 "Make sure %s is copied to /boot/modules\n", ufiname);
223 return ENOENT;
224 }
225
226 if (IS_BE(sc) || IS_SH(sc)) {
227 if ((sc->flags & OCE_FLAGS_BE2)) {
228 device_printf(sc->dev,
229 "Flashing not supported for BE2 yet.\n");
230 status = 1;
231 goto done;
232 }
233 status = oce_be3_fwupgrade(sc, fw);
234 } else
235 status = oce_lancer_fwupgrade(sc, fw);
236done:
237 if (status) {
238 device_printf(sc->dev, "Firmware Upgrade failed\n");
239 } else {
240 device_printf(sc->dev, "Firmware Flashed successfully\n");
241 }
242
243 /* Release Firmware*/
244 firmware_put(fw, FIRMWARE_UNLOAD);
245
246 return status;
247}
248
249
250static int
251oce_be3_fwupgrade(POCE_SOFTC sc, const struct firmware *fw)
252{
253 int rc = 0, num_imgs = 0, i = 0;
254 const struct flash_file_hdr *fhdr;
255 const struct image_hdr *img_ptr;
256
257 fhdr = (const struct flash_file_hdr *)fw->data;
258 if (fhdr->build[0] != '3') {
259 device_printf(sc->dev, "Invalid BE3 firmware image\n");
260 return EINVAL;
261 }
262 /* Display flash version */
263 device_printf(sc->dev, "Flashing Firmware %s\n", &fhdr->build[2]);
264
265 num_imgs = fhdr->num_imgs;
266 for (i = 0; i < num_imgs; i++) {
267 img_ptr = (const struct image_hdr *)((const char *)fw->data +
268 sizeof(struct flash_file_hdr) +
269 (i * sizeof(struct image_hdr)));
270 if (img_ptr->imageid == 1) {
271 rc = oce_be3_flashdata(sc, fw, num_imgs);
272 break;
273 }
274 }
275
276 return rc;
277}
278
279
280static int
281oce_be3_flashdata(POCE_SOFTC sc, const struct firmware *fw, int num_imgs)
282{
283 char cookie[2][16] = {"*** SE FLAS", "H DIRECTORY *** "};
284 const char *p = (const char *)fw->data;
285 const struct flash_sec_info *fsec = NULL;
286 struct mbx_common_read_write_flashrom *req;
287 int rc = 0, i, img_type, bin_offset = 0;
288 boolean_t skip_image;
289 uint32_t optype = 0, size = 0, start = 0, num_bytes = 0;
290 uint32_t opcode = 0;
291 OCE_DMA_MEM dma_mem;
292
293 /* Validate Cookie */
294 bin_offset = (sizeof(struct flash_file_hdr) +
295 (num_imgs * sizeof(struct image_hdr)));
296 p += bin_offset;
297 while (p < ((const char *)fw->data + fw->datasize)) {
298 fsec = (const struct flash_sec_info *)p;
299 if (!memcmp(cookie, fsec->cookie, sizeof(cookie)))
300 break;
301 fsec = NULL;
302 p += 32;
303 }
304
305 if (!fsec) {
306 device_printf(sc->dev,
307 "Invalid Cookie. Firmware image corrupted ?\n");
308 return EINVAL;
309 }
310
311 rc = oce_dma_alloc(sc, sizeof(struct mbx_common_read_write_flashrom)
312 + 32*1024, &dma_mem, 0);
313 if (rc) {
314 device_printf(sc->dev,
315 "Memory allocation failure while flashing\n");
316 return ENOMEM;
317 }
318 req = OCE_DMAPTR(&dma_mem, struct mbx_common_read_write_flashrom);
319
320 for (i = 0; i < MAX_FLASH_COMP; i++) {
321
322 img_type = fsec->fsec_entry[i].type;
323 skip_image = FALSE;
324 switch (img_type) {
325 case IMG_ISCSI:
326 optype = 0;
327 size = 2097152;
328 start = 2097152;
329 break;
330 case IMG_REDBOOT:
331 optype = 1;
332 size = 1048576;
333 start = 262144;
334 if (!oce_img_flashing_required(sc, fw->data,
335 optype, start, size, bin_offset))
336 skip_image = TRUE;
337 break;
338 case IMG_BIOS:
339 optype = 2;
340 size = 524288;
341 start = 12582912;
342 break;
343 case IMG_PXEBIOS:
344 optype = 3;
345 size = 524288;
346 start = 13107200;
347 break;
348 case IMG_FCOEBIOS:
349 optype = 8;
350 size = 524288;
351 start = 13631488;
352 break;
353 case IMG_ISCSI_BAK:
354 optype = 9;
355 size = 2097152;
356 start = 4194304;
357 break;
358 case IMG_FCOE:
359 optype = 10;
360 size = 2097152;
361 start = 6291456;
362 break;
363 case IMG_FCOE_BAK:
364 optype = 11;
365 size = 2097152;
366 start = 8388608;
367 break;
368 case IMG_NCSI:
369 optype = 13;
370 size = 262144;
371 start = 15990784;
372 break;
373 case IMG_PHY:
374 optype = 99;
375 size = 262144;
376 start = 1310720;
377 if (!oce_phy_flashing_required(sc))
378 skip_image = TRUE;
379 break;
380 default:
381 skip_image = TRUE;
382 break;
383 }
384 if (skip_image)
385 continue;
386
387 p = fw->data;
388 p = p + bin_offset + start;
389 if ((p + size) > ((const char *)fw->data + fw->datasize)) {
390 rc = 1;
391 goto ret;
392 }
393
394 while (size) {
395
396 if (size > 32*1024)
397 num_bytes = 32*1024;
398 else
399 num_bytes = size;
400 size -= num_bytes;
401
402 if (!size)
403 opcode = FLASHROM_OPER_FLASH;
404 else
405 opcode = FLASHROM_OPER_SAVE;
406
407 memcpy(req->data_buffer, p, num_bytes);
408 p += num_bytes;
409
410 rc = oce_mbox_write_flashrom(sc, optype, opcode,
411 &dma_mem, num_bytes);
412 if (rc) {
413 device_printf(sc->dev,
414 "cmd to write to flash rom failed.\n");
415 rc = EIO;
416 goto ret;
417 }
418 /* Leave the CPU for others for some time */
419 pause("yield", 10);
420
421 }
422 }
423ret:
424 oce_dma_free(sc, &dma_mem);
425 return rc;
426
427}
428
429
430static boolean_t
431oce_phy_flashing_required(POCE_SOFTC sc)
432{
433 int status = 0;
434 struct oce_phy_info phy_info;
435
436 status = oce_mbox_get_phy_info(sc, &phy_info);
437 if (status)
438 return FALSE;
439
440 if ((phy_info.phy_type == TN_8022) &&
441 (phy_info.interface_type == PHY_TYPE_BASET_10GB)) {
442 return TRUE;
443 }
444
445 return FALSE;
446}
447
448
449static boolean_t
450oce_img_flashing_required(POCE_SOFTC sc, const char *p,
451 int img_optype, uint32_t img_offset,
452 uint32_t img_size, uint32_t hdrs_size)
453{
454 uint32_t crc_offset;
455 uint8_t flashed_crc[4];
456 int status;
457
458 crc_offset = hdrs_size + img_offset + img_size - 4;
459
460 p += crc_offset;
461
462 status = oce_mbox_get_flashrom_crc(sc, flashed_crc,
463 (img_size - 4), img_optype);
464 if (status)
465 return TRUE; /* Some thing worng. ReFlash */
466
467 /*update redboot only if crc does not match*/
468 if (bcmp(flashed_crc, p, 4))
469 return TRUE;
470 else
471 return FALSE;
472}
473
474
475static int
476oce_lancer_fwupgrade(POCE_SOFTC sc, const struct firmware *fw)
477{
478
479 int rc = 0;
480 OCE_DMA_MEM dma_mem;
481 const uint8_t *data = NULL;
482 uint8_t *dest_image_ptr = NULL;
483 size_t size = 0;
484 uint32_t data_written = 0, chunk_size = 0;
485 uint32_t offset = 0, add_status = 0;
486
487 if (!IS_ALIGNED(fw->datasize, sizeof(uint32_t))) {
488 device_printf(sc->dev,
489 "Lancer FW image is not 4 byte aligned.");
490 return EINVAL;
491 }
492
493 rc = oce_dma_alloc(sc, 32*1024, &dma_mem, 0);
494 if (rc) {
495 device_printf(sc->dev,
496 "Memory allocation failure while flashing Lancer\n");
497 return ENOMEM;
498 }
499
500 size = fw->datasize;
501 data = fw->data;
502 dest_image_ptr = OCE_DMAPTR(&dma_mem, uint8_t);
503
504 while (size) {
505 chunk_size = MIN(size, (32*1024));
506
507 bcopy(data, dest_image_ptr, chunk_size);
508
509 rc = oce_mbox_lancer_write_flashrom(sc, chunk_size, offset,
510 &dma_mem, &data_written, &add_status);
511
512 if (rc)
513 break;
514
515 size -= data_written;
516 data += data_written;
517 offset += data_written;
518 pause("yield", 10);
519
520 }
521
522 if (!rc)
523 /* Commit the firmware*/
524 rc = oce_mbox_lancer_write_flashrom(sc, 0, offset, &dma_mem,
525 &data_written, &add_status);
526 if (rc) {
527 device_printf(sc->dev, "Lancer firmware load error. "
528 "Addstatus = 0x%x, status = %d \n", add_status, rc);
529 rc = EIO;
530 }
531 oce_dma_free(sc, &dma_mem);
532 return rc;
533
534}
535
536
537static void
538oce_add_stats_sysctls_be3(POCE_SOFTC sc,
539 struct sysctl_ctx_list *ctx,
540 struct sysctl_oid *stats_node)
541{
542 struct sysctl_oid *rx_stats_node, *tx_stats_node;
543 struct sysctl_oid_list *rx_stat_list, *tx_stat_list;
544 struct sysctl_oid_list *queue_stats_list;
545 struct sysctl_oid *queue_stats_node;
546 struct oce_drv_stats *stats;
547 char prefix[32];
548 int i;
549
550 stats = &sc->oce_stats_info;
551
552 rx_stats_node = SYSCTL_ADD_NODE(ctx,
553 SYSCTL_CHILDREN(stats_node),
554 OID_AUTO,"rx", CTLFLAG_RD,
555 NULL, "RX Ethernet Statistics");
556 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
557
558
559 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_pkts",
560 CTLFLAG_RD, &stats->rx.t_rx_pkts,
561 "Total Received Packets");
562 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_bytes",
563 CTLFLAG_RD, &stats->rx.t_rx_bytes,
564 "Total Received Bytes");
565 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags",
566 CTLFLAG_RD, &stats->rx.t_rx_frags, 0,
567 "Total Received Fragements");
568 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts",
569 CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0,
570 "Total Received Multicast Packets");
571 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_ucast_pkts",
572 CTLFLAG_RD, &stats->rx.t_rx_ucast_pkts, 0,
573 "Total Received Unicast Packets");
574 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_rxcp_errs",
575 CTLFLAG_RD, &stats->rx.t_rxcp_errs, 0,
576 "Total Receive completion errors");
577 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pause_frames",
578 CTLFLAG_RD, &stats->u0.be.rx_pause_frames, 0,
579 "Pause Frames");
580 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "priority_pause_frames",
581 CTLFLAG_RD, &stats->u0.be.rx_priority_pause_frames, 0,
582 "Priority Pause Frames");
583 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "control_frames",
584 CTLFLAG_RD, &stats->u0.be.rx_control_frames, 0,
585 "Control Frames");
586
587 for (i = 0; i < sc->nrqs; i++) {
588 sprintf(prefix, "queue%d",i);
589 queue_stats_node = SYSCTL_ADD_NODE(ctx,
590 SYSCTL_CHILDREN(rx_stats_node),
591 OID_AUTO, prefix, CTLFLAG_RD,
592 NULL, "Queue name");
593 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
594
595 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_pkts",
596 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_pkts,
597 "Receive Packets");
598 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes",
599 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes,
600 "Recived Bytes");
601 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags",
602 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0,
603 "Received Fragments");
604 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
605 "rx_mcast_pkts", CTLFLAG_RD,
606 &sc->rq[i]->rx_stats.rx_mcast_pkts, 0,
607 "Received Multicast Packets");
608 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
609 "rx_ucast_pkts", CTLFLAG_RD,
610 &sc->rq[i]->rx_stats.rx_ucast_pkts, 0,
611 "Received Unicast Packets");
612 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rxcp_err",
613 CTLFLAG_RD, &sc->rq[i]->rx_stats.rxcp_err, 0,
614 "Received Completion Errors");
615
616 }
617
618 rx_stats_node = SYSCTL_ADD_NODE(ctx,
619 SYSCTL_CHILDREN(rx_stats_node),
620 OID_AUTO, "err", CTLFLAG_RD,
621 NULL, "Receive Error Stats");
622 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
623
624 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "crc_errs",
625 CTLFLAG_RD, &stats->u0.be.rx_crc_errors, 0,
626 "CRC Errors");
627 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pbuf_errors",
628 CTLFLAG_RD, &stats->u0.be.rx_drops_no_pbuf, 0,
629 "Drops due to pbuf full");
630 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "erx_errors",
631 CTLFLAG_RD, &stats->u0.be.rx_drops_no_erx_descr, 0,
632 "ERX Errors");
633 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors",
634 CTLFLAG_RD, &stats->u0.be.rx_drops_too_many_frags, 0,
635 "RX Alignmnet Errors");
636 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors",
637 CTLFLAG_RD, &stats->u0.be.rx_in_range_errors, 0,
638 "In Range Errors");
639 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "out_range_errors",
640 CTLFLAG_RD, &stats->u0.be.rx_out_range_errors, 0,
641 "Out Range Errors");
642 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "frame_too_long",
643 CTLFLAG_RD, &stats->u0.be.rx_frame_too_long, 0,
644 "Frame Too Long");
645 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "address_match_errors",
646 CTLFLAG_RD, &stats->u0.be.rx_address_match_errors, 0,
647 "Address Match Errors");
648 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_small",
649 CTLFLAG_RD, &stats->u0.be.rx_dropped_too_small, 0,
650 "Dropped Too Small");
651 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_short",
652 CTLFLAG_RD, &stats->u0.be.rx_dropped_too_short, 0,
653 "Dropped Too Short");
654 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
655 "dropped_header_too_small", CTLFLAG_RD,
656 &stats->u0.be.rx_dropped_header_too_small, 0,
657 "Dropped Header Too Small");
658 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_tcp_length",
659 CTLFLAG_RD, &stats->u0.be.rx_dropped_tcp_length, 0,
660 "Dropped TCP Length");
661 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_runt",
662 CTLFLAG_RD, &stats->u0.be.rx_dropped_runt, 0,
663 "Dropped runt");
664 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "ip_checksum_errs",
665 CTLFLAG_RD, &stats->u0.be.rx_ip_checksum_errs, 0,
666 "IP Checksum Errors");
667 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "tcp_checksum_errs",
668 CTLFLAG_RD, &stats->u0.be.rx_tcp_checksum_errs, 0,
669 "TCP Checksum Errors");
670 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "udp_checksum_errs",
671 CTLFLAG_RD, &stats->u0.be.rx_udp_checksum_errs, 0,
672 "UDP Checksum Errors");
673 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "fifo_overflow_drop",
674 CTLFLAG_RD, &stats->u0.be.rxpp_fifo_overflow_drop, 0,
675 "FIFO Overflow Drop");
676 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
677 "input_fifo_overflow_drop", CTLFLAG_RD,
678 &stats->u0.be.rx_input_fifo_overflow_drop, 0,
679 "Input FIFO Overflow Drop");
680
681 tx_stats_node = SYSCTL_ADD_NODE(ctx,
682 SYSCTL_CHILDREN(stats_node), OID_AUTO,
683 "tx",CTLFLAG_RD, NULL,
684 "TX Ethernet Statistics");
685 tx_stat_list = SYSCTL_CHILDREN(tx_stats_node);
686
687 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_pkts",
688 CTLFLAG_RD, &stats->tx.t_tx_pkts,
689 "Total Transmit Packets");
690 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_bytes",
691 CTLFLAG_RD, &stats->tx.t_tx_bytes,
692 "Total Transmit Bytes");
693 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_reqs",
694 CTLFLAG_RD, &stats->tx.t_tx_reqs, 0,
695 "Total Transmit Requests");
696 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_stops",
697 CTLFLAG_RD, &stats->tx.t_tx_stops, 0,
698 "Total Transmit Stops");
699 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_wrbs",
700 CTLFLAG_RD, &stats->tx.t_tx_wrbs, 0,
701 "Total Transmit WRB's");
702 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_compl",
703 CTLFLAG_RD, &stats->tx.t_tx_compl, 0,
704 "Total Transmit Completions");
705 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO,
706 "total_ipv6_ext_hdr_tx_drop", CTLFLAG_RD,
707 &stats->tx.t_ipv6_ext_hdr_tx_drop, 0,
708 "Total Transmit IPV6 Drops");
709 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "pauseframes",
710 CTLFLAG_RD, &stats->u0.be.tx_pauseframes, 0,
711 "Pause Frames");
712 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "priority_pauseframes",
713 CTLFLAG_RD, &stats->u0.be.tx_priority_pauseframes, 0,
714 "Priority Pauseframes");
715 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "controlframes",
716 CTLFLAG_RD, &stats->u0.be.tx_controlframes, 0,
717 "Tx Control Frames");
718
719 for (i = 0; i < sc->nwqs; i++) {
720 sprintf(prefix, "queue%d",i);
721 queue_stats_node = SYSCTL_ADD_NODE(ctx,
722 SYSCTL_CHILDREN(tx_stats_node),
723 OID_AUTO, prefix, CTLFLAG_RD,
724 NULL, "Queue name");
725 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
726
727 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_pkts",
728 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_pkts,
729 "Transmit Packets");
730 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_bytes",
731 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_bytes,
732 "Transmit Bytes");
733 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_reqs",
734 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_reqs, 0,
735 "Transmit Requests");
736 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_stops",
737 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_stops, 0,
738 "Transmit Stops");
739 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_wrbs",
740 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_wrbs, 0,
741 "Transmit WRB's");
742 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_compl",
743 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_compl, 0,
744 "Transmit Completions");
745 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
746 "ipv6_ext_hdr_tx_drop",CTLFLAG_RD,
747 &sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop, 0,
748 "Transmit IPV6 Ext Header Drop");
749
750 }
751 return;
752}
753
754
755static void
756oce_add_stats_sysctls_xe201(POCE_SOFTC sc,
757 struct sysctl_ctx_list *ctx,
758 struct sysctl_oid *stats_node)
759{
760 struct sysctl_oid *rx_stats_node, *tx_stats_node;
761 struct sysctl_oid_list *rx_stat_list, *tx_stat_list;
762 struct sysctl_oid_list *queue_stats_list;
763 struct sysctl_oid *queue_stats_node;
764 struct oce_drv_stats *stats;
765 char prefix[32];
766 int i;
767
768 stats = &sc->oce_stats_info;
769
770 rx_stats_node = SYSCTL_ADD_NODE(ctx,
771 SYSCTL_CHILDREN(stats_node),
772 OID_AUTO, "rx", CTLFLAG_RD,
773 NULL, "RX Ethernet Statistics");
774 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
775
776
777 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_pkts",
778 CTLFLAG_RD, &stats->rx.t_rx_pkts,
779 "Total Received Packets");
780 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_bytes",
781 CTLFLAG_RD, &stats->rx.t_rx_bytes,
782 "Total Received Bytes");
783 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags",
784 CTLFLAG_RD, &stats->rx.t_rx_frags, 0,
785 "Total Received Fragements");
786 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts",
787 CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0,
788 "Total Received Multicast Packets");
789 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_ucast_pkts",
790 CTLFLAG_RD, &stats->rx.t_rx_ucast_pkts, 0,
791 "Total Received Unicast Packets");
792 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_rxcp_errs",
793 CTLFLAG_RD, &stats->rx.t_rxcp_errs, 0,
794 "Total Receive completion errors");
795 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pause_frames",
796 CTLFLAG_RD, &stats->u0.xe201.rx_pause_frames, 0,
797 "Pause Frames");
798 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "control_frames",
799 CTLFLAG_RD, &stats->u0.xe201.rx_control_frames, 0,
800 "Control Frames");
801
802 for (i = 0; i < sc->nrqs; i++) {
803 sprintf(prefix, "queue%d",i);
804 queue_stats_node = SYSCTL_ADD_NODE(ctx,
805 SYSCTL_CHILDREN(rx_stats_node),
806 OID_AUTO, prefix, CTLFLAG_RD,
807 NULL, "Queue name");
808 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
809
810 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_pkts",
811 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_pkts,
812 "Receive Packets");
813 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes",
814 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes,
815 "Recived Bytes");
816 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags",
817 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0,
818 "Received Fragments");
819 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
820 "rx_mcast_pkts", CTLFLAG_RD,
821 &sc->rq[i]->rx_stats.rx_mcast_pkts, 0,
822 "Received Multicast Packets");
823 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
824 "rx_ucast_pkts",CTLFLAG_RD,
825 &sc->rq[i]->rx_stats.rx_ucast_pkts, 0,
826 "Received Unicast Packets");
827 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rxcp_err",
828 CTLFLAG_RD, &sc->rq[i]->rx_stats.rxcp_err, 0,
829 "Received Completion Errors");
830
831 }
832
833 rx_stats_node = SYSCTL_ADD_NODE(ctx,
834 SYSCTL_CHILDREN(rx_stats_node),
835 OID_AUTO, "err", CTLFLAG_RD,
836 NULL, "Receive Error Stats");
837 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
838
839 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "crc_errs",
840 CTLFLAG_RD, &stats->u0.xe201.rx_crc_errors, 0,
841 "CRC Errors");
842 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors",
843 CTLFLAG_RD, &stats->u0.xe201.rx_alignment_errors, 0,
844 "RX Alignmnet Errors");
845 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors",
846 CTLFLAG_RD, &stats->u0.xe201.rx_in_range_errors, 0,
847 "In Range Errors");
848 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "out_range_errors",
849 CTLFLAG_RD, &stats->u0.xe201.rx_out_of_range_errors, 0,
850 "Out Range Errors");
851 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "frame_too_long",
852 CTLFLAG_RD, &stats->u0.xe201.rx_frames_too_long, 0,
853 "Frame Too Long");
854 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "address_match_errors",
855 CTLFLAG_RD, &stats->u0.xe201.rx_address_match_errors, 0,
856 "Address Match Errors");
857 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_small",
858 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_too_small, 0,
859 "Dropped Too Small");
860 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_short",
861 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_too_short, 0,
862 "Dropped Too Short");
863 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
864 "dropped_header_too_small", CTLFLAG_RD,
865 &stats->u0.xe201.rx_dropped_header_too_small, 0,
866 "Dropped Header Too Small");
867 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
868 "dropped_tcp_length", CTLFLAG_RD,
869 &stats->u0.xe201.rx_dropped_invalid_tcp_length, 0,
870 "Dropped TCP Length");
871 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_runt",
872 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_runt, 0,
873 "Dropped runt");
874 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "ip_checksum_errs",
875 CTLFLAG_RD, &stats->u0.xe201.rx_ip_checksum_errors, 0,
876 "IP Checksum Errors");
877 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "tcp_checksum_errs",
878 CTLFLAG_RD, &stats->u0.xe201.rx_tcp_checksum_errors, 0,
879 "TCP Checksum Errors");
880 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "udp_checksum_errs",
881 CTLFLAG_RD, &stats->u0.xe201.rx_udp_checksum_errors, 0,
882 "UDP Checksum Errors");
883 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "input_fifo_overflow_drop",
884 CTLFLAG_RD, &stats->u0.xe201.rx_fifo_overflow, 0,
885 "Input FIFO Overflow Drop");
886
887 tx_stats_node = SYSCTL_ADD_NODE(ctx,
888 SYSCTL_CHILDREN(stats_node),
889 OID_AUTO, "tx", CTLFLAG_RD,
890 NULL, "TX Ethernet Statistics");
891 tx_stat_list = SYSCTL_CHILDREN(tx_stats_node);
892
893 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_pkts",
894 CTLFLAG_RD, &stats->tx.t_tx_pkts,
895 "Total Transmit Packets");
896 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_bytes",
897 CTLFLAG_RD, &stats->tx.t_tx_bytes,
898 "Total Transmit Bytes");
899 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_reqs",
900 CTLFLAG_RD, &stats->tx.t_tx_reqs, 0,
901 "Total Transmit Requests");
902 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_stops",
903 CTLFLAG_RD, &stats->tx.t_tx_stops, 0,
904 "Total Transmit Stops");
905 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_wrbs",
906 CTLFLAG_RD, &stats->tx.t_tx_wrbs, 0,
907 "Total Transmit WRB's");
908 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_compl",
909 CTLFLAG_RD, &stats->tx.t_tx_compl, 0,
910 "Total Transmit Completions");
911 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO,
912 "total_ipv6_ext_hdr_tx_drop",
913 CTLFLAG_RD, &stats->tx.t_ipv6_ext_hdr_tx_drop, 0,
914 "Total Transmit IPV6 Drops");
915 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "pauseframes",
916 CTLFLAG_RD, &stats->u0.xe201.tx_pause_frames, 0,
917 "Pause Frames");
918 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "controlframes",
919 CTLFLAG_RD, &stats->u0.xe201.tx_control_frames, 0,
920 "Tx Control Frames");
921
922 for (i = 0; i < sc->nwqs; i++) {
923 sprintf(prefix, "queue%d",i);
924 queue_stats_node = SYSCTL_ADD_NODE(ctx,
925 SYSCTL_CHILDREN(tx_stats_node),
926 OID_AUTO, prefix, CTLFLAG_RD,
927 NULL, "Queue name");
928 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
929
930 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_pkts",
931 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_pkts,
932 "Transmit Packets");
933 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_bytes",
934 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_bytes,
935 "Transmit Bytes");
936 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_reqs",
937 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_reqs, 0,
938 "Transmit Requests");
939 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_stops",
940 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_stops, 0,
941 "Transmit Stops");
942 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_wrbs",
943 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_wrbs, 0,
944 "Transmit WRB's");
945 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_compl",
946 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_compl, 0,
947 "Transmit Completions");
948 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
949 "ipv6_ext_hdr_tx_drop", CTLFLAG_RD,
950 &sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop, 0,
951 "Transmit IPV6 Ext Header Drop");
952
953 }
954 return;
955}
956
957
958void
959oce_refresh_queue_stats(POCE_SOFTC sc)
960{
961 struct oce_drv_stats *adapter_stats;
962 int i;
963
964 adapter_stats = &sc->oce_stats_info;
965
966 /* Caluculate total TX and TXstats from all queues */
967
968 bzero(&adapter_stats->rx, sizeof(struct oce_rx_stats));
969 for (i = 0; i < sc->nrqs; i++) {
970
971 adapter_stats->rx.t_rx_pkts += sc->rq[i]->rx_stats.rx_pkts;
972 adapter_stats->rx.t_rx_bytes += sc->rq[i]->rx_stats.rx_bytes;
973 adapter_stats->rx.t_rx_frags += sc->rq[i]->rx_stats.rx_frags;
974 adapter_stats->rx.t_rx_mcast_pkts +=
975 sc->rq[i]->rx_stats.rx_mcast_pkts;
976 adapter_stats->rx.t_rx_ucast_pkts +=
977 sc->rq[i]->rx_stats.rx_ucast_pkts;
978 adapter_stats->rx.t_rxcp_errs += sc-> rq[i]->rx_stats.rxcp_err;
979 }
980
981 bzero(&adapter_stats->tx, sizeof(struct oce_tx_stats));
982 for (i = 0; i < sc->nwqs; i++) {
983 adapter_stats->tx.t_tx_reqs += sc->wq[i]->tx_stats.tx_reqs;
984 adapter_stats->tx.t_tx_stops += sc->wq[i]->tx_stats.tx_stops;
985 adapter_stats->tx.t_tx_wrbs += sc->wq[i]->tx_stats.tx_wrbs;
986 adapter_stats->tx.t_tx_compl += sc->wq[i]->tx_stats.tx_compl;
987 adapter_stats->tx.t_tx_bytes += sc->wq[i]->tx_stats.tx_bytes;
988 adapter_stats->tx.t_tx_pkts += sc->wq[i]->tx_stats.tx_pkts;
989 adapter_stats->tx.t_ipv6_ext_hdr_tx_drop +=
990 sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop;
991 }
992
993}
994
995
996
997static void
998copy_stats_to_sc_xe201(POCE_SOFTC sc)
999{
1000 struct oce_xe201_stats *adapter_stats;
1001 struct mbx_get_pport_stats *nic_mbx;
1002 struct pport_stats *port_stats;
1003
1004 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_pport_stats);
1005 port_stats = &nic_mbx->params.rsp.pps;
1006 adapter_stats = &sc->oce_stats_info.u0.xe201;
1007
1008 adapter_stats->tx_pkts = port_stats->tx_pkts;
1009 adapter_stats->tx_unicast_pkts = port_stats->tx_unicast_pkts;
1010 adapter_stats->tx_multicast_pkts = port_stats->tx_multicast_pkts;
1011 adapter_stats->tx_broadcast_pkts = port_stats->tx_broadcast_pkts;
1012 adapter_stats->tx_bytes = port_stats->tx_bytes;
1013 adapter_stats->tx_unicast_bytes = port_stats->tx_unicast_bytes;
1014 adapter_stats->tx_multicast_bytes = port_stats->tx_multicast_bytes;
1015 adapter_stats->tx_broadcast_bytes = port_stats->tx_broadcast_bytes;
1016 adapter_stats->tx_discards = port_stats->tx_discards;
1017 adapter_stats->tx_errors = port_stats->tx_errors;
1018 adapter_stats->tx_pause_frames = port_stats->tx_pause_frames;
1019 adapter_stats->tx_pause_on_frames = port_stats->tx_pause_on_frames;
1020 adapter_stats->tx_pause_off_frames = port_stats->tx_pause_off_frames;
1021 adapter_stats->tx_internal_mac_errors =
1022 port_stats->tx_internal_mac_errors;
1023 adapter_stats->tx_control_frames = port_stats->tx_control_frames;
1024 adapter_stats->tx_pkts_64_bytes = port_stats->tx_pkts_64_bytes;
1025 adapter_stats->tx_pkts_65_to_127_bytes =
1026 port_stats->tx_pkts_65_to_127_bytes;
1027 adapter_stats->tx_pkts_128_to_255_bytes =
1028 port_stats->tx_pkts_128_to_255_bytes;
1029 adapter_stats->tx_pkts_256_to_511_bytes =
1030 port_stats->tx_pkts_256_to_511_bytes;
1031 adapter_stats->tx_pkts_512_to_1023_bytes =
1032 port_stats->tx_pkts_512_to_1023_bytes;
1033 adapter_stats->tx_pkts_1024_to_1518_bytes =
1034 port_stats->tx_pkts_1024_to_1518_bytes;
1035 adapter_stats->tx_pkts_1519_to_2047_bytes =
1036 port_stats->tx_pkts_1519_to_2047_bytes;
1037 adapter_stats->tx_pkts_2048_to_4095_bytes =
1038 port_stats->tx_pkts_2048_to_4095_bytes;
1039 adapter_stats->tx_pkts_4096_to_8191_bytes =
1040 port_stats->tx_pkts_4096_to_8191_bytes;
1041 adapter_stats->tx_pkts_8192_to_9216_bytes =
1042 port_stats->tx_pkts_8192_to_9216_bytes;
1043 adapter_stats->tx_lso_pkts = port_stats->tx_lso_pkts;
1044 adapter_stats->rx_pkts = port_stats->rx_pkts;
1045 adapter_stats->rx_unicast_pkts = port_stats->rx_unicast_pkts;
1046 adapter_stats->rx_multicast_pkts = port_stats->rx_multicast_pkts;
1047 adapter_stats->rx_broadcast_pkts = port_stats->rx_broadcast_pkts;
1048 adapter_stats->rx_bytes = port_stats->rx_bytes;
1049 adapter_stats->rx_unicast_bytes = port_stats->rx_unicast_bytes;
1050 adapter_stats->rx_multicast_bytes = port_stats->rx_multicast_bytes;
1051 adapter_stats->rx_broadcast_bytes = port_stats->rx_broadcast_bytes;
1052 adapter_stats->rx_unknown_protos = port_stats->rx_unknown_protos;
1053 adapter_stats->rx_discards = port_stats->rx_discards;
1054 adapter_stats->rx_errors = port_stats->rx_errors;
1055 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1056 adapter_stats->rx_alignment_errors = port_stats->rx_alignment_errors;
1057 adapter_stats->rx_symbol_errors = port_stats->rx_symbol_errors;
1058 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1059 adapter_stats->rx_pause_on_frames = port_stats->rx_pause_on_frames;
1060 adapter_stats->rx_pause_off_frames = port_stats->rx_pause_off_frames;
1061 adapter_stats->rx_frames_too_long = port_stats->rx_frames_too_long;
1062 adapter_stats->rx_internal_mac_errors =
1063 port_stats->rx_internal_mac_errors;
1064 adapter_stats->rx_undersize_pkts = port_stats->rx_undersize_pkts;
1065 adapter_stats->rx_oversize_pkts = port_stats->rx_oversize_pkts;
1066 adapter_stats->rx_fragment_pkts = port_stats->rx_fragment_pkts;
1067 adapter_stats->rx_jabbers = port_stats->rx_jabbers;
1068 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1069 adapter_stats->rx_control_frames_unknown_opcode =
1070 port_stats->rx_control_frames_unknown_opcode;
1071 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1072 adapter_stats->rx_out_of_range_errors =
1073 port_stats->rx_out_of_range_errors;
1074 adapter_stats->rx_address_match_errors =
1075 port_stats->rx_address_match_errors;
1076 adapter_stats->rx_vlan_mismatch_errors =
1077 port_stats->rx_vlan_mismatch_errors;
1078 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1079 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1080 adapter_stats->rx_dropped_header_too_small =
1081 port_stats->rx_dropped_header_too_small;
1082 adapter_stats->rx_dropped_invalid_tcp_length =
1083 port_stats->rx_dropped_invalid_tcp_length;
1084 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1085 adapter_stats->rx_ip_checksum_errors =
1086 port_stats->rx_ip_checksum_errors;
1087 adapter_stats->rx_tcp_checksum_errors =
1088 port_stats->rx_tcp_checksum_errors;
1089 adapter_stats->rx_udp_checksum_errors =
1090 port_stats->rx_udp_checksum_errors;
1091 adapter_stats->rx_non_rss_pkts = port_stats->rx_non_rss_pkts;
1092 adapter_stats->rx_ipv4_pkts = port_stats->rx_ipv4_pkts;
1093 adapter_stats->rx_ipv6_pkts = port_stats->rx_ipv6_pkts;
1094 adapter_stats->rx_ipv4_bytes = port_stats->rx_ipv4_bytes;
1095 adapter_stats->rx_ipv6_bytes = port_stats->rx_ipv6_bytes;
1096 adapter_stats->rx_nic_pkts = port_stats->rx_nic_pkts;
1097 adapter_stats->rx_tcp_pkts = port_stats->rx_tcp_pkts;
1098 adapter_stats->rx_iscsi_pkts = port_stats->rx_iscsi_pkts;
1099 adapter_stats->rx_management_pkts = port_stats->rx_management_pkts;
1100 adapter_stats->rx_switched_unicast_pkts =
1101 port_stats->rx_switched_unicast_pkts;
1102 adapter_stats->rx_switched_multicast_pkts =
1103 port_stats->rx_switched_multicast_pkts;
1104 adapter_stats->rx_switched_broadcast_pkts =
1105 port_stats->rx_switched_broadcast_pkts;
1106 adapter_stats->num_forwards = port_stats->num_forwards;
1107 adapter_stats->rx_fifo_overflow = port_stats->rx_fifo_overflow;
1108 adapter_stats->rx_input_fifo_overflow =
1109 port_stats->rx_input_fifo_overflow;
1110 adapter_stats->rx_drops_too_many_frags =
1111 port_stats->rx_drops_too_many_frags;
1112 adapter_stats->rx_drops_invalid_queue =
1113 port_stats->rx_drops_invalid_queue;
1114 adapter_stats->rx_drops_mtu = port_stats->rx_drops_mtu;
1115 adapter_stats->rx_pkts_64_bytes = port_stats->rx_pkts_64_bytes;
1116 adapter_stats->rx_pkts_65_to_127_bytes =
1117 port_stats->rx_pkts_65_to_127_bytes;
1118 adapter_stats->rx_pkts_128_to_255_bytes =
1119 port_stats->rx_pkts_128_to_255_bytes;
1120 adapter_stats->rx_pkts_256_to_511_bytes =
1121 port_stats->rx_pkts_256_to_511_bytes;
1122 adapter_stats->rx_pkts_512_to_1023_bytes =
1123 port_stats->rx_pkts_512_to_1023_bytes;
1124 adapter_stats->rx_pkts_1024_to_1518_bytes =
1125 port_stats->rx_pkts_1024_to_1518_bytes;
1126 adapter_stats->rx_pkts_1519_to_2047_bytes =
1127 port_stats->rx_pkts_1519_to_2047_bytes;
1128 adapter_stats->rx_pkts_2048_to_4095_bytes =
1129 port_stats->rx_pkts_2048_to_4095_bytes;
1130 adapter_stats->rx_pkts_4096_to_8191_bytes =
1131 port_stats->rx_pkts_4096_to_8191_bytes;
1132 adapter_stats->rx_pkts_8192_to_9216_bytes =
1133 port_stats->rx_pkts_8192_to_9216_bytes;
1134}
1135
1136
1137
1138static void
1139copy_stats_to_sc_be2(POCE_SOFTC sc)
1140{
1141 struct oce_be_stats *adapter_stats;
1142 struct oce_pmem_stats *pmem;
1143 struct oce_rxf_stats_v0 *rxf_stats;
1144 struct oce_port_rxf_stats_v0 *port_stats;
1145 struct mbx_get_nic_stats_v0 *nic_mbx;
1146 uint32_t port = sc->port_id;
1147
1148 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_nic_stats_v0);
1149 pmem = &nic_mbx->params.rsp.stats.pmem;
1150 rxf_stats = &nic_mbx->params.rsp.stats.rxf;
1151 port_stats = &nic_mbx->params.rsp.stats.rxf.port[port];
1152
1153 adapter_stats = &sc->oce_stats_info.u0.be;
1154
1155
1156 /* Update stats */
1157 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1158 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1159 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1160 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1161 adapter_stats->rx_frame_too_long = port_stats->rx_frame_too_long;
1162 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1163 adapter_stats->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs;
1164 adapter_stats->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs;
1165 adapter_stats->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs;
1166 adapter_stats->rxpp_fifo_overflow_drop =
1167 port_stats->rxpp_fifo_overflow_drop;
1168 adapter_stats->rx_dropped_tcp_length =
1169 port_stats->rx_dropped_tcp_length;
1170 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1171 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1172 adapter_stats->rx_out_range_errors = port_stats->rx_out_range_errors;
1173 adapter_stats->rx_dropped_header_too_small =
1174 port_stats->rx_dropped_header_too_small;
1175 adapter_stats->rx_input_fifo_overflow_drop =
1176 port_stats->rx_input_fifo_overflow_drop;
1177 adapter_stats->rx_address_match_errors =
1178 port_stats->rx_address_match_errors;
1179 adapter_stats->rx_alignment_symbol_errors =
1180 port_stats->rx_alignment_symbol_errors;
1181 adapter_stats->tx_pauseframes = port_stats->tx_pauseframes;
1182 adapter_stats->tx_controlframes = port_stats->tx_controlframes;
1183
1184 if (sc->if_id)
1185 adapter_stats->jabber_events = rxf_stats->port1_jabber_events;
1186 else
1187 adapter_stats->jabber_events = rxf_stats->port0_jabber_events;
1188
1189 adapter_stats->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf;
1190 adapter_stats->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb;
1191 adapter_stats->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr;
1192 adapter_stats->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring;
1193 adapter_stats->forwarded_packets = rxf_stats->forwarded_packets;
1194 adapter_stats->rx_drops_mtu = rxf_stats->rx_drops_mtu;
1195 adapter_stats->rx_drops_no_tpre_descr =
1196 rxf_stats->rx_drops_no_tpre_descr;
1197 adapter_stats->rx_drops_too_many_frags =
1198 rxf_stats->rx_drops_too_many_frags;
1199 adapter_stats->eth_red_drops = pmem->eth_red_drops;
1200}
1201
1202
1203static void
1204copy_stats_to_sc_be3(POCE_SOFTC sc)
1205{
1206 struct oce_be_stats *adapter_stats;
1207 struct oce_pmem_stats *pmem;
1208 struct oce_rxf_stats_v1 *rxf_stats;
1209 struct oce_port_rxf_stats_v1 *port_stats;
1210 struct mbx_get_nic_stats *nic_mbx;
1211 uint32_t port = sc->port_id;
1212
1213 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_nic_stats);
1214 pmem = &nic_mbx->params.rsp.stats.pmem;
1215 rxf_stats = &nic_mbx->params.rsp.stats.rxf;
1216 port_stats = &nic_mbx->params.rsp.stats.rxf.port[port];
1217
1218 adapter_stats = &sc->oce_stats_info.u0.be;
1219
1220 /* Update stats */
1221 adapter_stats->pmem_fifo_overflow_drop =
1222 port_stats->pmem_fifo_overflow_drop;
1223 adapter_stats->rx_priority_pause_frames =
1224 port_stats->rx_priority_pause_frames;
1225 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1226 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1227 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1228 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1229 adapter_stats->rx_frame_too_long = port_stats->rx_frame_too_long;
1230 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1231 adapter_stats->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs;
1232 adapter_stats->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs;
1233 adapter_stats->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs;
1234 adapter_stats->rx_dropped_tcp_length =
1235 port_stats->rx_dropped_tcp_length;
1236 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1237 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1238 adapter_stats->rx_out_range_errors = port_stats->rx_out_range_errors;
1239 adapter_stats->rx_dropped_header_too_small =
1240 port_stats->rx_dropped_header_too_small;
1241 adapter_stats->rx_input_fifo_overflow_drop =
1242 port_stats->rx_input_fifo_overflow_drop;
1243 adapter_stats->rx_address_match_errors =
1244 port_stats->rx_address_match_errors;
1245 adapter_stats->rx_alignment_symbol_errors =
1246 port_stats->rx_alignment_symbol_errors;
1247 adapter_stats->rxpp_fifo_overflow_drop =
1248 port_stats->rxpp_fifo_overflow_drop;
1249 adapter_stats->tx_pauseframes = port_stats->tx_pauseframes;
1250 adapter_stats->tx_controlframes = port_stats->tx_controlframes;
1251 adapter_stats->jabber_events = port_stats->jabber_events;
1252
1253 adapter_stats->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf;
1254 adapter_stats->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb;
1255 adapter_stats->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr;
1256 adapter_stats->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring;
1257 adapter_stats->forwarded_packets = rxf_stats->forwarded_packets;
1258 adapter_stats->rx_drops_mtu = rxf_stats->rx_drops_mtu;
1259 adapter_stats->rx_drops_no_tpre_descr =
1260 rxf_stats->rx_drops_no_tpre_descr;
1261 adapter_stats->rx_drops_too_many_frags =
1262 rxf_stats->rx_drops_too_many_frags;
1263
1264 adapter_stats->eth_red_drops = pmem->eth_red_drops;
1265}
1266
1267
1268int
1269oce_stats_init(POCE_SOFTC sc)
1270{
1271 int rc = 0, sz;
1272
1273 if (IS_BE(sc) || IS_SH(sc)) {
1274 if (sc->flags & OCE_FLAGS_BE2)
1275 sz = sizeof(struct mbx_get_nic_stats_v0);
1276 else
1277 sz = sizeof(struct mbx_get_nic_stats);
1278 } else
1279 sz = sizeof(struct mbx_get_pport_stats);
1280
1281 rc = oce_dma_alloc(sc, sz, &sc->stats_mem, 0);
1282
1283 return rc;
1284}
1285
1286
1287void
1288oce_stats_free(POCE_SOFTC sc)
1289{
1290
1291 oce_dma_free(sc, &sc->stats_mem);
1292
1293}
1294
1295
1296int
1297oce_refresh_nic_stats(POCE_SOFTC sc)
1298{
1299 int rc = 0, reset = 0;
1300
1301 if (IS_BE(sc) || IS_SH(sc)) {
1302 if (sc->flags & OCE_FLAGS_BE2) {
1303 rc = oce_mbox_get_nic_stats_v0(sc, &sc->stats_mem);
1304 if (!rc)
1305 copy_stats_to_sc_be2(sc);
1306 } else {
1307 rc = oce_mbox_get_nic_stats(sc, &sc->stats_mem);
1308 if (!rc)
1309 copy_stats_to_sc_be3(sc);
1310 }
1311
1312 } else {
1313 rc = oce_mbox_get_pport_stats(sc, &sc->stats_mem, reset);
1314 if (!rc)
1315 copy_stats_to_sc_xe201(sc);
1316 }
1317
1318 return rc;
1319}
1320
1321static int
1322oce_sysctl_sfp_vpd_dump(SYSCTL_HANDLER_ARGS)
1323{
1324 int result = 0, error;
1325 int rc = 0;
1326 POCE_SOFTC sc = (POCE_SOFTC) arg1;
1327
1328 /* sysctl default handler */
1329 error = sysctl_handle_int(oidp, &result, 0, req);
1330 if (error || !req->newptr)
1331 return (error);
1332
1333 if(result == -1) {
1334 return EINVAL;
1335 }
1336 bzero((char *)sfp_vpd_dump_buffer, TRANSCEIVER_DATA_SIZE);
1337
1338 rc = oce_mbox_read_transrecv_data(sc, PAGE_NUM_A0);
1339 if(rc)
1340 return rc;
1341
1342 rc = oce_mbox_read_transrecv_data(sc, PAGE_NUM_A2);
1343 if(rc)
1344 return rc;
1345
1346 return rc;
1347}