[v2,5/6] net/iavf_be: extend backend to support iavf rxq_irq

Message ID 20210107071503.14720-6-jingjing.wu@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series introduce iavf backend driver |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Jingjing Wu Jan. 7, 2021, 7:15 a.m. UTC
  Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 drivers/net/iavf_be/iavf_be_ethdev.c | 3 ++-
 drivers/net/iavf_be/iavf_be_rxtx.c   | 5 +++++
 drivers/net/iavf_be/iavf_be_vchnl.c  | 8 ++++++--
 3 files changed, 13 insertions(+), 3 deletions(-)
  

Patch

diff --git a/drivers/net/iavf_be/iavf_be_ethdev.c b/drivers/net/iavf_be/iavf_be_ethdev.c
index 4bf936f21b..76d6103c2f 100644
--- a/drivers/net/iavf_be/iavf_be_ethdev.c
+++ b/drivers/net/iavf_be/iavf_be_ethdev.c
@@ -382,7 +382,6 @@  iavfbe_new_device(struct rte_emudev *dev)
 	adapter->reset = (uint8_t *)(uintptr_t)addr;
 	IAVFBE_WRITE_32(adapter->reset, RTE_IAVF_EMU_RESET_COMPLETED);
 	adapter->started = 1;
-	printf("NEW DEVICE: memtable, %p\n", adapter->mem_table);
 
 	return 0;
 }
@@ -465,6 +464,7 @@  iavfbe_update_device(struct rte_emudev *dev)
 				"Can not get irq info of rxq %d\n", i);
 			return -1;
 		}
+		rxq->kickfd = irq_info.eventfd;
 		rte_atomic32_set(&rxq->irq_enable, irq_info.enable);
 	}
 
@@ -479,6 +479,7 @@  iavfbe_update_device(struct rte_emudev *dev)
 				"Can not get irq info of txq %d\n", i);
 			return -1;
 		}
+		txq->callfd = irq_info.eventfd;
 		rte_atomic32_set(&txq->irq_enable, irq_info.enable);
 	}
 
diff --git a/drivers/net/iavf_be/iavf_be_rxtx.c b/drivers/net/iavf_be/iavf_be_rxtx.c
index 66f30cc0a8..9da70976e1 100644
--- a/drivers/net/iavf_be/iavf_be_rxtx.c
+++ b/drivers/net/iavf_be/iavf_be_rxtx.c
@@ -5,6 +5,7 @@ 
 #include <unistd.h>
 #include <inttypes.h>
 #include <sys/queue.h>
+#include <sys/eventfd.h>
 
 #include <rte_string_fns.h>
 #include <rte_mbuf.h>
@@ -461,6 +462,10 @@  iavfbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 end_of_xmit:
 	txq->rx_head = head;
 	txq->stats.sent_miss_num += nb_pkts - nb_tx;
+
+	if (rte_atomic32_read(&txq->irq_enable) == true)
+		eventfd_write(txq->callfd, (eventfd_t)1);
+
 end_unlock:
 	rte_spinlock_unlock(&txq->access_lock);
 
diff --git a/drivers/net/iavf_be/iavf_be_vchnl.c b/drivers/net/iavf_be/iavf_be_vchnl.c
index 2195047280..243ad638f8 100644
--- a/drivers/net/iavf_be/iavf_be_vchnl.c
+++ b/drivers/net/iavf_be/iavf_be_vchnl.c
@@ -95,12 +95,15 @@  apply_tx_irq(struct iavfbe_tx_queue *txq, uint16_t vector)
 {
 	struct rte_emudev_irq_info info;
 
+	rte_spinlock_lock(&txq->access_lock);
 	txq->vector = vector;
 	if (rte_emudev_get_irq_info(txq->adapter->edev_id, vector, &info)) {
 		IAVF_BE_LOG(ERR, "Can not get irq info\n");
 		return IAVF_ERR_DEVICE_NOT_SUPPORTED;
 	}
 	txq->callfd = info.eventfd;
+	rte_atomic32_set(&txq->irq_enable, info.enable);
+	rte_spinlock_unlock(&txq->access_lock);
 
 	return 0;
 }
@@ -110,12 +113,15 @@  apply_rx_irq(struct iavfbe_rx_queue *rxq, uint16_t vector)
 {
 	struct rte_emudev_irq_info info;
 
+	rte_spinlock_lock(&rxq->access_lock);
 	rxq->vector = vector;
 	if (rte_emudev_get_irq_info(rxq->adapter->edev_id, vector, &info)) {
 		IAVF_BE_LOG(ERR, "Can not get irq info\n");
 		return IAVF_ERR_DEVICE_NOT_SUPPORTED;
 	}
 	rxq->kickfd = info.eventfd;
+	rte_atomic32_set(&rxq->irq_enable, info.enable);
+	rte_spinlock_unlock(&rxq->access_lock);
 
 	return 0;
 }
@@ -557,13 +563,11 @@  iavfbe_process_cmd_config_irq_map(struct iavfbe_adapter *adapter,
 			txq = dev->data->tx_queues[j];
 
 			if ((1 << j) & map->rxq_map) {
-				txq->vector = vector_id;
 				ret = apply_tx_irq(txq, vector_id);
 				if (ret)
 					goto send_msg;
 			}
 			if ((1 << j) & map->txq_map) {
-				rxq->vector = vector_id;
 				ret = apply_rx_irq(rxq, vector_id);
 				if (ret)
 					goto send_msg;