Deleted Added
full compact
qlnx_os.c (322849) qlnx_os.c (322851)
1/*
2 * Copyright (c) 2017-2018 Cavium, Inc.
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
7 * are met:
8 *

--- 18 unchanged lines hidden (view full) ---

27
28
29/*
30 * File: qlnx_os.c
31 * Author : David C Somayajulu, Cavium, Inc., San Jose, CA 95131.
32 */
33
34#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2017-2018 Cavium, Inc.
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
7 * are met:
8 *

--- 18 unchanged lines hidden (view full) ---

27
28
29/*
30 * File: qlnx_os.c
31 * Author : David C Somayajulu, Cavium, Inc., San Jose, CA 95131.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c 322849 2017-08-24 17:36:10Z davidcs $");
35__FBSDID("$FreeBSD: stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c 322851 2017-08-24 18:51:55Z davidcs $");
36
37#include "qlnx_os.h"
38#include "bcm_osal.h"
39#include "reg_addr.h"
40#include "ecore_gtt_reg_addr.h"
41#include "ecore.h"
42#include "ecore_chain.h"
43#include "ecore_status.h"

--- 45 unchanged lines hidden (view full) ---

89static void qlnx_media_status(struct ifnet *ifp, struct ifmediareq *ifmr);
90static void qlnx_stop(qlnx_host_t *ha);
91static int qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp,
92 struct mbuf **m_headp);
93static int qlnx_get_ifq_snd_maxlen(qlnx_host_t *ha);
94static uint32_t qlnx_get_optics(qlnx_host_t *ha,
95 struct qlnx_link_output *if_link);
96static int qlnx_transmit(struct ifnet *ifp, struct mbuf *mp);
36
37#include "qlnx_os.h"
38#include "bcm_osal.h"
39#include "reg_addr.h"
40#include "ecore_gtt_reg_addr.h"
41#include "ecore.h"
42#include "ecore_chain.h"
43#include "ecore_status.h"

--- 45 unchanged lines hidden (view full) ---

89static void qlnx_media_status(struct ifnet *ifp, struct ifmediareq *ifmr);
90static void qlnx_stop(qlnx_host_t *ha);
91static int qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp,
92 struct mbuf **m_headp);
93static int qlnx_get_ifq_snd_maxlen(qlnx_host_t *ha);
94static uint32_t qlnx_get_optics(qlnx_host_t *ha,
95 struct qlnx_link_output *if_link);
96static int qlnx_transmit(struct ifnet *ifp, struct mbuf *mp);
97static int qlnx_transmit_locked(struct ifnet *ifp, struct qlnx_fastpath *fp,
98 struct mbuf *mp);
97static void qlnx_qflush(struct ifnet *ifp);
98
99static int qlnx_alloc_parent_dma_tag(qlnx_host_t *ha);
100static void qlnx_free_parent_dma_tag(qlnx_host_t *ha);
101static int qlnx_alloc_tx_dma_tag(qlnx_host_t *ha);
102static void qlnx_free_tx_dma_tag(qlnx_host_t *ha);
103static int qlnx_alloc_rx_dma_tag(qlnx_host_t *ha);
104static void qlnx_free_rx_dma_tag(qlnx_host_t *ha);

--- 23 unchanged lines hidden (view full) ---

128static int qlnx_grc_dumpsize(qlnx_host_t *ha, uint32_t *num_dwords,
129 int hwfn_index);
130static int qlnx_idle_chk_size(qlnx_host_t *ha, uint32_t *num_dwords,
131 int hwfn_index);
132static void qlnx_timer(void *arg);
133static int qlnx_alloc_tx_br(qlnx_host_t *ha, struct qlnx_fastpath *fp);
134static void qlnx_free_tx_br(qlnx_host_t *ha, struct qlnx_fastpath *fp);
135static void qlnx_trigger_dump(qlnx_host_t *ha);
99static void qlnx_qflush(struct ifnet *ifp);
100
101static int qlnx_alloc_parent_dma_tag(qlnx_host_t *ha);
102static void qlnx_free_parent_dma_tag(qlnx_host_t *ha);
103static int qlnx_alloc_tx_dma_tag(qlnx_host_t *ha);
104static void qlnx_free_tx_dma_tag(qlnx_host_t *ha);
105static int qlnx_alloc_rx_dma_tag(qlnx_host_t *ha);
106static void qlnx_free_rx_dma_tag(qlnx_host_t *ha);

--- 23 unchanged lines hidden (view full) ---

130static int qlnx_grc_dumpsize(qlnx_host_t *ha, uint32_t *num_dwords,
131 int hwfn_index);
132static int qlnx_idle_chk_size(qlnx_host_t *ha, uint32_t *num_dwords,
133 int hwfn_index);
134static void qlnx_timer(void *arg);
135static int qlnx_alloc_tx_br(qlnx_host_t *ha, struct qlnx_fastpath *fp);
136static void qlnx_free_tx_br(qlnx_host_t *ha, struct qlnx_fastpath *fp);
137static void qlnx_trigger_dump(qlnx_host_t *ha);
138static uint16_t qlnx_num_tx_compl(qlnx_host_t *ha, struct qlnx_fastpath *fp,
139 struct qlnx_tx_queue *txq);
136static void qlnx_tx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp,
137 struct qlnx_tx_queue *txq);
138static int qlnx_rx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp, int budget,
139 int lro_enable);
140static void qlnx_fp_taskqueue(void *context, int pending);
141static void qlnx_sample_storm_stats(qlnx_host_t *ha);
142static int qlnx_alloc_tpa_mbuf(qlnx_host_t *ha, uint16_t rx_buf_size,
143 struct qlnx_agg_info *tpa);

--- 66 unchanged lines hidden (view full) ---

210#define QLOGIC_PCI_DEVICE_ID_1654 0x1654
211#endif
212
213/* 10G/25G/40G Adapter QLE41xxx*/
214#ifndef QLOGIC_PCI_DEVICE_ID_8070
215#define QLOGIC_PCI_DEVICE_ID_8070 0x8070
216#endif
217
140static void qlnx_tx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp,
141 struct qlnx_tx_queue *txq);
142static int qlnx_rx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp, int budget,
143 int lro_enable);
144static void qlnx_fp_taskqueue(void *context, int pending);
145static void qlnx_sample_storm_stats(qlnx_host_t *ha);
146static int qlnx_alloc_tpa_mbuf(qlnx_host_t *ha, uint16_t rx_buf_size,
147 struct qlnx_agg_info *tpa);

--- 66 unchanged lines hidden (view full) ---

214#define QLOGIC_PCI_DEVICE_ID_1654 0x1654
215#endif
216
217/* 10G/25G/40G Adapter QLE41xxx*/
218#ifndef QLOGIC_PCI_DEVICE_ID_8070
219#define QLOGIC_PCI_DEVICE_ID_8070 0x8070
220#endif
221
222SYSCTL_NODE(_hw, OID_AUTO, qlnxe, CTLFLAG_RD, 0, "qlnxe driver parameters");
223/* Number of Queues: 0 (Auto) or 1 to 32 (fixed queue number) */
224static int qlnxe_queue_count = QLNX_DEFAULT_RSS;
225SYSCTL_INT(_hw_qlnxe, OID_AUTO, queue_count, CTLFLAG_RDTUN,
226 &qlnxe_queue_count, 0, "Multi-Queue queue count");
227
218static int
219qlnx_valid_device(device_t dev)
220{
221 uint16_t device_id;
222
223 device_id = pci_get_device(dev);
224
225 if ((device_id == QLOGIC_PCI_DEVICE_ID_1634) ||

--- 71 unchanged lines hidden (view full) ---

297
298 default:
299 return (ENXIO);
300 }
301
302 return (BUS_PROBE_DEFAULT);
303}
304
228static int
229qlnx_valid_device(device_t dev)
230{
231 uint16_t device_id;
232
233 device_id = pci_get_device(dev);
234
235 if ((device_id == QLOGIC_PCI_DEVICE_ID_1634) ||

--- 71 unchanged lines hidden (view full) ---

307
308 default:
309 return (ENXIO);
310 }
311
312 return (BUS_PROBE_DEFAULT);
313}
314
315static uint16_t
316qlnx_num_tx_compl(qlnx_host_t *ha, struct qlnx_fastpath *fp,
317 struct qlnx_tx_queue *txq)
318{
319 u16 hw_bd_cons;
320 u16 ecore_cons_idx;
321 uint16_t diff;
305
322
323 hw_bd_cons = le16toh(*txq->hw_cons_ptr);
324
325 ecore_cons_idx = ecore_chain_get_cons_idx(&txq->tx_pbl);
326 if (hw_bd_cons < ecore_cons_idx) {
327 diff = (1 << 16) - (ecore_cons_idx - hw_bd_cons);
328 } else {
329 diff = hw_bd_cons - ecore_cons_idx;
330 }
331 return diff;
332}
333
334
306static void
307qlnx_sp_intr(void *arg)
308{
309 struct ecore_hwfn *p_hwfn;
310 qlnx_host_t *ha;
311 int i;
312
313 p_hwfn = arg;

--- 76 unchanged lines hidden (view full) ---

390}
391
392static void
393qlnx_fp_taskqueue(void *context, int pending)
394{
395 struct qlnx_fastpath *fp;
396 qlnx_host_t *ha;
397 struct ifnet *ifp;
335static void
336qlnx_sp_intr(void *arg)
337{
338 struct ecore_hwfn *p_hwfn;
339 qlnx_host_t *ha;
340 int i;
341
342 p_hwfn = arg;

--- 76 unchanged lines hidden (view full) ---

419}
420
421static void
422qlnx_fp_taskqueue(void *context, int pending)
423{
424 struct qlnx_fastpath *fp;
425 qlnx_host_t *ha;
426 struct ifnet *ifp;
398 struct mbuf *mp;
399 int ret;
400 struct thread *cthread;
401
402#ifdef QLNX_RCV_IN_TASKQ
403 int lro_enable;
404 int rx_int = 0, total_rx_count = 0;
427
428#ifdef QLNX_RCV_IN_TASKQ
429 int lro_enable;
430 int rx_int = 0, total_rx_count = 0;
405
431 struct thread *cthread;
406#endif /* #ifdef QLNX_RCV_IN_TASKQ */
407
408 fp = context;
409
410 if (fp == NULL)
411 return;
412
432#endif /* #ifdef QLNX_RCV_IN_TASKQ */
433
434 fp = context;
435
436 if (fp == NULL)
437 return;
438
439 ha = (qlnx_host_t *)fp->edev;
440
441 ifp = ha->ifp;
442
443#ifdef QLNX_RCV_IN_TASKQ
444
413 cthread = curthread;
414
415 thread_lock(cthread);
416
417 if (!sched_is_bound(cthread))
418 sched_bind(cthread, fp->rss_id);
419
420 thread_unlock(cthread);
421
445 cthread = curthread;
446
447 thread_lock(cthread);
448
449 if (!sched_is_bound(cthread))
450 sched_bind(cthread, fp->rss_id);
451
452 thread_unlock(cthread);
453
422 ha = (qlnx_host_t *)fp->edev;
454 lro_enable = ifp->if_capenable & IFCAP_LRO;
423
455
424 ifp = ha->ifp;
456 rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, lro_enable);
425
457
426#ifdef QLNX_RCV_IN_TASKQ
427 {
428 lro_enable = ifp->if_capenable & IFCAP_LRO;
458 if (rx_int) {
459 fp->rx_pkts += rx_int;
460 total_rx_count += rx_int;
461 }
429
462
430 rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, lro_enable);
431
432 if (rx_int) {
433 fp->rx_pkts += rx_int;
434 total_rx_count += rx_int;
435 }
436
437#ifdef QLNX_SOFT_LRO
463#ifdef QLNX_SOFT_LRO
438 {
439 struct lro_ctrl *lro;
440
441 lro = &fp->rxq->lro;
464 {
465 struct lro_ctrl *lro;
442
466
443 if (lro_enable && total_rx_count) {
467 lro = &fp->rxq->lro;
444
468
469 if (lro_enable && total_rx_count) {
470
445#if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO)
446
471#if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO)
472
447 if (ha->dbg_trace_lro_cnt) {
448 if (lro->lro_mbuf_count & ~1023)
449 fp->lro_cnt_1024++;
450 else if (lro->lro_mbuf_count & ~511)
451 fp->lro_cnt_512++;
452 else if (lro->lro_mbuf_count & ~255)
453 fp->lro_cnt_256++;
454 else if (lro->lro_mbuf_count & ~127)
455 fp->lro_cnt_128++;
456 else if (lro->lro_mbuf_count & ~63)
457 fp->lro_cnt_64++;
458 }
459 tcp_lro_flush_all(lro);
473 if (ha->dbg_trace_lro_cnt) {
474 if (lro->lro_mbuf_count & ~1023)
475 fp->lro_cnt_1024++;
476 else if (lro->lro_mbuf_count & ~511)
477 fp->lro_cnt_512++;
478 else if (lro->lro_mbuf_count & ~255)
479 fp->lro_cnt_256++;
480 else if (lro->lro_mbuf_count & ~127)
481 fp->lro_cnt_128++;
482 else if (lro->lro_mbuf_count & ~63)
483 fp->lro_cnt_64++;
484 }
485 tcp_lro_flush_all(lro);
460
461#else
486
487#else
462 struct lro_entry *queued;
488 struct lro_entry *queued;
463
489
464 while ((!SLIST_EMPTY(&lro->lro_active))) {
465 queued = SLIST_FIRST(&lro->lro_active);
466 SLIST_REMOVE_HEAD(&lro->lro_active, next);
467 tcp_lro_flush(lro, queued);
468 }
469#endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */
490 while ((!SLIST_EMPTY(&lro->lro_active))) {
491 queued = SLIST_FIRST(&lro->lro_active);
492 SLIST_REMOVE_HEAD(&lro->lro_active, next);
493 tcp_lro_flush(lro, queued);
470 }
494 }
495#endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */
471 }
496 }
497 }
472#endif /* #ifdef QLNX_SOFT_LRO */
473
498#endif /* #ifdef QLNX_SOFT_LRO */
499
474 ecore_sb_update_sb_idx(fp->sb_info);
475 rmb();
476 }
500 ecore_sb_update_sb_idx(fp->sb_info);
501 rmb();
477
478#endif /* #ifdef QLNX_RCV_IN_TASKQ */
479
502
503#endif /* #ifdef QLNX_RCV_IN_TASKQ */
504
480 mtx_lock(&fp->tx_mtx);
505 if(ifp->if_drv_flags & IFF_DRV_RUNNING) {
481
506
482 if (((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
483 IFF_DRV_RUNNING) || (!ha->link_up)) {
507 if (!drbr_empty(ifp, fp->tx_br)) {
484
508
485 mtx_unlock(&fp->tx_mtx);
486 goto qlnx_fp_taskqueue_exit;
487 }
509 if(mtx_trylock(&fp->tx_mtx)) {
488
510
489 mp = drbr_peek(ifp, fp->tx_br);
511#ifdef QLNX_TRACE_PERF_DATA
512 tx_pkts = fp->tx_pkts_transmitted;
513 tx_compl = fp->tx_pkts_completed;
514#endif
490
515
491 while (mp != NULL) {
516 qlnx_transmit_locked(ifp, fp, NULL);
492
517
493 if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
494 ret = qlnx_send(ha, fp, &mp);
495 } else {
496 ret = -1;
497 }
498
499 if (ret) {
500
501 if (mp != NULL) {
502 drbr_putback(ifp, fp->tx_br, mp);
503 } else {
504 fp->tx_pkts_processed++;
505 drbr_advance(ifp, fp->tx_br);
518#ifdef QLNX_TRACE_PERF_DATA
519 fp->tx_pkts_trans_fp +=
520 (fp->tx_pkts_transmitted - tx_pkts);
521 fp->tx_pkts_compl_fp +=
522 (fp->tx_pkts_completed - tx_compl);
523#endif
524 mtx_unlock(&fp->tx_mtx);
506 }
525 }
507
508 mtx_unlock(&fp->tx_mtx);
509
510 goto qlnx_fp_taskqueue_exit;
511
512 } else {
513 drbr_advance(ifp, fp->tx_br);
514 fp->tx_pkts_transmitted++;
515 fp->tx_pkts_processed++;
516 }
526 }
517
518 if (fp->tx_ring_full)
519 break;
520
521 mp = drbr_peek(ifp, fp->tx_br);
522 }
523
527 }
528
524 mtx_unlock(&fp->tx_mtx);
525
526qlnx_fp_taskqueue_exit:
527
528#ifdef QLNX_RCV_IN_TASKQ
529 if (rx_int) {
530 if (fp->fp_taskqueue != NULL)
531 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task);
532 } else {
533 if (fp->tx_ring_full) {
534 qlnx_mdelay(__func__, 100);
535 }
536 ecore_sb_ack(fp->sb_info, IGU_INT_ENABLE, 1);
537 }
538#endif /* #ifdef QLNX_RCV_IN_TASKQ */
539
529#ifdef QLNX_RCV_IN_TASKQ
530 if (rx_int) {
531 if (fp->fp_taskqueue != NULL)
532 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task);
533 } else {
534 if (fp->tx_ring_full) {
535 qlnx_mdelay(__func__, 100);
536 }
537 ecore_sb_ack(fp->sb_info, IGU_INT_ENABLE, 1);
538 }
539#endif /* #ifdef QLNX_RCV_IN_TASKQ */
540
540 QL_DPRINT2(ha, "exit ret = %d\n", ret);
541 QL_DPRINT2(ha, "exit \n");
541 return;
542}
543
544static int
545qlnx_create_fp_taskqueues(qlnx_host_t *ha)
546{
547 int i;
548 uint8_t tq_name[32];

--- 57 unchanged lines hidden (view full) ---

606 QLNX_UNLOCK(ha);
607 taskqueue_drain(fp->fp_taskqueue, &fp->fp_task);
608 QLNX_LOCK(ha);
609 }
610 }
611 return;
612}
613
542 return;
543}
544
545static int
546qlnx_create_fp_taskqueues(qlnx_host_t *ha)
547{
548 int i;
549 uint8_t tq_name[32];

--- 57 unchanged lines hidden (view full) ---

607 QLNX_UNLOCK(ha);
608 taskqueue_drain(fp->fp_taskqueue, &fp->fp_task);
609 QLNX_LOCK(ha);
610 }
611 }
612 return;
613}
614
615static void
616qlnx_get_params(qlnx_host_t *ha)
617{
618 if ((qlnxe_queue_count < 0) || (qlnxe_queue_count > QLNX_MAX_RSS)) {
619 device_printf(ha->pci_dev, "invalid queue_count value (%d)\n",
620 qlnxe_queue_count);
621 qlnxe_queue_count = 0;
622 }
623 return;
624}
625
614/*
615 * Name: qlnx_pci_attach
616 * Function: attaches the device to the operating system
617 */
618static int
619qlnx_pci_attach(device_t dev)
620{
621 qlnx_host_t *ha = NULL;

--- 79 unchanged lines hidden (view full) ---

701
702 if (qlnx_alloc_rx_dma_tag(ha))
703 goto qlnx_pci_attach_err;
704
705
706 if (qlnx_init_hw(ha) != 0)
707 goto qlnx_pci_attach_err;
708
626/*
627 * Name: qlnx_pci_attach
628 * Function: attaches the device to the operating system
629 */
630static int
631qlnx_pci_attach(device_t dev)
632{
633 qlnx_host_t *ha = NULL;

--- 79 unchanged lines hidden (view full) ---

713
714 if (qlnx_alloc_rx_dma_tag(ha))
715 goto qlnx_pci_attach_err;
716
717
718 if (qlnx_init_hw(ha) != 0)
719 goto qlnx_pci_attach_err;
720
721 qlnx_get_params(ha);
722
723 if((pci_get_device(dev) == QLOGIC_PCI_DEVICE_ID_1644) &&
724 (qlnxe_queue_count == QLNX_DEFAULT_RSS)) {
725 qlnxe_queue_count = QLNX_MAX_RSS;
726 }
727
709 /*
710 * Allocate MSI-x vectors
711 */
728 /*
729 * Allocate MSI-x vectors
730 */
712 ha->num_rss = QLNX_MAX_RSS;
731 if(qlnxe_queue_count == 0)
732 ha->num_rss = QLNX_DEFAULT_RSS;
733 else
734 ha->num_rss = qlnxe_queue_count;
735
713 ha->num_tc = QLNX_MAX_TC;
714
715 ha->msix_count = pci_msix_count(dev);
716
717 if (ha->msix_count > (mp_ncpus + ha->cdev.num_hwfns))
718 ha->msix_count = mp_ncpus + ha->cdev.num_hwfns;
719
720 if (!ha->msix_count ||

--- 510 unchanged lines hidden (view full) ---

1231 CTLFLAG_RD, &ha->fp_array[i].tx_pkts_transmitted,
1232 "No. of transmitted packets");
1233
1234 SYSCTL_ADD_QUAD(ctx, node_children,
1235 OID_AUTO, "tx_pkts_completed",
1236 CTLFLAG_RD, &ha->fp_array[i].tx_pkts_completed,
1237 "No. of transmit completions");
1238
736 ha->num_tc = QLNX_MAX_TC;
737
738 ha->msix_count = pci_msix_count(dev);
739
740 if (ha->msix_count > (mp_ncpus + ha->cdev.num_hwfns))
741 ha->msix_count = mp_ncpus + ha->cdev.num_hwfns;
742
743 if (!ha->msix_count ||

--- 510 unchanged lines hidden (view full) ---

1254 CTLFLAG_RD, &ha->fp_array[i].tx_pkts_transmitted,
1255 "No. of transmitted packets");
1256
1257 SYSCTL_ADD_QUAD(ctx, node_children,
1258 OID_AUTO, "tx_pkts_completed",
1259 CTLFLAG_RD, &ha->fp_array[i].tx_pkts_completed,
1260 "No. of transmit completions");
1261
1262 SYSCTL_ADD_QUAD(ctx, node_children,
1263 OID_AUTO, "tx_non_tso_pkts",
1264 CTLFLAG_RD, &ha->fp_array[i].tx_non_tso_pkts,
1265 "No. of non LSO transmited packets");
1266
1267#ifdef QLNX_TRACE_PERF_DATA
1268
1269 SYSCTL_ADD_QUAD(ctx, node_children,
1270 OID_AUTO, "tx_pkts_trans_ctx",
1271 CTLFLAG_RD, &ha->fp_array[i].tx_pkts_trans_ctx,
1272 "No. of transmitted packets in transmit context");
1273
1274 SYSCTL_ADD_QUAD(ctx, node_children,
1275 OID_AUTO, "tx_pkts_compl_ctx",
1276 CTLFLAG_RD, &ha->fp_array[i].tx_pkts_compl_ctx,
1277 "No. of transmit completions in transmit context");
1278
1279 SYSCTL_ADD_QUAD(ctx, node_children,
1280 OID_AUTO, "tx_pkts_trans_fp",
1281 CTLFLAG_RD, &ha->fp_array[i].tx_pkts_trans_fp,
1282 "No. of transmitted packets in taskqueue");
1283
1284 SYSCTL_ADD_QUAD(ctx, node_children,
1285 OID_AUTO, "tx_pkts_compl_fp",
1286 CTLFLAG_RD, &ha->fp_array[i].tx_pkts_compl_fp,
1287 "No. of transmit completions in taskqueue");
1288
1289 SYSCTL_ADD_QUAD(ctx, node_children,
1290 OID_AUTO, "tx_pkts_compl_intr",
1291 CTLFLAG_RD, &ha->fp_array[i].tx_pkts_compl_intr,
1292 "No. of transmit completions in interrupt ctx");
1293#endif
1294
1295 SYSCTL_ADD_QUAD(ctx, node_children,
1296 OID_AUTO, "tx_tso_pkts",
1297 CTLFLAG_RD, &ha->fp_array[i].tx_tso_pkts,
1298 "No. of LSO transmited packets");
1299
1239 SYSCTL_ADD_QUAD(ctx, node_children,
1240 OID_AUTO, "tx_lso_wnd_min_len",
1241 CTLFLAG_RD, &ha->fp_array[i].tx_lso_wnd_min_len,
1242 "tx_lso_wnd_min_len");
1243
1244 SYSCTL_ADD_QUAD(ctx, node_children,
1245 OID_AUTO, "tx_defrag",
1246 CTLFLAG_RD, &ha->fp_array[i].tx_defrag,

--- 32 unchanged lines hidden (view full) ---

1279 snprintf(name_str, sizeof(name_str),
1280 "tx_pkts_nseg_%02d", (j+1));
1281
1282 SYSCTL_ADD_QUAD(ctx, node_children,
1283 OID_AUTO, name_str, CTLFLAG_RD,
1284 &ha->fp_array[i].tx_pkts[j], name_str);
1285 }
1286
1300 SYSCTL_ADD_QUAD(ctx, node_children,
1301 OID_AUTO, "tx_lso_wnd_min_len",
1302 CTLFLAG_RD, &ha->fp_array[i].tx_lso_wnd_min_len,
1303 "tx_lso_wnd_min_len");
1304
1305 SYSCTL_ADD_QUAD(ctx, node_children,
1306 OID_AUTO, "tx_defrag",
1307 CTLFLAG_RD, &ha->fp_array[i].tx_defrag,

--- 32 unchanged lines hidden (view full) ---

1340 snprintf(name_str, sizeof(name_str),
1341 "tx_pkts_nseg_%02d", (j+1));
1342
1343 SYSCTL_ADD_QUAD(ctx, node_children,
1344 OID_AUTO, name_str, CTLFLAG_RD,
1345 &ha->fp_array[i].tx_pkts[j], name_str);
1346 }
1347
1348#ifdef QLNX_TRACE_PERF_DATA
1349 for (j = 0; j < 18; j++) {
1350
1351 bzero(name_str, (sizeof(uint8_t) * sizeof(name_str)));
1352 snprintf(name_str, sizeof(name_str),
1353 "tx_pkts_hist_%02d", (j+1));
1354
1355 SYSCTL_ADD_QUAD(ctx, node_children,
1356 OID_AUTO, name_str, CTLFLAG_RD,
1357 &ha->fp_array[i].tx_pkts_hist[j], name_str);
1358 }
1359 for (j = 0; j < 5; j++) {
1360
1361 bzero(name_str, (sizeof(uint8_t) * sizeof(name_str)));
1362 snprintf(name_str, sizeof(name_str),
1363 "tx_comInt_%02d", (j+1));
1364
1365 SYSCTL_ADD_QUAD(ctx, node_children,
1366 OID_AUTO, name_str, CTLFLAG_RD,
1367 &ha->fp_array[i].tx_comInt[j], name_str);
1368 }
1369 for (j = 0; j < 18; j++) {
1370
1371 bzero(name_str, (sizeof(uint8_t) * sizeof(name_str)));
1372 snprintf(name_str, sizeof(name_str),
1373 "tx_pkts_q_%02d", (j+1));
1374
1375 SYSCTL_ADD_QUAD(ctx, node_children,
1376 OID_AUTO, name_str, CTLFLAG_RD,
1377 &ha->fp_array[i].tx_pkts_q[j], name_str);
1378 }
1379#endif
1380
1287 SYSCTL_ADD_QUAD(ctx, node_children,
1288 OID_AUTO, "err_tx_nsegs_gt_elem_left",
1289 CTLFLAG_RD, &ha->fp_array[i].err_tx_nsegs_gt_elem_left,
1290 "err_tx_nsegs_gt_elem_left");
1291
1292 SYSCTL_ADD_QUAD(ctx, node_children,
1293 OID_AUTO, "err_tx_dmamap_create",
1294 CTLFLAG_RD, &ha->fp_array[i].err_tx_dmamap_create,

--- 679 unchanged lines hidden (view full) ---

1974 ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING;
1975 ifp->if_capabilities |= IFCAP_VLAN_HWFILTER;
1976 ifp->if_capabilities |= IFCAP_VLAN_HWCSUM;
1977 ifp->if_capabilities |= IFCAP_VLAN_HWTSO;
1978 ifp->if_capabilities |= IFCAP_TSO4;
1979 ifp->if_capabilities |= IFCAP_TSO6;
1980 ifp->if_capabilities |= IFCAP_LRO;
1981
1381 SYSCTL_ADD_QUAD(ctx, node_children,
1382 OID_AUTO, "err_tx_nsegs_gt_elem_left",
1383 CTLFLAG_RD, &ha->fp_array[i].err_tx_nsegs_gt_elem_left,
1384 "err_tx_nsegs_gt_elem_left");
1385
1386 SYSCTL_ADD_QUAD(ctx, node_children,
1387 OID_AUTO, "err_tx_dmamap_create",
1388 CTLFLAG_RD, &ha->fp_array[i].err_tx_dmamap_create,

--- 679 unchanged lines hidden (view full) ---

2068 ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING;
2069 ifp->if_capabilities |= IFCAP_VLAN_HWFILTER;
2070 ifp->if_capabilities |= IFCAP_VLAN_HWCSUM;
2071 ifp->if_capabilities |= IFCAP_VLAN_HWTSO;
2072 ifp->if_capabilities |= IFCAP_TSO4;
2073 ifp->if_capabilities |= IFCAP_TSO6;
2074 ifp->if_capabilities |= IFCAP_LRO;
2075
2076 ifp->if_hw_tsomax = QLNX_MAX_TSO_FRAME_SIZE -
2077 (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN);
2078 ifp->if_hw_tsomaxsegcount = QLNX_MAX_SEGMENTS - 1 /* hdr */;
2079 ifp->if_hw_tsomaxsegsize = QLNX_MAX_TX_MBUF_SIZE;
2080
2081
1982 ifp->if_capenable = ifp->if_capabilities;
1983
1984 ifp->if_hwassist = CSUM_IP;
1985 ifp->if_hwassist |= CSUM_TCP | CSUM_UDP;
1986 ifp->if_hwassist |= CSUM_TCP_IPV6 | CSUM_UDP_IPV6;
1987 ifp->if_hwassist |= CSUM_TSO;
1988
1989 ifp->if_hdrlen = sizeof(struct ether_vlan_header);

--- 548 unchanged lines hidden (view full) ---

2538
2539static void
2540qlnx_tx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp,
2541 struct qlnx_tx_queue *txq)
2542{
2543 u16 hw_bd_cons;
2544 u16 ecore_cons_idx;
2545 uint16_t diff;
2082 ifp->if_capenable = ifp->if_capabilities;
2083
2084 ifp->if_hwassist = CSUM_IP;
2085 ifp->if_hwassist |= CSUM_TCP | CSUM_UDP;
2086 ifp->if_hwassist |= CSUM_TCP_IPV6 | CSUM_UDP_IPV6;
2087 ifp->if_hwassist |= CSUM_TSO;
2088
2089 ifp->if_hdrlen = sizeof(struct ether_vlan_header);

--- 548 unchanged lines hidden (view full) ---

2638
2639static void
2640qlnx_tx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp,
2641 struct qlnx_tx_queue *txq)
2642{
2643 u16 hw_bd_cons;
2644 u16 ecore_cons_idx;
2645 uint16_t diff;
2646 uint16_t idx, idx2;
2546
2547 hw_bd_cons = le16toh(*txq->hw_cons_ptr);
2548
2549 while (hw_bd_cons !=
2550 (ecore_cons_idx = ecore_chain_get_cons_idx(&txq->tx_pbl))) {
2551
2552 if (hw_bd_cons < ecore_cons_idx) {
2553 diff = (1 << 16) - (ecore_cons_idx - hw_bd_cons);

--- 21 unchanged lines hidden (view full) ---

2575 ecore_chain_get_elem_left(&txq->tx_pbl));
2576
2577 fp->err_tx_cons_idx_conflict++;
2578
2579 //DEBUG
2580 qlnx_trigger_dump(ha);
2581 }
2582
2647
2648 hw_bd_cons = le16toh(*txq->hw_cons_ptr);
2649
2650 while (hw_bd_cons !=
2651 (ecore_cons_idx = ecore_chain_get_cons_idx(&txq->tx_pbl))) {
2652
2653 if (hw_bd_cons < ecore_cons_idx) {
2654 diff = (1 << 16) - (ecore_cons_idx - hw_bd_cons);

--- 21 unchanged lines hidden (view full) ---

2676 ecore_chain_get_elem_left(&txq->tx_pbl));
2677
2678 fp->err_tx_cons_idx_conflict++;
2679
2680 //DEBUG
2681 qlnx_trigger_dump(ha);
2682 }
2683
2684 idx = (txq->sw_tx_cons + 1) & (TX_RING_SIZE - 1);
2685 idx2 = (txq->sw_tx_cons + 2) & (TX_RING_SIZE - 1);
2686 prefetch(txq->sw_tx_ring[idx].mp);
2687 prefetch(txq->sw_tx_ring[idx2].mp);
2688
2583 qlnx_free_tx_pkt(ha, fp, txq);
2584
2585 txq->sw_tx_cons = (txq->sw_tx_cons + 1) & (TX_RING_SIZE - 1);
2586 }
2587 return;
2588}
2589
2590static int
2689 qlnx_free_tx_pkt(ha, fp, txq);
2690
2691 txq->sw_tx_cons = (txq->sw_tx_cons + 1) & (TX_RING_SIZE - 1);
2692 }
2693 return;
2694}
2695
2696static int
2697qlnx_transmit_locked(struct ifnet *ifp,struct qlnx_fastpath *fp, struct mbuf *mp)
2698{
2699 int ret = 0;
2700 struct qlnx_tx_queue *txq;
2701 qlnx_host_t * ha;
2702 uint16_t elem_left;
2703
2704 txq = fp->txq[0];
2705 ha = (qlnx_host_t *)fp->edev;
2706
2707
2708 if ((!(ifp->if_drv_flags & IFF_DRV_RUNNING)) || (!ha->link_up)) {
2709 if(mp != NULL)
2710 ret = drbr_enqueue(ifp, fp->tx_br, mp);
2711 return (ret);
2712 }
2713
2714 if(mp != NULL)
2715 ret = drbr_enqueue(ifp, fp->tx_br, mp);
2716
2717 mp = drbr_peek(ifp, fp->tx_br);
2718
2719 while (mp != NULL) {
2720
2721 if (qlnx_send(ha, fp, &mp)) {
2722
2723 if (mp != NULL) {
2724 drbr_putback(ifp, fp->tx_br, mp);
2725 } else {
2726 fp->tx_pkts_processed++;
2727 drbr_advance(ifp, fp->tx_br);
2728 }
2729 goto qlnx_transmit_locked_exit;
2730
2731 } else {
2732 drbr_advance(ifp, fp->tx_br);
2733 fp->tx_pkts_transmitted++;
2734 fp->tx_pkts_processed++;
2735 }
2736
2737 mp = drbr_peek(ifp, fp->tx_br);
2738 }
2739
2740qlnx_transmit_locked_exit:
2741 if((qlnx_num_tx_compl(ha,fp, fp->txq[0]) > QLNX_TX_COMPL_THRESH) ||
2742 ((int)(elem_left = ecore_chain_get_elem_left(&txq->tx_pbl))
2743 < QLNX_TX_ELEM_MAX_THRESH))
2744 (void)qlnx_tx_int(ha, fp, fp->txq[0]);
2745
2746 QL_DPRINT2(ha, "%s: exit ret = %d\n", __func__, ret);
2747 return ret;
2748}
2749
2750
2751static int
2591qlnx_transmit(struct ifnet *ifp, struct mbuf *mp)
2592{
2593 qlnx_host_t *ha = (qlnx_host_t *)ifp->if_softc;
2594 struct qlnx_fastpath *fp;
2595 int rss_id = 0, ret = 0;
2596
2752qlnx_transmit(struct ifnet *ifp, struct mbuf *mp)
2753{
2754 qlnx_host_t *ha = (qlnx_host_t *)ifp->if_softc;
2755 struct qlnx_fastpath *fp;
2756 int rss_id = 0, ret = 0;
2757
2758#ifdef QLNX_TRACEPERF_DATA
2759 uint64_t tx_pkts = 0, tx_compl = 0;
2760#endif
2761
2597 QL_DPRINT2(ha, "enter\n");
2598
2599#if __FreeBSD_version >= 1100000
2600 if (M_HASHTYPE_GET(mp) != M_HASHTYPE_NONE)
2601#else
2602 if (mp->m_flags & M_FLOWID)
2603#endif
2604 rss_id = (mp->m_pkthdr.flowid % ECORE_RSS_IND_TABLE_SIZE) %
2605 ha->num_rss;
2606
2607 fp = &ha->fp_array[rss_id];
2608
2609 if (fp->tx_br == NULL) {
2610 ret = EINVAL;
2611 goto qlnx_transmit_exit;
2612 }
2613
2762 QL_DPRINT2(ha, "enter\n");
2763
2764#if __FreeBSD_version >= 1100000
2765 if (M_HASHTYPE_GET(mp) != M_HASHTYPE_NONE)
2766#else
2767 if (mp->m_flags & M_FLOWID)
2768#endif
2769 rss_id = (mp->m_pkthdr.flowid % ECORE_RSS_IND_TABLE_SIZE) %
2770 ha->num_rss;
2771
2772 fp = &ha->fp_array[rss_id];
2773
2774 if (fp->tx_br == NULL) {
2775 ret = EINVAL;
2776 goto qlnx_transmit_exit;
2777 }
2778
2614 if (mp != NULL) {
2615 ret = drbr_enqueue(ifp, fp->tx_br, mp);
2616 }
2779 if (mtx_trylock(&fp->tx_mtx)) {
2617
2780
2618 if (fp->fp_taskqueue != NULL)
2619 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task);
2781#ifdef QLNX_TRACEPERF_DATA
2782 tx_pkts = fp->tx_pkts_transmitted;
2783 tx_compl = fp->tx_pkts_completed;
2784#endif
2620
2785
2621 ret = 0;
2786 ret = qlnx_transmit_locked(ifp, fp, mp);
2622
2787
2788#ifdef QLNX_TRACEPERF_DATA
2789 fp->tx_pkts_trans_ctx += (fp->tx_pkts_transmitted - tx_pkts);
2790 fp->tx_pkts_compl_ctx += (fp->tx_pkts_completed - tx_compl);
2791#endif
2792 mtx_unlock(&fp->tx_mtx);
2793 } else {
2794 if (mp != NULL && (fp->fp_taskqueue != NULL)) {
2795 ret = drbr_enqueue(ifp, fp->tx_br, mp);
2796 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task);
2797 }
2798 }
2799
2623qlnx_transmit_exit:
2624
2625 QL_DPRINT2(ha, "exit ret = %d\n", ret);
2626 return ret;
2627}
2628
2629static void
2630qlnx_qflush(struct ifnet *ifp)

--- 163 unchanged lines hidden (view full) ---

2794 struct eth_tx_2nd_bd *second_bd;
2795 struct eth_tx_3rd_bd *third_bd;
2796 struct eth_tx_bd *tx_data_bd;
2797
2798 int seg_idx = 0;
2799 uint32_t nbds_in_hdr = 0;
2800 uint32_t offset = 0;
2801
2800qlnx_transmit_exit:
2801
2802 QL_DPRINT2(ha, "exit ret = %d\n", ret);
2803 return ret;
2804}
2805
2806static void
2807qlnx_qflush(struct ifnet *ifp)

--- 163 unchanged lines hidden (view full) ---

2971 struct eth_tx_2nd_bd *second_bd;
2972 struct eth_tx_3rd_bd *third_bd;
2973 struct eth_tx_bd *tx_data_bd;
2974
2975 int seg_idx = 0;
2976 uint32_t nbds_in_hdr = 0;
2977 uint32_t offset = 0;
2978
2979#ifdef QLNX_TRACE_PERF_DATA
2980 uint16_t bd_used;
2981#endif
2982
2802 QL_DPRINT8(ha, "enter\n");
2803
2804 if (!ha->link_up)
2805 return (-1);
2806
2807 first_bd = NULL;
2808 second_bd = NULL;
2809 third_bd = NULL;
2810 tx_data_bd = NULL;
2811
2812 txq = fp->txq[0];
2813
2983 QL_DPRINT8(ha, "enter\n");
2984
2985 if (!ha->link_up)
2986 return (-1);
2987
2988 first_bd = NULL;
2989 second_bd = NULL;
2990 third_bd = NULL;
2991 tx_data_bd = NULL;
2992
2993 txq = fp->txq[0];
2994
2814 if (fp->tx_ring_full) {
2815 elem_left = ecore_chain_get_elem_left(&txq->tx_pbl);
2995 if ((int)(elem_left = ecore_chain_get_elem_left(&txq->tx_pbl)) <
2996 QLNX_TX_ELEM_MIN_THRESH) {
2816
2997
2817 if (elem_left < (TX_RING_SIZE >> 4))
2818 return (-1);
2819 else
2820 fp->tx_ring_full = 0;
2821 }
2998 fp->tx_nsegs_gt_elem_left++;
2999 fp->err_tx_nsegs_gt_elem_left++;
2822
3000
3001 return (ENOBUFS);
3002 }
3003
2823 idx = txq->sw_tx_prod;
2824
2825 map = txq->sw_tx_ring[idx].map;
2826 segs = txq->segs;
2827
2828 ret = bus_dmamap_load_mbuf_sg(ha->tx_tag, map, m_head, segs, &nsegs,
2829 BUS_DMA_NOWAIT);
2830
2831 if (ha->dbg_trace_tso_pkt_len) {
3004 idx = txq->sw_tx_prod;
3005
3006 map = txq->sw_tx_ring[idx].map;
3007 segs = txq->segs;
3008
3009 ret = bus_dmamap_load_mbuf_sg(ha->tx_tag, map, m_head, segs, &nsegs,
3010 BUS_DMA_NOWAIT);
3011
3012 if (ha->dbg_trace_tso_pkt_len) {
2832 if (!fp->tx_tso_min_pkt_len) {
2833 fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len;
2834 fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len;
2835 } else {
2836 if (fp->tx_tso_min_pkt_len > m_head->m_pkthdr.len)
3013 if (m_head->m_pkthdr.csum_flags & CSUM_TSO) {
3014 if (!fp->tx_tso_min_pkt_len) {
2837 fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len;
3015 fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len;
2838 if (fp->tx_tso_max_pkt_len < m_head->m_pkthdr.len)
2839 fp->tx_tso_max_pkt_len = m_head->m_pkthdr.len;
3016 fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len;
3017 } else {
3018 if (fp->tx_tso_min_pkt_len > m_head->m_pkthdr.len)
3019 fp->tx_tso_min_pkt_len =
3020 m_head->m_pkthdr.len;
3021 if (fp->tx_tso_max_pkt_len < m_head->m_pkthdr.len)
3022 fp->tx_tso_max_pkt_len =
3023 m_head->m_pkthdr.len;
3024 }
2840 }
2841 }
2842
2843 if (m_head->m_pkthdr.csum_flags & CSUM_TSO)
2844 offset = qlnx_tcp_offset(ha, m_head);
2845
2846 if ((ret == EFBIG) ||
2847 ((nsegs > QLNX_MAX_SEGMENTS_NON_TSO) && (

--- 70 unchanged lines hidden (view full) ---

2918
2919 if (ha->dbg_trace_tso_pkt_len) {
2920 if (nsegs < QLNX_FP_MAX_SEGS)
2921 fp->tx_pkts[(nsegs - 1)]++;
2922 else
2923 fp->tx_pkts[(QLNX_FP_MAX_SEGS - 1)]++;
2924 }
2925
3025 }
3026 }
3027
3028 if (m_head->m_pkthdr.csum_flags & CSUM_TSO)
3029 offset = qlnx_tcp_offset(ha, m_head);
3030
3031 if ((ret == EFBIG) ||
3032 ((nsegs > QLNX_MAX_SEGMENTS_NON_TSO) && (

--- 70 unchanged lines hidden (view full) ---

3103
3104 if (ha->dbg_trace_tso_pkt_len) {
3105 if (nsegs < QLNX_FP_MAX_SEGS)
3106 fp->tx_pkts[(nsegs - 1)]++;
3107 else
3108 fp->tx_pkts[(QLNX_FP_MAX_SEGS - 1)]++;
3109 }
3110
3111#ifdef QLNX_TRACE_PERF_DATA
3112 if (m_head->m_pkthdr.csum_flags & CSUM_TSO) {
3113 if(m_head->m_pkthdr.len <= 2048)
3114 fp->tx_pkts_hist[0]++;
3115 else if((m_head->m_pkthdr.len > 2048) &&
3116 (m_head->m_pkthdr.len <= 4096))
3117 fp->tx_pkts_hist[1]++;
3118 else if((m_head->m_pkthdr.len > 4096) &&
3119 (m_head->m_pkthdr.len <= 8192))
3120 fp->tx_pkts_hist[2]++;
3121 else if((m_head->m_pkthdr.len > 8192) &&
3122 (m_head->m_pkthdr.len <= 12288 ))
3123 fp->tx_pkts_hist[3]++;
3124 else if((m_head->m_pkthdr.len > 11288) &&
3125 (m_head->m_pkthdr.len <= 16394))
3126 fp->tx_pkts_hist[4]++;
3127 else if((m_head->m_pkthdr.len > 16384) &&
3128 (m_head->m_pkthdr.len <= 20480))
3129 fp->tx_pkts_hist[5]++;
3130 else if((m_head->m_pkthdr.len > 20480) &&
3131 (m_head->m_pkthdr.len <= 24576))
3132 fp->tx_pkts_hist[6]++;
3133 else if((m_head->m_pkthdr.len > 24576) &&
3134 (m_head->m_pkthdr.len <= 28672))
3135 fp->tx_pkts_hist[7]++;
3136 else if((m_head->m_pkthdr.len > 28762) &&
3137 (m_head->m_pkthdr.len <= 32768))
3138 fp->tx_pkts_hist[8]++;
3139 else if((m_head->m_pkthdr.len > 32768) &&
3140 (m_head->m_pkthdr.len <= 36864))
3141 fp->tx_pkts_hist[9]++;
3142 else if((m_head->m_pkthdr.len > 36864) &&
3143 (m_head->m_pkthdr.len <= 40960))
3144 fp->tx_pkts_hist[10]++;
3145 else if((m_head->m_pkthdr.len > 40960) &&
3146 (m_head->m_pkthdr.len <= 45056))
3147 fp->tx_pkts_hist[11]++;
3148 else if((m_head->m_pkthdr.len > 45056) &&
3149 (m_head->m_pkthdr.len <= 49152))
3150 fp->tx_pkts_hist[12]++;
3151 else if((m_head->m_pkthdr.len > 49512) &&
3152 m_head->m_pkthdr.len <= 53248))
3153 fp->tx_pkts_hist[13]++;
3154 else if((m_head->m_pkthdr.len > 53248) &&
3155 (m_head->m_pkthdr.len <= 57344))
3156 fp->tx_pkts_hist[14]++;
3157 else if((m_head->m_pkthdr.len > 53248) &&
3158 (m_head->m_pkthdr.len <= 57344))
3159 fp->tx_pkts_hist[15]++;
3160 else if((m_head->m_pkthdr.len > 57344) &&
3161 (m_head->m_pkthdr.len <= 61440))
3162 fp->tx_pkts_hist[16]++;
3163 else
3164 fp->tx_pkts_hist[17]++;
3165 }
3166
3167 if (m_head->m_pkthdr.csum_flags & CSUM_TSO) {
3168
3169 elem_left = ecore_chain_get_elem_left(&txq->tx_pbl);
3170 bd_used = TX_RING_SIZE - elem_left;
3171
3172 if(bd_used <= 100)
3173 fp->tx_pkts_q[0]++;
3174 else if((bd_used > 100) && (bd_used <= 500))
3175 fp->tx_pkts_q[1]++;
3176 else if((bd_used > 500) && (bd_used <= 1000))
3177 fp->tx_pkts_q[2]++;
3178 else if((bd_used > 1000) && (bd_used <= 2000))
3179 fp->tx_pkts_q[3]++;
3180 else if((bd_used > 3000) && (bd_used <= 4000))
3181 fp->tx_pkts_q[4]++;
3182 else if((bd_used > 4000) && (bd_used <= 5000))
3183 fp->tx_pkts_q[5]++;
3184 else if((bd_used > 6000) && (bd_used <= 7000))
3185 fp->tx_pkts_q[6]++;
3186 else if((bd_used > 7000) && (bd_used <= 8000))
3187 fp->tx_pkts_q[7]++;
3188 else if((bd_used > 8000) && (bd_used <= 9000))
3189 fp->tx_pkts_q[8]++;
3190 else if((bd_used > 9000) && (bd_used <= 10000))
3191 fp->tx_pkts_q[9]++;
3192 else if((bd_used > 10000) && (bd_used <= 11000))
3193 fp->tx_pkts_q[10]++;
3194 else if((bd_used > 11000) && (bd_used <= 12000))
3195 fp->tx_pkts_q[11]++;
3196 else if((bd_used > 12000) && (bd_used <= 13000))
3197 fp->tx_pkts_q[12]++;
3198 else if((bd_used > 13000) && (bd_used <= 14000))
3199 fp->tx_pkts_q[13]++;
3200 else if((bd_used > 14000) && (bd_used <= 15000))
3201 fp->tx_pkts_q[14]++;
3202 else if((bd_used > 15000) && (bd_used <= 16000))
3203 fp->tx_pkts_q[15]++;
3204 else
3205 fp->tx_pkts_q[16]++;
3206 }
3207
3208#endif /* end of QLNX_TRACE_PERF_DATA */
3209
2926 if ((nsegs + QLNX_TX_ELEM_RESERVE) >
2927 (int)(elem_left = ecore_chain_get_elem_left(&txq->tx_pbl))) {
2928
2929 QL_DPRINT1(ha, "(%d, 0x%x) insuffient BDs"
2930 " in chain[%d] trying to free packets\n",
2931 nsegs, elem_left, fp->rss_id);
2932
2933 fp->tx_nsegs_gt_elem_left++;

--- 4 unchanged lines hidden (view full) ---

2938 ecore_chain_get_elem_left(&txq->tx_pbl))) {
2939
2940 QL_DPRINT1(ha,
2941 "(%d, 0x%x) insuffient BDs in chain[%d]\n",
2942 nsegs, elem_left, fp->rss_id);
2943
2944 fp->err_tx_nsegs_gt_elem_left++;
2945 fp->tx_ring_full = 1;
3210 if ((nsegs + QLNX_TX_ELEM_RESERVE) >
3211 (int)(elem_left = ecore_chain_get_elem_left(&txq->tx_pbl))) {
3212
3213 QL_DPRINT1(ha, "(%d, 0x%x) insuffient BDs"
3214 " in chain[%d] trying to free packets\n",
3215 nsegs, elem_left, fp->rss_id);
3216
3217 fp->tx_nsegs_gt_elem_left++;

--- 4 unchanged lines hidden (view full) ---

3222 ecore_chain_get_elem_left(&txq->tx_pbl))) {
3223
3224 QL_DPRINT1(ha,
3225 "(%d, 0x%x) insuffient BDs in chain[%d]\n",
3226 nsegs, elem_left, fp->rss_id);
3227
3228 fp->err_tx_nsegs_gt_elem_left++;
3229 fp->tx_ring_full = 1;
2946 ha->storm_stats_enable = 1;
3230 if (ha->storm_stats_enable)
3231 ha->storm_stats_gather = 1;
2947 return (ENOBUFS);
2948 }
2949 }
2950
2951 bus_dmamap_sync(ha->tx_tag, map, BUS_DMASYNC_PREWRITE);
2952
2953 txq->sw_tx_ring[idx].mp = m_head;
2954

--- 171 unchanged lines hidden (view full) ---

3126 ecore_chain_produce(&txq->tx_pbl);
3127 memset(third_bd, 0, sizeof(*third_bd));
3128 }
3129
3130 third_bd->data.lso_mss = m_head->m_pkthdr.tso_segsz;
3131 third_bd->data.bitfields |=
3132 (nbds_in_hdr<<ETH_TX_DATA_3RD_BD_HDR_NBD_SHIFT);
3133 }
3232 return (ENOBUFS);
3233 }
3234 }
3235
3236 bus_dmamap_sync(ha->tx_tag, map, BUS_DMASYNC_PREWRITE);
3237
3238 txq->sw_tx_ring[idx].mp = m_head;
3239

--- 171 unchanged lines hidden (view full) ---

3411 ecore_chain_produce(&txq->tx_pbl);
3412 memset(third_bd, 0, sizeof(*third_bd));
3413 }
3414
3415 third_bd->data.lso_mss = m_head->m_pkthdr.tso_segsz;
3416 third_bd->data.bitfields |=
3417 (nbds_in_hdr<<ETH_TX_DATA_3RD_BD_HDR_NBD_SHIFT);
3418 }
3419 fp->tx_tso_pkts++;
3134 } else {
3135 segs++;
3136 for (seg_idx = 1; seg_idx < nsegs; seg_idx++) {
3137 tx_data_bd = (struct eth_tx_bd *)
3138 ecore_chain_produce(&txq->tx_pbl);
3139 memset(tx_data_bd, 0, sizeof(*tx_data_bd));
3140 BD_SET_UNMAP_ADDR_LEN(tx_data_bd, segs->ds_addr,\
3141 segs->ds_len);
3142 segs++;
3143 nbd++;
3144 }
3145 first_bd->data.bitfields =
3146 (m_head->m_pkthdr.len & ETH_TX_DATA_1ST_BD_PKT_LEN_MASK)
3147 << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT;
3148 first_bd->data.bitfields =
3149 htole16(first_bd->data.bitfields);
3420 } else {
3421 segs++;
3422 for (seg_idx = 1; seg_idx < nsegs; seg_idx++) {
3423 tx_data_bd = (struct eth_tx_bd *)
3424 ecore_chain_produce(&txq->tx_pbl);
3425 memset(tx_data_bd, 0, sizeof(*tx_data_bd));
3426 BD_SET_UNMAP_ADDR_LEN(tx_data_bd, segs->ds_addr,\
3427 segs->ds_len);
3428 segs++;
3429 nbd++;
3430 }
3431 first_bd->data.bitfields =
3432 (m_head->m_pkthdr.len & ETH_TX_DATA_1ST_BD_PKT_LEN_MASK)
3433 << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT;
3434 first_bd->data.bitfields =
3435 htole16(first_bd->data.bitfields);
3436 fp->tx_non_tso_pkts++;
3150 }
3151
3152
3153 first_bd->data.nbds = nbd;
3154
3155 if (ha->dbg_trace_tso_pkt_len) {
3156 if (fp->tx_tso_max_nsegs < nsegs)
3157 fp->tx_tso_max_nsegs = nsegs;

--- 1140 unchanged lines hidden (view full) ---

4298 ha->err_fp_null++;
4299 } else {
4300
4301#ifdef QLNX_RCV_IN_TASKQ
4302 ecore_sb_ack(fp->sb_info, IGU_INT_DISABLE, 0);
4303 if (fp->fp_taskqueue != NULL)
4304 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task);
4305#else
3437 }
3438
3439
3440 first_bd->data.nbds = nbd;
3441
3442 if (ha->dbg_trace_tso_pkt_len) {
3443 if (fp->tx_tso_max_nsegs < nsegs)
3444 fp->tx_tso_max_nsegs = nsegs;

--- 1140 unchanged lines hidden (view full) ---

4585 ha->err_fp_null++;
4586 } else {
4587
4588#ifdef QLNX_RCV_IN_TASKQ
4589 ecore_sb_ack(fp->sb_info, IGU_INT_DISABLE, 0);
4590 if (fp->fp_taskqueue != NULL)
4591 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task);
4592#else
4306 int rx_int = 0, total_rx_count = 0;
4307 int lro_enable, tc;
4593 int rx_int = 0, total_rx_count = 0;
4594 int lro_enable, tc;
4595 struct qlnx_tx_queue *txq;
4596 uint16_t elem_left;
4308
4309 lro_enable = ha->ifp->if_capenable & IFCAP_LRO;
4310
4311 ecore_sb_ack(fp->sb_info, IGU_INT_DISABLE, 0);
4312
4313 do {
4314 for (tc = 0; tc < ha->num_tc; tc++) {
4597
4598 lro_enable = ha->ifp->if_capenable & IFCAP_LRO;
4599
4600 ecore_sb_ack(fp->sb_info, IGU_INT_DISABLE, 0);
4601
4602 do {
4603 for (tc = 0; tc < ha->num_tc; tc++) {
4315 if (mtx_trylock(&fp->tx_mtx)) {
4316 qlnx_tx_int(ha, fp, fp->txq[tc]);
4317 mtx_unlock(&fp->tx_mtx);
4318 }
4604
4605 txq = fp->txq[tc];
4606
4607 if((int)(elem_left =
4608 ecore_chain_get_elem_left(&txq->tx_pbl)) <
4609 QLNX_TX_ELEM_THRESH) {
4610
4611 if (mtx_trylock(&fp->tx_mtx)) {
4612#ifdef QLNX_TRACE_PERF_DATA
4613 tx_compl = fp->tx_pkts_completed;
4614#endif
4615
4616 qlnx_tx_int(ha, fp, fp->txq[tc]);
4617#ifdef QLNX_TRACE_PERF_DATA
4618 fp->tx_pkts_compl_intr +=
4619 (fp->tx_pkts_completed - tx_compl);
4620 if ((fp->tx_pkts_completed - tx_compl) <= 32)
4621 fp->tx_comInt[0]++;
4622 else if (((fp->tx_pkts_completed - tx_compl) > 32) &&
4623 ((fp->tx_pkts_completed - tx_compl) <= 64))
4624 fp->tx_comInt[1]++;
4625 else if(((fp->tx_pkts_completed - tx_compl) > 64) &&
4626 ((fp->tx_pkts_completed - tx_compl) <= 128))
4627 fp->tx_comInt[2]++;
4628 else if(((fp->tx_pkts_completed - tx_compl) > 128))
4629 fp->tx_comInt[3]++;
4630#endif
4631 mtx_unlock(&fp->tx_mtx);
4632 }
4633 }
4319 }
4320
4321 rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold,
4322 lro_enable);
4323
4324 if (rx_int) {
4325 fp->rx_pkts += rx_int;
4326 total_rx_count += rx_int;
4327 }
4328
4329 } while (rx_int);
4330
4634 }
4635
4636 rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold,
4637 lro_enable);
4638
4639 if (rx_int) {
4640 fp->rx_pkts += rx_int;
4641 total_rx_count += rx_int;
4642 }
4643
4644 } while (rx_int);
4645
4331
4332#ifdef QLNX_SOFT_LRO
4333 {
4334 struct lro_ctrl *lro;
4335
4336 lro = &fp->rxq->lro;
4337
4338 if (lro_enable && total_rx_count) {
4339

--- 263 unchanged lines hidden (view full) ---

4603{
4604 if (bus_dma_tag_create(NULL, /* parent */
4605 1, 0, /* alignment, bounds */
4606 BUS_SPACE_MAXADDR, /* lowaddr */
4607 BUS_SPACE_MAXADDR, /* highaddr */
4608 NULL, NULL, /* filter, filterarg */
4609 QLNX_MAX_TSO_FRAME_SIZE, /* maxsize */
4610 QLNX_MAX_SEGMENTS, /* nsegments */
4646#ifdef QLNX_SOFT_LRO
4647 {
4648 struct lro_ctrl *lro;
4649
4650 lro = &fp->rxq->lro;
4651
4652 if (lro_enable && total_rx_count) {
4653

--- 263 unchanged lines hidden (view full) ---

4917{
4918 if (bus_dma_tag_create(NULL, /* parent */
4919 1, 0, /* alignment, bounds */
4920 BUS_SPACE_MAXADDR, /* lowaddr */
4921 BUS_SPACE_MAXADDR, /* highaddr */
4922 NULL, NULL, /* filter, filterarg */
4923 QLNX_MAX_TSO_FRAME_SIZE, /* maxsize */
4924 QLNX_MAX_SEGMENTS, /* nsegments */
4611 (PAGE_SIZE * 4), /* maxsegsize */
4612 BUS_DMA_ALLOCNOW, /* flags */
4925 QLNX_MAX_TX_MBUF_SIZE, /* maxsegsize */
4926 0, /* flags */
4613 NULL, /* lockfunc */
4614 NULL, /* lockfuncarg */
4615 &ha->tx_tag)) {
4616
4617 QL_DPRINT1(ha, "tx_tag alloc failed\n");
4618 return (-1);
4619 }
4620

--- 16 unchanged lines hidden (view full) ---

4637 if (bus_dma_tag_create(NULL, /* parent */
4638 1, 0, /* alignment, bounds */
4639 BUS_SPACE_MAXADDR, /* lowaddr */
4640 BUS_SPACE_MAXADDR, /* highaddr */
4641 NULL, NULL, /* filter, filterarg */
4642 MJUM9BYTES, /* maxsize */
4643 1, /* nsegments */
4644 MJUM9BYTES, /* maxsegsize */
4927 NULL, /* lockfunc */
4928 NULL, /* lockfuncarg */
4929 &ha->tx_tag)) {
4930
4931 QL_DPRINT1(ha, "tx_tag alloc failed\n");
4932 return (-1);
4933 }
4934

--- 16 unchanged lines hidden (view full) ---

4951 if (bus_dma_tag_create(NULL, /* parent */
4952 1, 0, /* alignment, bounds */
4953 BUS_SPACE_MAXADDR, /* lowaddr */
4954 BUS_SPACE_MAXADDR, /* highaddr */
4955 NULL, NULL, /* filter, filterarg */
4956 MJUM9BYTES, /* maxsize */
4957 1, /* nsegments */
4958 MJUM9BYTES, /* maxsegsize */
4645 BUS_DMA_ALLOCNOW, /* flags */
4959 0, /* flags */
4646 NULL, /* lockfunc */
4647 NULL, /* lockfuncarg */
4648 &ha->rx_tag)) {
4649
4650 QL_DPRINT1(ha, " rx_tag alloc failed\n");
4651
4652 return (-1);
4653 }

--- 596 unchanged lines hidden (view full) ---

5250 fp->tx_ring_full = 0;
5251
5252 /* reset all the statistics counters */
5253
5254 fp->tx_pkts_processed = 0;
5255 fp->tx_pkts_freed = 0;
5256 fp->tx_pkts_transmitted = 0;
5257 fp->tx_pkts_completed = 0;
4960 NULL, /* lockfunc */
4961 NULL, /* lockfuncarg */
4962 &ha->rx_tag)) {
4963
4964 QL_DPRINT1(ha, " rx_tag alloc failed\n");
4965
4966 return (-1);
4967 }

--- 596 unchanged lines hidden (view full) ---

5564 fp->tx_ring_full = 0;
5565
5566 /* reset all the statistics counters */
5567
5568 fp->tx_pkts_processed = 0;
5569 fp->tx_pkts_freed = 0;
5570 fp->tx_pkts_transmitted = 0;
5571 fp->tx_pkts_completed = 0;
5572
5573#ifdef QLNX_TRACE_PERF_DATA
5574 fp->tx_pkts_trans_ctx = 0;
5575 fp->tx_pkts_compl_ctx = 0;
5576 fp->tx_pkts_trans_fp = 0;
5577 fp->tx_pkts_compl_fp = 0;
5578 fp->tx_pkts_compl_intr = 0;
5579#endif
5258 fp->tx_lso_wnd_min_len = 0;
5259 fp->tx_defrag = 0;
5260 fp->tx_nsegs_gt_elem_left = 0;
5261 fp->tx_tso_max_nsegs = 0;
5262 fp->tx_tso_min_nsegs = 0;
5263 fp->err_tx_nsegs_gt_elem_left = 0;
5264 fp->err_tx_dmamap_create = 0;
5265 fp->err_tx_defrag_dmamap_load = 0;

--- 1335 unchanged lines hidden (view full) ---

6601qlnx_timer(void *arg)
6602{
6603 qlnx_host_t *ha;
6604
6605 ha = (qlnx_host_t *)arg;
6606
6607 ecore_get_vport_stats(&ha->cdev, &ha->hw_stats);
6608
5580 fp->tx_lso_wnd_min_len = 0;
5581 fp->tx_defrag = 0;
5582 fp->tx_nsegs_gt_elem_left = 0;
5583 fp->tx_tso_max_nsegs = 0;
5584 fp->tx_tso_min_nsegs = 0;
5585 fp->err_tx_nsegs_gt_elem_left = 0;
5586 fp->err_tx_dmamap_create = 0;
5587 fp->err_tx_defrag_dmamap_load = 0;

--- 1335 unchanged lines hidden (view full) ---

6923qlnx_timer(void *arg)
6924{
6925 qlnx_host_t *ha;
6926
6927 ha = (qlnx_host_t *)arg;
6928
6929 ecore_get_vport_stats(&ha->cdev, &ha->hw_stats);
6930
6609 if (ha->storm_stats_enable)
6931 if (ha->storm_stats_gather)
6610 qlnx_sample_storm_stats(ha);
6611
6612 callout_reset(&ha->qlnx_callout, hz, qlnx_timer, ha);
6613
6614 return;
6615}
6616
6617static int

--- 232 unchanged lines hidden (view full) ---

6850 int i, index;
6851 struct ecore_dev *cdev;
6852 qlnx_storm_stats_t *s_stats;
6853 uint32_t reg;
6854 struct ecore_ptt *p_ptt;
6855 struct ecore_hwfn *hwfn;
6856
6857 if (ha->storm_stats_index >= QLNX_STORM_STATS_SAMPLES_PER_HWFN) {
6932 qlnx_sample_storm_stats(ha);
6933
6934 callout_reset(&ha->qlnx_callout, hz, qlnx_timer, ha);
6935
6936 return;
6937}
6938
6939static int

--- 232 unchanged lines hidden (view full) ---

7172 int i, index;
7173 struct ecore_dev *cdev;
7174 qlnx_storm_stats_t *s_stats;
7175 uint32_t reg;
7176 struct ecore_ptt *p_ptt;
7177 struct ecore_hwfn *hwfn;
7178
7179 if (ha->storm_stats_index >= QLNX_STORM_STATS_SAMPLES_PER_HWFN) {
6858 ha->storm_stats_enable = 0;
7180 ha->storm_stats_gather = 0;
6859 return;
6860 }
6861
6862 cdev = &ha->cdev;
6863
6864 for_each_hwfn(cdev, i) {
6865
6866 hwfn = &cdev->hwfns[i];

--- 244 unchanged lines hidden ---
7181 return;
7182 }
7183
7184 cdev = &ha->cdev;
7185
7186 for_each_hwfn(cdev, i) {
7187
7188 hwfn = &cdev->hwfns[i];

--- 244 unchanged lines hidden ---