|
|
|
|
@ -71,7 +71,8 @@ static int ena_com_mem_addr_set(struct ena_com_dev *ena_dev,
|
|
|
|
|
dma_addr_t addr)
|
|
|
|
|
{
|
|
|
|
|
if ((addr & GENMASK_ULL(ena_dev->dma_addr_bits - 1, 0)) != addr) {
|
|
|
|
|
pr_err("DMA address has more bits that the device supports\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"DMA address has more bits that the device supports\n");
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -83,6 +84,7 @@ static int ena_com_mem_addr_set(struct ena_com_dev *ena_dev,
|
|
|
|
|
|
|
|
|
|
static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
|
|
|
|
|
{
|
|
|
|
|
struct ena_com_dev *ena_dev = admin_queue->ena_dev;
|
|
|
|
|
struct ena_com_admin_sq *sq = &admin_queue->sq;
|
|
|
|
|
u16 size = ADMIN_SQ_SIZE(admin_queue->q_depth);
|
|
|
|
|
|
|
|
|
|
@ -90,7 +92,7 @@ static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
|
|
|
|
|
&sq->dma_addr, GFP_KERNEL);
|
|
|
|
|
|
|
|
|
|
if (!sq->entries) {
|
|
|
|
|
pr_err("Memory allocation failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Memory allocation failed\n");
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -105,6 +107,7 @@ static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
|
|
|
|
|
|
|
|
|
|
static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue)
|
|
|
|
|
{
|
|
|
|
|
struct ena_com_dev *ena_dev = admin_queue->ena_dev;
|
|
|
|
|
struct ena_com_admin_cq *cq = &admin_queue->cq;
|
|
|
|
|
u16 size = ADMIN_CQ_SIZE(admin_queue->q_depth);
|
|
|
|
|
|
|
|
|
|
@ -112,7 +115,7 @@ static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue)
|
|
|
|
|
&cq->dma_addr, GFP_KERNEL);
|
|
|
|
|
|
|
|
|
|
if (!cq->entries) {
|
|
|
|
|
pr_err("Memory allocation failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Memory allocation failed\n");
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -135,7 +138,7 @@ static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev,
|
|
|
|
|
&aenq->dma_addr, GFP_KERNEL);
|
|
|
|
|
|
|
|
|
|
if (!aenq->entries) {
|
|
|
|
|
pr_err("Memory allocation failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Memory allocation failed\n");
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -156,7 +159,8 @@ static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev,
|
|
|
|
|
writel(aenq_caps, ena_dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF);
|
|
|
|
|
|
|
|
|
|
if (unlikely(!aenq_handlers)) {
|
|
|
|
|
pr_err("AENQ handlers pointer is NULL\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"AENQ handlers pointer is NULL\n");
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -176,18 +180,21 @@ static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *admin_queu
|
|
|
|
|
u16 command_id, bool capture)
|
|
|
|
|
{
|
|
|
|
|
if (unlikely(command_id >= admin_queue->q_depth)) {
|
|
|
|
|
pr_err("Command id is larger than the queue size. cmd_id: %u queue size %d\n",
|
|
|
|
|
command_id, admin_queue->q_depth);
|
|
|
|
|
netdev_err(admin_queue->ena_dev->net_device,
|
|
|
|
|
"Command id is larger than the queue size. cmd_id: %u queue size %d\n",
|
|
|
|
|
command_id, admin_queue->q_depth);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unlikely(!admin_queue->comp_ctx)) {
|
|
|
|
|
pr_err("Completion context is NULL\n");
|
|
|
|
|
netdev_err(admin_queue->ena_dev->net_device,
|
|
|
|
|
"Completion context is NULL\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unlikely(admin_queue->comp_ctx[command_id].occupied && capture)) {
|
|
|
|
|
pr_err("Completion context is occupied\n");
|
|
|
|
|
netdev_err(admin_queue->ena_dev->net_device,
|
|
|
|
|
"Completion context is occupied\n");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -217,7 +224,8 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
|
|
|
|
|
/* In case of queue FULL */
|
|
|
|
|
cnt = (u16)atomic_read(&admin_queue->outstanding_cmds);
|
|
|
|
|
if (cnt >= admin_queue->q_depth) {
|
|
|
|
|
pr_debug("Admin queue is full.\n");
|
|
|
|
|
netdev_dbg(admin_queue->ena_dev->net_device,
|
|
|
|
|
"Admin queue is full.\n");
|
|
|
|
|
admin_queue->stats.out_of_space++;
|
|
|
|
|
return ERR_PTR(-ENOSPC);
|
|
|
|
|
}
|
|
|
|
|
@ -259,6 +267,7 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
|
|
|
|
|
|
|
|
|
|
static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *admin_queue)
|
|
|
|
|
{
|
|
|
|
|
struct ena_com_dev *ena_dev = admin_queue->ena_dev;
|
|
|
|
|
size_t size = admin_queue->q_depth * sizeof(struct ena_comp_ctx);
|
|
|
|
|
struct ena_comp_ctx *comp_ctx;
|
|
|
|
|
u16 i;
|
|
|
|
|
@ -266,7 +275,7 @@ static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *admin_queue)
|
|
|
|
|
admin_queue->comp_ctx =
|
|
|
|
|
devm_kzalloc(admin_queue->q_dmadev, size, GFP_KERNEL);
|
|
|
|
|
if (unlikely(!admin_queue->comp_ctx)) {
|
|
|
|
|
pr_err("Memory allocation failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Memory allocation failed\n");
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -337,7 +346,8 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!io_sq->desc_addr.virt_addr) {
|
|
|
|
|
pr_err("Memory allocation failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Memory allocation failed\n");
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -363,7 +373,8 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
|
|
|
|
|
devm_kzalloc(ena_dev->dmadev, size, GFP_KERNEL);
|
|
|
|
|
|
|
|
|
|
if (!io_sq->bounce_buf_ctrl.base_buffer) {
|
|
|
|
|
pr_err("Bounce buffer memory allocation failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Bounce buffer memory allocation failed\n");
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -423,7 +434,7 @@ static int ena_com_init_io_cq(struct ena_com_dev *ena_dev,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!io_cq->cdesc_addr.virt_addr) {
|
|
|
|
|
pr_err("Memory allocation failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Memory allocation failed\n");
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -444,7 +455,8 @@ static void ena_com_handle_single_admin_completion(struct ena_com_admin_queue *a
|
|
|
|
|
|
|
|
|
|
comp_ctx = get_comp_ctxt(admin_queue, cmd_id, false);
|
|
|
|
|
if (unlikely(!comp_ctx)) {
|
|
|
|
|
pr_err("comp_ctx is NULL. Changing the admin queue running state\n");
|
|
|
|
|
netdev_err(admin_queue->ena_dev->net_device,
|
|
|
|
|
"comp_ctx is NULL. Changing the admin queue running state\n");
|
|
|
|
|
admin_queue->running_state = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -496,10 +508,12 @@ static void ena_com_handle_admin_completion(struct ena_com_admin_queue *admin_qu
|
|
|
|
|
admin_queue->stats.completed_cmd += comp_num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int ena_com_comp_status_to_errno(u8 comp_status)
|
|
|
|
|
static int ena_com_comp_status_to_errno(struct ena_com_admin_queue *admin_queue,
|
|
|
|
|
u8 comp_status)
|
|
|
|
|
{
|
|
|
|
|
if (unlikely(comp_status != 0))
|
|
|
|
|
pr_err("Admin command failed[%u]\n", comp_status);
|
|
|
|
|
netdev_err(admin_queue->ena_dev->net_device,
|
|
|
|
|
"Admin command failed[%u]\n", comp_status);
|
|
|
|
|
|
|
|
|
|
switch (comp_status) {
|
|
|
|
|
case ENA_ADMIN_SUCCESS:
|
|
|
|
|
@ -546,7 +560,8 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (time_is_before_jiffies(timeout)) {
|
|
|
|
|
pr_err("Wait for completion (polling) timeout\n");
|
|
|
|
|
netdev_err(admin_queue->ena_dev->net_device,
|
|
|
|
|
"Wait for completion (polling) timeout\n");
|
|
|
|
|
/* ENA didn't have any completion */
|
|
|
|
|
spin_lock_irqsave(&admin_queue->q_lock, flags);
|
|
|
|
|
admin_queue->stats.no_completion++;
|
|
|
|
|
@ -562,7 +577,8 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unlikely(comp_ctx->status == ENA_CMD_ABORTED)) {
|
|
|
|
|
pr_err("Command was aborted\n");
|
|
|
|
|
netdev_err(admin_queue->ena_dev->net_device,
|
|
|
|
|
"Command was aborted\n");
|
|
|
|
|
spin_lock_irqsave(&admin_queue->q_lock, flags);
|
|
|
|
|
admin_queue->stats.aborted_cmd++;
|
|
|
|
|
spin_unlock_irqrestore(&admin_queue->q_lock, flags);
|
|
|
|
|
@ -573,7 +589,7 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
|
|
|
|
|
WARN(comp_ctx->status != ENA_CMD_COMPLETED, "Invalid comp status %d\n",
|
|
|
|
|
comp_ctx->status);
|
|
|
|
|
|
|
|
|
|
ret = ena_com_comp_status_to_errno(comp_ctx->comp_status);
|
|
|
|
|
ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status);
|
|
|
|
|
err:
|
|
|
|
|
comp_ctxt_release(admin_queue, comp_ctx);
|
|
|
|
|
return ret;
|
|
|
|
|
@ -615,7 +631,8 @@ static int ena_com_set_llq(struct ena_com_dev *ena_dev)
|
|
|
|
|
sizeof(resp));
|
|
|
|
|
|
|
|
|
|
if (unlikely(ret))
|
|
|
|
|
pr_err("Failed to set LLQ configurations: %d\n", ret);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to set LLQ configurations: %d\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
@ -637,8 +654,9 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
|
|
|
|
|
llq_info->header_location_ctrl =
|
|
|
|
|
llq_default_cfg->llq_header_location;
|
|
|
|
|
} else {
|
|
|
|
|
pr_err("Invalid header location control, supported: 0x%x\n",
|
|
|
|
|
supported_feat);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Invalid header location control, supported: 0x%x\n",
|
|
|
|
|
supported_feat);
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -652,14 +670,16 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
|
|
|
|
|
} else if (supported_feat & ENA_ADMIN_SINGLE_DESC_PER_ENTRY) {
|
|
|
|
|
llq_info->desc_stride_ctrl = ENA_ADMIN_SINGLE_DESC_PER_ENTRY;
|
|
|
|
|
} else {
|
|
|
|
|
pr_err("Invalid desc_stride_ctrl, supported: 0x%x\n",
|
|
|
|
|
supported_feat);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Invalid desc_stride_ctrl, supported: 0x%x\n",
|
|
|
|
|
supported_feat);
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pr_err("Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
|
|
|
|
|
llq_default_cfg->llq_stride_ctrl, supported_feat,
|
|
|
|
|
llq_info->desc_stride_ctrl);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
|
|
|
|
|
llq_default_cfg->llq_stride_ctrl,
|
|
|
|
|
supported_feat, llq_info->desc_stride_ctrl);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
llq_info->desc_stride_ctrl = 0;
|
|
|
|
|
@ -680,20 +700,23 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
|
|
|
|
|
llq_info->desc_list_entry_size_ctrl = ENA_ADMIN_LIST_ENTRY_SIZE_256B;
|
|
|
|
|
llq_info->desc_list_entry_size = 256;
|
|
|
|
|
} else {
|
|
|
|
|
pr_err("Invalid entry_size_ctrl, supported: 0x%x\n",
|
|
|
|
|
supported_feat);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Invalid entry_size_ctrl, supported: 0x%x\n",
|
|
|
|
|
supported_feat);
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pr_err("Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
|
|
|
|
|
llq_default_cfg->llq_ring_entry_size, supported_feat,
|
|
|
|
|
llq_info->desc_list_entry_size);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
|
|
|
|
|
llq_default_cfg->llq_ring_entry_size, supported_feat,
|
|
|
|
|
llq_info->desc_list_entry_size);
|
|
|
|
|
}
|
|
|
|
|
if (unlikely(llq_info->desc_list_entry_size & 0x7)) {
|
|
|
|
|
/* The desc list entry size should be whole multiply of 8
|
|
|
|
|
* This requirement comes from __iowrite64_copy()
|
|
|
|
|
*/
|
|
|
|
|
pr_err("Illegal entry size %d\n", llq_info->desc_list_entry_size);
|
|
|
|
|
netdev_err(ena_dev->net_device, "Illegal entry size %d\n",
|
|
|
|
|
llq_info->desc_list_entry_size);
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -716,14 +739,16 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
|
|
|
|
|
} else if (supported_feat & ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8) {
|
|
|
|
|
llq_info->descs_num_before_header = ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8;
|
|
|
|
|
} else {
|
|
|
|
|
pr_err("Invalid descs_num_before_header, supported: 0x%x\n",
|
|
|
|
|
supported_feat);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Invalid descs_num_before_header, supported: 0x%x\n",
|
|
|
|
|
supported_feat);
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pr_err("Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
|
|
|
|
|
llq_default_cfg->llq_num_decs_before_header,
|
|
|
|
|
supported_feat, llq_info->descs_num_before_header);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
|
|
|
|
|
llq_default_cfg->llq_num_decs_before_header,
|
|
|
|
|
supported_feat, llq_info->descs_num_before_header);
|
|
|
|
|
}
|
|
|
|
|
/* Check for accelerated queue supported */
|
|
|
|
|
llq_accel_mode_get = llq_features->accel_mode.u.get;
|
|
|
|
|
@ -739,7 +764,8 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
|
|
|
|
|
|
|
|
|
|
rc = ena_com_set_llq(ena_dev);
|
|
|
|
|
if (rc)
|
|
|
|
|
pr_err("Cannot set LLQ configuration: %d\n", rc);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Cannot set LLQ configuration: %d\n", rc);
|
|
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
@ -766,15 +792,17 @@ static int ena_com_wait_and_process_admin_cq_interrupts(struct ena_comp_ctx *com
|
|
|
|
|
spin_unlock_irqrestore(&admin_queue->q_lock, flags);
|
|
|
|
|
|
|
|
|
|
if (comp_ctx->status == ENA_CMD_COMPLETED) {
|
|
|
|
|
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",
|
|
|
|
|
comp_ctx->cmd_opcode,
|
|
|
|
|
admin_queue->auto_polling ? "ON" : "OFF");
|
|
|
|
|
netdev_err(admin_queue->ena_dev->net_device,
|
|
|
|
|
"The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n",
|
|
|
|
|
comp_ctx->cmd_opcode,
|
|
|
|
|
admin_queue->auto_polling ? "ON" : "OFF");
|
|
|
|
|
/* Check if fallback to polling is enabled */
|
|
|
|
|
if (admin_queue->auto_polling)
|
|
|
|
|
admin_queue->polling = true;
|
|
|
|
|
} else {
|
|
|
|
|
pr_err("The ena device didn't send a completion for the admin cmd %d status %d\n",
|
|
|
|
|
comp_ctx->cmd_opcode, comp_ctx->status);
|
|
|
|
|
netdev_err(admin_queue->ena_dev->net_device,
|
|
|
|
|
"The ena device didn't send a completion for the admin cmd %d status %d\n",
|
|
|
|
|
comp_ctx->cmd_opcode, comp_ctx->status);
|
|
|
|
|
}
|
|
|
|
|
/* Check if shifted to polling mode.
|
|
|
|
|
* This will happen if there is a completion without an interrupt
|
|
|
|
|
@ -787,7 +815,7 @@ static int ena_com_wait_and_process_admin_cq_interrupts(struct ena_comp_ctx *com
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = ena_com_comp_status_to_errno(comp_ctx->comp_status);
|
|
|
|
|
ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status);
|
|
|
|
|
err:
|
|
|
|
|
comp_ctxt_release(admin_queue, comp_ctx);
|
|
|
|
|
return ret;
|
|
|
|
|
@ -834,15 +862,17 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unlikely(i == timeout)) {
|
|
|
|
|
pr_err("Reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",
|
|
|
|
|
mmio_read->seq_num, offset, read_resp->req_id,
|
|
|
|
|
read_resp->reg_off);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",
|
|
|
|
|
mmio_read->seq_num, offset, read_resp->req_id,
|
|
|
|
|
read_resp->reg_off);
|
|
|
|
|
ret = ENA_MMIO_READ_TIMEOUT;
|
|
|
|
|
goto err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (read_resp->reg_off != offset) {
|
|
|
|
|
pr_err("Read failure: wrong offset provided\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Read failure: wrong offset provided\n");
|
|
|
|
|
ret = ENA_MMIO_READ_TIMEOUT;
|
|
|
|
|
} else {
|
|
|
|
|
ret = read_resp->reg_val;
|
|
|
|
|
@ -901,7 +931,8 @@ static int ena_com_destroy_io_sq(struct ena_com_dev *ena_dev,
|
|
|
|
|
sizeof(destroy_resp));
|
|
|
|
|
|
|
|
|
|
if (unlikely(ret && (ret != -ENODEV)))
|
|
|
|
|
pr_err("Failed to destroy io sq error: %d\n", ret);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to destroy io sq error: %d\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
@ -951,7 +982,8 @@ static int wait_for_reset_state(struct ena_com_dev *ena_dev, u32 timeout,
|
|
|
|
|
val = ena_com_reg_bar_read32(ena_dev, ENA_REGS_DEV_STS_OFF);
|
|
|
|
|
|
|
|
|
|
if (unlikely(val == ENA_MMIO_READ_TIMEOUT)) {
|
|
|
|
|
pr_err("Reg read timeout occurred\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Reg read timeout occurred\n");
|
|
|
|
|
return -ETIME;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -991,7 +1023,8 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
if (!ena_com_check_supported_feature_id(ena_dev, feature_id)) {
|
|
|
|
|
pr_debug("Feature %d isn't supported\n", feature_id);
|
|
|
|
|
netdev_dbg(ena_dev->net_device, "Feature %d isn't supported\n",
|
|
|
|
|
feature_id);
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1010,7 +1043,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
|
|
|
|
|
&get_cmd.control_buffer.address,
|
|
|
|
|
control_buf_dma_addr);
|
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
|
pr_err("Memory address set failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Memory address set failed\n");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1027,8 +1060,9 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
|
|
|
|
|
sizeof(*get_resp));
|
|
|
|
|
|
|
|
|
|
if (unlikely(ret))
|
|
|
|
|
pr_err("Failed to submit get_feature command %d error: %d\n",
|
|
|
|
|
feature_id, ret);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to submit get_feature command %d error: %d\n",
|
|
|
|
|
feature_id, ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
@ -1130,9 +1164,10 @@ static int ena_com_indirect_table_allocate(struct ena_com_dev *ena_dev,
|
|
|
|
|
|
|
|
|
|
if ((get_resp.u.ind_table.min_size > log_size) ||
|
|
|
|
|
(get_resp.u.ind_table.max_size < log_size)) {
|
|
|
|
|
pr_err("Indirect table size doesn't fit. requested size: %d while min is:%d and max %d\n",
|
|
|
|
|
1 << log_size, 1 << get_resp.u.ind_table.min_size,
|
|
|
|
|
1 << get_resp.u.ind_table.max_size);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Indirect table size doesn't fit. requested size: %d while min is:%d and max %d\n",
|
|
|
|
|
1 << log_size, 1 << get_resp.u.ind_table.min_size,
|
|
|
|
|
1 << get_resp.u.ind_table.max_size);
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1223,7 +1258,8 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
|
|
|
|
|
&create_cmd.sq_ba,
|
|
|
|
|
io_sq->desc_addr.phys_addr);
|
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
|
pr_err("Memory address set failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Memory address set failed\n");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -1234,7 +1270,8 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
|
|
|
|
|
(struct ena_admin_acq_entry *)&cmd_completion,
|
|
|
|
|
sizeof(cmd_completion));
|
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
|
pr_err("Failed to create IO SQ. error: %d\n", ret);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to create IO SQ. error: %d\n", ret);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1252,7 +1289,8 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
|
|
|
|
|
cmd_completion.llq_descriptors_offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pr_debug("Created sq[%u], depth[%u]\n", io_sq->idx, io_sq->q_depth);
|
|
|
|
|
netdev_dbg(ena_dev->net_device, "Created sq[%u], depth[%u]\n",
|
|
|
|
|
io_sq->idx, io_sq->q_depth);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
@ -1286,7 +1324,8 @@ static void ena_com_update_intr_delay_resolution(struct ena_com_dev *ena_dev,
|
|
|
|
|
u16 prev_intr_delay_resolution = ena_dev->intr_delay_resolution;
|
|
|
|
|
|
|
|
|
|
if (unlikely(!intr_delay_resolution)) {
|
|
|
|
|
pr_err("Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n");
|
|
|
|
|
intr_delay_resolution = ENA_DEFAULT_INTR_DELAY_RESOLUTION;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1322,11 +1361,13 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue,
|
|
|
|
|
comp, comp_size);
|
|
|
|
|
if (IS_ERR(comp_ctx)) {
|
|
|
|
|
if (comp_ctx == ERR_PTR(-ENODEV))
|
|
|
|
|
pr_debug("Failed to submit command [%ld]\n",
|
|
|
|
|
PTR_ERR(comp_ctx));
|
|
|
|
|
netdev_dbg(admin_queue->ena_dev->net_device,
|
|
|
|
|
"Failed to submit command [%ld]\n",
|
|
|
|
|
PTR_ERR(comp_ctx));
|
|
|
|
|
else
|
|
|
|
|
pr_err("Failed to submit command [%ld]\n",
|
|
|
|
|
PTR_ERR(comp_ctx));
|
|
|
|
|
netdev_err(admin_queue->ena_dev->net_device,
|
|
|
|
|
"Failed to submit command [%ld]\n",
|
|
|
|
|
PTR_ERR(comp_ctx));
|
|
|
|
|
|
|
|
|
|
return PTR_ERR(comp_ctx);
|
|
|
|
|
}
|
|
|
|
|
@ -1334,9 +1375,11 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue,
|
|
|
|
|
ret = ena_com_wait_and_process_admin_cq(comp_ctx, admin_queue);
|
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
|
if (admin_queue->running_state)
|
|
|
|
|
pr_err("Failed to process command. ret = %d\n", ret);
|
|
|
|
|
netdev_err(admin_queue->ena_dev->net_device,
|
|
|
|
|
"Failed to process command. ret = %d\n", ret);
|
|
|
|
|
else
|
|
|
|
|
pr_debug("Failed to process command. ret = %d\n", ret);
|
|
|
|
|
netdev_dbg(admin_queue->ena_dev->net_device,
|
|
|
|
|
"Failed to process command. ret = %d\n", ret);
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
@ -1365,7 +1408,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
|
|
|
|
|
&create_cmd.cq_ba,
|
|
|
|
|
io_cq->cdesc_addr.phys_addr);
|
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
|
pr_err("Memory address set failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Memory address set failed\n");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1375,7 +1418,8 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
|
|
|
|
|
(struct ena_admin_acq_entry *)&cmd_completion,
|
|
|
|
|
sizeof(cmd_completion));
|
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
|
pr_err("Failed to create IO CQ. error: %d\n", ret);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to create IO CQ. error: %d\n", ret);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1394,7 +1438,8 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
|
|
|
|
|
(u32 __iomem *)((uintptr_t)ena_dev->reg_bar +
|
|
|
|
|
cmd_completion.numa_node_register_offset);
|
|
|
|
|
|
|
|
|
|
pr_debug("Created cq[%u], depth[%u]\n", io_cq->idx, io_cq->q_depth);
|
|
|
|
|
netdev_dbg(ena_dev->net_device, "Created cq[%u], depth[%u]\n",
|
|
|
|
|
io_cq->idx, io_cq->q_depth);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
@ -1404,8 +1449,9 @@ int ena_com_get_io_handlers(struct ena_com_dev *ena_dev, u16 qid,
|
|
|
|
|
struct ena_com_io_cq **io_cq)
|
|
|
|
|
{
|
|
|
|
|
if (qid >= ENA_TOTAL_NUM_QUEUES) {
|
|
|
|
|
pr_err("Invalid queue number %d but the max is %d\n", qid,
|
|
|
|
|
ENA_TOTAL_NUM_QUEUES);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Invalid queue number %d but the max is %d\n", qid,
|
|
|
|
|
ENA_TOTAL_NUM_QUEUES);
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1471,7 +1517,8 @@ int ena_com_destroy_io_cq(struct ena_com_dev *ena_dev,
|
|
|
|
|
sizeof(destroy_resp));
|
|
|
|
|
|
|
|
|
|
if (unlikely(ret && (ret != -ENODEV)))
|
|
|
|
|
pr_err("Failed to destroy IO CQ. error: %d\n", ret);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to destroy IO CQ. error: %d\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
@ -1513,13 +1560,14 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
|
|
|
|
|
|
|
|
|
|
ret = ena_com_get_feature(ena_dev, &get_resp, ENA_ADMIN_AENQ_CONFIG, 0);
|
|
|
|
|
if (ret) {
|
|
|
|
|
pr_info("Can't get aenq configuration\n");
|
|
|
|
|
dev_info(ena_dev->dmadev, "Can't get aenq configuration\n");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((get_resp.u.aenq.supported_groups & groups_flag) != groups_flag) {
|
|
|
|
|
pr_warn("Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n",
|
|
|
|
|
get_resp.u.aenq.supported_groups, groups_flag);
|
|
|
|
|
netdev_warn(ena_dev->net_device,
|
|
|
|
|
"Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n",
|
|
|
|
|
get_resp.u.aenq.supported_groups, groups_flag);
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1538,7 +1586,8 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
|
|
|
|
|
sizeof(resp));
|
|
|
|
|
|
|
|
|
|
if (unlikely(ret))
|
|
|
|
|
pr_err("Failed to config AENQ ret: %d\n", ret);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to config AENQ ret: %d\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
@ -1549,17 +1598,18 @@ int ena_com_get_dma_width(struct ena_com_dev *ena_dev)
|
|
|
|
|
int width;
|
|
|
|
|
|
|
|
|
|
if (unlikely(caps == ENA_MMIO_READ_TIMEOUT)) {
|
|
|
|
|
pr_err("Reg read timeout occurred\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Reg read timeout occurred\n");
|
|
|
|
|
return -ETIME;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
width = (caps & ENA_REGS_CAPS_DMA_ADDR_WIDTH_MASK) >>
|
|
|
|
|
ENA_REGS_CAPS_DMA_ADDR_WIDTH_SHIFT;
|
|
|
|
|
|
|
|
|
|
pr_debug("ENA dma width: %d\n", width);
|
|
|
|
|
netdev_dbg(ena_dev->net_device, "ENA dma width: %d\n", width);
|
|
|
|
|
|
|
|
|
|
if ((width < 32) || width > ENA_MAX_PHYS_ADDR_SIZE_BITS) {
|
|
|
|
|
pr_err("DMA width illegal value: %d\n", width);
|
|
|
|
|
netdev_err(ena_dev->net_device, "DMA width illegal value: %d\n",
|
|
|
|
|
width);
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1583,23 +1633,24 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
|
|
|
|
|
|
|
|
|
|
if (unlikely((ver == ENA_MMIO_READ_TIMEOUT) ||
|
|
|
|
|
(ctrl_ver == ENA_MMIO_READ_TIMEOUT))) {
|
|
|
|
|
pr_err("Reg read timeout occurred\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Reg read timeout occurred\n");
|
|
|
|
|
return -ETIME;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pr_info("ENA device version: %d.%d\n",
|
|
|
|
|
(ver & ENA_REGS_VERSION_MAJOR_VERSION_MASK) >>
|
|
|
|
|
ENA_REGS_VERSION_MAJOR_VERSION_SHIFT,
|
|
|
|
|
ver & ENA_REGS_VERSION_MINOR_VERSION_MASK);
|
|
|
|
|
dev_info(ena_dev->dmadev, "ENA device version: %d.%d\n",
|
|
|
|
|
(ver & ENA_REGS_VERSION_MAJOR_VERSION_MASK) >>
|
|
|
|
|
ENA_REGS_VERSION_MAJOR_VERSION_SHIFT,
|
|
|
|
|
ver & ENA_REGS_VERSION_MINOR_VERSION_MASK);
|
|
|
|
|
|
|
|
|
|
pr_info("ENA controller version: %d.%d.%d implementation version %d\n",
|
|
|
|
|
(ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_MASK) >>
|
|
|
|
|
ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_SHIFT,
|
|
|
|
|
(ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MINOR_VERSION_MASK) >>
|
|
|
|
|
ENA_REGS_CONTROLLER_VERSION_MINOR_VERSION_SHIFT,
|
|
|
|
|
(ctrl_ver & ENA_REGS_CONTROLLER_VERSION_SUBMINOR_VERSION_MASK),
|
|
|
|
|
(ctrl_ver & ENA_REGS_CONTROLLER_VERSION_IMPL_ID_MASK) >>
|
|
|
|
|
ENA_REGS_CONTROLLER_VERSION_IMPL_ID_SHIFT);
|
|
|
|
|
dev_info(ena_dev->dmadev,
|
|
|
|
|
"ENA controller version: %d.%d.%d implementation version %d\n",
|
|
|
|
|
(ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_MASK) >>
|
|
|
|
|
ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_SHIFT,
|
|
|
|
|
(ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MINOR_VERSION_MASK) >>
|
|
|
|
|
ENA_REGS_CONTROLLER_VERSION_MINOR_VERSION_SHIFT,
|
|
|
|
|
(ctrl_ver & ENA_REGS_CONTROLLER_VERSION_SUBMINOR_VERSION_MASK),
|
|
|
|
|
(ctrl_ver & ENA_REGS_CONTROLLER_VERSION_IMPL_ID_MASK) >>
|
|
|
|
|
ENA_REGS_CONTROLLER_VERSION_IMPL_ID_SHIFT);
|
|
|
|
|
|
|
|
|
|
ctrl_ver_masked =
|
|
|
|
|
(ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_MASK) |
|
|
|
|
|
@ -1608,7 +1659,8 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
|
|
|
|
|
|
|
|
|
|
/* Validate the ctrl version without the implementation ID */
|
|
|
|
|
if (ctrl_ver_masked < MIN_ENA_CTRL_VER) {
|
|
|
|
|
pr_err("ENA ctrl version is lower than the minimal ctrl version the driver supports\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"ENA ctrl version is lower than the minimal ctrl version the driver supports\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1741,12 +1793,13 @@ int ena_com_admin_init(struct ena_com_dev *ena_dev,
|
|
|
|
|
dev_sts = ena_com_reg_bar_read32(ena_dev, ENA_REGS_DEV_STS_OFF);
|
|
|
|
|
|
|
|
|
|
if (unlikely(dev_sts == ENA_MMIO_READ_TIMEOUT)) {
|
|
|
|
|
pr_err("Reg read timeout occurred\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Reg read timeout occurred\n");
|
|
|
|
|
return -ETIME;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(dev_sts & ENA_REGS_DEV_STS_READY_MASK)) {
|
|
|
|
|
pr_err("Device isn't ready, abort com init\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Device isn't ready, abort com init\n");
|
|
|
|
|
return -ENODEV;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1823,8 +1876,9 @@ int ena_com_create_io_queue(struct ena_com_dev *ena_dev,
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
if (ctx->qid >= ENA_TOTAL_NUM_QUEUES) {
|
|
|
|
|
pr_err("Qid (%d) is bigger than max num of queues (%d)\n",
|
|
|
|
|
ctx->qid, ENA_TOTAL_NUM_QUEUES);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Qid (%d) is bigger than max num of queues (%d)\n",
|
|
|
|
|
ctx->qid, ENA_TOTAL_NUM_QUEUES);
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1882,8 +1936,9 @@ void ena_com_destroy_io_queue(struct ena_com_dev *ena_dev, u16 qid)
|
|
|
|
|
struct ena_com_io_cq *io_cq;
|
|
|
|
|
|
|
|
|
|
if (qid >= ENA_TOTAL_NUM_QUEUES) {
|
|
|
|
|
pr_err("Qid (%d) is bigger than max num of queues (%d)\n", qid,
|
|
|
|
|
ENA_TOTAL_NUM_QUEUES);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Qid (%d) is bigger than max num of queues (%d)\n",
|
|
|
|
|
qid, ENA_TOTAL_NUM_QUEUES);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2035,8 +2090,9 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data)
|
|
|
|
|
timestamp = (u64)aenq_common->timestamp_low |
|
|
|
|
|
((u64)aenq_common->timestamp_high << 32);
|
|
|
|
|
|
|
|
|
|
pr_debug("AENQ! Group[%x] Syndrome[%x] timestamp: [%llus]\n",
|
|
|
|
|
aenq_common->group, aenq_common->syndrome, timestamp);
|
|
|
|
|
netdev_dbg(ena_dev->net_device,
|
|
|
|
|
"AENQ! Group[%x] Syndrome[%x] timestamp: [%llus]\n",
|
|
|
|
|
aenq_common->group, aenq_common->syndrome, timestamp);
|
|
|
|
|
|
|
|
|
|
/* Handle specific event*/
|
|
|
|
|
handler_cb = ena_com_get_specific_aenq_cb(ena_dev,
|
|
|
|
|
@ -2079,19 +2135,20 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
|
|
|
|
|
|
|
|
|
|
if (unlikely((stat == ENA_MMIO_READ_TIMEOUT) ||
|
|
|
|
|
(cap == ENA_MMIO_READ_TIMEOUT))) {
|
|
|
|
|
pr_err("Reg read32 timeout occurred\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Reg read32 timeout occurred\n");
|
|
|
|
|
return -ETIME;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((stat & ENA_REGS_DEV_STS_READY_MASK) == 0) {
|
|
|
|
|
pr_err("Device isn't ready, can't reset device\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Device isn't ready, can't reset device\n");
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
timeout = (cap & ENA_REGS_CAPS_RESET_TIMEOUT_MASK) >>
|
|
|
|
|
ENA_REGS_CAPS_RESET_TIMEOUT_SHIFT;
|
|
|
|
|
if (timeout == 0) {
|
|
|
|
|
pr_err("Invalid timeout value\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Invalid timeout value\n");
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2107,7 +2164,8 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
|
|
|
|
|
rc = wait_for_reset_state(ena_dev, timeout,
|
|
|
|
|
ENA_REGS_DEV_STS_RESET_IN_PROGRESS_MASK);
|
|
|
|
|
if (rc != 0) {
|
|
|
|
|
pr_err("Reset indication didn't turn on\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Reset indication didn't turn on\n");
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2115,7 +2173,8 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
|
|
|
|
|
writel(0, ena_dev->reg_bar + ENA_REGS_DEV_CTL_OFF);
|
|
|
|
|
rc = wait_for_reset_state(ena_dev, timeout, 0);
|
|
|
|
|
if (rc != 0) {
|
|
|
|
|
pr_err("Reset indication didn't turn off\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Reset indication didn't turn off\n");
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2152,7 +2211,8 @@ static int ena_get_dev_stats(struct ena_com_dev *ena_dev,
|
|
|
|
|
sizeof(*get_resp));
|
|
|
|
|
|
|
|
|
|
if (unlikely(ret))
|
|
|
|
|
pr_err("Failed to get stats. error: %d\n", ret);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to get stats. error: %d\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
@ -2195,7 +2255,8 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu)
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
if (!ena_com_check_supported_feature_id(ena_dev, ENA_ADMIN_MTU)) {
|
|
|
|
|
pr_debug("Feature %d isn't supported\n", ENA_ADMIN_MTU);
|
|
|
|
|
netdev_dbg(ena_dev->net_device, "Feature %d isn't supported\n",
|
|
|
|
|
ENA_ADMIN_MTU);
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2214,7 +2275,8 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu)
|
|
|
|
|
sizeof(resp));
|
|
|
|
|
|
|
|
|
|
if (unlikely(ret))
|
|
|
|
|
pr_err("Failed to set mtu %d. error: %d\n", mtu, ret);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to set mtu %d. error: %d\n", mtu, ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
@ -2228,7 +2290,8 @@ int ena_com_get_offload_settings(struct ena_com_dev *ena_dev,
|
|
|
|
|
ret = ena_com_get_feature(ena_dev, &resp,
|
|
|
|
|
ENA_ADMIN_STATELESS_OFFLOAD_CONFIG, 0);
|
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
|
pr_err("Failed to get offload capabilities %d\n", ret);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to get offload capabilities %d\n", ret);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2248,8 +2311,8 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
|
|
|
|
|
|
|
|
|
|
if (!ena_com_check_supported_feature_id(ena_dev,
|
|
|
|
|
ENA_ADMIN_RSS_HASH_FUNCTION)) {
|
|
|
|
|
pr_debug("Feature %d isn't supported\n",
|
|
|
|
|
ENA_ADMIN_RSS_HASH_FUNCTION);
|
|
|
|
|
netdev_dbg(ena_dev->net_device, "Feature %d isn't supported\n",
|
|
|
|
|
ENA_ADMIN_RSS_HASH_FUNCTION);
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2260,8 +2323,9 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
if (!(get_resp.u.flow_hash_func.supported_func & BIT(rss->hash_func))) {
|
|
|
|
|
pr_err("Func hash %d isn't supported by device, abort\n",
|
|
|
|
|
rss->hash_func);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Func hash %d isn't supported by device, abort\n",
|
|
|
|
|
rss->hash_func);
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2278,7 +2342,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
|
|
|
|
|
&cmd.control_buffer.address,
|
|
|
|
|
rss->hash_key_dma_addr);
|
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
|
pr_err("Memory address set failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Memory address set failed\n");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2290,8 +2354,9 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
|
|
|
|
|
(struct ena_admin_acq_entry *)&resp,
|
|
|
|
|
sizeof(resp));
|
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
|
pr_err("Failed to set hash function %d. error: %d\n",
|
|
|
|
|
rss->hash_func, ret);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to set hash function %d. error: %d\n",
|
|
|
|
|
rss->hash_func, ret);
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2322,7 +2387,8 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
|
|
if (!(BIT(func) & get_resp.u.flow_hash_func.supported_func)) {
|
|
|
|
|
pr_err("Flow hash function %d isn't supported\n", func);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Flow hash function %d isn't supported\n", func);
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2330,8 +2396,9 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
|
|
|
|
|
case ENA_ADMIN_TOEPLITZ:
|
|
|
|
|
if (key) {
|
|
|
|
|
if (key_len != sizeof(hash_key->key)) {
|
|
|
|
|
pr_err("key len (%hu) doesn't equal the supported size (%zu)\n",
|
|
|
|
|
key_len, sizeof(hash_key->key));
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"key len (%hu) doesn't equal the supported size (%zu)\n",
|
|
|
|
|
key_len, sizeof(hash_key->key));
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
memcpy(hash_key->key, key, key_len);
|
|
|
|
|
@ -2343,7 +2410,8 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
|
|
|
|
|
rss->hash_init_val = init_val;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
pr_err("Invalid hash function (%d)\n", func);
|
|
|
|
|
netdev_err(ena_dev->net_device, "Invalid hash function (%d)\n",
|
|
|
|
|
func);
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2429,8 +2497,8 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
|
|
|
|
|
|
|
|
|
|
if (!ena_com_check_supported_feature_id(ena_dev,
|
|
|
|
|
ENA_ADMIN_RSS_HASH_INPUT)) {
|
|
|
|
|
pr_debug("Feature %d isn't supported\n",
|
|
|
|
|
ENA_ADMIN_RSS_HASH_INPUT);
|
|
|
|
|
netdev_dbg(ena_dev->net_device, "Feature %d isn't supported\n",
|
|
|
|
|
ENA_ADMIN_RSS_HASH_INPUT);
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2448,7 +2516,7 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
|
|
|
|
|
&cmd.control_buffer.address,
|
|
|
|
|
rss->hash_ctrl_dma_addr);
|
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
|
pr_err("Memory address set failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Memory address set failed\n");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
cmd.control_buffer.length = sizeof(*hash_ctrl);
|
|
|
|
|
@ -2459,7 +2527,8 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
|
|
|
|
|
(struct ena_admin_acq_entry *)&resp,
|
|
|
|
|
sizeof(resp));
|
|
|
|
|
if (unlikely(ret))
|
|
|
|
|
pr_err("Failed to set hash input. error: %d\n", ret);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to set hash input. error: %d\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
@ -2509,9 +2578,10 @@ int ena_com_set_default_hash_ctrl(struct ena_com_dev *ena_dev)
|
|
|
|
|
available_fields = hash_ctrl->selected_fields[i].fields &
|
|
|
|
|
hash_ctrl->supported_fields[i].fields;
|
|
|
|
|
if (available_fields != hash_ctrl->selected_fields[i].fields) {
|
|
|
|
|
pr_err("Hash control doesn't support all the desire configuration. proto %x supported %x selected %x\n",
|
|
|
|
|
i, hash_ctrl->supported_fields[i].fields,
|
|
|
|
|
hash_ctrl->selected_fields[i].fields);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Hash control doesn't support all the desire configuration. proto %x supported %x selected %x\n",
|
|
|
|
|
i, hash_ctrl->supported_fields[i].fields,
|
|
|
|
|
hash_ctrl->selected_fields[i].fields);
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -2535,7 +2605,8 @@ int ena_com_fill_hash_ctrl(struct ena_com_dev *ena_dev,
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
if (proto >= ENA_ADMIN_RSS_PROTO_NUM) {
|
|
|
|
|
pr_err("Invalid proto num (%u)\n", proto);
|
|
|
|
|
netdev_err(ena_dev->net_device, "Invalid proto num (%u)\n",
|
|
|
|
|
proto);
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2547,8 +2618,9 @@ int ena_com_fill_hash_ctrl(struct ena_com_dev *ena_dev,
|
|
|
|
|
/* Make sure all the fields are supported */
|
|
|
|
|
supported_fields = hash_ctrl->supported_fields[proto].fields;
|
|
|
|
|
if ((hash_fields & supported_fields) != hash_fields) {
|
|
|
|
|
pr_err("Proto %d doesn't support the required fields %x. supports only: %x\n",
|
|
|
|
|
proto, hash_fields, supported_fields);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Proto %d doesn't support the required fields %x. supports only: %x\n",
|
|
|
|
|
proto, hash_fields, supported_fields);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hash_ctrl->selected_fields[proto].fields = hash_fields;
|
|
|
|
|
@ -2588,14 +2660,15 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
|
|
|
|
|
|
|
|
|
|
if (!ena_com_check_supported_feature_id(
|
|
|
|
|
ena_dev, ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG)) {
|
|
|
|
|
pr_debug("Feature %d isn't supported\n",
|
|
|
|
|
ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG);
|
|
|
|
|
netdev_dbg(ena_dev->net_device, "Feature %d isn't supported\n",
|
|
|
|
|
ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG);
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = ena_com_ind_tbl_convert_to_device(ena_dev);
|
|
|
|
|
if (ret) {
|
|
|
|
|
pr_err("Failed to convert host indirection table to device table\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to convert host indirection table to device table\n");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2612,7 +2685,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
|
|
|
|
|
&cmd.control_buffer.address,
|
|
|
|
|
rss->rss_ind_tbl_dma_addr);
|
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
|
pr_err("Memory address set failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Memory address set failed\n");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2626,7 +2699,8 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
|
|
|
|
|
sizeof(resp));
|
|
|
|
|
|
|
|
|
|
if (unlikely(ret))
|
|
|
|
|
pr_err("Failed to set indirect table. error: %d\n", ret);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to set indirect table. error: %d\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
@ -2782,7 +2856,7 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
|
|
|
|
|
&cmd.u.host_attr.debug_ba,
|
|
|
|
|
host_attr->debug_area_dma_addr);
|
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
|
pr_err("Memory address set failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Memory address set failed\n");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2790,7 +2864,7 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
|
|
|
|
|
&cmd.u.host_attr.os_info_ba,
|
|
|
|
|
host_attr->host_info_dma_addr);
|
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
|
pr_err("Memory address set failed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device, "Memory address set failed\n");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2803,7 +2877,8 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
|
|
|
|
|
sizeof(resp));
|
|
|
|
|
|
|
|
|
|
if (unlikely(ret))
|
|
|
|
|
pr_err("Failed to set host attributes: %d\n", ret);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to set host attributes: %d\n", ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
@ -2815,12 +2890,14 @@ bool ena_com_interrupt_moderation_supported(struct ena_com_dev *ena_dev)
|
|
|
|
|
ENA_ADMIN_INTERRUPT_MODERATION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int ena_com_update_nonadaptive_moderation_interval(u32 coalesce_usecs,
|
|
|
|
|
static int ena_com_update_nonadaptive_moderation_interval(struct ena_com_dev *ena_dev,
|
|
|
|
|
u32 coalesce_usecs,
|
|
|
|
|
u32 intr_delay_resolution,
|
|
|
|
|
u32 *intr_moder_interval)
|
|
|
|
|
{
|
|
|
|
|
if (!intr_delay_resolution) {
|
|
|
|
|
pr_err("Illegal interrupt delay granularity value\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Illegal interrupt delay granularity value\n");
|
|
|
|
|
return -EFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2832,7 +2909,8 @@ static int ena_com_update_nonadaptive_moderation_interval(u32 coalesce_usecs,
|
|
|
|
|
int ena_com_update_nonadaptive_moderation_interval_tx(struct ena_com_dev *ena_dev,
|
|
|
|
|
u32 tx_coalesce_usecs)
|
|
|
|
|
{
|
|
|
|
|
return ena_com_update_nonadaptive_moderation_interval(tx_coalesce_usecs,
|
|
|
|
|
return ena_com_update_nonadaptive_moderation_interval(ena_dev,
|
|
|
|
|
tx_coalesce_usecs,
|
|
|
|
|
ena_dev->intr_delay_resolution,
|
|
|
|
|
&ena_dev->intr_moder_tx_interval);
|
|
|
|
|
}
|
|
|
|
|
@ -2840,7 +2918,8 @@ int ena_com_update_nonadaptive_moderation_interval_tx(struct ena_com_dev *ena_de
|
|
|
|
|
int ena_com_update_nonadaptive_moderation_interval_rx(struct ena_com_dev *ena_dev,
|
|
|
|
|
u32 rx_coalesce_usecs)
|
|
|
|
|
{
|
|
|
|
|
return ena_com_update_nonadaptive_moderation_interval(rx_coalesce_usecs,
|
|
|
|
|
return ena_com_update_nonadaptive_moderation_interval(ena_dev,
|
|
|
|
|
rx_coalesce_usecs,
|
|
|
|
|
ena_dev->intr_delay_resolution,
|
|
|
|
|
&ena_dev->intr_moder_rx_interval);
|
|
|
|
|
}
|
|
|
|
|
@ -2856,12 +2935,14 @@ int ena_com_init_interrupt_moderation(struct ena_com_dev *ena_dev)
|
|
|
|
|
|
|
|
|
|
if (rc) {
|
|
|
|
|
if (rc == -EOPNOTSUPP) {
|
|
|
|
|
pr_debug("Feature %d isn't supported\n",
|
|
|
|
|
ENA_ADMIN_INTERRUPT_MODERATION);
|
|
|
|
|
netdev_dbg(ena_dev->net_device,
|
|
|
|
|
"Feature %d isn't supported\n",
|
|
|
|
|
ENA_ADMIN_INTERRUPT_MODERATION);
|
|
|
|
|
rc = 0;
|
|
|
|
|
} else {
|
|
|
|
|
pr_err("Failed to get interrupt moderation admin cmd. rc: %d\n",
|
|
|
|
|
rc);
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"Failed to get interrupt moderation admin cmd. rc: %d\n",
|
|
|
|
|
rc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no moderation supported, disable adaptive support */
|
|
|
|
|
@ -2909,7 +2990,8 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev,
|
|
|
|
|
(llq_info->descs_num_before_header * sizeof(struct ena_eth_io_tx_desc));
|
|
|
|
|
|
|
|
|
|
if (unlikely(ena_dev->tx_max_header_size == 0)) {
|
|
|
|
|
pr_err("The size of the LLQ entry is smaller than needed\n");
|
|
|
|
|
netdev_err(ena_dev->net_device,
|
|
|
|
|
"The size of the LLQ entry is smaller than needed\n");
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|