+ smt_used = CpuUtils.is_smt_enabled(node[u"cpuinfo"])
+ cpu_list = CpuUtils.cpu_list_per_node(node, cpu_node, smt_used)
+ # CPU thread sibling offset.
+ sib = len(cpu_list) // CpuUtils.NR_OF_THREADS
+
+ dtc_is_integer = isinstance(nf_dtc, int)
+ if not smt_used and not dtc_is_integer:
+ raise RuntimeError(u"Cannot allocate if SMT is not enabled!")
+ # TODO: Please reword the following todo if it is still relevant
+ # TODO: Workaround as we are using physical core as main unit, we must
+ # adjust number of physical dataplane cores in case of float for further
+ # array referencing. As rounding method in Py2.7 and Py3.x differs, we
+ # are using static mapping. This can be rewritten using flat arrays and
+ # different logic (from Physical core unit to Logical core unit).
+ if not dtc_is_integer:
+ nf_dtc = 1
+
+ mt_req = ((nf_chains * nf_nodes) + nf_mtcr - 1) // nf_mtcr
+ dt_req = ((nf_chains * nf_nodes) + nf_dtcr - 1) // nf_dtcr
+
+ if (skip_cnt + mt_req + dt_req) > (sib if smt_used else len(cpu_list)):
+ raise RuntimeError(u"Not enough CPU cores available for placement!")
+
+ offset = (nf_node - 1) + (nf_chain - 1) * nf_nodes
+ mt_skip = skip_cnt + (offset % mt_req)
+ dt_skip = skip_cnt + mt_req + (offset % dt_req) * nf_dtc
+
+ result = cpu_list[dt_skip:dt_skip + nf_dtc]
+ if smt_used:
+ if (offset // mt_req) & 1: # check oddness
+ mt_skip += sib