cxgb_sge.c (177464) | cxgb_sge.c (180583) |
---|---|
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 --- 16 unchanged lines hidden (view full) --- 25ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26POSSIBILITY OF SUCH DAMAGE. 27 28***************************************************************************/ 29#define DEBUG_BUFRING 30 31 32#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 --- 16 unchanged lines hidden (view full) --- 25ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26POSSIBILITY OF SUCH DAMAGE. 27 28***************************************************************************/ 29#define DEBUG_BUFRING 30 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/dev/cxgb/cxgb_sge.c 177464 2008-03-20 20:52:37Z kmacy $"); | 33__FBSDID("$FreeBSD: head/sys/dev/cxgb/cxgb_sge.c 180583 2008-07-18 06:12:31Z kmacy $"); |
34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/kernel.h> 38#include <sys/module.h> 39#include <sys/bus.h> 40#include <sys/conf.h> 41#include <machine/bus.h> --- 347 unchanged lines hidden (view full) --- 389 390 /* XXX Does ETHER_ALIGN need to be accounted for here? */ 391 p->max_pkt_size = adap->sge.qs[0].fl[1].buf_size - sizeof(struct cpl_rx_data); 392 393 for (i = 0; i < SGE_QSETS; ++i) { 394 struct qset_params *q = p->qset + i; 395 396 if (adap->params.nports > 2) { | 34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/kernel.h> 38#include <sys/module.h> 39#include <sys/bus.h> 40#include <sys/conf.h> 41#include <machine/bus.h> --- 347 unchanged lines hidden (view full) --- 389 390 /* XXX Does ETHER_ALIGN need to be accounted for here? */ 391 p->max_pkt_size = adap->sge.qs[0].fl[1].buf_size - sizeof(struct cpl_rx_data); 392 393 for (i = 0; i < SGE_QSETS; ++i) { 394 struct qset_params *q = p->qset + i; 395 396 if (adap->params.nports > 2) { |
397 q->coalesce_nsecs = 50000; | 397 q->coalesce_usecs = 50; |
398 } else { 399#ifdef INVARIANTS | 398 } else { 399#ifdef INVARIANTS |
400 q->coalesce_nsecs = 10000; | 400 q->coalesce_usecs = 10; |
401#else | 401#else |
402 q->coalesce_nsecs = 5000; | 402 q->coalesce_usecs = 5; |
403#endif 404 } 405 q->polling = adap->params.rev > 0; 406 q->rspq_size = RSPQ_Q_SIZE; 407 q->fl_size = fl_q_size; 408 q->jumbo_size = jumbo_q_size; 409 q->txq_size[TXQ_ETH] = TX_ETH_Q_SIZE; 410 q->txq_size[TXQ_OFLD] = 1024; --- 74 unchanged lines hidden (view full) --- 485 486 return (0); 487} 488 489void 490t3_update_qset_coalesce(struct sge_qset *qs, const struct qset_params *p) 491{ 492 | 403#endif 404 } 405 q->polling = adap->params.rev > 0; 406 q->rspq_size = RSPQ_Q_SIZE; 407 q->fl_size = fl_q_size; 408 q->jumbo_size = jumbo_q_size; 409 q->txq_size[TXQ_ETH] = TX_ETH_Q_SIZE; 410 q->txq_size[TXQ_OFLD] = 1024; --- 74 unchanged lines hidden (view full) --- 485 486 return (0); 487} 488 489void 490t3_update_qset_coalesce(struct sge_qset *qs, const struct qset_params *p) 491{ 492 |
493 qs->rspq.holdoff_tmr = max(p->coalesce_nsecs/100, 1U); | 493 qs->rspq.holdoff_tmr = max(p->coalesce_usecs * 10, 1U); |
494 qs->rspq.polling = 0 /* p->polling */; 495} 496 497#if !defined(__i386__) && !defined(__amd64__) 498static void 499refill_fl_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) 500{ 501 struct refill_fl_cb_arg *cb_arg = arg; --- 807 unchanged lines hidden (view full) --- 1309 txq_prod(txq, 1, &txqs); 1310 1311 for (fidx = 1, i = 0; i < count; i++, batchmi++, fidx += 2) { 1312 struct cpl_tx_pkt_batch_entry *cbe = &cpl_batch->pkt_entry[i]; 1313 1314 cntrl = V_TXPKT_INTF(pi->txpkt_intf); 1315 GET_VTAG_MI(cntrl, batchmi); 1316 cntrl |= V_TXPKT_OPCODE(CPL_TX_PKT); | 494 qs->rspq.polling = 0 /* p->polling */; 495} 496 497#if !defined(__i386__) && !defined(__amd64__) 498static void 499refill_fl_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) 500{ 501 struct refill_fl_cb_arg *cb_arg = arg; --- 807 unchanged lines hidden (view full) --- 1309 txq_prod(txq, 1, &txqs); 1310 1311 for (fidx = 1, i = 0; i < count; i++, batchmi++, fidx += 2) { 1312 struct cpl_tx_pkt_batch_entry *cbe = &cpl_batch->pkt_entry[i]; 1313 1314 cntrl = V_TXPKT_INTF(pi->txpkt_intf); 1315 GET_VTAG_MI(cntrl, batchmi); 1316 cntrl |= V_TXPKT_OPCODE(CPL_TX_PKT); |
1317 if (__predict_false(!(m0->m_pkthdr.csum_flags & CSUM_IP))) 1318 cntrl |= F_TXPKT_IPCSUM_DIS; 1319 if (__predict_false(!(m0->m_pkthdr.csum_flags & (CSUM_TCP | CSUM_UDP)))) 1320 cntrl |= F_TXPKT_L4CSUM_DIS; |
|
1317 cbe->cntrl = htonl(cntrl); 1318 cbe->len = htonl(batchmi->mi_len | 0x80000000); 1319 cbe->addr = htobe64(segs[i].ds_addr); 1320 txd->flit[fidx] |= htobe64(1 << 24); 1321 } 1322 1323 wrp->wr_hi = htonl(F_WR_SOP | F_WR_EOP | V_WR_DATATYPE(1) | 1324 V_WR_SGLSFLT(flits)) | htonl(V_WR_OP(FW_WROPCODE_TUNNEL_TX_PKT) | txqs.compl); --- 13 unchanged lines hidden (view full) --- 1338 char *pkthdr, tmp[TCPPKTHDRSIZE]; 1339 struct mbuf_vec *mv; 1340 struct mbuf_iovec *tmpmi; 1341 1342 mv = mtomv(m0); 1343 tmpmi = mv->mv_vec; 1344 1345 txd->flit[2] = 0; | 1321 cbe->cntrl = htonl(cntrl); 1322 cbe->len = htonl(batchmi->mi_len | 0x80000000); 1323 cbe->addr = htobe64(segs[i].ds_addr); 1324 txd->flit[fidx] |= htobe64(1 << 24); 1325 } 1326 1327 wrp->wr_hi = htonl(F_WR_SOP | F_WR_EOP | V_WR_DATATYPE(1) | 1328 V_WR_SGLSFLT(flits)) | htonl(V_WR_OP(FW_WROPCODE_TUNNEL_TX_PKT) | txqs.compl); --- 13 unchanged lines hidden (view full) --- 1342 char *pkthdr, tmp[TCPPKTHDRSIZE]; 1343 struct mbuf_vec *mv; 1344 struct mbuf_iovec *tmpmi; 1345 1346 mv = mtomv(m0); 1347 tmpmi = mv->mv_vec; 1348 1349 txd->flit[2] = 0; |
1346 GET_VTAG_MI(cntrl, mi); | 1350 GET_VTAG(cntrl, m0); |
1347 cntrl |= V_TXPKT_OPCODE(CPL_TX_PKT_LSO); 1348 hdr->cntrl = htonl(cntrl); 1349 mlen = m0->m_pkthdr.len; 1350 hdr->len = htonl(mlen | 0x80000000); 1351 1352 DPRINTF("tso buf len=%d\n", mlen); 1353 undersized = (((tmpmi->mi_len < TCPPKTHDRSIZE) && 1354 (m0->m_flags & M_VLANTAG)) || 1355 (tmpmi->mi_len < TCPPKTHDRSIZE - ETHER_VLAN_ENCAP_LEN)); 1356 1357 if (__predict_false(undersized)) { 1358 pkthdr = tmp; | 1351 cntrl |= V_TXPKT_OPCODE(CPL_TX_PKT_LSO); 1352 hdr->cntrl = htonl(cntrl); 1353 mlen = m0->m_pkthdr.len; 1354 hdr->len = htonl(mlen | 0x80000000); 1355 1356 DPRINTF("tso buf len=%d\n", mlen); 1357 undersized = (((tmpmi->mi_len < TCPPKTHDRSIZE) && 1358 (m0->m_flags & M_VLANTAG)) || 1359 (tmpmi->mi_len < TCPPKTHDRSIZE - ETHER_VLAN_ENCAP_LEN)); 1360 1361 if (__predict_false(undersized)) { 1362 pkthdr = tmp; |
1359 dump_mi(mi); | 1363 if (mi) 1364 dump_mi(mi); 1365 printf("mbuf=%p,len=%d,tso_segsz=%d,csum_flags=%#x,flags=%#x", 1366 m0, mlen, m0->m_pkthdr.tso_segsz, m0->m_pkthdr.csum_flags, m0->m_flags); |
1360 panic("discontig packet - fixxorz"); 1361 } else 1362 pkthdr = m0->m_data; 1363 1364 if (__predict_false(m0->m_flags & M_VLANTAG)) { 1365 eth_type = CPL_ETH_II_VLAN; 1366 ip = (struct ip *)(pkthdr + ETHER_HDR_LEN + 1367 ETHER_VLAN_ENCAP_LEN); 1368 } else { 1369 eth_type = CPL_ETH_II; 1370 ip = (struct ip *)(pkthdr + ETHER_HDR_LEN); 1371 } 1372 tcp = (struct tcphdr *)((uint8_t *)ip + 1373 sizeof(*ip)); 1374 1375 tso_info |= V_LSO_ETH_TYPE(eth_type) | 1376 V_LSO_IPHDR_WORDS(ip->ip_hl) | 1377 V_LSO_TCPHDR_WORDS(tcp->th_off); 1378 hdr->lso_info = htonl(tso_info); | 1367 panic("discontig packet - fixxorz"); 1368 } else 1369 pkthdr = m0->m_data; 1370 1371 if (__predict_false(m0->m_flags & M_VLANTAG)) { 1372 eth_type = CPL_ETH_II_VLAN; 1373 ip = (struct ip *)(pkthdr + ETHER_HDR_LEN + 1374 ETHER_VLAN_ENCAP_LEN); 1375 } else { 1376 eth_type = CPL_ETH_II; 1377 ip = (struct ip *)(pkthdr + ETHER_HDR_LEN); 1378 } 1379 tcp = (struct tcphdr *)((uint8_t *)ip + 1380 sizeof(*ip)); 1381 1382 tso_info |= V_LSO_ETH_TYPE(eth_type) | 1383 V_LSO_IPHDR_WORDS(ip->ip_hl) | 1384 V_LSO_TCPHDR_WORDS(tcp->th_off); 1385 hdr->lso_info = htonl(tso_info); |
1386 1387 if (__predict_false(mlen <= PIO_LEN)) { 1388 /* pkt not undersized but fits in PIO_LEN */ 1389 printf("**5592 Fix** mbuf=%p,len=%d,tso_segsz=%d,csum_flags=%#x,flags=%#x", 1390 m0, mlen, m0->m_pkthdr.tso_segsz, m0->m_pkthdr.csum_flags, m0->m_flags); 1391 txq_prod(txq, 1, &txqs); 1392 m_copydata(m0, 0, mlen, (caddr_t)&txd->flit[3]); 1393 m_freem(m0); 1394 m0 = NULL; 1395 flits = (mlen + 7) / 8 + 3; 1396 hdr->wr.wr_hi = htonl(V_WR_BCNTLFLT(mlen & 7) | 1397 V_WR_OP(FW_WROPCODE_TUNNEL_TX_PKT) | 1398 F_WR_SOP | F_WR_EOP | txqs.compl); 1399 wmb(); 1400 hdr->wr.wr_lo = htonl(V_WR_LEN(flits) | 1401 V_WR_GEN(txqs.gen) | V_WR_TID(txq->token)); 1402 1403 wr_gen2(txd, txqs.gen); 1404 check_ring_tx_db(sc, txq); 1405 return (0); 1406 } |
|
1379 flits = 3; 1380 } else { 1381 struct cpl_tx_pkt *cpl = (struct cpl_tx_pkt *)txd; 1382 1383 GET_VTAG(cntrl, m0); 1384 cntrl |= V_TXPKT_OPCODE(CPL_TX_PKT); | 1407 flits = 3; 1408 } else { 1409 struct cpl_tx_pkt *cpl = (struct cpl_tx_pkt *)txd; 1410 1411 GET_VTAG(cntrl, m0); 1412 cntrl |= V_TXPKT_OPCODE(CPL_TX_PKT); |
1413 if (__predict_false(!(m0->m_pkthdr.csum_flags & CSUM_IP))) 1414 cntrl |= F_TXPKT_IPCSUM_DIS; 1415 if (__predict_false(!(m0->m_pkthdr.csum_flags & (CSUM_TCP | CSUM_UDP)))) 1416 cntrl |= F_TXPKT_L4CSUM_DIS; |
|
1385 cpl->cntrl = htonl(cntrl); 1386 mlen = m0->m_pkthdr.len; 1387 cpl->len = htonl(mlen | 0x80000000); 1388 1389 if (mlen <= PIO_LEN) { 1390 txq_prod(txq, 1, &txqs); 1391 m_copydata(m0, 0, mlen, (caddr_t)&txd->flit[2]); 1392 m_freem(m0); --- 1826 unchanged lines hidden (view full) --- 3219 3220 for (i = 0; i < nqsets; i++) 3221 sc->sge.qs[i].lro.enabled = enabled; 3222 3223 return (0); 3224} 3225 3226static int | 1417 cpl->cntrl = htonl(cntrl); 1418 mlen = m0->m_pkthdr.len; 1419 cpl->len = htonl(mlen | 0x80000000); 1420 1421 if (mlen <= PIO_LEN) { 1422 txq_prod(txq, 1, &txqs); 1423 m_copydata(m0, 0, mlen, (caddr_t)&txd->flit[2]); 1424 m_freem(m0); --- 1826 unchanged lines hidden (view full) --- 3251 3252 for (i = 0; i < nqsets; i++) 3253 sc->sge.qs[i].lro.enabled = enabled; 3254 3255 return (0); 3256} 3257 3258static int |
3227t3_set_coalesce_nsecs(SYSCTL_HANDLER_ARGS) | 3259t3_set_coalesce_usecs(SYSCTL_HANDLER_ARGS) |
3228{ 3229 adapter_t *sc = arg1; 3230 struct qset_params *qsp = &sc->params.sge.qset[0]; | 3260{ 3261 adapter_t *sc = arg1; 3262 struct qset_params *qsp = &sc->params.sge.qset[0]; |
3231 int coalesce_nsecs; | 3263 int coalesce_usecs; |
3232 struct sge_qset *qs; 3233 int i, j, err, nqsets = 0; 3234 struct mtx *lock; 3235 3236 if ((sc->flags & FULL_INIT_DONE) == 0) 3237 return (ENXIO); 3238 | 3264 struct sge_qset *qs; 3265 int i, j, err, nqsets = 0; 3266 struct mtx *lock; 3267 3268 if ((sc->flags & FULL_INIT_DONE) == 0) 3269 return (ENXIO); 3270 |
3239 coalesce_nsecs = qsp->coalesce_nsecs; 3240 err = sysctl_handle_int(oidp, &coalesce_nsecs, arg2, req); | 3271 coalesce_usecs = qsp->coalesce_usecs; 3272 err = sysctl_handle_int(oidp, &coalesce_usecs, arg2, req); |
3241 3242 if (err != 0) { 3243 return (err); 3244 } | 3273 3274 if (err != 0) { 3275 return (err); 3276 } |
3245 if (coalesce_nsecs == qsp->coalesce_nsecs) | 3277 if (coalesce_usecs == qsp->coalesce_usecs) |
3246 return (0); 3247 3248 for (i = 0; i < sc->params.nports; i++) 3249 for (j = 0; j < sc->port[i].nqsets; j++) 3250 nqsets++; 3251 | 3278 return (0); 3279 3280 for (i = 0; i < sc->params.nports; i++) 3281 for (j = 0; j < sc->port[i].nqsets; j++) 3282 nqsets++; 3283 |
3252 coalesce_nsecs = max(100, coalesce_nsecs); | 3284 coalesce_usecs = max(1, coalesce_usecs); |
3253 3254 for (i = 0; i < nqsets; i++) { 3255 qs = &sc->sge.qs[i]; 3256 qsp = &sc->params.sge.qset[i]; | 3285 3286 for (i = 0; i < nqsets; i++) { 3287 qs = &sc->sge.qs[i]; 3288 qsp = &sc->params.sge.qset[i]; |
3257 qsp->coalesce_nsecs = coalesce_nsecs; | 3289 qsp->coalesce_usecs = coalesce_usecs; |
3258 3259 lock = (sc->flags & USING_MSIX) ? &qs->rspq.lock : 3260 &sc->sge.qs[0].rspq.lock; 3261 3262 mtx_lock(lock); 3263 t3_update_qset_coalesce(qs, qsp); 3264 t3_write_reg(sc, A_SG_GTS, V_RSPQ(qs->rspq.cntxt_id) | 3265 V_NEWTIMER(qs->rspq.holdoff_tmr)); --- 86 unchanged lines hidden (view full) --- 3352 int i, j; 3353 3354 ctx = device_get_sysctl_ctx(sc->dev); 3355 children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)); 3356 3357 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, 3358 "intr_coal", 3359 CTLTYPE_INT|CTLFLAG_RW, sc, | 3290 3291 lock = (sc->flags & USING_MSIX) ? &qs->rspq.lock : 3292 &sc->sge.qs[0].rspq.lock; 3293 3294 mtx_lock(lock); 3295 t3_update_qset_coalesce(qs, qsp); 3296 t3_write_reg(sc, A_SG_GTS, V_RSPQ(qs->rspq.cntxt_id) | 3297 V_NEWTIMER(qs->rspq.holdoff_tmr)); --- 86 unchanged lines hidden (view full) --- 3384 int i, j; 3385 3386 ctx = device_get_sysctl_ctx(sc->dev); 3387 children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)); 3388 3389 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, 3390 "intr_coal", 3391 CTLTYPE_INT|CTLFLAG_RW, sc, |
3360 0, t3_set_coalesce_nsecs, 3361 "I", "interrupt coalescing timer (ns)"); | 3392 0, t3_set_coalesce_usecs, 3393 "I", "interrupt coalescing timer (us)"); |
3362 3363 for (i = 0; i < sc->params.nports; i++) { 3364 struct port_info *pi = &sc->port[i]; 3365 struct sysctl_oid *poid; 3366 struct sysctl_oid_list *poidlist; 3367 3368 snprintf(pi->namebuf, PORT_NAME_LEN, "port%d", i); 3369 poid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, --- 166 unchanged lines hidden --- | 3394 3395 for (i = 0; i < sc->params.nports; i++) { 3396 struct port_info *pi = &sc->port[i]; 3397 struct sysctl_oid *poid; 3398 struct sysctl_oid_list *poidlist; 3399 3400 snprintf(pi->namebuf, PORT_NAME_LEN, "port%d", i); 3401 poid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, --- 166 unchanged lines hidden --- |