1/* SPDX-License-Identifier: BSD-3-Clause */ 2/* Copyright (c) 2021, Intel Corporation 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 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. 14 * 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. 18 * 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. 30 */ 31 32#ifndef _IAVF_PROTOTYPE_H_ 33#define _IAVF_PROTOTYPE_H_ 34 35#include "iavf_type.h" 36#include "iavf_alloc.h" 37#include "virtchnl.h" 38 39/* Prototypes for shared code functions that are not in 40 * the standard function pointer structures. These are 41 * mostly because they are needed even before the init 42 * has happened and will assist in the early SW and FW 43 * setup. 44 */ 45 46/* adminq functions */ 47enum iavf_status iavf_init_adminq(struct iavf_hw *hw); 48enum iavf_status iavf_shutdown_adminq(struct iavf_hw *hw); 49enum iavf_status iavf_init_asq(struct iavf_hw *hw); 50enum iavf_status iavf_init_arq(struct iavf_hw *hw); 51enum iavf_status iavf_alloc_adminq_asq_ring(struct iavf_hw *hw); 52enum iavf_status iavf_alloc_adminq_arq_ring(struct iavf_hw *hw); 53enum iavf_status iavf_shutdown_asq(struct iavf_hw *hw); 54enum iavf_status iavf_shutdown_arq(struct iavf_hw *hw); 55u16 iavf_clean_asq(struct iavf_hw *hw); 56void iavf_free_adminq_asq(struct iavf_hw *hw); 57void iavf_free_adminq_arq(struct iavf_hw *hw); 58enum iavf_status iavf_validate_mac_addr(u8 *mac_addr); 59void iavf_adminq_init_ring_data(struct iavf_hw *hw); 60enum iavf_status iavf_clean_arq_element(struct iavf_hw *hw, 61 struct iavf_arq_event_info *e, 62 u16 *events_pending); 63enum iavf_status iavf_asq_send_command(struct iavf_hw *hw, 64 struct iavf_aq_desc *desc, 65 void *buff, /* can be NULL */ 66 u16 buff_size, 67 struct iavf_asq_cmd_details *cmd_details); 68bool iavf_asq_done(struct iavf_hw *hw); 69 70/* debug function for adminq */ 71void iavf_debug_aq(struct iavf_hw *hw, enum iavf_debug_mask mask, 72 void *desc, void *buffer, u16 buf_len); 73 74void iavf_idle_aq(struct iavf_hw *hw); 75bool iavf_check_asq_alive(struct iavf_hw *hw); 76enum iavf_status iavf_aq_queue_shutdown(struct iavf_hw *hw, bool unloading); 77 78enum iavf_status iavf_aq_get_rss_lut(struct iavf_hw *hw, u16 seid, 79 bool pf_lut, u8 *lut, u16 lut_size); 80enum iavf_status iavf_aq_set_rss_lut(struct iavf_hw *hw, u16 seid, 81 bool pf_lut, u8 *lut, u16 lut_size); 82enum iavf_status iavf_aq_get_rss_key(struct iavf_hw *hw, 83 u16 seid, 84 struct iavf_aqc_get_set_rss_key_data *key); 85enum iavf_status iavf_aq_set_rss_key(struct iavf_hw *hw, 86 u16 seid, 87 struct iavf_aqc_get_set_rss_key_data *key); 88const char *iavf_aq_str(struct iavf_hw *hw, enum iavf_admin_queue_err aq_err); 89const char *iavf_stat_str(struct iavf_hw *hw, enum iavf_status stat_err); 90 91enum iavf_status iavf_set_mac_type(struct iavf_hw *hw); 92 93extern struct iavf_rx_ptype_decoded iavf_ptype_lookup[]; 94 95STATIC INLINE struct iavf_rx_ptype_decoded decode_rx_desc_ptype(u8 ptype) 96{ 97 return iavf_ptype_lookup[ptype]; 98} 99 100/* prototype for functions used for SW spinlocks */ 101void iavf_init_spinlock(struct iavf_spinlock *sp); 102void iavf_acquire_spinlock(struct iavf_spinlock *sp); 103void iavf_release_spinlock(struct iavf_spinlock *sp); 104void iavf_destroy_spinlock(struct iavf_spinlock *sp); 105 106void iavf_vf_parse_hw_config(struct iavf_hw *hw, 107 struct virtchnl_vf_resource *msg); 108enum iavf_status iavf_vf_reset(struct iavf_hw *hw); 109enum iavf_status iavf_aq_send_msg_to_pf(struct iavf_hw *hw, 110 enum virtchnl_ops v_opcode, 111 enum iavf_status v_retval, 112 u8 *msg, u16 msglen, 113 struct iavf_asq_cmd_details *cmd_details); 114enum iavf_status iavf_aq_debug_dump(struct iavf_hw *hw, u8 cluster_id, 115 u8 table_id, u32 start_index, u16 buff_size, 116 void *buff, u16 *ret_buff_size, 117 u8 *ret_next_table, u32 *ret_next_index, 118 struct iavf_asq_cmd_details *cmd_details); 119enum iavf_status iavf_aq_clear_all_wol_filters(struct iavf_hw *hw, 120 struct iavf_asq_cmd_details *cmd_details); 121#endif /* _IAVF_PROTOTYPE_H_ */ 122