void sfc_tx_qfini(struct sfc_adapter *sa, unsigned int sw_index) { struct sfc_txq_info *txq_info; struct sfc_txq *txq; sfc_log_init(sa, "TxQ = %u", sw_index); SFC_ASSERT(sw_index < sa->txq_count); txq_info = &sa->txq_info[sw_index]; txq = txq_info->txq; SFC_ASSERT(txq != NULL); SFC_ASSERT(txq->state == SFC_TXQ_INITIALIZED); sa->dp_tx->qdestroy(txq->dp); txq->dp = NULL; txq_info->txq = NULL; txq_info->entries = 0; sfc_dma_free(sa, &txq->mem); sfc_ev_qfini(txq->evq); txq->evq = NULL; rte_free(txq); }
void sfc_ev_detach(struct sfc_adapter *sa) { sfc_log_init(sa, "entry"); sfc_ev_qfini(sa->mgmt_evq); if (sa->evq_count != 0) sfc_err(sa, "%u EvQs are not destroyed before detach", sa->evq_count); }
int sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index, uint16_t nb_tx_desc, unsigned int socket_id, const struct rte_eth_txconf *tx_conf) { const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic); struct sfc_txq_info *txq_info; struct sfc_evq *evq; struct sfc_txq *txq; int rc = 0; struct sfc_dp_tx_qcreate_info info; sfc_log_init(sa, "TxQ = %u", sw_index); rc = sfc_tx_qcheck_conf(sa, nb_tx_desc, tx_conf); if (rc != 0) goto fail_bad_conf; SFC_ASSERT(sw_index < sa->txq_count); txq_info = &sa->txq_info[sw_index]; SFC_ASSERT(nb_tx_desc <= sa->txq_max_entries); txq_info->entries = nb_tx_desc; rc = sfc_ev_qinit(sa, SFC_EVQ_TYPE_TX, sw_index, txq_info->entries, socket_id, &evq); if (rc != 0) goto fail_ev_qinit; rc = ENOMEM; txq = rte_zmalloc_socket("sfc-txq", sizeof(*txq), 0, socket_id); if (txq == NULL) goto fail_txq_alloc; txq_info->txq = txq; txq->hw_index = sw_index; txq->evq = evq; txq->free_thresh = (tx_conf->tx_free_thresh) ? tx_conf->tx_free_thresh : SFC_TX_DEFAULT_FREE_THRESH; txq->flags = tx_conf->txq_flags; rc = sfc_dma_alloc(sa, "txq", sw_index, EFX_TXQ_SIZE(txq_info->entries), socket_id, &txq->mem); if (rc != 0) goto fail_dma_alloc; memset(&info, 0, sizeof(info)); info.free_thresh = txq->free_thresh; info.flags = tx_conf->txq_flags; info.txq_entries = txq_info->entries; info.dma_desc_size_max = encp->enc_tx_dma_desc_size_max; info.txq_hw_ring = txq->mem.esm_base; info.evq_entries = txq_info->entries; info.evq_hw_ring = evq->mem.esm_base; info.hw_index = txq->hw_index; info.mem_bar = sa->mem_bar.esb_base; rc = sa->dp_tx->qcreate(sa->eth_dev->data->port_id, sw_index, &SFC_DEV_TO_PCI(sa->eth_dev)->addr, socket_id, &info, &txq->dp); if (rc != 0) goto fail_dp_tx_qinit; evq->dp_txq = txq->dp; txq->state = SFC_TXQ_INITIALIZED; txq_info->deferred_start = (tx_conf->tx_deferred_start != 0); return 0; fail_dp_tx_qinit: sfc_dma_free(sa, &txq->mem); fail_dma_alloc: txq_info->txq = NULL; rte_free(txq); fail_txq_alloc: sfc_ev_qfini(evq); fail_ev_qinit: txq_info->entries = 0; fail_bad_conf: sfc_log_init(sa, "failed (TxQ = %u, rc = %d)", sw_index, rc); return rc; }