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