cxgb_sge.c (170789) | cxgb_sge.c (170869) |
---|---|
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> | 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 $"); | 31__FBSDID("$FreeBSD: head/sys/dev/cxgb/cxgb_sge.c 170869 2007-06-17 04:33:38Z 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 } | 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); | 689 if (sc->open_device_map != 0) 690 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 | 691} 692 693/* 694 * This is meant to be a catch-all function to keep sge state private 695 * to sge.c 696 * 697 */ 698int --- 764 unchanged lines hidden (view full) --- 1463 bus_dma_tag_destroy(q->fl[i].entry_tag); 1464 } 1465 if (q->fl[i].sdesc) { 1466 free_rx_bufs(sc, &q->fl[i]); 1467 free(q->fl[i].sdesc, M_DEVBUF); 1468 } 1469 } 1470 |
1470 for (i = 0; i < SGE_TXQ_PER_SET; ++i) { | 1471 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); | 1472 if (q->txq[i].desc) { 1473 mtx_lock(&sc->sge.reg_lock); 1474 t3_sge_enable_ecntxt(sc, q->txq[i].cntxt_id, 0); 1475 mtx_unlock(&sc->sge.reg_lock); 1476 bus_dmamap_unload(q->txq[i].desc_tag, 1477 q->txq[i].desc_map); 1478 bus_dmamem_free(q->txq[i].desc_tag, q->txq[i].desc, 1479 q->txq[i].desc_map); 1480 bus_dma_tag_destroy(q->txq[i].desc_tag); 1481 bus_dma_tag_destroy(q->txq[i].entry_tag); |
1482 MTX_DESTROY(&q->txq[i].lock); |
|
1481 } 1482 if (q->txq[i].sdesc) { 1483 free(q->txq[i].sdesc, M_DEVBUF); 1484 } | 1483 } 1484 if (q->txq[i].sdesc) { 1485 free(q->txq[i].sdesc, M_DEVBUF); 1486 } |
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); | 1487 } 1488 1489 if (q->rspq.desc) { 1490 mtx_lock(&sc->sge.reg_lock); 1491 t3_sge_disable_rspcntxt(sc, q->rspq.cntxt_id); 1492 mtx_unlock(&sc->sge.reg_lock); 1493 1494 bus_dmamap_unload(q->rspq.desc_tag, q->rspq.desc_map); 1495 bus_dmamem_free(q->rspq.desc_tag, q->rspq.desc, 1496 q->rspq.desc_map); 1497 bus_dma_tag_destroy(q->rspq.desc_tag); |
1498 MTX_DESTROY(&q->rspq.lock); |
|
1499 } 1500 | 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{ | 1501 bzero(q, sizeof(*q)); 1502} 1503 1504/** 1505 * t3_free_sge_resources - free SGE resources 1506 * @sc: the adapter softc 1507 * 1508 * Frees resources used by the SGE queue sets. 1509 */ 1510void 1511t3_free_sge_resources(adapter_t *sc) 1512{ |
1516 int i; | 1513 int i, nqsets; |
1517 | 1514 |
1518 for (i = 0; i < SGE_QSETS; ++i) | 1515 for (nqsets = i = 0; i < (sc)->params.nports; i++) 1516 nqsets += sc->port[i].nqsets; 1517 1518 for (i = 0; i < nqsets; ++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{ | 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; | 1551 int i, nqsets; 1552 |
1552 t3_set_reg_field(sc, A_SG_CONTROL, F_GLOBALENABLE, 0); 1553 1554 if (sc->tq == NULL) 1555 return; 1556 | 1553 t3_set_reg_field(sc, A_SG_CONTROL, F_GLOBALENABLE, 0); 1554 1555 if (sc->tq == NULL) 1556 return; 1557 |
1557 for (i = 0; i < SGE_QSETS; ++i) { | 1558 for (nqsets = i = 0; i < (sc)->params.nports; i++) 1559 nqsets += sc->port[i].nqsets; 1560 1561 for (i = 0; i < nqsets; ++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]; | 1562 struct sge_qset *qs = &sc->sge.qs[i]; 1563 1564 taskqueue_drain(sc->tq, &qs->txq[TXQ_OFLD].qresume_tsk); 1565 taskqueue_drain(sc->tq, &qs->txq[TXQ_CTRL].qresume_tsk); 1566 } 1567} 1568 1569 --- 439 unchanged lines hidden (view full) --- 2009 &q->txq[i].desc_map, 2010 sc->tx_dmat, &q->txq[i].entry_tag)) != 0) { 2011 printf("error %d from alloc ring tx %i\n", ret, i); 2012 goto err; 2013 } 2014 mbufq_init(&q->txq[i].sendq); 2015 q->txq[i].gen = 1; 2016 q->txq[i].size = p->txq_size[i]; |
2013 mtx_init(&q->txq[i].lock, "t3 txq lock", NULL, MTX_DEF); | 2017 snprintf(q->txq[i].lockbuf, TXQ_NAME_LEN, "t3 txq lock %d:%d:%d", 2018 device_get_unit(sc->dev), irq_vec_idx, i); 2019 MTX_INIT(&q->txq[i].lock, q->txq[i].lockbuf, 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; | 2020 } 2021 2022 TASK_INIT(&q->txq[TXQ_OFLD].qresume_tsk, 0, restart_offloadq, q); 2023 TASK_INIT(&q->txq[TXQ_CTRL].qresume_tsk, 0, restart_ctrlq, q); 2024 2025 q->fl[0].gen = q->fl[1].gen = 1; 2026 q->fl[0].size = p->fl_size; 2027 q->fl[1].size = p->jumbo_size; 2028 2029 q->rspq.gen = 1; 2030 q->rspq.size = p->rspq_size; |
2025 mtx_init(&q->rspq.lock, "t3 rspq lock", NULL, MTX_DEF); 2026 | 2031 |
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 | 2032 q->txq[TXQ_ETH].stop_thres = nports * 2033 flits_to_desc(sgl_len(TX_MAX_SEGS + 1) + 3); 2034 2035 q->fl[0].buf_size = MCLBYTES; 2036 q->fl[0].zone = zone_clust; 2037 q->fl[0].type = EXT_CLUSTER; 2038 q->fl[1].buf_size = MJUMPAGESIZE; 2039 q->fl[1].zone = zone_jumbop; --- 48 unchanged lines hidden (view full) --- 2088 q->txq[TXQ_CTRL].size, 2089 q->txq[TXQ_CTRL].token, 1, 0); 2090 if (ret) { 2091 printf("error %d from t3_sge_init_ecntxt\n", ret); 2092 goto err_unlock; 2093 } 2094 } 2095 |
2096 snprintf(q->rspq.lockbuf, RSPQ_NAME_LEN, "t3 rspq lock %d:%d", 2097 device_get_unit(sc->dev), irq_vec_idx); 2098 MTX_INIT(&q->rspq.lock, q->rspq.lockbuf, NULL, MTX_DEF); 2099 |
|
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 --- | 2100 mtx_unlock(&sc->sge.reg_lock); 2101 t3_update_qset_coalesce(q, p); 2102 q->port = pi; 2103 2104 refill_fl(sc, &q->fl[0], q->fl[0].size); 2105 refill_fl(sc, &q->fl[1], q->fl[1].size); 2106 refill_rspq(sc, &q->rspq, q->rspq.size - 1); 2107 --- 570 unchanged lines hidden --- |