Skip to content

Commit a5886ef

Browse files
baileyforrestdavem330
authored andcommitted
gve: Introduce per netdev enum gve_queue_format
The currently supported queue formats are: - GQI_RDA - GQI with raw DMA addressing - GQI_QPL - GQI with queue page list - DQO_RDA - DQO with raw DMA addressing The old `gve_priv.raw_addressing` value is only used for GQI_RDA, so we remove it in favor of just checking against GQI_RDA Signed-off-by: Bailey Forrest <bcf@google.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Reviewed-by: Catherine Sullivan <csully@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8a39d3e commit a5886ef

File tree

5 files changed

+37
-15
lines changed

5 files changed

+37
-15
lines changed

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,17 @@ struct gve_qpl_config {
194194
unsigned long *qpl_id_map; /* bitmap of used qpl ids */
195195
};
196196

197+
/* GVE_QUEUE_FORMAT_UNSPECIFIED must be zero since 0 is the default value
198+
* when the entire configure_device_resources command is zeroed out and the
199+
* queue_format is not specified.
200+
*/
201+
enum gve_queue_format {
202+
GVE_QUEUE_FORMAT_UNSPECIFIED = 0x0,
203+
GVE_GQI_RDA_FORMAT = 0x1,
204+
GVE_GQI_QPL_FORMAT = 0x2,
205+
GVE_DQO_RDA_FORMAT = 0x3,
206+
};
207+
197208
struct gve_priv {
198209
struct net_device *dev;
199210
struct gve_tx_ring *tx; /* array of tx_cfg.num_queues */
@@ -216,7 +227,6 @@ struct gve_priv {
216227
u64 num_registered_pages; /* num pages registered with NIC */
217228
u32 rx_copybreak; /* copy packets smaller than this */
218229
u16 default_num_queues; /* default num queues to set up */
219-
u8 raw_addressing; /* 1 if this dev supports raw addressing, 0 otherwise */
220230

221231
struct gve_queue_config tx_cfg;
222232
struct gve_queue_config rx_cfg;
@@ -275,6 +285,8 @@ struct gve_priv {
275285

276286
/* Gvnic device link speed from hypervisor. */
277287
u64 link_speed;
288+
289+
enum gve_queue_format queue_format;
278290
};
279291

280292
enum gve_service_task_flags_bit {
@@ -454,14 +466,20 @@ static inline u32 gve_rx_idx_to_ntfy(struct gve_priv *priv, u32 queue_idx)
454466
*/
455467
static inline u32 gve_num_tx_qpls(struct gve_priv *priv)
456468
{
457-
return priv->raw_addressing ? 0 : priv->tx_cfg.num_queues;
469+
if (priv->queue_format != GVE_GQI_QPL_FORMAT)
470+
return 0;
471+
472+
return priv->tx_cfg.num_queues;
458473
}
459474

460475
/* Returns the number of rx queue page lists
461476
*/
462477
static inline u32 gve_num_rx_qpls(struct gve_priv *priv)
463478
{
464-
return priv->raw_addressing ? 0 : priv->rx_cfg.num_queues;
479+
if (priv->queue_format != GVE_GQI_QPL_FORMAT)
480+
return 0;
481+
482+
return priv->rx_cfg.num_queues;
465483
}
466484

467485
/* Returns a pointer to the next available tx qpl in the list of qpls

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void gve_parse_device_option(struct gve_priv *priv,
6161

6262
dev_info(&priv->pdev->dev,
6363
"Gqi raw addressing device option enabled.\n");
64-
priv->raw_addressing = 1;
64+
priv->queue_format = GVE_GQI_RDA_FORMAT;
6565
break;
6666
case GVE_DEV_OPT_ID_GQI_RDA:
6767
if (option_length < sizeof(**dev_op_gqi_rda) ||
@@ -460,7 +460,8 @@ static int gve_adminq_create_tx_queue(struct gve_priv *priv, u32 queue_index)
460460
u32 qpl_id;
461461
int err;
462462

463-
qpl_id = priv->raw_addressing ? GVE_RAW_ADDRESSING_QPL_ID : tx->tx_fifo.qpl->id;
463+
qpl_id = priv->queue_format == GVE_GQI_RDA_FORMAT ?
464+
GVE_RAW_ADDRESSING_QPL_ID : tx->tx_fifo.qpl->id;
464465
memset(&cmd, 0, sizeof(cmd));
465466
cmd.opcode = cpu_to_be32(GVE_ADMINQ_CREATE_TX_QUEUE);
466467
cmd.create_tx_queue = (struct gve_adminq_create_tx_queue) {
@@ -501,7 +502,8 @@ static int gve_adminq_create_rx_queue(struct gve_priv *priv, u32 queue_index)
501502
u32 qpl_id;
502503
int err;
503504

504-
qpl_id = priv->raw_addressing ? GVE_RAW_ADDRESSING_QPL_ID : rx->data.qpl->id;
505+
qpl_id = priv->queue_format == GVE_GQI_RDA_FORMAT ?
506+
GVE_RAW_ADDRESSING_QPL_ID : rx->data.qpl->id;
505507
memset(&cmd, 0, sizeof(cmd));
506508
cmd.opcode = cpu_to_be32(GVE_ADMINQ_CREATE_RX_QUEUE);
507509
cmd.create_rx_queue = (struct gve_adminq_create_rx_queue) {
@@ -628,7 +630,6 @@ int gve_adminq_describe_device(struct gve_priv *priv)
628630
if (err)
629631
goto free_device_descriptor;
630632

631-
priv->raw_addressing = 0;
632633
err = gve_process_device_options(priv, descriptor, &dev_op_gqi_rda,
633634
&dev_op_gqi_qpl, &dev_op_dqo_rda);
634635
if (err)
@@ -638,17 +639,19 @@ int gve_adminq_describe_device(struct gve_priv *priv)
638639
* is not set to GqiRda, choose the queue format in a priority order:
639640
* DqoRda, GqiRda, GqiQpl. Use GqiQpl as default.
640641
*/
641-
if (priv->raw_addressing == 1) {
642+
if (priv->queue_format == GVE_GQI_RDA_FORMAT) {
642643
dev_info(&priv->pdev->dev,
643644
"Driver is running with GQI RDA queue format.\n");
644645
} else if (dev_op_dqo_rda) {
646+
priv->queue_format = GVE_DQO_RDA_FORMAT;
645647
dev_info(&priv->pdev->dev,
646648
"Driver is running with DQO RDA queue format.\n");
647649
} else if (dev_op_gqi_rda) {
650+
priv->queue_format = GVE_GQI_RDA_FORMAT;
648651
dev_info(&priv->pdev->dev,
649652
"Driver is running with GQI RDA queue format.\n");
650-
priv->raw_addressing = 1;
651653
} else {
654+
priv->queue_format = GVE_GQI_QPL_FORMAT;
652655
dev_info(&priv->pdev->dev,
653656
"Driver is running with GQI QPL queue format.\n");
654657
}

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

Lines changed: 5 additions & 4 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/cpumask.h>
@@ -681,7 +681,7 @@ static int gve_alloc_qpls(struct gve_priv *priv)
681681
int err;
682682

683683
/* Raw addressing means no QPLs */
684-
if (priv->raw_addressing)
684+
if (priv->queue_format == GVE_GQI_RDA_FORMAT)
685685
return 0;
686686

687687
priv->qpls = kvzalloc(num_qpls * sizeof(*priv->qpls), GFP_KERNEL);
@@ -725,7 +725,7 @@ static void gve_free_qpls(struct gve_priv *priv)
725725
int i;
726726

727727
/* Raw addressing means no QPLs */
728-
if (priv->raw_addressing)
728+
if (priv->queue_format == GVE_GQI_RDA_FORMAT)
729729
return;
730730

731731
kvfree(priv->qpl_cfg.qpl_id_map);
@@ -1088,7 +1088,7 @@ static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
10881088
if (skip_describe_device)
10891089
goto setup_device;
10901090

1091-
priv->raw_addressing = false;
1091+
priv->queue_format = GVE_QUEUE_FORMAT_UNSPECIFIED;
10921092
/* Get the initial information we need from the device */
10931093
err = gve_adminq_describe_device(priv);
10941094
if (err) {
@@ -1352,6 +1352,7 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
13521352
goto abort_with_wq;
13531353

13541354
dev_info(&pdev->dev, "GVE version %s\n", gve_version_str);
1355+
dev_info(&pdev->dev, "GVE queue format %d\n", (int)priv->queue_format);
13551356
gve_clear_probe_in_progress(priv);
13561357
queue_work(priv->gve_wq, &priv->service_task);
13571358
return 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static int gve_rx_alloc_ring(struct gve_priv *priv, int idx)
148148

149149
slots = priv->rx_data_slot_cnt;
150150
rx->mask = slots - 1;
151-
rx->data.raw_addressing = priv->raw_addressing;
151+
rx->data.raw_addressing = priv->queue_format == GVE_GQI_RDA_FORMAT;
152152

153153
/* alloc rx data ring */
154154
bytes = sizeof(*rx->data.data_ring) * slots;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static int gve_tx_alloc_ring(struct gve_priv *priv, int idx)
191191
if (!tx->desc)
192192
goto abort_with_info;
193193

194-
tx->raw_addressing = priv->raw_addressing;
194+
tx->raw_addressing = priv->queue_format == GVE_GQI_RDA_FORMAT;
195195
tx->dev = &priv->pdev->dev;
196196
if (!tx->raw_addressing) {
197197
tx->tx_fifo.qpl = gve_assign_tx_qpl(priv);

0 commit comments

Comments
 (0)