• Vedang Patel's avatar
    taprio: Add support for txtime-assist mode · 4cfd5779
    Vedang Patel authored
    Currently, we are seeing non-critical packets being transmitted outside of
    their timeslice. We can confirm that the packets are being dequeued at the
    right time. So, the delay is induced in the hardware side.  The most likely
    reason is the hardware queues are starving the lower priority queues.
    
    In order to improve the performance of taprio, we will be making use of the
    txtime feature provided by the ETF qdisc. For all the packets which do not
    have the SO_TXTIME option set, taprio will set the transmit timestamp (set
    in skb->tstamp) in this mode. TAPrio Qdisc will ensure that the transmit
    time for the packet is set to when the gate is open. If SO_TXTIME is set,
    the TAPrio qdisc will validate whether the timestamp (in skb->tstamp)
    occurs when the gate corresponding to skb's traffic class is open.
    
    Following two parameters added to support this mode:
    - flags: used to enable txtime-assist mode. Will also be used to enable
      other modes (like hardware offloading) later.
    - txtime-delay: This indicates the minimum time it will take for the packet
      to hit the wire. This is useful in determining whether we can transmit
    the packet in the remaining time if the gate corresponding to the packet is
    currently open.
    
    An example configuration for enabling txtime-assist:
    
    tc qdisc replace dev eth0 parent root handle 100 taprio \\
          num_tc 3 \\
          map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 \\
          queues 1@0 1@0 1@0 \\
          base-time 1558653424279842568 \\
          sched-entry S 01 300000 \\
          sched-entry S 02 300000 \\
          sched-entry S 04 400000 \\
          flags 0x1 \\
          txtime-delay 40000 \\
          clockid CLOCK_TAI
    
    tc qdisc replace dev $IFACE parent 100:1 etf skip_sock_check \\
          offload delta 200000 clockid CLOCK_TAI
    
    Note that all the traffic classes are mapped to the same queue.  This is
    only possible in taprio when txtime-assist is enabled. Also, note that the
    ETF Qdisc is enabled with offload mode set.
    
    In this mode, if the packet's traffic class is open and the complete packet
    can be transmitted, taprio will try to transmit the packet immediately.
    This will be done by setting skb->tstamp to current_time + the time delta
    indicated in the txtime-delay parameter. This parameter indicates the time
    taken (in software) for packet to reach the network adapter.
    
    If the packet cannot be transmitted in the current interval or if the
    packet's traffic is not currently transmitting, the skb->tstamp is set to
    the next available timestamp value. This is tracked in the next_launchtime
    parameter in the struct sched_entry.
    
    The behaviour w.r.t admin and oper schedules is not changed from what is
    present in software mode.
    
    The transmit time is already known in advance. So, we do not need the HR
    timers to advance the schedule and wakeup the dequeue side of taprio.  So,
    HR timer won't be run when this mode is enabled.
    Signed-off-by: default avatarVedang Patel <vedang.patel@intel.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    4cfd5779
sch_taprio.c 38.2 KB