.. | .. |
---|
32 | 32 | MODULE_AUTHOR("Cavium Networks, <support@cavium.com>"); |
---|
33 | 33 | MODULE_DESCRIPTION("Cavium LiquidIO Intelligent Server Adapter Virtual Function Driver"); |
---|
34 | 34 | MODULE_LICENSE("GPL"); |
---|
35 | | -MODULE_VERSION(LIQUIDIO_VERSION); |
---|
36 | 35 | |
---|
37 | 36 | static int debug = -1; |
---|
38 | 37 | module_param(debug, int, 0644); |
---|
39 | 38 | MODULE_PARM_DESC(debug, "NETIF_MSG debug bits"); |
---|
40 | 39 | |
---|
41 | 40 | #define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK) |
---|
42 | | - |
---|
43 | | -struct liquidio_rx_ctl_context { |
---|
44 | | - int octeon_id; |
---|
45 | | - |
---|
46 | | - wait_queue_head_t wc; |
---|
47 | | - |
---|
48 | | - int cond; |
---|
49 | | -}; |
---|
50 | 41 | |
---|
51 | 42 | struct oct_timestamp_resp { |
---|
52 | 43 | u64 rh; |
---|
.. | .. |
---|
108 | 99 | } |
---|
109 | 100 | |
---|
110 | 101 | /** |
---|
111 | | - * \brief Cause device to go quiet so it can be safely removed/reset/etc |
---|
112 | | - * @param oct Pointer to Octeon device |
---|
| 102 | + * pcierror_quiesce_device - Cause device to go quiet so it can be safely removed/reset/etc |
---|
| 103 | + * @oct: Pointer to Octeon device |
---|
113 | 104 | */ |
---|
114 | 105 | static void pcierror_quiesce_device(struct octeon_device *oct) |
---|
115 | 106 | { |
---|
.. | .. |
---|
152 | 143 | } |
---|
153 | 144 | |
---|
154 | 145 | /** |
---|
155 | | - * \brief Cleanup PCI AER uncorrectable error status |
---|
156 | | - * @param dev Pointer to PCI device |
---|
| 146 | + * cleanup_aer_uncorrect_error_status - Cleanup PCI AER uncorrectable error status |
---|
| 147 | + * @dev: Pointer to PCI device |
---|
157 | 148 | */ |
---|
158 | 149 | static void cleanup_aer_uncorrect_error_status(struct pci_dev *dev) |
---|
159 | 150 | { |
---|
.. | .. |
---|
172 | 163 | } |
---|
173 | 164 | |
---|
174 | 165 | /** |
---|
175 | | - * \brief Stop all PCI IO to a given device |
---|
176 | | - * @param dev Pointer to Octeon device |
---|
| 166 | + * stop_pci_io - Stop all PCI IO to a given device |
---|
| 167 | + * @oct: Pointer to Octeon device |
---|
177 | 168 | */ |
---|
178 | 169 | static void stop_pci_io(struct octeon_device *oct) |
---|
179 | 170 | { |
---|
.. | .. |
---|
214 | 205 | } |
---|
215 | 206 | |
---|
216 | 207 | /** |
---|
217 | | - * \brief called when PCI error is detected |
---|
218 | | - * @param pdev Pointer to PCI device |
---|
219 | | - * @param state The current pci connection state |
---|
| 208 | + * liquidio_pcie_error_detected - called when PCI error is detected |
---|
| 209 | + * @pdev: Pointer to PCI device |
---|
| 210 | + * @state: The current pci connection state |
---|
220 | 211 | * |
---|
221 | 212 | * This function is called after a PCI bus error affecting |
---|
222 | 213 | * this device has been detected. |
---|
.. | .. |
---|
265 | 256 | }; |
---|
266 | 257 | |
---|
267 | 258 | /** |
---|
268 | | - * \brief Print link information |
---|
269 | | - * @param netdev network device |
---|
| 259 | + * print_link_info - Print link information |
---|
| 260 | + * @netdev: network device |
---|
270 | 261 | */ |
---|
271 | 262 | static void print_link_info(struct net_device *netdev) |
---|
272 | 263 | { |
---|
.. | .. |
---|
287 | 278 | } |
---|
288 | 279 | |
---|
289 | 280 | /** |
---|
290 | | - * \brief Routine to notify MTU change |
---|
291 | | - * @param work work_struct data structure |
---|
| 281 | + * octnet_link_status_change - Routine to notify MTU change |
---|
| 282 | + * @work: work_struct data structure |
---|
292 | 283 | */ |
---|
293 | 284 | static void octnet_link_status_change(struct work_struct *work) |
---|
294 | 285 | { |
---|
.. | .. |
---|
305 | 296 | } |
---|
306 | 297 | |
---|
307 | 298 | /** |
---|
308 | | - * \brief Sets up the mtu status change work |
---|
309 | | - * @param netdev network device |
---|
| 299 | + * setup_link_status_change_wq - Sets up the mtu status change work |
---|
| 300 | + * @netdev: network device |
---|
310 | 301 | */ |
---|
311 | 302 | static int setup_link_status_change_wq(struct net_device *netdev) |
---|
312 | 303 | { |
---|
.. | .. |
---|
337 | 328 | } |
---|
338 | 329 | |
---|
339 | 330 | /** |
---|
340 | | - * \brief Update link status |
---|
341 | | - * @param netdev network device |
---|
342 | | - * @param ls link status structure |
---|
| 331 | + * update_link_status - Update link status |
---|
| 332 | + * @netdev: network device |
---|
| 333 | + * @ls: link status structure |
---|
343 | 334 | * |
---|
344 | 335 | * Called on receipt of a link status response from the core application to |
---|
345 | 336 | * update each interface's link status. |
---|
.. | .. |
---|
383 | 374 | } |
---|
384 | 375 | |
---|
385 | 376 | /** |
---|
386 | | - * \brief PCI probe handler |
---|
387 | | - * @param pdev PCI device structure |
---|
388 | | - * @param ent unused |
---|
| 377 | + * liquidio_vf_probe - PCI probe handler |
---|
| 378 | + * @pdev: PCI device structure |
---|
| 379 | + * @ent: unused |
---|
389 | 380 | */ |
---|
390 | 381 | static int |
---|
391 | 382 | liquidio_vf_probe(struct pci_dev *pdev, |
---|
392 | | - const struct pci_device_id *ent __attribute__((unused))) |
---|
| 383 | + const struct pci_device_id __maybe_unused *ent) |
---|
393 | 384 | { |
---|
394 | 385 | struct octeon_device *oct_dev = NULL; |
---|
395 | 386 | |
---|
.. | .. |
---|
425 | 416 | } |
---|
426 | 417 | |
---|
427 | 418 | /** |
---|
428 | | - * \brief PCI FLR for each Octeon device. |
---|
429 | | - * @param oct octeon device |
---|
| 419 | + * octeon_pci_flr - PCI FLR for each Octeon device. |
---|
| 420 | + * @oct: octeon device |
---|
430 | 421 | */ |
---|
431 | 422 | static void octeon_pci_flr(struct octeon_device *oct) |
---|
432 | 423 | { |
---|
.. | .. |
---|
446 | 437 | } |
---|
447 | 438 | |
---|
448 | 439 | /** |
---|
449 | | - *\brief Destroy resources associated with octeon device |
---|
450 | | - * @param pdev PCI device structure |
---|
451 | | - * @param ent unused |
---|
| 440 | + * octeon_destroy_resources - Destroy resources associated with octeon device |
---|
| 441 | + * @oct: octeon device |
---|
452 | 442 | */ |
---|
453 | 443 | static void octeon_destroy_resources(struct octeon_device *oct) |
---|
454 | 444 | { |
---|
| 445 | + struct octeon_device_priv *oct_priv = |
---|
| 446 | + (struct octeon_device_priv *)oct->priv; |
---|
455 | 447 | struct msix_entry *msix_entries; |
---|
456 | 448 | int i; |
---|
457 | 449 | |
---|
.. | .. |
---|
467 | 459 | |
---|
468 | 460 | schedule_timeout_uninterruptible(HZ / 10); |
---|
469 | 461 | |
---|
470 | | - /* fallthrough */ |
---|
| 462 | + fallthrough; |
---|
471 | 463 | case OCT_DEV_HOST_OK: |
---|
472 | | - /* fallthrough */ |
---|
473 | 464 | case OCT_DEV_IO_QUEUES_DONE: |
---|
474 | | - if (wait_for_pending_requests(oct)) |
---|
475 | | - dev_err(&oct->pci_dev->dev, "There were pending requests\n"); |
---|
476 | | - |
---|
477 | 465 | if (lio_wait_for_instr_fetch(oct)) |
---|
478 | 466 | dev_err(&oct->pci_dev->dev, "IQ had pending instructions\n"); |
---|
| 467 | + |
---|
| 468 | + if (wait_for_pending_requests(oct)) |
---|
| 469 | + dev_err(&oct->pci_dev->dev, "There were pending requests\n"); |
---|
479 | 470 | |
---|
480 | 471 | /* Disable the input and output queues now. No more packets will |
---|
481 | 472 | * arrive from Octeon, but we should wait for all packet |
---|
.. | .. |
---|
485 | 476 | |
---|
486 | 477 | if (lio_wait_for_oq_pkts(oct)) |
---|
487 | 478 | dev_err(&oct->pci_dev->dev, "OQ had pending packets\n"); |
---|
488 | | - /* fall through */ |
---|
| 479 | + |
---|
| 480 | + /* Force all requests waiting to be fetched by OCTEON to |
---|
| 481 | + * complete. |
---|
| 482 | + */ |
---|
| 483 | + for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) { |
---|
| 484 | + struct octeon_instr_queue *iq; |
---|
| 485 | + |
---|
| 486 | + if (!(oct->io_qmask.iq & BIT_ULL(i))) |
---|
| 487 | + continue; |
---|
| 488 | + iq = oct->instr_queue[i]; |
---|
| 489 | + |
---|
| 490 | + if (atomic_read(&iq->instr_pending)) { |
---|
| 491 | + spin_lock_bh(&iq->lock); |
---|
| 492 | + iq->fill_cnt = 0; |
---|
| 493 | + iq->octeon_read_index = iq->host_write_index; |
---|
| 494 | + iq->stats.instr_processed += |
---|
| 495 | + atomic_read(&iq->instr_pending); |
---|
| 496 | + lio_process_iq_request_list(oct, iq, 0); |
---|
| 497 | + spin_unlock_bh(&iq->lock); |
---|
| 498 | + } |
---|
| 499 | + } |
---|
| 500 | + |
---|
| 501 | + lio_process_ordered_list(oct, 1); |
---|
| 502 | + octeon_free_sc_done_list(oct); |
---|
| 503 | + octeon_free_sc_zombie_list(oct); |
---|
| 504 | + |
---|
| 505 | + fallthrough; |
---|
489 | 506 | case OCT_DEV_INTR_SET_DONE: |
---|
490 | 507 | /* Disable interrupts */ |
---|
491 | 508 | oct->fn_list.disable_interrupt(oct, OCTEON_ALL_INTR); |
---|
.. | .. |
---|
514 | 531 | else |
---|
515 | 532 | cn23xx_vf_ask_pf_to_do_flr(oct); |
---|
516 | 533 | |
---|
517 | | - /* fallthrough */ |
---|
| 534 | + fallthrough; |
---|
518 | 535 | case OCT_DEV_MSIX_ALLOC_VECTOR_DONE: |
---|
519 | 536 | octeon_free_ioq_vector(oct); |
---|
520 | 537 | |
---|
521 | | - /* fallthrough */ |
---|
| 538 | + fallthrough; |
---|
522 | 539 | case OCT_DEV_MBOX_SETUP_DONE: |
---|
523 | 540 | oct->fn_list.free_mbox(oct); |
---|
524 | 541 | |
---|
525 | | - /* fallthrough */ |
---|
| 542 | + fallthrough; |
---|
526 | 543 | case OCT_DEV_IN_RESET: |
---|
527 | 544 | case OCT_DEV_DROQ_INIT_DONE: |
---|
528 | 545 | mdelay(100); |
---|
.. | .. |
---|
532 | 549 | octeon_delete_droq(oct, i); |
---|
533 | 550 | } |
---|
534 | 551 | |
---|
535 | | - /* fallthrough */ |
---|
| 552 | + fallthrough; |
---|
536 | 553 | case OCT_DEV_RESP_LIST_INIT_DONE: |
---|
537 | 554 | octeon_delete_response_list(oct); |
---|
538 | 555 | |
---|
539 | | - /* fallthrough */ |
---|
| 556 | + fallthrough; |
---|
540 | 557 | case OCT_DEV_INSTR_QUEUE_INIT_DONE: |
---|
541 | 558 | for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) { |
---|
542 | 559 | if (!(oct->io_qmask.iq & BIT_ULL(i))) |
---|
.. | .. |
---|
544 | 561 | octeon_delete_instr_queue(oct, i); |
---|
545 | 562 | } |
---|
546 | 563 | |
---|
547 | | - /* fallthrough */ |
---|
| 564 | + fallthrough; |
---|
548 | 565 | case OCT_DEV_SC_BUFF_POOL_INIT_DONE: |
---|
549 | 566 | octeon_free_sc_buffer_pool(oct); |
---|
550 | 567 | |
---|
551 | | - /* fallthrough */ |
---|
| 568 | + fallthrough; |
---|
552 | 569 | case OCT_DEV_DISPATCH_INIT_DONE: |
---|
553 | 570 | octeon_delete_dispatch_list(oct); |
---|
554 | 571 | cancel_delayed_work_sync(&oct->nic_poll_work.work); |
---|
555 | 572 | |
---|
556 | | - /* fallthrough */ |
---|
| 573 | + fallthrough; |
---|
557 | 574 | case OCT_DEV_PCI_MAP_DONE: |
---|
558 | 575 | octeon_unmap_pci_barx(oct, 0); |
---|
559 | 576 | octeon_unmap_pci_barx(oct, 1); |
---|
560 | 577 | |
---|
561 | | - /* fallthrough */ |
---|
| 578 | + fallthrough; |
---|
562 | 579 | case OCT_DEV_PCI_ENABLE_DONE: |
---|
563 | 580 | pci_clear_master(oct->pci_dev); |
---|
564 | 581 | /* Disable the device, releasing the PCI INT */ |
---|
565 | 582 | pci_disable_device(oct->pci_dev); |
---|
566 | 583 | |
---|
567 | | - /* fallthrough */ |
---|
| 584 | + fallthrough; |
---|
568 | 585 | case OCT_DEV_BEGIN_STATE: |
---|
569 | 586 | /* Nothing to be done here either */ |
---|
570 | 587 | break; |
---|
571 | 588 | } |
---|
| 589 | + |
---|
| 590 | + tasklet_kill(&oct_priv->droq_tasklet); |
---|
572 | 591 | } |
---|
573 | 592 | |
---|
574 | 593 | /** |
---|
575 | | - * \brief Callback for rx ctrl |
---|
576 | | - * @param status status of request |
---|
577 | | - * @param buf pointer to resp structure |
---|
| 594 | + * send_rx_ctrl_cmd - Send Rx control command |
---|
| 595 | + * @lio: per-network private data |
---|
| 596 | + * @start_stop: whether to start or stop |
---|
578 | 597 | */ |
---|
579 | | -static void rx_ctl_callback(struct octeon_device *oct, |
---|
580 | | - u32 status, void *buf) |
---|
581 | | -{ |
---|
582 | | - struct octeon_soft_command *sc = (struct octeon_soft_command *)buf; |
---|
583 | | - struct liquidio_rx_ctl_context *ctx; |
---|
584 | | - |
---|
585 | | - ctx = (struct liquidio_rx_ctl_context *)sc->ctxptr; |
---|
586 | | - |
---|
587 | | - oct = lio_get_device(ctx->octeon_id); |
---|
588 | | - if (status) |
---|
589 | | - dev_err(&oct->pci_dev->dev, "rx ctl instruction failed. Status: %llx\n", |
---|
590 | | - CVM_CAST64(status)); |
---|
591 | | - WRITE_ONCE(ctx->cond, 1); |
---|
592 | | - |
---|
593 | | - /* This barrier is required to be sure that the response has been |
---|
594 | | - * written fully before waking up the handler |
---|
595 | | - */ |
---|
596 | | - wmb(); |
---|
597 | | - |
---|
598 | | - wake_up_interruptible(&ctx->wc); |
---|
599 | | -} |
---|
600 | | - |
---|
601 | | -/** |
---|
602 | | - * \brief Send Rx control command |
---|
603 | | - * @param lio per-network private data |
---|
604 | | - * @param start_stop whether to start or stop |
---|
605 | | - */ |
---|
606 | | -static void send_rx_ctrl_cmd(struct lio *lio, int start_stop) |
---|
| 598 | +static int send_rx_ctrl_cmd(struct lio *lio, int start_stop) |
---|
607 | 599 | { |
---|
608 | 600 | struct octeon_device *oct = (struct octeon_device *)lio->oct_dev; |
---|
609 | | - int ctx_size = sizeof(struct liquidio_rx_ctl_context); |
---|
610 | | - struct liquidio_rx_ctl_context *ctx; |
---|
611 | 601 | struct octeon_soft_command *sc; |
---|
612 | 602 | union octnet_cmd *ncmd; |
---|
613 | 603 | int retval; |
---|
614 | 604 | |
---|
615 | 605 | if (oct->props[lio->ifidx].rx_on == start_stop) |
---|
616 | | - return; |
---|
| 606 | + return 0; |
---|
617 | 607 | |
---|
618 | 608 | sc = (struct octeon_soft_command *) |
---|
619 | 609 | octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE, |
---|
620 | | - 16, ctx_size); |
---|
| 610 | + 16, 0); |
---|
| 611 | + if (!sc) { |
---|
| 612 | + netif_info(lio, rx_err, lio->netdev, |
---|
| 613 | + "Failed to allocate octeon_soft_command struct\n"); |
---|
| 614 | + return -ENOMEM; |
---|
| 615 | + } |
---|
621 | 616 | |
---|
622 | 617 | ncmd = (union octnet_cmd *)sc->virtdptr; |
---|
623 | | - ctx = (struct liquidio_rx_ctl_context *)sc->ctxptr; |
---|
624 | | - |
---|
625 | | - WRITE_ONCE(ctx->cond, 0); |
---|
626 | | - ctx->octeon_id = lio_get_device_id(oct); |
---|
627 | | - init_waitqueue_head(&ctx->wc); |
---|
628 | 618 | |
---|
629 | 619 | ncmd->u64 = 0; |
---|
630 | 620 | ncmd->s.cmd = OCTNET_CMD_RX_CTL; |
---|
.. | .. |
---|
637 | 627 | octeon_prepare_soft_command(oct, sc, OPCODE_NIC, |
---|
638 | 628 | OPCODE_NIC_CMD, 0, 0, 0); |
---|
639 | 629 | |
---|
640 | | - sc->callback = rx_ctl_callback; |
---|
641 | | - sc->callback_arg = sc; |
---|
642 | | - sc->wait_time = 5000; |
---|
| 630 | + init_completion(&sc->complete); |
---|
| 631 | + sc->sc_status = OCTEON_REQUEST_PENDING; |
---|
643 | 632 | |
---|
644 | 633 | retval = octeon_send_soft_command(oct, sc); |
---|
645 | 634 | if (retval == IQ_SEND_FAILED) { |
---|
646 | 635 | netif_info(lio, rx_err, lio->netdev, "Failed to send RX Control message\n"); |
---|
| 636 | + octeon_free_soft_command(oct, sc); |
---|
647 | 637 | } else { |
---|
648 | 638 | /* Sleep on a wait queue till the cond flag indicates that the |
---|
649 | 639 | * response arrived or timed-out. |
---|
650 | 640 | */ |
---|
651 | | - if (sleep_cond(&ctx->wc, &ctx->cond) == -EINTR) |
---|
652 | | - return; |
---|
| 641 | + retval = wait_for_sc_completion_timeout(oct, sc, 0); |
---|
| 642 | + if (retval) |
---|
| 643 | + return retval; |
---|
| 644 | + |
---|
653 | 645 | oct->props[lio->ifidx].rx_on = start_stop; |
---|
| 646 | + WRITE_ONCE(sc->caller_is_done, true); |
---|
654 | 647 | } |
---|
655 | 648 | |
---|
656 | | - octeon_free_soft_command(oct, sc); |
---|
| 649 | + return retval; |
---|
657 | 650 | } |
---|
658 | 651 | |
---|
659 | 652 | /** |
---|
660 | | - * \brief Destroy NIC device interface |
---|
661 | | - * @param oct octeon device |
---|
662 | | - * @param ifidx which interface to destroy |
---|
| 653 | + * liquidio_destroy_nic_device - Destroy NIC device interface |
---|
| 654 | + * @oct: octeon device |
---|
| 655 | + * @ifidx: which interface to destroy |
---|
663 | 656 | * |
---|
664 | 657 | * Cleanup associated with each interface for an Octeon device when NIC |
---|
665 | 658 | * module is being unloaded or if initialization fails during load. |
---|
.. | .. |
---|
667 | 660 | static void liquidio_destroy_nic_device(struct octeon_device *oct, int ifidx) |
---|
668 | 661 | { |
---|
669 | 662 | struct net_device *netdev = oct->props[ifidx].netdev; |
---|
| 663 | + struct octeon_device_priv *oct_priv = |
---|
| 664 | + (struct octeon_device_priv *)oct->priv; |
---|
670 | 665 | struct napi_struct *napi, *n; |
---|
671 | 666 | struct lio *lio; |
---|
672 | 667 | |
---|
.. | .. |
---|
696 | 691 | list_for_each_entry_safe(napi, n, &netdev->napi_list, dev_list) |
---|
697 | 692 | netif_napi_del(napi); |
---|
698 | 693 | |
---|
| 694 | + tasklet_enable(&oct_priv->droq_tasklet); |
---|
| 695 | + |
---|
699 | 696 | if (atomic_read(&lio->ifstate) & LIO_IFSTATE_REGISTERED) |
---|
700 | 697 | unregister_netdev(netdev); |
---|
701 | 698 | |
---|
.. | .. |
---|
713 | 710 | } |
---|
714 | 711 | |
---|
715 | 712 | /** |
---|
716 | | - * \brief Stop complete NIC functionality |
---|
717 | | - * @param oct octeon device |
---|
| 713 | + * liquidio_stop_nic_module - Stop complete NIC functionality |
---|
| 714 | + * @oct: octeon device |
---|
718 | 715 | */ |
---|
719 | 716 | static int liquidio_stop_nic_module(struct octeon_device *oct) |
---|
720 | 717 | { |
---|
.. | .. |
---|
746 | 743 | } |
---|
747 | 744 | |
---|
748 | 745 | /** |
---|
749 | | - * \brief Cleans up resources at unload time |
---|
750 | | - * @param pdev PCI device structure |
---|
| 746 | + * liquidio_vf_remove - Cleans up resources at unload time |
---|
| 747 | + * @pdev: PCI device structure |
---|
751 | 748 | */ |
---|
752 | 749 | static void liquidio_vf_remove(struct pci_dev *pdev) |
---|
753 | 750 | { |
---|
.. | .. |
---|
772 | 769 | } |
---|
773 | 770 | |
---|
774 | 771 | /** |
---|
775 | | - * \brief PCI initialization for each Octeon device. |
---|
776 | | - * @param oct octeon device |
---|
| 772 | + * octeon_pci_os_setup - PCI initialization for each Octeon device. |
---|
| 773 | + * @oct: octeon device |
---|
777 | 774 | */ |
---|
778 | 775 | static int octeon_pci_os_setup(struct octeon_device *oct) |
---|
779 | 776 | { |
---|
.. | .. |
---|
801 | 798 | } |
---|
802 | 799 | |
---|
803 | 800 | /** |
---|
804 | | - * \brief Unmap and free network buffer |
---|
805 | | - * @param buf buffer |
---|
| 801 | + * free_netbuf - Unmap and free network buffer |
---|
| 802 | + * @buf: buffer |
---|
806 | 803 | */ |
---|
807 | 804 | static void free_netbuf(void *buf) |
---|
808 | 805 | { |
---|
.. | .. |
---|
821 | 818 | } |
---|
822 | 819 | |
---|
823 | 820 | /** |
---|
824 | | - * \brief Unmap and free gather buffer |
---|
825 | | - * @param buf buffer |
---|
| 821 | + * free_netsgbuf - Unmap and free gather buffer |
---|
| 822 | + * @buf: buffer |
---|
826 | 823 | */ |
---|
827 | 824 | static void free_netsgbuf(void *buf) |
---|
828 | 825 | { |
---|
.. | .. |
---|
844 | 841 | |
---|
845 | 842 | i = 1; |
---|
846 | 843 | while (frags--) { |
---|
847 | | - struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i - 1]; |
---|
| 844 | + skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1]; |
---|
848 | 845 | |
---|
849 | 846 | pci_unmap_page((lio->oct_dev)->pci_dev, |
---|
850 | 847 | g->sg[(i >> 2)].ptr[(i & 3)], |
---|
851 | | - frag->size, DMA_TO_DEVICE); |
---|
| 848 | + skb_frag_size(frag), DMA_TO_DEVICE); |
---|
852 | 849 | i++; |
---|
853 | 850 | } |
---|
854 | 851 | |
---|
.. | .. |
---|
862 | 859 | } |
---|
863 | 860 | |
---|
864 | 861 | /** |
---|
865 | | - * \brief Unmap and free gather buffer with response |
---|
866 | | - * @param buf buffer |
---|
| 862 | + * free_netsgbuf_with_resp - Unmap and free gather buffer with response |
---|
| 863 | + * @buf: buffer |
---|
867 | 864 | */ |
---|
868 | 865 | static void free_netsgbuf_with_resp(void *buf) |
---|
869 | 866 | { |
---|
.. | .. |
---|
888 | 885 | |
---|
889 | 886 | i = 1; |
---|
890 | 887 | while (frags--) { |
---|
891 | | - struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i - 1]; |
---|
| 888 | + skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1]; |
---|
892 | 889 | |
---|
893 | 890 | pci_unmap_page((lio->oct_dev)->pci_dev, |
---|
894 | 891 | g->sg[(i >> 2)].ptr[(i & 3)], |
---|
895 | | - frag->size, DMA_TO_DEVICE); |
---|
| 892 | + skb_frag_size(frag), DMA_TO_DEVICE); |
---|
896 | 893 | i++; |
---|
897 | 894 | } |
---|
898 | 895 | |
---|
.. | .. |
---|
906 | 903 | } |
---|
907 | 904 | |
---|
908 | 905 | /** |
---|
909 | | - * \brief Net device open for LiquidIO |
---|
910 | | - * @param netdev network device |
---|
| 906 | + * liquidio_open - Net device open for LiquidIO |
---|
| 907 | + * @netdev: network device |
---|
911 | 908 | */ |
---|
912 | 909 | static int liquidio_open(struct net_device *netdev) |
---|
913 | 910 | { |
---|
914 | 911 | struct lio *lio = GET_LIO(netdev); |
---|
915 | 912 | struct octeon_device *oct = lio->oct_dev; |
---|
| 913 | + struct octeon_device_priv *oct_priv = |
---|
| 914 | + (struct octeon_device_priv *)oct->priv; |
---|
916 | 915 | struct napi_struct *napi, *n; |
---|
| 916 | + int ret = 0; |
---|
917 | 917 | |
---|
918 | 918 | if (!oct->props[lio->ifidx].napi_enabled) { |
---|
| 919 | + tasklet_disable(&oct_priv->droq_tasklet); |
---|
| 920 | + |
---|
919 | 921 | list_for_each_entry_safe(napi, n, &netdev->napi_list, dev_list) |
---|
920 | 922 | napi_enable(napi); |
---|
921 | 923 | |
---|
.. | .. |
---|
932 | 934 | netif_info(lio, ifup, lio->netdev, "Interface Open, ready for traffic\n"); |
---|
933 | 935 | start_txqs(netdev); |
---|
934 | 936 | |
---|
| 937 | + INIT_DELAYED_WORK(&lio->stats_wk.work, lio_fetch_stats); |
---|
| 938 | + lio->stats_wk.ctxptr = lio; |
---|
| 939 | + schedule_delayed_work(&lio->stats_wk.work, msecs_to_jiffies |
---|
| 940 | + (LIQUIDIO_NDEV_STATS_POLL_TIME_MS)); |
---|
| 941 | + |
---|
935 | 942 | /* tell Octeon to start forwarding packets to host */ |
---|
936 | | - send_rx_ctrl_cmd(lio, 1); |
---|
| 943 | + ret = send_rx_ctrl_cmd(lio, 1); |
---|
| 944 | + if (ret) |
---|
| 945 | + return ret; |
---|
937 | 946 | |
---|
938 | 947 | dev_info(&oct->pci_dev->dev, "%s interface is opened\n", netdev->name); |
---|
939 | 948 | |
---|
940 | | - return 0; |
---|
| 949 | + return ret; |
---|
941 | 950 | } |
---|
942 | 951 | |
---|
943 | 952 | /** |
---|
944 | | - * \brief Net device stop for LiquidIO |
---|
945 | | - * @param netdev network device |
---|
| 953 | + * liquidio_stop - jNet device stop for LiquidIO |
---|
| 954 | + * @netdev: network device |
---|
946 | 955 | */ |
---|
947 | 956 | static int liquidio_stop(struct net_device *netdev) |
---|
948 | 957 | { |
---|
949 | 958 | struct lio *lio = GET_LIO(netdev); |
---|
950 | 959 | struct octeon_device *oct = lio->oct_dev; |
---|
| 960 | + struct octeon_device_priv *oct_priv = |
---|
| 961 | + (struct octeon_device_priv *)oct->priv; |
---|
951 | 962 | struct napi_struct *napi, *n; |
---|
| 963 | + int ret = 0; |
---|
952 | 964 | |
---|
953 | 965 | /* tell Octeon to stop forwarding packets to host */ |
---|
954 | | - send_rx_ctrl_cmd(lio, 0); |
---|
| 966 | + ret = send_rx_ctrl_cmd(lio, 0); |
---|
| 967 | + if (ret) |
---|
| 968 | + return ret; |
---|
955 | 969 | |
---|
956 | 970 | netif_info(lio, ifdown, lio->netdev, "Stopping interface!\n"); |
---|
957 | 971 | /* Inform that netif carrier is down */ |
---|
.. | .. |
---|
977 | 991 | oct->props[lio->ifidx].napi_enabled = 0; |
---|
978 | 992 | |
---|
979 | 993 | oct->droq[0]->ops.poll_mode = 0; |
---|
| 994 | + |
---|
| 995 | + tasklet_enable(&oct_priv->droq_tasklet); |
---|
980 | 996 | } |
---|
| 997 | + |
---|
| 998 | + cancel_delayed_work_sync(&lio->stats_wk.work); |
---|
981 | 999 | |
---|
982 | 1000 | dev_info(&oct->pci_dev->dev, "%s interface is stopped\n", netdev->name); |
---|
983 | 1001 | |
---|
984 | | - return 0; |
---|
| 1002 | + return ret; |
---|
985 | 1003 | } |
---|
986 | 1004 | |
---|
987 | 1005 | /** |
---|
988 | | - * \brief Converts a mask based on net device flags |
---|
989 | | - * @param netdev network device |
---|
| 1006 | + * get_new_flags - Converts a mask based on net device flags |
---|
| 1007 | + * @netdev: network device |
---|
990 | 1008 | * |
---|
991 | 1009 | * This routine generates a octnet_ifflags mask from the net device flags |
---|
992 | 1010 | * received from the OS. |
---|
.. | .. |
---|
1054 | 1072 | } |
---|
1055 | 1073 | |
---|
1056 | 1074 | /** |
---|
1057 | | - * \brief Net device set_multicast_list |
---|
1058 | | - * @param netdev network device |
---|
| 1075 | + * liquidio_set_mcast_list - Net device set_multicast_list |
---|
| 1076 | + * @netdev: network device |
---|
1059 | 1077 | */ |
---|
1060 | 1078 | static void liquidio_set_mcast_list(struct net_device *netdev) |
---|
1061 | 1079 | { |
---|
.. | .. |
---|
1093 | 1111 | /* Apparently, any activity in this call from the kernel has to |
---|
1094 | 1112 | * be atomic. So we won't wait for response. |
---|
1095 | 1113 | */ |
---|
1096 | | - nctrl.wait_time = 0; |
---|
1097 | 1114 | |
---|
1098 | 1115 | ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl); |
---|
1099 | | - if (ret < 0) { |
---|
| 1116 | + if (ret) { |
---|
1100 | 1117 | dev_err(&oct->pci_dev->dev, "DEVFLAGS change failed in core (ret: 0x%x)\n", |
---|
1101 | 1118 | ret); |
---|
1102 | 1119 | } |
---|
.. | .. |
---|
1105 | 1122 | } |
---|
1106 | 1123 | |
---|
1107 | 1124 | /** |
---|
1108 | | - * \brief Net device set_mac_address |
---|
1109 | | - * @param netdev network device |
---|
| 1125 | + * liquidio_set_mac - Net device set_mac_address |
---|
| 1126 | + * @netdev: network device |
---|
| 1127 | + * @p: opaque pointer to sockaddr |
---|
1110 | 1128 | */ |
---|
1111 | 1129 | static int liquidio_set_mac(struct net_device *netdev, void *p) |
---|
1112 | 1130 | { |
---|
.. | .. |
---|
1133 | 1151 | nctrl.ncmd.s.more = 1; |
---|
1134 | 1152 | nctrl.iq_no = lio->linfo.txpciq[0].s.q_no; |
---|
1135 | 1153 | nctrl.netpndev = (u64)netdev; |
---|
1136 | | - nctrl.cb_fn = liquidio_link_ctrl_cmd_completion; |
---|
1137 | | - nctrl.wait_time = 100; |
---|
1138 | 1154 | |
---|
1139 | 1155 | nctrl.udd[0] = 0; |
---|
1140 | 1156 | /* The MAC Address is presented in network byte order. */ |
---|
.. | .. |
---|
1145 | 1161 | dev_err(&oct->pci_dev->dev, "MAC Address change failed\n"); |
---|
1146 | 1162 | return -ENOMEM; |
---|
1147 | 1163 | } |
---|
| 1164 | + |
---|
| 1165 | + if (nctrl.sc_status == |
---|
| 1166 | + FIRMWARE_STATUS_CODE(OCTEON_REQUEST_NO_PERMISSION)) { |
---|
| 1167 | + dev_err(&oct->pci_dev->dev, "MAC Address change failed: no permission\n"); |
---|
| 1168 | + return -EPERM; |
---|
| 1169 | + } |
---|
| 1170 | + |
---|
1148 | 1171 | memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); |
---|
1149 | 1172 | ether_addr_copy(((u8 *)&lio->linfo.hw_addr) + 2, addr->sa_data); |
---|
1150 | 1173 | |
---|
.. | .. |
---|
1198 | 1221 | lstats->rx_packets = pkts; |
---|
1199 | 1222 | lstats->rx_dropped = drop; |
---|
1200 | 1223 | |
---|
1201 | | - octnet_get_link_stats(netdev); |
---|
1202 | 1224 | lstats->multicast = oct->link_stats.fromwire.fw_total_mcast; |
---|
1203 | 1225 | |
---|
1204 | 1226 | /* detailed rx_errors: */ |
---|
.. | .. |
---|
1220 | 1242 | } |
---|
1221 | 1243 | |
---|
1222 | 1244 | /** |
---|
1223 | | - * \brief Handler for SIOCSHWTSTAMP ioctl |
---|
1224 | | - * @param netdev network device |
---|
1225 | | - * @param ifr interface request |
---|
1226 | | - * @param cmd command |
---|
| 1245 | + * hwtstamp_ioctl - Handler for SIOCSHWTSTAMP ioctl |
---|
| 1246 | + * @netdev: network device |
---|
| 1247 | + * @ifr: interface request |
---|
1227 | 1248 | */ |
---|
1228 | 1249 | static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr) |
---|
1229 | 1250 | { |
---|
.. | .. |
---|
1278 | 1299 | } |
---|
1279 | 1300 | |
---|
1280 | 1301 | /** |
---|
1281 | | - * \brief ioctl handler |
---|
1282 | | - * @param netdev network device |
---|
1283 | | - * @param ifr interface request |
---|
1284 | | - * @param cmd command |
---|
| 1302 | + * liquidio_ioctl - ioctl handler |
---|
| 1303 | + * @netdev: network device |
---|
| 1304 | + * @ifr: interface request |
---|
| 1305 | + * @cmd: command |
---|
1285 | 1306 | */ |
---|
1286 | 1307 | static int liquidio_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) |
---|
1287 | 1308 | { |
---|
.. | .. |
---|
1330 | 1351 | tx_buffer_free(skb); |
---|
1331 | 1352 | } |
---|
1332 | 1353 | |
---|
1333 | | -/* \brief Send a data packet that will be timestamped |
---|
1334 | | - * @param oct octeon device |
---|
1335 | | - * @param ndata pointer to network data |
---|
1336 | | - * @param finfo pointer to private network data |
---|
| 1354 | +/* send_nic_timestamp_pkt - Send a data packet that will be timestamped |
---|
| 1355 | + * @oct: octeon device |
---|
| 1356 | + * @ndata: pointer to network data |
---|
| 1357 | + * @finfo: pointer to private network data |
---|
1337 | 1358 | */ |
---|
1338 | 1359 | static int send_nic_timestamp_pkt(struct octeon_device *oct, |
---|
1339 | 1360 | struct octnic_data_pkt *ndata, |
---|
.. | .. |
---|
1384 | 1405 | return retval; |
---|
1385 | 1406 | } |
---|
1386 | 1407 | |
---|
1387 | | -/** \brief Transmit networks packets to the Octeon interface |
---|
1388 | | - * @param skbuff skbuff struct to be passed to network layer. |
---|
1389 | | - * @param netdev pointer to network device |
---|
| 1408 | +/** |
---|
| 1409 | + * liquidio_xmit - Transmit networks packets to the Octeon interface |
---|
| 1410 | + * @skb: skbuff struct to be passed to network layer. |
---|
| 1411 | + * @netdev: pointer to network device |
---|
1390 | 1412 | * @returns whether the packet was transmitted to the device okay or not |
---|
1391 | 1413 | * (NETDEV_TX_OK or NETDEV_TX_BUSY) |
---|
1392 | 1414 | */ |
---|
.. | .. |
---|
1486 | 1508 | ndata.reqtype = REQTYPE_NORESP_NET; |
---|
1487 | 1509 | |
---|
1488 | 1510 | } else { |
---|
1489 | | - struct skb_frag_struct *frag; |
---|
| 1511 | + skb_frag_t *frag; |
---|
1490 | 1512 | struct octnic_gather *g; |
---|
1491 | 1513 | int i, frags; |
---|
1492 | 1514 | |
---|
.. | .. |
---|
1524 | 1546 | frag = &skb_shinfo(skb)->frags[i - 1]; |
---|
1525 | 1547 | |
---|
1526 | 1548 | g->sg[(i >> 2)].ptr[(i & 3)] = |
---|
1527 | | - dma_map_page(&oct->pci_dev->dev, |
---|
1528 | | - frag->page.p, |
---|
1529 | | - frag->page_offset, |
---|
1530 | | - frag->size, |
---|
1531 | | - DMA_TO_DEVICE); |
---|
| 1549 | + skb_frag_dma_map(&oct->pci_dev->dev, |
---|
| 1550 | + frag, 0, skb_frag_size(frag), |
---|
| 1551 | + DMA_TO_DEVICE); |
---|
1532 | 1552 | if (dma_mapping_error(&oct->pci_dev->dev, |
---|
1533 | 1553 | g->sg[i >> 2].ptr[i & 3])) { |
---|
1534 | 1554 | dma_unmap_single(&oct->pci_dev->dev, |
---|
.. | .. |
---|
1539 | 1559 | frag = &skb_shinfo(skb)->frags[j - 1]; |
---|
1540 | 1560 | dma_unmap_page(&oct->pci_dev->dev, |
---|
1541 | 1561 | g->sg[j >> 2].ptr[j & 3], |
---|
1542 | | - frag->size, |
---|
| 1562 | + skb_frag_size(frag), |
---|
1543 | 1563 | DMA_TO_DEVICE); |
---|
1544 | 1564 | } |
---|
1545 | 1565 | dev_err(&oct->pci_dev->dev, "%s DMA mapping error 3\n", |
---|
.. | .. |
---|
1547 | 1567 | return NETDEV_TX_BUSY; |
---|
1548 | 1568 | } |
---|
1549 | 1569 | |
---|
1550 | | - add_sg_size(&g->sg[(i >> 2)], frag->size, (i & 3)); |
---|
| 1570 | + add_sg_size(&g->sg[(i >> 2)], skb_frag_size(frag), |
---|
| 1571 | + (i & 3)); |
---|
1551 | 1572 | i++; |
---|
1552 | 1573 | } |
---|
1553 | 1574 | |
---|
.. | .. |
---|
1574 | 1595 | irh->vlan = skb_vlan_tag_get(skb) & VLAN_VID_MASK; |
---|
1575 | 1596 | } |
---|
1576 | 1597 | |
---|
1577 | | - xmit_more = skb->xmit_more; |
---|
| 1598 | + xmit_more = netdev_xmit_more(); |
---|
1578 | 1599 | |
---|
1579 | 1600 | if (unlikely(cmdsetup.s.timestamp)) |
---|
1580 | 1601 | status = send_nic_timestamp_pkt(oct, &ndata, finfo, xmit_more); |
---|
.. | .. |
---|
1615 | 1636 | return NETDEV_TX_OK; |
---|
1616 | 1637 | } |
---|
1617 | 1638 | |
---|
1618 | | -/** \brief Network device Tx timeout |
---|
1619 | | - * @param netdev pointer to network device |
---|
| 1639 | +/** |
---|
| 1640 | + * liquidio_tx_timeout - Network device Tx timeout |
---|
| 1641 | + * @netdev: pointer to network device |
---|
| 1642 | + * @txqueue: index of the hung transmit queue |
---|
1620 | 1643 | */ |
---|
1621 | | -static void liquidio_tx_timeout(struct net_device *netdev) |
---|
| 1644 | +static void liquidio_tx_timeout(struct net_device *netdev, unsigned int txqueue) |
---|
1622 | 1645 | { |
---|
1623 | 1646 | struct lio *lio; |
---|
1624 | 1647 | |
---|
.. | .. |
---|
1638 | 1661 | struct lio *lio = GET_LIO(netdev); |
---|
1639 | 1662 | struct octeon_device *oct = lio->oct_dev; |
---|
1640 | 1663 | struct octnic_ctrl_pkt nctrl; |
---|
1641 | | - struct completion compl; |
---|
1642 | | - u16 response_code; |
---|
1643 | 1664 | int ret = 0; |
---|
1644 | 1665 | |
---|
1645 | 1666 | memset(&nctrl, 0, sizeof(struct octnic_ctrl_pkt)); |
---|
.. | .. |
---|
1648 | 1669 | nctrl.ncmd.s.cmd = OCTNET_CMD_ADD_VLAN_FILTER; |
---|
1649 | 1670 | nctrl.ncmd.s.param1 = vid; |
---|
1650 | 1671 | nctrl.iq_no = lio->linfo.txpciq[0].s.q_no; |
---|
1651 | | - nctrl.wait_time = 100; |
---|
1652 | 1672 | nctrl.netpndev = (u64)netdev; |
---|
1653 | 1673 | nctrl.cb_fn = liquidio_link_ctrl_cmd_completion; |
---|
1654 | | - init_completion(&compl); |
---|
1655 | | - nctrl.completion = &compl; |
---|
1656 | | - nctrl.response_code = &response_code; |
---|
1657 | 1674 | |
---|
1658 | 1675 | ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl); |
---|
1659 | | - if (ret < 0) { |
---|
| 1676 | + if (ret) { |
---|
1660 | 1677 | dev_err(&oct->pci_dev->dev, "Add VLAN filter failed in core (ret: 0x%x)\n", |
---|
1661 | 1678 | ret); |
---|
1662 | | - return -EIO; |
---|
| 1679 | + return -EPERM; |
---|
1663 | 1680 | } |
---|
1664 | | - |
---|
1665 | | - if (!wait_for_completion_timeout(&compl, |
---|
1666 | | - msecs_to_jiffies(nctrl.wait_time))) |
---|
1667 | | - return -EPERM; |
---|
1668 | | - |
---|
1669 | | - if (READ_ONCE(response_code)) |
---|
1670 | | - return -EPERM; |
---|
1671 | 1681 | |
---|
1672 | 1682 | return 0; |
---|
1673 | 1683 | } |
---|
.. | .. |
---|
1687 | 1697 | nctrl.ncmd.s.cmd = OCTNET_CMD_DEL_VLAN_FILTER; |
---|
1688 | 1698 | nctrl.ncmd.s.param1 = vid; |
---|
1689 | 1699 | nctrl.iq_no = lio->linfo.txpciq[0].s.q_no; |
---|
1690 | | - nctrl.wait_time = 100; |
---|
1691 | 1700 | nctrl.netpndev = (u64)netdev; |
---|
1692 | 1701 | nctrl.cb_fn = liquidio_link_ctrl_cmd_completion; |
---|
1693 | 1702 | |
---|
1694 | 1703 | ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl); |
---|
1695 | | - if (ret < 0) { |
---|
| 1704 | + if (ret) { |
---|
1696 | 1705 | dev_err(&oct->pci_dev->dev, "Del VLAN filter failed in core (ret: 0x%x)\n", |
---|
1697 | 1706 | ret); |
---|
| 1707 | + if (ret > 0) |
---|
| 1708 | + ret = -EIO; |
---|
1698 | 1709 | } |
---|
1699 | 1710 | return ret; |
---|
1700 | 1711 | } |
---|
.. | .. |
---|
1720 | 1731 | nctrl.ncmd.s.cmd = command; |
---|
1721 | 1732 | nctrl.ncmd.s.param1 = rx_cmd; |
---|
1722 | 1733 | nctrl.iq_no = lio->linfo.txpciq[0].s.q_no; |
---|
1723 | | - nctrl.wait_time = 100; |
---|
1724 | 1734 | nctrl.netpndev = (u64)netdev; |
---|
1725 | 1735 | nctrl.cb_fn = liquidio_link_ctrl_cmd_completion; |
---|
1726 | 1736 | |
---|
1727 | 1737 | ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl); |
---|
1728 | | - if (ret < 0) { |
---|
| 1738 | + if (ret) { |
---|
1729 | 1739 | dev_err(&oct->pci_dev->dev, "DEVFLAGS RXCSUM change failed in core (ret:0x%x)\n", |
---|
1730 | 1740 | ret); |
---|
| 1741 | + if (ret > 0) |
---|
| 1742 | + ret = -EIO; |
---|
1731 | 1743 | } |
---|
1732 | 1744 | return ret; |
---|
1733 | 1745 | } |
---|
.. | .. |
---|
1755 | 1767 | nctrl.ncmd.s.more = vxlan_cmd_bit; |
---|
1756 | 1768 | nctrl.ncmd.s.param1 = vxlan_port; |
---|
1757 | 1769 | nctrl.iq_no = lio->linfo.txpciq[0].s.q_no; |
---|
1758 | | - nctrl.wait_time = 100; |
---|
1759 | 1770 | nctrl.netpndev = (u64)netdev; |
---|
1760 | 1771 | nctrl.cb_fn = liquidio_link_ctrl_cmd_completion; |
---|
1761 | 1772 | |
---|
1762 | 1773 | ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl); |
---|
1763 | | - if (ret < 0) { |
---|
| 1774 | + if (ret) { |
---|
1764 | 1775 | dev_err(&oct->pci_dev->dev, |
---|
1765 | 1776 | "DEVFLAGS VxLAN port add/delete failed in core (ret : 0x%x)\n", |
---|
1766 | 1777 | ret); |
---|
| 1778 | + if (ret > 0) |
---|
| 1779 | + ret = -EIO; |
---|
1767 | 1780 | } |
---|
1768 | 1781 | return ret; |
---|
1769 | 1782 | } |
---|
| 1783 | + |
---|
| 1784 | +static int liquidio_udp_tunnel_set_port(struct net_device *netdev, |
---|
| 1785 | + unsigned int table, unsigned int entry, |
---|
| 1786 | + struct udp_tunnel_info *ti) |
---|
| 1787 | +{ |
---|
| 1788 | + return liquidio_vxlan_port_command(netdev, |
---|
| 1789 | + OCTNET_CMD_VXLAN_PORT_CONFIG, |
---|
| 1790 | + htons(ti->port), |
---|
| 1791 | + OCTNET_CMD_VXLAN_PORT_ADD); |
---|
| 1792 | +} |
---|
| 1793 | + |
---|
| 1794 | +static int liquidio_udp_tunnel_unset_port(struct net_device *netdev, |
---|
| 1795 | + unsigned int table, |
---|
| 1796 | + unsigned int entry, |
---|
| 1797 | + struct udp_tunnel_info *ti) |
---|
| 1798 | +{ |
---|
| 1799 | + return liquidio_vxlan_port_command(netdev, |
---|
| 1800 | + OCTNET_CMD_VXLAN_PORT_CONFIG, |
---|
| 1801 | + htons(ti->port), |
---|
| 1802 | + OCTNET_CMD_VXLAN_PORT_DEL); |
---|
| 1803 | +} |
---|
| 1804 | + |
---|
| 1805 | +static const struct udp_tunnel_nic_info liquidio_udp_tunnels = { |
---|
| 1806 | + .set_port = liquidio_udp_tunnel_set_port, |
---|
| 1807 | + .unset_port = liquidio_udp_tunnel_unset_port, |
---|
| 1808 | + .tables = { |
---|
| 1809 | + { .n_entries = 1024, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, |
---|
| 1810 | + }, |
---|
| 1811 | +}; |
---|
1770 | 1812 | |
---|
1771 | 1813 | /** \brief Net device fix features |
---|
1772 | 1814 | * @param netdev pointer to network device |
---|
.. | .. |
---|
1836 | 1878 | return 0; |
---|
1837 | 1879 | } |
---|
1838 | 1880 | |
---|
1839 | | -static void liquidio_add_vxlan_port(struct net_device *netdev, |
---|
1840 | | - struct udp_tunnel_info *ti) |
---|
1841 | | -{ |
---|
1842 | | - if (ti->type != UDP_TUNNEL_TYPE_VXLAN) |
---|
1843 | | - return; |
---|
1844 | | - |
---|
1845 | | - liquidio_vxlan_port_command(netdev, |
---|
1846 | | - OCTNET_CMD_VXLAN_PORT_CONFIG, |
---|
1847 | | - htons(ti->port), |
---|
1848 | | - OCTNET_CMD_VXLAN_PORT_ADD); |
---|
1849 | | -} |
---|
1850 | | - |
---|
1851 | | -static void liquidio_del_vxlan_port(struct net_device *netdev, |
---|
1852 | | - struct udp_tunnel_info *ti) |
---|
1853 | | -{ |
---|
1854 | | - if (ti->type != UDP_TUNNEL_TYPE_VXLAN) |
---|
1855 | | - return; |
---|
1856 | | - |
---|
1857 | | - liquidio_vxlan_port_command(netdev, |
---|
1858 | | - OCTNET_CMD_VXLAN_PORT_CONFIG, |
---|
1859 | | - htons(ti->port), |
---|
1860 | | - OCTNET_CMD_VXLAN_PORT_DEL); |
---|
1861 | | -} |
---|
1862 | | - |
---|
1863 | 1881 | static const struct net_device_ops lionetdevops = { |
---|
1864 | 1882 | .ndo_open = liquidio_open, |
---|
1865 | 1883 | .ndo_stop = liquidio_stop, |
---|
.. | .. |
---|
1874 | 1892 | .ndo_do_ioctl = liquidio_ioctl, |
---|
1875 | 1893 | .ndo_fix_features = liquidio_fix_features, |
---|
1876 | 1894 | .ndo_set_features = liquidio_set_features, |
---|
1877 | | - .ndo_udp_tunnel_add = liquidio_add_vxlan_port, |
---|
1878 | | - .ndo_udp_tunnel_del = liquidio_del_vxlan_port, |
---|
| 1895 | + .ndo_udp_tunnel_add = udp_tunnel_nic_add_port, |
---|
| 1896 | + .ndo_udp_tunnel_del = udp_tunnel_nic_del_port, |
---|
1879 | 1897 | }; |
---|
1880 | 1898 | |
---|
1881 | 1899 | static int lio_nic_info(struct octeon_recv_info *recv_info, void *buf) |
---|
.. | .. |
---|
1914 | 1932 | } |
---|
1915 | 1933 | |
---|
1916 | 1934 | /** |
---|
1917 | | - * \brief Setup network interfaces |
---|
1918 | | - * @param octeon_dev octeon device |
---|
| 1935 | + * setup_nic_devices - Setup network interfaces |
---|
| 1936 | + * @octeon_dev: octeon device |
---|
1919 | 1937 | * |
---|
1920 | 1938 | * Called during init time for each device. It assumes the NIC |
---|
1921 | 1939 | * is already up and running. The link information for each |
---|
.. | .. |
---|
1924 | 1942 | static int setup_nic_devices(struct octeon_device *octeon_dev) |
---|
1925 | 1943 | { |
---|
1926 | 1944 | int retval, num_iqueues, num_oqueues; |
---|
1927 | | - struct liquidio_if_cfg_context *ctx; |
---|
1928 | | - u32 resp_size, ctx_size, data_size; |
---|
| 1945 | + u32 resp_size, data_size; |
---|
1929 | 1946 | struct liquidio_if_cfg_resp *resp; |
---|
1930 | 1947 | struct octeon_soft_command *sc; |
---|
1931 | 1948 | union oct_nic_if_cfg if_cfg; |
---|
.. | .. |
---|
1956 | 1973 | |
---|
1957 | 1974 | for (i = 0; i < octeon_dev->ifcount; i++) { |
---|
1958 | 1975 | resp_size = sizeof(struct liquidio_if_cfg_resp); |
---|
1959 | | - ctx_size = sizeof(struct liquidio_if_cfg_context); |
---|
1960 | 1976 | data_size = sizeof(struct lio_version); |
---|
1961 | 1977 | sc = (struct octeon_soft_command *) |
---|
1962 | 1978 | octeon_alloc_soft_command(octeon_dev, data_size, |
---|
1963 | | - resp_size, ctx_size); |
---|
| 1979 | + resp_size, 0); |
---|
1964 | 1980 | resp = (struct liquidio_if_cfg_resp *)sc->virtrptr; |
---|
1965 | | - ctx = (struct liquidio_if_cfg_context *)sc->ctxptr; |
---|
1966 | 1981 | vdata = (struct lio_version *)sc->virtdptr; |
---|
1967 | 1982 | |
---|
1968 | 1983 | *((u64 *)vdata) = 0; |
---|
1969 | 1984 | vdata->major = cpu_to_be16(LIQUIDIO_BASE_MAJOR_VERSION); |
---|
1970 | 1985 | vdata->minor = cpu_to_be16(LIQUIDIO_BASE_MINOR_VERSION); |
---|
1971 | 1986 | vdata->micro = cpu_to_be16(LIQUIDIO_BASE_MICRO_VERSION); |
---|
1972 | | - |
---|
1973 | | - WRITE_ONCE(ctx->cond, 0); |
---|
1974 | | - ctx->octeon_id = lio_get_device_id(octeon_dev); |
---|
1975 | | - init_waitqueue_head(&ctx->wc); |
---|
1976 | 1987 | |
---|
1977 | 1988 | if_cfg.u64 = 0; |
---|
1978 | 1989 | |
---|
.. | .. |
---|
1986 | 1997 | OPCODE_NIC_IF_CFG, 0, if_cfg.u64, |
---|
1987 | 1998 | 0); |
---|
1988 | 1999 | |
---|
1989 | | - sc->callback = lio_if_cfg_callback; |
---|
1990 | | - sc->callback_arg = sc; |
---|
1991 | | - sc->wait_time = 5000; |
---|
| 2000 | + init_completion(&sc->complete); |
---|
| 2001 | + sc->sc_status = OCTEON_REQUEST_PENDING; |
---|
1992 | 2002 | |
---|
1993 | 2003 | retval = octeon_send_soft_command(octeon_dev, sc); |
---|
1994 | 2004 | if (retval == IQ_SEND_FAILED) { |
---|
1995 | 2005 | dev_err(&octeon_dev->pci_dev->dev, |
---|
1996 | 2006 | "iq/oq config failed status: %x\n", retval); |
---|
1997 | 2007 | /* Soft instr is freed by driver in case of failure. */ |
---|
1998 | | - goto setup_nic_dev_fail; |
---|
| 2008 | + octeon_free_soft_command(octeon_dev, sc); |
---|
| 2009 | + return(-EIO); |
---|
1999 | 2010 | } |
---|
2000 | 2011 | |
---|
2001 | 2012 | /* Sleep on a wait queue till the cond flag indicates that the |
---|
2002 | 2013 | * response arrived or timed-out. |
---|
2003 | 2014 | */ |
---|
2004 | | - if (sleep_cond(&ctx->wc, &ctx->cond) == -EINTR) { |
---|
2005 | | - dev_err(&octeon_dev->pci_dev->dev, "Wait interrupted\n"); |
---|
2006 | | - goto setup_nic_wait_intr; |
---|
2007 | | - } |
---|
| 2015 | + retval = wait_for_sc_completion_timeout(octeon_dev, sc, 0); |
---|
| 2016 | + if (retval) |
---|
| 2017 | + return retval; |
---|
2008 | 2018 | |
---|
2009 | 2019 | retval = resp->status; |
---|
2010 | 2020 | if (retval) { |
---|
2011 | | - dev_err(&octeon_dev->pci_dev->dev, "iq/oq config failed\n"); |
---|
2012 | | - goto setup_nic_dev_fail; |
---|
| 2021 | + dev_err(&octeon_dev->pci_dev->dev, |
---|
| 2022 | + "iq/oq config failed, retval = %d\n", retval); |
---|
| 2023 | + WRITE_ONCE(sc->caller_is_done, true); |
---|
| 2024 | + return -EIO; |
---|
2013 | 2025 | } |
---|
| 2026 | + |
---|
| 2027 | + snprintf(octeon_dev->fw_info.liquidio_firmware_version, |
---|
| 2028 | + 32, "%s", |
---|
| 2029 | + resp->cfg_info.liquidio_firmware_version); |
---|
2014 | 2030 | |
---|
2015 | 2031 | octeon_swap_8B_data((u64 *)(&resp->cfg_info), |
---|
2016 | 2032 | (sizeof(struct liquidio_if_cfg_info)) >> 3); |
---|
.. | .. |
---|
2022 | 2038 | dev_err(&octeon_dev->pci_dev->dev, |
---|
2023 | 2039 | "Got bad iqueues (%016llx) or oqueues (%016llx) from firmware.\n", |
---|
2024 | 2040 | resp->cfg_info.iqmask, resp->cfg_info.oqmask); |
---|
2025 | | - goto setup_nic_dev_fail; |
---|
| 2041 | + WRITE_ONCE(sc->caller_is_done, true); |
---|
| 2042 | + goto setup_nic_dev_done; |
---|
2026 | 2043 | } |
---|
2027 | 2044 | dev_dbg(&octeon_dev->pci_dev->dev, |
---|
2028 | 2045 | "interface %d, iqmask %016llx, oqmask %016llx, numiqueues %d, numoqueues %d\n", |
---|
.. | .. |
---|
2033 | 2050 | |
---|
2034 | 2051 | if (!netdev) { |
---|
2035 | 2052 | dev_err(&octeon_dev->pci_dev->dev, "Device allocation failed\n"); |
---|
2036 | | - goto setup_nic_dev_fail; |
---|
| 2053 | + WRITE_ONCE(sc->caller_is_done, true); |
---|
| 2054 | + goto setup_nic_dev_done; |
---|
2037 | 2055 | } |
---|
2038 | 2056 | |
---|
2039 | 2057 | SET_NETDEV_DEV(netdev, &octeon_dev->pci_dev->dev); |
---|
.. | .. |
---|
2070 | 2088 | lio->linfo.link.u64 = resp->cfg_info.linfo.link.u64; |
---|
2071 | 2089 | lio->linfo.macaddr_is_admin_asgnd = |
---|
2072 | 2090 | resp->cfg_info.linfo.macaddr_is_admin_asgnd; |
---|
| 2091 | + lio->linfo.macaddr_spoofchk = |
---|
| 2092 | + resp->cfg_info.linfo.macaddr_spoofchk; |
---|
2073 | 2093 | |
---|
2074 | 2094 | lio->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE); |
---|
2075 | 2095 | |
---|
.. | .. |
---|
2094 | 2114 | |
---|
2095 | 2115 | netdev->hw_enc_features = |
---|
2096 | 2116 | (lio->enc_dev_capability & ~NETIF_F_LRO); |
---|
| 2117 | + netdev->udp_tunnel_nic_info = &liquidio_udp_tunnels; |
---|
| 2118 | + |
---|
2097 | 2119 | netdev->vlan_features = lio->dev_capability; |
---|
2098 | 2120 | /* Add any unchangeable hw features */ |
---|
2099 | 2121 | lio->dev_capability |= NETIF_F_HW_VLAN_CTAG_FILTER | |
---|
.. | .. |
---|
2108 | 2130 | /* MTU range: 68 - 16000 */ |
---|
2109 | 2131 | netdev->min_mtu = LIO_MIN_MTU_SIZE; |
---|
2110 | 2132 | netdev->max_mtu = LIO_MAX_MTU_SIZE; |
---|
| 2133 | + |
---|
| 2134 | + WRITE_ONCE(sc->caller_is_done, true); |
---|
2111 | 2135 | |
---|
2112 | 2136 | /* Point to the properties for octeon device to which this |
---|
2113 | 2137 | * interface belongs. |
---|
.. | .. |
---|
2132 | 2156 | lio->linfo.num_txpciq, |
---|
2133 | 2157 | lio->linfo.num_rxpciq)) { |
---|
2134 | 2158 | dev_err(&octeon_dev->pci_dev->dev, "I/O queues creation failed\n"); |
---|
2135 | | - goto setup_nic_dev_fail; |
---|
| 2159 | + goto setup_nic_dev_free; |
---|
2136 | 2160 | } |
---|
2137 | 2161 | |
---|
2138 | 2162 | ifstate_set(lio, LIO_IFSTATE_DROQ_OPS); |
---|
.. | .. |
---|
2155 | 2179 | if (lio_setup_glists(octeon_dev, lio, num_iqueues)) { |
---|
2156 | 2180 | dev_err(&octeon_dev->pci_dev->dev, |
---|
2157 | 2181 | "Gather list allocation failed\n"); |
---|
2158 | | - goto setup_nic_dev_fail; |
---|
| 2182 | + goto setup_nic_dev_free; |
---|
2159 | 2183 | } |
---|
2160 | 2184 | |
---|
2161 | 2185 | /* Register ethtool support */ |
---|
.. | .. |
---|
2170 | 2194 | OCTNIC_LROIPV4 | OCTNIC_LROIPV6); |
---|
2171 | 2195 | |
---|
2172 | 2196 | if (setup_link_status_change_wq(netdev)) |
---|
2173 | | - goto setup_nic_dev_fail; |
---|
| 2197 | + goto setup_nic_dev_free; |
---|
2174 | 2198 | |
---|
2175 | 2199 | if (setup_rx_oom_poll_fn(netdev)) |
---|
2176 | | - goto setup_nic_dev_fail; |
---|
| 2200 | + goto setup_nic_dev_free; |
---|
2177 | 2201 | |
---|
2178 | 2202 | /* Register the network device with the OS */ |
---|
2179 | 2203 | if (register_netdev(netdev)) { |
---|
2180 | 2204 | dev_err(&octeon_dev->pci_dev->dev, "Device registration failed\n"); |
---|
2181 | | - goto setup_nic_dev_fail; |
---|
| 2205 | + goto setup_nic_dev_free; |
---|
2182 | 2206 | } |
---|
2183 | 2207 | |
---|
2184 | 2208 | dev_dbg(&octeon_dev->pci_dev->dev, |
---|
.. | .. |
---|
2201 | 2225 | dev_dbg(&octeon_dev->pci_dev->dev, |
---|
2202 | 2226 | "NIC ifidx:%d Setup successful\n", i); |
---|
2203 | 2227 | |
---|
2204 | | - octeon_free_soft_command(octeon_dev, sc); |
---|
2205 | | - |
---|
2206 | 2228 | octeon_dev->no_speed_setting = 1; |
---|
2207 | 2229 | } |
---|
2208 | 2230 | |
---|
2209 | 2231 | return 0; |
---|
2210 | 2232 | |
---|
2211 | | -setup_nic_dev_fail: |
---|
2212 | | - |
---|
2213 | | - octeon_free_soft_command(octeon_dev, sc); |
---|
2214 | | - |
---|
2215 | | -setup_nic_wait_intr: |
---|
| 2233 | +setup_nic_dev_free: |
---|
2216 | 2234 | |
---|
2217 | 2235 | while (i--) { |
---|
2218 | 2236 | dev_err(&octeon_dev->pci_dev->dev, |
---|
2219 | 2237 | "NIC ifidx:%d Setup failed\n", i); |
---|
2220 | 2238 | liquidio_destroy_nic_device(octeon_dev, i); |
---|
2221 | 2239 | } |
---|
| 2240 | + |
---|
| 2241 | +setup_nic_dev_done: |
---|
| 2242 | + |
---|
2222 | 2243 | return -ENODEV; |
---|
2223 | 2244 | } |
---|
2224 | 2245 | |
---|
2225 | 2246 | /** |
---|
2226 | | - * \brief initialize the NIC |
---|
2227 | | - * @param oct octeon device |
---|
| 2247 | + * liquidio_init_nic_module - initialize the NIC |
---|
| 2248 | + * @oct: octeon device |
---|
2228 | 2249 | * |
---|
2229 | 2250 | * This initialization routine is called once the Octeon device application is |
---|
2230 | 2251 | * up and running |
---|
.. | .. |
---|
2264 | 2285 | } |
---|
2265 | 2286 | |
---|
2266 | 2287 | /** |
---|
2267 | | - * \brief Device initialization for each Octeon device that is probed |
---|
2268 | | - * @param octeon_dev octeon device |
---|
| 2288 | + * octeon_device_init - Device initialization for each Octeon device that is probed |
---|
| 2289 | + * @oct: octeon device |
---|
2269 | 2290 | */ |
---|
2270 | 2291 | static int octeon_device_init(struct octeon_device *oct) |
---|
2271 | 2292 | { |
---|
.. | .. |
---|
2351 | 2372 | } |
---|
2352 | 2373 | atomic_set(&oct->status, OCT_DEV_MSIX_ALLOC_VECTOR_DONE); |
---|
2353 | 2374 | |
---|
2354 | | - dev_info(&oct->pci_dev->dev, "OCTEON_CN23XX VF Version: %s, %d ioqs\n", |
---|
2355 | | - LIQUIDIO_VERSION, oct->sriov_info.rings_per_vf); |
---|
| 2375 | + dev_info(&oct->pci_dev->dev, "OCTEON_CN23XX VF: %d ioqs\n", |
---|
| 2376 | + oct->sriov_info.rings_per_vf); |
---|
2356 | 2377 | |
---|
2357 | 2378 | /* Setup the interrupt handler and record the INT SUM register address*/ |
---|
2358 | 2379 | if (octeon_setup_interrupt(oct, oct->sriov_info.rings_per_vf)) |
---|