@@ -2189,15 +2189,22 @@ void idpf_tx_splitq_build_flow_desc(union idpf_tx_flex_desc *desc,
21892189 desc -> flow .qw1 .compl_tag = cpu_to_le16 (params -> compl_tag );
21902190}
21912191
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
21942199 */
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 )
21962202{
2197- if (IDPF_DESC_UNUSED (tx_q ) < size ||
2203+ if (IDPF_DESC_UNUSED (tx_q ) < descs_needed ||
21982204 IDPF_TX_COMPLQ_PENDING (tx_q -> txq_grp ) >
21992205 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 )
22012208 return 0 ;
22022209 return 1 ;
22032210}
@@ -2206,14 +2213,21 @@ static int idpf_txq_has_room(struct idpf_tx_queue *tx_q, u32 size)
22062213 * idpf_tx_maybe_stop_splitq - 1st level check for Tx splitq stop conditions
22072214 * @tx_q: the queue to be checked
22082215 * @descs_needed: number of descriptors required for this packet
2216+ * @bufs_needed: number of buffers needed for this packet
22092217 *
2210- * Returns 0 if stop is not needed
2218+ * Return: 0 if stop is not needed
22112219 */
22122220static 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 )
22142223{
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+ */
22152228 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 ),
22172231 1 , 1 ))
22182232 return 0 ;
22192233
@@ -2255,14 +2269,16 @@ void idpf_tx_buf_hw_update(struct idpf_tx_queue *tx_q, u32 val,
22552269}
22562270
22572271/**
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
22592273 * @txq: queue to send buffer on
22602274 * @skb: send buffer
2275+ * @bufs_needed: (output) number of buffers needed for this skb.
22612276 *
2262- * Returns number of data descriptors needed for this skb.
2277+ * Return: number of data descriptors and buffers needed for this skb.
22632278 */
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 )
22662282{
22672283 const struct skb_shared_info * shinfo ;
22682284 unsigned int count = 0 , i ;
@@ -2273,6 +2289,7 @@ unsigned int idpf_tx_desc_count_required(struct idpf_tx_queue *txq,
22732289 return count ;
22742290
22752291 shinfo = skb_shinfo (skb );
2292+ * bufs_needed += shinfo -> nr_frags ;
22762293 for (i = 0 ; i < shinfo -> nr_frags ; i ++ ) {
22772294 unsigned int size ;
22782295
@@ -2875,11 +2892,11 @@ static netdev_tx_t idpf_tx_splitq_frame(struct sk_buff *skb,
28752892 };
28762893 union idpf_flex_tx_ctx_desc * ctx_desc ;
28772894 struct idpf_tx_buf * first ;
2878- unsigned int count ;
2895+ u32 count , buf_count = 1 ;
28792896 int tso , idx ;
28802897 u32 buf_id ;
28812898
2882- count = idpf_tx_desc_count_required (tx_q , skb );
2899+ count = idpf_tx_res_count_required (tx_q , skb , & buf_count );
28832900 if (unlikely (!count ))
28842901 return idpf_tx_drop_skb (tx_q , skb );
28852902
@@ -2889,7 +2906,7 @@ static netdev_tx_t idpf_tx_splitq_frame(struct sk_buff *skb,
28892906
28902907 /* Check for splitq specific TX resources */
28912908 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 )) {
28932910 idpf_tx_buf_hw_update (tx_q , tx_q -> next_to_use , false);
28942911
28952912 return NETDEV_TX_BUSY ;
0 commit comments