1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright (c) 2021, Intel Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the Intel Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
34 * @file iavf_txrx_common.h
35 * @brief Tx/Rx hotpath functions common to legacy and iflib
37 * Contains implementations for functions used in the hotpath for both the
38 * legacy and iflib driver implementations.
40 #ifndef _IAVF_TXRX_COMMON_H_
41 #define _IAVF_TXRX_COMMON_H_
43 #include "iavf_iflib.h"
45 static inline int iavf_ptype_to_hash(u8 ptype);
48 * iavf_ptype_to_hash - parse the packet type
51 * Determine the appropriate hash for a given packet type
53 * @returns the M_HASHTYPE_* value for the given packet type.
56 iavf_ptype_to_hash(u8 ptype)
58 struct iavf_rx_ptype_decoded decoded;
60 decoded = decode_rx_desc_ptype(ptype);
63 return M_HASHTYPE_OPAQUE;
65 if (decoded.outer_ip == IAVF_RX_PTYPE_OUTER_L2)
66 return M_HASHTYPE_OPAQUE;
68 /* Note: anything that gets to this point is IP */
69 if (decoded.outer_ip_ver == IAVF_RX_PTYPE_OUTER_IPV6) {
70 switch (decoded.inner_prot) {
71 case IAVF_RX_PTYPE_INNER_PROT_TCP:
72 return M_HASHTYPE_RSS_TCP_IPV6;
73 case IAVF_RX_PTYPE_INNER_PROT_UDP:
74 return M_HASHTYPE_RSS_UDP_IPV6;
76 return M_HASHTYPE_RSS_IPV6;
79 if (decoded.outer_ip_ver == IAVF_RX_PTYPE_OUTER_IPV4) {
80 switch (decoded.inner_prot) {
81 case IAVF_RX_PTYPE_INNER_PROT_TCP:
82 return M_HASHTYPE_RSS_TCP_IPV4;
83 case IAVF_RX_PTYPE_INNER_PROT_UDP:
84 return M_HASHTYPE_RSS_UDP_IPV4;
86 return M_HASHTYPE_RSS_IPV4;
89 /* We should never get here! */
90 return M_HASHTYPE_OPAQUE;
93 #endif /* _IAVF_TXRX_COMMON_H_ */