bxe.c (305614) | bxe.c (307972) |
---|---|
1/*- 2 * Copyright (c) 2007-2014 QLogic Corporation. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 24 * THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2007-2014 QLogic Corporation. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 24 * THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: stable/11/sys/dev/bxe/bxe.c 305614 2016-09-08 15:05:25Z pfg $"); | 28__FBSDID("$FreeBSD: stable/11/sys/dev/bxe/bxe.c 307972 2016-10-26 17:53:12Z davidcs $"); |
29 | 29 |
30#define BXE_DRIVER_VERSION "1.78.81" | 30#define BXE_DRIVER_VERSION "1.78.89" |
31 32#include "bxe.h" 33#include "ecore_sp.h" 34#include "ecore_init.h" 35#include "ecore_init_ops.h" 36 37#include "57710_int_offsets.h" 38#include "57711_int_offsets.h" --- 445 unchanged lines hidden (view full) --- 484 4, STATS_FLAGS_FUNC, "mbuf_alloc_tx"}, 485 { STATS_OFFSET32(mbuf_alloc_rx), 486 4, STATS_FLAGS_FUNC, "mbuf_alloc_rx"}, 487 { STATS_OFFSET32(mbuf_alloc_sge), 488 4, STATS_FLAGS_FUNC, "mbuf_alloc_sge"}, 489 { STATS_OFFSET32(mbuf_alloc_tpa), 490 4, STATS_FLAGS_FUNC, "mbuf_alloc_tpa"}, 491 { STATS_OFFSET32(tx_queue_full_return), | 31 32#include "bxe.h" 33#include "ecore_sp.h" 34#include "ecore_init.h" 35#include "ecore_init_ops.h" 36 37#include "57710_int_offsets.h" 38#include "57711_int_offsets.h" --- 445 unchanged lines hidden (view full) --- 484 4, STATS_FLAGS_FUNC, "mbuf_alloc_tx"}, 485 { STATS_OFFSET32(mbuf_alloc_rx), 486 4, STATS_FLAGS_FUNC, "mbuf_alloc_rx"}, 487 { STATS_OFFSET32(mbuf_alloc_sge), 488 4, STATS_FLAGS_FUNC, "mbuf_alloc_sge"}, 489 { STATS_OFFSET32(mbuf_alloc_tpa), 490 4, STATS_FLAGS_FUNC, "mbuf_alloc_tpa"}, 491 { STATS_OFFSET32(tx_queue_full_return), |
492 4, STATS_FLAGS_FUNC, "tx_queue_full_return"} | 492 4, STATS_FLAGS_FUNC, "tx_queue_full_return"}, 493 { STATS_OFFSET32(tx_request_link_down_failures), 494 4, STATS_FLAGS_FUNC, "tx_request_link_down_failures"}, 495 { STATS_OFFSET32(bd_avail_too_less_failures), 496 4, STATS_FLAGS_FUNC, "bd_avail_too_less_failures"}, 497 { STATS_OFFSET32(tx_mq_not_empty), 498 4, STATS_FLAGS_FUNC, "tx_mq_not_empty"} 499 |
493}; 494 495static const struct { 496 uint32_t offset; 497 uint32_t size; 498 char string[STAT_NAME_LEN]; 499} bxe_eth_q_stats_arr[] = { 500 { Q_STATS_OFFSET32(total_bytes_received_hi), --- 96 unchanged lines hidden (view full) --- 597 4, "mbuf_alloc_tx"}, 598 { Q_STATS_OFFSET32(mbuf_alloc_rx), 599 4, "mbuf_alloc_rx"}, 600 { Q_STATS_OFFSET32(mbuf_alloc_sge), 601 4, "mbuf_alloc_sge"}, 602 { Q_STATS_OFFSET32(mbuf_alloc_tpa), 603 4, "mbuf_alloc_tpa"}, 604 { Q_STATS_OFFSET32(tx_queue_full_return), | 500}; 501 502static const struct { 503 uint32_t offset; 504 uint32_t size; 505 char string[STAT_NAME_LEN]; 506} bxe_eth_q_stats_arr[] = { 507 { Q_STATS_OFFSET32(total_bytes_received_hi), --- 96 unchanged lines hidden (view full) --- 604 4, "mbuf_alloc_tx"}, 605 { Q_STATS_OFFSET32(mbuf_alloc_rx), 606 4, "mbuf_alloc_rx"}, 607 { Q_STATS_OFFSET32(mbuf_alloc_sge), 608 4, "mbuf_alloc_sge"}, 609 { Q_STATS_OFFSET32(mbuf_alloc_tpa), 610 4, "mbuf_alloc_tpa"}, 611 { Q_STATS_OFFSET32(tx_queue_full_return), |
605 4, "tx_queue_full_return"} | 612 4, "tx_queue_full_return"}, 613 { Q_STATS_OFFSET32(tx_request_link_down_failures), 614 4, "tx_request_link_down_failures"}, 615 { Q_STATS_OFFSET32(bd_avail_too_less_failures), 616 4, "bd_avail_too_less_failures"}, 617 { Q_STATS_OFFSET32(tx_mq_not_empty), 618 4, "tx_mq_not_empty"} 619 |
606}; 607 608#define BXE_NUM_ETH_STATS ARRAY_SIZE(bxe_eth_stats_arr) 609#define BXE_NUM_ETH_Q_STATS ARRAY_SIZE(bxe_eth_q_stats_arr) 610 611 612static void bxe_cmng_fns_init(struct bxe_softc *sc, 613 uint8_t read_cfg, --- 4980 unchanged lines hidden (view full) --- 5594 return; 5595 } 5596 5597 BXE_FP_TX_LOCK(fp); 5598 bxe_tx_start_locked(sc, ifp, fp); 5599 BXE_FP_TX_UNLOCK(fp); 5600} 5601 | 620}; 621 622#define BXE_NUM_ETH_STATS ARRAY_SIZE(bxe_eth_stats_arr) 623#define BXE_NUM_ETH_Q_STATS ARRAY_SIZE(bxe_eth_q_stats_arr) 624 625 626static void bxe_cmng_fns_init(struct bxe_softc *sc, 627 uint8_t read_cfg, --- 4980 unchanged lines hidden (view full) --- 5608 return; 5609 } 5610 5611 BXE_FP_TX_LOCK(fp); 5612 bxe_tx_start_locked(sc, ifp, fp); 5613 BXE_FP_TX_UNLOCK(fp); 5614} 5615 |
5602#if __FreeBSD_version >= 800000 | 5616#if __FreeBSD_version >= 901504 |
5603 5604static int 5605bxe_tx_mq_start_locked(struct bxe_softc *sc, 5606 if_t ifp, 5607 struct bxe_fastpath *fp, 5608 struct mbuf *m) 5609{ 5610 struct buf_ring *tx_br = fp->tx_br; --- 5 unchanged lines hidden (view full) --- 5616 5617 BXE_FP_TX_LOCK_ASSERT(fp); 5618 5619 if (!tx_br) { 5620 BLOGE(sc, "Multiqueue TX and no buf_ring!\n"); 5621 return (EINVAL); 5622 } 5623 | 5617 5618static int 5619bxe_tx_mq_start_locked(struct bxe_softc *sc, 5620 if_t ifp, 5621 struct bxe_fastpath *fp, 5622 struct mbuf *m) 5623{ 5624 struct buf_ring *tx_br = fp->tx_br; --- 5 unchanged lines hidden (view full) --- 5630 5631 BXE_FP_TX_LOCK_ASSERT(fp); 5632 5633 if (!tx_br) { 5634 BLOGE(sc, "Multiqueue TX and no buf_ring!\n"); 5635 return (EINVAL); 5636 } 5637 |
5624 if (!sc->link_vars.link_up || 5625 (if_getdrvflags(ifp) & 5626 (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) { 5627 if (m != NULL) 5628 rc = drbr_enqueue(ifp, tx_br, m); | 5638 if (m != NULL) { 5639 rc = drbr_enqueue(ifp, tx_br, m); 5640 if (rc != 0) { 5641 fp->eth_q_stats.tx_soft_errors++; 5642 goto bxe_tx_mq_start_locked_exit; 5643 } 5644 } 5645 5646 if (!sc->link_vars.link_up || !(ifp->if_drv_flags & IFF_DRV_RUNNING)) { 5647 fp->eth_q_stats.tx_request_link_down_failures++; |
5629 goto bxe_tx_mq_start_locked_exit; 5630 } 5631 5632 /* fetch the depth of the driver queue */ 5633 depth = drbr_inuse_drv(ifp, tx_br); 5634 if (depth > fp->eth_q_stats.tx_max_drbr_queue_depth) { 5635 fp->eth_q_stats.tx_max_drbr_queue_depth = depth; 5636 } 5637 | 5648 goto bxe_tx_mq_start_locked_exit; 5649 } 5650 5651 /* fetch the depth of the driver queue */ 5652 depth = drbr_inuse_drv(ifp, tx_br); 5653 if (depth > fp->eth_q_stats.tx_max_drbr_queue_depth) { 5654 fp->eth_q_stats.tx_max_drbr_queue_depth = depth; 5655 } 5656 |
5638 if (m == NULL) { 5639 /* no new work, check for pending frames */ 5640 next = drbr_dequeue_drv(ifp, tx_br); 5641 } else if (drbr_needs_enqueue_drv(ifp, tx_br)) { 5642 /* have both new and pending work, maintain packet order */ 5643 rc = drbr_enqueue(ifp, tx_br, m); 5644 if (rc != 0) { 5645 fp->eth_q_stats.tx_soft_errors++; 5646 goto bxe_tx_mq_start_locked_exit; | 5657 /* keep adding entries while there are frames to send */ 5658 while ((next = drbr_peek(ifp, tx_br)) != NULL) { 5659 /* handle any completions if we're running low */ 5660 tx_bd_avail = bxe_tx_avail(sc, fp); 5661 if (tx_bd_avail < BXE_TX_CLEANUP_THRESHOLD) { 5662 /* bxe_txeof will set IFF_DRV_OACTIVE appropriately */ 5663 bxe_txeof(sc, fp); 5664 tx_bd_avail = bxe_tx_avail(sc, fp); 5665 if (tx_bd_avail < (BXE_TSO_MAX_SEGMENTS + 1)) { 5666 fp->eth_q_stats.bd_avail_too_less_failures++; 5667 m_freem(next); 5668 drbr_advance(ifp, tx_br); 5669 rc = ENOBUFS; 5670 break; 5671 } |
5647 } | 5672 } |
5648 next = drbr_dequeue_drv(ifp, tx_br); 5649 } else { 5650 /* new work only and nothing pending */ 5651 next = m; 5652 } | |
5653 | 5673 |
5654 /* keep adding entries while there are frames to send */ 5655 while (next != NULL) { 5656 | |
5657 /* the mbuf now belongs to us */ 5658 fp->eth_q_stats.mbuf_alloc_tx++; 5659 5660 /* 5661 * Put the frame into the transmit ring. If we don't have room, 5662 * place the mbuf back at the head of the TX queue, set the 5663 * OACTIVE flag, and wait for the NIC to drain the chain. 5664 */ 5665 rc = bxe_tx_encap(fp, &next); 5666 if (__predict_false(rc != 0)) { 5667 fp->eth_q_stats.tx_encap_failures++; 5668 if (next != NULL) { 5669 /* mark the TX queue as full and save the frame */ 5670 if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); | 5674 /* the mbuf now belongs to us */ 5675 fp->eth_q_stats.mbuf_alloc_tx++; 5676 5677 /* 5678 * Put the frame into the transmit ring. If we don't have room, 5679 * place the mbuf back at the head of the TX queue, set the 5680 * OACTIVE flag, and wait for the NIC to drain the chain. 5681 */ 5682 rc = bxe_tx_encap(fp, &next); 5683 if (__predict_false(rc != 0)) { 5684 fp->eth_q_stats.tx_encap_failures++; 5685 if (next != NULL) { 5686 /* mark the TX queue as full and save the frame */ 5687 if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); |
5671 /* XXX this may reorder the frame */ 5672 rc = drbr_enqueue(ifp, tx_br, next); | 5688 drbr_putback(ifp, tx_br, next); |
5673 fp->eth_q_stats.mbuf_alloc_tx--; 5674 fp->eth_q_stats.tx_frames_deferred++; | 5689 fp->eth_q_stats.mbuf_alloc_tx--; 5690 fp->eth_q_stats.tx_frames_deferred++; |
5675 } | 5691 } else 5692 drbr_advance(ifp, tx_br); |
5676 5677 /* stop looking for more work */ 5678 break; 5679 } 5680 5681 /* the transmit frame was enqueued successfully */ 5682 tx_count++; 5683 5684 /* send a copy of the frame to any BPF listeners */ 5685 if_etherbpfmtap(ifp, next); 5686 | 5693 5694 /* stop looking for more work */ 5695 break; 5696 } 5697 5698 /* the transmit frame was enqueued successfully */ 5699 tx_count++; 5700 5701 /* send a copy of the frame to any BPF listeners */ 5702 if_etherbpfmtap(ifp, next); 5703 |
5687 tx_bd_avail = bxe_tx_avail(sc, fp); 5688 5689 /* handle any completions if we're running low */ 5690 if (tx_bd_avail < BXE_TX_CLEANUP_THRESHOLD) { 5691 /* bxe_txeof will set IFF_DRV_OACTIVE appropriately */ 5692 bxe_txeof(sc, fp); 5693 if (if_getdrvflags(ifp) & IFF_DRV_OACTIVE) { 5694 break; 5695 } 5696 } 5697 5698 next = drbr_dequeue_drv(ifp, tx_br); | 5704 drbr_advance(ifp, tx_br); |
5699 } 5700 5701 /* all TX packets were dequeued and/or the tx ring is full */ 5702 if (tx_count > 0) { 5703 /* reset the TX watchdog timeout timer */ 5704 fp->watchdog_timer = BXE_TX_TIMEOUT; 5705 } 5706 5707bxe_tx_mq_start_locked_exit: | 5705 } 5706 5707 /* all TX packets were dequeued and/or the tx ring is full */ 5708 if (tx_count > 0) { 5709 /* reset the TX watchdog timeout timer */ 5710 fp->watchdog_timer = BXE_TX_TIMEOUT; 5711 } 5712 5713bxe_tx_mq_start_locked_exit: |
5714 /* If we didn't drain the drbr, enqueue a task in the future to do it. */ 5715 if (!drbr_empty(ifp, tx_br)) { 5716 fp->eth_q_stats.tx_mq_not_empty++; 5717 taskqueue_enqueue_timeout(fp->tq, &fp->tx_timeout_task, 1); 5718 } |
|
5708 5709 return (rc); 5710} 5711 | 5719 5720 return (rc); 5721} 5722 |
5723static void 5724bxe_tx_mq_start_deferred(void *arg, 5725 int pending) 5726{ 5727 struct bxe_fastpath *fp = (struct bxe_fastpath *)arg; 5728 struct bxe_softc *sc = fp->sc; 5729 if_t ifp = sc->ifp; 5730 5731 BXE_FP_TX_LOCK(fp); 5732 bxe_tx_mq_start_locked(sc, ifp, fp, NULL); 5733 BXE_FP_TX_UNLOCK(fp); 5734} 5735 |
|
5712/* Multiqueue (TSS) dispatch routine. */ 5713static int 5714bxe_tx_mq_start(struct ifnet *ifp, 5715 struct mbuf *m) 5716{ 5717 struct bxe_softc *sc = if_getsoftc(ifp); 5718 struct bxe_fastpath *fp; 5719 int fp_index, rc; --- 5 unchanged lines hidden (view full) --- 5725 if (BXE_VALID_FLOWID(m)) 5726 fp_index = (m->m_pkthdr.flowid % sc->num_queues); 5727 5728 fp = &sc->fp[fp_index]; 5729 5730 if (BXE_FP_TX_TRYLOCK(fp)) { 5731 rc = bxe_tx_mq_start_locked(sc, ifp, fp, m); 5732 BXE_FP_TX_UNLOCK(fp); | 5736/* Multiqueue (TSS) dispatch routine. */ 5737static int 5738bxe_tx_mq_start(struct ifnet *ifp, 5739 struct mbuf *m) 5740{ 5741 struct bxe_softc *sc = if_getsoftc(ifp); 5742 struct bxe_fastpath *fp; 5743 int fp_index, rc; --- 5 unchanged lines hidden (view full) --- 5749 if (BXE_VALID_FLOWID(m)) 5750 fp_index = (m->m_pkthdr.flowid % sc->num_queues); 5751 5752 fp = &sc->fp[fp_index]; 5753 5754 if (BXE_FP_TX_TRYLOCK(fp)) { 5755 rc = bxe_tx_mq_start_locked(sc, ifp, fp, m); 5756 BXE_FP_TX_UNLOCK(fp); |
5733 } else | 5757 } else { |
5734 rc = drbr_enqueue(ifp, fp->tx_br, m); | 5758 rc = drbr_enqueue(ifp, fp->tx_br, m); |
5759 taskqueue_enqueue(fp->tq, &fp->tx_task); 5760 } |
|
5735 5736 return (rc); 5737} 5738 5739static void 5740bxe_mq_flush(struct ifnet *ifp) 5741{ 5742 struct bxe_softc *sc = if_getsoftc(ifp); --- 18 unchanged lines hidden (view full) --- 5761 } 5762 BXE_FP_TX_UNLOCK(fp); 5763 } 5764 } 5765 5766 if_qflush(ifp); 5767} 5768 | 5761 5762 return (rc); 5763} 5764 5765static void 5766bxe_mq_flush(struct ifnet *ifp) 5767{ 5768 struct bxe_softc *sc = if_getsoftc(ifp); --- 18 unchanged lines hidden (view full) --- 5787 } 5788 BXE_FP_TX_UNLOCK(fp); 5789 } 5790 } 5791 5792 if_qflush(ifp); 5793} 5794 |
5769#endif /* FreeBSD_version >= 800000 */ | 5795#endif /* FreeBSD_version >= 901504 */ |
5770 5771static uint16_t 5772bxe_cid_ilt_lines(struct bxe_softc *sc) 5773{ 5774 if (IS_SRIOV(sc)) { 5775 return ((BXE_FIRST_VF_CID + BXE_VF_CIDS) / ILT_PAGE_CIDS); 5776 } 5777 return (L2_ILT_LINES(sc)); --- 343 unchanged lines hidden (view full) --- 6121bxe_free_fp_buffers(struct bxe_softc *sc) 6122{ 6123 struct bxe_fastpath *fp; 6124 int i; 6125 6126 for (i = 0; i < sc->num_queues; i++) { 6127 fp = &sc->fp[i]; 6128 | 5796 5797static uint16_t 5798bxe_cid_ilt_lines(struct bxe_softc *sc) 5799{ 5800 if (IS_SRIOV(sc)) { 5801 return ((BXE_FIRST_VF_CID + BXE_VF_CIDS) / ILT_PAGE_CIDS); 5802 } 5803 return (L2_ILT_LINES(sc)); --- 343 unchanged lines hidden (view full) --- 6147bxe_free_fp_buffers(struct bxe_softc *sc) 6148{ 6149 struct bxe_fastpath *fp; 6150 int i; 6151 6152 for (i = 0; i < sc->num_queues; i++) { 6153 fp = &sc->fp[i]; 6154 |
6129#if __FreeBSD_version >= 800000 | 6155#if __FreeBSD_version >= 901504 |
6130 if (fp->tx_br != NULL) { 6131 /* just in case bxe_mq_flush() wasn't called */ 6132 if (mtx_initialized(&fp->tx_mtx)) { 6133 struct mbuf *m; 6134 6135 BXE_FP_TX_LOCK(fp); 6136 while ((m = buf_ring_dequeue_sc(fp->tx_br)) != NULL) 6137 m_freem(m); --- 810 unchanged lines hidden (view full) --- 6948 6949/* this function is called upon a link interrupt */ 6950static void 6951bxe_link_attn(struct bxe_softc *sc) 6952{ 6953 uint32_t pause_enabled = 0; 6954 struct host_port_stats *pstats; 6955 int cmng_fns; | 6156 if (fp->tx_br != NULL) { 6157 /* just in case bxe_mq_flush() wasn't called */ 6158 if (mtx_initialized(&fp->tx_mtx)) { 6159 struct mbuf *m; 6160 6161 BXE_FP_TX_LOCK(fp); 6162 while ((m = buf_ring_dequeue_sc(fp->tx_br)) != NULL) 6163 m_freem(m); --- 810 unchanged lines hidden (view full) --- 6974 6975/* this function is called upon a link interrupt */ 6976static void 6977bxe_link_attn(struct bxe_softc *sc) 6978{ 6979 uint32_t pause_enabled = 0; 6980 struct host_port_stats *pstats; 6981 int cmng_fns; |
6982 struct bxe_fastpath *fp; 6983 int i; |
|
6956 6957 /* Make sure that we are synced with the current statistics */ 6958 bxe_stats_handle(sc, STATS_EVENT_STOP); 6959 6960 elink_link_update(&sc->link_params, &sc->link_vars); 6961 6962 if (sc->link_vars.link_up) { 6963 --- 15 unchanged lines hidden (view full) --- 6979 pstats = BXE_SP(sc, port_stats); 6980 /* reset old mac stats */ 6981 memset(&(pstats->mac_stx[0]), 0, sizeof(struct mac_stx)); 6982 } 6983 6984 if (sc->state == BXE_STATE_OPEN) { 6985 bxe_stats_handle(sc, STATS_EVENT_LINK_UP); 6986 } | 6984 6985 /* Make sure that we are synced with the current statistics */ 6986 bxe_stats_handle(sc, STATS_EVENT_STOP); 6987 6988 elink_link_update(&sc->link_params, &sc->link_vars); 6989 6990 if (sc->link_vars.link_up) { 6991 --- 15 unchanged lines hidden (view full) --- 7007 pstats = BXE_SP(sc, port_stats); 7008 /* reset old mac stats */ 7009 memset(&(pstats->mac_stx[0]), 0, sizeof(struct mac_stx)); 7010 } 7011 7012 if (sc->state == BXE_STATE_OPEN) { 7013 bxe_stats_handle(sc, STATS_EVENT_LINK_UP); 7014 } |
7015 7016 /* Restart tx when the link comes back. */ 7017 FOR_EACH_ETH_QUEUE(sc, i) { 7018 fp = &sc->fp[i]; 7019 taskqueue_enqueue(fp->tq, &fp->tx_task); 7020 } |
|
6987 } 6988 6989 if (sc->link_vars.link_up && sc->link_vars.line_speed) { 6990 cmng_fns = bxe_get_cmng_fns_mode(sc); 6991 6992 if (cmng_fns != CMNG_FNS_NONE) { 6993 bxe_cmng_fns_init(sc, FALSE, cmng_fns); 6994 storm_memset_cmng(sc, &sc->cmng, SC_PORT(sc)); --- 2035 unchanged lines hidden (view full) --- 9030 bus_teardown_intr(sc->dev, sc->intr[i].resource, sc->intr[i].tag); 9031 } 9032 } 9033 9034 for (i = 0; i < sc->num_queues; i++) { 9035 fp = &sc->fp[i]; 9036 if (fp->tq) { 9037 taskqueue_drain(fp->tq, &fp->tq_task); | 7021 } 7022 7023 if (sc->link_vars.link_up && sc->link_vars.line_speed) { 7024 cmng_fns = bxe_get_cmng_fns_mode(sc); 7025 7026 if (cmng_fns != CMNG_FNS_NONE) { 7027 bxe_cmng_fns_init(sc, FALSE, cmng_fns); 7028 storm_memset_cmng(sc, &sc->cmng, SC_PORT(sc)); --- 2035 unchanged lines hidden (view full) --- 9064 bus_teardown_intr(sc->dev, sc->intr[i].resource, sc->intr[i].tag); 9065 } 9066 } 9067 9068 for (i = 0; i < sc->num_queues; i++) { 9069 fp = &sc->fp[i]; 9070 if (fp->tq) { 9071 taskqueue_drain(fp->tq, &fp->tq_task); |
9072 taskqueue_drain(fp->tq, &fp->tx_task); 9073 while (taskqueue_cancel_timeout(fp->tq, &fp->tx_timeout_task, 9074 NULL)) 9075 taskqueue_drain_timeout(fp->tq, &fp->tx_timeout_task); |
|
9038 taskqueue_free(fp->tq); 9039 fp->tq = NULL; 9040 } 9041 } 9042 9043 9044 if (sc->sp_tq) { 9045 taskqueue_drain(sc->sp_tq, &sc->sp_tq_task); --- 16 unchanged lines hidden (view full) --- 9062{ 9063 struct bxe_fastpath *fp; 9064 int rc = 0; 9065 int i; 9066 9067 snprintf(sc->sp_tq_name, sizeof(sc->sp_tq_name), 9068 "bxe%d_sp_tq", sc->unit); 9069 TASK_INIT(&sc->sp_tq_task, 0, bxe_handle_sp_tq, sc); | 9076 taskqueue_free(fp->tq); 9077 fp->tq = NULL; 9078 } 9079 } 9080 9081 9082 if (sc->sp_tq) { 9083 taskqueue_drain(sc->sp_tq, &sc->sp_tq_task); --- 16 unchanged lines hidden (view full) --- 9100{ 9101 struct bxe_fastpath *fp; 9102 int rc = 0; 9103 int i; 9104 9105 snprintf(sc->sp_tq_name, sizeof(sc->sp_tq_name), 9106 "bxe%d_sp_tq", sc->unit); 9107 TASK_INIT(&sc->sp_tq_task, 0, bxe_handle_sp_tq, sc); |
9070 sc->sp_tq = taskqueue_create_fast(sc->sp_tq_name, M_NOWAIT, 9071 taskqueue_thread_enqueue, 9072 &sc->sp_tq); | 9108 sc->sp_tq = taskqueue_create(sc->sp_tq_name, M_NOWAIT, 9109 taskqueue_thread_enqueue, 9110 &sc->sp_tq); |
9073 taskqueue_start_threads(&sc->sp_tq, 1, PWAIT, /* lower priority */ 9074 "%s", sc->sp_tq_name); 9075 9076 9077 for (i = 0; i < sc->num_queues; i++) { 9078 fp = &sc->fp[i]; 9079 snprintf(fp->tq_name, sizeof(fp->tq_name), 9080 "bxe%d_fp%d_tq", sc->unit, i); 9081 TASK_INIT(&fp->tq_task, 0, bxe_handle_fp_tq, fp); | 9111 taskqueue_start_threads(&sc->sp_tq, 1, PWAIT, /* lower priority */ 9112 "%s", sc->sp_tq_name); 9113 9114 9115 for (i = 0; i < sc->num_queues; i++) { 9116 fp = &sc->fp[i]; 9117 snprintf(fp->tq_name, sizeof(fp->tq_name), 9118 "bxe%d_fp%d_tq", sc->unit, i); 9119 TASK_INIT(&fp->tq_task, 0, bxe_handle_fp_tq, fp); |
9082 fp->tq = taskqueue_create_fast(fp->tq_name, M_NOWAIT, 9083 taskqueue_thread_enqueue, 9084 &fp->tq); | 9120 TASK_INIT(&fp->tx_task, 0, bxe_tx_mq_start_deferred, fp); 9121 fp->tq = taskqueue_create(fp->tq_name, M_NOWAIT, 9122 taskqueue_thread_enqueue, 9123 &fp->tq); 9124 TIMEOUT_TASK_INIT(fp->tq, &fp->tx_timeout_task, 0, 9125 bxe_tx_mq_start_deferred, fp); |
9085 taskqueue_start_threads(&fp->tq, 1, PI_NET, /* higher priority */ 9086 "%s", fp->tq_name); 9087 } 9088 9089 /* setup interrupt handlers */ 9090 if (sc->interrupt_mode == INTR_MODE_MSIX) { 9091 BLOGD(sc, DBG_LOAD, "Enabling slowpath MSI-X[0] vector\n"); 9092 --- 3016 unchanged lines hidden (view full) --- 12109} 12110 12111/* periodic timer callout routine, only runs when the interface is up */ 12112 12113static void 12114bxe_periodic_callout_func(void *xsc) 12115{ 12116 struct bxe_softc *sc = (struct bxe_softc *)xsc; | 9126 taskqueue_start_threads(&fp->tq, 1, PI_NET, /* higher priority */ 9127 "%s", fp->tq_name); 9128 } 9129 9130 /* setup interrupt handlers */ 9131 if (sc->interrupt_mode == INTR_MODE_MSIX) { 9132 BLOGD(sc, DBG_LOAD, "Enabling slowpath MSI-X[0] vector\n"); 9133 --- 3016 unchanged lines hidden (view full) --- 12150} 12151 12152/* periodic timer callout routine, only runs when the interface is up */ 12153 12154static void 12155bxe_periodic_callout_func(void *xsc) 12156{ 12157 struct bxe_softc *sc = (struct bxe_softc *)xsc; |
12117 struct bxe_fastpath *fp; 12118 uint16_t tx_bd_avail; | |
12119 int i; 12120 12121 if (!BXE_CORE_TRYLOCK(sc)) { 12122 /* just bail and try again next time */ 12123 12124 if ((sc->state == BXE_STATE_OPEN) && 12125 (atomic_load_acq_long(&sc->periodic_flags) == PERIODIC_GO)) { 12126 /* schedule the next periodic callout */ --- 4 unchanged lines hidden (view full) --- 12131 return; 12132 } 12133 12134 if ((sc->state != BXE_STATE_OPEN) || 12135 (atomic_load_acq_long(&sc->periodic_flags) == PERIODIC_STOP)) { 12136 BLOGW(sc, "periodic callout exit (state=0x%x)\n", sc->state); 12137 BXE_CORE_UNLOCK(sc); 12138 return; | 12158 int i; 12159 12160 if (!BXE_CORE_TRYLOCK(sc)) { 12161 /* just bail and try again next time */ 12162 12163 if ((sc->state == BXE_STATE_OPEN) && 12164 (atomic_load_acq_long(&sc->periodic_flags) == PERIODIC_GO)) { 12165 /* schedule the next periodic callout */ --- 4 unchanged lines hidden (view full) --- 12170 return; 12171 } 12172 12173 if ((sc->state != BXE_STATE_OPEN) || 12174 (atomic_load_acq_long(&sc->periodic_flags) == PERIODIC_STOP)) { 12175 BLOGW(sc, "periodic callout exit (state=0x%x)\n", sc->state); 12176 BXE_CORE_UNLOCK(sc); 12177 return; |
12139 } 12140 12141#if __FreeBSD_version >= 800000 12142 12143 FOR_EACH_QUEUE(sc, i) { 12144 fp = &sc->fp[i]; 12145 12146 if (BXE_FP_TX_TRYLOCK(fp)) { 12147 if_t ifp = sc->ifp; 12148 /* 12149 * If interface was stopped due to unavailable 12150 * bds, try to process some tx completions 12151 */ 12152 (void) bxe_txeof(sc, fp); 12153 12154 tx_bd_avail = bxe_tx_avail(sc, fp); 12155 if (tx_bd_avail >= BXE_TX_CLEANUP_THRESHOLD) { 12156 bxe_tx_mq_start_locked(sc, ifp, fp, NULL); 12157 } 12158 BXE_FP_TX_UNLOCK(fp); | |
12159 } | 12178 } |
12160 } | |
12161 | 12179 |
12162#else | |
12163 | 12180 |
12164 fp = &sc->fp[0]; 12165 if (BXE_FP_TX_TRYLOCK(fp)) { 12166 struct ifnet *ifp = sc->ifnet; 12167 /* 12168 * If interface was stopped due to unavailable 12169 * bds, try to process some tx completions 12170 */ 12171 (void) bxe_txeof(sc, fp); 12172 12173 tx_bd_avail = bxe_tx_avail(sc, fp); 12174 if (tx_bd_avail >= BXE_TX_CLEANUP_THRESHOLD) { 12175 bxe_tx_start_locked(sc, ifp, fp); 12176 } 12177 12178 BXE_FP_TX_UNLOCK(fp); 12179 } 12180 12181#endif /* #if __FreeBSD_version >= 800000 */ 12182 | |
12183 /* Check for TX timeouts on any fastpath. */ 12184 FOR_EACH_QUEUE(sc, i) { 12185 if (bxe_watchdog(sc, &sc->fp[i]) != 0) { 12186 /* Ruh-Roh, chip was reset! */ 12187 break; 12188 } 12189 } 12190 --- 460 unchanged lines hidden (view full) --- 12651 } 12652 12653 if_setsoftc(ifp, sc); 12654 if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev)); 12655 if_setflags(ifp, (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST)); 12656 if_setioctlfn(ifp, bxe_ioctl); 12657 if_setstartfn(ifp, bxe_tx_start); 12658 if_setgetcounterfn(ifp, bxe_get_counter); | 12181 /* Check for TX timeouts on any fastpath. */ 12182 FOR_EACH_QUEUE(sc, i) { 12183 if (bxe_watchdog(sc, &sc->fp[i]) != 0) { 12184 /* Ruh-Roh, chip was reset! */ 12185 break; 12186 } 12187 } 12188 --- 460 unchanged lines hidden (view full) --- 12649 } 12650 12651 if_setsoftc(ifp, sc); 12652 if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev)); 12653 if_setflags(ifp, (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST)); 12654 if_setioctlfn(ifp, bxe_ioctl); 12655 if_setstartfn(ifp, bxe_tx_start); 12656 if_setgetcounterfn(ifp, bxe_get_counter); |
12659#if __FreeBSD_version >= 800000 | 12657#if __FreeBSD_version >= 901504 |
12660 if_settransmitfn(ifp, bxe_tx_mq_start); 12661 if_setqflushfn(ifp, bxe_mq_flush); 12662#endif 12663#ifdef FreeBSD8_0 12664 if_settimer(ifp, 0); 12665#endif 12666 if_setinitfn(ifp, bxe_init); 12667 if_setmtu(ifp, sc->mtu); --- 3026 unchanged lines hidden (view full) --- 15694 bxe_eth_q_stats_arr[j].string); 15695 } 15696 } 15697} 15698 15699static int 15700bxe_alloc_buf_rings(struct bxe_softc *sc) 15701{ | 12658 if_settransmitfn(ifp, bxe_tx_mq_start); 12659 if_setqflushfn(ifp, bxe_mq_flush); 12660#endif 12661#ifdef FreeBSD8_0 12662 if_settimer(ifp, 0); 12663#endif 12664 if_setinitfn(ifp, bxe_init); 12665 if_setmtu(ifp, sc->mtu); --- 3026 unchanged lines hidden (view full) --- 15692 bxe_eth_q_stats_arr[j].string); 15693 } 15694 } 15695} 15696 15697static int 15698bxe_alloc_buf_rings(struct bxe_softc *sc) 15699{ |
15702#if __FreeBSD_version >= 800000 | 15700#if __FreeBSD_version >= 901504 |
15703 15704 int i; 15705 struct bxe_fastpath *fp; 15706 15707 for (i = 0; i < sc->num_queues; i++) { 15708 15709 fp = &sc->fp[i]; 15710 --- 4 unchanged lines hidden (view full) --- 15715 } 15716#endif 15717 return (0); 15718} 15719 15720static void 15721bxe_free_buf_rings(struct bxe_softc *sc) 15722{ | 15701 15702 int i; 15703 struct bxe_fastpath *fp; 15704 15705 for (i = 0; i < sc->num_queues; i++) { 15706 15707 fp = &sc->fp[i]; 15708 --- 4 unchanged lines hidden (view full) --- 15713 } 15714#endif 15715 return (0); 15716} 15717 15718static void 15719bxe_free_buf_rings(struct bxe_softc *sc) 15720{ |
15723#if __FreeBSD_version >= 800000 | 15721#if __FreeBSD_version >= 901504 |
15724 15725 int i; 15726 struct bxe_fastpath *fp; 15727 15728 for (i = 0; i < sc->num_queues; i++) { 15729 15730 fp = &sc->fp[i]; 15731 --- 3263 unchanged lines hidden --- | 15722 15723 int i; 15724 struct bxe_fastpath *fp; 15725 15726 for (i = 0; i < sc->num_queues; i++) { 15727 15728 fp = &sc->fp[i]; 15729 --- 3263 unchanged lines hidden --- |