gve: Implement queue api
Subsystems (3)
v2 cover gve: Implement queue api
Following the discussion on
https://patchwork.kernel.org/project/linux-media/patch/[email protected]/,
the queue api defined by Mina is implemented for gve.
The first patch is just Mina's introduction of the api. The rest of the patches make surgical changes in gve to enable it to work correctly with only a subset of queues present (thus far it had assumed that either all queues are up or all are down). The final patch has the api implementation.
Changes since v1: clang warning fixes, kdoc warning fix, and addressed review comments.
Mina Almasry (1):
queue_api: define queue api
Shailend Chand (9):
gve: Make the GQ RX free queue funcs idempotent
gve: Add adminq funcs to add/remove a single Rx queue
gve: Make gve_turn(up|down) ignore stopped queues
gve: Make gve_turnup work for nonempty queues
gve: Avoid rescheduling napi if on wrong cpu
gve: Reset Rx ring state in the ring-stop funcs
gve: Account for stopped queues when reading NIC stats
gve: Alloc and free QPLs with the rings
gve: Implement queue api
drivers/net/ethernet/google/gve/gve.h | 37 +- drivers/net/ethernet/google/gve/gve_adminq.c | 79 ++- drivers/net/ethernet/google/gve/gve_adminq.h | 2 + drivers/net/ethernet/google/gve/gve_dqo.h | 6 + drivers/net/ethernet/google/gve/gve_ethtool.c | 48 +- drivers/net/ethernet/google/gve/gve_main.c | 575 ++++++++++-------- drivers/net/ethernet/google/gve/gve_rx.c | 132 ++-- drivers/net/ethernet/google/gve/gve_rx_dqo.c | 137 +++-- drivers/net/ethernet/google/gve/gve_tx.c | 33 +- drivers/net/ethernet/google/gve/gve_tx_dqo.c | 23 +- include/linux/netdevice.h | 3 + include/net/netdev_queues.h | 31 + 12 files changed, 677 insertions(+), 429 deletions(-)
Signature · 1 line
2.45.0.rc0.197.gbae5840b3b-goog
PATCH v2 1/10 queue_api: define queue api
From: Mina Almasry <[email protected]>
This API enables the net stack to reset the queues used for devmem TCP.
--- include/linux/netdevice.h | 3 +++ include/net/netdev_queues.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+)
include/linux/netdevice.h +3 -0
@@ -1957,6 +1957,7 @@ enum netdev_reg_state {* @sysfs_rx_queue_group: Space for optional per-rx queue attributes * @rtnl_link_ops: Rtnl_link_ops * @stat_ops: Optional ops for queue-aware statistics +* @queue_mgmt_ops: Optional ops for queue management * * @gso_max_size: Maximum size of generic segmentation offload * @tso_max_size: Device (as in HW) limit on the max TSO request size
@@ -2340,6 +2341,8 @@ struct net_device {const struct netdev_stat_ops *stat_ops; +const struct netdev_queue_mgmt_ops *queue_mgmt_ops; +/* for setting kernel sock attribute on TCP connection setup */ #define GSO_MAX_SEGS 65535u#define GSO_LEGACY_MAX_SIZE 65536u
include/net/netdev_queues.h +31 -0
@@ -87,6 +87,37 @@ struct netdev_stat_ops { struct netdev_queue_stats_tx *tx); }; +/** +* struct netdev_queue_mgmt_ops - netdev ops for queue management +* +* @ndo_queue_mem_size: Size of the struct that describes a queue's memory. +* +* @ndo_queue_mem_alloc: Allocate memory for an RX queue at the specified index. +* The new memory is written at the specified address. +* +* @ndo_queue_mem_free: Free memory from an RX queue. +* +* @ndo_queue_start: Start an RX queue with the specified memory and at the +* specified index. +* +* @ndo_queue_stop: Stop the RX queue at the specified index. The stopped +* queue's memory is written at the specified address. +*/ +struct netdev_queue_mgmt_ops { +size_t ndo_queue_mem_size; +int (*ndo_queue_mem_alloc)(struct net_device *dev, +void *per_queue_mem, +int idx); +void (*ndo_queue_mem_free)(struct net_device *dev, +void *per_queue_mem); +int (*ndo_queue_start)(struct net_device *dev, +void *per_queue_mem, +int idx); +int (*ndo_queue_stop)(struct net_device *dev, +void *per_queue_mem, +int idx); +}; +/** * DOC: Lockless queue stopping / waking helpers. *
Signature · 1 line
2.45.0.rc0.197.gbae5840b3b-goog
PATCH v2 2/10 gve: Make the GQ RX free queue funcs idempotent
In reply to Shailend ChandAlthough this is not fixing any existing double free bug, making these functions idempotent allows for a simpler implementation of future ndo hooks that act on a single queue.
--- drivers/net/ethernet/google/gve/gve_rx.c | 29 ++++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-)
drivers/net/ethernet/google/gve/gve_rx.c +19 -10
@@ -30,6 +30,9 @@ static void gve_rx_unfill_pages(struct gve_priv *priv,u32 slots = rx->mask +1 ;int i; +if (!rx->data.page_info) +return ; +if (rx->data.raw_addressing) {for (i =0 ; i < slots; i++) gve_rx_free_buffer(&priv->pdev->dev, &rx->data.page_info[i],
@@ -69,20 +72,26 @@ static void gve_rx_free_ring_gqi(struct gve_priv *priv, struct gve_rx_ring *rx,int idx = rx->q_num;size_t bytes; - bytes =sizeof (struct gve_rx_desc ) * cfg->ring_size; -dma_free_coherent (dev, bytes, rx->desc.desc_ring, rx->desc.bus); - rx->desc.desc_ring =NULL ; +if (rx->desc.desc_ring) { + bytes =sizeof (struct gve_rx_desc ) * cfg->ring_size; +dma_free_coherent (dev, bytes, rx->desc.desc_ring, rx->desc.bus); + rx->desc.desc_ring =NULL ; + } -dma_free_coherent (dev,sizeof (*rx->q_resources), - rx->q_resources, rx->q_resources_bus); - rx->q_resources =NULL ; +if (rx->q_resources) { +dma_free_coherent (dev,sizeof (*rx->q_resources), + rx->q_resources, rx->q_resources_bus); + rx->q_resources =NULL ; + }gve_rx_unfill_pages (priv, rx, cfg); - bytes =sizeof (*rx->data.data_ring) * slots; -dma_free_coherent (dev, bytes, rx->data.data_ring, - rx->data.data_bus); - rx->data.data_ring =NULL ; +if (rx->data.data_ring) { + bytes =sizeof (*rx->data.data_ring) * slots; +dma_free_coherent (dev, bytes, rx->data.data_ring, + rx->data.data_bus); + rx->data.data_ring =NULL ; + }kvfree (rx->qpl_copy_pool); rx->qpl_copy_pool =NULL ;
Signature · 1 line
2.45.0.rc0.197.gbae5840b3b-goog
PATCH v2 3/10 gve: Add adminq funcs to add/remove a single Rx queue
In reply to Shailend ChandThis allows for implementing future ndo hooks that act on a single queue.
--- drivers/net/ethernet/google/gve/gve_adminq.c | 79 +++++++++++++------- drivers/net/ethernet/google/gve/gve_adminq.h | 2 + 2 files changed, 54 insertions(+), 27 deletions(-)
drivers/net/ethernet/google/gve/gve_adminq.c +52 -27
@@ -630,14 +630,15 @@ int gve_adminq_create_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_quereturn gve_adminq_kick_and_wait (priv); } -static int gve_adminq_create_rx_queue (struct gve_priv *priv,u32 queue_index) +static void gve_adminq_get_create_rx_queue_cmd (struct gve_priv *priv, +union gve_adminq_command *cmd, +u32 queue_index) {struct gve_rx_ring *rx = &priv->rx[queue_index]; -union gve_adminq_command cmd; -memset (&cmd,0 ,sizeof (cmd)); - cmd.opcode =cpu_to_be32 (GVE_ADMINQ_CREATE_RX_QUEUE ); - cmd.create_rx_queue = (struct gve_adminq_create_rx_queue ) { +memset (cmd,0 ,sizeof (*cmd)); + cmd->opcode =cpu_to_be32 (GVE_ADMINQ_CREATE_RX_QUEUE ); + cmd->create_rx_queue = (struct gve_adminq_create_rx_queue ) { .queue_id =cpu_to_be32 (queue_index), .ntfy_id =cpu_to_be32 (rx->ntfy_id), .queue_resources_addr =cpu_to_be64 (rx->q_resources_bus),
@@ -648,13 +649,13 @@ static int gve_adminq_create_rx_queue(struct gve_priv *priv, u32 queue_index)u32 qpl_id = priv->queue_format ==GVE_GQI_RDA_FORMAT ?GVE_RAW_ADDRESSING_QPL_ID : rx->data.qpl->id; - cmd.create_rx_queue.rx_desc_ring_addr = + cmd->create_rx_queue.rx_desc_ring_addr =cpu_to_be64 (rx->desc.bus), - cmd.create_rx_queue.rx_data_ring_addr = + cmd->create_rx_queue.rx_data_ring_addr =cpu_to_be64 (rx->data.data_bus), - cmd.create_rx_queue.index =cpu_to_be32 (queue_index); - cmd.create_rx_queue.queue_page_list_id =cpu_to_be32 (qpl_id); - cmd.create_rx_queue.packet_buffer_size =cpu_to_be16 (rx->packet_buffer_size); + cmd->create_rx_queue.index =cpu_to_be32 (queue_index); + cmd->create_rx_queue.queue_page_list_id =cpu_to_be32 (qpl_id); + cmd->create_rx_queue.packet_buffer_size =cpu_to_be16 (rx->packet_buffer_size); }else {u32 qpl_id =0 ;
@@ -662,25 +663,40 @@ static int gve_adminq_create_rx_queue(struct gve_priv *priv, u32 queue_index) qpl_id =GVE_RAW_ADDRESSING_QPL_ID ; else qpl_id = rx->dqo.qpl->id; - cmd.create_rx_queue.queue_page_list_id =cpu_to_be32 (qpl_id); - cmd.create_rx_queue.rx_desc_ring_addr = + cmd->create_rx_queue.queue_page_list_id =cpu_to_be32 (qpl_id); + cmd->create_rx_queue.rx_desc_ring_addr =cpu_to_be64 (rx->dqo.complq.bus); - cmd.create_rx_queue.rx_data_ring_addr = + cmd->create_rx_queue.rx_data_ring_addr =cpu_to_be64 (rx->dqo.bufq.bus); - cmd.create_rx_queue.packet_buffer_size = + cmd->create_rx_queue.packet_buffer_size =cpu_to_be16 (priv->data_buffer_size_dqo); - cmd.create_rx_queue.rx_buff_ring_size = + cmd->create_rx_queue.rx_buff_ring_size =cpu_to_be16 (priv->rx_desc_cnt); - cmd.create_rx_queue.enable_rsc = + cmd->create_rx_queue.enable_rsc = !!(priv->dev->features &NETIF_F_LRO );if (priv->header_split_enabled) - cmd.create_rx_queue.header_buffer_size = + cmd->create_rx_queue.header_buffer_size =cpu_to_be16 (priv->header_buf_size); } +} + +static int gve_adminq_create_rx_queue (struct gve_priv *priv,u32 queue_index) +{ +union gve_adminq_command cmd; +gve_adminq_get_create_rx_queue_cmd (priv, &cmd, queue_index);return gve_adminq_issue_cmd (priv, &cmd); } +/* Unlike gve_adminq_create_rx_queue, this actually rings the doorbell */ +int gve_adminq_create_single_rx_queue (struct gve_priv *priv,u32 queue_index) +{ +union gve_adminq_command cmd; + +gve_adminq_get_create_rx_queue_cmd (priv, &cmd, queue_index); +return gve_adminq_execute_cmd (priv, &cmd); +} +int gve_adminq_create_rx_queues (struct gve_priv *priv,u32 num_queues) {int err;
@@ -727,22 +743,31 @@ int gve_adminq_destroy_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_qureturn gve_adminq_kick_and_wait (priv); } +static void gve_adminq_make_destroy_rx_queue_cmd (union gve_adminq_command *cmd, +u32 queue_index) +{ +memset (cmd,0 ,sizeof (*cmd)); + cmd->opcode =cpu_to_be32 (GVE_ADMINQ_DESTROY_RX_QUEUE ); + cmd->destroy_rx_queue = (struct gve_adminq_destroy_rx_queue ) { + .queue_id =cpu_to_be32 (queue_index), + }; +} +static int gve_adminq_destroy_rx_queue (struct gve_priv *priv,u32 queue_index) {union gve_adminq_command cmd; -int err; -memset (&cmd,0 ,sizeof (cmd)); - cmd.opcode =cpu_to_be32 (GVE_ADMINQ_DESTROY_RX_QUEUE ); - cmd.destroy_rx_queue = (struct gve_adminq_destroy_rx_queue ) { - .queue_id =cpu_to_be32 (queue_index), - }; +gve_adminq_make_destroy_rx_queue_cmd (&cmd, queue_index); +return gve_adminq_issue_cmd (priv, &cmd); +} - err =gve_adminq_issue_cmd (priv, &cmd); -if (err) -return err; +/* Unlike gve_adminq_destroy_rx_queue, this actually rings the doorbell */ +int gve_adminq_destroy_single_rx_queue (struct gve_priv *priv,u32 queue_index) +{ +union gve_adminq_command cmd; -return 0 ; +gve_adminq_make_destroy_rx_queue_cmd (&cmd, queue_index); +return gve_adminq_execute_cmd (priv, &cmd); }int gve_adminq_destroy_rx_queues (struct gve_priv *priv,u32 num_queues)
drivers/net/ethernet/google/gve/gve_adminq.h +2 -0
@@ -451,7 +451,9 @@ int gve_adminq_configure_device_resources(struct gve_priv *priv,int gve_adminq_deconfigure_device_resources (struct gve_priv *priv);int gve_adminq_create_tx_queues (struct gve_priv *priv,u32 start_id,u32 num_queues);int gve_adminq_destroy_tx_queues (struct gve_priv *priv,u32 start_id,u32 num_queues); +int gve_adminq_create_single_rx_queue (struct gve_priv *priv,u32 queue_index);int gve_adminq_create_rx_queues (struct gve_priv *priv,u32 num_queues); +int gve_adminq_destroy_single_rx_queue (struct gve_priv *priv,u32 queue_index);int gve_adminq_destroy_rx_queues (struct gve_priv *priv,u32 queue_id);int gve_adminq_register_page_list (struct gve_priv *priv,struct gve_queue_page_list *qpl);
Signature · 1 line
2.45.0.rc0.197.gbae5840b3b-goog
PATCH v2 4/10 gve: Make gve_turn(up|down) ignore stopped queues
In reply to Shailend ChandCurrently the queues are either all live or all dead, toggling from one state to the other via the ndo open and stop hooks. The future addition of single-queue ndo hooks changes this, and thus gve_turnup and gve_turndown should evolve to account for a state where some queues are live and some aren't.
--- drivers/net/ethernet/google/gve/gve_main.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/ethernet/google/gve/gve_main.c +10 -0
@@ -1937,12 +1937,16 @@ static void gve_turndown(struct gve_priv *priv)int ntfy_idx =gve_tx_idx_to_ntfy (priv, idx);struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx]; +if (!gve_tx_was_added_to_block (priv, idx)) +continue ;napi_disable (&block->napi); }for (idx =0 ; idx < priv->rx_cfg.num_queues; idx++) {int ntfy_idx =gve_rx_idx_to_ntfy (priv, idx);struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx]; +if (!gve_rx_was_added_to_block (priv, idx)) +continue ;napi_disable (&block->napi); }
@@ -1965,6 +1969,9 @@ static void gve_turnup(struct gve_priv *priv)int ntfy_idx =gve_tx_idx_to_ntfy (priv, idx);struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx]; +if (!gve_tx_was_added_to_block (priv, idx)) +continue ; +napi_enable (&block->napi);if (gve_is_gqi (priv)) {iowrite32be (0 ,gve_irq_doorbell (priv, block));
@@ -1977,6 +1984,9 @@ static void gve_turnup(struct gve_priv *priv)int ntfy_idx =gve_rx_idx_to_ntfy (priv, idx);struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx]; +if (!gve_rx_was_added_to_block (priv, idx)) +continue ; +napi_enable (&block->napi);if (gve_is_gqi (priv)) {iowrite32be (0 ,gve_irq_doorbell (priv, block));
Signature · 1 line
2.45.0.rc0.197.gbae5840b3b-goog
PATCH v2 5/10 gve: Make gve_turnup work for nonempty queues
In reply to Shailend ChandgVNIC has a requirement that all queues have to be quiesced before any queue is operated on (created or destroyed). To enable the implementation of future ndo hooks that work on a single queue, we need to evolve gve_turnup to account for queues already having some unprocessed descriptors in the ring.
Say rxq 4 is being stopped and started via the queue api. Due to gve's requirement of quiescence, queues 0 through 3 are not processing their rings while queue 4 is being toggled. Once they are made live, these queues need to be poked to cause them to check their rings for descriptors that were written during their brief period of quiescence.
--- drivers/net/ethernet/google/gve/gve_main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/net/ethernet/google/gve/gve_main.c +14 -0
@@ -1979,6 +1979,13 @@ static void gve_turnup(struct gve_priv *priv)gve_set_itr_coalesce_usecs_dqo (priv, block, priv->tx_coalesce_usecs); } + +/* Any descs written by the NIC before this barrier will be +* handled by the one-off napi schedule below. Whereas any +* descs after the barrier will generate interrupts. +*/ +mb (); +napi_schedule (&block->napi); }for (idx =0 ; idx < priv->rx_cfg.num_queues; idx++) {int ntfy_idx =gve_rx_idx_to_ntfy (priv, idx);
@@ -1994,6 +2001,13 @@ static void gve_turnup(struct gve_priv *priv)gve_set_itr_coalesce_usecs_dqo (priv, block, priv->rx_coalesce_usecs); } + +/* Any descs written by the NIC before this barrier will be +* handled by the one-off napi schedule below. Whereas any +* descs after the barrier will generate interrupts. +*/ +mb (); +napi_schedule (&block->napi); }gve_set_napi_enabled (priv);
Signature · 1 line
2.45.0.rc0.197.gbae5840b3b-goog
PATCH v2 6/10 gve: Avoid rescheduling napi if on wrong cpu
In reply to Shailend ChandIn order to make possible the implementation of per-queue ndo hooks, gve_turnup was changed in a previous patch to account for queues already having some unprocessed descriptors: it does a one-off napi_schdule to handle them. If conditions of consistent high traffic persist in the immediate aftermath of this, the poll routine for a queue can be "stuck" on the cpu on which the ndo hooks ran, instead of the cpu its irq has affinity with.
This situation is exacerbated by the fact that the ndo hooks for all the queues are invoked on the same cpu, potentially causing all the napi poll routines to be residing on the same cpu.
A self correcting mechanism in the poll method itself solves this problem.
--- drivers/net/ethernet/google/gve/gve.h | 1 + drivers/net/ethernet/google/gve/gve_main.c | 33 ++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-)
drivers/net/ethernet/google/gve/gve.h +1 -0
@@ -610,6 +610,7 @@ struct gve_notify_block {struct gve_priv *priv;struct gve_tx_ring *tx;/* tx rings on this block */ struct gve_rx_ring *rx;/* rx rings on this block */ +u32 irq; };/* Tracks allowed and current queue settings */
drivers/net/ethernet/google/gve/gve_main.c +31 -2
@@ -9,6 +9,7 @@#include <linux/etherdevice.h> #include <linux/filter.h> #include <linux/interrupt.h> +#include <linux/irq.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/sched.h>
@@ -253,6 +254,18 @@ static irqreturn_t gve_intr_dqo(int irq, void *arg)return IRQ_HANDLED ; } +static int gve_is_napi_on_home_cpu (struct gve_priv *priv,u32 irq) +{ +int cpu_curr =smp_processor_id (); +const struct cpumask *aff_mask; + + aff_mask =irq_get_effective_affinity_mask (irq); +if (unlikely (!aff_mask)) +return 1 ; + +return cpumask_test_cpu (cpu_curr, aff_mask); +} +int gve_napi_poll (struct napi_struct *napi,int budget) {struct gve_notify_block *block;
@@ -322,8 +335,21 @@ int gve_napi_poll_dqo(struct napi_struct *napi, int budget) reschedule |= work_done == budget; } -if (reschedule) -return budget; +if (reschedule) { +/* Reschedule by returning budget only if already on the correct +* cpu. +*/ +if (likely (gve_is_napi_on_home_cpu (priv, block->irq))) +return budget; + +/* If not on the cpu with which this queue's irq has affinity +* with, we avoid rescheduling napi and arm the irq instead so +* that napi gets rescheduled back eventually onto the right +* cpu. +*/ +if (work_done == budget) + work_done--; + }if (likely (napi_complete_done (napi, work_done))) {/* Enable interrupts again.
@@ -428,6 +454,7 @@ static int gve_alloc_notify_blocks(struct gve_priv *priv) "Failed to receive msix vector %d\n", i); goto abort_with_some_ntfy_blocks; } + block->irq = priv->msix_vectors[msix_idx].vector;irq_set_affinity_hint (priv->msix_vectors[msix_idx].vector,get_cpu_mask (i % active_cpus)); block->irq_db_index = &priv->irq_db_indices[i].index;
@@ -441,6 +468,7 @@ static int gve_alloc_notify_blocks(struct gve_priv *priv)irq_set_affinity_hint (priv->msix_vectors[msix_idx].vector,NULL );free_irq (priv->msix_vectors[msix_idx].vector, block); + block->irq =0 ; }kvfree (priv->ntfy_blocks); priv->ntfy_blocks =NULL ;
@@ -474,6 +502,7 @@ static void gve_free_notify_blocks(struct gve_priv *priv)irq_set_affinity_hint (priv->msix_vectors[msix_idx].vector,NULL );free_irq (priv->msix_vectors[msix_idx].vector, block); + block->irq =0 ; }free_irq (priv->msix_vectors[priv->mgmt_msix_idx].vector, priv);kvfree (priv->ntfy_blocks);
Signature · 1 line
2.45.0.rc0.197.gbae5840b3b-goog
PATCH v2 7/10 gve: Reset Rx ring state in the ring-stop funcs
In reply to Shailend ChandThis does not fix any existing bug. In anticipation of the ndo queue api hooks that alloc/free/start/stop a single Rx queue, the already existing per-queue stop functions are being made more robust. Specifically for this use case: rx_queue_n.stop() + rx_queue_n.start()
Note that this is not the use case being used in devmem tcp (the first place these new ndo hooks would be used). There the usecase is:new_queue.alloc() + old_queue.stop() + new_queue.start() + old_queue.free()
--- drivers/net/ethernet/google/gve/gve_rx.c | 48 +++++++-- drivers/net/ethernet/google/gve/gve_rx_dqo.c | 102 +++++++++++++++---- 2 files changed, 120 insertions(+), 30 deletions(-)
drivers/net/ethernet/google/gve/gve_rx.c +37 -11
@@ -53,6 +53,41 @@ static void gve_rx_unfill_pages(struct gve_priv *priv, rx->data.page_info =NULL ; } +static void gve_rx_ctx_clear (struct gve_rx_ctx *ctx) +{ + ctx->skb_head =NULL ; + ctx->skb_tail =NULL ; + ctx->total_size =0 ; + ctx->frag_cnt =0 ; + ctx->drop_pkt = false; +} + +static void gve_rx_init_ring_state_gqi (struct gve_rx_ring *rx) +{ + rx->desc.seqno =1 ; + rx->cnt =0 ; +gve_rx_ctx_clear (&rx->ctx); +} + +static void gve_rx_reset_ring_gqi (struct gve_priv *priv,int idx) +{ +struct gve_rx_ring *rx = &priv->rx[idx]; +const u32 slots = priv->rx_desc_cnt; +size_t size; + +/* Reset desc ring */ +if (rx->desc.desc_ring) { + size = slots *sizeof (rx->desc.desc_ring[0 ]); +memset (rx->desc.desc_ring,0 , size); + } + +/* Reset q_resources */ +if (rx->q_resources) +memset (rx->q_resources,0 ,sizeof (*rx->q_resources)); + +gve_rx_init_ring_state_gqi (rx); +} +void gve_rx_stop_ring_gqi (struct gve_priv *priv,int idx) {int ntfy_idx =gve_rx_idx_to_ntfy (priv, idx);
@@ -62,6 +97,7 @@ void gve_rx_stop_ring_gqi(struct gve_priv *priv, int idx)gve_remove_napi (priv, ntfy_idx);gve_rx_remove_from_block (priv, idx); +gve_rx_reset_ring_gqi (priv, idx); } static void gve_rx_free_ring_gqi(struct gve_priv *priv, struct gve_rx_ring *rx,
@@ -222,15 +258,6 @@ static int gve_rx_prefill_pages(struct gve_rx_ring *rx,return err; } -static void gve_rx_ctx_clear (struct gve_rx_ctx *ctx) -{ - ctx->skb_head =NULL ; - ctx->skb_tail =NULL ; - ctx->total_size =0 ; - ctx->frag_cnt =0 ; - ctx->drop_pkt = false; -} -void gve_rx_start_ring_gqi (struct gve_priv *priv,int idx) {int ntfy_idx =gve_rx_idx_to_ntfy (priv, idx);
@@ -309,9 +336,8 @@ static int gve_rx_alloc_ring_gqi(struct gve_priv *priv, err = -ENOMEM ; goto abort_with_q_resources; } - rx->cnt =0 ; rx->db_threshold = slots /2 ; - rx->desc.seqno =1 ; +gve_rx_init_ring_state_gqi (rx); rx->packet_buffer_size =GVE_DEFAULT_RX_BUFFER_SIZE ;gve_rx_ctx_clear (&rx->ctx);
drivers/net/ethernet/google/gve/gve_rx_dqo.c +83 -19
148 lines not on this page · raw message
Signature · 1 line
2.45.0.rc0.197.gbae5840b3b-goog
PATCH v2 8/10 gve: Account for stopped queues when reading NIC stats
In reply to Shailend ChandWe now account for the fact that the NIC might send us stats for a subset of queues. Without this change, gve_get_ethtool_stats might make an invalid access on the priv->stats_report->stats array.
--- drivers/net/ethernet/google/gve/gve_ethtool.c | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-)
drivers/net/ethernet/google/gve/gve_ethtool.c +35 -6
@@ -8,6 +8,7 @@#include "gve.h" #include "gve_adminq.h" #include "gve_dqo.h" +#include "gve_utils.h" static void gve_get_drvinfo (struct net_device *netdev,struct ethtool_drvinfo *info)
@@ -165,6 +166,8 @@ gve_get_ethtool_stats(struct net_device *netdev,struct stats *report_stats;int *rx_qid_to_stats_idx;int *tx_qid_to_stats_idx; +int num_stopped_rxqs =0 ; +int num_stopped_txqs =0 ;struct gve_priv *priv;bool skip_nic_stats;unsigned int start;
@@ -181,12 +184,23 @@ gve_get_ethtool_stats(struct net_device *netdev, sizeof(int), GFP_KERNEL);if (!rx_qid_to_stats_idx)return ; +for (ring =0 ; ring < priv->rx_cfg.num_queues; ring++) { + rx_qid_to_stats_idx[ring] =-1 ; +if (!gve_rx_was_added_to_block (priv, ring)) + num_stopped_rxqs++; + } tx_qid_to_stats_idx =kmalloc_array (num_tx_queues,sizeof (int ),GFP_KERNEL );if (!tx_qid_to_stats_idx) {kfree (rx_qid_to_stats_idx);return ; } +for (ring =0 ; ring < num_tx_queues; ring++) { + tx_qid_to_stats_idx[ring] =-1 ; +if (!gve_tx_was_added_to_block (priv, ring)) + num_stopped_txqs++; + } + for (rx_pkts = 0, rx_bytes = 0, rx_hsplit_pkt = 0, rx_skb_alloc_fail = 0, rx_buf_alloc_fail = 0, rx_desc_err_dropped_pkt = 0, rx_hsplit_unsplit_pkt = 0,
@@ -260,7 +274,13 @@ gve_get_ethtool_stats(struct net_device *netdev,/* For rx cross-reporting stats, start from nic rx stats in report */ base_stats_idx =GVE_TX_STATS_REPORT_NUM * num_tx_queues +GVE_RX_STATS_REPORT_NUM * priv->rx_cfg.num_queues; - max_stats_idx =NIC_RX_STATS_REPORT_NUM * priv->rx_cfg.num_queues + +/* The boundary between driver stats and NIC stats shifts if there are +* stopped queues. +*/ + base_stats_idx +=NIC_RX_STATS_REPORT_NUM * num_stopped_rxqs + +NIC_TX_STATS_REPORT_NUM * num_stopped_txqs; + max_stats_idx =NIC_RX_STATS_REPORT_NUM * + (priv->rx_cfg.num_queues - num_stopped_rxqs) + base_stats_idx;/* Preprocess the stats report for rx, map queue id to start index */ skip_nic_stats = false;
@@ -274,6 +294,10 @@ gve_get_ethtool_stats(struct net_device *netdev, skip_nic_stats = true;break ; } +if (queue_id <0 || queue_id >= priv->rx_cfg.num_queues) { +net_err_ratelimited ("Invalid rxq id in NIC stats\n" ); +continue ; + } rx_qid_to_stats_idx[queue_id] = stats_idx; }/* walk RX rings */
@@ -308,11 +332,11 @@ gve_get_ethtool_stats(struct net_device *netdev, data[i++] = rx->rx_copybreak_pkt; data[i++] = rx->rx_copied_pkt;/* stats from NIC */ -if (skip_nic_stats) { + stats_idx = rx_qid_to_stats_idx[ring]; +if (skip_nic_stats || stats_idx <0 ) {/* skip NIC rx stats */ i +=NIC_RX_STATS_REPORT_NUM ; }else { - stats_idx = rx_qid_to_stats_idx[ring];for (j =0 ; j <NIC_RX_STATS_REPORT_NUM ; j++) {u64 value =be64_to_cpu (report_stats[stats_idx + j].value);
@@ -338,7 +362,8 @@ gve_get_ethtool_stats(struct net_device *netdev,/* For tx cross-reporting stats, start from nic tx stats in report */ base_stats_idx = max_stats_idx; - max_stats_idx =NIC_TX_STATS_REPORT_NUM * num_tx_queues + + max_stats_idx =NIC_TX_STATS_REPORT_NUM * + (num_tx_queues - num_stopped_txqs) + max_stats_idx;/* Preprocess the stats report for tx, map queue id to start index */ skip_nic_stats = false;
@@ -352,6 +377,10 @@ gve_get_ethtool_stats(struct net_device *netdev, skip_nic_stats = true;break ; } +if (queue_id <0 || queue_id >= num_tx_queues) { +net_err_ratelimited ("Invalid txq id in NIC stats\n" ); +continue ; + } tx_qid_to_stats_idx[queue_id] = stats_idx; }/* walk TX rings */
@@ -383,11 +412,11 @@ gve_get_ethtool_stats(struct net_device *netdev, data[i++] =gve_tx_load_event_counter (priv, tx); data[i++] = tx->dma_mapping_error;/* stats from NIC */ -if (skip_nic_stats) { + stats_idx = tx_qid_to_stats_idx[ring]; +if (skip_nic_stats || stats_idx <0 ) {/* skip NIC tx stats */ i +=NIC_TX_STATS_REPORT_NUM ; }else { - stats_idx = tx_qid_to_stats_idx[ring];for (j =0 ; j <NIC_TX_STATS_REPORT_NUM ; j++) {u64 value =be64_to_cpu (report_stats[stats_idx + j].value);
Signature · 1 line
2.45.0.rc0.197.gbae5840b3b-goog
PATCH v2 9/10 gve: Alloc and free QPLs with the rings
In reply to Shailend ChandEvery tx and rx ring has its own queue-page-list (QPL) that serves as the bounce buffer. Previously we were allocating QPLs for all queues before the queues themselves were allocated and later associating a QPL with a queue. This is avoidable complexity: it is much more natural for each queue to allocate and free its own QPL.
Moreover, the advent of new queue-manipulating ndo hooks make it hard to keep things as is: we would need to transfer a QPL from an old queue to a new queue, and that is unpleasant.
--- drivers/net/ethernet/google/gve/gve.h | 30 +- drivers/net/ethernet/google/gve/gve_ethtool.c | 7 +- drivers/net/ethernet/google/gve/gve_main.c | 343 +++++------------- drivers/net/ethernet/google/gve/gve_rx.c | 43 ++- drivers/net/ethernet/google/gve/gve_rx_dqo.c | 23 +- drivers/net/ethernet/google/gve/gve_tx.c | 33 +- drivers/net/ethernet/google/gve/gve_tx_dqo.c | 23 +- 7 files changed, 171 insertions(+), 331 deletions(-)
drivers/net/ethernet/google/gve/gve.h +6 -24
@@ -638,26 +638,10 @@ struct gve_ptype_lut {struct gve_ptype ptypes[GVE_NUM_PTYPES ]; }; -/* Parameters for allocating queue page lists */ -struct gve_qpls_alloc_cfg { -struct gve_queue_config *tx_cfg; -struct gve_queue_config *rx_cfg; - -u16 num_xdp_queues; -bool raw_addressing; -bool is_gqi; - -/* Allocated resources are returned here */ -struct gve_queue_page_list *qpls; -}; -/* Parameters for allocating resources for tx queues */ struct gve_tx_alloc_rings_cfg {struct gve_queue_config *qcfg; -/* qpls must already be allocated */ -struct gve_queue_page_list *qpls; -u16 ring_size;u16 start_idx;u16 num_rings;
@@ -673,9 +657,6 @@ struct gve_rx_alloc_rings_cfg {struct gve_queue_config *qcfg;struct gve_queue_config *qcfg_tx; -/* qpls must already be allocated */ -struct gve_queue_page_list *qpls; -u16 ring_size;u16 packet_buffer_size;bool raw_addressing;
@@ -701,7 +682,6 @@ struct gve_priv {struct net_device *dev;struct gve_tx_ring *tx;/* array of tx_cfg.num_queues */ struct gve_rx_ring *rx;/* array of rx_cfg.num_queues */ -struct gve_queue_page_list *qpls;/* array of num qpls */ struct gve_notify_block *ntfy_blocks;/* array of num_ntfy_blks */ struct gve_irq_db *irq_db_indices;/* array of num_ntfy_blks */ dma_addr_t irq_db_indices_bus;
@@ -1025,7 +1005,6 @@ static inline u32 gve_rx_qpl_id(struct gve_priv *priv, int rx_qid)return priv->tx_cfg.max_queues + rx_qid; } -/* Returns the index into priv->qpls where a certain rx queue's QPL resides */ static inline u32 gve_get_rx_qpl_id (const struct gve_queue_config *tx_cfg,int rx_qid) {return tx_cfg->max_queues + rx_qid;
@@ -1036,7 +1015,6 @@ static inline u32 gve_tx_start_qpl_id(struct gve_priv *priv)return gve_tx_qpl_id (priv,0 ); } -/* Returns the index into priv->qpls where the first rx queue's QPL resides */ static inline u32 gve_rx_start_qpl_id (const struct gve_queue_config *tx_cfg) {return gve_get_rx_qpl_id (tx_cfg,0 );
@@ -1090,6 +1068,12 @@ int gve_alloc_page(struct gve_priv *priv, struct device *dev, enum dma_data_direction, gfp_t gfp_flags);void gve_free_page (struct device *dev,struct page *page,dma_addr_t dma,enum dma_data_direction ); +/* qpls */ +struct gve_queue_page_list *gve_alloc_queue_page_list (struct gve_priv *priv, +u32 id,int pages); +void gve_free_queue_page_list (struct gve_priv *priv, +struct gve_queue_page_list *qpl, +u32 id);/* tx handling */ netdev_tx_t gve_tx (struct sk_buff *skb,struct net_device *dev); int gve_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
@@ -1126,11 +1110,9 @@ int gve_set_hsplit_config(struct gve_priv *priv, u8 tcp_data_split);void gve_schedule_reset (struct gve_priv *priv);int gve_reset (struct gve_priv *priv,bool attempt_teardown);void gve_get_curr_alloc_cfgs (struct gve_priv *priv, -struct gve_qpls_alloc_cfg *qpls_alloc_cfg,struct gve_tx_alloc_rings_cfg *tx_alloc_cfg,struct gve_rx_alloc_rings_cfg *rx_alloc_cfg);int gve_adjust_config (struct gve_priv *priv, -struct gve_qpls_alloc_cfg *qpls_alloc_cfg,struct gve_tx_alloc_rings_cfg *tx_alloc_cfg,struct gve_rx_alloc_rings_cfg *rx_alloc_cfg); int gve_adjust_queues(struct gve_priv *priv,
drivers/net/ethernet/google/gve/gve_ethtool.c +2 -5
@@ -538,20 +538,17 @@ static int gve_adjust_ring_sizes(struct gve_priv *priv, {struct gve_tx_alloc_rings_cfg tx_alloc_cfg = {0 };struct gve_rx_alloc_rings_cfg rx_alloc_cfg = {0 }; -struct gve_qpls_alloc_cfg qpls_alloc_cfg = {0 };int err;/* get current queue configuration */ -gve_get_curr_alloc_cfgs (priv, &qpls_alloc_cfg, - &tx_alloc_cfg, &rx_alloc_cfg); +gve_get_curr_alloc_cfgs (priv, &tx_alloc_cfg, &rx_alloc_cfg);/* copy over the new ring_size from ethtool */ tx_alloc_cfg.ring_size = new_tx_desc_cnt; rx_alloc_cfg.ring_size = new_rx_desc_cnt;if (netif_running (priv->dev)) { - err =gve_adjust_config (priv, &qpls_alloc_cfg, - &tx_alloc_cfg, &rx_alloc_cfg); + err =gve_adjust_config (priv, &tx_alloc_cfg, &rx_alloc_cfg);if (err)return err; }
drivers/net/ethernet/google/gve/gve_main.c +86 -257
647 lines not on this page · raw message
drivers/net/ethernet/google/gve/gve_rx.c +27 -16
100 lines not on this page · raw message
drivers/net/ethernet/google/gve/gve_rx_dqo.c +14 -9
@@ -307,6 +307,7 @@ static void gve_rx_free_ring_dqo(struct gve_priv *priv, struct gve_rx_ring *rx,size_t buffer_queue_slots;int idx = rx->q_num;size_t size; +u32 qpl_id;int i; completion_queue_slots = rx->dqo.complq.mask +1 ;
@@ -325,7 +326,11 @@ static void gve_rx_free_ring_dqo(struct gve_priv *priv, struct gve_rx_ring *rx,gve_free_page_dqo (priv, bs, !rx->dqo.qpl); } - rx->dqo.qpl =NULL ; +if (rx->dqo.qpl) { + qpl_id =gve_get_rx_qpl_id (cfg->qcfg_tx, rx->q_num); +gve_free_queue_page_list (priv, rx->dqo.qpl, qpl_id); + rx->dqo.qpl =NULL ; + }if (rx->dqo.bufq.desc_ring) { size =sizeof (rx->dqo.bufq.desc_ring[0 ]) * buffer_queue_slots;
@@ -377,7 +382,9 @@ static int gve_rx_alloc_ring_dqo(struct gve_priv *priv, int idx) {struct device *hdev = &priv->pdev->dev; +int qpl_page_cnt;size_t size; +u32 qpl_id;const u32 buffer_queue_slots = cfg->ring_size;const u32 completion_queue_slots = cfg->ring_size;
@@ -418,9 +425,13 @@ static int gve_rx_alloc_ring_dqo(struct gve_priv *priv, goto err;if (!cfg->raw_addressing) { -u32 qpl_id =gve_get_rx_qpl_id (cfg->qcfg_tx, rx->q_num); + qpl_id =gve_get_rx_qpl_id (cfg->qcfg_tx, rx->q_num); + qpl_page_cnt =gve_get_rx_pages_per_qpl_dqo (cfg->ring_size); - rx->dqo.qpl = &cfg->qpls[qpl_id]; + rx->dqo.qpl =gve_alloc_queue_page_list (priv, qpl_id, + qpl_page_cnt); +if (!rx->dqo.qpl) + goto err; rx->dqo.next_qpl_page_idx =0 ; }
@@ -454,12 +465,6 @@ int gve_rx_alloc_rings_dqo(struct gve_priv *priv,int err;int i; -if (!cfg->raw_addressing && !cfg->qpls) { -netif_err (priv, drv, priv->dev, -"Cannot alloc QPL ring before allocing QPLs\n" ); -return -EINVAL ; - } - rx =kvcalloc (cfg->qcfg->max_queues,sizeof (struct gve_rx_ring ),GFP_KERNEL );if (!rx)
drivers/net/ethernet/google/gve/gve_tx.c +22 -11
@@ -216,6 +216,7 @@ static void gve_tx_free_ring_gqi(struct gve_priv *priv, struct gve_tx_ring *tx,struct device *hdev = &priv->pdev->dev;int idx = tx->q_num;size_t bytes; +u32 qpl_id;u32 slots; slots = tx->mask +1 ;
@@ -223,8 +224,12 @@ static void gve_tx_free_ring_gqi(struct gve_priv *priv, struct gve_tx_ring *tx, tx->q_resources, tx->q_resources_bus); tx->q_resources =NULL ; -if (!tx->raw_addressing) { -gve_tx_fifo_release (priv, &tx->tx_fifo); +if (tx->tx_fifo.qpl) { +if (tx->tx_fifo.base) +gve_tx_fifo_release (priv, &tx->tx_fifo); + + qpl_id =gve_tx_qpl_id (priv, tx->q_num); +gve_free_queue_page_list (priv, tx->tx_fifo.qpl, qpl_id); tx->tx_fifo.qpl =NULL ; }
@@ -255,6 +260,8 @@ static int gve_tx_alloc_ring_gqi(struct gve_priv *priv, int idx) {struct device *hdev = &priv->pdev->dev; +int qpl_page_cnt; +u32 qpl_id =0 ;size_t bytes;/* Make sure everything is zeroed to start */
@@ -279,12 +286,17 @@ static int gve_tx_alloc_ring_gqi(struct gve_priv *priv, tx->raw_addressing = cfg->raw_addressing; tx->dev = hdev;if (!tx->raw_addressing) { -u32 qpl_id =gve_tx_qpl_id (priv, tx->q_num); + qpl_id =gve_tx_qpl_id (priv, tx->q_num); + qpl_page_cnt = priv->tx_pages_per_qpl; + + tx->tx_fifo.qpl =gve_alloc_queue_page_list (priv, qpl_id, + qpl_page_cnt); +if (!tx->tx_fifo.qpl) + goto abort_with_desc; - tx->tx_fifo.qpl = &cfg->qpls[qpl_id];/* map Tx FIFO */ if (gve_tx_fifo_init (priv, &tx->tx_fifo)) - goto abort_with_desc; + goto abort_with_qpl; } tx->q_resources =
@@ -300,6 +312,11 @@ static int gve_tx_alloc_ring_gqi(struct gve_priv *priv, abort_with_fifo:if (!tx->raw_addressing)gve_tx_fifo_release (priv, &tx->tx_fifo); +abort_with_qpl: +if (!tx->raw_addressing) { +gve_free_queue_page_list (priv, tx->tx_fifo.qpl, qpl_id); + tx->tx_fifo.qpl =NULL ; + } abort_with_desc:dma_free_coherent (hdev, bytes, tx->desc, tx->bus); tx->desc =NULL ;
@@ -316,12 +333,6 @@ int gve_tx_alloc_rings_gqi(struct gve_priv *priv,int err =0 ;int i, j; -if (!cfg->raw_addressing && !cfg->qpls) { -netif_err (priv, drv, priv->dev, -"Cannot alloc QPL ring before allocing QPLs\n" ); -return -EINVAL ; - } -if (cfg->start_idx + cfg->num_rings > cfg->qcfg->max_queues) {netif_err (priv, drv, priv->dev,"Cannot alloc more than the max num of Tx rings\n" );
drivers/net/ethernet/google/gve/gve_tx_dqo.c +14 -9
@@ -209,6 +209,7 @@ static void gve_tx_free_ring_dqo(struct gve_priv *priv, struct gve_tx_ring *tx,struct device *hdev = &priv->pdev->dev;int idx = tx->q_num;size_t bytes; +u32 qpl_id;if (tx->q_resources) { dma_free_coherent(hdev, sizeof(*tx->q_resources),
@@ -236,7 +237,11 @@ static void gve_tx_free_ring_dqo(struct gve_priv *priv, struct gve_tx_ring *tx,kvfree (tx->dqo.tx_qpl_buf_next); tx->dqo.tx_qpl_buf_next =NULL ; - tx->dqo.qpl =NULL ; +if (tx->dqo.qpl) { + qpl_id =gve_tx_qpl_id (priv, tx->q_num); +gve_free_queue_page_list (priv, tx->dqo.qpl, qpl_id); + tx->dqo.qpl =NULL ; + }netif_dbg (priv, drv, priv->dev,"freed tx queue %d\n" , idx); }
@@ -282,7 +287,9 @@ static int gve_tx_alloc_ring_dqo(struct gve_priv *priv, {struct device *hdev = &priv->pdev->dev;int num_pending_packets; +int qpl_page_cnt;size_t bytes; +u32 qpl_id;int i;memset (tx,0 ,sizeof (*tx));
@@ -349,9 +356,13 @@ static int gve_tx_alloc_ring_dqo(struct gve_priv *priv, goto err;if (!cfg->raw_addressing) { -u32 qpl_id =gve_tx_qpl_id (priv, tx->q_num); + qpl_id =gve_tx_qpl_id (priv, tx->q_num); + qpl_page_cnt = priv->tx_pages_per_qpl; - tx->dqo.qpl = &cfg->qpls[qpl_id]; + tx->dqo.qpl =gve_alloc_queue_page_list (priv, qpl_id, + qpl_page_cnt); +if (!tx->dqo.qpl) + goto err;if (gve_tx_qpl_buf_init (tx)) goto err;
@@ -371,12 +382,6 @@ int gve_tx_alloc_rings_dqo(struct gve_priv *priv,int err =0 ;int i, j; -if (!cfg->raw_addressing && !cfg->qpls) { -netif_err (priv, drv, priv->dev, -"Cannot alloc QPL ring before allocing QPLs\n" ); -return -EINVAL ; - } -if (cfg->start_idx + cfg->num_rings > cfg->qcfg->max_queues) {netif_err (priv, drv, priv->dev,"Cannot alloc more than the max num of Tx rings\n" );
Signature · 1 line
2.45.0.rc0.197.gbae5840b3b-goog
PATCH v2 10/10 gve: Implement queue api
In reply to Shailend ChandThe new netdev queue api is implemented for gve.
--- drivers/net/ethernet/google/gve/gve.h | 6 + drivers/net/ethernet/google/gve/gve_dqo.h | 6 + drivers/net/ethernet/google/gve/gve_main.c | 177 +++++++++++++++++-- drivers/net/ethernet/google/gve/gve_rx.c | 12 +- drivers/net/ethernet/google/gve/gve_rx_dqo.c | 12 +- 5 files changed, 189 insertions(+), 24 deletions(-)
drivers/net/ethernet/google/gve/gve.h +6 -0
@@ -1096,6 +1096,12 @@ bool gve_tx_clean_pending(struct gve_priv *priv, struct gve_tx_ring *tx);void gve_rx_write_doorbell (struct gve_priv *priv,struct gve_rx_ring *rx);int gve_rx_poll (struct gve_notify_block *block,int budget);bool gve_rx_work_pending (struct gve_rx_ring *rx); +int gve_rx_alloc_ring_gqi (struct gve_priv *priv, +struct gve_rx_alloc_rings_cfg *cfg, +struct gve_rx_ring *rx, +int idx); +void gve_rx_free_ring_gqi (struct gve_priv *priv,struct gve_rx_ring *rx, +struct gve_rx_alloc_rings_cfg *cfg);int gve_rx_alloc_rings (struct gve_priv *priv);int gve_rx_alloc_rings_gqi (struct gve_priv *priv,struct gve_rx_alloc_rings_cfg *cfg);
drivers/net/ethernet/google/gve/gve_dqo.h +6 -0
@@ -44,6 +44,12 @@ void gve_tx_free_rings_dqo(struct gve_priv *priv, struct gve_tx_alloc_rings_cfg *cfg);void gve_tx_start_ring_dqo (struct gve_priv *priv,int idx);void gve_tx_stop_ring_dqo (struct gve_priv *priv,int idx); +int gve_rx_alloc_ring_dqo (struct gve_priv *priv, +struct gve_rx_alloc_rings_cfg *cfg, +struct gve_rx_ring *rx, +int idx); +void gve_rx_free_ring_dqo (struct gve_priv *priv,struct gve_rx_ring *rx, +struct gve_rx_alloc_rings_cfg *cfg);int gve_rx_alloc_rings_dqo (struct gve_priv *priv,struct gve_rx_alloc_rings_cfg *cfg); void gve_rx_free_rings_dqo(struct gve_priv *priv,
drivers/net/ethernet/google/gve/gve_main.c +165 -12
217 lines not on this page · raw message
drivers/net/ethernet/google/gve/gve_rx.c +6 -6
@@ -99,8 +99,8 @@ void gve_rx_stop_ring_gqi(struct gve_priv *priv, int idx)gve_rx_reset_ring_gqi (priv, idx); } -static void gve_rx_free_ring_gqi (struct gve_priv *priv,struct gve_rx_ring *rx, -struct gve_rx_alloc_rings_cfg *cfg) +void gve_rx_free_ring_gqi (struct gve_priv *priv,struct gve_rx_ring *rx, +struct gve_rx_alloc_rings_cfg *cfg) {struct device *dev = &priv->pdev->dev;u32 slots = rx->mask +1 ;
@@ -264,10 +264,10 @@ void gve_rx_start_ring_gqi(struct gve_priv *priv, int idx)gve_add_napi (priv, ntfy_idx, gve_napi_poll); } -static int gve_rx_alloc_ring_gqi (struct gve_priv *priv, -struct gve_rx_alloc_rings_cfg *cfg, -struct gve_rx_ring *rx, -int idx) +int gve_rx_alloc_ring_gqi (struct gve_priv *priv, +struct gve_rx_alloc_rings_cfg *cfg, +struct gve_rx_ring *rx, +int idx) {struct device *hdev = &priv->pdev->dev;u32 slots = cfg->ring_size;
drivers/net/ethernet/google/gve/gve_rx_dqo.c +6 -6
@@ -299,8 +299,8 @@ void gve_rx_stop_ring_dqo(struct gve_priv *priv, int idx)gve_rx_reset_ring_dqo (priv, idx); } -static void gve_rx_free_ring_dqo (struct gve_priv *priv,struct gve_rx_ring *rx, -struct gve_rx_alloc_rings_cfg *cfg) +void gve_rx_free_ring_dqo (struct gve_priv *priv,struct gve_rx_ring *rx, +struct gve_rx_alloc_rings_cfg *cfg) {struct device *hdev = &priv->pdev->dev;size_t completion_queue_slots;
@@ -376,10 +376,10 @@ void gve_rx_start_ring_dqo(struct gve_priv *priv, int idx)gve_add_napi (priv, ntfy_idx, gve_napi_poll_dqo); } -static int gve_rx_alloc_ring_dqo (struct gve_priv *priv, -struct gve_rx_alloc_rings_cfg *cfg, -struct gve_rx_ring *rx, -int idx) +int gve_rx_alloc_ring_dqo (struct gve_priv *priv, +struct gve_rx_alloc_rings_cfg *cfg, +struct gve_rx_ring *rx, +int idx) {struct device *hdev = &priv->pdev->dev;int qpl_page_cnt;
Signature · 1 line
2.45.0.rc0.197.gbae5840b3b-goog
Quoted 15 lines · Shailend Chand
The new netdev queue api is implemented for gve.
Tested-by Mina Almasry <[email protected]>Reviewed-by Mina Almasry <[email protected]>Reviewed-by Praveen Kaligineedi <[email protected]>Reviewed-by Harshitha Ramamurthy <[email protected]>Signed-off-by Shailend Chand <[email protected]>--- drivers/net/ethernet/google/gve/gve.h | 6 + drivers/net/ethernet/google/gve/gve_dqo.h | 6 + drivers/net/ethernet/google/gve/gve_main.c | 177 +++++++++++++++++-- drivers/net/ethernet/google/gve/gve_rx.c | 12 +- drivers/net/ethernet/google/gve/gve_rx_dqo.c | 12 +- 5 files changed, 189 insertions(+), 24 deletions(-)
[...]
drivers/net/ethernet/google/gve/gve_main.c static void gve_write_version(u8 __iomem *driver_version_register) · line 2476
Quoted 7 lines
drivers/net/ethernet/google/gve/gve_main.c +7
-0+static const struct netdev_queue_mgmt_ops gve_queue_mgmt_ops = { + .ndo_queue_mem_size =sizeof (struct gve_rx_ring ), + .ndo_queue_mem_alloc = gve_rx_queue_mem_alloc, + .ndo_queue_mem_free = gve_rx_queue_mem_free, + .ndo_queue_start = gve_rx_queue_start, + .ndo_queue_stop = gve_rx_queue_stop, +};
Shailend, Mina, do you have code that calls the ndos somewhere?
Quoted 20 lines · David Wei
Quoted 15 lines · Shailend Chand
The new netdev queue api is implemented for gve.
Tested-by Mina Almasry <[email protected]>Reviewed-by Mina Almasry <[email protected]>Reviewed-by Praveen Kaligineedi <[email protected]>Reviewed-by Harshitha Ramamurthy <[email protected]>Signed-off-by Shailend Chand <[email protected]>--- drivers/net/ethernet/google/gve/gve.h | 6 + drivers/net/ethernet/google/gve/gve_dqo.h | 6 + drivers/net/ethernet/google/gve/gve_main.c | 177 +++++++++++++++++-- drivers/net/ethernet/google/gve/gve_rx.c | 12 +- drivers/net/ethernet/google/gve/gve_rx_dqo.c | 12 +- 5 files changed, 189 insertions(+), 24 deletions(-)[...]
Quoted 9 lines
drivers/net/ethernet/google/gve/gve_main.c static void gve_write_version(u8 __iomem *driver_version_register) · line 2476
Quoted 7 lines
drivers/net/ethernet/google/gve/gve_main.c +7
-0+static const struct netdev_queue_mgmt_ops gve_queue_mgmt_ops = { + .ndo_queue_mem_size =sizeof (struct gve_rx_ring ), + .ndo_queue_mem_alloc = gve_rx_queue_mem_alloc, + .ndo_queue_mem_free = gve_rx_queue_mem_free, + .ndo_queue_start = gve_rx_queue_start, + .ndo_queue_stop = gve_rx_queue_stop, +};Shailend, Mina, do you have code that calls the ndos somewhere?
I plan to rebase the devmem TCP series on top of these ndos and submit that, likely sometime this week. The ndos should be used from an updated version of [RFC,net-next,v8,04/14] netdev: support binding dma-buf to netdevice
https://patchwork.kernel.org/project/netdevbpf/list/?series=840819&state=*
Signature · 2 lines
Thanks, Mina
Quoted 31 lines · Mina Almasry
Quoted 20 lines · David Wei
Quoted 15 lines · Shailend Chand
The new netdev queue api is implemented for gve.
Tested-by Mina Almasry <[email protected]>Reviewed-by Mina Almasry <[email protected]>Reviewed-by Praveen Kaligineedi <[email protected]>Reviewed-by Harshitha Ramamurthy <[email protected]>Signed-off-by Shailend Chand <[email protected]>--- drivers/net/ethernet/google/gve/gve.h | 6 + drivers/net/ethernet/google/gve/gve_dqo.h | 6 + drivers/net/ethernet/google/gve/gve_main.c | 177 +++++++++++++++++-- drivers/net/ethernet/google/gve/gve_rx.c | 12 +- drivers/net/ethernet/google/gve/gve_rx_dqo.c | 12 +- 5 files changed, 189 insertions(+), 24 deletions(-)[...]
Quoted 9 lines
drivers/net/ethernet/google/gve/gve_main.c static void gve_write_version(u8 __iomem *driver_version_register) · line 2476
Quoted 7 lines
drivers/net/ethernet/google/gve/gve_main.c +7
-0+static const struct netdev_queue_mgmt_ops gve_queue_mgmt_ops = { + .ndo_queue_mem_size =sizeof (struct gve_rx_ring ), + .ndo_queue_mem_alloc = gve_rx_queue_mem_alloc, + .ndo_queue_mem_free = gve_rx_queue_mem_free, + .ndo_queue_start = gve_rx_queue_start, + .ndo_queue_stop = gve_rx_queue_stop, +};Shailend, Mina, do you have code that calls the ndos somewhere?
Quoted 4 lines
I plan to rebase the devmem TCP series on top of these ndos and submit that, likely sometime this week. The ndos should be used from an updated version of [RFC,net-next,v8,04/14] netdev: support binding dma-buf to netdevice
Now that queue API ndos have merged, could you please send this as a separate series and put it somewhere where it can be re-used e.g. netdev_rx_queue.c?
Happy to do that as well if you don't want to/mind.
Quoted 33 lines · David Wei
Quoted 31 lines · Mina Almasry
Quoted 29 lines · David Wei
Quoted 15 lines · Shailend Chand
The new netdev queue api is implemented for gve.
Tested-by Mina Almasry <[email protected]>Reviewed-by Mina Almasry <[email protected]>Reviewed-by Praveen Kaligineedi <[email protected]>Reviewed-by Harshitha Ramamurthy <[email protected]>Signed-off-by Shailend Chand <[email protected]>--- drivers/net/ethernet/google/gve/gve.h | 6 + drivers/net/ethernet/google/gve/gve_dqo.h | 6 + drivers/net/ethernet/google/gve/gve_main.c | 177 +++++++++++++++++-- drivers/net/ethernet/google/gve/gve_rx.c | 12 +- drivers/net/ethernet/google/gve/gve_rx_dqo.c | 12 +- 5 files changed, 189 insertions(+), 24 deletions(-)[...]
drivers/net/ethernet/google/gve/gve_main.c static void gve_write_version(u8 __iomem *driver_version_register) · line 2476
Quoted 7 lines
drivers/net/ethernet/google/gve/gve_main.c +7
-0+static const struct netdev_queue_mgmt_ops gve_queue_mgmt_ops = { + .ndo_queue_mem_size =sizeof (struct gve_rx_ring ), + .ndo_queue_mem_alloc = gve_rx_queue_mem_alloc, + .ndo_queue_mem_free = gve_rx_queue_mem_free, + .ndo_queue_start = gve_rx_queue_start, + .ndo_queue_stop = gve_rx_queue_stop, +};Shailend, Mina, do you have code that calls the ndos somewhere?
Quoted 9 lines
Quoted 4 lines
I plan to rebase the devmem TCP series on top of these ndos and submit that, likely sometime this week. The ndos should be used from an updated version of [RFC,net-next,v8,04/14] netdev: support binding dma-buf to netdevice
Now that queue API ndos have merged, could you please send this as a separate series and put it somewhere where it can be re-used e.g.
netdev_rx_queue.c?
Definitely happy to put it in a generic place like netdev_rx_queue.c like you did, but slight pushback to putting it into its own series. With the ndos merged finally, I can take our devmem TCP series out of RFC and I am eager to do so. Making it dependent on a change that is in another series means it must remain RFC.
What I can do here is put this change into its own patch in the devmem TCP series. Once that is reviewed the maintainers may apply that patch out of the series. I can also put it in its own series and keep devmem TCP in RFC for now if you insist :D
Signature · 2 lines
Thanks, Mina
Quoted 50 lines · Mina Almasry
Quoted 33 lines · David Wei
Quoted 31 lines · Mina Almasry
Quoted 29 lines · David Wei
Quoted 15 lines · Shailend Chand
The new netdev queue api is implemented for gve.
Tested-by Mina Almasry <[email protected]>Reviewed-by Mina Almasry <[email protected]>Reviewed-by Praveen Kaligineedi <[email protected]>Reviewed-by Harshitha Ramamurthy <[email protected]>Signed-off-by Shailend Chand <[email protected]>--- drivers/net/ethernet/google/gve/gve.h | 6 + drivers/net/ethernet/google/gve/gve_dqo.h | 6 + drivers/net/ethernet/google/gve/gve_main.c | 177 +++++++++++++++++-- drivers/net/ethernet/google/gve/gve_rx.c | 12 +- drivers/net/ethernet/google/gve/gve_rx_dqo.c | 12 +- 5 files changed, 189 insertions(+), 24 deletions(-)[...]
drivers/net/ethernet/google/gve/gve_main.c static void gve_write_version(u8 __iomem *driver_version_register) · line 2476
Quoted 7 lines
drivers/net/ethernet/google/gve/gve_main.c +7
-0+static const struct netdev_queue_mgmt_ops gve_queue_mgmt_ops = { + .ndo_queue_mem_size =sizeof (struct gve_rx_ring ), + .ndo_queue_mem_alloc = gve_rx_queue_mem_alloc, + .ndo_queue_mem_free = gve_rx_queue_mem_free, + .ndo_queue_start = gve_rx_queue_start, + .ndo_queue_stop = gve_rx_queue_stop, +};Shailend, Mina, do you have code that calls the ndos somewhere?
Quoted 9 lines
Quoted 4 lines
I plan to rebase the devmem TCP series on top of these ndos and submit that, likely sometime this week. The ndos should be used from an updated version of [RFC,net-next,v8,04/14] netdev: support binding dma-buf to netdevice
Now that queue API ndos have merged, could you please send this as a separate series and put it somewhere where it can be re-used e.g.
netdev_rx_queue.c?Definitely happy to put it in a generic place like
netdev_rx_queue.clike you did, but slight pushback to putting it into its own series. With the ndos merged finally, I can take our devmem TCP series out of RFC and I am eager to do so. Making it dependent on a change that is in another series means it must remain RFC.
Quoted 4 lines
What I can do here is put this change into its own patch in the devmem TCP series. Once that is reviewed the maintainers may apply that patch out of the series. I can also put it in its own series and keep devmem TCP in RFC for now if you insist :D
No, that's fine. Please put it at the front of the series once you're ready. I'll cherrypick it into our series.
Quoted 2 lines
Quoted 16 lines · Shailend Chand
Following the discussion on
https://patchwork.kernel.org/project/linux-media/patch/[email protected]/,
the queue api defined by Mina is implemented for gve.The first patch is just Mina's introduction of the api. The rest of the patches make surgical changes in gve to enable it to work correctly with only a subset of queues present (thus far it had assumed that either all queues are up or all are down). The final patch has the api implementation.
Changes since v1: clang warning fixes, kdoc warning fix, and addressed review comments.
Mina Almasry (1):
queue_api: define queue api
Quoted 10 lines
Shailend Chand (9):
gve: Make the GQ RX free queue funcs idempotent
gve: Add adminq funcs to add/remove a single Rx queue
gve: Makegve_turn(up|down)ignore stopped queues
gve: Makegve_turnupwork for nonempty queues
gve: Avoid rescheduling napi if on wrong cpu
gve: Reset Rx ring state in the ring-stop funcs
gve: Account for stopped queues when reading NIC stats
gve: Alloc and free QPLs with the rings
gve: Implement queue api
That QPLS alloc reorg is a great simplification. Nice bonus.
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 11 lines · On Wed, 1 May 2024 23:25:39 +0000 you wrote:
Following the discussion on
https://patchwork.kernel.org/project/linux-media/patch/[email protected]/,
the queue api defined by Mina is implemented for gve.The first patch is just Mina's introduction of the api. The rest of the patches make surgical changes in gve to enable it to work correctly with only a subset of queues present (thus far it had assumed that either all queues are up or all are down). The final patch has the api implementation.
[...]
Here is the summary with links:
- [net-next,v2,01/10] queue_api: define queue api
https://git.kernel.org/netdev/net-next/c/087b24de5c82 - [net-next,v2,02/10] gve: Make the GQ RX free queue funcs idempotent https://git.kernel.org/netdev/net-next/c/dcecfcf21bd1 - [net-next,v2,03/10] gve: Add adminq funcs to add/remove a single Rx queue https://git.kernel.org/netdev/net-next/c/242f30fe692e - [net-next,v2,04/10] gve: Make gve_turn(up|down) ignore stopped queues https://git.kernel.org/netdev/net-next/c/5abc37bdcbc5 - [net-next,v2,05/10] gve: Make gve_turnup work for nonempty queues https://git.kernel.org/netdev/net-next/c/864616d97a45 - [net-next,v2,06/10] gve: Avoid rescheduling napi if on wrong cpu https://git.kernel.org/netdev/net-next/c/9a5e0776d11f - [net-next,v2,07/10] gve: Reset Rx ring state in the ring-stop funcs https://git.kernel.org/netdev/net-next/c/770f52d5a0ed - [net-next,v2,08/10] gve: Account for stopped queues when reading NIC stats https://git.kernel.org/netdev/net-next/c/af9bcf910b1f - [net-next,v2,09/10] gve: Alloc and free QPLs with the rings https://git.kernel.org/netdev/net-next/c/ee24284e2a10
- [net-next,v2,10/10] gve: Implement queue api
(no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 38 lines · On Sun, May 5, 2024 at 6:40 AM <[email protected]> wrote:
Hello:
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 11 lines · On Wed, 1 May 2024 23:25:39 +0000 you wrote:
Following the discussion on
https://patchwork.kernel.org/project/linux-media/patch/[email protected]/,
the queue api defined by Mina is implemented for gve.The first patch is just Mina's introduction of the api. The rest of the patches make surgical changes in gve to enable it to work correctly with only a subset of queues present (thus far it had assumed that either all queues are up or all are down). The final patch has the api implementation.
[...]
Here is the summary with links:
- [net-next,v2,01/10]queue_api: define queue apihttps://git.kernel.org/netdev/net-next/c/087b24de5c82 - [net-next,v2,02/10] gve: Make the GQ RX free queue funcs idempotent https://git.kernel.org/netdev/net-next/c/dcecfcf21bd1 - [net-next,v2,03/10] gve: Add adminq funcs to add/remove a single Rx queue https://git.kernel.org/netdev/net-next/c/242f30fe692e - [net-next,v2,04/10] gve: Make gve_turn(up|down) ignore stopped queues https://git.kernel.org/netdev/net-next/c/5abc37bdcbc5 - [net-next,v2,05/10] gve: Make gve_turnup work for nonempty queues https://git.kernel.org/netdev/net-next/c/864616d97a45 - [net-next,v2,06/10] gve: Avoid rescheduling napi if on wrong cpu https://git.kernel.org/netdev/net-next/c/9a5e0776d11f - [net-next,v2,07/10] gve: Reset Rx ring state in the ring-stop funcs https://git.kernel.org/netdev/net-next/c/770f52d5a0ed - [net-next,v2,08/10] gve: Account for stopped queues when reading NIC stats https://git.kernel.org/netdev/net-next/c/af9bcf910b1f - [net-next,v2,09/10] gve: Alloc and free QPLs with the rings https://git.kernel.org/netdev/net-next/c/ee24284e2a10
Quoted 2 lines
- [net-next,v2,10/10] gve: Implement queue api
(no matching commit)
The last patch of this patchset did not get applied:
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/,
not sure why there is a "no matching commit" message.
Quoted 7 lines
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 43 lines · Shailend Chand
Quoted 38 lines · On Sun, May 5, 2024 at 6:40 AM <[email protected]> wrote:
Hello:
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 11 lines · On Wed, 1 May 2024 23:25:39 +0000 you wrote:
Following the discussion on
https://patchwork.kernel.org/project/linux-media/patch/[email protected]/,
the queue api defined by Mina is implemented for gve.The first patch is just Mina's introduction of the api. The rest of the patches make surgical changes in gve to enable it to work correctly with only a subset of queues present (thus far it had assumed that either all queues are up or all are down). The final patch has the api implementation.
[...]
Here is the summary with links:
- [net-next,v2,01/10]queue_api: define queue apihttps://git.kernel.org/netdev/net-next/c/087b24de5c82 - [net-next,v2,02/10] gve: Make the GQ RX free queue funcs idempotent https://git.kernel.org/netdev/net-next/c/dcecfcf21bd1 - [net-next,v2,03/10] gve: Add adminq funcs to add/remove a single Rx queue https://git.kernel.org/netdev/net-next/c/242f30fe692e - [net-next,v2,04/10] gve: Make gve_turn(up|down) ignore stopped queues https://git.kernel.org/netdev/net-next/c/5abc37bdcbc5 - [net-next,v2,05/10] gve: Make gve_turnup work for nonempty queues https://git.kernel.org/netdev/net-next/c/864616d97a45 - [net-next,v2,06/10] gve: Avoid rescheduling napi if on wrong cpu https://git.kernel.org/netdev/net-next/c/9a5e0776d11f - [net-next,v2,07/10] gve: Reset Rx ring state in the ring-stop funcs https://git.kernel.org/netdev/net-next/c/770f52d5a0ed - [net-next,v2,08/10] gve: Account for stopped queues when reading NIC stats https://git.kernel.org/netdev/net-next/c/af9bcf910b1f - [net-next,v2,09/10] gve: Alloc and free QPLs with the rings https://git.kernel.org/netdev/net-next/c/ee24284e2a10Quoted 2 lines
- [net-next,v2,10/10] gve: Implement queue api
(no matching commit)
Quoted 3 lines
The last patch of this patchset did not get applied:
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/,
not sure why there is a "no matching commit" message.
This is the v2 patch that did not get applied
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/.
The subjects of the cover letter and this patch both are the same, differing only in their number prefix, maybe that could be triggering some issue.
Quoted 9 lines
Quoted 9 lines
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Jakub Kicinski
maintainerQuoted 9 lines · On Mon, 6 May 2024 11:07:52 -0700 Shailend Chand wrote:
Quoted 3 lines
The last patch of this patchset did not get applied:
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/,
not sure why there is a "no matching commit" message.This is the v2 patch that did not get applied
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/.
The subjects of the cover letter and this patch both are the same, differing only in their number prefix, maybe that could be triggering some issue.
The space characters in Mina's review tag are funny looking, maybe that was the cause. In any case, applied now, will push once build finishes. Thanks!