Lines Matching full:context

26 def _rss_key_check(cfg, data=None, context=0):  argument
28 data = get_rss(cfg, context=context)
35 def get_rss(cfg, context=0): argument
36 return ethtool(f"-x {cfg.ifname} context {context}", json=True)[0]
51 # Output will be something like: "New RSS context is 1" or
65 # There's no good API to get the context count, so the tests
92 # used for queues of the main context, since some background
112 """Check that ntuple rule references RSS context ID"""
114 pattern = f"RSS Context (ID: )?{ctx_id}"
115 ksft_true(re.search(pattern, text), "RSS context not referenced in ntuple rule")
172 ksft_ge(cnts[0], 5000, "traffic on main context (1/2): " + str(cnts))
173 ksft_ge(cnts[1], 5000, "traffic on main context (2/2): " + str(cnts))
216 ctx_id = ethtool_create(cfg, "-X", "context new")
217 ctx_ref = f"context {ctx_id}"
221 data = get_rss(cfg, context=ctx_id)
242 flow = f"flow-type tcp{cfg.addr_ipver} dst-ip {cfg.addr} dst-port {port} context {ctx_id}"
251 data = get_rss(cfg, context=ctx_id)
263 … raise Exception(f"Driver didn't prevent us from deactivating a used queue (context {ctx_id})")
267 …flow = f"flow-type tcp{cfg.addr_ipver} dst-ip {cfg.addr} dst-port {port} context {ctx_id} action 1"
275 … raise Exception(f"Driver didn't prevent us from targeting a nonexistent queue (context {ctx_id})")
296 … raise Exception(f"Driver didn't prevent us from deactivating a used queue (context {ctx_id})")
379 ids.append(ethtool_create(cfg, "-X", f"context new"))
380 defer(ethtool, f"-X {cfg.ifname} context {ids[-1]} delete")
382 ids.append(ethtool_create(cfg, "-X", f"context new weight 1 1"))
383 defer(ethtool, f"-X {cfg.ifname} context {ids[-1]} delete")
385 ids.append(ethtool_create(cfg, "-X", f"context new hkey {key}"))
386 defer(ethtool, f"-X {cfg.ifname} context {ids[-1]} delete")
396 tuples = [(c['header']['dev-name'], c.get('context', -1)) for c in ctxs]
397 ksft_eq(len(tuples), len(set(tuples)), "duplicates in context dump")
407 if len(ids) > 1 and data.get('context') == ids[1]:
410 if len(ids) > 2 and data.get('context') == ids[2]:
415 tuples = [(c['header']['dev-name'], c.get('context', -1)) for c in ctxs]
417 ksft_eq(len(tuples), len(ctx_tuples), "duplicates in context dump")
423 ctxs = cfg.ethnl.rss_get({'start-context': 1}, dump=True)
424 tuples = [(c['header']['dev-name'], c.get('context', -1)) for c in ctxs]
425 ksft_eq(len(tuples), len(set(tuples)), "duplicates in context dump")
430 ctxs = cfg.ethnl.rss_get({'header': {'dev-name': cfg.ifname}, 'start-context': 1}, dump=True)
431 ctx_tuples = set([(c['header']['dev-name'], c.get('context', -1)) for c in ctxs])
438 The queues will be allocated 2 for each context:
468 ctx_id = ethtool_create(cfg, "-X", f"context new {create_cfg}")
469 defer(ethtool, f"-X {cfg.ifname} context {ctx_id} delete")
474 ksft_pr(f"Failed to create context {i + 1}, trying to test what we got")
480 _rss_key_check(cfg, context=ctx_id)
483 ethtool(f"-X {cfg.ifname} context {ctx_id} {want_cfg}")
484 _rss_key_check(cfg, context=ctx_id)
486 # Sanity check the context we just created
488 … ksft_eq(min(data['rss-indirection-table']), 2 + i * 2, "Unexpected context cfg: " + str(data))
489 … ksft_eq(max(data['rss-indirection-table']), 2 + i * 2 + 1, "Unexpected context cfg: " + str(data))
492 … flow = f"flow-type tcp{cfg.addr_ipver} dst-ip {cfg.addr} dst-port {ports[i]} context {ctx_id}"
499 _send_traffic_check(cfg, ports[i], f"context {i}",
569 _send_traffic_check(cfg, ports[i], f"context {i}", expected)
576 ctx_id = ethtool_create(cfg, "-X", f"context new start {2 + i * 2} equal 2")
577 ctx.append(defer(ethtool, f"-X {cfg.ifname} context {ctx_id} delete"))
580 … flow = f"flow-type tcp{cfg.addr_ipver} dst-ip {cfg.addr} dst-port {ports[i]} context {ctx_id}"
586 # Remove middle context
590 # Remove first context
594 # Remove last context
602 Use 4 queues for the main context, but only queues 2 and 3 for context 1.
622 other_ctx = ethtool_create(cfg, "-X", "context new")
623 ethtool(f"-X {cfg.ifname} context {other_ctx} equal 4")
624 defer(ethtool, f"-X {cfg.ifname} context {other_ctx} delete")
626 ctx_id = ethtool_create(cfg, "-X", "context new")
627 ethtool(f"-X {cfg.ifname} context {ctx_id} start 2 equal 2")
628 defer(ethtool, f"-X {cfg.ifname} context {ctx_id} delete")
632 … flow = f"flow-type tcp{cfg.addr_ipver} dst-ip {cfg.addr} dst-port {port} context {other_ctx}"
636 # Test the main context
641 ksft_ge(sum(cnts[ :4]), 20000, "traffic on main context: " + str(cnts))
642 ksft_ge(sum(cnts[ :2]), 7000, "traffic on main context (1/2): " + str(cnts))
643 ksft_ge(sum(cnts[2:4]), 7000, "traffic on main context (2/2): " + str(cnts))
647 # Now create a rule for context 1 and make sure traffic goes to a subset
650 flow = f"flow-type tcp{cfg.addr_ipver} dst-ip {cfg.addr} dst-port {port} context {ctx_id}"
659 ksft_lt(sum(cnts[ :2]), directed / 2, "traffic on main context: " + str(cnts))
660 ksft_ge(directed, 20000, "traffic on extra context: " + str(cnts))
671 Test that we are not allowed to add a rule pointing to an RSS context
677 # Find a context which doesn't exist
680 get_rss(cfg, context=ctx_id)
685 flow = f"flow-type tcp{cfg.addr_ipver} dst-ip {cfg.addr} dst-port 1234 context {ctx_id}"
694 Test that deletion returns -EBUSY when an rss context is being used
700 # create additional rss context
701 ctx_id = ethtool_create(cfg, "-X", "context new")
702 ctx_deleter = defer(ethtool, f"-X {cfg.ifname} context {ctx_id} delete")
704 # utilize context from ntuple filter
706 flow = f"flow-type tcp{cfg.addr_ipver} dst-ip {cfg.addr} dst-port {port} context {ctx_id}"
710 # attempt to delete in-use context
714 raise KsftFailEx(f"deleted context {ctx_id} used by rule {ntuple_id}")
740 # create additional rss context
741 ctx_id = ethtool_create(cfg, "-X", "context new equal 2")
742 defer(ethtool, f"-X {cfg.ifname} context {ctx_id} delete")
744 # utilize context from ntuple filter
746 …flow = f"flow-type tcp{cfg.addr_ipver} dst-ip {cfg.addr} dst-port {port} context {ctx_id} action 2"
753 _send_traffic_check(cfg, port, f"context {ctx_id}", { 'target': (2, 3),
760 Allocate a port, direct this port to context 0, then create a new RSS
761 context and steer all TCP traffic to it (context 1). Verify that:
763 context (0/1).
764 * Traffic to any other TCP port is redirected to the new context
779 # Use queues 0 and 1 for the main context
783 # Create a new RSS context that uses queues 2 and 3
784 ctx_id = ethtool_create(cfg, "-X", "context new start 2 equal 2")
785 defer(ethtool, f"-X {cfg.ifname} context {ctx_id} delete")
787 # Generic low-priority rule: redirect all TCP traffic to the new context.
789 flow_generic = f"flow-type tcp{cfg.addr_ipver} dst-ip {cfg.addr} context {ctx_id} loc 1"
793 # Specific high-priority rule for a random port that should stay on context 0.
796 …flow_main = f"flow-type tcp{cfg.addr_ipver} dst-ip {cfg.addr} dst-port {port_main} context 0 loc 0"
803 _send_traffic_check(cfg, port_main, "context 0",
807 # And that traffic for any other port is steered to the new context
809 _send_traffic_check(cfg, port_other, f"context {ctx_id}",
840 ctx1_id = ethtool_create(cfg, "-X", "context new start 2 equal 2")
841 defer(ethtool, f"-X {cfg.ifname} context {ctx1_id} delete")
843 raise KsftSkipEx("Create context not supported with interface down") from exc
845 ctx2_id = ethtool_create(cfg, "-X", "context new start 4 equal 2")
846 defer(ethtool, f"-X {cfg.ifname} context {ctx2_id} delete")
849 flow = f"flow-type tcp{cfg.addr_ipver} dst-ip {cfg.addr} dst-port {port_ctx2} context {ctx2_id}"
870 data1 = [c for c in ctxs if c.get('context') == ctx1_id]
871 ksft_eq(len(data1), 1, f"Context {ctx1_id} should persist after ifup")
873 data2 = [c for c in ctxs if c.get('context') == ctx2_id]
874 ksft_eq(len(data2), 1, f"Context {ctx2_id} should persist after ifup")
883 ksft_ge(main_traffic, 18000, f"Main context traffic distribution: {cnts}")
884 ksft_lt(sum(cnts[2:6]), 500, f"Other context queues should be mostly empty: {cnts}")
886 _send_traffic_check(cfg, port_ctx2, f"context {ctx2_id}",