@@ -257,15 +257,23 @@ static void zcrx_populate_area(struct io_uring_zcrx_area_reg *area_reg)
257257static void setup_zcrx (struct io_uring * ring )
258258{
259259 struct io_uring_zcrx_area_reg area_reg ;
260- unsigned int ifindex ;
261260 unsigned int rq_entries = cfg_rq_entries ;
261+ unsigned int qidx = cfg_queue_id ;
262+ unsigned ifq_flags = 0 ;
262263 unsigned rq_flags = 0 ;
264+ unsigned int ifindex ;
263265 size_t ring_size ;
264266 int ret ;
265267
266- ifindex = if_nametoindex (cfg_ifname );
267- if (!ifindex )
268- t_error (1 , 0 , "bad interface name: %s" , cfg_ifname );
268+ if (cfg_ifname ) {
269+ ifindex = if_nametoindex (cfg_ifname );
270+ if (!ifindex )
271+ t_error (1 , 0 , "bad interface name: %s" , cfg_ifname );
272+ } else {
273+ ifq_flags |= ZCRX_REG_NODEV ;
274+ ifindex = 0 ;
275+ qidx = 0 ;
276+ }
269277
270278 ring_size = get_refill_ring_size (rq_entries );
271279 ring_ptr = NULL ;
@@ -289,7 +297,8 @@ static void setup_zcrx(struct io_uring *ring)
289297
290298 struct io_uring_zcrx_ifq_reg reg = {
291299 .if_idx = ifindex ,
292- .if_rxq = cfg_queue_id ,
300+ .if_rxq = qidx ,
301+ .flags = ifq_flags ,
293302 .rq_entries = rq_entries ,
294303 .area_ptr = uring_ptr_to_u64 (& area_reg ),
295304 .region_ptr = uring_ptr_to_u64 (& region_reg ),
@@ -663,9 +672,9 @@ static void parse_opts(int argc, char **argv)
663672 }
664673 }
665674
666- if (!cfg_ifname )
667- t_error (1 , - EINVAL , "Interface is not specified " );
668- if (cfg_queue_id == -1 )
675+ if (!cfg_ifname && cfg_queue_id != -1 )
676+ t_error (1 , - EINVAL , "Queue index passed for device-less zcrx " );
677+ if (cfg_ifname && cfg_queue_id == -1 )
669678 t_error (1 , - EINVAL , "Queue idx is not specified" );
670679}
671680
0 commit comments