New upstream version 18.02
[deb_dpdk.git] / drivers / net / avf / base / avf_prototype.h
1 /*******************************************************************************
2
3 Copyright (c) 2013 - 2015, Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8
9  1. Redistributions of source code must retain the above copyright notice,
10     this list of conditions and the following disclaimer.
11
12  2. Redistributions in binary form must reproduce the above copyright
13     notice, this list of conditions and the following disclaimer in the
14     documentation and/or other materials provided with the distribution.
15
16  3. Neither the name of the Intel Corporation nor the names of its
17     contributors may be used to endorse or promote products derived from
18     this software without specific prior written permission.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32 ***************************************************************************/
33
34 #ifndef _AVF_PROTOTYPE_H_
35 #define _AVF_PROTOTYPE_H_
36
37 #include "avf_type.h"
38 #include "avf_alloc.h"
39 #include "virtchnl.h"
40
41 /* Prototypes for shared code functions that are not in
42  * the standard function pointer structures.  These are
43  * mostly because they are needed even before the init
44  * has happened and will assist in the early SW and FW
45  * setup.
46  */
47
48 /* adminq functions */
49 enum avf_status_code avf_init_adminq(struct avf_hw *hw);
50 enum avf_status_code avf_shutdown_adminq(struct avf_hw *hw);
51 enum avf_status_code avf_init_asq(struct avf_hw *hw);
52 enum avf_status_code avf_init_arq(struct avf_hw *hw);
53 enum avf_status_code avf_alloc_adminq_asq_ring(struct avf_hw *hw);
54 enum avf_status_code avf_alloc_adminq_arq_ring(struct avf_hw *hw);
55 enum avf_status_code avf_shutdown_asq(struct avf_hw *hw);
56 enum avf_status_code avf_shutdown_arq(struct avf_hw *hw);
57 u16 avf_clean_asq(struct avf_hw *hw);
58 void avf_free_adminq_asq(struct avf_hw *hw);
59 void avf_free_adminq_arq(struct avf_hw *hw);
60 enum avf_status_code avf_validate_mac_addr(u8 *mac_addr);
61 void avf_adminq_init_ring_data(struct avf_hw *hw);
62 enum avf_status_code avf_clean_arq_element(struct avf_hw *hw,
63                                              struct avf_arq_event_info *e,
64                                              u16 *events_pending);
65 enum avf_status_code avf_asq_send_command(struct avf_hw *hw,
66                                 struct avf_aq_desc *desc,
67                                 void *buff, /* can be NULL */
68                                 u16  buff_size,
69                                 struct avf_asq_cmd_details *cmd_details);
70 bool avf_asq_done(struct avf_hw *hw);
71
72 /* debug function for adminq */
73 void avf_debug_aq(struct avf_hw *hw, enum avf_debug_mask mask,
74                    void *desc, void *buffer, u16 buf_len);
75
76 void avf_idle_aq(struct avf_hw *hw);
77 bool avf_check_asq_alive(struct avf_hw *hw);
78 enum avf_status_code avf_aq_queue_shutdown(struct avf_hw *hw, bool unloading);
79
80 enum avf_status_code avf_aq_get_rss_lut(struct avf_hw *hw, u16 seid,
81                                           bool pf_lut, u8 *lut, u16 lut_size);
82 enum avf_status_code avf_aq_set_rss_lut(struct avf_hw *hw, u16 seid,
83                                           bool pf_lut, u8 *lut, u16 lut_size);
84 enum avf_status_code avf_aq_get_rss_key(struct avf_hw *hw,
85                                      u16 seid,
86                                      struct avf_aqc_get_set_rss_key_data *key);
87 enum avf_status_code avf_aq_set_rss_key(struct avf_hw *hw,
88                                      u16 seid,
89                                      struct avf_aqc_get_set_rss_key_data *key);
90 const char *avf_aq_str(struct avf_hw *hw, enum avf_admin_queue_err aq_err);
91 const char *avf_stat_str(struct avf_hw *hw, enum avf_status_code stat_err);
92
93
94 enum avf_status_code avf_set_mac_type(struct avf_hw *hw);
95
96 extern struct avf_rx_ptype_decoded avf_ptype_lookup[];
97
98 STATIC INLINE struct avf_rx_ptype_decoded decode_rx_desc_ptype(u8 ptype)
99 {
100         return avf_ptype_lookup[ptype];
101 }
102
103 /* prototype for functions used for SW spinlocks */
104 void avf_init_spinlock(struct avf_spinlock *sp);
105 void avf_acquire_spinlock(struct avf_spinlock *sp);
106 void avf_release_spinlock(struct avf_spinlock *sp);
107 void avf_destroy_spinlock(struct avf_spinlock *sp);
108
109 /* avf_common for VF drivers*/
110 void avf_parse_hw_config(struct avf_hw *hw,
111                              struct virtchnl_vf_resource *msg);
112 enum avf_status_code avf_reset(struct avf_hw *hw);
113 enum avf_status_code avf_aq_send_msg_to_pf(struct avf_hw *hw,
114                                 enum virtchnl_ops v_opcode,
115                                 enum avf_status_code v_retval,
116                                 u8 *msg, u16 msglen,
117                                 struct avf_asq_cmd_details *cmd_details);
118 enum avf_status_code avf_set_filter_control(struct avf_hw *hw,
119                                 struct avf_filter_control_settings *settings);
120 enum avf_status_code avf_aq_add_rem_control_packet_filter(struct avf_hw *hw,
121                                 u8 *mac_addr, u16 ethtype, u16 flags,
122                                 u16 vsi_seid, u16 queue, bool is_add,
123                                 struct avf_control_filter_stats *stats,
124                                 struct avf_asq_cmd_details *cmd_details);
125 enum avf_status_code avf_aq_debug_dump(struct avf_hw *hw, u8 cluster_id,
126                                 u8 table_id, u32 start_index, u16 buff_size,
127                                 void *buff, u16 *ret_buff_size,
128                                 u8 *ret_next_table, u32 *ret_next_index,
129                                 struct avf_asq_cmd_details *cmd_details);
130 void avf_add_filter_to_drop_tx_flow_control_frames(struct avf_hw *hw,
131                                                     u16 vsi_seid);
132 enum avf_status_code avf_aq_rx_ctl_read_register(struct avf_hw *hw,
133                                 u32 reg_addr, u32 *reg_val,
134                                 struct avf_asq_cmd_details *cmd_details);
135 u32 avf_read_rx_ctl(struct avf_hw *hw, u32 reg_addr);
136 enum avf_status_code avf_aq_rx_ctl_write_register(struct avf_hw *hw,
137                                 u32 reg_addr, u32 reg_val,
138                                 struct avf_asq_cmd_details *cmd_details);
139 void avf_write_rx_ctl(struct avf_hw *hw, u32 reg_addr, u32 reg_val);
140 enum avf_status_code avf_aq_set_phy_register(struct avf_hw *hw,
141                                 u8 phy_select, u8 dev_addr,
142                                 u32 reg_addr, u32 reg_val,
143                                 struct avf_asq_cmd_details *cmd_details);
144 enum avf_status_code avf_aq_get_phy_register(struct avf_hw *hw,
145                                 u8 phy_select, u8 dev_addr,
146                                 u32 reg_addr, u32 *reg_val,
147                                 struct avf_asq_cmd_details *cmd_details);
148
149 enum avf_status_code avf_aq_set_arp_proxy_config(struct avf_hw *hw,
150                         struct avf_aqc_arp_proxy_data *proxy_config,
151                         struct avf_asq_cmd_details *cmd_details);
152 enum avf_status_code avf_aq_set_ns_proxy_table_entry(struct avf_hw *hw,
153                         struct avf_aqc_ns_proxy_data *ns_proxy_table_entry,
154                         struct avf_asq_cmd_details *cmd_details);
155 enum avf_status_code avf_aq_set_clear_wol_filter(struct avf_hw *hw,
156                         u8 filter_index,
157                         struct avf_aqc_set_wol_filter_data *filter,
158                         bool set_filter, bool no_wol_tco,
159                         bool filter_valid, bool no_wol_tco_valid,
160                         struct avf_asq_cmd_details *cmd_details);
161 enum avf_status_code avf_aq_get_wake_event_reason(struct avf_hw *hw,
162                         u16 *wake_reason,
163                         struct avf_asq_cmd_details *cmd_details);
164 enum avf_status_code avf_aq_clear_all_wol_filters(struct avf_hw *hw,
165                         struct avf_asq_cmd_details *cmd_details);
166 enum avf_status_code avf_read_phy_register_clause22(struct avf_hw *hw,
167                                         u16 reg, u8 phy_addr, u16 *value);
168 enum avf_status_code avf_write_phy_register_clause22(struct avf_hw *hw,
169                                         u16 reg, u8 phy_addr, u16 value);
170 enum avf_status_code avf_read_phy_register_clause45(struct avf_hw *hw,
171                                 u8 page, u16 reg, u8 phy_addr, u16 *value);
172 enum avf_status_code avf_write_phy_register_clause45(struct avf_hw *hw,
173                                 u8 page, u16 reg, u8 phy_addr, u16 value);
174 enum avf_status_code avf_read_phy_register(struct avf_hw *hw,
175                                 u8 page, u16 reg, u8 phy_addr, u16 *value);
176 enum avf_status_code avf_write_phy_register(struct avf_hw *hw,
177                                 u8 page, u16 reg, u8 phy_addr, u16 value);
178 u8 avf_get_phy_address(struct avf_hw *hw, u8 dev_num);
179 enum avf_status_code avf_blink_phy_link_led(struct avf_hw *hw,
180                                               u32 time, u32 interval);
181 enum avf_status_code avf_aq_write_ddp(struct avf_hw *hw, void *buff,
182                                         u16 buff_size, u32 track_id,
183                                         u32 *error_offset, u32 *error_info,
184                                         struct avf_asq_cmd_details *
185                                         cmd_details);
186 enum avf_status_code avf_aq_get_ddp_list(struct avf_hw *hw, void *buff,
187                                            u16 buff_size, u8 flags,
188                                            struct avf_asq_cmd_details *
189                                            cmd_details);
190 struct avf_generic_seg_header *
191 avf_find_segment_in_package(u32 segment_type,
192                              struct avf_package_header *pkg_header);
193 struct avf_profile_section_header *
194 avf_find_section_in_profile(u32 section_type,
195                              struct avf_profile_segment *profile);
196 enum avf_status_code
197 avf_write_profile(struct avf_hw *hw, struct avf_profile_segment *avf_seg,
198                    u32 track_id);
199 enum avf_status_code
200 avf_rollback_profile(struct avf_hw *hw, struct avf_profile_segment *avf_seg,
201                       u32 track_id);
202 enum avf_status_code
203 avf_add_pinfo_to_list(struct avf_hw *hw,
204                        struct avf_profile_segment *profile,
205                        u8 *profile_info_sec, u32 track_id);
206 #endif /* _AVF_PROTOTYPE_H_ */