Skip to content

Commit a4e262c

Browse files
Sameeh Jubrandavem330
authored andcommitted
net: ena: allow automatic fallback to polling mode
Enable fallback to polling mode for Admin queue when identified a command response arrival without an accompanying MSI-X interrupt Signed-off-by: Igor Chauskin <igorch@amazon.com> Signed-off-by: Sameeh Jubran <sameehj@amazon.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent adf671c commit a4e262c

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

drivers/net/ethernet/amazon/ena/ena_com.c

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -762,16 +762,26 @@ static int ena_com_wait_and_process_admin_cq_interrupts(struct ena_comp_ctx *com
762762
admin_queue->stats.no_completion++;
763763
spin_unlock_irqrestore(&admin_queue->q_lock, flags);
764764

765-
if (comp_ctx->status == ENA_CMD_COMPLETED)
766-
pr_err("The ena device have completion but the driver didn't receive any MSI-X interrupt (cmd %d)\n",
767-
comp_ctx->cmd_opcode);
768-
else
769-
pr_err("The ena device doesn't send any completion for the admin cmd %d status %d\n",
765+
if (comp_ctx->status == ENA_CMD_COMPLETED) {
766+
pr_err("The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n",
767+
comp_ctx->cmd_opcode,
768+
admin_queue->auto_polling ? "ON" : "OFF");
769+
/* Check if fallback to polling is enabled */
770+
if (admin_queue->auto_polling)
771+
admin_queue->polling = true;
772+
} else {
773+
pr_err("The ena device doesn't send a completion for the admin cmd %d status %d\n",
770774
comp_ctx->cmd_opcode, comp_ctx->status);
771-
772-
admin_queue->running_state = false;
773-
ret = -ETIME;
774-
goto err;
775+
}
776+
/* Check if shifted to polling mode.
777+
* This will happen if there is a completion without an interrupt
778+
* and autopolling mode is enabled. Continuing normal execution in such case
779+
*/
780+
if (!admin_queue->polling) {
781+
admin_queue->running_state = false;
782+
ret = -ETIME;
783+
goto err;
784+
}
775785
}
776786

777787
ret = ena_com_comp_status_to_errno(comp_ctx->comp_status);
@@ -1650,6 +1660,12 @@ void ena_com_set_admin_polling_mode(struct ena_com_dev *ena_dev, bool polling)
16501660
ena_dev->admin_queue.polling = polling;
16511661
}
16521662

1663+
void ena_com_set_admin_auto_polling_mode(struct ena_com_dev *ena_dev,
1664+
bool polling)
1665+
{
1666+
ena_dev->admin_queue.auto_polling = polling;
1667+
}
1668+
16531669
int ena_com_mmio_reg_read_request_init(struct ena_com_dev *ena_dev)
16541670
{
16551671
struct ena_com_mmio_read *mmio_read = &ena_dev->mmio_read;

drivers/net/ethernet/amazon/ena/ena_com.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ struct ena_com_admin_queue {
283283
/* Indicate if the admin queue should poll for completion */
284284
bool polling;
285285

286+
/* Define if fallback to polling mode should occur */
287+
bool auto_polling;
288+
286289
u16 curr_cmd_id;
287290

288291
/* Indicate that the ena was initialized and can
@@ -545,6 +548,17 @@ void ena_com_set_admin_polling_mode(struct ena_com_dev *ena_dev, bool polling);
545548
*/
546549
bool ena_com_get_ena_admin_polling_mode(struct ena_com_dev *ena_dev);
547550

551+
/* ena_com_set_admin_auto_polling_mode - Enable autoswitch to polling mode
552+
* @ena_dev: ENA communication layer struct
553+
* @polling: Enable/Disable polling mode
554+
*
555+
* Set the autopolling mode.
556+
* If autopolling is on:
557+
* In case of missing interrupt when data is available switch to polling.
558+
*/
559+
void ena_com_set_admin_auto_polling_mode(struct ena_com_dev *ena_dev,
560+
bool polling);
561+
548562
/* ena_com_admin_q_comp_intr_handler - admin queue interrupt handler
549563
* @ena_dev: ENA communication layer struct
550564
*

0 commit comments

Comments
 (0)