1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Huawei Technologies Co., Ltd
11 #include "base/hinic_compat.h"
12 #include "base/hinic_pmd_hwdev.h"
13 #include "base/hinic_pmd_hwif.h"
14 #include "base/hinic_pmd_wq.h"
15 #include "base/hinic_pmd_nicio.h"
16 #include "hinic_pmd_ethdev.h"
17 #include "hinic_pmd_tx.h"
20 void hinic_free_all_tx_skbs(struct hinic_txq *txq)
23 struct hinic_nic_dev *nic_dev = txq->nic_dev;
24 struct hinic_tx_info *tx_info;
25 int free_wqebbs = hinic_get_sq_free_wqebbs(nic_dev->hwdev,
28 while (free_wqebbs < txq->q_depth) {
29 ci = hinic_get_sq_local_ci(nic_dev->hwdev, txq->q_id);
31 tx_info = &txq->tx_info[ci];
33 if (unlikely(tx_info->cpy_mbuf != NULL)) {
34 rte_pktmbuf_free(tx_info->cpy_mbuf);
35 tx_info->cpy_mbuf = NULL;
38 rte_pktmbuf_free(tx_info->mbuf);
39 hinic_update_sq_local_ci(nic_dev->hwdev, txq->q_id,
42 free_wqebbs += tx_info->wqebb_cnt;
47 void hinic_free_all_tx_resources(struct rte_eth_dev *eth_dev)
50 struct hinic_nic_dev *nic_dev =
51 HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
53 for (q_id = 0; q_id < nic_dev->num_sq; q_id++) {
54 eth_dev->data->tx_queues[q_id] = NULL;
56 if (nic_dev->txqs[q_id] == NULL)
59 /* stop tx queue free tx mbuf */
60 hinic_free_all_tx_skbs(nic_dev->txqs[q_id]);
61 hinic_free_tx_resources(nic_dev->txqs[q_id]);
64 kfree(nic_dev->txqs[q_id]);
65 nic_dev->txqs[q_id] = NULL;
69 void hinic_free_tx_resources(struct hinic_txq *txq)
71 if (txq->tx_info == NULL)
78 void hinic_destroy_sq(struct hinic_hwdev *hwdev, u16 q_id)
80 struct hinic_nic_io *nic_io;
83 nic_io = hwdev->nic_io;
84 qp = &nic_io->qps[q_id];
86 if (qp->sq.wq == NULL)
89 hinic_free_db_addr(nic_io->hwdev, qp->sq.db_addr);
90 hinic_wq_free(nic_io->hwdev, qp->sq.wq);