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