The Tx time descriptor holds the launch time in a 19-bit field, in
units of 128 ns. The hardware compares it with the low 19 bits of the
PHC time in the same units, so the field wraps every 2^19 * 128 ns
(about 67.1 ms).

ice_write_ts_desc() takes the launch time modulo one second before
the shift. One second is 7812500 units of 128 ns, and that is not a
multiple of 2^19. Thus in second k of the PHC, the encoded value is
k * 51820 units (k * 6.63 ms) after the launch time, modulo 67.1 ms.
At each second boundary, the launch time that the hardware sees moves
6.63 ms later. The error goes through the full 67.1 ms range every
10.1 s. In half of that time it is more than half of the range, and
the queued packets look late.

The result is a pacing fault that comes and goes: the queue holds
packets too long, or sends them at line rate. Because the phase
depends on the absolute PHC time, some runs start in the bad half of
the cycle and some do not.

Encode the full launch time, and let FIELD_PREP() keep the low 19
bits.

On E830, with one ST 2110-20 video stream on a 1024-entry Tx ring,
6 of 13 runs lost pacing with the modulo encoding. With this patch,
32 of 32 runs paced correctly, with burst sizes of 1, 4 and 16.

Fixes: 0b6ff09a1f19 ("net/intel: support Tx packet pacing for E830")
Cc: [email protected]

Signed-off-by: Marek Kasiewicz <[email protected]>
Signed-off-by: Dawid Wesierski <[email protected]>
---
 drivers/net/intel/ice/ice_rxtx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/intel/ice/ice_rxtx.c b/drivers/net/intel/ice/ice_rxtx.c
index 6f19e070ee..7c299618c5 100644
--- a/drivers/net/intel/ice/ice_rxtx.c
+++ b/drivers/net/intel/ice/ice_rxtx.c
@@ -3095,7 +3095,8 @@ ice_write_ts_desc(struct ci_tx_queue *txq,
                  uint16_t ts_id)
 {
        uint64_t txtime = *RTE_MBUF_DYNFIELD(tx_pkt, txq->tsq->ts_offset, 
uint64_t *);
-       uint32_t tstamp = (uint32_t)(txtime % NS_PER_S) >> 
ICE_TXTIME_CTX_RESOLUTION_128NS;
+       /* The hardware compares the low 19 bits of PHC time in 128ns units. */
+       uint32_t tstamp = (uint32_t)(txtime >> ICE_TXTIME_CTX_RESOLUTION_128NS);
        const uint32_t desc_tx_id = (tx_id == 0) ? txq->nb_tx_desc : tx_id;
        __le32 ts_desc = rte_cpu_to_le_32(FIELD_PREP(ICE_TXTIME_TX_DESC_IDX_M, 
desc_tx_id) |
                        FIELD_PREP(ICE_TXTIME_STAMP_M, tstamp));
-- 
2.43.0

---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial 
Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | 
Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z 
dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach 
handlowych.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i 
moze zawierac informacje poufne. W razie przypadkowego otrzymania tej 
wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; 
jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole 
use of the intended recipient(s). If you are not the intended recipient, please 
contact the sender and delete all copies; any review or distribution by others 
is strictly prohibited.

Reply via email to