Skip to content

Commit 242f30f

Browse files
shailend-gdavem330
authored andcommitted
gve: Add adminq funcs to add/remove a single Rx queue
This allows for implementing future ndo hooks that act on a single queue. Tested-by: Mina Almasry <almasrymina@google.com> Reviewed-by: Praveen Kaligineedi <pkaligineedi@google.com> Reviewed-by: Harshitha Ramamurthy <hramamurthy@google.com> Signed-off-by: Shailend Chand <shailend@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dcecfcf commit 242f30f

2 files changed

Lines changed: 54 additions & 27 deletions

File tree

drivers/net/ethernet/google/gve/gve_adminq.c

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -630,14 +630,15 @@ int gve_adminq_create_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_que
630630
return gve_adminq_kick_and_wait(priv);
631631
}
632632

633-
static int gve_adminq_create_rx_queue(struct gve_priv *priv, u32 queue_index)
633+
static void gve_adminq_get_create_rx_queue_cmd(struct gve_priv *priv,
634+
union gve_adminq_command *cmd,
635+
u32 queue_index)
634636
{
635637
struct gve_rx_ring *rx = &priv->rx[queue_index];
636-
union gve_adminq_command cmd;
637638

638-
memset(&cmd, 0, sizeof(cmd));
639-
cmd.opcode = cpu_to_be32(GVE_ADMINQ_CREATE_RX_QUEUE);
640-
cmd.create_rx_queue = (struct gve_adminq_create_rx_queue) {
639+
memset(cmd, 0, sizeof(*cmd));
640+
cmd->opcode = cpu_to_be32(GVE_ADMINQ_CREATE_RX_QUEUE);
641+
cmd->create_rx_queue = (struct gve_adminq_create_rx_queue) {
641642
.queue_id = cpu_to_be32(queue_index),
642643
.ntfy_id = cpu_to_be32(rx->ntfy_id),
643644
.queue_resources_addr = cpu_to_be64(rx->q_resources_bus),
@@ -648,39 +649,54 @@ static int gve_adminq_create_rx_queue(struct gve_priv *priv, u32 queue_index)
648649
u32 qpl_id = priv->queue_format == GVE_GQI_RDA_FORMAT ?
649650
GVE_RAW_ADDRESSING_QPL_ID : rx->data.qpl->id;
650651

651-
cmd.create_rx_queue.rx_desc_ring_addr =
652+
cmd->create_rx_queue.rx_desc_ring_addr =
652653
cpu_to_be64(rx->desc.bus),
653-
cmd.create_rx_queue.rx_data_ring_addr =
654+
cmd->create_rx_queue.rx_data_ring_addr =
654655
cpu_to_be64(rx->data.data_bus),
655-
cmd.create_rx_queue.index = cpu_to_be32(queue_index);
656-
cmd.create_rx_queue.queue_page_list_id = cpu_to_be32(qpl_id);
657-
cmd.create_rx_queue.packet_buffer_size = cpu_to_be16(rx->packet_buffer_size);
656+
cmd->create_rx_queue.index = cpu_to_be32(queue_index);
657+
cmd->create_rx_queue.queue_page_list_id = cpu_to_be32(qpl_id);
658+
cmd->create_rx_queue.packet_buffer_size = cpu_to_be16(rx->packet_buffer_size);
658659
} else {
659660
u32 qpl_id = 0;
660661

661662
if (priv->queue_format == GVE_DQO_RDA_FORMAT)
662663
qpl_id = GVE_RAW_ADDRESSING_QPL_ID;
663664
else
664665
qpl_id = rx->dqo.qpl->id;
665-
cmd.create_rx_queue.queue_page_list_id = cpu_to_be32(qpl_id);
666-
cmd.create_rx_queue.rx_desc_ring_addr =
666+
cmd->create_rx_queue.queue_page_list_id = cpu_to_be32(qpl_id);
667+
cmd->create_rx_queue.rx_desc_ring_addr =
667668
cpu_to_be64(rx->dqo.complq.bus);
668-
cmd.create_rx_queue.rx_data_ring_addr =
669+
cmd->create_rx_queue.rx_data_ring_addr =
669670
cpu_to_be64(rx->dqo.bufq.bus);
670-
cmd.create_rx_queue.packet_buffer_size =
671+
cmd->create_rx_queue.packet_buffer_size =
671672
cpu_to_be16(priv->data_buffer_size_dqo);
672-
cmd.create_rx_queue.rx_buff_ring_size =
673+
cmd->create_rx_queue.rx_buff_ring_size =
673674
cpu_to_be16(priv->rx_desc_cnt);
674-
cmd.create_rx_queue.enable_rsc =
675+
cmd->create_rx_queue.enable_rsc =
675676
!!(priv->dev->features & NETIF_F_LRO);
676677
if (priv->header_split_enabled)
677-
cmd.create_rx_queue.header_buffer_size =
678+
cmd->create_rx_queue.header_buffer_size =
678679
cpu_to_be16(priv->header_buf_size);
679680
}
681+
}
682+
683+
static int gve_adminq_create_rx_queue(struct gve_priv *priv, u32 queue_index)
684+
{
685+
union gve_adminq_command cmd;
680686

687+
gve_adminq_get_create_rx_queue_cmd(priv, &cmd, queue_index);
681688
return gve_adminq_issue_cmd(priv, &cmd);
682689
}
683690

691+
/* Unlike gve_adminq_create_rx_queue, this actually rings the doorbell */
692+
int gve_adminq_create_single_rx_queue(struct gve_priv *priv, u32 queue_index)
693+
{
694+
union gve_adminq_command cmd;
695+
696+
gve_adminq_get_create_rx_queue_cmd(priv, &cmd, queue_index);
697+
return gve_adminq_execute_cmd(priv, &cmd);
698+
}
699+
684700
int gve_adminq_create_rx_queues(struct gve_priv *priv, u32 num_queues)
685701
{
686702
int err;
@@ -727,22 +743,31 @@ int gve_adminq_destroy_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_qu
727743
return gve_adminq_kick_and_wait(priv);
728744
}
729745

746+
static void gve_adminq_make_destroy_rx_queue_cmd(union gve_adminq_command *cmd,
747+
u32 queue_index)
748+
{
749+
memset(cmd, 0, sizeof(*cmd));
750+
cmd->opcode = cpu_to_be32(GVE_ADMINQ_DESTROY_RX_QUEUE);
751+
cmd->destroy_rx_queue = (struct gve_adminq_destroy_rx_queue) {
752+
.queue_id = cpu_to_be32(queue_index),
753+
};
754+
}
755+
730756
static int gve_adminq_destroy_rx_queue(struct gve_priv *priv, u32 queue_index)
731757
{
732758
union gve_adminq_command cmd;
733-
int err;
734759

735-
memset(&cmd, 0, sizeof(cmd));
736-
cmd.opcode = cpu_to_be32(GVE_ADMINQ_DESTROY_RX_QUEUE);
737-
cmd.destroy_rx_queue = (struct gve_adminq_destroy_rx_queue) {
738-
.queue_id = cpu_to_be32(queue_index),
739-
};
760+
gve_adminq_make_destroy_rx_queue_cmd(&cmd, queue_index);
761+
return gve_adminq_issue_cmd(priv, &cmd);
762+
}
740763

741-
err = gve_adminq_issue_cmd(priv, &cmd);
742-
if (err)
743-
return err;
764+
/* Unlike gve_adminq_destroy_rx_queue, this actually rings the doorbell */
765+
int gve_adminq_destroy_single_rx_queue(struct gve_priv *priv, u32 queue_index)
766+
{
767+
union gve_adminq_command cmd;
744768

745-
return 0;
769+
gve_adminq_make_destroy_rx_queue_cmd(&cmd, queue_index);
770+
return gve_adminq_execute_cmd(priv, &cmd);
746771
}
747772

748773
int gve_adminq_destroy_rx_queues(struct gve_priv *priv, u32 num_queues)

drivers/net/ethernet/google/gve/gve_adminq.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,9 @@ int gve_adminq_configure_device_resources(struct gve_priv *priv,
451451
int gve_adminq_deconfigure_device_resources(struct gve_priv *priv);
452452
int gve_adminq_create_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_queues);
453453
int gve_adminq_destroy_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_queues);
454+
int gve_adminq_create_single_rx_queue(struct gve_priv *priv, u32 queue_index);
454455
int gve_adminq_create_rx_queues(struct gve_priv *priv, u32 num_queues);
456+
int gve_adminq_destroy_single_rx_queue(struct gve_priv *priv, u32 queue_index);
455457
int gve_adminq_destroy_rx_queues(struct gve_priv *priv, u32 queue_id);
456458
int gve_adminq_register_page_list(struct gve_priv *priv,
457459
struct gve_queue_page_list *qpl);

0 commit comments

Comments
 (0)