Commit da580ca8 authored by Shay Agroskin's avatar Shay Agroskin Committed by Jakub Kicinski

net: ena: add device distinct log prefix to files

ENA logs are adjusted to display the full ENA representation to
distinct each ENA device in case of multiple interfaces.
Using netdev_err/warn and dev_info functions for logging provides
uniform printing with clear distinction of the device and interface.

This patch changes all printing in ena_com files to use netev_* logging
functions except for messages of info level. Log functions of that level
would be printed with dev_info because of the early stage they are
called in when net_device struct isn't yet registered.

To allow using netdev_* functions in all ena_com functions, a pointer to
the net_device was added to ena_com_dev struct.

The patch also adds some log messages to make driver debugging easier.
Signed-off-by: default avatarAmit Bernstein <amitbern@amazon.com>
Signed-off-by: default avatarShay Agroskin <shayagr@amazon.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent ce74496a
This diff is collapsed.
...@@ -303,6 +303,7 @@ struct ena_com_dev { ...@@ -303,6 +303,7 @@ struct ena_com_dev {
u8 __iomem *reg_bar; u8 __iomem *reg_bar;
void __iomem *mem_bar; void __iomem *mem_bar;
void *dmadev; void *dmadev;
struct net_device *net_device;
enum ena_admin_placement_policy_type tx_mem_queue_type; enum ena_admin_placement_policy_type tx_mem_queue_type;
u32 tx_max_header_size; u32 tx_max_header_size;
...@@ -931,6 +932,26 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev, ...@@ -931,6 +932,26 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev,
struct ena_admin_feature_llq_desc *llq_features, struct ena_admin_feature_llq_desc *llq_features,
struct ena_llq_configurations *llq_default_config); struct ena_llq_configurations *llq_default_config);
/* ena_com_io_sq_to_ena_dev - Extract ena_com_dev using contained field io_sq.
* @io_sq: IO submit queue struct
*
* @return - ena_com_dev struct extracted from io_sq
*/
static inline struct ena_com_dev *ena_com_io_sq_to_ena_dev(struct ena_com_io_sq *io_sq)
{
return container_of(io_sq, struct ena_com_dev, io_sq_queues[io_sq->qid]);
}
/* ena_com_io_cq_to_ena_dev - Extract ena_com_dev using contained field io_cq.
* @io_sq: IO submit queue struct
*
* @return - ena_com_dev struct extracted from io_sq
*/
static inline struct ena_com_dev *ena_com_io_cq_to_ena_dev(struct ena_com_io_cq *io_cq)
{
return container_of(io_cq, struct ena_com_dev, io_cq_queues[io_cq->qid]);
}
static inline bool ena_com_get_adaptive_moderation_enabled(struct ena_com_dev *ena_dev) static inline bool ena_com_get_adaptive_moderation_enabled(struct ena_com_dev *ena_dev)
{ {
return ena_dev->adaptive_coalescing; return ena_dev->adaptive_coalescing;
......
...@@ -58,12 +58,14 @@ static int ena_com_write_bounce_buffer_to_dev(struct ena_com_io_sq *io_sq, ...@@ -58,12 +58,14 @@ static int ena_com_write_bounce_buffer_to_dev(struct ena_com_io_sq *io_sq,
if (is_llq_max_tx_burst_exists(io_sq)) { if (is_llq_max_tx_burst_exists(io_sq)) {
if (unlikely(!io_sq->entries_in_tx_burst_left)) { if (unlikely(!io_sq->entries_in_tx_burst_left)) {
pr_err("Error: trying to send more packets than tx burst allows\n"); netdev_err(ena_com_io_sq_to_ena_dev(io_sq)->net_device,
"Error: trying to send more packets than tx burst allows\n");
return -ENOSPC; return -ENOSPC;
} }
io_sq->entries_in_tx_burst_left--; io_sq->entries_in_tx_burst_left--;
pr_debug("Decreasing entries_in_tx_burst_left of queue %d to %d\n", netdev_dbg(ena_com_io_sq_to_ena_dev(io_sq)->net_device,
"Decreasing entries_in_tx_burst_left of queue %d to %d\n",
io_sq->qid, io_sq->entries_in_tx_burst_left); io_sq->qid, io_sq->entries_in_tx_burst_left);
} }
...@@ -102,12 +104,14 @@ static int ena_com_write_header_to_bounce(struct ena_com_io_sq *io_sq, ...@@ -102,12 +104,14 @@ static int ena_com_write_header_to_bounce(struct ena_com_io_sq *io_sq,
if (unlikely((header_offset + header_len) > if (unlikely((header_offset + header_len) >
llq_info->desc_list_entry_size)) { llq_info->desc_list_entry_size)) {
pr_err("Trying to write header larger than llq entry can accommodate\n"); netdev_err(ena_com_io_sq_to_ena_dev(io_sq)->net_device,
"Trying to write header larger than llq entry can accommodate\n");
return -EFAULT; return -EFAULT;
} }
if (unlikely(!bounce_buffer)) { if (unlikely(!bounce_buffer)) {
pr_err("Bounce buffer is NULL\n"); netdev_err(ena_com_io_sq_to_ena_dev(io_sq)->net_device,
"Bounce buffer is NULL\n");
return -EFAULT; return -EFAULT;
} }
...@@ -125,7 +129,8 @@ static void *get_sq_desc_llq(struct ena_com_io_sq *io_sq) ...@@ -125,7 +129,8 @@ static void *get_sq_desc_llq(struct ena_com_io_sq *io_sq)
bounce_buffer = pkt_ctrl->curr_bounce_buf; bounce_buffer = pkt_ctrl->curr_bounce_buf;
if (unlikely(!bounce_buffer)) { if (unlikely(!bounce_buffer)) {
pr_err("Bounce buffer is NULL\n"); netdev_err(ena_com_io_sq_to_ena_dev(io_sq)->net_device,
"Bounce buffer is NULL\n");
return NULL; return NULL;
} }
...@@ -250,7 +255,8 @@ static u16 ena_com_cdesc_rx_pkt_get(struct ena_com_io_cq *io_cq, ...@@ -250,7 +255,8 @@ static u16 ena_com_cdesc_rx_pkt_get(struct ena_com_io_cq *io_cq,
io_cq->cur_rx_pkt_cdesc_count = 0; io_cq->cur_rx_pkt_cdesc_count = 0;
io_cq->cur_rx_pkt_cdesc_start_idx = head_masked; io_cq->cur_rx_pkt_cdesc_start_idx = head_masked;
pr_debug("ENA q_id: %d packets were completed. first desc idx %u descs# %d\n", netdev_dbg(ena_com_io_cq_to_ena_dev(io_cq)->net_device,
"ENA q_id: %d packets were completed. first desc idx %u descs# %d\n",
io_cq->qid, *first_cdesc_idx, count); io_cq->qid, *first_cdesc_idx, count);
} else { } else {
io_cq->cur_rx_pkt_cdesc_count += count; io_cq->cur_rx_pkt_cdesc_count += count;
...@@ -335,7 +341,8 @@ static int ena_com_create_and_store_tx_meta_desc(struct ena_com_io_sq *io_sq, ...@@ -335,7 +341,8 @@ static int ena_com_create_and_store_tx_meta_desc(struct ena_com_io_sq *io_sq,
return 0; return 0;
} }
static void ena_com_rx_set_flags(struct ena_com_rx_ctx *ena_rx_ctx, static void ena_com_rx_set_flags(struct ena_com_io_cq *io_cq,
struct ena_com_rx_ctx *ena_rx_ctx,
struct ena_eth_io_rx_cdesc_base *cdesc) struct ena_eth_io_rx_cdesc_base *cdesc)
{ {
ena_rx_ctx->l3_proto = cdesc->status & ena_rx_ctx->l3_proto = cdesc->status &
...@@ -357,7 +364,8 @@ static void ena_com_rx_set_flags(struct ena_com_rx_ctx *ena_rx_ctx, ...@@ -357,7 +364,8 @@ static void ena_com_rx_set_flags(struct ena_com_rx_ctx *ena_rx_ctx,
(cdesc->status & ENA_ETH_IO_RX_CDESC_BASE_IPV4_FRAG_MASK) >> (cdesc->status & ENA_ETH_IO_RX_CDESC_BASE_IPV4_FRAG_MASK) >>
ENA_ETH_IO_RX_CDESC_BASE_IPV4_FRAG_SHIFT; ENA_ETH_IO_RX_CDESC_BASE_IPV4_FRAG_SHIFT;
pr_debug("l3_proto %d l4_proto %d l3_csum_err %d l4_csum_err %d hash %d frag %d cdesc_status %x\n", netdev_dbg(ena_com_io_cq_to_ena_dev(io_cq)->net_device,
"l3_proto %d l4_proto %d l3_csum_err %d l4_csum_err %d hash %d frag %d cdesc_status %x\n",
ena_rx_ctx->l3_proto, ena_rx_ctx->l4_proto, ena_rx_ctx->l3_proto, ena_rx_ctx->l4_proto,
ena_rx_ctx->l3_csum_err, ena_rx_ctx->l4_csum_err, ena_rx_ctx->l3_csum_err, ena_rx_ctx->l4_csum_err,
ena_rx_ctx->hash, ena_rx_ctx->frag, cdesc->status); ena_rx_ctx->hash, ena_rx_ctx->frag, cdesc->status);
...@@ -385,12 +393,14 @@ int ena_com_prepare_tx(struct ena_com_io_sq *io_sq, ...@@ -385,12 +393,14 @@ int ena_com_prepare_tx(struct ena_com_io_sq *io_sq,
/* num_bufs +1 for potential meta desc */ /* num_bufs +1 for potential meta desc */
if (unlikely(!ena_com_sq_have_enough_space(io_sq, num_bufs + 1))) { if (unlikely(!ena_com_sq_have_enough_space(io_sq, num_bufs + 1))) {
pr_debug("Not enough space in the tx queue\n"); netdev_dbg(ena_com_io_sq_to_ena_dev(io_sq)->net_device,
"Not enough space in the tx queue\n");
return -ENOMEM; return -ENOMEM;
} }
if (unlikely(header_len > io_sq->tx_max_header_size)) { if (unlikely(header_len > io_sq->tx_max_header_size)) {
pr_err("Header size is too large %d max header: %d\n", netdev_err(ena_com_io_sq_to_ena_dev(io_sq)->net_device,
"Header size is too large %d max header: %d\n",
header_len, io_sq->tx_max_header_size); header_len, io_sq->tx_max_header_size);
return -EINVAL; return -EINVAL;
} }
...@@ -405,7 +415,8 @@ int ena_com_prepare_tx(struct ena_com_io_sq *io_sq, ...@@ -405,7 +415,8 @@ int ena_com_prepare_tx(struct ena_com_io_sq *io_sq,
rc = ena_com_create_and_store_tx_meta_desc(io_sq, ena_tx_ctx, &have_meta); rc = ena_com_create_and_store_tx_meta_desc(io_sq, ena_tx_ctx, &have_meta);
if (unlikely(rc)) { if (unlikely(rc)) {
pr_err("Failed to create and store tx meta desc\n"); netdev_err(ena_com_io_sq_to_ena_dev(io_sq)->net_device,
"Failed to create and store tx meta desc\n");
return rc; return rc;
} }
...@@ -529,11 +540,13 @@ int ena_com_rx_pkt(struct ena_com_io_cq *io_cq, ...@@ -529,11 +540,13 @@ int ena_com_rx_pkt(struct ena_com_io_cq *io_cq,
return 0; return 0;
} }
pr_debug("Fetch rx packet: queue %d completed desc: %d\n", io_cq->qid, netdev_dbg(ena_com_io_cq_to_ena_dev(io_cq)->net_device,
"Fetch rx packet: queue %d completed desc: %d\n", io_cq->qid,
nb_hw_desc); nb_hw_desc);
if (unlikely(nb_hw_desc > ena_rx_ctx->max_bufs)) { if (unlikely(nb_hw_desc > ena_rx_ctx->max_bufs)) {
pr_err("Too many RX cdescs (%d) > MAX(%d)\n", nb_hw_desc, netdev_err(ena_com_io_cq_to_ena_dev(io_cq)->net_device,
"Too many RX cdescs (%d) > MAX(%d)\n", nb_hw_desc,
ena_rx_ctx->max_bufs); ena_rx_ctx->max_bufs);
return -ENOSPC; return -ENOSPC;
} }
...@@ -557,11 +570,12 @@ int ena_com_rx_pkt(struct ena_com_io_cq *io_cq, ...@@ -557,11 +570,12 @@ int ena_com_rx_pkt(struct ena_com_io_cq *io_cq,
/* Update SQ head ptr */ /* Update SQ head ptr */
io_sq->next_to_comp += nb_hw_desc; io_sq->next_to_comp += nb_hw_desc;
pr_debug("[%s][QID#%d] Updating SQ head to: %d\n", __func__, io_sq->qid, netdev_dbg(ena_com_io_cq_to_ena_dev(io_cq)->net_device,
io_sq->next_to_comp); "[%s][QID#%d] Updating SQ head to: %d\n", __func__,
io_sq->qid, io_sq->next_to_comp);
/* Get rx flags from the last pkt */ /* Get rx flags from the last pkt */
ena_com_rx_set_flags(ena_rx_ctx, cdesc); ena_com_rx_set_flags(io_cq, ena_rx_ctx, cdesc);
ena_rx_ctx->descs = nb_hw_desc; ena_rx_ctx->descs = nb_hw_desc;
return 0; return 0;
...@@ -593,6 +607,10 @@ int ena_com_add_single_rx_desc(struct ena_com_io_sq *io_sq, ...@@ -593,6 +607,10 @@ int ena_com_add_single_rx_desc(struct ena_com_io_sq *io_sq,
desc->req_id = req_id; desc->req_id = req_id;
netdev_dbg(ena_com_io_sq_to_ena_dev(io_sq)->net_device,
"[%s] Adding single RX desc, Queue: %u, req_id: %u\n",
__func__, io_sq->qid, req_id);
desc->buff_addr_lo = (u32)ena_buf->paddr; desc->buff_addr_lo = (u32)ena_buf->paddr;
desc->buff_addr_hi = desc->buff_addr_hi =
((ena_buf->paddr & GENMASK_ULL(io_sq->dma_addr_bits - 1, 32)) >> 32); ((ena_buf->paddr & GENMASK_ULL(io_sq->dma_addr_bits - 1, 32)) >> 32);
......
...@@ -140,8 +140,9 @@ static inline bool ena_com_is_doorbell_needed(struct ena_com_io_sq *io_sq, ...@@ -140,8 +140,9 @@ static inline bool ena_com_is_doorbell_needed(struct ena_com_io_sq *io_sq,
llq_info->descs_per_entry); llq_info->descs_per_entry);
} }
pr_debug("Queue: %d num_descs: %d num_entries_needed: %d\n", io_sq->qid, netdev_dbg(ena_com_io_sq_to_ena_dev(io_sq)->net_device,
num_descs, num_entries_needed); "Queue: %d num_descs: %d num_entries_needed: %d\n",
io_sq->qid, num_descs, num_entries_needed);
return num_entries_needed > io_sq->entries_in_tx_burst_left; return num_entries_needed > io_sq->entries_in_tx_burst_left;
} }
...@@ -151,13 +152,15 @@ static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq) ...@@ -151,13 +152,15 @@ static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq)
u16 max_entries_in_tx_burst = io_sq->llq_info.max_entries_in_tx_burst; u16 max_entries_in_tx_burst = io_sq->llq_info.max_entries_in_tx_burst;
u16 tail = io_sq->tail; u16 tail = io_sq->tail;
pr_debug("Write submission queue doorbell for queue: %d tail: %d\n", netdev_dbg(ena_com_io_sq_to_ena_dev(io_sq)->net_device,
"Write submission queue doorbell for queue: %d tail: %d\n",
io_sq->qid, tail); io_sq->qid, tail);
writel(tail, io_sq->db_addr); writel(tail, io_sq->db_addr);
if (is_llq_max_tx_burst_exists(io_sq)) { if (is_llq_max_tx_burst_exists(io_sq)) {
pr_debug("Reset available entries in tx burst for queue %d to %d\n", netdev_dbg(ena_com_io_sq_to_ena_dev(io_sq)->net_device,
"Reset available entries in tx burst for queue %d to %d\n",
io_sq->qid, max_entries_in_tx_burst); io_sq->qid, max_entries_in_tx_burst);
io_sq->entries_in_tx_burst_left = max_entries_in_tx_burst; io_sq->entries_in_tx_burst_left = max_entries_in_tx_burst;
} }
...@@ -176,7 +179,8 @@ static inline int ena_com_update_dev_comp_head(struct ena_com_io_cq *io_cq) ...@@ -176,7 +179,8 @@ static inline int ena_com_update_dev_comp_head(struct ena_com_io_cq *io_cq)
need_update = unreported_comp > (io_cq->q_depth / ENA_COMP_HEAD_THRESH); need_update = unreported_comp > (io_cq->q_depth / ENA_COMP_HEAD_THRESH);
if (unlikely(need_update)) { if (unlikely(need_update)) {
pr_debug("Write completion queue doorbell for queue %d: head: %d\n", netdev_dbg(ena_com_io_cq_to_ena_dev(io_cq)->net_device,
"Write completion queue doorbell for queue %d: head: %d\n",
io_cq->qid, head); io_cq->qid, head);
writel(head, io_cq->cq_head_db_reg); writel(head, io_cq->cq_head_db_reg);
io_cq->last_head_update = head; io_cq->last_head_update = head;
...@@ -240,7 +244,8 @@ static inline int ena_com_tx_comp_req_id_get(struct ena_com_io_cq *io_cq, ...@@ -240,7 +244,8 @@ static inline int ena_com_tx_comp_req_id_get(struct ena_com_io_cq *io_cq,
*req_id = READ_ONCE(cdesc->req_id); *req_id = READ_ONCE(cdesc->req_id);
if (unlikely(*req_id >= io_cq->q_depth)) { if (unlikely(*req_id >= io_cq->q_depth)) {
pr_err("Invalid req id %d\n", cdesc->req_id); netdev_err(ena_com_io_cq_to_ena_dev(io_cq)->net_device,
"Invalid req id %d\n", cdesc->req_id);
return -EINVAL; return -EINVAL;
} }
......
...@@ -4192,6 +4192,8 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -4192,6 +4192,8 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
adapter->pdev = pdev; adapter->pdev = pdev;
adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE); adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
ena_dev->net_device = netdev;
pci_set_drvdata(pdev, adapter); pci_set_drvdata(pdev, adapter);
rc = ena_device_init(ena_dev, pdev, &get_feat_ctx, &wd_state); rc = ena_device_init(ena_dev, pdev, &get_feat_ctx, &wd_state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment