[v7,05/21] net/cpfl: support queue start
Checks
Commit Message
Add support for these device ops:
- rx_queue_start
- tx_queue_start
Signed-off-by: Mingxia Liu <mingxia.liu@intel.com>
---
drivers/net/cpfl/cpfl_ethdev.c | 41 ++++++++++
drivers/net/cpfl/cpfl_rxtx.c | 138 +++++++++++++++++++++++++++++++++
drivers/net/cpfl/cpfl_rxtx.h | 4 +
3 files changed, 183 insertions(+)
Comments
On 2/16/2023 12:29 AM, Mingxia Liu wrote:
> Add support for these device ops:
> - rx_queue_start
> - tx_queue_start
>
> Signed-off-by: Mingxia Liu <mingxia.liu@intel.com>
<...>
> +int
> +cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)
> +{
> + struct idpf_rx_queue *rxq;
> + int err;
> +
> + if (rx_queue_id >= dev->data->nb_rx_queues)
> + return -EINVAL;
> +
> + rxq = dev->data->rx_queues[rx_queue_id];
> +
> + if (rxq == NULL || !rxq->q_set) {
> + PMD_DRV_LOG(ERR, "RX queue %u not available or setup",
> + rx_queue_id);
> + return -EINVAL;
> + }
> +
> + if (rxq->bufq1 == NULL) {
> + /* Single queue */
What do you think to keep the queue type explicitly in the queue struct,
instead of deducing it from pointer values?
Thanks, Ferruh !
It's a good idea!
As for it involves a wide range of change, including idpf common module and idpf pmd code,
So we'd better update it in the later fix patch after rc2.
> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@amd.com>
> Sent: Tuesday, February 28, 2023 5:47 AM
> To: Liu, Mingxia <mingxia.liu@intel.com>; dev@dpdk.org; Xing, Beilei
> <beilei.xing@intel.com>; Zhang, Yuying <yuying.zhang@intel.com>
> Subject: Re: [PATCH v7 05/21] net/cpfl: support queue start
>
> On 2/16/2023 12:29 AM, Mingxia Liu wrote:
> > Add support for these device ops:
> > - rx_queue_start
> > - tx_queue_start
> >
> > Signed-off-by: Mingxia Liu <mingxia.liu@intel.com>
>
> <...>
>
> > +int
> > +cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id) {
> > + struct idpf_rx_queue *rxq;
> > + int err;
> > +
> > + if (rx_queue_id >= dev->data->nb_rx_queues)
> > + return -EINVAL;
> > +
> > + rxq = dev->data->rx_queues[rx_queue_id];
> > +
> > + if (rxq == NULL || !rxq->q_set) {
> > + PMD_DRV_LOG(ERR, "RX queue %u not available or setup",
> > + rx_queue_id);
> > + return -EINVAL;
> > + }
> > +
> > + if (rxq->bufq1 == NULL) {
> > + /* Single queue */
>
> What do you think to keep the queue type explicitly in the queue struct,
> instead of deducing it from pointer values?
>
If time permits, we will first submit a fixed patch to add a q type member in rx_queue strc.
> -----Original Message-----
> From: Liu, Mingxia
> Sent: Tuesday, February 28, 2023 11:15 AM
> To: Ferruh Yigit <ferruh.yigit@amd.com>; dev@dpdk.org; Xing, Beilei
> <beilei.xing@intel.com>; Zhang, Yuying <Yuying.Zhang@intel.com>
> Subject: RE: [PATCH v7 05/21] net/cpfl: support queue start
>
> Thanks, Ferruh !
> It's a good idea!
>
> As for it involves a wide range of change, including idpf common module
> and idpf pmd code, So we'd better update it in the later fix patch after rc2.
>
> > -----Original Message-----
> > From: Ferruh Yigit <ferruh.yigit@amd.com>
> > Sent: Tuesday, February 28, 2023 5:47 AM
> > To: Liu, Mingxia <mingxia.liu@intel.com>; dev@dpdk.org; Xing, Beilei
> > <beilei.xing@intel.com>; Zhang, Yuying <yuying.zhang@intel.com>
> > Subject: Re: [PATCH v7 05/21] net/cpfl: support queue start
> >
> > On 2/16/2023 12:29 AM, Mingxia Liu wrote:
> > > Add support for these device ops:
> > > - rx_queue_start
> > > - tx_queue_start
> > >
> > > Signed-off-by: Mingxia Liu <mingxia.liu@intel.com>
> >
> > <...>
> >
> > > +int
> > > +cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id) {
> > > + struct idpf_rx_queue *rxq;
> > > + int err;
> > > +
> > > + if (rx_queue_id >= dev->data->nb_rx_queues)
> > > + return -EINVAL;
> > > +
> > > + rxq = dev->data->rx_queues[rx_queue_id];
> > > +
> > > + if (rxq == NULL || !rxq->q_set) {
> > > + PMD_DRV_LOG(ERR, "RX queue %u not available or setup",
> > > + rx_queue_id);
> > > + return -EINVAL;
> > > + }
> > > +
> > > + if (rxq->bufq1 == NULL) {
> > > + /* Single queue */
> >
> > What do you think to keep the queue type explicitly in the queue
> > struct, instead of deducing it from pointer values?
> >
@@ -184,12 +184,51 @@ cpfl_dev_configure(struct rte_eth_dev *dev)
return 0;
}
+static int
+cpfl_start_queues(struct rte_eth_dev *dev)
+{
+ struct idpf_rx_queue *rxq;
+ struct idpf_tx_queue *txq;
+ int err = 0;
+ int i;
+
+ for (i = 0; i < dev->data->nb_tx_queues; i++) {
+ txq = dev->data->tx_queues[i];
+ if (txq == NULL || txq->tx_deferred_start)
+ continue;
+ err = cpfl_tx_queue_start(dev, i);
+ if (err != 0) {
+ PMD_DRV_LOG(ERR, "Fail to start Tx queue %u", i);
+ return err;
+ }
+ }
+
+ for (i = 0; i < dev->data->nb_rx_queues; i++) {
+ rxq = dev->data->rx_queues[i];
+ if (rxq == NULL || rxq->rx_deferred_start)
+ continue;
+ err = cpfl_rx_queue_start(dev, i);
+ if (err != 0) {
+ PMD_DRV_LOG(ERR, "Fail to start Rx queue %u", i);
+ return err;
+ }
+ }
+
+ return err;
+}
+
static int
cpfl_dev_start(struct rte_eth_dev *dev)
{
struct idpf_vport *vport = dev->data->dev_private;
int ret;
+ ret = cpfl_start_queues(dev);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed to start queues");
+ return ret;
+ }
+
ret = idpf_vc_vport_ena_dis(vport, true);
if (ret != 0) {
PMD_DRV_LOG(ERR, "Failed to enable vport");
@@ -574,6 +613,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = {
.dev_start = cpfl_dev_start,
.dev_stop = cpfl_dev_stop,
.link_update = cpfl_dev_link_update,
+ .rx_queue_start = cpfl_rx_queue_start,
+ .tx_queue_start = cpfl_tx_queue_start,
.dev_supported_ptypes_get = cpfl_dev_supported_ptypes_get,
};
@@ -474,3 +474,141 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
err_txq_alloc:
return ret;
}
+
+int
+cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)
+{
+ struct idpf_rx_queue *rxq;
+ int err;
+
+ if (rx_queue_id >= dev->data->nb_rx_queues)
+ return -EINVAL;
+
+ rxq = dev->data->rx_queues[rx_queue_id];
+
+ if (rxq == NULL || !rxq->q_set) {
+ PMD_DRV_LOG(ERR, "RX queue %u not available or setup",
+ rx_queue_id);
+ return -EINVAL;
+ }
+
+ if (rxq->bufq1 == NULL) {
+ /* Single queue */
+ err = idpf_qc_single_rxq_mbufs_alloc(rxq);
+ if (err != 0) {
+ PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
+ return err;
+ }
+
+ rte_wmb();
+
+ /* Init the RX tail register. */
+ IDPF_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
+ } else {
+ /* Split queue */
+ err = idpf_qc_split_rxq_mbufs_alloc(rxq->bufq1);
+ if (err != 0) {
+ PMD_DRV_LOG(ERR, "Failed to allocate RX buffer queue mbuf");
+ return err;
+ }
+ err = idpf_qc_split_rxq_mbufs_alloc(rxq->bufq2);
+ if (err != 0) {
+ PMD_DRV_LOG(ERR, "Failed to allocate RX buffer queue mbuf");
+ return err;
+ }
+
+ rte_wmb();
+
+ /* Init the RX tail register. */
+ IDPF_PCI_REG_WRITE(rxq->bufq1->qrx_tail, rxq->bufq1->rx_tail);
+ IDPF_PCI_REG_WRITE(rxq->bufq2->qrx_tail, rxq->bufq2->rx_tail);
+ }
+
+ return err;
+}
+
+int
+cpfl_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
+{
+ struct idpf_vport *vport = dev->data->dev_private;
+ struct idpf_rx_queue *rxq =
+ dev->data->rx_queues[rx_queue_id];
+ int err = 0;
+
+ err = idpf_vc_rxq_config(vport, rxq);
+ if (err != 0) {
+ PMD_DRV_LOG(ERR, "Fail to configure Rx queue %u", rx_queue_id);
+ return err;
+ }
+
+ err = cpfl_rx_queue_init(dev, rx_queue_id);
+ if (err != 0) {
+ PMD_DRV_LOG(ERR, "Failed to init RX queue %u",
+ rx_queue_id);
+ return err;
+ }
+
+ /* Ready to switch the queue on */
+ err = idpf_vc_queue_switch(vport, rx_queue_id, true, true);
+ if (err != 0) {
+ PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
+ rx_queue_id);
+ } else {
+ rxq->q_started = true;
+ dev->data->rx_queue_state[rx_queue_id] =
+ RTE_ETH_QUEUE_STATE_STARTED;
+ }
+
+ return err;
+}
+
+int
+cpfl_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id)
+{
+ struct idpf_tx_queue *txq;
+
+ if (tx_queue_id >= dev->data->nb_tx_queues)
+ return -EINVAL;
+
+ txq = dev->data->tx_queues[tx_queue_id];
+
+ /* Init the RX tail register. */
+ IDPF_PCI_REG_WRITE(txq->qtx_tail, 0);
+
+ return 0;
+}
+
+int
+cpfl_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
+{
+ struct idpf_vport *vport = dev->data->dev_private;
+ struct idpf_tx_queue *txq =
+ dev->data->tx_queues[tx_queue_id];
+ int err = 0;
+
+ err = idpf_vc_txq_config(vport, txq);
+ if (err != 0) {
+ PMD_DRV_LOG(ERR, "Fail to configure Tx queue %u", tx_queue_id);
+ return err;
+ }
+
+ err = cpfl_tx_queue_init(dev, tx_queue_id);
+ if (err != 0) {
+ PMD_DRV_LOG(ERR, "Failed to init TX queue %u",
+ tx_queue_id);
+ return err;
+ }
+
+ /* Ready to switch the queue on */
+ err = idpf_vc_queue_switch(vport, tx_queue_id, false, true);
+ if (err != 0) {
+ PMD_DRV_LOG(ERR, "Failed to switch TX queue %u on",
+ tx_queue_id);
+ } else {
+ txq->q_started = true;
+ dev->data->tx_queue_state[tx_queue_id] =
+ RTE_ETH_QUEUE_STATE_STARTED;
+ }
+
+ return err;
+}
@@ -28,4 +28,8 @@ int cpfl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
uint16_t nb_desc, unsigned int socket_id,
const struct rte_eth_rxconf *rx_conf,
struct rte_mempool *mp);
+int cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int cpfl_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int cpfl_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
+int cpfl_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
#endif /* _CPFL_RXTX_H_ */