Commit 7c6fe9b2af79df44ecc0c276cb124ef27f4e4730

Authored by Zh-yuan Ye
Committed by Greg Kroah-Hartman
1 parent 712c39d931

net: cbs: Fix software cbs to consider packet sending time

[ Upstream commit 961d0e5b32946703125964f9f5b6321d60f4d706 ]

Currently the software CBS does not consider the packet sending time
when depleting the credits. It caused the throughput to be
Idleslope[kbps] * (Port transmit rate[kbps] / |Sendslope[kbps]|) where
Idleslope * (Port transmit rate / (Idleslope + |Sendslope|)) = Idleslope
is expected. In order to fix the issue above, this patch takes the time
when the packet sending completes into account by moving the anchor time
variable "last" ahead to the send completion time upon transmission and
adding wait when the next dequeue request comes before the send
completion time of the previous packet.

changelog:
V2->V3:
 - remove unnecessary whitespace cleanup
 - add the checks if port_rate is 0 before division

V1->V2:
 - combine variable "send_completed" into "last"
 - add the comment for estimate of the packet sending

Fixes: 585d763af09c ("net/sched: Introduce Credit Based Shaper (CBS) qdisc")
Signed-off-by: Zh-yuan Ye <ye.zh-yuan@socionext.com>
Reviewed-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 11 additions and 1 deletions Side-by-side Diff

... ... @@ -181,6 +181,11 @@
181 181 s64 credits;
182 182 int len;
183 183  
  184 + /* The previous packet is still being sent */
  185 + if (now < q->last) {
  186 + qdisc_watchdog_schedule_ns(&q->watchdog, q->last);
  187 + return NULL;
  188 + }
184 189 if (q->credits < 0) {
185 190 credits = timediff_to_credits(now - q->last, q->idleslope);
186 191  
... ... @@ -212,7 +217,12 @@
212 217 credits += q->credits;
213 218  
214 219 q->credits = max_t(s64, credits, q->locredit);
215   - q->last = now;
  220 + /* Estimate of the transmission of the last byte of the packet in ns */
  221 + if (unlikely(atomic64_read(&q->port_rate) == 0))
  222 + q->last = now;
  223 + else
  224 + q->last = now + div64_s64(len * NSEC_PER_SEC,
  225 + atomic64_read(&q->port_rate));
216 226  
217 227 return skb;
218 228 }