Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_hpts_test.c
| Show First 20 Lines • Show All 618 Lines • ▼ Show 20 Lines | |||||
| * the process. | * the process. | ||||
| */ | */ | ||||
| KTEST_FUNC(tcpcb_insertion) | KTEST_FUNC(tcpcb_insertion) | ||||
| { | { | ||||
| struct tcp_hptsi *pace; | struct tcp_hptsi *pace; | ||||
| struct tcpcb *tp; | struct tcpcb *tp; | ||||
| struct tcp_hpts_entry *hpts; | struct tcp_hpts_entry *hpts; | ||||
| uint32_t timeout_usecs = 10; | uint32_t timeout_usecs = 10; | ||||
| int error; | |||||
| error = 0; | |||||
| test_hpts_init(); | test_hpts_init(); | ||||
| pace = tcp_hptsi_create(&test_funcs, false); | pace = tcp_hptsi_create(&test_funcs, false); | ||||
| KTEST_NEQUAL(pace, NULL); | KTEST_NEQUAL(pace, NULL); | ||||
| tcp_hptsi_start(pace); | tcp_hptsi_start(pace); | ||||
| tp = test_hpts_create_tcpcb(ctx, pace); | tp = test_hpts_create_tcpcb(ctx, pace); | ||||
| KTEST_NEQUAL(tp, NULL); | KTEST_NEQUAL(tp, NULL); | ||||
| KTEST_EQUAL(tp->t_in_hpts, IHPTS_NONE); | KTEST_EQUAL(tp->t_in_hpts, IHPTS_NONE); | ||||
| KTEST_EQUAL((tp->t_flags2 & TF2_HPTS_CALLS), 0); | KTEST_EQUAL((tp->t_flags2 & TF2_HPTS_CALLS), 0); | ||||
| INP_WLOCK(&tp->t_inpcb); | INP_WLOCK(&tp->t_inpcb); | ||||
| tp->t_flags2 |= TF2_HPTS_CALLS; | tp->t_flags2 |= TF2_HPTS_CALLS; | ||||
| KTEST_EQUAL(call_counts[CCNT_SWI_SCHED], 0); | KTEST_EQUAL_GOTO(call_counts[CCNT_SWI_SCHED], 0, cleanup_locked); | ||||
| tcp_hpts_insert(pace, tp, timeout_usecs, NULL); | tcp_hpts_insert(pace, tp, timeout_usecs, NULL); | ||||
| KTEST_EQUAL(tp->t_in_hpts, IHPTS_ONQUEUE); | KTEST_EQUAL_GOTO(tp->t_in_hpts, IHPTS_ONQUEUE, cleanup_locked); | ||||
| INP_WUNLOCK(&tp->t_inpcb); | INP_WUNLOCK(&tp->t_inpcb); | ||||
| KTEST_EQUAL(call_counts[CCNT_TCP_OUTPUT], 0); | KTEST_EQUAL(call_counts[CCNT_TCP_OUTPUT], 0); | ||||
| KTEST_EQUAL(call_counts[CCNT_SWI_SCHED], 1); | KTEST_EQUAL(call_counts[CCNT_SWI_SCHED], 1); | ||||
| KTEST_VERIFY(tcp_in_hpts(tp)); | KTEST_VERIFY(tcp_in_hpts(tp)); | ||||
| KTEST_VERIFY(tp->t_hpts_slot >= 0); | KTEST_VERIFY(tp->t_hpts_slot >= 0); | ||||
| KTEST_VERIFY(tp->t_hpts_slot < NUM_OF_HPTSI_SLOTS); | KTEST_VERIFY(tp->t_hpts_slot < NUM_OF_HPTSI_SLOTS); | ||||
| hpts = pace->rp_ent[tp->t_hpts_cpu]; | hpts = pace->rp_ent[tp->t_hpts_cpu]; | ||||
| KTEST_EQUAL(hpts->p_on_queue_cnt, 1); | KTEST_EQUAL(hpts->p_on_queue_cnt, 1); | ||||
| KTEST_EQUAL(tp->t_hpts_request, 0); | KTEST_EQUAL(tp->t_hpts_request, 0); | ||||
| KTEST_EQUAL(tp->t_hpts_slot, HPTS_USEC_TO_SLOTS(timeout_usecs)); | KTEST_EQUAL(tp->t_hpts_slot, HPTS_USEC_TO_SLOTS(timeout_usecs)); | ||||
| //KTEST_EQUAL(tp->t_hpts_gencnt, 1); | //KTEST_EQUAL(tp->t_hpts_gencnt, 1); | ||||
| INP_WLOCK(&tp->t_inpcb); | INP_WLOCK(&tp->t_inpcb); | ||||
| tcp_hpts_remove(pace, tp); | tcp_hpts_remove(pace, tp); | ||||
| KTEST_EQUAL(tp->t_in_hpts, IHPTS_NONE); | KTEST_EQUAL_GOTO(tp->t_in_hpts, IHPTS_NONE, cleanup_locked); | ||||
| INP_WUNLOCK(&tp->t_inpcb); | INP_WUNLOCK(&tp->t_inpcb); | ||||
| KTEST_EQUAL(call_counts[CCNT_TCP_OUTPUT], 0); | KTEST_EQUAL(call_counts[CCNT_TCP_OUTPUT], 0); | ||||
| KTEST_VERIFY(!tcp_in_hpts(tp)); | KTEST_VERIFY(!tcp_in_hpts(tp)); | ||||
| KTEST_EQUAL(hpts->p_on_queue_cnt, 0); | KTEST_EQUAL(hpts->p_on_queue_cnt, 0); | ||||
| test_hpts_free_tcpcb(tp); | test_hpts_free_tcpcb(tp); | ||||
| tcp_hptsi_stop(pace); | tcp_hptsi_stop(pace); | ||||
| tcp_hptsi_destroy(pace); | tcp_hptsi_destroy(pace); | ||||
| return (0); | return (0); | ||||
| cleanup_locked: | |||||
| INP_WUNLOCK(&tp->t_inpcb); | |||||
| return (error); | |||||
| } | } | ||||
| /* | /* | ||||
| * Validates the core HPTS timer functionality by verifying that scheduled | * Validates the core HPTS timer functionality by verifying that scheduled | ||||
| * tcpcb entries trigger tcp_output calls at appropriate times, simulating | * tcpcb entries trigger tcp_output calls at appropriate times, simulating | ||||
| * real-world timer-driven TCP processing. | * real-world timer-driven TCP processing. | ||||
| */ | */ | ||||
| KTEST_FUNC(timer_functionality) | KTEST_FUNC(timer_functionality) | ||||
| ▲ Show 20 Lines • Show All 791 Lines • ▼ Show 20 Lines | |||||
| */ | */ | ||||
| KTEST_FUNC(direct_wake_mechanism) | KTEST_FUNC(direct_wake_mechanism) | ||||
| { | { | ||||
| struct tcp_hptsi *pace; | struct tcp_hptsi *pace; | ||||
| struct tcpcb *tp; | struct tcpcb *tp; | ||||
| struct tcp_hpts_entry *hpts; | struct tcp_hpts_entry *hpts; | ||||
| int error; | int error; | ||||
| error = 0; | |||||
| test_hpts_init(); | test_hpts_init(); | ||||
| pace = tcp_hptsi_create(&test_funcs, false); | pace = tcp_hptsi_create(&test_funcs, false); | ||||
| KTEST_NEQUAL(pace, NULL); | KTEST_NEQUAL(pace, NULL); | ||||
| tcp_hptsi_start(pace); | tcp_hptsi_start(pace); | ||||
| tp = test_hpts_create_tcpcb(ctx, pace); | tp = test_hpts_create_tcpcb(ctx, pace); | ||||
| KTEST_NEQUAL(tp, NULL); | KTEST_NEQUAL(tp, NULL); | ||||
| ▲ Show 20 Lines • Show All 220 Lines • Show Last 20 Lines | |||||