MCPcopy Create free account
hub / github.com/F-Stack/f-stack / balanced_traffic

Function balanced_traffic

dpdk/usertools/dpdk-rss-flows.py:119–152  ·  view source on GitHub ↗
(
    algo: RSSAlgo,
    traffic_template: TrafficTemplate,
    check_reverse_traffic: bool = False,
    all_flows: bool = False,
)

Source from the content-addressed store, hash-verified

117
118
119def balanced_traffic(
120 algo: RSSAlgo,
121 traffic_template: TrafficTemplate,
122 check_reverse_traffic: bool = False,
123 all_flows: bool = False,
124) -> typing.Iterator[typing.Tuple[int, int, Packet]]:
125 queues = set()
126 if check_reverse_traffic:
127 queues_reverse = set()
128
129 for pkt in traffic_template:
130 q = algo.get_queue_index(pkt)
131
132 # check if q is already filled
133 if not all_flows and q in queues:
134 continue
135
136 qr = algo.get_queue_index(pkt.reverse())
137
138 if check_reverse_traffic:
139 # check if q is already filled
140 if not all_flows and qr in queues_reverse:
141 continue
142 # mark this queue as matched
143 queues_reverse.add(qr)
144
145 # mark this queue as filled
146 queues.add(q)
147
148 yield q, qr, pkt
149
150 # stop when all queues have been filled
151 if not all_flows and len(queues) == algo.queues_count:
152 break
153
154
155NO_PORT = (0,)

Callers 1

mainFunction · 0.85

Calls 3

get_queue_indexMethod · 0.80
reverseMethod · 0.80
setFunction · 0.50

Tested by

no test coverage detected