qlnx_os.c (317118) | qlnx_os.c (318657) |
---|---|
1/* 2 * Copyright (c) 2017-2018 Cavium, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 18 unchanged lines hidden (view full) --- 27 28 29/* 30 * File: qlnx_os.c 31 * Author : David C Somayajulu, Cavium, Inc., San Jose, CA 95131. 32 */ 33 34#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2017-2018 Cavium, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 18 unchanged lines hidden (view full) --- 27 28 29/* 30 * File: qlnx_os.c 31 * Author : David C Somayajulu, Cavium, Inc., San Jose, CA 95131. 32 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c 317118 2017-04-19 03:18:11Z davidcs $"); | 35__FBSDID("$FreeBSD: stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c 318657 2017-05-22 19:22:06Z davidcs $"); |
36 37#include "qlnx_os.h" 38#include "bcm_osal.h" 39#include "reg_addr.h" 40#include "ecore_gtt_reg_addr.h" 41#include "ecore.h" 42#include "ecore_chain.h" 43#include "ecore_status.h" --- 333 unchanged lines hidden (view full) --- 377static void 378qlnx_fp_taskqueue(void *context, int pending) 379{ 380 struct qlnx_fastpath *fp; 381 qlnx_host_t *ha; 382 struct ifnet *ifp; 383 struct mbuf *mp; 384 int ret; | 36 37#include "qlnx_os.h" 38#include "bcm_osal.h" 39#include "reg_addr.h" 40#include "ecore_gtt_reg_addr.h" 41#include "ecore.h" 42#include "ecore_chain.h" 43#include "ecore_status.h" --- 333 unchanged lines hidden (view full) --- 377static void 378qlnx_fp_taskqueue(void *context, int pending) 379{ 380 struct qlnx_fastpath *fp; 381 qlnx_host_t *ha; 382 struct ifnet *ifp; 383 struct mbuf *mp; 384 int ret; |
385 int lro_enable, tc; 386 int rx_int = 0, total_rx_count = 0; 387 struct thread *cthread; |
|
385 386 fp = context; 387 388 if (fp == NULL) 389 return; 390 | 388 389 fp = context; 390 391 if (fp == NULL) 392 return; 393 |
394 cthread = curthread; 395 396 thread_lock(cthread); 397 398 if (!sched_is_bound(cthread)) 399 sched_bind(cthread, fp->rss_id); 400 401 thread_unlock(cthread); 402 |
|
391 ha = (qlnx_host_t *)fp->edev; 392 393 ifp = ha->ifp; 394 | 403 ha = (qlnx_host_t *)fp->edev; 404 405 ifp = ha->ifp; 406 |
407 lro_enable = ha->ifp->if_capenable & IFCAP_LRO; 408 409 rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, lro_enable); 410 411 if (rx_int) { 412 fp->rx_pkts += rx_int; 413 total_rx_count += rx_int; 414 } 415 416#ifdef QLNX_SOFT_LRO 417 { 418 struct lro_ctrl *lro; 419 420 lro = &fp->rxq->lro; 421 422 if (lro_enable && total_rx_count) { 423 424#if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) 425 426 if (ha->dbg_trace_lro_cnt) { 427 if (lro->lro_mbuf_count & ~1023) 428 fp->lro_cnt_1024++; 429 else if (lro->lro_mbuf_count & ~511) 430 fp->lro_cnt_512++; 431 else if (lro->lro_mbuf_count & ~255) 432 fp->lro_cnt_256++; 433 else if (lro->lro_mbuf_count & ~127) 434 fp->lro_cnt_128++; 435 else if (lro->lro_mbuf_count & ~63) 436 fp->lro_cnt_64++; 437 } 438 tcp_lro_flush_all(lro); 439 440#else 441 struct lro_entry *queued; 442 443 while ((!SLIST_EMPTY(&lro->lro_active))) { 444 queued = SLIST_FIRST(&lro->lro_active); 445 SLIST_REMOVE_HEAD(&lro->lro_active, next); 446 tcp_lro_flush(lro, queued); 447 } 448#endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */ 449 } 450 } 451#endif /* #ifdef QLNX_SOFT_LRO */ 452 453 ecore_sb_update_sb_idx(fp->sb_info); 454 rmb(); 455 |
|
395 mtx_lock(&fp->tx_mtx); 396 397 if (((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != 398 IFF_DRV_RUNNING) || (!ha->link_up)) { 399 400 mtx_unlock(&fp->tx_mtx); 401 goto qlnx_fp_taskqueue_exit; 402 } 403 | 456 mtx_lock(&fp->tx_mtx); 457 458 if (((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != 459 IFF_DRV_RUNNING) || (!ha->link_up)) { 460 461 mtx_unlock(&fp->tx_mtx); 462 goto qlnx_fp_taskqueue_exit; 463 } 464 |
404 (void)qlnx_tx_int(ha, fp, fp->txq[0]); | 465 for (tc = 0; tc < ha->num_tc; tc++) { 466 (void)qlnx_tx_int(ha, fp, fp->txq[tc]); 467 } |
405 406 mp = drbr_peek(ifp, fp->tx_br); 407 408 while (mp != NULL) { 409 | 468 469 mp = drbr_peek(ifp, fp->tx_br); 470 471 while (mp != NULL) { 472 |
410 ret = qlnx_send(ha, fp, &mp); | 473 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { 474 ret = qlnx_send(ha, fp, &mp); 475 } else { 476 ret = -1; 477 } |
411 412 if (ret) { 413 414 if (mp != NULL) { 415 drbr_putback(ifp, fp->tx_br, mp); 416 } else { 417 fp->tx_pkts_processed++; 418 drbr_advance(ifp, fp->tx_br); --- 4 unchanged lines hidden (view full) --- 423 goto qlnx_fp_taskqueue_exit; 424 425 } else { 426 drbr_advance(ifp, fp->tx_br); 427 fp->tx_pkts_transmitted++; 428 fp->tx_pkts_processed++; 429 } 430 | 478 479 if (ret) { 480 481 if (mp != NULL) { 482 drbr_putback(ifp, fp->tx_br, mp); 483 } else { 484 fp->tx_pkts_processed++; 485 drbr_advance(ifp, fp->tx_br); --- 4 unchanged lines hidden (view full) --- 490 goto qlnx_fp_taskqueue_exit; 491 492 } else { 493 drbr_advance(ifp, fp->tx_br); 494 fp->tx_pkts_transmitted++; 495 fp->tx_pkts_processed++; 496 } 497 |
498 if (fp->tx_ring_full) 499 break; 500 |
|
431 mp = drbr_peek(ifp, fp->tx_br); 432 } 433 | 501 mp = drbr_peek(ifp, fp->tx_br); 502 } 503 |
434 (void)qlnx_tx_int(ha, fp, fp->txq[0]); | 504 for (tc = 0; tc < ha->num_tc; tc++) { 505 (void)qlnx_tx_int(ha, fp, fp->txq[tc]); 506 } |
435 436 mtx_unlock(&fp->tx_mtx); 437 438qlnx_fp_taskqueue_exit: | 507 508 mtx_unlock(&fp->tx_mtx); 509 510qlnx_fp_taskqueue_exit: |
511 if (rx_int) { 512 if (fp->fp_taskqueue != NULL) 513 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); 514 } else { 515 if (fp->tx_ring_full) { 516 qlnx_mdelay(__func__, 100); 517 } 518 ecore_sb_ack(fp->sb_info, IGU_INT_ENABLE, 1); 519 } |
|
439 440 QL_DPRINT2(ha, (ha->pci_dev, "%s: exit ret = %d\n", __func__, ret)); 441 return; 442} 443 444static int 445qlnx_create_fp_taskqueues(qlnx_host_t *ha) 446{ --- 52 unchanged lines hidden (view full) --- 499{ 500 int i; 501 struct qlnx_fastpath *fp; 502 503 for (i = 0; i < ha->num_rss; i++) { 504 fp = &ha->fp_array[i]; 505 506 if (fp->fp_taskqueue != NULL) { | 520 521 QL_DPRINT2(ha, (ha->pci_dev, "%s: exit ret = %d\n", __func__, ret)); 522 return; 523} 524 525static int 526qlnx_create_fp_taskqueues(qlnx_host_t *ha) 527{ --- 52 unchanged lines hidden (view full) --- 580{ 581 int i; 582 struct qlnx_fastpath *fp; 583 584 for (i = 0; i < ha->num_rss; i++) { 585 fp = &ha->fp_array[i]; 586 587 if (fp->fp_taskqueue != NULL) { |
588 QLNX_UNLOCK(ha); |
|
507 taskqueue_drain(fp->fp_taskqueue, &fp->fp_task); | 589 taskqueue_drain(fp->fp_taskqueue, &fp->fp_task); |
590 QLNX_LOCK(ha); |
|
508 } 509 } 510 return; 511} 512 513/* 514 * Name: qlnx_pci_attach 515 * Function: attaches the device to the operating system --- 19 unchanged lines hidden (view full) --- 535 device_printf(dev, "device is not valid device\n"); 536 return (ENXIO); 537 } 538 ha->pci_func = pci_get_function(dev); 539 540 ha->pci_dev = dev; 541 542 mtx_init(&ha->hw_lock, "qlnx_hw_lock", MTX_NETWORK_LOCK, MTX_DEF); | 591 } 592 } 593 return; 594} 595 596/* 597 * Name: qlnx_pci_attach 598 * Function: attaches the device to the operating system --- 19 unchanged lines hidden (view full) --- 618 device_printf(dev, "device is not valid device\n"); 619 return (ENXIO); 620 } 621 ha->pci_func = pci_get_function(dev); 622 623 ha->pci_dev = dev; 624 625 mtx_init(&ha->hw_lock, "qlnx_hw_lock", MTX_NETWORK_LOCK, MTX_DEF); |
543 mtx_init(&ha->tx_lock, "qlnx_tx_lock", MTX_NETWORK_LOCK, MTX_DEF); | |
544 545 ha->flags.lock_init = 1; 546 547 pci_enable_busmaster(dev); 548 549 /* 550 * map the PCI BARs 551 */ --- 387 unchanged lines hidden (view full) --- 939 } 940 941 qlnx_destroy_sp_taskqueues(ha); 942 943 if (ha->msix_count) 944 pci_release_msi(dev); 945 946 if (ha->flags.lock_init) { | 626 627 ha->flags.lock_init = 1; 628 629 pci_enable_busmaster(dev); 630 631 /* 632 * map the PCI BARs 633 */ --- 387 unchanged lines hidden (view full) --- 1021 } 1022 1023 qlnx_destroy_sp_taskqueues(ha); 1024 1025 if (ha->msix_count) 1026 pci_release_msi(dev); 1027 1028 if (ha->flags.lock_init) { |
947 mtx_destroy(&ha->tx_lock); | |
948 mtx_destroy(&ha->hw_lock); 949 } 950 951 if (ha->pci_reg) 952 (void) bus_release_resource(dev, SYS_RES_MEMORY, ha->reg_rid, 953 ha->pci_reg); 954 955 if (ha->pci_dbells) --- 265 unchanged lines hidden (view full) --- 1221 CTLFLAG_RD, &ha->fp_array[i].err_tx_free_pkt_null, 1222 "err_tx_free_pkt_null"); 1223 1224 SYSCTL_ADD_QUAD(ctx, node_children, 1225 OID_AUTO, "err_tx_cons_idx_conflict", 1226 CTLFLAG_RD, &ha->fp_array[i].err_tx_cons_idx_conflict, 1227 "err_tx_cons_idx_conflict"); 1228 | 1029 mtx_destroy(&ha->hw_lock); 1030 } 1031 1032 if (ha->pci_reg) 1033 (void) bus_release_resource(dev, SYS_RES_MEMORY, ha->reg_rid, 1034 ha->pci_reg); 1035 1036 if (ha->pci_dbells) --- 265 unchanged lines hidden (view full) --- 1302 CTLFLAG_RD, &ha->fp_array[i].err_tx_free_pkt_null, 1303 "err_tx_free_pkt_null"); 1304 1305 SYSCTL_ADD_QUAD(ctx, node_children, 1306 OID_AUTO, "err_tx_cons_idx_conflict", 1307 CTLFLAG_RD, &ha->fp_array[i].err_tx_cons_idx_conflict, 1308 "err_tx_cons_idx_conflict"); 1309 |
1229#ifdef QLNX_TRACE_LRO_CNT | |
1230 SYSCTL_ADD_QUAD(ctx, node_children, 1231 OID_AUTO, "lro_cnt_64", 1232 CTLFLAG_RD, &ha->fp_array[i].lro_cnt_64, 1233 "lro_cnt_64"); 1234 1235 SYSCTL_ADD_QUAD(ctx, node_children, 1236 OID_AUTO, "lro_cnt_128", 1237 CTLFLAG_RD, &ha->fp_array[i].lro_cnt_128, --- 8 unchanged lines hidden (view full) --- 1246 OID_AUTO, "lro_cnt_512", 1247 CTLFLAG_RD, &ha->fp_array[i].lro_cnt_512, 1248 "lro_cnt_512"); 1249 1250 SYSCTL_ADD_QUAD(ctx, node_children, 1251 OID_AUTO, "lro_cnt_1024", 1252 CTLFLAG_RD, &ha->fp_array[i].lro_cnt_1024, 1253 "lro_cnt_1024"); | 1310 SYSCTL_ADD_QUAD(ctx, node_children, 1311 OID_AUTO, "lro_cnt_64", 1312 CTLFLAG_RD, &ha->fp_array[i].lro_cnt_64, 1313 "lro_cnt_64"); 1314 1315 SYSCTL_ADD_QUAD(ctx, node_children, 1316 OID_AUTO, "lro_cnt_128", 1317 CTLFLAG_RD, &ha->fp_array[i].lro_cnt_128, --- 8 unchanged lines hidden (view full) --- 1326 OID_AUTO, "lro_cnt_512", 1327 CTLFLAG_RD, &ha->fp_array[i].lro_cnt_512, 1328 "lro_cnt_512"); 1329 1330 SYSCTL_ADD_QUAD(ctx, node_children, 1331 OID_AUTO, "lro_cnt_1024", 1332 CTLFLAG_RD, &ha->fp_array[i].lro_cnt_1024, 1333 "lro_cnt_1024"); |
1254#endif /* #ifdef QLNX_TRACE_LRO_CNT */ | |
1255 1256 /* Rx Related */ 1257 1258 SYSCTL_ADD_QUAD(ctx, node_children, 1259 OID_AUTO, "rx_pkts", 1260 CTLFLAG_RD, &ha->fp_array[i].rx_pkts, 1261 "No. of received packets"); 1262 --- 442 unchanged lines hidden (view full) --- 1705 OID_AUTO, "debug", CTLFLAG_RW, 1706 &ha->dbg_level, ha->dbg_level, "Debug Level"); 1707 1708 ha->dp_level = 0; 1709 SYSCTL_ADD_UINT(ctx, children, 1710 OID_AUTO, "dp_level", CTLFLAG_RW, 1711 &ha->dp_level, ha->dp_level, "DP Level"); 1712 | 1334 1335 /* Rx Related */ 1336 1337 SYSCTL_ADD_QUAD(ctx, node_children, 1338 OID_AUTO, "rx_pkts", 1339 CTLFLAG_RD, &ha->fp_array[i].rx_pkts, 1340 "No. of received packets"); 1341 --- 442 unchanged lines hidden (view full) --- 1784 OID_AUTO, "debug", CTLFLAG_RW, 1785 &ha->dbg_level, ha->dbg_level, "Debug Level"); 1786 1787 ha->dp_level = 0; 1788 SYSCTL_ADD_UINT(ctx, children, 1789 OID_AUTO, "dp_level", CTLFLAG_RW, 1790 &ha->dp_level, ha->dp_level, "DP Level"); 1791 |
1792 ha->dbg_trace_lro_cnt = 0; 1793 SYSCTL_ADD_UINT(ctx, children, 1794 OID_AUTO, "dbg_trace_lro_cnt", CTLFLAG_RW, 1795 &ha->dbg_trace_lro_cnt, ha->dbg_trace_lro_cnt, 1796 "Trace LRO Counts"); 1797 1798 ha->dbg_trace_tso_pkt_len = 0; 1799 SYSCTL_ADD_UINT(ctx, children, 1800 OID_AUTO, "dbg_trace_tso_pkt_len", CTLFLAG_RW, 1801 &ha->dbg_trace_tso_pkt_len, ha->dbg_trace_tso_pkt_len, 1802 "Trace TSO packet lengths"); 1803 |
|
1713 ha->dp_module = 0; 1714 SYSCTL_ADD_UINT(ctx, children, 1715 OID_AUTO, "dp_module", CTLFLAG_RW, 1716 &ha->dp_module, ha->dp_module, "DP Module"); 1717 1718 ha->err_inject = 0; 1719 1720 SYSCTL_ADD_UINT(ctx, children, --- 29 unchanged lines hidden (view full) --- 1750 &ha->rx_coalesce_usecs, ha->rx_coalesce_usecs, 1751 "rx_coalesce_usecs"); 1752 1753 SYSCTL_ADD_UINT(ctx, children, 1754 OID_AUTO, "tx_coalesce_usecs", CTLFLAG_RD, 1755 &ha->tx_coalesce_usecs, ha->tx_coalesce_usecs, 1756 "tx_coalesce_usecs"); 1757 | 1804 ha->dp_module = 0; 1805 SYSCTL_ADD_UINT(ctx, children, 1806 OID_AUTO, "dp_module", CTLFLAG_RW, 1807 &ha->dp_module, ha->dp_module, "DP Module"); 1808 1809 ha->err_inject = 0; 1810 1811 SYSCTL_ADD_UINT(ctx, children, --- 29 unchanged lines hidden (view full) --- 1841 &ha->rx_coalesce_usecs, ha->rx_coalesce_usecs, 1842 "rx_coalesce_usecs"); 1843 1844 SYSCTL_ADD_UINT(ctx, children, 1845 OID_AUTO, "tx_coalesce_usecs", CTLFLAG_RD, 1846 &ha->tx_coalesce_usecs, ha->tx_coalesce_usecs, 1847 "tx_coalesce_usecs"); 1848 |
1758 ha->rx_pkt_threshold = 32; | 1849 ha->rx_pkt_threshold = 128; |
1759 SYSCTL_ADD_UINT(ctx, children, 1760 OID_AUTO, "rx_pkt_threshold", CTLFLAG_RW, 1761 &ha->rx_pkt_threshold, ha->rx_pkt_threshold, 1762 "No. of Rx Pkts to process at a time"); 1763 1764 ha->rx_jumbo_buf_eq_mtu = 0; 1765 SYSCTL_ADD_UINT(ctx, children, 1766 OID_AUTO, "rx_jumbo_buf_eq_mtu", CTLFLAG_RW, --- 390 unchanged lines hidden (view full) --- 2157 2158 if (ifr->ifr_mtu > QLNX_MAX_MTU) { 2159 ret = EINVAL; 2160 } else { 2161 QLNX_LOCK(ha); 2162 ifp->if_mtu = ifr->ifr_mtu; 2163 ha->max_frame_size = 2164 ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; | 1850 SYSCTL_ADD_UINT(ctx, children, 1851 OID_AUTO, "rx_pkt_threshold", CTLFLAG_RW, 1852 &ha->rx_pkt_threshold, ha->rx_pkt_threshold, 1853 "No. of Rx Pkts to process at a time"); 1854 1855 ha->rx_jumbo_buf_eq_mtu = 0; 1856 SYSCTL_ADD_UINT(ctx, children, 1857 OID_AUTO, "rx_jumbo_buf_eq_mtu", CTLFLAG_RW, --- 390 unchanged lines hidden (view full) --- 2248 2249 if (ifr->ifr_mtu > QLNX_MAX_MTU) { 2250 ret = EINVAL; 2251 } else { 2252 QLNX_LOCK(ha); 2253 ifp->if_mtu = ifr->ifr_mtu; 2254 ha->max_frame_size = 2255 ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; |
2165 if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) { | 2256 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { |
2166 qlnx_init_locked(ha); 2167 } 2168 2169 QLNX_UNLOCK(ha); 2170 } 2171 2172 break; 2173 2174 case SIOCSIFFLAGS: 2175 QL_DPRINT4(ha, (ha->pci_dev, "%s: SIOCSIFFLAGS (0x%lx)\n", 2176 __func__, cmd)); 2177 2178 QLNX_LOCK(ha); 2179 2180 if (ifp->if_flags & IFF_UP) { | 2257 qlnx_init_locked(ha); 2258 } 2259 2260 QLNX_UNLOCK(ha); 2261 } 2262 2263 break; 2264 2265 case SIOCSIFFLAGS: 2266 QL_DPRINT4(ha, (ha->pci_dev, "%s: SIOCSIFFLAGS (0x%lx)\n", 2267 __func__, cmd)); 2268 2269 QLNX_LOCK(ha); 2270 2271 if (ifp->if_flags & IFF_UP) { |
2181 if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) { | 2272 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { |
2182 if ((ifp->if_flags ^ ha->if_flags) & 2183 IFF_PROMISC) { 2184 ret = qlnx_set_promisc(ha); 2185 } else if ((ifp->if_flags ^ ha->if_flags) & 2186 IFF_ALLMULTI) { 2187 ret = qlnx_set_allmulti(ha); 2188 } 2189 } else { --- 517 unchanged lines hidden (view full) --- 2707 return (-1); 2708 2709 first_bd = NULL; 2710 second_bd = NULL; 2711 third_bd = NULL; 2712 tx_data_bd = NULL; 2713 2714 txq = fp->txq[0]; | 2273 if ((ifp->if_flags ^ ha->if_flags) & 2274 IFF_PROMISC) { 2275 ret = qlnx_set_promisc(ha); 2276 } else if ((ifp->if_flags ^ ha->if_flags) & 2277 IFF_ALLMULTI) { 2278 ret = qlnx_set_allmulti(ha); 2279 } 2280 } else { --- 517 unchanged lines hidden (view full) --- 2798 return (-1); 2799 2800 first_bd = NULL; 2801 second_bd = NULL; 2802 third_bd = NULL; 2803 tx_data_bd = NULL; 2804 2805 txq = fp->txq[0]; |
2806 2807 if (fp->tx_ring_full) { 2808 elem_left = ecore_chain_get_elem_left(&txq->tx_pbl); 2809 2810 if (elem_left < (TX_RING_SIZE >> 4)) 2811 return (-1); 2812 else 2813 fp->tx_ring_full = 0; 2814 } 2815 |
|
2715 idx = txq->sw_tx_prod; 2716 2717 map = txq->sw_tx_ring[idx].map; 2718 segs = txq->segs; 2719 2720 ret = bus_dmamap_load_mbuf_sg(ha->tx_tag, map, m_head, segs, &nsegs, 2721 BUS_DMA_NOWAIT); 2722 | 2816 idx = txq->sw_tx_prod; 2817 2818 map = txq->sw_tx_ring[idx].map; 2819 segs = txq->segs; 2820 2821 ret = bus_dmamap_load_mbuf_sg(ha->tx_tag, map, m_head, segs, &nsegs, 2822 BUS_DMA_NOWAIT); 2823 |
2723#ifdef QLNX_TRACE_TSO_PKT_LEN 2724 2725 if (!fp->tx_tso_min_pkt_len) { 2726 fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len; 2727 fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len; 2728 } else { 2729 if (fp->tx_tso_min_pkt_len > m_head->m_pkthdr.len) | 2824 if (ha->dbg_trace_tso_pkt_len) { 2825 if (!fp->tx_tso_min_pkt_len) { |
2730 fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len; | 2826 fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len; |
2731 if (fp->tx_tso_max_pkt_len < m_head->m_pkthdr.len) 2732 fp->tx_tso_max_pkt_len = m_head->m_pkthdr.len; | 2827 fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len; 2828 } else { 2829 if (fp->tx_tso_min_pkt_len > m_head->m_pkthdr.len) 2830 fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len; 2831 if (fp->tx_tso_max_pkt_len < m_head->m_pkthdr.len) 2832 fp->tx_tso_max_pkt_len = m_head->m_pkthdr.len; 2833 } |
2733 } 2734 | 2834 } 2835 |
2735#endif /* #ifdef QLNX_TRACE_TSO_PKT_LEN */ 2736 | |
2737 if (m_head->m_pkthdr.csum_flags & CSUM_TSO) 2738 offset = qlnx_tcp_offset(ha, m_head); 2739 2740 if ((ret == EFBIG) || 2741 ((nsegs > QLNX_MAX_SEGMENTS_NON_TSO) && ( 2742 (!(m_head->m_pkthdr.csum_flags & CSUM_TSO)) || 2743 ((m_head->m_pkthdr.csum_flags & CSUM_TSO) && 2744 qlnx_tso_check(fp, segs, nsegs, offset))))) { --- 65 unchanged lines hidden (view full) --- 2810 fp->tx_pkts_freed++; 2811 m_freem(m_head); 2812 *m_headp = NULL; 2813 return (ret); 2814 } 2815 2816 QL_ASSERT(ha, (nsegs != 0), ("qlnx_send: empty packet")); 2817 | 2836 if (m_head->m_pkthdr.csum_flags & CSUM_TSO) 2837 offset = qlnx_tcp_offset(ha, m_head); 2838 2839 if ((ret == EFBIG) || 2840 ((nsegs > QLNX_MAX_SEGMENTS_NON_TSO) && ( 2841 (!(m_head->m_pkthdr.csum_flags & CSUM_TSO)) || 2842 ((m_head->m_pkthdr.csum_flags & CSUM_TSO) && 2843 qlnx_tso_check(fp, segs, nsegs, offset))))) { --- 65 unchanged lines hidden (view full) --- 2909 fp->tx_pkts_freed++; 2910 m_freem(m_head); 2911 *m_headp = NULL; 2912 return (ret); 2913 } 2914 2915 QL_ASSERT(ha, (nsegs != 0), ("qlnx_send: empty packet")); 2916 |
2818#ifdef QLNX_TRACE_TSO_PKT_LEN | 2917 if (ha->dbg_trace_tso_pkt_len) { 2918 if (nsegs < QLNX_FP_MAX_SEGS) 2919 fp->tx_pkts[(nsegs - 1)]++; 2920 else 2921 fp->tx_pkts[(QLNX_FP_MAX_SEGS - 1)]++; 2922 } |
2819 | 2923 |
2820 if (nsegs < QLNX_FP_MAX_SEGS) 2821 fp->tx_pkts[(nsegs - 1)]++; 2822 else 2823 fp->tx_pkts[(QLNX_FP_MAX_SEGS - 1)]++; 2824 2825#endif /* #ifdef QLNX_TRACE_TSO_PKT_LEN */ 2826 | |
2827 if ((nsegs + QLNX_TX_ELEM_RESERVE) > 2828 (int)(elem_left = ecore_chain_get_elem_left(&txq->tx_pbl))) { 2829 2830 QL_DPRINT1(ha, (ha->pci_dev, "%s: (%d, 0x%x) insuffient BDs" 2831 "in chain[%d] trying to free packets\n", 2832 __func__, nsegs, elem_left, fp->rss_id)); 2833 2834 fp->tx_nsegs_gt_elem_left++; 2835 2836 (void)qlnx_tx_int(ha, fp, txq); 2837 2838 if ((nsegs + QLNX_TX_ELEM_RESERVE) > (int)(elem_left = 2839 ecore_chain_get_elem_left(&txq->tx_pbl))) { 2840 2841 QL_DPRINT1(ha, (ha->pci_dev, 2842 "%s: (%d, 0x%x) insuffient BDs in chain[%d]\n", 2843 __func__, nsegs, elem_left, fp->rss_id)); 2844 2845 fp->err_tx_nsegs_gt_elem_left++; | 2924 if ((nsegs + QLNX_TX_ELEM_RESERVE) > 2925 (int)(elem_left = ecore_chain_get_elem_left(&txq->tx_pbl))) { 2926 2927 QL_DPRINT1(ha, (ha->pci_dev, "%s: (%d, 0x%x) insuffient BDs" 2928 "in chain[%d] trying to free packets\n", 2929 __func__, nsegs, elem_left, fp->rss_id)); 2930 2931 fp->tx_nsegs_gt_elem_left++; 2932 2933 (void)qlnx_tx_int(ha, fp, txq); 2934 2935 if ((nsegs + QLNX_TX_ELEM_RESERVE) > (int)(elem_left = 2936 ecore_chain_get_elem_left(&txq->tx_pbl))) { 2937 2938 QL_DPRINT1(ha, (ha->pci_dev, 2939 "%s: (%d, 0x%x) insuffient BDs in chain[%d]\n", 2940 __func__, nsegs, elem_left, fp->rss_id)); 2941 2942 fp->err_tx_nsegs_gt_elem_left++; |
2943 fp->tx_ring_full = 1; |
|
2846 ha->storm_stats_enable = 1; 2847 return (ENOBUFS); 2848 } 2849 } 2850 2851 bus_dmamap_sync(ha->tx_tag, map, BUS_DMASYNC_PREWRITE); 2852 2853 txq->sw_tx_ring[idx].mp = m_head; --- 192 unchanged lines hidden (view full) --- 3046 << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT; 3047 first_bd->data.bitfields = 3048 htole16(first_bd->data.bitfields); 3049 } 3050 3051 3052 first_bd->data.nbds = nbd; 3053 | 2944 ha->storm_stats_enable = 1; 2945 return (ENOBUFS); 2946 } 2947 } 2948 2949 bus_dmamap_sync(ha->tx_tag, map, BUS_DMASYNC_PREWRITE); 2950 2951 txq->sw_tx_ring[idx].mp = m_head; --- 192 unchanged lines hidden (view full) --- 3144 << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT; 3145 first_bd->data.bitfields = 3146 htole16(first_bd->data.bitfields); 3147 } 3148 3149 3150 first_bd->data.nbds = nbd; 3151 |
3054#ifdef QLNX_TRACE_TSO_PKT_LEN | 3152 if (ha->dbg_trace_tso_pkt_len) { 3153 if (fp->tx_tso_max_nsegs < nsegs) 3154 fp->tx_tso_max_nsegs = nsegs; |
3055 | 3155 |
3056 if (fp->tx_tso_max_nsegs < nsegs) 3057 fp->tx_tso_max_nsegs = nsegs; | 3156 if ((nsegs < fp->tx_tso_min_nsegs) || (!fp->tx_tso_min_nsegs)) 3157 fp->tx_tso_min_nsegs = nsegs; 3158 } |
3058 | 3159 |
3059 if ((nsegs < fp->tx_tso_min_nsegs) || (!fp->tx_tso_min_nsegs)) 3060 fp->tx_tso_min_nsegs = nsegs; 3061 3062#endif /* #ifdef QLNX_TRACE_TSO_PKT_LEN */ 3063 | |
3064 txq->sw_tx_ring[idx].nsegs = nsegs; 3065 txq->sw_tx_prod = (txq->sw_tx_prod + 1) & (TX_RING_SIZE - 1); 3066 3067 txq->tx_db.data.bd_prod = 3068 htole16(ecore_chain_get_prod_idx(&txq->tx_pbl)); 3069 3070 qlnx_txq_doorbell_wr32(ha, txq->doorbell_addr, txq->tx_db.raw); 3071 --- 1111 unchanged lines hidden (view full) --- 4183 */ 4184 4185static void 4186qlnx_fp_isr(void *arg) 4187{ 4188 qlnx_ivec_t *ivec = arg; 4189 qlnx_host_t *ha; 4190 struct qlnx_fastpath *fp = NULL; | 3160 txq->sw_tx_ring[idx].nsegs = nsegs; 3161 txq->sw_tx_prod = (txq->sw_tx_prod + 1) & (TX_RING_SIZE - 1); 3162 3163 txq->tx_db.data.bd_prod = 3164 htole16(ecore_chain_get_prod_idx(&txq->tx_pbl)); 3165 3166 qlnx_txq_doorbell_wr32(ha, txq->doorbell_addr, txq->tx_db.raw); 3167 --- 1111 unchanged lines hidden (view full) --- 4279 */ 4280 4281static void 4282qlnx_fp_isr(void *arg) 4283{ 4284 qlnx_ivec_t *ivec = arg; 4285 qlnx_host_t *ha; 4286 struct qlnx_fastpath *fp = NULL; |
4191 int idx, lro_enable, tc; 4192 int rx_int = 0, total_rx_count = 0; | 4287 int idx; |
4193 4194 ha = ivec->ha; | 4288 4289 ha = ivec->ha; |
4195 lro_enable = ha->ifp->if_capenable & IFCAP_LRO; | |
4196 4197 if (ha->state != QLNX_STATE_OPEN) { 4198 return; 4199 } 4200 4201 idx = ivec->rss_idx; 4202 4203 if ((idx = ivec->rss_idx) >= ha->num_rss) { --- 5 unchanged lines hidden (view full) --- 4209 fp = &ha->fp_array[idx]; 4210 4211 if (fp == NULL) { 4212 QL_DPRINT1(ha, (ha->pci_dev, "%s: fp_array[%d] NULL\n", 4213 __func__, idx)); 4214 ha->err_fp_null++; 4215 } else { 4216 ecore_sb_ack(fp->sb_info, IGU_INT_DISABLE, 0); | 4290 4291 if (ha->state != QLNX_STATE_OPEN) { 4292 return; 4293 } 4294 4295 idx = ivec->rss_idx; 4296 4297 if ((idx = ivec->rss_idx) >= ha->num_rss) { --- 5 unchanged lines hidden (view full) --- 4303 fp = &ha->fp_array[idx]; 4304 4305 if (fp == NULL) { 4306 QL_DPRINT1(ha, (ha->pci_dev, "%s: fp_array[%d] NULL\n", 4307 __func__, idx)); 4308 ha->err_fp_null++; 4309 } else { 4310 ecore_sb_ack(fp->sb_info, IGU_INT_DISABLE, 0); |
4217 4218 do { 4219 for (tc = 0; tc < ha->num_tc; tc++) { 4220 if (mtx_trylock(&fp->tx_mtx)) { 4221 qlnx_tx_int(ha, fp, fp->txq[tc]); 4222 mtx_unlock(&fp->tx_mtx); 4223 } 4224 } 4225 4226 rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, 4227 lro_enable); 4228 4229 if (rx_int) { 4230 fp->rx_pkts += rx_int; 4231 total_rx_count += rx_int; 4232 } 4233 4234 } while (rx_int); 4235 4236 4237#ifdef QLNX_SOFT_LRO 4238 { 4239 struct lro_ctrl *lro; 4240 4241 lro = &fp->rxq->lro; 4242 4243 if (lro_enable && total_rx_count) { 4244 4245#if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) 4246 4247#ifdef QLNX_TRACE_LRO_CNT 4248 if (lro->lro_mbuf_count & ~1023) 4249 fp->lro_cnt_1024++; 4250 else if (lro->lro_mbuf_count & ~511) 4251 fp->lro_cnt_512++; 4252 else if (lro->lro_mbuf_count & ~255) 4253 fp->lro_cnt_256++; 4254 else if (lro->lro_mbuf_count & ~127) 4255 fp->lro_cnt_128++; 4256 else if (lro->lro_mbuf_count & ~63) 4257 fp->lro_cnt_64++; 4258#endif /* #ifdef QLNX_TRACE_LRO_CNT */ 4259 4260 tcp_lro_flush_all(lro); 4261 4262#else 4263 struct lro_entry *queued; 4264 4265 while ((!SLIST_EMPTY(&lro->lro_active))) { 4266 queued = SLIST_FIRST(&lro->lro_active); 4267 SLIST_REMOVE_HEAD(&lro->lro_active, \ 4268 next); 4269 tcp_lro_flush(lro, queued); 4270 } 4271#endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */ 4272 } 4273 } 4274#endif /* #ifdef QLNX_SOFT_LRO */ 4275 4276 if (fp->fp_taskqueue != NULL) 4277 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); 4278 4279 ecore_sb_update_sb_idx(fp->sb_info); 4280 rmb(); 4281 ecore_sb_ack(fp->sb_info, IGU_INT_ENABLE, 1); 4282 4283 return; | 4311 if (fp->fp_taskqueue != NULL) 4312 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); |
4284 } 4285 4286 return; 4287} 4288 4289 4290/* 4291 * slow path interrupt processing function --- 853 unchanged lines hidden (view full) --- 5145 txq_array_index = tc * ha->num_rss + rss_id; 5146 fp->txq[tc] = &ha->txq_array[txq_array_index]; 5147 fp->txq[tc]->index = txq_array_index; 5148 } 5149 5150 snprintf(fp->name, sizeof(fp->name), "%s-fp-%d", qlnx_name_str, 5151 rss_id); 5152 | 4313 } 4314 4315 return; 4316} 4317 4318 4319/* 4320 * slow path interrupt processing function --- 853 unchanged lines hidden (view full) --- 5174 txq_array_index = tc * ha->num_rss + rss_id; 5175 fp->txq[tc] = &ha->txq_array[txq_array_index]; 5176 fp->txq[tc]->index = txq_array_index; 5177 } 5178 5179 snprintf(fp->name, sizeof(fp->name), "%s-fp-%d", qlnx_name_str, 5180 rss_id); 5181 |
5182 fp->tx_ring_full = 0; 5183 |
|
5153 /* reset all the statistics counters */ 5154 5155 fp->tx_pkts_processed = 0; 5156 fp->tx_pkts_freed = 0; 5157 fp->tx_pkts_transmitted = 0; 5158 fp->tx_pkts_completed = 0; 5159 fp->tx_lso_wnd_min_len = 0; 5160 fp->tx_defrag = 0; --- 1877 unchanged lines hidden --- | 5184 /* reset all the statistics counters */ 5185 5186 fp->tx_pkts_processed = 0; 5187 fp->tx_pkts_freed = 0; 5188 fp->tx_pkts_transmitted = 0; 5189 fp->tx_pkts_completed = 0; 5190 fp->tx_lso_wnd_min_len = 0; 5191 fp->tx_defrag = 0; --- 1877 unchanged lines hidden --- |