Skip to content

Commit 1f6228e

Browse files
baileyforrestdavem330
authored andcommitted
gve: Update adminq commands to support DQO queues
DQO queue creation requires additional parameters: - TX completion/RX buffer queue size - TX completion/RX buffer queue address - TX/RX queue size - RX buffer size Signed-off-by: Bailey Forrest <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Reviewed-by: Catherine Sullivan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a4aa1f1 commit 1f6228e

File tree

4 files changed

+64
-29
lines changed

4 files changed

+64
-29
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,9 @@ struct gve_priv {
548548
struct gve_options_dqo_rda options_dqo_rda;
549549
struct gve_ptype_lut *ptype_lut_dqo;
550550

551+
/* Must be a power of two. */
552+
int data_buffer_size_dqo;
553+
551554
enum gve_queue_format queue_format;
552555
};
553556

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

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ int gve_adminq_configure_device_resources(struct gve_priv *priv,
443443
.irq_db_stride = cpu_to_be32(sizeof(priv->ntfy_blocks[0])),
444444
.ntfy_blk_msix_base_idx =
445445
cpu_to_be32(GVE_NTFY_BLK_BASE_MSIX_IDX),
446+
.queue_format = priv->queue_format,
446447
};
447448

448449
return gve_adminq_execute_cmd(priv, &cmd);
@@ -462,28 +463,32 @@ static int gve_adminq_create_tx_queue(struct gve_priv *priv, u32 queue_index)
462463
{
463464
struct gve_tx_ring *tx = &priv->tx[queue_index];
464465
union gve_adminq_command cmd;
465-
u32 qpl_id;
466-
int err;
467466

468-
qpl_id = priv->queue_format == GVE_GQI_RDA_FORMAT ?
469-
GVE_RAW_ADDRESSING_QPL_ID : tx->tx_fifo.qpl->id;
470467
memset(&cmd, 0, sizeof(cmd));
471468
cmd.opcode = cpu_to_be32(GVE_ADMINQ_CREATE_TX_QUEUE);
472469
cmd.create_tx_queue = (struct gve_adminq_create_tx_queue) {
473470
.queue_id = cpu_to_be32(queue_index),
474-
.reserved = 0,
475471
.queue_resources_addr =
476472
cpu_to_be64(tx->q_resources_bus),
477473
.tx_ring_addr = cpu_to_be64(tx->bus),
478-
.queue_page_list_id = cpu_to_be32(qpl_id),
479474
.ntfy_id = cpu_to_be32(tx->ntfy_id),
480475
};
481476

482-
err = gve_adminq_issue_cmd(priv, &cmd);
483-
if (err)
484-
return err;
477+
if (gve_is_gqi(priv)) {
478+
u32 qpl_id = priv->queue_format == GVE_GQI_RDA_FORMAT ?
479+
GVE_RAW_ADDRESSING_QPL_ID : tx->tx_fifo.qpl->id;
485480

486-
return 0;
481+
cmd.create_tx_queue.queue_page_list_id = cpu_to_be32(qpl_id);
482+
} else {
483+
cmd.create_tx_queue.tx_ring_size =
484+
cpu_to_be16(priv->tx_desc_cnt);
485+
cmd.create_tx_queue.tx_comp_ring_addr =
486+
cpu_to_be64(tx->complq_bus_dqo);
487+
cmd.create_tx_queue.tx_comp_ring_size =
488+
cpu_to_be16(priv->options_dqo_rda.tx_comp_ring_entries);
489+
}
490+
491+
return gve_adminq_issue_cmd(priv, &cmd);
487492
}
488493

489494
int gve_adminq_create_tx_queues(struct gve_priv *priv, u32 num_queues)
@@ -504,29 +509,41 @@ static int gve_adminq_create_rx_queue(struct gve_priv *priv, u32 queue_index)
504509
{
505510
struct gve_rx_ring *rx = &priv->rx[queue_index];
506511
union gve_adminq_command cmd;
507-
u32 qpl_id;
508-
int err;
509512

510-
qpl_id = priv->queue_format == GVE_GQI_RDA_FORMAT ?
511-
GVE_RAW_ADDRESSING_QPL_ID : rx->data.qpl->id;
512513
memset(&cmd, 0, sizeof(cmd));
513514
cmd.opcode = cpu_to_be32(GVE_ADMINQ_CREATE_RX_QUEUE);
514515
cmd.create_rx_queue = (struct gve_adminq_create_rx_queue) {
515516
.queue_id = cpu_to_be32(queue_index),
516-
.index = cpu_to_be32(queue_index),
517-
.reserved = 0,
518517
.ntfy_id = cpu_to_be32(rx->ntfy_id),
519518
.queue_resources_addr = cpu_to_be64(rx->q_resources_bus),
520-
.rx_desc_ring_addr = cpu_to_be64(rx->desc.bus),
521-
.rx_data_ring_addr = cpu_to_be64(rx->data.data_bus),
522-
.queue_page_list_id = cpu_to_be32(qpl_id),
523519
};
524520

525-
err = gve_adminq_issue_cmd(priv, &cmd);
526-
if (err)
527-
return err;
521+
if (gve_is_gqi(priv)) {
522+
u32 qpl_id = priv->queue_format == GVE_GQI_RDA_FORMAT ?
523+
GVE_RAW_ADDRESSING_QPL_ID : rx->data.qpl->id;
524+
525+
cmd.create_rx_queue.rx_desc_ring_addr =
526+
cpu_to_be64(rx->desc.bus),
527+
cmd.create_rx_queue.rx_data_ring_addr =
528+
cpu_to_be64(rx->data.data_bus),
529+
cmd.create_rx_queue.index = cpu_to_be32(queue_index);
530+
cmd.create_rx_queue.queue_page_list_id = cpu_to_be32(qpl_id);
531+
} else {
532+
cmd.create_rx_queue.rx_ring_size =
533+
cpu_to_be16(priv->rx_desc_cnt);
534+
cmd.create_rx_queue.rx_desc_ring_addr =
535+
cpu_to_be64(rx->dqo.complq.bus);
536+
cmd.create_rx_queue.rx_data_ring_addr =
537+
cpu_to_be64(rx->dqo.bufq.bus);
538+
cmd.create_rx_queue.packet_buffer_size =
539+
cpu_to_be16(priv->data_buffer_size_dqo);
540+
cmd.create_rx_queue.rx_buff_ring_size =
541+
cpu_to_be16(priv->options_dqo_rda.rx_buff_ring_entries);
542+
cmd.create_rx_queue.enable_rsc =
543+
!!(priv->dev->features & NETIF_F_LRO);
544+
}
528545

529-
return 0;
546+
return gve_adminq_issue_cmd(priv, &cmd);
530547
}
531548

532549
int gve_adminq_create_rx_queues(struct gve_priv *priv, u32 num_queues)

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,11 @@ struct gve_adminq_configure_device_resources {
139139
__be32 num_irq_dbs;
140140
__be32 irq_db_stride;
141141
__be32 ntfy_blk_msix_base_idx;
142+
u8 queue_format;
143+
u8 padding[7];
142144
};
143145

144-
static_assert(sizeof(struct gve_adminq_configure_device_resources) == 32);
146+
static_assert(sizeof(struct gve_adminq_configure_device_resources) == 40);
145147

146148
struct gve_adminq_register_page_list {
147149
__be32 page_list_id;
@@ -166,9 +168,13 @@ struct gve_adminq_create_tx_queue {
166168
__be64 tx_ring_addr;
167169
__be32 queue_page_list_id;
168170
__be32 ntfy_id;
171+
__be64 tx_comp_ring_addr;
172+
__be16 tx_ring_size;
173+
__be16 tx_comp_ring_size;
174+
u8 padding[4];
169175
};
170176

171-
static_assert(sizeof(struct gve_adminq_create_tx_queue) == 32);
177+
static_assert(sizeof(struct gve_adminq_create_tx_queue) == 48);
172178

173179
struct gve_adminq_create_rx_queue {
174180
__be32 queue_id;
@@ -179,10 +185,14 @@ struct gve_adminq_create_rx_queue {
179185
__be64 rx_desc_ring_addr;
180186
__be64 rx_data_ring_addr;
181187
__be32 queue_page_list_id;
182-
u8 padding[4];
188+
__be16 rx_ring_size;
189+
__be16 packet_buffer_size;
190+
__be16 rx_buff_ring_size;
191+
u8 enable_rsc;
192+
u8 padding[5];
183193
};
184194

185-
static_assert(sizeof(struct gve_adminq_create_rx_queue) == 48);
195+
static_assert(sizeof(struct gve_adminq_create_rx_queue) == 56);
186196

187197
/* Queue resources that are shared with the device */
188198
struct gve_queue_resources {

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
22
/* Google virtual Ethernet (gve) driver
33
*
4-
* Copyright (C) 2015-2019 Google, Inc.
4+
* Copyright (C) 2015-2021 Google, Inc.
55
*/
66

77
#include <linux/ethtool.h>
@@ -453,11 +453,16 @@ static int gve_set_tunable(struct net_device *netdev,
453453

454454
switch (etuna->id) {
455455
case ETHTOOL_RX_COPYBREAK:
456+
{
457+
u32 max_copybreak = gve_is_gqi(priv) ?
458+
(PAGE_SIZE / 2) : priv->data_buffer_size_dqo;
459+
456460
len = *(u32 *)value;
457-
if (len > PAGE_SIZE / 2)
461+
if (len > max_copybreak)
458462
return -EINVAL;
459463
priv->rx_copybreak = len;
460464
return 0;
465+
}
461466
default:
462467
return -EOPNOTSUPP;
463468
}

0 commit comments

Comments
 (0)