1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Chelsio Communications.
8 #include "cxgbe_filter.h"
11 * Validate if the requested filter specification can be set by checking
12 * if the requested features have been enabled
14 int validate_filter(struct adapter *adapter, struct ch_filter_specification *fs)
19 * Check for unconfigured fields being used.
21 fconf = adapter->params.tp.vlan_pri_map;
24 (fs->val._field || fs->mask._field)
25 #define U(_mask, _field) \
26 (!(fconf & (_mask)) && S(_field))
28 if (U(F_ETHERTYPE, ethtype) || U(F_PROTOCOL, proto))
37 * Check if entry already filled.
39 bool is_filter_set(struct tid_info *t, int fidx, int family)
44 /* IPv6 requires four slots and IPv4 requires only 1 slot.
45 * Ensure, there's enough slots available.
47 max = family == FILTER_TYPE_IPV6 ? fidx + 3 : fidx;
49 t4_os_lock(&t->ftid_lock);
50 for (i = fidx; i <= max; i++) {
51 if (rte_bitmap_get(t->ftid_bmap, i)) {
56 t4_os_unlock(&t->ftid_lock);
61 * Allocate a available free entry
63 int cxgbe_alloc_ftid(struct adapter *adap, unsigned int family)
65 struct tid_info *t = &adap->tids;
69 t4_os_lock(&t->ftid_lock);
70 if (family == FILTER_TYPE_IPV6)
71 pos = cxgbe_bitmap_find_free_region(t->ftid_bmap, size, 4);
73 pos = cxgbe_find_first_zero_bit(t->ftid_bmap, size);
74 t4_os_unlock(&t->ftid_lock);
76 return pos < size ? pos : -1;