@@ -2189,15 +2189,22 @@ void idpf_tx_splitq_build_flow_desc(union idpf_tx_flex_desc *desc,
2189
2189
desc -> flow .qw1 .compl_tag = cpu_to_le16 (params -> compl_tag );
2190
2190
}
2191
2191
2192
- /* Global conditions to tell whether the txq (and related resources)
2193
- * has room to allow the use of "size" descriptors.
2192
+ /**
2193
+ * idpf_tx_splitq_has_room - check if enough Tx splitq resources are available
2194
+ * @tx_q: the queue to be checked
2195
+ * @descs_needed: number of descriptors required for this packet
2196
+ * @bufs_needed: number of Tx buffers required for this packet
2197
+ *
2198
+ * Return: 0 if no room available, 1 otherwise
2194
2199
*/
2195
- static int idpf_txq_has_room (struct idpf_tx_queue * tx_q , u32 size )
2200
+ static int idpf_txq_has_room (struct idpf_tx_queue * tx_q , u32 descs_needed ,
2201
+ u32 bufs_needed )
2196
2202
{
2197
- if (IDPF_DESC_UNUSED (tx_q ) < size ||
2203
+ if (IDPF_DESC_UNUSED (tx_q ) < descs_needed ||
2198
2204
IDPF_TX_COMPLQ_PENDING (tx_q -> txq_grp ) >
2199
2205
IDPF_TX_COMPLQ_OVERFLOW_THRESH (tx_q -> txq_grp -> complq ) ||
2200
- IDPF_TX_BUF_RSV_LOW (tx_q ))
2206
+ IDPF_TX_BUF_RSV_LOW (tx_q ) ||
2207
+ idpf_tx_splitq_get_free_bufs (tx_q -> refillq ) < bufs_needed )
2201
2208
return 0 ;
2202
2209
return 1 ;
2203
2210
}
@@ -2206,14 +2213,21 @@ static int idpf_txq_has_room(struct idpf_tx_queue *tx_q, u32 size)
2206
2213
* idpf_tx_maybe_stop_splitq - 1st level check for Tx splitq stop conditions
2207
2214
* @tx_q: the queue to be checked
2208
2215
* @descs_needed: number of descriptors required for this packet
2216
+ * @bufs_needed: number of buffers needed for this packet
2209
2217
*
2210
- * Returns 0 if stop is not needed
2218
+ * Return: 0 if stop is not needed
2211
2219
*/
2212
2220
static int idpf_tx_maybe_stop_splitq (struct idpf_tx_queue * tx_q ,
2213
- unsigned int descs_needed )
2221
+ u32 descs_needed ,
2222
+ u32 bufs_needed )
2214
2223
{
2224
+ /* Since we have multiple resources to check for splitq, our
2225
+ * start,stop_thrs becomes a boolean check instead of a count
2226
+ * threshold.
2227
+ */
2215
2228
if (netif_subqueue_maybe_stop (tx_q -> netdev , tx_q -> idx ,
2216
- idpf_txq_has_room (tx_q , descs_needed ),
2229
+ idpf_txq_has_room (tx_q , descs_needed ,
2230
+ bufs_needed ),
2217
2231
1 , 1 ))
2218
2232
return 0 ;
2219
2233
@@ -2255,14 +2269,16 @@ void idpf_tx_buf_hw_update(struct idpf_tx_queue *tx_q, u32 val,
2255
2269
}
2256
2270
2257
2271
/**
2258
- * idpf_tx_desc_count_required - calculate number of Tx descriptors needed
2272
+ * idpf_tx_res_count_required - get number of Tx resources needed for this pkt
2259
2273
* @txq: queue to send buffer on
2260
2274
* @skb: send buffer
2275
+ * @bufs_needed: (output) number of buffers needed for this skb.
2261
2276
*
2262
- * Returns number of data descriptors needed for this skb.
2277
+ * Return: number of data descriptors and buffers needed for this skb.
2263
2278
*/
2264
- unsigned int idpf_tx_desc_count_required (struct idpf_tx_queue * txq ,
2265
- struct sk_buff * skb )
2279
+ unsigned int idpf_tx_res_count_required (struct idpf_tx_queue * txq ,
2280
+ struct sk_buff * skb ,
2281
+ u32 * bufs_needed )
2266
2282
{
2267
2283
const struct skb_shared_info * shinfo ;
2268
2284
unsigned int count = 0 , i ;
@@ -2273,6 +2289,7 @@ unsigned int idpf_tx_desc_count_required(struct idpf_tx_queue *txq,
2273
2289
return count ;
2274
2290
2275
2291
shinfo = skb_shinfo (skb );
2292
+ * bufs_needed += shinfo -> nr_frags ;
2276
2293
for (i = 0 ; i < shinfo -> nr_frags ; i ++ ) {
2277
2294
unsigned int size ;
2278
2295
@@ -2875,11 +2892,11 @@ static netdev_tx_t idpf_tx_splitq_frame(struct sk_buff *skb,
2875
2892
};
2876
2893
union idpf_flex_tx_ctx_desc * ctx_desc ;
2877
2894
struct idpf_tx_buf * first ;
2878
- unsigned int count ;
2895
+ u32 count , buf_count = 1 ;
2879
2896
int tso , idx ;
2880
2897
u32 buf_id ;
2881
2898
2882
- count = idpf_tx_desc_count_required (tx_q , skb );
2899
+ count = idpf_tx_res_count_required (tx_q , skb , & buf_count );
2883
2900
if (unlikely (!count ))
2884
2901
return idpf_tx_drop_skb (tx_q , skb );
2885
2902
@@ -2889,7 +2906,7 @@ static netdev_tx_t idpf_tx_splitq_frame(struct sk_buff *skb,
2889
2906
2890
2907
/* Check for splitq specific TX resources */
2891
2908
count += (IDPF_TX_DESCS_PER_CACHE_LINE + tso );
2892
- if (idpf_tx_maybe_stop_splitq (tx_q , count )) {
2909
+ if (idpf_tx_maybe_stop_splitq (tx_q , count , buf_count )) {
2893
2910
idpf_tx_buf_hw_update (tx_q , tx_q -> next_to_use , false);
2894
2911
2895
2912
return NETDEV_TX_BUSY ;
0 commit comments