1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
6 #include "distributor_private.h"
11 find_match_vec(struct rte_distributor *d,
16 __m128i incoming_fids;
17 __m128i inflight_fids;
18 __m128i preflight_fids;
23 struct rte_distributor_backlog *bl;
28 * 2. Loop through all worker ID's
29 * 2a. Load the current inflights for that worker into an xmm reg
30 * 2b. Load the current backlog for that worker into an xmm reg
31 * 2c. use cmpestrm to intersect flow_ids with backlog and inflights
32 * 2d. Add any matches to the output
33 * 3. Write the output xmm (matching worker ids).
37 output = _mm_set1_epi16(0);
38 incoming_fids = _mm_load_si128((__m128i *)data_ptr);
40 for (i = 0; i < d->num_workers; i++) {
44 _mm_load_si128((__m128i *)&(d->in_flight_tags[i]));
46 _mm_load_si128((__m128i *)(bl->tags));
49 * Any incoming_fid that exists anywhere in inflight_fids will
50 * have 0xffff in same position of the mask as the incoming fid
51 * Example (shortened to bytes for brevity):
52 * incoming_fids 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08
53 * inflight_fids 0x03 0x05 0x07 0x00 0x00 0x00 0x00 0x00
54 * mask 0x00 0x00 0xff 0x00 0xff 0x00 0xff 0x00
57 mask1 = _mm_cmpestrm(inflight_fids, 8, incoming_fids, 8,
61 mask2 = _mm_cmpestrm(preflight_fids, 8, incoming_fids, 8,
66 mask1 = _mm_or_si128(mask1, mask2);
68 * Now mask contains 0xffff where there's a match.
69 * Next we need to store the worker_id in the relevant position
73 wkr = _mm_set1_epi16(i+1);
74 mask1 = _mm_and_si128(mask1, wkr);
75 output = _mm_or_si128(mask1, output);
79 * At this stage, the output 128-bit contains 8 16-bit values, with
80 * each non-zero value containing the worker ID on which the
81 * corresponding flow is pinned to.
83 _mm_store_si128((__m128i *)output_ptr, output);