Skip to content

Commit 80eb65d

Browse files
josh8551021ferruhy
authored andcommitted
net/gve: add IO memory barriers before reading descriptors
Without memory barriers, there is no guarantee that the CPU will actually wait until after the descriptor has been fully written before loading descriptor data. In this case, it is possible that stale data is read and acted on by the driver when processing TX or RX completions. This change adds read memory barriers just after the generation bit is read in both the RX and the TX path to ensure that the NIC has properly passed ownership to the driver before descriptor data is read in full. Note that memory barriers should not be needed after writing the RX buffer queue/TX descriptor queue tails because rte_write32 includes an implicit write memory barrier. Fixes: 4022f99 ("net/gve: support basic Tx data path for DQO") Fixes: 45da16b ("net/gve: support basic Rx data path for DQO") Cc: [email protected] Signed-off-by: Joshua Washington <[email protected]> Reviewed-by: Praveen Kaligineedi <[email protected]> Reviewed-by: Rushil Gupta <[email protected]>
1 parent 036c564 commit 80eb65d

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

drivers/net/gve/gve_rx_dqo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ gve_rx_burst_dqo(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
132132
if (rx_desc->generation != rxq->cur_gen_bit)
133133
break;
134134

135+
rte_io_rmb();
136+
135137
if (unlikely(rx_desc->rx_error)) {
136138
rxq->stats.errors++;
137139
continue;

drivers/net/gve/gve_tx_dqo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ gve_tx_clean_dqo(struct gve_tx_queue *txq)
2424
if (compl_desc->generation != txq->cur_gen_bit)
2525
return;
2626

27+
rte_io_rmb();
28+
2729
compl_tag = rte_le_to_cpu_16(compl_desc->completion_tag);
2830

2931
aim_txq = txq->txqs[compl_desc->id];

0 commit comments

Comments
 (0)