Commit 242f30fe authored by Shailend Chand's avatar Shailend Chand Committed by David S. Miller

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: default avatarMina Almasry <almasrymina@google.com>
Reviewed-by: default avatarPraveen Kaligineedi <pkaligineedi@google.com>
Reviewed-by: default avatarHarshitha Ramamurthy <hramamurthy@google.com>
Signed-off-by: default avatarShailend Chand <shailend@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dcecfcf2
...@@ -630,14 +630,15 @@ int gve_adminq_create_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_que ...@@ -630,14 +630,15 @@ int gve_adminq_create_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_que
return gve_adminq_kick_and_wait(priv); return 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]; struct gve_rx_ring *rx = &priv->rx[queue_index];
union gve_adminq_command cmd;
memset(&cmd, 0, sizeof(cmd)); memset(cmd, 0, sizeof(*cmd));
cmd.opcode = cpu_to_be32(GVE_ADMINQ_CREATE_RX_QUEUE); cmd->opcode = cpu_to_be32(GVE_ADMINQ_CREATE_RX_QUEUE);
cmd.create_rx_queue = (struct gve_adminq_create_rx_queue) { cmd->create_rx_queue = (struct gve_adminq_create_rx_queue) {
.queue_id = cpu_to_be32(queue_index), .queue_id = cpu_to_be32(queue_index),
.ntfy_id = cpu_to_be32(rx->ntfy_id), .ntfy_id = cpu_to_be32(rx->ntfy_id),
.queue_resources_addr = cpu_to_be64(rx->q_resources_bus), .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) ...@@ -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 ? u32 qpl_id = priv->queue_format == GVE_GQI_RDA_FORMAT ?
GVE_RAW_ADDRESSING_QPL_ID : rx->data.qpl->id; 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), 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), cpu_to_be64(rx->data.data_bus),
cmd.create_rx_queue.index = cpu_to_be32(queue_index); 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.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.packet_buffer_size = cpu_to_be16(rx->packet_buffer_size);
} else { } else {
u32 qpl_id = 0; u32 qpl_id = 0;
...@@ -662,25 +663,40 @@ static int gve_adminq_create_rx_queue(struct gve_priv *priv, u32 queue_index) ...@@ -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; qpl_id = GVE_RAW_ADDRESSING_QPL_ID;
else else
qpl_id = rx->dqo.qpl->id; qpl_id = rx->dqo.qpl->id;
cmd.create_rx_queue.queue_page_list_id = cpu_to_be32(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.rx_desc_ring_addr =
cpu_to_be64(rx->dqo.complq.bus); 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); 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); 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); 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); !!(priv->dev->features & NETIF_F_LRO);
if (priv->header_split_enabled) 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); 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); 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 gve_adminq_create_rx_queues(struct gve_priv *priv, u32 num_queues)
{ {
int err; int err;
...@@ -727,22 +743,31 @@ int gve_adminq_destroy_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_qu ...@@ -727,22 +743,31 @@ int gve_adminq_destroy_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_qu
return gve_adminq_kick_and_wait(priv); return 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) static int gve_adminq_destroy_rx_queue(struct gve_priv *priv, u32 queue_index)
{ {
union gve_adminq_command cmd; union gve_adminq_command cmd;
int err;
memset(&cmd, 0, sizeof(cmd)); gve_adminq_make_destroy_rx_queue_cmd(&cmd, queue_index);
cmd.opcode = cpu_to_be32(GVE_ADMINQ_DESTROY_RX_QUEUE); return gve_adminq_issue_cmd(priv, &cmd);
cmd.destroy_rx_queue = (struct gve_adminq_destroy_rx_queue) { }
.queue_id = cpu_to_be32(queue_index),
};
err = gve_adminq_issue_cmd(priv, &cmd); /* Unlike gve_adminq_destroy_rx_queue, this actually rings the doorbell */
if (err) int gve_adminq_destroy_single_rx_queue(struct gve_priv *priv, u32 queue_index)
return err; {
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) int gve_adminq_destroy_rx_queues(struct gve_priv *priv, u32 num_queues)
......
...@@ -451,7 +451,9 @@ int gve_adminq_configure_device_resources(struct gve_priv *priv, ...@@ -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_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_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_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_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_destroy_rx_queues(struct gve_priv *priv, u32 queue_id);
int gve_adminq_register_page_list(struct gve_priv *priv, int gve_adminq_register_page_list(struct gve_priv *priv,
struct gve_queue_page_list *qpl); struct gve_queue_page_list *qpl);
......
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