From 1938bb951a981f4d3016b796f771b5047fb846a2 Mon Sep 17 00:00:00 2001 From: Andrew Moch Date: Fri, 2 Oct 2020 23:41:59 +0100 Subject: fpga: lib: Fix small packets stuck in 10 GbE TX Any packet less than CUT_THROUGH bytes has a high chance of getting stuck in the TX FIFO of the xge_mac_wrapper. In cut-through mode we were waiting for CUT_THROUGH bytes before transmitting the packet. --- fpga/usrp3/lib/xge_interface/xge_mac_wrapper.v | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/fpga/usrp3/lib/xge_interface/xge_mac_wrapper.v b/fpga/usrp3/lib/xge_interface/xge_mac_wrapper.v index 143808f6d..b5c6943ed 100644 --- a/fpga/usrp3/lib/xge_interface/xge_mac_wrapper.v +++ b/fpga/usrp3/lib/xge_interface/xge_mac_wrapper.v @@ -434,20 +434,27 @@ module xge_mac_wrapper #( // reg cut_through; reg cut_wait; + reg [15:0] cut_idlecount; if (CUT_THROUGH > 0) begin : yes_cut_through wire cut_start; wire cut_end; - assign cut_start = tx_occupied > CUT_THROUGH; + // start under 2 conditions + // (1) we have more the CUT_THROUGH bytes buffered + assign cut_start = tx_occupied > CUT_THROUGH || + // (2) we have kept bytes waiting for too long + // The second case happens when less than CUT_THROUGH bytes are pushed + (cut_idlecount == 0); assign cut_end = eth_tx_eof && eth_tx_valid; // Add SOF always @(posedge xgmii_clk) begin : cut_through_dff if (xgmii_reset) begin - cut_through <= 1'b0; - cut_wait <= 1'b0; + cut_through <= 1'b0; + cut_wait <= 1'b0; + cut_idlecount <= CUT_THROUGH+2; end else begin cut_wait <= eth_tx_full; if (cut_start) begin @@ -455,6 +462,13 @@ module xge_mac_wrapper #( end else if (cut_end) begin cut_through <= 1'b0; end + if (tx_occupied > 0 && cut_through == 1'b0) begin + if (cut_idlecount > 0) begin + cut_idlecount <= cut_idlecount-1; + end + end else begin + cut_idlecount <= CUT_THROUGH+2; + end end end end else begin : no_cut_through -- cgit v1.2.3