| .. | .. |
|---|
| 32 | 32 | #define OCTNIC_MAX_SG MAX_SKB_FRAGS |
|---|
| 33 | 33 | |
|---|
| 34 | 34 | /** |
|---|
| 35 | | - * \brief Callback for getting interface configuration |
|---|
| 36 | | - * @param status status of request |
|---|
| 37 | | - * @param buf pointer to resp structure |
|---|
| 38 | | - */ |
|---|
| 39 | | -void lio_if_cfg_callback(struct octeon_device *oct, |
|---|
| 40 | | - u32 status __attribute__((unused)), void *buf) |
|---|
| 41 | | -{ |
|---|
| 42 | | - struct octeon_soft_command *sc = (struct octeon_soft_command *)buf; |
|---|
| 43 | | - struct liquidio_if_cfg_context *ctx; |
|---|
| 44 | | - struct liquidio_if_cfg_resp *resp; |
|---|
| 45 | | - |
|---|
| 46 | | - resp = (struct liquidio_if_cfg_resp *)sc->virtrptr; |
|---|
| 47 | | - ctx = (struct liquidio_if_cfg_context *)sc->ctxptr; |
|---|
| 48 | | - |
|---|
| 49 | | - oct = lio_get_device(ctx->octeon_id); |
|---|
| 50 | | - if (resp->status) |
|---|
| 51 | | - dev_err(&oct->pci_dev->dev, "nic if cfg instruction failed. Status: %llx\n", |
|---|
| 52 | | - CVM_CAST64(resp->status)); |
|---|
| 53 | | - WRITE_ONCE(ctx->cond, 1); |
|---|
| 54 | | - |
|---|
| 55 | | - snprintf(oct->fw_info.liquidio_firmware_version, 32, "%s", |
|---|
| 56 | | - resp->cfg_info.liquidio_firmware_version); |
|---|
| 57 | | - |
|---|
| 58 | | - /* This barrier is required to be sure that the response has been |
|---|
| 59 | | - * written fully before waking up the handler |
|---|
| 60 | | - */ |
|---|
| 61 | | - wmb(); |
|---|
| 62 | | - |
|---|
| 63 | | - wake_up_interruptible(&ctx->wc); |
|---|
| 64 | | -} |
|---|
| 65 | | - |
|---|
| 66 | | -/** |
|---|
| 67 | | - * \brief Delete gather lists |
|---|
| 68 | | - * @param lio per-network private data |
|---|
| 35 | + * lio_delete_glists - Delete gather lists |
|---|
| 36 | + * @lio: per-network private data |
|---|
| 69 | 37 | */ |
|---|
| 70 | 38 | void lio_delete_glists(struct lio *lio) |
|---|
| 71 | 39 | { |
|---|
| .. | .. |
|---|
| 105 | 73 | } |
|---|
| 106 | 74 | |
|---|
| 107 | 75 | /** |
|---|
| 108 | | - * \brief Setup gather lists |
|---|
| 109 | | - * @param lio per-network private data |
|---|
| 76 | + * lio_setup_glists - Setup gather lists |
|---|
| 77 | + * @oct: octeon_device |
|---|
| 78 | + * @lio: per-network private data |
|---|
| 79 | + * @num_iqs: count of iqs to allocate |
|---|
| 110 | 80 | */ |
|---|
| 111 | 81 | int lio_setup_glists(struct octeon_device *oct, struct lio *lio, int num_iqs) |
|---|
| 112 | 82 | { |
|---|
| .. | .. |
|---|
| 198 | 168 | nctrl.ncmd.s.cmd = cmd; |
|---|
| 199 | 169 | nctrl.ncmd.s.param1 = param1; |
|---|
| 200 | 170 | nctrl.iq_no = lio->linfo.txpciq[0].s.q_no; |
|---|
| 201 | | - nctrl.wait_time = 100; |
|---|
| 202 | 171 | nctrl.netpndev = (u64)netdev; |
|---|
| 203 | 172 | nctrl.cb_fn = liquidio_link_ctrl_cmd_completion; |
|---|
| 204 | 173 | |
|---|
| 205 | 174 | ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl); |
|---|
| 206 | | - if (ret < 0) { |
|---|
| 175 | + if (ret) { |
|---|
| 207 | 176 | dev_err(&oct->pci_dev->dev, "Feature change failed in core (ret: 0x%x)\n", |
|---|
| 208 | 177 | ret); |
|---|
| 178 | + if (ret > 0) |
|---|
| 179 | + ret = -EIO; |
|---|
| 209 | 180 | } |
|---|
| 210 | 181 | return ret; |
|---|
| 211 | 182 | } |
|---|
| .. | .. |
|---|
| 285 | 256 | struct octeon_device *oct = lio->oct_dev; |
|---|
| 286 | 257 | u8 *mac; |
|---|
| 287 | 258 | |
|---|
| 288 | | - if (nctrl->completion && nctrl->response_code) { |
|---|
| 289 | | - /* Signal whoever is interested that the response code from the |
|---|
| 290 | | - * firmware has arrived. |
|---|
| 291 | | - */ |
|---|
| 292 | | - WRITE_ONCE(*nctrl->response_code, nctrl->status); |
|---|
| 293 | | - complete(nctrl->completion); |
|---|
| 294 | | - } |
|---|
| 295 | | - |
|---|
| 296 | | - if (nctrl->status) |
|---|
| 259 | + if (nctrl->sc_status) |
|---|
| 297 | 260 | return; |
|---|
| 298 | 261 | |
|---|
| 299 | 262 | switch (nctrl->ncmd.s.cmd) { |
|---|
| .. | .. |
|---|
| 464 | 427 | */ |
|---|
| 465 | 428 | } |
|---|
| 466 | 429 | |
|---|
| 430 | +void octeon_schedule_rxq_oom_work(struct octeon_device *oct, |
|---|
| 431 | + struct octeon_droq *droq) |
|---|
| 432 | +{ |
|---|
| 433 | + struct net_device *netdev = oct->props[0].netdev; |
|---|
| 434 | + struct lio *lio = GET_LIO(netdev); |
|---|
| 435 | + struct cavium_wq *wq = &lio->rxq_status_wq[droq->q_no]; |
|---|
| 436 | + |
|---|
| 437 | + queue_delayed_work(wq->wq, &wq->wk.work, |
|---|
| 438 | + msecs_to_jiffies(LIO_OOM_POLL_INTERVAL_MS)); |
|---|
| 439 | +} |
|---|
| 440 | + |
|---|
| 467 | 441 | static void octnet_poll_check_rxq_oom_status(struct work_struct *work) |
|---|
| 468 | 442 | { |
|---|
| 469 | 443 | struct cavium_wk *wk = (struct cavium_wk *)work; |
|---|
| 470 | 444 | struct lio *lio = (struct lio *)wk->ctxptr; |
|---|
| 471 | 445 | struct octeon_device *oct = lio->oct_dev; |
|---|
| 472 | | - struct octeon_droq *droq; |
|---|
| 473 | | - int q, q_no = 0; |
|---|
| 446 | + int q_no = wk->ctxul; |
|---|
| 447 | + struct octeon_droq *droq = oct->droq[q_no]; |
|---|
| 474 | 448 | |
|---|
| 475 | | - if (ifstate_check(lio, LIO_IFSTATE_RUNNING)) { |
|---|
| 476 | | - for (q = 0; q < lio->linfo.num_rxpciq; q++) { |
|---|
| 477 | | - q_no = lio->linfo.rxpciq[q].s.q_no; |
|---|
| 478 | | - droq = oct->droq[q_no]; |
|---|
| 479 | | - if (!droq) |
|---|
| 480 | | - continue; |
|---|
| 481 | | - octeon_droq_check_oom(droq); |
|---|
| 482 | | - } |
|---|
| 483 | | - } |
|---|
| 484 | | - queue_delayed_work(lio->rxq_status_wq.wq, |
|---|
| 485 | | - &lio->rxq_status_wq.wk.work, |
|---|
| 486 | | - msecs_to_jiffies(LIO_OOM_POLL_INTERVAL_MS)); |
|---|
| 449 | + if (!ifstate_check(lio, LIO_IFSTATE_RUNNING) || !droq) |
|---|
| 450 | + return; |
|---|
| 451 | + |
|---|
| 452 | + if (octeon_retry_droq_refill(droq)) |
|---|
| 453 | + octeon_schedule_rxq_oom_work(oct, droq); |
|---|
| 487 | 454 | } |
|---|
| 488 | 455 | |
|---|
| 489 | 456 | int setup_rx_oom_poll_fn(struct net_device *netdev) |
|---|
| 490 | 457 | { |
|---|
| 491 | 458 | struct lio *lio = GET_LIO(netdev); |
|---|
| 492 | 459 | struct octeon_device *oct = lio->oct_dev; |
|---|
| 460 | + struct cavium_wq *wq; |
|---|
| 461 | + int q, q_no; |
|---|
| 493 | 462 | |
|---|
| 494 | | - lio->rxq_status_wq.wq = alloc_workqueue("rxq-oom-status", |
|---|
| 495 | | - WQ_MEM_RECLAIM, 0); |
|---|
| 496 | | - if (!lio->rxq_status_wq.wq) { |
|---|
| 497 | | - dev_err(&oct->pci_dev->dev, "unable to create cavium rxq oom status wq\n"); |
|---|
| 498 | | - return -ENOMEM; |
|---|
| 463 | + for (q = 0; q < oct->num_oqs; q++) { |
|---|
| 464 | + q_no = lio->linfo.rxpciq[q].s.q_no; |
|---|
| 465 | + wq = &lio->rxq_status_wq[q_no]; |
|---|
| 466 | + wq->wq = alloc_workqueue("rxq-oom-status", |
|---|
| 467 | + WQ_MEM_RECLAIM, 0); |
|---|
| 468 | + if (!wq->wq) { |
|---|
| 469 | + dev_err(&oct->pci_dev->dev, "unable to create cavium rxq oom status wq\n"); |
|---|
| 470 | + return -ENOMEM; |
|---|
| 471 | + } |
|---|
| 472 | + |
|---|
| 473 | + INIT_DELAYED_WORK(&wq->wk.work, |
|---|
| 474 | + octnet_poll_check_rxq_oom_status); |
|---|
| 475 | + wq->wk.ctxptr = lio; |
|---|
| 476 | + wq->wk.ctxul = q_no; |
|---|
| 499 | 477 | } |
|---|
| 500 | | - INIT_DELAYED_WORK(&lio->rxq_status_wq.wk.work, |
|---|
| 501 | | - octnet_poll_check_rxq_oom_status); |
|---|
| 502 | | - lio->rxq_status_wq.wk.ctxptr = lio; |
|---|
| 503 | | - queue_delayed_work(lio->rxq_status_wq.wq, |
|---|
| 504 | | - &lio->rxq_status_wq.wk.work, |
|---|
| 505 | | - msecs_to_jiffies(LIO_OOM_POLL_INTERVAL_MS)); |
|---|
| 478 | + |
|---|
| 506 | 479 | return 0; |
|---|
| 507 | 480 | } |
|---|
| 508 | 481 | |
|---|
| 509 | 482 | void cleanup_rx_oom_poll_fn(struct net_device *netdev) |
|---|
| 510 | 483 | { |
|---|
| 511 | 484 | struct lio *lio = GET_LIO(netdev); |
|---|
| 485 | + struct octeon_device *oct = lio->oct_dev; |
|---|
| 486 | + struct cavium_wq *wq; |
|---|
| 487 | + int q_no; |
|---|
| 512 | 488 | |
|---|
| 513 | | - if (lio->rxq_status_wq.wq) { |
|---|
| 514 | | - cancel_delayed_work_sync(&lio->rxq_status_wq.wk.work); |
|---|
| 515 | | - flush_workqueue(lio->rxq_status_wq.wq); |
|---|
| 516 | | - destroy_workqueue(lio->rxq_status_wq.wq); |
|---|
| 489 | + for (q_no = 0; q_no < oct->num_oqs; q_no++) { |
|---|
| 490 | + wq = &lio->rxq_status_wq[q_no]; |
|---|
| 491 | + if (wq->wq) { |
|---|
| 492 | + cancel_delayed_work_sync(&wq->wk.work); |
|---|
| 493 | + flush_workqueue(wq->wq); |
|---|
| 494 | + destroy_workqueue(wq->wq); |
|---|
| 495 | + wq->wq = NULL; |
|---|
| 496 | + } |
|---|
| 517 | 497 | } |
|---|
| 518 | 498 | } |
|---|
| 519 | 499 | |
|---|
| .. | .. |
|---|
| 543 | 523 | } |
|---|
| 544 | 524 | |
|---|
| 545 | 525 | /** |
|---|
| 546 | | - * \brief Setup output queue |
|---|
| 547 | | - * @param oct octeon device |
|---|
| 548 | | - * @param q_no which queue |
|---|
| 549 | | - * @param num_descs how many descriptors |
|---|
| 550 | | - * @param desc_size size of each descriptor |
|---|
| 551 | | - * @param app_ctx application context |
|---|
| 526 | + * octeon_setup_droq - Setup output queue |
|---|
| 527 | + * @oct: octeon device |
|---|
| 528 | + * @q_no: which queue |
|---|
| 529 | + * @num_descs: how many descriptors |
|---|
| 530 | + * @desc_size: size of each descriptor |
|---|
| 531 | + * @app_ctx: application context |
|---|
| 552 | 532 | */ |
|---|
| 553 | 533 | static int octeon_setup_droq(struct octeon_device *oct, int q_no, int num_descs, |
|---|
| 554 | 534 | int desc_size, void *app_ctx) |
|---|
| .. | .. |
|---|
| 577 | 557 | return ret_val; |
|---|
| 578 | 558 | } |
|---|
| 579 | 559 | |
|---|
| 580 | | -/** Routine to push packets arriving on Octeon interface upto network layer. |
|---|
| 581 | | - * @param oct_id - octeon device id. |
|---|
| 582 | | - * @param skbuff - skbuff struct to be passed to network layer. |
|---|
| 583 | | - * @param len - size of total data received. |
|---|
| 584 | | - * @param rh - Control header associated with the packet |
|---|
| 585 | | - * @param param - additional control data with the packet |
|---|
| 586 | | - * @param arg - farg registered in droq_ops |
|---|
| 560 | +/** |
|---|
| 561 | + * liquidio_push_packet - Routine to push packets arriving on Octeon interface upto network layer. |
|---|
| 562 | + * @octeon_id:octeon device id. |
|---|
| 563 | + * @skbuff: skbuff struct to be passed to network layer. |
|---|
| 564 | + * @len: size of total data received. |
|---|
| 565 | + * @rh: Control header associated with the packet |
|---|
| 566 | + * @param: additional control data with the packet |
|---|
| 567 | + * @arg: farg registered in droq_ops |
|---|
| 587 | 568 | */ |
|---|
| 588 | 569 | static void |
|---|
| 589 | | -liquidio_push_packet(u32 octeon_id __attribute__((unused)), |
|---|
| 570 | +liquidio_push_packet(u32 __maybe_unused octeon_id, |
|---|
| 590 | 571 | void *skbuff, |
|---|
| 591 | 572 | u32 len, |
|---|
| 592 | 573 | union octeon_rh *rh, |
|---|
| .. | .. |
|---|
| 683 | 664 | (((rh->r_dh.encap_on) && |
|---|
| 684 | 665 | (rh->r_dh.csum_verified & CNNIC_TUN_CSUM_VERIFIED)) || |
|---|
| 685 | 666 | (!(rh->r_dh.encap_on) && |
|---|
| 686 | | - (rh->r_dh.csum_verified & CNNIC_CSUM_VERIFIED)))) |
|---|
| 667 | + ((rh->r_dh.csum_verified & CNNIC_CSUM_VERIFIED) == |
|---|
| 668 | + CNNIC_CSUM_VERIFIED)))) |
|---|
| 687 | 669 | /* checksum has already been verified */ |
|---|
| 688 | 670 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
|---|
| 689 | 671 | else |
|---|
| .. | .. |
|---|
| 719 | 701 | } |
|---|
| 720 | 702 | |
|---|
| 721 | 703 | /** |
|---|
| 722 | | - * \brief wrapper for calling napi_schedule |
|---|
| 723 | | - * @param param parameters to pass to napi_schedule |
|---|
| 704 | + * napi_schedule_wrapper - wrapper for calling napi_schedule |
|---|
| 705 | + * @param: parameters to pass to napi_schedule |
|---|
| 724 | 706 | * |
|---|
| 725 | 707 | * Used when scheduling on different CPUs |
|---|
| 726 | 708 | */ |
|---|
| .. | .. |
|---|
| 732 | 714 | } |
|---|
| 733 | 715 | |
|---|
| 734 | 716 | /** |
|---|
| 735 | | - * \brief callback when receive interrupt occurs and we are in NAPI mode |
|---|
| 736 | | - * @param arg pointer to octeon output queue |
|---|
| 717 | + * liquidio_napi_drv_callback - callback when receive interrupt occurs and we are in NAPI mode |
|---|
| 718 | + * @arg: pointer to octeon output queue |
|---|
| 737 | 719 | */ |
|---|
| 738 | 720 | static void liquidio_napi_drv_callback(void *arg) |
|---|
| 739 | 721 | { |
|---|
| .. | .. |
|---|
| 758 | 740 | } |
|---|
| 759 | 741 | |
|---|
| 760 | 742 | /** |
|---|
| 761 | | - * \brief Entry point for NAPI polling |
|---|
| 762 | | - * @param napi NAPI structure |
|---|
| 763 | | - * @param budget maximum number of items to process |
|---|
| 743 | + * liquidio_napi_poll - Entry point for NAPI polling |
|---|
| 744 | + * @napi: NAPI structure |
|---|
| 745 | + * @budget: maximum number of items to process |
|---|
| 764 | 746 | */ |
|---|
| 765 | 747 | static int liquidio_napi_poll(struct napi_struct *napi, int budget) |
|---|
| 766 | 748 | { |
|---|
| .. | .. |
|---|
| 803 | 785 | if ((work_done < budget && tx_done) || |
|---|
| 804 | 786 | (iq && iq->pkt_in_done >= MAX_REG_CNT) || |
|---|
| 805 | 787 | (droq->pkt_count >= MAX_REG_CNT)) { |
|---|
| 806 | | - tx_done = 1; |
|---|
| 807 | 788 | napi_complete_done(napi, work_done); |
|---|
| 808 | 789 | |
|---|
| 809 | 790 | octeon_enable_irq(droq->oct_dev, droq->q_no); |
|---|
| .. | .. |
|---|
| 814 | 795 | } |
|---|
| 815 | 796 | |
|---|
| 816 | 797 | /** |
|---|
| 817 | | - * \brief Setup input and output queues |
|---|
| 818 | | - * @param octeon_dev octeon device |
|---|
| 819 | | - * @param ifidx Interface index |
|---|
| 798 | + * liquidio_setup_io_queues - Setup input and output queues |
|---|
| 799 | + * @octeon_dev: octeon device |
|---|
| 800 | + * @ifidx: Interface index |
|---|
| 801 | + * @num_iqs: input io queue count |
|---|
| 802 | + * @num_oqs: output io queue count |
|---|
| 820 | 803 | * |
|---|
| 821 | 804 | * Note: Queues are with respect to the octeon device. Thus |
|---|
| 822 | 805 | * an input queue is for egress packets, and output queues |
|---|
| .. | .. |
|---|
| 949 | 932 | } |
|---|
| 950 | 933 | |
|---|
| 951 | 934 | irqreturn_t |
|---|
| 952 | | -liquidio_msix_intr_handler(int irq __attribute__((unused)), void *dev) |
|---|
| 935 | +liquidio_msix_intr_handler(int __maybe_unused irq, void *dev) |
|---|
| 953 | 936 | { |
|---|
| 954 | 937 | struct octeon_ioq_vector *ioq_vector = (struct octeon_ioq_vector *)dev; |
|---|
| 955 | 938 | struct octeon_device *oct = ioq_vector->oct_dev; |
|---|
| .. | .. |
|---|
| 965 | 948 | } |
|---|
| 966 | 949 | |
|---|
| 967 | 950 | /** |
|---|
| 968 | | - * \brief Droq packet processor sceduler |
|---|
| 969 | | - * @param oct octeon device |
|---|
| 951 | + * liquidio_schedule_droq_pkt_handlers - Droq packet processor sceduler |
|---|
| 952 | + * @oct: octeon device |
|---|
| 970 | 953 | */ |
|---|
| 971 | 954 | static void liquidio_schedule_droq_pkt_handlers(struct octeon_device *oct) |
|---|
| 972 | 955 | { |
|---|
| .. | .. |
|---|
| 994 | 977 | } |
|---|
| 995 | 978 | |
|---|
| 996 | 979 | /** |
|---|
| 997 | | - * \brief Interrupt handler for octeon |
|---|
| 998 | | - * @param irq unused |
|---|
| 999 | | - * @param dev octeon device |
|---|
| 980 | + * liquidio_legacy_intr_handler - Interrupt handler for octeon |
|---|
| 981 | + * @irq: unused |
|---|
| 982 | + * @dev: octeon device |
|---|
| 1000 | 983 | */ |
|---|
| 1001 | 984 | static |
|---|
| 1002 | | -irqreturn_t liquidio_legacy_intr_handler(int irq __attribute__((unused)), |
|---|
| 1003 | | - void *dev) |
|---|
| 985 | +irqreturn_t liquidio_legacy_intr_handler(int __maybe_unused irq, void *dev) |
|---|
| 1004 | 986 | { |
|---|
| 1005 | 987 | struct octeon_device *oct = (struct octeon_device *)dev; |
|---|
| 1006 | 988 | irqreturn_t ret; |
|---|
| .. | .. |
|---|
| 1021 | 1003 | } |
|---|
| 1022 | 1004 | |
|---|
| 1023 | 1005 | /** |
|---|
| 1024 | | - * \brief Setup interrupt for octeon device |
|---|
| 1025 | | - * @param oct octeon device |
|---|
| 1006 | + * octeon_setup_interrupt - Setup interrupt for octeon device |
|---|
| 1007 | + * @oct: octeon device |
|---|
| 1008 | + * @num_ioqs: number of queues |
|---|
| 1026 | 1009 | * |
|---|
| 1027 | 1010 | * Enable interrupt in Octeon device as given in the PCI interrupt mask. |
|---|
| 1028 | 1011 | */ |
|---|
| .. | .. |
|---|
| 1105 | 1088 | dev_dbg(&oct->pci_dev->dev, "OCTEON: Enough MSI-X interrupts are allocated...\n"); |
|---|
| 1106 | 1089 | |
|---|
| 1107 | 1090 | num_ioq_vectors = oct->num_msix_irqs; |
|---|
| 1108 | | - /** For PF, there is one non-ioq interrupt handler */ |
|---|
| 1091 | + /* For PF, there is one non-ioq interrupt handler */ |
|---|
| 1109 | 1092 | if (OCTEON_CN23XX_PF(oct)) { |
|---|
| 1110 | 1093 | num_ioq_vectors -= 1; |
|---|
| 1111 | 1094 | |
|---|
| .. | .. |
|---|
| 1148 | 1131 | dev_err(&oct->pci_dev->dev, |
|---|
| 1149 | 1132 | "Request_irq failed for MSIX interrupt Error: %d\n", |
|---|
| 1150 | 1133 | irqret); |
|---|
| 1151 | | - /** Freeing the non-ioq irq vector here . */ |
|---|
| 1134 | + /* Freeing the non-ioq irq vector here . */ |
|---|
| 1152 | 1135 | free_irq(msix_entries[num_ioq_vectors].vector, |
|---|
| 1153 | 1136 | oct); |
|---|
| 1154 | 1137 | |
|---|
| 1155 | 1138 | while (i) { |
|---|
| 1156 | 1139 | i--; |
|---|
| 1157 | | - /** clearing affinity mask. */ |
|---|
| 1140 | + /* clearing affinity mask. */ |
|---|
| 1158 | 1141 | irq_set_affinity_hint( |
|---|
| 1159 | 1142 | msix_entries[i].vector, |
|---|
| 1160 | 1143 | NULL); |
|---|
| .. | .. |
|---|
| 1218 | 1201 | return 0; |
|---|
| 1219 | 1202 | } |
|---|
| 1220 | 1203 | |
|---|
| 1221 | | -static void liquidio_change_mtu_completion(struct octeon_device *oct, |
|---|
| 1222 | | - u32 status, void *buf) |
|---|
| 1223 | | -{ |
|---|
| 1224 | | - struct octeon_soft_command *sc = (struct octeon_soft_command *)buf; |
|---|
| 1225 | | - struct liquidio_if_cfg_context *ctx; |
|---|
| 1226 | | - |
|---|
| 1227 | | - ctx = (struct liquidio_if_cfg_context *)sc->ctxptr; |
|---|
| 1228 | | - |
|---|
| 1229 | | - if (status) { |
|---|
| 1230 | | - dev_err(&oct->pci_dev->dev, "MTU change failed. Status: %llx\n", |
|---|
| 1231 | | - CVM_CAST64(status)); |
|---|
| 1232 | | - WRITE_ONCE(ctx->cond, LIO_CHANGE_MTU_FAIL); |
|---|
| 1233 | | - } else { |
|---|
| 1234 | | - WRITE_ONCE(ctx->cond, LIO_CHANGE_MTU_SUCCESS); |
|---|
| 1235 | | - } |
|---|
| 1236 | | - |
|---|
| 1237 | | - /* This barrier is required to be sure that the response has been |
|---|
| 1238 | | - * written fully before waking up the handler |
|---|
| 1239 | | - */ |
|---|
| 1240 | | - wmb(); |
|---|
| 1241 | | - |
|---|
| 1242 | | - wake_up_interruptible(&ctx->wc); |
|---|
| 1243 | | -} |
|---|
| 1244 | | - |
|---|
| 1245 | 1204 | /** |
|---|
| 1246 | | - * \brief Net device change_mtu |
|---|
| 1247 | | - * @param netdev network device |
|---|
| 1205 | + * liquidio_change_mtu - Net device change_mtu |
|---|
| 1206 | + * @netdev: network device |
|---|
| 1207 | + * @new_mtu: the new max transmit unit size |
|---|
| 1248 | 1208 | */ |
|---|
| 1249 | 1209 | int liquidio_change_mtu(struct net_device *netdev, int new_mtu) |
|---|
| 1250 | 1210 | { |
|---|
| 1251 | 1211 | struct lio *lio = GET_LIO(netdev); |
|---|
| 1252 | 1212 | struct octeon_device *oct = lio->oct_dev; |
|---|
| 1253 | | - struct liquidio_if_cfg_context *ctx; |
|---|
| 1254 | 1213 | struct octeon_soft_command *sc; |
|---|
| 1255 | 1214 | union octnet_cmd *ncmd; |
|---|
| 1256 | | - int ctx_size; |
|---|
| 1257 | 1215 | int ret = 0; |
|---|
| 1258 | 1216 | |
|---|
| 1259 | | - ctx_size = sizeof(struct liquidio_if_cfg_context); |
|---|
| 1260 | 1217 | sc = (struct octeon_soft_command *) |
|---|
| 1261 | | - octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE, 16, ctx_size); |
|---|
| 1218 | + octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE, 16, 0); |
|---|
| 1219 | + if (!sc) { |
|---|
| 1220 | + netif_info(lio, rx_err, lio->netdev, |
|---|
| 1221 | + "Failed to allocate soft command\n"); |
|---|
| 1222 | + return -ENOMEM; |
|---|
| 1223 | + } |
|---|
| 1262 | 1224 | |
|---|
| 1263 | 1225 | ncmd = (union octnet_cmd *)sc->virtdptr; |
|---|
| 1264 | | - ctx = (struct liquidio_if_cfg_context *)sc->ctxptr; |
|---|
| 1265 | 1226 | |
|---|
| 1266 | | - WRITE_ONCE(ctx->cond, 0); |
|---|
| 1267 | | - ctx->octeon_id = lio_get_device_id(oct); |
|---|
| 1268 | | - init_waitqueue_head(&ctx->wc); |
|---|
| 1227 | + init_completion(&sc->complete); |
|---|
| 1228 | + sc->sc_status = OCTEON_REQUEST_PENDING; |
|---|
| 1269 | 1229 | |
|---|
| 1270 | 1230 | ncmd->u64 = 0; |
|---|
| 1271 | 1231 | ncmd->s.cmd = OCTNET_CMD_CHANGE_MTU; |
|---|
| .. | .. |
|---|
| 1278 | 1238 | octeon_prepare_soft_command(oct, sc, OPCODE_NIC, |
|---|
| 1279 | 1239 | OPCODE_NIC_CMD, 0, 0, 0); |
|---|
| 1280 | 1240 | |
|---|
| 1281 | | - sc->callback = liquidio_change_mtu_completion; |
|---|
| 1282 | | - sc->callback_arg = sc; |
|---|
| 1283 | | - sc->wait_time = 100; |
|---|
| 1284 | | - |
|---|
| 1285 | 1241 | ret = octeon_send_soft_command(oct, sc); |
|---|
| 1286 | 1242 | if (ret == IQ_SEND_FAILED) { |
|---|
| 1287 | 1243 | netif_info(lio, rx_err, lio->netdev, "Failed to change MTU\n"); |
|---|
| 1244 | + octeon_free_soft_command(oct, sc); |
|---|
| 1288 | 1245 | return -EINVAL; |
|---|
| 1289 | 1246 | } |
|---|
| 1290 | 1247 | /* Sleep on a wait queue till the cond flag indicates that the |
|---|
| 1291 | 1248 | * response arrived or timed-out. |
|---|
| 1292 | 1249 | */ |
|---|
| 1293 | | - if (sleep_cond(&ctx->wc, &ctx->cond) == -EINTR || |
|---|
| 1294 | | - ctx->cond == LIO_CHANGE_MTU_FAIL) { |
|---|
| 1295 | | - octeon_free_soft_command(oct, sc); |
|---|
| 1250 | + ret = wait_for_sc_completion_timeout(oct, sc, 0); |
|---|
| 1251 | + if (ret) |
|---|
| 1252 | + return ret; |
|---|
| 1253 | + |
|---|
| 1254 | + if (sc->sc_status) { |
|---|
| 1255 | + WRITE_ONCE(sc->caller_is_done, true); |
|---|
| 1296 | 1256 | return -EINVAL; |
|---|
| 1297 | 1257 | } |
|---|
| 1298 | 1258 | |
|---|
| 1299 | 1259 | netdev->mtu = new_mtu; |
|---|
| 1300 | 1260 | lio->mtu = new_mtu; |
|---|
| 1301 | 1261 | |
|---|
| 1302 | | - octeon_free_soft_command(oct, sc); |
|---|
| 1262 | + WRITE_ONCE(sc->caller_is_done, true); |
|---|
| 1303 | 1263 | return 0; |
|---|
| 1304 | 1264 | } |
|---|
| 1305 | 1265 | |
|---|
| .. | .. |
|---|
| 1333 | 1293 | struct octeon_soft_command *sc = (struct octeon_soft_command *)ptr; |
|---|
| 1334 | 1294 | struct oct_nic_stats_resp *resp = |
|---|
| 1335 | 1295 | (struct oct_nic_stats_resp *)sc->virtrptr; |
|---|
| 1336 | | - struct oct_nic_stats_ctrl *ctrl = |
|---|
| 1337 | | - (struct oct_nic_stats_ctrl *)sc->ctxptr; |
|---|
| 1338 | 1296 | struct nic_rx_stats *rsp_rstats = &resp->stats.fromwire; |
|---|
| 1339 | 1297 | struct nic_tx_stats *rsp_tstats = &resp->stats.fromhost; |
|---|
| 1340 | 1298 | struct nic_rx_stats *rstats = &oct_dev->link_stats.fromwire; |
|---|
| .. | .. |
|---|
| 1422 | 1380 | |
|---|
| 1423 | 1381 | resp->status = 1; |
|---|
| 1424 | 1382 | } else { |
|---|
| 1383 | + dev_err(&oct_dev->pci_dev->dev, "sc OPCODE_NIC_PORT_STATS command failed\n"); |
|---|
| 1425 | 1384 | resp->status = -1; |
|---|
| 1426 | 1385 | } |
|---|
| 1427 | | - complete(&ctrl->complete); |
|---|
| 1428 | 1386 | } |
|---|
| 1429 | 1387 | |
|---|
| 1430 | | -int octnet_get_link_stats(struct net_device *netdev) |
|---|
| 1388 | +static int lio_fetch_vf_stats(struct lio *lio) |
|---|
| 1431 | 1389 | { |
|---|
| 1432 | | - struct lio *lio = GET_LIO(netdev); |
|---|
| 1433 | 1390 | struct octeon_device *oct_dev = lio->oct_dev; |
|---|
| 1434 | 1391 | struct octeon_soft_command *sc; |
|---|
| 1435 | | - struct oct_nic_stats_ctrl *ctrl; |
|---|
| 1436 | | - struct oct_nic_stats_resp *resp; |
|---|
| 1392 | + struct oct_nic_vf_stats_resp *resp; |
|---|
| 1393 | + |
|---|
| 1437 | 1394 | int retval; |
|---|
| 1438 | 1395 | |
|---|
| 1439 | 1396 | /* Alloc soft command */ |
|---|
| 1440 | 1397 | sc = (struct octeon_soft_command *) |
|---|
| 1441 | 1398 | octeon_alloc_soft_command(oct_dev, |
|---|
| 1442 | 1399 | 0, |
|---|
| 1443 | | - sizeof(struct oct_nic_stats_resp), |
|---|
| 1444 | | - sizeof(struct octnic_ctrl_pkt)); |
|---|
| 1400 | + sizeof(struct oct_nic_vf_stats_resp), |
|---|
| 1401 | + 0); |
|---|
| 1445 | 1402 | |
|---|
| 1446 | | - if (!sc) |
|---|
| 1447 | | - return -ENOMEM; |
|---|
| 1403 | + if (!sc) { |
|---|
| 1404 | + dev_err(&oct_dev->pci_dev->dev, "Soft command allocation failed\n"); |
|---|
| 1405 | + retval = -ENOMEM; |
|---|
| 1406 | + goto lio_fetch_vf_stats_exit; |
|---|
| 1407 | + } |
|---|
| 1408 | + |
|---|
| 1409 | + resp = (struct oct_nic_vf_stats_resp *)sc->virtrptr; |
|---|
| 1410 | + memset(resp, 0, sizeof(struct oct_nic_vf_stats_resp)); |
|---|
| 1411 | + |
|---|
| 1412 | + init_completion(&sc->complete); |
|---|
| 1413 | + sc->sc_status = OCTEON_REQUEST_PENDING; |
|---|
| 1414 | + |
|---|
| 1415 | + sc->iq_no = lio->linfo.txpciq[0].s.q_no; |
|---|
| 1416 | + |
|---|
| 1417 | + octeon_prepare_soft_command(oct_dev, sc, OPCODE_NIC, |
|---|
| 1418 | + OPCODE_NIC_VF_PORT_STATS, 0, 0, 0); |
|---|
| 1419 | + |
|---|
| 1420 | + retval = octeon_send_soft_command(oct_dev, sc); |
|---|
| 1421 | + if (retval == IQ_SEND_FAILED) { |
|---|
| 1422 | + octeon_free_soft_command(oct_dev, sc); |
|---|
| 1423 | + goto lio_fetch_vf_stats_exit; |
|---|
| 1424 | + } |
|---|
| 1425 | + |
|---|
| 1426 | + retval = |
|---|
| 1427 | + wait_for_sc_completion_timeout(oct_dev, sc, |
|---|
| 1428 | + (2 * LIO_SC_MAX_TMO_MS)); |
|---|
| 1429 | + if (retval) { |
|---|
| 1430 | + dev_err(&oct_dev->pci_dev->dev, |
|---|
| 1431 | + "sc OPCODE_NIC_VF_PORT_STATS command failed\n"); |
|---|
| 1432 | + goto lio_fetch_vf_stats_exit; |
|---|
| 1433 | + } |
|---|
| 1434 | + |
|---|
| 1435 | + if (sc->sc_status != OCTEON_REQUEST_TIMEOUT && !resp->status) { |
|---|
| 1436 | + octeon_swap_8B_data((u64 *)&resp->spoofmac_cnt, |
|---|
| 1437 | + (sizeof(u64)) >> 3); |
|---|
| 1438 | + |
|---|
| 1439 | + if (resp->spoofmac_cnt != 0) { |
|---|
| 1440 | + dev_warn(&oct_dev->pci_dev->dev, |
|---|
| 1441 | + "%llu Spoofed packets detected\n", |
|---|
| 1442 | + resp->spoofmac_cnt); |
|---|
| 1443 | + } |
|---|
| 1444 | + } |
|---|
| 1445 | + WRITE_ONCE(sc->caller_is_done, 1); |
|---|
| 1446 | + |
|---|
| 1447 | +lio_fetch_vf_stats_exit: |
|---|
| 1448 | + return retval; |
|---|
| 1449 | +} |
|---|
| 1450 | + |
|---|
| 1451 | +void lio_fetch_stats(struct work_struct *work) |
|---|
| 1452 | +{ |
|---|
| 1453 | + struct cavium_wk *wk = (struct cavium_wk *)work; |
|---|
| 1454 | + struct lio *lio = wk->ctxptr; |
|---|
| 1455 | + struct octeon_device *oct_dev = lio->oct_dev; |
|---|
| 1456 | + struct octeon_soft_command *sc; |
|---|
| 1457 | + struct oct_nic_stats_resp *resp; |
|---|
| 1458 | + unsigned long time_in_jiffies; |
|---|
| 1459 | + int retval; |
|---|
| 1460 | + |
|---|
| 1461 | + if (OCTEON_CN23XX_PF(oct_dev)) { |
|---|
| 1462 | + /* report spoofchk every 2 seconds */ |
|---|
| 1463 | + if (!(oct_dev->vfstats_poll % LIO_VFSTATS_POLL) && |
|---|
| 1464 | + (oct_dev->fw_info.app_cap_flags & LIQUIDIO_SPOOFCHK_CAP) && |
|---|
| 1465 | + oct_dev->sriov_info.num_vfs_alloced) { |
|---|
| 1466 | + lio_fetch_vf_stats(lio); |
|---|
| 1467 | + } |
|---|
| 1468 | + |
|---|
| 1469 | + oct_dev->vfstats_poll++; |
|---|
| 1470 | + } |
|---|
| 1471 | + |
|---|
| 1472 | + /* Alloc soft command */ |
|---|
| 1473 | + sc = (struct octeon_soft_command *) |
|---|
| 1474 | + octeon_alloc_soft_command(oct_dev, |
|---|
| 1475 | + 0, |
|---|
| 1476 | + sizeof(struct oct_nic_stats_resp), |
|---|
| 1477 | + 0); |
|---|
| 1478 | + |
|---|
| 1479 | + if (!sc) { |
|---|
| 1480 | + dev_err(&oct_dev->pci_dev->dev, "Soft command allocation failed\n"); |
|---|
| 1481 | + goto lio_fetch_stats_exit; |
|---|
| 1482 | + } |
|---|
| 1448 | 1483 | |
|---|
| 1449 | 1484 | resp = (struct oct_nic_stats_resp *)sc->virtrptr; |
|---|
| 1450 | 1485 | memset(resp, 0, sizeof(struct oct_nic_stats_resp)); |
|---|
| 1451 | 1486 | |
|---|
| 1452 | | - ctrl = (struct oct_nic_stats_ctrl *)sc->ctxptr; |
|---|
| 1453 | | - memset(ctrl, 0, sizeof(struct oct_nic_stats_ctrl)); |
|---|
| 1454 | | - ctrl->netdev = netdev; |
|---|
| 1455 | | - init_completion(&ctrl->complete); |
|---|
| 1487 | + init_completion(&sc->complete); |
|---|
| 1488 | + sc->sc_status = OCTEON_REQUEST_PENDING; |
|---|
| 1456 | 1489 | |
|---|
| 1457 | 1490 | sc->iq_no = lio->linfo.txpciq[0].s.q_no; |
|---|
| 1458 | 1491 | |
|---|
| 1459 | 1492 | octeon_prepare_soft_command(oct_dev, sc, OPCODE_NIC, |
|---|
| 1460 | 1493 | OPCODE_NIC_PORT_STATS, 0, 0, 0); |
|---|
| 1461 | 1494 | |
|---|
| 1462 | | - sc->callback = octnet_nic_stats_callback; |
|---|
| 1463 | | - sc->callback_arg = sc; |
|---|
| 1464 | | - sc->wait_time = 500; /*in milli seconds*/ |
|---|
| 1465 | | - |
|---|
| 1466 | 1495 | retval = octeon_send_soft_command(oct_dev, sc); |
|---|
| 1467 | 1496 | if (retval == IQ_SEND_FAILED) { |
|---|
| 1468 | 1497 | octeon_free_soft_command(oct_dev, sc); |
|---|
| 1469 | | - return -EINVAL; |
|---|
| 1498 | + goto lio_fetch_stats_exit; |
|---|
| 1470 | 1499 | } |
|---|
| 1471 | 1500 | |
|---|
| 1472 | | - wait_for_completion_timeout(&ctrl->complete, msecs_to_jiffies(1000)); |
|---|
| 1473 | | - |
|---|
| 1474 | | - if (resp->status != 1) { |
|---|
| 1475 | | - octeon_free_soft_command(oct_dev, sc); |
|---|
| 1476 | | - |
|---|
| 1477 | | - return -EINVAL; |
|---|
| 1501 | + retval = wait_for_sc_completion_timeout(oct_dev, sc, |
|---|
| 1502 | + (2 * LIO_SC_MAX_TMO_MS)); |
|---|
| 1503 | + if (retval) { |
|---|
| 1504 | + dev_err(&oct_dev->pci_dev->dev, "sc OPCODE_NIC_PORT_STATS command failed\n"); |
|---|
| 1505 | + goto lio_fetch_stats_exit; |
|---|
| 1478 | 1506 | } |
|---|
| 1479 | 1507 | |
|---|
| 1480 | | - octeon_free_soft_command(oct_dev, sc); |
|---|
| 1508 | + octnet_nic_stats_callback(oct_dev, sc->sc_status, sc); |
|---|
| 1509 | + WRITE_ONCE(sc->caller_is_done, true); |
|---|
| 1481 | 1510 | |
|---|
| 1482 | | - return 0; |
|---|
| 1483 | | -} |
|---|
| 1511 | +lio_fetch_stats_exit: |
|---|
| 1512 | + time_in_jiffies = msecs_to_jiffies(LIQUIDIO_NDEV_STATS_POLL_TIME_MS); |
|---|
| 1513 | + if (ifstate_check(lio, LIO_IFSTATE_RUNNING)) |
|---|
| 1514 | + schedule_delayed_work(&lio->stats_wk.work, time_in_jiffies); |
|---|
| 1484 | 1515 | |
|---|
| 1485 | | -static void liquidio_nic_seapi_ctl_callback(struct octeon_device *oct, |
|---|
| 1486 | | - u32 status, |
|---|
| 1487 | | - void *buf) |
|---|
| 1488 | | -{ |
|---|
| 1489 | | - struct liquidio_nic_seapi_ctl_context *ctx; |
|---|
| 1490 | | - struct octeon_soft_command *sc = buf; |
|---|
| 1491 | | - |
|---|
| 1492 | | - ctx = sc->ctxptr; |
|---|
| 1493 | | - |
|---|
| 1494 | | - oct = lio_get_device(ctx->octeon_id); |
|---|
| 1495 | | - if (status) { |
|---|
| 1496 | | - dev_err(&oct->pci_dev->dev, "%s: instruction failed. Status: %llx\n", |
|---|
| 1497 | | - __func__, |
|---|
| 1498 | | - CVM_CAST64(status)); |
|---|
| 1499 | | - } |
|---|
| 1500 | | - ctx->status = status; |
|---|
| 1501 | | - complete(&ctx->complete); |
|---|
| 1516 | + return; |
|---|
| 1502 | 1517 | } |
|---|
| 1503 | 1518 | |
|---|
| 1504 | 1519 | int liquidio_set_speed(struct lio *lio, int speed) |
|---|
| 1505 | 1520 | { |
|---|
| 1506 | | - struct liquidio_nic_seapi_ctl_context *ctx; |
|---|
| 1507 | 1521 | struct octeon_device *oct = lio->oct_dev; |
|---|
| 1508 | 1522 | struct oct_nic_seapi_resp *resp; |
|---|
| 1509 | 1523 | struct octeon_soft_command *sc; |
|---|
| 1510 | 1524 | union octnet_cmd *ncmd; |
|---|
| 1511 | | - u32 ctx_size; |
|---|
| 1512 | 1525 | int retval; |
|---|
| 1513 | 1526 | u32 var; |
|---|
| 1514 | 1527 | |
|---|
| .. | .. |
|---|
| 1521 | 1534 | return -EOPNOTSUPP; |
|---|
| 1522 | 1535 | } |
|---|
| 1523 | 1536 | |
|---|
| 1524 | | - ctx_size = sizeof(struct liquidio_nic_seapi_ctl_context); |
|---|
| 1525 | 1537 | sc = octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE, |
|---|
| 1526 | 1538 | sizeof(struct oct_nic_seapi_resp), |
|---|
| 1527 | | - ctx_size); |
|---|
| 1539 | + 0); |
|---|
| 1528 | 1540 | if (!sc) |
|---|
| 1529 | 1541 | return -ENOMEM; |
|---|
| 1530 | 1542 | |
|---|
| 1531 | 1543 | ncmd = sc->virtdptr; |
|---|
| 1532 | | - ctx = sc->ctxptr; |
|---|
| 1533 | 1544 | resp = sc->virtrptr; |
|---|
| 1534 | 1545 | memset(resp, 0, sizeof(struct oct_nic_seapi_resp)); |
|---|
| 1535 | 1546 | |
|---|
| 1536 | | - ctx->octeon_id = lio_get_device_id(oct); |
|---|
| 1537 | | - ctx->status = 0; |
|---|
| 1538 | | - init_completion(&ctx->complete); |
|---|
| 1547 | + init_completion(&sc->complete); |
|---|
| 1548 | + sc->sc_status = OCTEON_REQUEST_PENDING; |
|---|
| 1539 | 1549 | |
|---|
| 1540 | 1550 | ncmd->u64 = 0; |
|---|
| 1541 | 1551 | ncmd->s.cmd = SEAPI_CMD_SPEED_SET; |
|---|
| .. | .. |
|---|
| 1548 | 1558 | octeon_prepare_soft_command(oct, sc, OPCODE_NIC, |
|---|
| 1549 | 1559 | OPCODE_NIC_UBOOT_CTL, 0, 0, 0); |
|---|
| 1550 | 1560 | |
|---|
| 1551 | | - sc->callback = liquidio_nic_seapi_ctl_callback; |
|---|
| 1552 | | - sc->callback_arg = sc; |
|---|
| 1553 | | - sc->wait_time = 5000; |
|---|
| 1554 | | - |
|---|
| 1555 | 1561 | retval = octeon_send_soft_command(oct, sc); |
|---|
| 1556 | 1562 | if (retval == IQ_SEND_FAILED) { |
|---|
| 1557 | 1563 | dev_info(&oct->pci_dev->dev, "Failed to send soft command\n"); |
|---|
| 1564 | + octeon_free_soft_command(oct, sc); |
|---|
| 1558 | 1565 | retval = -EBUSY; |
|---|
| 1559 | 1566 | } else { |
|---|
| 1560 | 1567 | /* Wait for response or timeout */ |
|---|
| 1561 | | - if (wait_for_completion_timeout(&ctx->complete, |
|---|
| 1562 | | - msecs_to_jiffies(10000)) == 0) { |
|---|
| 1563 | | - dev_err(&oct->pci_dev->dev, "%s: sc timeout\n", |
|---|
| 1564 | | - __func__); |
|---|
| 1565 | | - octeon_free_soft_command(oct, sc); |
|---|
| 1566 | | - return -EINTR; |
|---|
| 1567 | | - } |
|---|
| 1568 | + retval = wait_for_sc_completion_timeout(oct, sc, 0); |
|---|
| 1569 | + if (retval) |
|---|
| 1570 | + return retval; |
|---|
| 1568 | 1571 | |
|---|
| 1569 | 1572 | retval = resp->status; |
|---|
| 1570 | 1573 | |
|---|
| 1571 | 1574 | if (retval) { |
|---|
| 1572 | 1575 | dev_err(&oct->pci_dev->dev, "%s failed, retval=%d\n", |
|---|
| 1573 | 1576 | __func__, retval); |
|---|
| 1574 | | - octeon_free_soft_command(oct, sc); |
|---|
| 1577 | + WRITE_ONCE(sc->caller_is_done, true); |
|---|
| 1578 | + |
|---|
| 1575 | 1579 | return -EIO; |
|---|
| 1576 | 1580 | } |
|---|
| 1577 | 1581 | |
|---|
| .. | .. |
|---|
| 1583 | 1587 | } |
|---|
| 1584 | 1588 | |
|---|
| 1585 | 1589 | oct->speed_setting = var; |
|---|
| 1590 | + WRITE_ONCE(sc->caller_is_done, true); |
|---|
| 1586 | 1591 | } |
|---|
| 1587 | | - |
|---|
| 1588 | | - octeon_free_soft_command(oct, sc); |
|---|
| 1589 | 1592 | |
|---|
| 1590 | 1593 | return retval; |
|---|
| 1591 | 1594 | } |
|---|
| 1592 | 1595 | |
|---|
| 1593 | 1596 | int liquidio_get_speed(struct lio *lio) |
|---|
| 1594 | 1597 | { |
|---|
| 1595 | | - struct liquidio_nic_seapi_ctl_context *ctx; |
|---|
| 1596 | 1598 | struct octeon_device *oct = lio->oct_dev; |
|---|
| 1597 | 1599 | struct oct_nic_seapi_resp *resp; |
|---|
| 1598 | 1600 | struct octeon_soft_command *sc; |
|---|
| 1599 | 1601 | union octnet_cmd *ncmd; |
|---|
| 1600 | | - u32 ctx_size; |
|---|
| 1601 | 1602 | int retval; |
|---|
| 1602 | 1603 | |
|---|
| 1603 | | - ctx_size = sizeof(struct liquidio_nic_seapi_ctl_context); |
|---|
| 1604 | 1604 | sc = octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE, |
|---|
| 1605 | 1605 | sizeof(struct oct_nic_seapi_resp), |
|---|
| 1606 | | - ctx_size); |
|---|
| 1606 | + 0); |
|---|
| 1607 | 1607 | if (!sc) |
|---|
| 1608 | 1608 | return -ENOMEM; |
|---|
| 1609 | 1609 | |
|---|
| 1610 | 1610 | ncmd = sc->virtdptr; |
|---|
| 1611 | | - ctx = sc->ctxptr; |
|---|
| 1612 | 1611 | resp = sc->virtrptr; |
|---|
| 1613 | 1612 | memset(resp, 0, sizeof(struct oct_nic_seapi_resp)); |
|---|
| 1614 | 1613 | |
|---|
| 1615 | | - ctx->octeon_id = lio_get_device_id(oct); |
|---|
| 1616 | | - ctx->status = 0; |
|---|
| 1617 | | - init_completion(&ctx->complete); |
|---|
| 1614 | + init_completion(&sc->complete); |
|---|
| 1615 | + sc->sc_status = OCTEON_REQUEST_PENDING; |
|---|
| 1618 | 1616 | |
|---|
| 1619 | 1617 | ncmd->u64 = 0; |
|---|
| 1620 | 1618 | ncmd->s.cmd = SEAPI_CMD_SPEED_GET; |
|---|
| .. | .. |
|---|
| 1626 | 1624 | octeon_prepare_soft_command(oct, sc, OPCODE_NIC, |
|---|
| 1627 | 1625 | OPCODE_NIC_UBOOT_CTL, 0, 0, 0); |
|---|
| 1628 | 1626 | |
|---|
| 1629 | | - sc->callback = liquidio_nic_seapi_ctl_callback; |
|---|
| 1630 | | - sc->callback_arg = sc; |
|---|
| 1631 | | - sc->wait_time = 5000; |
|---|
| 1632 | | - |
|---|
| 1633 | 1627 | retval = octeon_send_soft_command(oct, sc); |
|---|
| 1634 | 1628 | if (retval == IQ_SEND_FAILED) { |
|---|
| 1635 | 1629 | dev_info(&oct->pci_dev->dev, "Failed to send soft command\n"); |
|---|
| 1636 | | - oct->no_speed_setting = 1; |
|---|
| 1637 | | - oct->speed_setting = 25; |
|---|
| 1638 | | - |
|---|
| 1639 | | - retval = -EBUSY; |
|---|
| 1630 | + octeon_free_soft_command(oct, sc); |
|---|
| 1631 | + retval = -EIO; |
|---|
| 1640 | 1632 | } else { |
|---|
| 1641 | | - if (wait_for_completion_timeout(&ctx->complete, |
|---|
| 1642 | | - msecs_to_jiffies(10000)) == 0) { |
|---|
| 1643 | | - dev_err(&oct->pci_dev->dev, "%s: sc timeout\n", |
|---|
| 1644 | | - __func__); |
|---|
| 1633 | + retval = wait_for_sc_completion_timeout(oct, sc, 0); |
|---|
| 1634 | + if (retval) |
|---|
| 1635 | + return retval; |
|---|
| 1645 | 1636 | |
|---|
| 1646 | | - oct->speed_setting = 25; |
|---|
| 1647 | | - oct->no_speed_setting = 1; |
|---|
| 1648 | | - |
|---|
| 1649 | | - octeon_free_soft_command(oct, sc); |
|---|
| 1650 | | - |
|---|
| 1651 | | - return -EINTR; |
|---|
| 1652 | | - } |
|---|
| 1653 | 1637 | retval = resp->status; |
|---|
| 1654 | 1638 | if (retval) { |
|---|
| 1655 | 1639 | dev_err(&oct->pci_dev->dev, |
|---|
| 1656 | 1640 | "%s failed retval=%d\n", __func__, retval); |
|---|
| 1657 | | - oct->no_speed_setting = 1; |
|---|
| 1658 | | - oct->speed_setting = 25; |
|---|
| 1659 | | - octeon_free_soft_command(oct, sc); |
|---|
| 1660 | 1641 | retval = -EIO; |
|---|
| 1661 | 1642 | } else { |
|---|
| 1662 | 1643 | u32 var; |
|---|
| .. | .. |
|---|
| 1664 | 1645 | var = be32_to_cpu((__force __be32)resp->speed); |
|---|
| 1665 | 1646 | oct->speed_setting = var; |
|---|
| 1666 | 1647 | if (var == 0xffff) { |
|---|
| 1667 | | - oct->no_speed_setting = 1; |
|---|
| 1668 | 1648 | /* unable to access boot variables |
|---|
| 1669 | 1649 | * get the default value based on the NIC type |
|---|
| 1670 | 1650 | */ |
|---|
| 1671 | | - oct->speed_setting = 25; |
|---|
| 1651 | + if (oct->subsystem_id == |
|---|
| 1652 | + OCTEON_CN2350_25GB_SUBSYS_ID || |
|---|
| 1653 | + oct->subsystem_id == |
|---|
| 1654 | + OCTEON_CN2360_25GB_SUBSYS_ID) { |
|---|
| 1655 | + oct->no_speed_setting = 1; |
|---|
| 1656 | + oct->speed_setting = 25; |
|---|
| 1657 | + } else { |
|---|
| 1658 | + oct->speed_setting = 10; |
|---|
| 1659 | + } |
|---|
| 1672 | 1660 | } |
|---|
| 1661 | + |
|---|
| 1673 | 1662 | } |
|---|
| 1663 | + WRITE_ONCE(sc->caller_is_done, true); |
|---|
| 1674 | 1664 | } |
|---|
| 1675 | 1665 | |
|---|
| 1676 | | - octeon_free_soft_command(oct, sc); |
|---|
| 1666 | + return retval; |
|---|
| 1667 | +} |
|---|
| 1668 | + |
|---|
| 1669 | +int liquidio_set_fec(struct lio *lio, int on_off) |
|---|
| 1670 | +{ |
|---|
| 1671 | + struct oct_nic_seapi_resp *resp; |
|---|
| 1672 | + struct octeon_soft_command *sc; |
|---|
| 1673 | + struct octeon_device *oct; |
|---|
| 1674 | + union octnet_cmd *ncmd; |
|---|
| 1675 | + int retval; |
|---|
| 1676 | + u32 var; |
|---|
| 1677 | + |
|---|
| 1678 | + oct = lio->oct_dev; |
|---|
| 1679 | + |
|---|
| 1680 | + if (oct->props[lio->ifidx].fec == on_off) |
|---|
| 1681 | + return 0; |
|---|
| 1682 | + |
|---|
| 1683 | + if (!OCTEON_CN23XX_PF(oct)) { |
|---|
| 1684 | + dev_err(&oct->pci_dev->dev, "%s: SET FEC only for PF\n", |
|---|
| 1685 | + __func__); |
|---|
| 1686 | + return -1; |
|---|
| 1687 | + } |
|---|
| 1688 | + |
|---|
| 1689 | + if (oct->speed_boot != 25) { |
|---|
| 1690 | + dev_err(&oct->pci_dev->dev, |
|---|
| 1691 | + "Set FEC only when link speed is 25G during insmod\n"); |
|---|
| 1692 | + return -1; |
|---|
| 1693 | + } |
|---|
| 1694 | + |
|---|
| 1695 | + sc = octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE, |
|---|
| 1696 | + sizeof(struct oct_nic_seapi_resp), 0); |
|---|
| 1697 | + if (!sc) { |
|---|
| 1698 | + dev_err(&oct->pci_dev->dev, |
|---|
| 1699 | + "Failed to allocate soft command\n"); |
|---|
| 1700 | + return -ENOMEM; |
|---|
| 1701 | + } |
|---|
| 1702 | + |
|---|
| 1703 | + ncmd = sc->virtdptr; |
|---|
| 1704 | + resp = sc->virtrptr; |
|---|
| 1705 | + memset(resp, 0, sizeof(struct oct_nic_seapi_resp)); |
|---|
| 1706 | + |
|---|
| 1707 | + init_completion(&sc->complete); |
|---|
| 1708 | + sc->sc_status = OCTEON_REQUEST_PENDING; |
|---|
| 1709 | + |
|---|
| 1710 | + ncmd->u64 = 0; |
|---|
| 1711 | + ncmd->s.cmd = SEAPI_CMD_FEC_SET; |
|---|
| 1712 | + ncmd->s.param1 = on_off; |
|---|
| 1713 | + /* SEAPI_CMD_FEC_DISABLE(0) or SEAPI_CMD_FEC_RS(1) */ |
|---|
| 1714 | + |
|---|
| 1715 | + octeon_swap_8B_data((u64 *)ncmd, (OCTNET_CMD_SIZE >> 3)); |
|---|
| 1716 | + |
|---|
| 1717 | + sc->iq_no = lio->linfo.txpciq[0].s.q_no; |
|---|
| 1718 | + |
|---|
| 1719 | + octeon_prepare_soft_command(oct, sc, OPCODE_NIC, |
|---|
| 1720 | + OPCODE_NIC_UBOOT_CTL, 0, 0, 0); |
|---|
| 1721 | + |
|---|
| 1722 | + retval = octeon_send_soft_command(oct, sc); |
|---|
| 1723 | + if (retval == IQ_SEND_FAILED) { |
|---|
| 1724 | + dev_info(&oct->pci_dev->dev, "Failed to send soft command\n"); |
|---|
| 1725 | + octeon_free_soft_command(oct, sc); |
|---|
| 1726 | + return -EIO; |
|---|
| 1727 | + } |
|---|
| 1728 | + |
|---|
| 1729 | + retval = wait_for_sc_completion_timeout(oct, sc, 0); |
|---|
| 1730 | + if (retval) |
|---|
| 1731 | + return (-EIO); |
|---|
| 1732 | + |
|---|
| 1733 | + var = be32_to_cpu(resp->fec_setting); |
|---|
| 1734 | + resp->fec_setting = var; |
|---|
| 1735 | + if (var != on_off) { |
|---|
| 1736 | + dev_err(&oct->pci_dev->dev, |
|---|
| 1737 | + "Setting failed fec= %x, expect %x\n", |
|---|
| 1738 | + var, on_off); |
|---|
| 1739 | + oct->props[lio->ifidx].fec = var; |
|---|
| 1740 | + if (resp->fec_setting == SEAPI_CMD_FEC_SET_RS) |
|---|
| 1741 | + oct->props[lio->ifidx].fec = 1; |
|---|
| 1742 | + else |
|---|
| 1743 | + oct->props[lio->ifidx].fec = 0; |
|---|
| 1744 | + } |
|---|
| 1745 | + |
|---|
| 1746 | + WRITE_ONCE(sc->caller_is_done, true); |
|---|
| 1747 | + |
|---|
| 1748 | + if (oct->props[lio->ifidx].fec != |
|---|
| 1749 | + oct->props[lio->ifidx].fec_boot) { |
|---|
| 1750 | + dev_dbg(&oct->pci_dev->dev, |
|---|
| 1751 | + "Reload driver to change fec to %s\n", |
|---|
| 1752 | + oct->props[lio->ifidx].fec ? "on" : "off"); |
|---|
| 1753 | + } |
|---|
| 1754 | + |
|---|
| 1755 | + return retval; |
|---|
| 1756 | +} |
|---|
| 1757 | + |
|---|
| 1758 | +int liquidio_get_fec(struct lio *lio) |
|---|
| 1759 | +{ |
|---|
| 1760 | + struct oct_nic_seapi_resp *resp; |
|---|
| 1761 | + struct octeon_soft_command *sc; |
|---|
| 1762 | + struct octeon_device *oct; |
|---|
| 1763 | + union octnet_cmd *ncmd; |
|---|
| 1764 | + int retval; |
|---|
| 1765 | + u32 var; |
|---|
| 1766 | + |
|---|
| 1767 | + oct = lio->oct_dev; |
|---|
| 1768 | + |
|---|
| 1769 | + sc = octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE, |
|---|
| 1770 | + sizeof(struct oct_nic_seapi_resp), 0); |
|---|
| 1771 | + if (!sc) |
|---|
| 1772 | + return -ENOMEM; |
|---|
| 1773 | + |
|---|
| 1774 | + ncmd = sc->virtdptr; |
|---|
| 1775 | + resp = sc->virtrptr; |
|---|
| 1776 | + memset(resp, 0, sizeof(struct oct_nic_seapi_resp)); |
|---|
| 1777 | + |
|---|
| 1778 | + init_completion(&sc->complete); |
|---|
| 1779 | + sc->sc_status = OCTEON_REQUEST_PENDING; |
|---|
| 1780 | + |
|---|
| 1781 | + ncmd->u64 = 0; |
|---|
| 1782 | + ncmd->s.cmd = SEAPI_CMD_FEC_GET; |
|---|
| 1783 | + |
|---|
| 1784 | + octeon_swap_8B_data((u64 *)ncmd, (OCTNET_CMD_SIZE >> 3)); |
|---|
| 1785 | + |
|---|
| 1786 | + sc->iq_no = lio->linfo.txpciq[0].s.q_no; |
|---|
| 1787 | + |
|---|
| 1788 | + octeon_prepare_soft_command(oct, sc, OPCODE_NIC, |
|---|
| 1789 | + OPCODE_NIC_UBOOT_CTL, 0, 0, 0); |
|---|
| 1790 | + |
|---|
| 1791 | + retval = octeon_send_soft_command(oct, sc); |
|---|
| 1792 | + if (retval == IQ_SEND_FAILED) { |
|---|
| 1793 | + dev_info(&oct->pci_dev->dev, |
|---|
| 1794 | + "%s: Failed to send soft command\n", __func__); |
|---|
| 1795 | + octeon_free_soft_command(oct, sc); |
|---|
| 1796 | + return -EIO; |
|---|
| 1797 | + } |
|---|
| 1798 | + |
|---|
| 1799 | + retval = wait_for_sc_completion_timeout(oct, sc, 0); |
|---|
| 1800 | + if (retval) |
|---|
| 1801 | + return retval; |
|---|
| 1802 | + |
|---|
| 1803 | + var = be32_to_cpu(resp->fec_setting); |
|---|
| 1804 | + resp->fec_setting = var; |
|---|
| 1805 | + if (resp->fec_setting == SEAPI_CMD_FEC_SET_RS) |
|---|
| 1806 | + oct->props[lio->ifidx].fec = 1; |
|---|
| 1807 | + else |
|---|
| 1808 | + oct->props[lio->ifidx].fec = 0; |
|---|
| 1809 | + |
|---|
| 1810 | + WRITE_ONCE(sc->caller_is_done, true); |
|---|
| 1811 | + |
|---|
| 1812 | + if (oct->props[lio->ifidx].fec != |
|---|
| 1813 | + oct->props[lio->ifidx].fec_boot) { |
|---|
| 1814 | + dev_dbg(&oct->pci_dev->dev, |
|---|
| 1815 | + "Reload driver to change fec to %s\n", |
|---|
| 1816 | + oct->props[lio->ifidx].fec ? "on" : "off"); |
|---|
| 1817 | + } |
|---|
| 1677 | 1818 | |
|---|
| 1678 | 1819 | return retval; |
|---|
| 1679 | 1820 | } |
|---|