Skip to content

Commit a8bb03f

Browse files
roxanan1996PlaidCat
authored andcommitted
idpf: improve when to set RE bit logic
jira KERNEL-168 commit-author Joshua Hay <joshua.a.hay@intel.com> commit f2d18e1 upstream-diff | adjusted context in struct idpf_tx_queue because the order of the fields is different due to missing - 5a816aa ("idpf: strictly assert cachelines of queue and queue vector structures") Track the gap between next_to_use and the last RE index. Set RE again if the gap is large enough to ensure RE bit is set frequently. This is critical before removing the stashing mechanisms because the opportunistic descriptor ring cleaning from the out-of-order completions will go away. Previously the descriptors would be "cleaned" by both the descriptor (RE) completion and the out-of-order completions. Without the latter, we must ensure the RE bit is set more frequently. Otherwise, it's theoretically possible for the descriptor ring next_to_clean to never advance. The previous implementation was dependent on the start of a packet falling on a 64th index in the descriptor ring, which is not guaranteed with large packets. Signed-off-by: Luigi Rizzo <lrizzo@google.com> Signed-off-by: Brian Vazquez <brianvv@google.com> Signed-off-by: Joshua Hay <joshua.a.hay@intel.com> Reviewed-by: Madhu Chittim <madhu.chittim@intel.com> Tested-by: Samuel Salin <Samuel.salin@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> (cherry picked from commit f2d18e1) Signed-off-by: Roxana Nicolescu <rnicolescu@ciq.com>
1 parent 929b426 commit a8bb03f

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

drivers/net/ethernet/intel/idpf/idpf_txrx.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ static int idpf_tx_desc_alloc(const struct idpf_vport *vport,
293293
*/
294294
idpf_queue_change(GEN_CHK, refillq);
295295

296+
tx_q->last_re = tx_q->desc_count - IDPF_TX_SPLITQ_RE_MIN_GAP;
297+
296298
return 0;
297299

298300
err_alloc:
@@ -2791,6 +2793,21 @@ netdev_tx_t idpf_tx_drop_skb(struct idpf_tx_queue *tx_q, struct sk_buff *skb)
27912793
return NETDEV_TX_OK;
27922794
}
27932795

2796+
/**
2797+
* idpf_tx_splitq_need_re - check whether RE bit needs to be set
2798+
* @tx_q: pointer to Tx queue
2799+
*
2800+
* Return: true if RE bit needs to be set, false otherwise
2801+
*/
2802+
static bool idpf_tx_splitq_need_re(struct idpf_tx_queue *tx_q)
2803+
{
2804+
int gap = tx_q->next_to_use - tx_q->last_re;
2805+
2806+
gap += (gap < 0) ? tx_q->desc_count : 0;
2807+
2808+
return gap >= IDPF_TX_SPLITQ_RE_MIN_GAP;
2809+
}
2810+
27942811
/**
27952812
* idpf_tx_splitq_frame - Sends buffer on Tx ring using flex descriptors
27962813
* @skb: send buffer
@@ -2871,9 +2888,10 @@ static netdev_tx_t idpf_tx_splitq_frame(struct sk_buff *skb,
28712888
* MIN_RING size to ensure it will be set at least once each
28722889
* time around the ring.
28732890
*/
2874-
if (!(tx_q->next_to_use % IDPF_TX_SPLITQ_RE_MIN_GAP)) {
2891+
if (idpf_tx_splitq_need_re(tx_q)) {
28752892
tx_params.eop_cmd |= IDPF_TXD_FLEX_FLOW_CMD_RE;
28762893
tx_q->txq_grp->num_completions_pending++;
2894+
tx_q->last_re = tx_q->next_to_use;
28772895
}
28782896

28792897
if (skb->ip_summed == CHECKSUM_PARTIAL)

drivers/net/ethernet/intel/idpf/idpf_txrx.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,8 @@ struct idpf_rx_queue {
672672
* @desc_count: Number of descriptors
673673
* @next_to_use: Next descriptor to use
674674
* @next_to_clean: Next descriptor to clean
675+
* @last_re: last descriptor index that RE bit was set
676+
* @tx_max_bufs: Max buffers that can be transmitted with scatter-gather
675677
* @netdev: &net_device corresponding to this queue
676678
* @cleaned_bytes: Splitq only, TXQ only: When a TX completion is received on
677679
* the TX completion queue, it can be for any TXQ associated
@@ -683,7 +685,6 @@ struct idpf_rx_queue {
683685
* only once at the end of the cleaning routine.
684686
* @clean_budget: singleq only, queue cleaning budget
685687
* @cleaned_pkts: Number of packets cleaned for the above said case
686-
* @tx_max_bufs: Max buffers that can be transmitted with scatter-gather
687688
* @tx_min_pkt_len: Min supported packet length
688689
* @refillq: Pointer to refill queue
689690
* @compl_tag_bufid_m: Completion tag buffer id mask
@@ -736,6 +737,8 @@ struct idpf_tx_queue {
736737
u16 desc_count;
737738
u16 next_to_use;
738739
u16 next_to_clean;
740+
u16 last_re;
741+
u16 tx_max_bufs;
739742

740743
struct net_device *netdev;
741744

@@ -745,7 +748,6 @@ struct idpf_tx_queue {
745748
};
746749
u16 cleaned_pkts;
747750

748-
u16 tx_max_bufs;
749751
u16 tx_min_pkt_len;
750752
struct idpf_sw_queue *refillq;
751753

0 commit comments

Comments
 (0)