| 523 | } |
| 524 | |
| 525 | void |
| 526 | memif_disconnect(struct rte_eth_dev *dev) |
| 527 | { |
| 528 | struct pmd_internals *pmd = dev->data->dev_private; |
| 529 | struct memif_msg_queue_elt *elt, *next; |
| 530 | struct memif_queue *mq; |
| 531 | struct rte_intr_handle *ih; |
| 532 | int i; |
| 533 | int ret; |
| 534 | |
| 535 | dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN; |
| 536 | pmd->flags &= ~ETH_MEMIF_FLAG_CONNECTING; |
| 537 | pmd->flags &= ~ETH_MEMIF_FLAG_CONNECTED; |
| 538 | |
| 539 | rte_spinlock_lock(&pmd->cc_lock); |
| 540 | if (pmd->cc != NULL) { |
| 541 | /* Clear control message queue (except disconnect message if any). */ |
| 542 | for (elt = TAILQ_FIRST(&pmd->cc->msg_queue); elt != NULL; elt = next) { |
| 543 | next = TAILQ_NEXT(elt, next); |
| 544 | if (elt->msg.type != MEMIF_MSG_TYPE_DISCONNECT) { |
| 545 | TAILQ_REMOVE(&pmd->cc->msg_queue, elt, next); |
| 546 | rte_free(elt); |
| 547 | } |
| 548 | } |
| 549 | /* send disconnect message (if there is any in queue) */ |
| 550 | memif_msg_send_from_queue(pmd->cc); |
| 551 | |
| 552 | /* at this point, there should be no more messages in queue */ |
| 553 | if (TAILQ_FIRST(&pmd->cc->msg_queue) != NULL) { |
| 554 | MIF_LOG(WARNING, |
| 555 | "Unexpected message(s) in message queue."); |
| 556 | } |
| 557 | |
| 558 | ih = pmd->cc->intr_handle; |
| 559 | if (rte_intr_fd_get(ih) > 0) { |
| 560 | ret = rte_intr_callback_unregister(ih, |
| 561 | memif_intr_handler, |
| 562 | pmd->cc); |
| 563 | /* |
| 564 | * If callback is active (disconnecting based on |
| 565 | * received control message). |
| 566 | */ |
| 567 | if (ret == -EAGAIN) { |
| 568 | ret = rte_intr_callback_unregister_pending(ih, |
| 569 | memif_intr_handler, |
| 570 | pmd->cc, |
| 571 | memif_intr_unregister_handler); |
| 572 | } else if (ret > 0) { |
| 573 | close(rte_intr_fd_get(ih)); |
| 574 | rte_intr_instance_free(ih); |
| 575 | rte_free(pmd->cc); |
| 576 | } |
| 577 | pmd->cc = NULL; |
| 578 | if (ret <= 0) |
| 579 | MIF_LOG(WARNING, |
| 580 | "Failed to unregister control channel callback."); |
| 581 | } |
| 582 | } |
no test coverage detected