netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] net: sched: sch_netem: Refactor code in 4-state loss generator
@ 2021-11-12 21:36 Harshit Mogalapalli
  2021-11-12 22:05 ` Stephen Hemminger
  2021-11-15 13:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Harshit Mogalapalli @ 2021-11-12 21:36 UTC (permalink / raw)
  Cc: harshit.m.mogalapalli, Stephen Hemminger, Jamal Hadi Salim,
	Cong Wang, Jiri Pirko, David S. Miller, Jakub Kicinski,
	Yang Yingliang, netdev, linux-kernel

Fixed comments to match description with variable names and
refactored code to match the convention as per [1].

To match the convention mapping is done as follows:
State 3 - LOST_IN_BURST_PERIOD
State 4 - LOST_IN_GAP_PERIOD

[1] S. Salsano, F. Ludovici, A. Ordine, "Definition of a general
and intuitive loss model for packet networks and its implementation
in the Netem module in the Linux kernel"

Fixes: a6e2fe17eba4 ("sch_netem: replace magic numbers with enumerate")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
 net/sched/sch_netem.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index ecbb10db1111..ed4ccef5d6a8 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -208,17 +208,17 @@ static bool loss_4state(struct netem_sched_data *q)
 	 * next state and if the next packet has to be transmitted or lost.
 	 * The four states correspond to:
 	 *   TX_IN_GAP_PERIOD => successfully transmitted packets within a gap period
-	 *   LOST_IN_BURST_PERIOD => isolated losses within a gap period
-	 *   LOST_IN_GAP_PERIOD => lost packets within a burst period
-	 *   TX_IN_GAP_PERIOD => successfully transmitted packets within a burst period
+	 *   LOST_IN_GAP_PERIOD => isolated losses within a gap period
+	 *   LOST_IN_BURST_PERIOD => lost packets within a burst period
+	 *   TX_IN_BURST_PERIOD => successfully transmitted packets within a burst period
 	 */
 	switch (clg->state) {
 	case TX_IN_GAP_PERIOD:
 		if (rnd < clg->a4) {
-			clg->state = LOST_IN_BURST_PERIOD;
+			clg->state = LOST_IN_GAP_PERIOD;
 			return true;
 		} else if (clg->a4 < rnd && rnd < clg->a1 + clg->a4) {
-			clg->state = LOST_IN_GAP_PERIOD;
+			clg->state = LOST_IN_BURST_PERIOD;
 			return true;
 		} else if (clg->a1 + clg->a4 < rnd) {
 			clg->state = TX_IN_GAP_PERIOD;
@@ -227,24 +227,24 @@ static bool loss_4state(struct netem_sched_data *q)
 		break;
 	case TX_IN_BURST_PERIOD:
 		if (rnd < clg->a5) {
-			clg->state = LOST_IN_GAP_PERIOD;
+			clg->state = LOST_IN_BURST_PERIOD;
 			return true;
 		} else {
 			clg->state = TX_IN_BURST_PERIOD;
 		}
 
 		break;
-	case LOST_IN_GAP_PERIOD:
+	case LOST_IN_BURST_PERIOD:
 		if (rnd < clg->a3)
 			clg->state = TX_IN_BURST_PERIOD;
 		else if (clg->a3 < rnd && rnd < clg->a2 + clg->a3) {
 			clg->state = TX_IN_GAP_PERIOD;
 		} else if (clg->a2 + clg->a3 < rnd) {
-			clg->state = LOST_IN_GAP_PERIOD;
+			clg->state = LOST_IN_BURST_PERIOD;
 			return true;
 		}
 		break;
-	case LOST_IN_BURST_PERIOD:
+	case LOST_IN_GAP_PERIOD:
 		clg->state = TX_IN_GAP_PERIOD;
 		break;
 	}
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] net: sched: sch_netem: Refactor code in 4-state loss generator
  2021-11-12 21:36 [PATCH v2] net: sched: sch_netem: Refactor code in 4-state loss generator Harshit Mogalapalli
@ 2021-11-12 22:05 ` Stephen Hemminger
  2021-11-15 13:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2021-11-12 22:05 UTC (permalink / raw)
  To: Harshit Mogalapalli
  Cc: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller,
	Jakub Kicinski, Yang Yingliang, netdev, linux-kernel

On Fri, 12 Nov 2021 13:36:47 -0800
Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> wrote:

> Fixed comments to match description with variable names and
> refactored code to match the convention as per [1].
> 
> To match the convention mapping is done as follows:
> State 3 - LOST_IN_BURST_PERIOD
> State 4 - LOST_IN_GAP_PERIOD
> 
> [1] S. Salsano, F. Ludovici, A. Ordine, "Definition of a general
> and intuitive loss model for packet networks and its implementation
> in the Netem module in the Linux kernel"
> 
> Fixes: a6e2fe17eba4 ("sch_netem: replace magic numbers with enumerate")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>

Acked-by: Stephen Hemminger <stephen@networkplumber.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] net: sched: sch_netem: Refactor code in 4-state loss generator
  2021-11-12 21:36 [PATCH v2] net: sched: sch_netem: Refactor code in 4-state loss generator Harshit Mogalapalli
  2021-11-12 22:05 ` Stephen Hemminger
@ 2021-11-15 13:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-11-15 13:30 UTC (permalink / raw)
  To: Harshit Mogalapalli
  Cc: stephen, jhs, xiyou.wangcong, jiri, davem, kuba, yangyingliang,
	netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Fri, 12 Nov 2021 13:36:47 -0800 you wrote:
> Fixed comments to match description with variable names and
> refactored code to match the convention as per [1].
> 
> To match the convention mapping is done as follows:
> State 3 - LOST_IN_BURST_PERIOD
> State 4 - LOST_IN_GAP_PERIOD
> 
> [...]

Here is the summary with links:
  - [v2] net: sched: sch_netem: Refactor code in 4-state loss generator
    https://git.kernel.org/netdev/net-next/c/cb3ef7b00042

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-15 13:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-12 21:36 [PATCH v2] net: sched: sch_netem: Refactor code in 4-state loss generator Harshit Mogalapalli
2021-11-12 22:05 ` Stephen Hemminger
2021-11-15 13:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).