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