1986e7b92SArtur Rojek /*- 2986e7b92SArtur Rojek * SPDX-License-Identifier: BSD-2-Clause 3986e7b92SArtur Rojek * 4*8d6806cdSOsama Abboud * Copyright (c) 2015-2024 Amazon.com, Inc. or its affiliates. 5986e7b92SArtur Rojek * All rights reserved. 6986e7b92SArtur Rojek * 7986e7b92SArtur Rojek * Redistribution and use in source and binary forms, with or without 8986e7b92SArtur Rojek * modification, are permitted provided that the following conditions 9986e7b92SArtur Rojek * are met: 10986e7b92SArtur Rojek * 11986e7b92SArtur Rojek * 1. Redistributions of source code must retain the above copyright 12986e7b92SArtur Rojek * notice, this list of conditions and the following disclaimer. 13986e7b92SArtur Rojek * 14986e7b92SArtur Rojek * 2. Redistributions in binary form must reproduce the above copyright 15986e7b92SArtur Rojek * notice, this list of conditions and the following disclaimer in the 16986e7b92SArtur Rojek * documentation and/or other materials provided with the distribution. 17986e7b92SArtur Rojek * 18986e7b92SArtur Rojek * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19986e7b92SArtur Rojek * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20986e7b92SArtur Rojek * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21986e7b92SArtur Rojek * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22986e7b92SArtur Rojek * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23986e7b92SArtur Rojek * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24986e7b92SArtur Rojek * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25986e7b92SArtur Rojek * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26986e7b92SArtur Rojek * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27986e7b92SArtur Rojek * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28986e7b92SArtur Rojek * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29986e7b92SArtur Rojek * 30986e7b92SArtur Rojek */ 31986e7b92SArtur Rojek 32986e7b92SArtur Rojek #ifndef ENA_RSS_H 33986e7b92SArtur Rojek #define ENA_RSS_H 34986e7b92SArtur Rojek 35986e7b92SArtur Rojek #include "opt_rss.h" 36986e7b92SArtur Rojek 37986e7b92SArtur Rojek #include <sys/types.h> 38986e7b92SArtur Rojek 39986e7b92SArtur Rojek #ifdef RSS 40986e7b92SArtur Rojek #include <net/rss_config.h> 41986e7b92SArtur Rojek #endif 42986e7b92SArtur Rojek 43986e7b92SArtur Rojek #include "ena.h" 44986e7b92SArtur Rojek 456d1ef2abSArtur Rojek #define ENA_RX_RSS_MSG_RECORD_SZ 8 466d1ef2abSArtur Rojek 476d1ef2abSArtur Rojek struct ena_indir { 486d1ef2abSArtur Rojek uint32_t table[ENA_RX_RSS_TABLE_SIZE]; 496d1ef2abSArtur Rojek /* This is the buffer wired to `rss.indir_table` sysctl. */ 506d1ef2abSArtur Rojek char sysctl_buf[ENA_RX_RSS_TABLE_SIZE * ENA_RX_RSS_MSG_RECORD_SZ]; 516d1ef2abSArtur Rojek }; 526d1ef2abSArtur Rojek 536d1ef2abSArtur Rojek int ena_rss_set_hash(struct ena_com_dev *ena_dev, const u8 *key); 546d1ef2abSArtur Rojek int ena_rss_get_hash_key(struct ena_com_dev *ena_dev, u8 *key); 55986e7b92SArtur Rojek int ena_rss_configure(struct ena_adapter *); 566d1ef2abSArtur Rojek int ena_rss_indir_get(struct ena_adapter *adapter, uint32_t *table); 576d1ef2abSArtur Rojek int ena_rss_indir_set(struct ena_adapter *adapter, uint32_t *table); 586d1ef2abSArtur Rojek int ena_rss_indir_init(struct ena_adapter *adapter); 596d1ef2abSArtur Rojek 606d1ef2abSArtur Rojek static inline void 616d1ef2abSArtur Rojek ena_rss_copy_indir_buf(char *buf, uint32_t *table) 626d1ef2abSArtur Rojek { 636d1ef2abSArtur Rojek int i; 646d1ef2abSArtur Rojek 656d1ef2abSArtur Rojek for (i = 0; i < ENA_RX_RSS_TABLE_SIZE; ++i) { 6682e558eaSDawid Gorecki buf += snprintf(buf, ENA_RX_RSS_MSG_RECORD_SZ + 1, "%s%d:%d", 6782e558eaSDawid Gorecki i == 0 ? "" : " ", i, table[i]); 686d1ef2abSArtur Rojek } 696d1ef2abSArtur Rojek } 70986e7b92SArtur Rojek 71986e7b92SArtur Rojek #endif /* !(ENA_RSS_H) */ 72