# SPDX-License-Identifier: GPL-2.0
import re
+import resource
import time
from os import path
from lib.py import ksft_run, ksft_exit, KsftSkipEx, ksft_variants, KsftNamedVariant
return int(values)
+def check_iou_rx_buf_len(cfg, expected_rx_buf_len):
+ """Check the io-uring memory provider exposes the expected rx_buf_len."""
+ q = cfg.netnl.queue_get({'ifindex': cfg.ifindex, 'type': 'rx', 'id': cfg.target})
+ napi_id = q['napi-id']
+ pools = cfg.netnl.page_pool_get({}, dump=True)
+ pools = [p for p in pools if p.get('napi-id') == napi_id
+ and 'io-uring' in p]
+ if len(pools) != 1:
+ raise Exception(f"Expected 1 io-uring page pool, found {len(pools)}")
+ rx_buf_len = pools[0]['io-uring'].get('rx-buf-len')
+ if rx_buf_len is None:
+ raise KsftSkipEx("io-uring 'rx-buf-len' attribute not supported")
+ if rx_buf_len != expected_rx_buf_len:
+ raise Exception(f'Expected io-uring rx-buf-len {expected_rx_buf_len}, '
+ f'got {rx_buf_len}')
+
+
def single(cfg):
channels = cfg.ethnl.channels_get({'header': {'dev-index': cfg.ifindex}})
channels = channels['combined-count']
defer(lambda: open(hp_file, 'w', encoding='utf-8').write(str(nr_hugepages)))
single(cfg)
- rx_cmd = f"{cfg.bin_local} -s -p {cfg.port} -i {cfg.ifname} -q {cfg.target} -x 2"
+ page_size = resource.getpagesize()
+ nr_pages = 2
+ rx_buf_len = nr_pages * page_size
+ rx_cmd = f"{cfg.bin_local} -s -p {cfg.port} -i {cfg.ifname} -q {cfg.target} -x {nr_pages}"
tx_cmd = f"{cfg.bin_remote} -c -h {cfg.addr_v['6']} -p {cfg.port} -l 12840"
probe = cmd(rx_cmd + " -d", fail=False)
mp_clear_wait(cfg)
with bkg(rx_cmd, exit_wait=True):
wait_port_listen(cfg.port, proto="tcp")
+
+ check_iou_rx_buf_len(cfg, rx_buf_len)
+
cmd(tx_cmd, host=cfg.remote)