@@ -651,7 +651,7 @@ static u32 pkt_get_buffer_len(struct xsk_umem_info *umem, u32 len)
651651 return ceil_u32 (len , umem -> frame_size ) * umem -> frame_size ;
652652}
653653
654- static struct pkt_stream * pkt_stream_generate (u32 nb_pkts , u32 pkt_len )
654+ static struct pkt_stream * __pkt_stream_generate (u32 nb_pkts , u32 pkt_len , u32 nb_start , u32 nb_off )
655655{
656656 struct pkt_stream * pkt_stream ;
657657 u32 i ;
@@ -666,12 +666,17 @@ static struct pkt_stream *pkt_stream_generate(u32 nb_pkts, u32 pkt_len)
666666 struct pkt * pkt = & pkt_stream -> pkts [i ];
667667
668668 pkt_set (pkt_stream , pkt , 0 , pkt_len );
669- pkt -> pkt_nb = i ;
669+ pkt -> pkt_nb = nb_start + i * nb_off ;
670670 }
671671
672672 return pkt_stream ;
673673}
674674
675+ static struct pkt_stream * pkt_stream_generate (u32 nb_pkts , u32 pkt_len )
676+ {
677+ return __pkt_stream_generate (nb_pkts , pkt_len , 0 , 1 );
678+ }
679+
675680static struct pkt_stream * pkt_stream_clone (struct pkt_stream * pkt_stream )
676681{
677682 return pkt_stream_generate (pkt_stream -> nb_pkts , pkt_stream -> pkts [0 ].len );
@@ -721,6 +726,24 @@ static void pkt_stream_receive_half(struct test_spec *test)
721726 pkt_stream -> nb_valid_entries /= 2 ;
722727}
723728
729+ static void pkt_stream_even_odd_sequence (struct test_spec * test )
730+ {
731+ struct pkt_stream * pkt_stream ;
732+ u32 i ;
733+
734+ for (i = 0 ; i < test -> nb_sockets ; i ++ ) {
735+ pkt_stream = test -> ifobj_tx -> xsk_arr [i ].pkt_stream ;
736+ pkt_stream = __pkt_stream_generate (pkt_stream -> nb_pkts / 2 ,
737+ pkt_stream -> pkts [0 ].len , i , 2 );
738+ test -> ifobj_tx -> xsk_arr [i ].pkt_stream = pkt_stream ;
739+
740+ pkt_stream = test -> ifobj_rx -> xsk_arr [i ].pkt_stream ;
741+ pkt_stream = __pkt_stream_generate (pkt_stream -> nb_pkts / 2 ,
742+ pkt_stream -> pkts [0 ].len , i , 2 );
743+ test -> ifobj_rx -> xsk_arr [i ].pkt_stream = pkt_stream ;
744+ }
745+ }
746+
724747static u64 pkt_get_addr (struct pkt * pkt , struct xsk_umem_info * umem )
725748{
726749 if (!pkt -> valid )
@@ -1584,6 +1607,7 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject)
15841607 LIBBPF_OPTS (bpf_xdp_query_opts , opts );
15851608 void * bufs ;
15861609 int ret ;
1610+ u32 i ;
15871611
15881612 if (ifobject -> umem -> unaligned_mode )
15891613 mmap_flags |= MAP_HUGETLB | MAP_HUGE_2MB ;
@@ -1608,9 +1632,12 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject)
16081632
16091633 xsk_populate_fill_ring (ifobject -> umem , ifobject -> xsk -> pkt_stream , ifobject -> use_fill_ring );
16101634
1611- ret = xsk_update_xskmap (ifobject -> xskmap , ifobject -> xsk -> xsk , 0 );
1612- if (ret )
1613- exit_with_error (errno );
1635+ for (i = 0 ; i < test -> nb_sockets ; i ++ ) {
1636+ ifobject -> xsk = & ifobject -> xsk_arr [i ];
1637+ ret = xsk_update_xskmap (ifobject -> xskmap , ifobject -> xsk -> xsk , i );
1638+ if (ret )
1639+ exit_with_error (errno );
1640+ }
16141641}
16151642
16161643static void * worker_testapp_validate_tx (void * arg )
@@ -2111,6 +2138,23 @@ static int testapp_xdp_metadata_copy(struct test_spec *test)
21112138 return testapp_validate_traffic (test );
21122139}
21132140
2141+ static int testapp_xdp_shared_umem (struct test_spec * test )
2142+ {
2143+ struct xsk_xdp_progs * skel_rx = test -> ifobj_rx -> xdp_progs ;
2144+ struct xsk_xdp_progs * skel_tx = test -> ifobj_tx -> xdp_progs ;
2145+
2146+ test -> total_steps = 1 ;
2147+ test -> nb_sockets = 2 ;
2148+
2149+ test_spec_set_xdp_prog (test , skel_rx -> progs .xsk_xdp_shared_umem ,
2150+ skel_tx -> progs .xsk_xdp_shared_umem ,
2151+ skel_rx -> maps .xsk , skel_tx -> maps .xsk );
2152+
2153+ pkt_stream_even_odd_sequence (test );
2154+
2155+ return testapp_validate_traffic (test );
2156+ }
2157+
21142158static int testapp_poll_txq_tmout (struct test_spec * test )
21152159{
21162160 test -> ifobj_tx -> use_poll = true;
@@ -2412,6 +2456,7 @@ static const struct test_spec tests[] = {
24122456 {.name = "STAT_FILL_EMPTY" , .test_func = testapp_stats_fill_empty },
24132457 {.name = "XDP_PROG_CLEANUP" , .test_func = testapp_xdp_prog_cleanup },
24142458 {.name = "XDP_DROP_HALF" , .test_func = testapp_xdp_drop },
2459+ {.name = "XDP_SHARED_UMEM" , .test_func = testapp_xdp_shared_umem },
24152460 {.name = "XDP_METADATA_COPY" , .test_func = testapp_xdp_metadata },
24162461 {.name = "XDP_METADATA_COPY_MULTI_BUFF" , .test_func = testapp_xdp_metadata_mb },
24172462 {.name = "SEND_RECEIVE_9K_PACKETS" , .test_func = testapp_send_receive_mb },
0 commit comments