Deleted Added
sdiff udiff text old ( 170789 ) new ( 170869 )
full compact
1/**************************************************************************
2
3Copyright (c) 2007, Chelsio Inc.
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8

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

23INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26POSSIBILITY OF SUCH DAMAGE.
27
28***************************************************************************/
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/cxgb/cxgb_sge.c 170789 2007-06-15 20:02:02Z kmacy $");
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/kernel.h>
36#include <sys/module.h>
37#include <sys/bus.h>
38#include <sys/conf.h>
39#include <machine/bus.h>

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

681 refill_rx = ((qs->fl[0].credits < qs->fl[0].size) ||
682 (qs->fl[1].credits < qs->fl[1].size));
683 if (reclaim_eth || reclaim_ofl || refill_rx) {
684 p = &sc->port[i];
685 taskqueue_enqueue(p->tq, &p->timer_reclaim_task);
686 break;
687 }
688 }
689 callout_reset(&sc->sge_timer_ch, TX_RECLAIM_PERIOD, sge_timer_cb, sc);
690}
691
692/*
693 * This is meant to be a catch-all function to keep sge state private
694 * to sge.c
695 *
696 */
697int

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

1462 bus_dma_tag_destroy(q->fl[i].entry_tag);
1463 }
1464 if (q->fl[i].sdesc) {
1465 free_rx_bufs(sc, &q->fl[i]);
1466 free(q->fl[i].sdesc, M_DEVBUF);
1467 }
1468 }
1469
1470 for (i = 0; i < SGE_TXQ_PER_SET; ++i) {
1471 if (q->txq[i].desc) {
1472 mtx_lock(&sc->sge.reg_lock);
1473 t3_sge_enable_ecntxt(sc, q->txq[i].cntxt_id, 0);
1474 mtx_unlock(&sc->sge.reg_lock);
1475 bus_dmamap_unload(q->txq[i].desc_tag,
1476 q->txq[i].desc_map);
1477 bus_dmamem_free(q->txq[i].desc_tag, q->txq[i].desc,
1478 q->txq[i].desc_map);
1479 bus_dma_tag_destroy(q->txq[i].desc_tag);
1480 bus_dma_tag_destroy(q->txq[i].entry_tag);
1481 }
1482 if (q->txq[i].sdesc) {
1483 free(q->txq[i].sdesc, M_DEVBUF);
1484 }
1485 if (mtx_initialized(&q->txq[i].lock)) {
1486 mtx_destroy(&q->txq[i].lock);
1487 }
1488 }
1489
1490 if (q->rspq.desc) {
1491 mtx_lock(&sc->sge.reg_lock);
1492 t3_sge_disable_rspcntxt(sc, q->rspq.cntxt_id);
1493 mtx_unlock(&sc->sge.reg_lock);
1494
1495 bus_dmamap_unload(q->rspq.desc_tag, q->rspq.desc_map);
1496 bus_dmamem_free(q->rspq.desc_tag, q->rspq.desc,
1497 q->rspq.desc_map);
1498 bus_dma_tag_destroy(q->rspq.desc_tag);
1499 }
1500
1501 if (mtx_initialized(&q->rspq.lock))
1502 mtx_destroy(&q->rspq.lock);
1503
1504 bzero(q, sizeof(*q));
1505}
1506
1507/**
1508 * t3_free_sge_resources - free SGE resources
1509 * @sc: the adapter softc
1510 *
1511 * Frees resources used by the SGE queue sets.
1512 */
1513void
1514t3_free_sge_resources(adapter_t *sc)
1515{
1516 int i;
1517
1518 for (i = 0; i < SGE_QSETS; ++i)
1519 t3_free_qset(sc, &sc->sge.qs[i]);
1520}
1521
1522/**
1523 * t3_sge_start - enable SGE
1524 * @sc: the controller softc
1525 *
1526 * Enables the SGE for DMAs. This is the last step in starting packet

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

1543 * tasklets as it cannot wait, however the tasklets will have no effect
1544 * since the doorbells are disabled and the driver will call this again
1545 * later from process context, at which time the tasklets will be stopped
1546 * if they are still running.
1547 */
1548void
1549t3_sge_stop(adapter_t *sc)
1550{
1551 int i;
1552 t3_set_reg_field(sc, A_SG_CONTROL, F_GLOBALENABLE, 0);
1553
1554 if (sc->tq == NULL)
1555 return;
1556
1557 for (i = 0; i < SGE_QSETS; ++i) {
1558 struct sge_qset *qs = &sc->sge.qs[i];
1559
1560 taskqueue_drain(sc->tq, &qs->txq[TXQ_OFLD].qresume_tsk);
1561 taskqueue_drain(sc->tq, &qs->txq[TXQ_CTRL].qresume_tsk);
1562 }
1563}
1564
1565

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

2005 &q->txq[i].desc_map,
2006 sc->tx_dmat, &q->txq[i].entry_tag)) != 0) {
2007 printf("error %d from alloc ring tx %i\n", ret, i);
2008 goto err;
2009 }
2010 mbufq_init(&q->txq[i].sendq);
2011 q->txq[i].gen = 1;
2012 q->txq[i].size = p->txq_size[i];
2013 mtx_init(&q->txq[i].lock, "t3 txq lock", NULL, MTX_DEF);
2014 }
2015
2016 TASK_INIT(&q->txq[TXQ_OFLD].qresume_tsk, 0, restart_offloadq, q);
2017 TASK_INIT(&q->txq[TXQ_CTRL].qresume_tsk, 0, restart_ctrlq, q);
2018
2019 q->fl[0].gen = q->fl[1].gen = 1;
2020 q->fl[0].size = p->fl_size;
2021 q->fl[1].size = p->jumbo_size;
2022
2023 q->rspq.gen = 1;
2024 q->rspq.size = p->rspq_size;
2025 mtx_init(&q->rspq.lock, "t3 rspq lock", NULL, MTX_DEF);
2026
2027 q->txq[TXQ_ETH].stop_thres = nports *
2028 flits_to_desc(sgl_len(TX_MAX_SEGS + 1) + 3);
2029
2030 q->fl[0].buf_size = MCLBYTES;
2031 q->fl[0].zone = zone_clust;
2032 q->fl[0].type = EXT_CLUSTER;
2033 q->fl[1].buf_size = MJUMPAGESIZE;
2034 q->fl[1].zone = zone_jumbop;

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

2083 q->txq[TXQ_CTRL].size,
2084 q->txq[TXQ_CTRL].token, 1, 0);
2085 if (ret) {
2086 printf("error %d from t3_sge_init_ecntxt\n", ret);
2087 goto err_unlock;
2088 }
2089 }
2090
2091 mtx_unlock(&sc->sge.reg_lock);
2092 t3_update_qset_coalesce(q, p);
2093 q->port = pi;
2094
2095 refill_fl(sc, &q->fl[0], q->fl[0].size);
2096 refill_fl(sc, &q->fl[1], q->fl[1].size);
2097 refill_rspq(sc, &q->rspq, q->rspq.size - 1);
2098

--- 570 unchanged lines hidden ---