[v4,18/31] net/ena/base: check for existing keep alive notification
Checks
Commit Message
From: Shai Brandes <shaibran@amazon.com>
This commit adds an API to query the aenq on whether
there is a pending keep alive notification.
Signed-off-by: Shai Brandes <shaibran@amazon.com>
Reviewed-by: Amit Bernstein <amitbern@amazon.com>
---
drivers/net/ena/base/ena_com.c | 39 ++++++++++++++++++++++++++++++++++
drivers/net/ena/base/ena_com.h | 10 +++++++++
2 files changed, 49 insertions(+)
@@ -2456,6 +2456,45 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data)
mmiowb();
}
+bool ena_com_aenq_has_keep_alive(struct ena_com_dev *ena_dev)
+{
+ struct ena_admin_aenq_common_desc *aenq_common;
+ struct ena_com_aenq *aenq = &ena_dev->aenq;
+ struct ena_admin_aenq_entry *aenq_e;
+ u8 phase = aenq->phase;
+ u16 masked_head;
+
+ masked_head = aenq->head & (aenq->q_depth - 1);
+ aenq_e = &aenq->entries[masked_head]; /* Get first entry */
+ aenq_common = &aenq_e->aenq_common_desc;
+
+ /* Go over all the events */
+ while ((READ_ONCE8(aenq_common->flags) &
+ ENA_ADMIN_AENQ_COMMON_DESC_PHASE_MASK) == phase) {
+ /* Make sure the device finished writing the rest of the descriptor
+ * before reading it.
+ */
+ dma_rmb();
+
+ if (aenq_common->group == ENA_ADMIN_KEEP_ALIVE)
+ return true;
+
+ /* Get next event entry */
+ masked_head++;
+
+ if (unlikely(masked_head == aenq->q_depth)) {
+ masked_head = 0;
+ phase = !phase;
+ }
+
+ aenq_e = &aenq->entries[masked_head];
+ aenq_common = &aenq_e->aenq_common_desc;
+ }
+
+ return false;
+}
+
+
int ena_com_dev_reset(struct ena_com_dev *ena_dev,
enum ena_regs_reset_reason_types reset_reason)
{
@@ -639,6 +639,16 @@ void ena_com_admin_q_comp_intr_handler(struct ena_com_dev *ena_dev);
*/
void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data);
+/* ena_com_aenq_has_keep_alive - Retrieve if there is a keep alive notification in the aenq
+ * @ena_dev: ENA communication layer struct
+ *
+ * This method goes over the async event notification queue and returns if there
+ * is a keep alive notification.
+ *
+ * @return - true if there is a keep alive notification in the aenq or false otherwise
+ */
+bool ena_com_aenq_has_keep_alive(struct ena_com_dev *ena_dev);
+
/* ena_com_abort_admin_commands - Abort all the outstanding admin commands.
* @ena_dev: ENA communication layer struct
*