@@ -71,6 +71,26 @@ efx_tx_desc(struct efx_tx_queue *tx_queue, unsigned int index)
71
71
return ((efx_qword_t * ) (tx_queue -> txd .buf .addr )) + index ;
72
72
}
73
73
74
+ /* Report whether the NIC considers this TX queue empty, given the
75
+ * write_count used for the last doorbell push. May return false
76
+ * negative.
77
+ */
78
+ static inline bool __efx_nic_tx_is_empty (struct efx_tx_queue * tx_queue ,
79
+ unsigned int write_count )
80
+ {
81
+ unsigned int empty_read_count = ACCESS_ONCE (tx_queue -> empty_read_count );
82
+
83
+ if (empty_read_count == 0 )
84
+ return false;
85
+
86
+ return ((empty_read_count ^ write_count ) & ~EFX_EMPTY_COUNT_VALID ) == 0 ;
87
+ }
88
+
89
+ static inline bool efx_nic_tx_is_empty (struct efx_tx_queue * tx_queue )
90
+ {
91
+ return __efx_nic_tx_is_empty (tx_queue , tx_queue -> write_count );
92
+ }
93
+
74
94
/* Decide whether to push a TX descriptor to the NIC vs merely writing
75
95
* the doorbell. This can reduce latency when we are adding a single
76
96
* descriptor to an empty queue, but is otherwise pointless. Further,
@@ -80,14 +100,10 @@ efx_tx_desc(struct efx_tx_queue *tx_queue, unsigned int index)
80
100
static inline bool efx_nic_may_push_tx_desc (struct efx_tx_queue * tx_queue ,
81
101
unsigned int write_count )
82
102
{
83
- unsigned empty_read_count = ACCESS_ONCE (tx_queue -> empty_read_count );
84
-
85
- if (empty_read_count == 0 )
86
- return false;
103
+ bool was_empty = __efx_nic_tx_is_empty (tx_queue , write_count );
87
104
88
105
tx_queue -> empty_read_count = 0 ;
89
- return ((empty_read_count ^ write_count ) & ~EFX_EMPTY_COUNT_VALID ) == 0
90
- && tx_queue -> write_count - write_count == 1 ;
106
+ return was_empty && tx_queue -> write_count - write_count == 1 ;
91
107
}
92
108
93
109
/* Returns a pointer to the specified descriptor in the RX descriptor queue */
0 commit comments