qlnx_os.c (320164) | qlnx_os.c (322849) |
---|---|
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 320164 2017-06-20 19:16:06Z davidcs $"); | 35__FBSDID("$FreeBSD: stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c 322849 2017-08-24 17:36:10Z 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" --- 348 unchanged lines hidden (view full) --- 392static void 393qlnx_fp_taskqueue(void *context, int pending) 394{ 395 struct qlnx_fastpath *fp; 396 qlnx_host_t *ha; 397 struct ifnet *ifp; 398 struct mbuf *mp; 399 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" --- 348 unchanged lines hidden (view full) --- 392static void 393qlnx_fp_taskqueue(void *context, int pending) 394{ 395 struct qlnx_fastpath *fp; 396 qlnx_host_t *ha; 397 struct ifnet *ifp; 398 struct mbuf *mp; 399 int ret; |
400 struct thread *cthread; 401 402#ifdef QLNX_RCV_IN_TASKQ |
|
400 int lro_enable; 401 int rx_int = 0, total_rx_count = 0; | 403 int lro_enable; 404 int rx_int = 0, total_rx_count = 0; |
402 struct thread *cthread; | |
403 | 405 |
406#endif /* #ifdef QLNX_RCV_IN_TASKQ */ 407 |
|
404 fp = context; 405 406 if (fp == NULL) 407 return; 408 409 cthread = curthread; 410 411 thread_lock(cthread); 412 413 if (!sched_is_bound(cthread)) 414 sched_bind(cthread, fp->rss_id); 415 416 thread_unlock(cthread); 417 418 ha = (qlnx_host_t *)fp->edev; 419 420 ifp = ha->ifp; 421 | 408 fp = context; 409 410 if (fp == NULL) 411 return; 412 413 cthread = curthread; 414 415 thread_lock(cthread); 416 417 if (!sched_is_bound(cthread)) 418 sched_bind(cthread, fp->rss_id); 419 420 thread_unlock(cthread); 421 422 ha = (qlnx_host_t *)fp->edev; 423 424 ifp = ha->ifp; 425 |
422 lro_enable = ha->ifp->if_capenable & IFCAP_LRO; | 426#ifdef QLNX_RCV_IN_TASKQ 427 { 428 lro_enable = ifp->if_capenable & IFCAP_LRO; |
423 | 429 |
424 rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, lro_enable); | 430 rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, lro_enable); |
425 | 431 |
426 if (rx_int) { 427 fp->rx_pkts += rx_int; 428 total_rx_count += rx_int; 429 } | 432 if (rx_int) { 433 fp->rx_pkts += rx_int; 434 total_rx_count += rx_int; 435 } |
430 431#ifdef QLNX_SOFT_LRO | 436 437#ifdef QLNX_SOFT_LRO |
432 { 433 struct lro_ctrl *lro; | 438 { 439 struct lro_ctrl *lro; 440 441 lro = &fp->rxq->lro; |
434 | 442 |
435 lro = &fp->rxq->lro; | 443 if (lro_enable && total_rx_count) { |
436 | 444 |
437 if (lro_enable && total_rx_count) { 438 | |
439#if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) 440 | 445#if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) 446 |
441 if (ha->dbg_trace_lro_cnt) { 442 if (lro->lro_mbuf_count & ~1023) 443 fp->lro_cnt_1024++; 444 else if (lro->lro_mbuf_count & ~511) 445 fp->lro_cnt_512++; 446 else if (lro->lro_mbuf_count & ~255) 447 fp->lro_cnt_256++; 448 else if (lro->lro_mbuf_count & ~127) 449 fp->lro_cnt_128++; 450 else if (lro->lro_mbuf_count & ~63) 451 fp->lro_cnt_64++; 452 } 453 tcp_lro_flush_all(lro); | 447 if (ha->dbg_trace_lro_cnt) { 448 if (lro->lro_mbuf_count & ~1023) 449 fp->lro_cnt_1024++; 450 else if (lro->lro_mbuf_count & ~511) 451 fp->lro_cnt_512++; 452 else if (lro->lro_mbuf_count & ~255) 453 fp->lro_cnt_256++; 454 else if (lro->lro_mbuf_count & ~127) 455 fp->lro_cnt_128++; 456 else if (lro->lro_mbuf_count & ~63) 457 fp->lro_cnt_64++; 458 } 459 tcp_lro_flush_all(lro); |
454 455#else | 460 461#else |
456 struct lro_entry *queued; | 462 struct lro_entry *queued; |
457 | 463 |
458 while ((!SLIST_EMPTY(&lro->lro_active))) { 459 queued = SLIST_FIRST(&lro->lro_active); 460 SLIST_REMOVE_HEAD(&lro->lro_active, next); 461 tcp_lro_flush(lro, queued); 462 } | 464 while ((!SLIST_EMPTY(&lro->lro_active))) { 465 queued = SLIST_FIRST(&lro->lro_active); 466 SLIST_REMOVE_HEAD(&lro->lro_active, next); 467 tcp_lro_flush(lro, queued); 468 } |
463#endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */ | 469#endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */ |
470 } |
|
464 } | 471 } |
465 } | |
466#endif /* #ifdef QLNX_SOFT_LRO */ 467 | 472#endif /* #ifdef QLNX_SOFT_LRO */ 473 |
468 ecore_sb_update_sb_idx(fp->sb_info); 469 rmb(); | 474 ecore_sb_update_sb_idx(fp->sb_info); 475 rmb(); 476 } |
470 | 477 |
478#endif /* #ifdef QLNX_RCV_IN_TASKQ */ 479 |
|
471 mtx_lock(&fp->tx_mtx); 472 473 if (((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != 474 IFF_DRV_RUNNING) || (!ha->link_up)) { 475 476 mtx_unlock(&fp->tx_mtx); 477 goto qlnx_fp_taskqueue_exit; 478 } 479 | 480 mtx_lock(&fp->tx_mtx); 481 482 if (((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != 483 IFF_DRV_RUNNING) || (!ha->link_up)) { 484 485 mtx_unlock(&fp->tx_mtx); 486 goto qlnx_fp_taskqueue_exit; 487 } 488 |
480// for (tc = 0; tc < ha->num_tc; tc++) { 481// (void)qlnx_tx_int(ha, fp, fp->txq[tc]); 482// } 483 | |
484 mp = drbr_peek(ifp, fp->tx_br); 485 486 while (mp != NULL) { 487 488 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { 489 ret = qlnx_send(ha, fp, &mp); 490 } else { 491 ret = -1; --- 19 unchanged lines hidden (view full) --- 511 } 512 513 if (fp->tx_ring_full) 514 break; 515 516 mp = drbr_peek(ifp, fp->tx_br); 517 } 518 | 489 mp = drbr_peek(ifp, fp->tx_br); 490 491 while (mp != NULL) { 492 493 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { 494 ret = qlnx_send(ha, fp, &mp); 495 } else { 496 ret = -1; --- 19 unchanged lines hidden (view full) --- 516 } 517 518 if (fp->tx_ring_full) 519 break; 520 521 mp = drbr_peek(ifp, fp->tx_br); 522 } 523 |
519// for (tc = 0; tc < ha->num_tc; tc++) { 520// (void)qlnx_tx_int(ha, fp, fp->txq[tc]); 521// } 522 | |
523 mtx_unlock(&fp->tx_mtx); 524 525qlnx_fp_taskqueue_exit: | 524 mtx_unlock(&fp->tx_mtx); 525 526qlnx_fp_taskqueue_exit: |
527 528#ifdef QLNX_RCV_IN_TASKQ |
|
526 if (rx_int) { 527 if (fp->fp_taskqueue != NULL) 528 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); 529 } else { 530 if (fp->tx_ring_full) { 531 qlnx_mdelay(__func__, 100); 532 } 533 ecore_sb_ack(fp->sb_info, IGU_INT_ENABLE, 1); 534 } | 529 if (rx_int) { 530 if (fp->fp_taskqueue != NULL) 531 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); 532 } else { 533 if (fp->tx_ring_full) { 534 qlnx_mdelay(__func__, 100); 535 } 536 ecore_sb_ack(fp->sb_info, IGU_INT_ENABLE, 1); 537 } |
538#endif /* #ifdef QLNX_RCV_IN_TASKQ */ |
|
535 536 QL_DPRINT2(ha, "exit ret = %d\n", ret); 537 return; 538} 539 540static int 541qlnx_create_fp_taskqueues(qlnx_host_t *ha) 542{ --- 3714 unchanged lines hidden (view full) --- 4257 } /* repeat while sw_comp_cons != hw_comp_cons... */ 4258 4259 /* Update producers */ 4260 qlnx_update_rx_prod(p_hwfn, rxq); 4261 4262 return rx_pkt; 4263} 4264 | 539 540 QL_DPRINT2(ha, "exit ret = %d\n", ret); 541 return; 542} 543 544static int 545qlnx_create_fp_taskqueues(qlnx_host_t *ha) 546{ --- 3714 unchanged lines hidden (view full) --- 4261 } /* repeat while sw_comp_cons != hw_comp_cons... */ 4262 4263 /* Update producers */ 4264 qlnx_update_rx_prod(p_hwfn, rxq); 4265 4266 return rx_pkt; 4267} 4268 |
4269 |
|
4265/* 4266 * fast path interrupt 4267 */ 4268 4269static void 4270qlnx_fp_isr(void *arg) 4271{ 4272 qlnx_ivec_t *ivec = arg; --- 14 unchanged lines hidden (view full) --- 4287 ha->err_illegal_intr++; 4288 return; 4289 } 4290 fp = &ha->fp_array[idx]; 4291 4292 if (fp == NULL) { 4293 ha->err_fp_null++; 4294 } else { | 4270/* 4271 * fast path interrupt 4272 */ 4273 4274static void 4275qlnx_fp_isr(void *arg) 4276{ 4277 qlnx_ivec_t *ivec = arg; --- 14 unchanged lines hidden (view full) --- 4292 ha->err_illegal_intr++; 4293 return; 4294 } 4295 fp = &ha->fp_array[idx]; 4296 4297 if (fp == NULL) { 4298 ha->err_fp_null++; 4299 } else { |
4300 4301#ifdef QLNX_RCV_IN_TASKQ |
|
4295 ecore_sb_ack(fp->sb_info, IGU_INT_DISABLE, 0); 4296 if (fp->fp_taskqueue != NULL) 4297 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); | 4302 ecore_sb_ack(fp->sb_info, IGU_INT_DISABLE, 0); 4303 if (fp->fp_taskqueue != NULL) 4304 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); |
4305#else 4306 int rx_int = 0, total_rx_count = 0; 4307 int lro_enable, tc; 4308 4309 lro_enable = ha->ifp->if_capenable & IFCAP_LRO; 4310 4311 ecore_sb_ack(fp->sb_info, IGU_INT_DISABLE, 0); 4312 4313 do { 4314 for (tc = 0; tc < ha->num_tc; tc++) { 4315 if (mtx_trylock(&fp->tx_mtx)) { 4316 qlnx_tx_int(ha, fp, fp->txq[tc]); 4317 mtx_unlock(&fp->tx_mtx); 4318 } 4319 } 4320 4321 rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, 4322 lro_enable); 4323 4324 if (rx_int) { 4325 fp->rx_pkts += rx_int; 4326 total_rx_count += rx_int; 4327 } 4328 4329 } while (rx_int); 4330 4331 4332#ifdef QLNX_SOFT_LRO 4333 { 4334 struct lro_ctrl *lro; 4335 4336 lro = &fp->rxq->lro; 4337 4338 if (lro_enable && total_rx_count) { 4339 4340#if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) 4341 4342#ifdef QLNX_TRACE_LRO_CNT 4343 if (lro->lro_mbuf_count & ~1023) 4344 fp->lro_cnt_1024++; 4345 else if (lro->lro_mbuf_count & ~511) 4346 fp->lro_cnt_512++; 4347 else if (lro->lro_mbuf_count & ~255) 4348 fp->lro_cnt_256++; 4349 else if (lro->lro_mbuf_count & ~127) 4350 fp->lro_cnt_128++; 4351 else if (lro->lro_mbuf_count & ~63) 4352 fp->lro_cnt_64++; 4353#endif /* #ifdef QLNX_TRACE_LRO_CNT */ 4354 4355 tcp_lro_flush_all(lro); 4356 4357#else 4358 struct lro_entry *queued; 4359 4360 while ((!SLIST_EMPTY(&lro->lro_active))) { 4361 queued = SLIST_FIRST(&lro->lro_active); 4362 SLIST_REMOVE_HEAD(&lro->lro_active, \ 4363 next); 4364 tcp_lro_flush(lro, queued); 4365 } 4366#endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */ 4367 } 4368 } 4369#endif /* #ifdef QLNX_SOFT_LRO */ 4370 4371 ecore_sb_update_sb_idx(fp->sb_info); 4372 rmb(); 4373 ecore_sb_ack(fp->sb_info, IGU_INT_ENABLE, 1); 4374 4375#endif /* #ifdef QLNX_RCV_IN_TASKQ */ |
|
4298 } 4299 4300 return; 4301} 4302 4303 4304/* 4305 * slow path interrupt processing function --- 2727 unchanged lines hidden --- | 4376 } 4377 4378 return; 4379} 4380 4381 4382/* 4383 * slow path interrupt processing function --- 2727 unchanged lines hidden --- |