Deleted Added
full compact
t4_sge.c (221911) t4_sge.c (222085)
1/*-
2 * Copyright (c) 2011 Chelsio Communications, Inc.
3 * All rights reserved.
4 * Written by: Navdeep Parhar <np@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2011 Chelsio Communications, Inc.
3 * All rights reserved.
4 * Written by: Navdeep Parhar <np@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/dev/cxgbe/t4_sge.c 221911 2011-05-14 19:27:15Z np $");
29__FBSDID("$FreeBSD: head/sys/dev/cxgbe/t4_sge.c 222085 2011-05-18 22:09:04Z np $");
30
31#include "opt_inet.h"
32
33#include <sys/types.h>
34#include <sys/mbuf.h>
35#include <sys/socket.h>
36#include <sys/kernel.h>
37#include <sys/malloc.h>

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

95 int, iq_intr_handler_t *, char *);
96static inline void init_fl(struct sge_fl *, int, char *);
97static inline void init_eq(struct sge_eq *, int, char *);
98static int alloc_ring(struct adapter *, size_t, bus_dma_tag_t *, bus_dmamap_t *,
99 bus_addr_t *, void **);
100static int free_ring(struct adapter *, bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
101 void *);
102static int alloc_iq_fl(struct port_info *, struct sge_iq *, struct sge_fl *,
30
31#include "opt_inet.h"
32
33#include <sys/types.h>
34#include <sys/mbuf.h>
35#include <sys/socket.h>
36#include <sys/kernel.h>
37#include <sys/malloc.h>

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

95 int, iq_intr_handler_t *, char *);
96static inline void init_fl(struct sge_fl *, int, char *);
97static inline void init_eq(struct sge_eq *, int, char *);
98static int alloc_ring(struct adapter *, size_t, bus_dma_tag_t *, bus_dmamap_t *,
99 bus_addr_t *, void **);
100static int free_ring(struct adapter *, bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
101 void *);
102static int alloc_iq_fl(struct port_info *, struct sge_iq *, struct sge_fl *,
103 int);
103 int, int);
104static int free_iq_fl(struct port_info *, struct sge_iq *, struct sge_fl *);
105static int alloc_iq(struct sge_iq *, int);
106static int free_iq(struct sge_iq *);
107static int alloc_rxq(struct port_info *, struct sge_rxq *, int, int);
108static int free_rxq(struct port_info *, struct sge_rxq *);
109static int alloc_ctrlq(struct adapter *, struct sge_ctrlq *, int);
110static int free_ctrlq(struct adapter *, struct sge_ctrlq *);
111static int alloc_txq(struct port_info *, struct sge_txq *, int);

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

1099 * allocated. Caller is responsible for cleanup in case this function fails.
1100 *
1101 * If the ingress queue will take interrupts directly (iq->handler == NULL) then
1102 * the intr_idx specifies the vector, starting from 0. Otherwise it specifies
1103 * the index of the queue to which its interrupts will be forwarded.
1104 */
1105static int
1106alloc_iq_fl(struct port_info *pi, struct sge_iq *iq, struct sge_fl *fl,
104static int free_iq_fl(struct port_info *, struct sge_iq *, struct sge_fl *);
105static int alloc_iq(struct sge_iq *, int);
106static int free_iq(struct sge_iq *);
107static int alloc_rxq(struct port_info *, struct sge_rxq *, int, int);
108static int free_rxq(struct port_info *, struct sge_rxq *);
109static int alloc_ctrlq(struct adapter *, struct sge_ctrlq *, int);
110static int free_ctrlq(struct adapter *, struct sge_ctrlq *);
111static int alloc_txq(struct port_info *, struct sge_txq *, int);

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

1099 * allocated. Caller is responsible for cleanup in case this function fails.
1100 *
1101 * If the ingress queue will take interrupts directly (iq->handler == NULL) then
1102 * the intr_idx specifies the vector, starting from 0. Otherwise it specifies
1103 * the index of the queue to which its interrupts will be forwarded.
1104 */
1105static int
1106alloc_iq_fl(struct port_info *pi, struct sge_iq *iq, struct sge_fl *fl,
1107 int intr_idx)
1107 int intr_idx, int cong)
1108{
1109 int rc, i, cntxt_id;
1110 size_t len;
1111 struct fw_iq_cmd c;
1112 struct adapter *sc = iq->adapter;
1113 __be32 v = 0;
1114
1115 /* The adapter queues are nominally allocated in port[0]'s name */

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

1150 V_FW_IQ_CMD_VIID(pi->viid) |
1151 V_FW_IQ_CMD_IQANUD(X_UPDATEDELIVERY_INTERRUPT));
1152 c.iqdroprss_to_iqesize = htobe16(V_FW_IQ_CMD_IQPCIECH(pi->tx_chan) |
1153 F_FW_IQ_CMD_IQGTSMODE |
1154 V_FW_IQ_CMD_IQINTCNTTHRESH(iq->intr_pktc_idx) |
1155 V_FW_IQ_CMD_IQESIZE(ilog2(iq->esize) - 4));
1156 c.iqsize = htobe16(iq->qsize);
1157 c.iqaddr = htobe64(iq->ba);
1108{
1109 int rc, i, cntxt_id;
1110 size_t len;
1111 struct fw_iq_cmd c;
1112 struct adapter *sc = iq->adapter;
1113 __be32 v = 0;
1114
1115 /* The adapter queues are nominally allocated in port[0]'s name */

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

1150 V_FW_IQ_CMD_VIID(pi->viid) |
1151 V_FW_IQ_CMD_IQANUD(X_UPDATEDELIVERY_INTERRUPT));
1152 c.iqdroprss_to_iqesize = htobe16(V_FW_IQ_CMD_IQPCIECH(pi->tx_chan) |
1153 F_FW_IQ_CMD_IQGTSMODE |
1154 V_FW_IQ_CMD_IQINTCNTTHRESH(iq->intr_pktc_idx) |
1155 V_FW_IQ_CMD_IQESIZE(ilog2(iq->esize) - 4));
1156 c.iqsize = htobe16(iq->qsize);
1157 c.iqaddr = htobe64(iq->ba);
1158 if (cong >= 0)
1159 c.iqns_to_fl0congen = htobe32(F_FW_IQ_CMD_IQFLINTCONGEN);
1158
1159 if (fl) {
1160 mtx_init(&fl->fl_lock, fl->lockname, NULL, MTX_DEF);
1161
1162 for (i = 0; i < FL_BUF_SIZES; i++) {
1163
1164 /*
1165 * A freelist buffer must be 16 byte aligned as the SGE

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

1193 device_printf(sc->dev,
1194 "failed to setup fl software descriptors: %d\n",
1195 rc);
1196 return (rc);
1197 }
1198 fl->needed = fl->cap;
1199
1200 c.iqns_to_fl0congen =
1160
1161 if (fl) {
1162 mtx_init(&fl->fl_lock, fl->lockname, NULL, MTX_DEF);
1163
1164 for (i = 0; i < FL_BUF_SIZES; i++) {
1165
1166 /*
1167 * A freelist buffer must be 16 byte aligned as the SGE

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

1195 device_printf(sc->dev,
1196 "failed to setup fl software descriptors: %d\n",
1197 rc);
1198 return (rc);
1199 }
1200 fl->needed = fl->cap;
1201
1202 c.iqns_to_fl0congen =
1201 htobe32(V_FW_IQ_CMD_FL0HOSTFCMODE(X_HOSTFCMODE_NONE));
1203 htobe32(V_FW_IQ_CMD_FL0HOSTFCMODE(X_HOSTFCMODE_NONE) |
1204 F_FW_IQ_CMD_FL0FETCHRO | F_FW_IQ_CMD_FL0DATARO |
1205 F_FW_IQ_CMD_FL0PADEN);
1206 if (cong >= 0) {
1207 c.iqns_to_fl0congen |=
1208 htobe32(V_FW_IQ_CMD_FL0CNGCHMAP(cong) |
1209 F_FW_IQ_CMD_FL0CONGCIF |
1210 F_FW_IQ_CMD_FL0CONGEN);
1211 }
1202 c.fl0dcaen_to_fl0cidxfthresh =
1203 htobe16(V_FW_IQ_CMD_FL0FBMIN(X_FETCHBURSTMIN_64B) |
1204 V_FW_IQ_CMD_FL0FBMAX(X_FETCHBURSTMAX_512B));
1205 c.fl0size = htobe16(fl->qsize);
1206 c.fl0addr = htobe64(fl->ba);
1207 }
1208
1209 rc = -t4_wr_mbox(sc, sc->mbox, &c, sizeof(c), &c);

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

1320 }
1321
1322 return (0);
1323}
1324
1325static int
1326alloc_iq(struct sge_iq *iq, int intr_idx)
1327{
1212 c.fl0dcaen_to_fl0cidxfthresh =
1213 htobe16(V_FW_IQ_CMD_FL0FBMIN(X_FETCHBURSTMIN_64B) |
1214 V_FW_IQ_CMD_FL0FBMAX(X_FETCHBURSTMAX_512B));
1215 c.fl0size = htobe16(fl->qsize);
1216 c.fl0addr = htobe64(fl->ba);
1217 }
1218
1219 rc = -t4_wr_mbox(sc, sc->mbox, &c, sizeof(c), &c);

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

1330 }
1331
1332 return (0);
1333}
1334
1335static int
1336alloc_iq(struct sge_iq *iq, int intr_idx)
1337{
1328 return alloc_iq_fl(NULL, iq, NULL, intr_idx);
1338 return alloc_iq_fl(NULL, iq, NULL, intr_idx, -1);
1329}
1330
1331static int
1332free_iq(struct sge_iq *iq)
1333{
1334 return free_iq_fl(NULL, iq, NULL);
1335}
1336
1337static int
1338alloc_rxq(struct port_info *pi, struct sge_rxq *rxq, int intr_idx, int idx)
1339{
1340 int rc;
1341 struct sysctl_oid *oid;
1342 struct sysctl_oid_list *children;
1343 char name[16];
1344
1339}
1340
1341static int
1342free_iq(struct sge_iq *iq)
1343{
1344 return free_iq_fl(NULL, iq, NULL);
1345}
1346
1347static int
1348alloc_rxq(struct port_info *pi, struct sge_rxq *rxq, int intr_idx, int idx)
1349{
1350 int rc;
1351 struct sysctl_oid *oid;
1352 struct sysctl_oid_list *children;
1353 char name[16];
1354
1345 rc = alloc_iq_fl(pi, &rxq->iq, &rxq->fl, intr_idx);
1355 rc = alloc_iq_fl(pi, &rxq->iq, &rxq->fl, intr_idx, 1 << pi->tx_chan);
1346 if (rc != 0)
1347 return (rc);
1348
1349#ifdef INET
1350 rc = tcp_lro_init(&rxq->lro);
1351 if (rc != 0)
1352 return (rc);
1353 rxq->lro.ifp = pi->ifp; /* also indicates LRO init'ed */

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

1431 F_FW_CMD_WRITE | F_FW_CMD_EXEC | V_FW_EQ_CTRL_CMD_PFN(sc->pf) |
1432 V_FW_EQ_CTRL_CMD_VFN(0));
1433 c.alloc_to_len16 = htobe32(F_FW_EQ_CTRL_CMD_ALLOC |
1434 F_FW_EQ_CTRL_CMD_EQSTART | FW_LEN16(c));
1435 c.cmpliqid_eqid = htonl(V_FW_EQ_CTRL_CMD_CMPLIQID(eq->iqid)); /* XXX */
1436 c.physeqid_pkd = htobe32(0);
1437 c.fetchszm_to_iqid =
1438 htobe32(V_FW_EQ_CTRL_CMD_HOSTFCMODE(X_HOSTFCMODE_STATUS_PAGE) |
1356 if (rc != 0)
1357 return (rc);
1358
1359#ifdef INET
1360 rc = tcp_lro_init(&rxq->lro);
1361 if (rc != 0)
1362 return (rc);
1363 rxq->lro.ifp = pi->ifp; /* also indicates LRO init'ed */

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

1441 F_FW_CMD_WRITE | F_FW_CMD_EXEC | V_FW_EQ_CTRL_CMD_PFN(sc->pf) |
1442 V_FW_EQ_CTRL_CMD_VFN(0));
1443 c.alloc_to_len16 = htobe32(F_FW_EQ_CTRL_CMD_ALLOC |
1444 F_FW_EQ_CTRL_CMD_EQSTART | FW_LEN16(c));
1445 c.cmpliqid_eqid = htonl(V_FW_EQ_CTRL_CMD_CMPLIQID(eq->iqid)); /* XXX */
1446 c.physeqid_pkd = htobe32(0);
1447 c.fetchszm_to_iqid =
1448 htobe32(V_FW_EQ_CTRL_CMD_HOSTFCMODE(X_HOSTFCMODE_STATUS_PAGE) |
1439 V_FW_EQ_CTRL_CMD_PCIECHN(idx) |
1449 V_FW_EQ_CTRL_CMD_PCIECHN(idx) | F_FW_EQ_CTRL_CMD_FETCHRO |
1440 V_FW_EQ_CTRL_CMD_IQID(eq->iqid));
1441 c.dcaen_to_eqsize =
1442 htobe32(V_FW_EQ_CTRL_CMD_FBMIN(X_FETCHBURSTMIN_64B) |
1443 V_FW_EQ_CTRL_CMD_FBMAX(X_FETCHBURSTMAX_512B) |
1444 V_FW_EQ_CTRL_CMD_CIDXFTHRESH(X_CIDXFLUSHTHRESH_32) |
1445 V_FW_EQ_CTRL_CMD_EQSIZE(eq->qsize));
1446 c.eqaddr = htobe64(eq->ba);
1447

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

1556 c.op_to_vfn = htobe32(V_FW_CMD_OP(FW_EQ_ETH_CMD) | F_FW_CMD_REQUEST |
1557 F_FW_CMD_WRITE | F_FW_CMD_EXEC | V_FW_EQ_ETH_CMD_PFN(sc->pf) |
1558 V_FW_EQ_ETH_CMD_VFN(0));
1559 c.alloc_to_len16 = htobe32(F_FW_EQ_ETH_CMD_ALLOC |
1560 F_FW_EQ_ETH_CMD_EQSTART | FW_LEN16(c));
1561 c.viid_pkd = htobe32(V_FW_EQ_ETH_CMD_VIID(pi->viid));
1562 c.fetchszm_to_iqid =
1563 htobe32(V_FW_EQ_ETH_CMD_HOSTFCMODE(X_HOSTFCMODE_STATUS_PAGE) |
1450 V_FW_EQ_CTRL_CMD_IQID(eq->iqid));
1451 c.dcaen_to_eqsize =
1452 htobe32(V_FW_EQ_CTRL_CMD_FBMIN(X_FETCHBURSTMIN_64B) |
1453 V_FW_EQ_CTRL_CMD_FBMAX(X_FETCHBURSTMAX_512B) |
1454 V_FW_EQ_CTRL_CMD_CIDXFTHRESH(X_CIDXFLUSHTHRESH_32) |
1455 V_FW_EQ_CTRL_CMD_EQSIZE(eq->qsize));
1456 c.eqaddr = htobe64(eq->ba);
1457

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

1566 c.op_to_vfn = htobe32(V_FW_CMD_OP(FW_EQ_ETH_CMD) | F_FW_CMD_REQUEST |
1567 F_FW_CMD_WRITE | F_FW_CMD_EXEC | V_FW_EQ_ETH_CMD_PFN(sc->pf) |
1568 V_FW_EQ_ETH_CMD_VFN(0));
1569 c.alloc_to_len16 = htobe32(F_FW_EQ_ETH_CMD_ALLOC |
1570 F_FW_EQ_ETH_CMD_EQSTART | FW_LEN16(c));
1571 c.viid_pkd = htobe32(V_FW_EQ_ETH_CMD_VIID(pi->viid));
1572 c.fetchszm_to_iqid =
1573 htobe32(V_FW_EQ_ETH_CMD_HOSTFCMODE(X_HOSTFCMODE_STATUS_PAGE) |
1564 V_FW_EQ_ETH_CMD_PCIECHN(pi->tx_chan) |
1574 V_FW_EQ_ETH_CMD_PCIECHN(pi->tx_chan) | F_FW_EQ_ETH_CMD_FETCHRO |
1565 V_FW_EQ_ETH_CMD_IQID(eq->iqid));
1566 c.dcaen_to_eqsize = htobe32(V_FW_EQ_ETH_CMD_FBMIN(X_FETCHBURSTMIN_64B) |
1567 V_FW_EQ_ETH_CMD_FBMAX(X_FETCHBURSTMAX_512B) |
1568 V_FW_EQ_ETH_CMD_CIDXFTHRESH(X_CIDXFLUSHTHRESH_32) |
1569 V_FW_EQ_ETH_CMD_EQSIZE(eq->qsize));
1570 c.eqaddr = htobe64(eq->ba);
1571
1572 rc = -t4_wr_mbox(sc, sc->mbox, &c, sizeof(c), &c);

--- 1176 unchanged lines hidden ---
1575 V_FW_EQ_ETH_CMD_IQID(eq->iqid));
1576 c.dcaen_to_eqsize = htobe32(V_FW_EQ_ETH_CMD_FBMIN(X_FETCHBURSTMIN_64B) |
1577 V_FW_EQ_ETH_CMD_FBMAX(X_FETCHBURSTMAX_512B) |
1578 V_FW_EQ_ETH_CMD_CIDXFTHRESH(X_CIDXFLUSHTHRESH_32) |
1579 V_FW_EQ_ETH_CMD_EQSIZE(eq->qsize));
1580 c.eqaddr = htobe64(eq->ba);
1581
1582 rc = -t4_wr_mbox(sc, sc->mbox, &c, sizeof(c), &c);

--- 1176 unchanged lines hidden ---