]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/ixl/ixlv.h
Remove stale libcasper(3) shared libraries following the
[FreeBSD/FreeBSD.git] / sys / dev / ixl / ixlv.h
1 /******************************************************************************
2
3   Copyright (c) 2013-2018, 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 /*$FreeBSD$*/
34
35
36 #ifndef _IXLV_H_
37 #define _IXLV_H_
38
39 #include "ixl.h"
40
41 #define IXLV_AQ_MAX_ERR         200
42 #define IXLV_MAX_FILTERS        128
43 #define IXLV_MAX_QUEUES         16
44 #define IXLV_AQ_TIMEOUT         (1 * hz)
45
46 #define IXLV_FLAG_AQ_ENABLE_QUEUES            (u32)(1 << 0)
47 #define IXLV_FLAG_AQ_DISABLE_QUEUES           (u32)(1 << 1)
48 #define IXLV_FLAG_AQ_ADD_MAC_FILTER           (u32)(1 << 2)
49 #define IXLV_FLAG_AQ_ADD_VLAN_FILTER          (u32)(1 << 3)
50 #define IXLV_FLAG_AQ_DEL_MAC_FILTER           (u32)(1 << 4)
51 #define IXLV_FLAG_AQ_DEL_VLAN_FILTER          (u32)(1 << 5)
52 #define IXLV_FLAG_AQ_CONFIGURE_QUEUES         (u32)(1 << 6)
53 #define IXLV_FLAG_AQ_MAP_VECTORS              (u32)(1 << 7)
54 #define IXLV_FLAG_AQ_HANDLE_RESET             (u32)(1 << 8)
55 #define IXLV_FLAG_AQ_CONFIGURE_PROMISC        (u32)(1 << 9)
56 #define IXLV_FLAG_AQ_GET_STATS                (u32)(1 << 10)
57 #define IXLV_FLAG_AQ_CONFIG_RSS_KEY           (u32)(1 << 11)
58 #define IXLV_FLAG_AQ_SET_RSS_HENA             (u32)(1 << 12)
59 #define IXLV_FLAG_AQ_GET_RSS_HENA_CAPS        (u32)(1 << 13)
60 #define IXLV_FLAG_AQ_CONFIG_RSS_LUT           (u32)(1 << 14)
61
62 /* printf %b flag args */
63 #define IXLV_FLAGS \
64     "\20\1ENABLE_QUEUES\2DISABLE_QUEUES\3ADD_MAC_FILTER" \
65     "\4ADD_VLAN_FILTER\5DEL_MAC_FILTER\6DEL_VLAN_FILTER" \
66     "\7CONFIGURE_QUEUES\10MAP_VECTORS\11HANDLE_RESET" \
67     "\12CONFIGURE_PROMISC\13GET_STATS\14CONFIG_RSS_KEY" \
68     "\15SET_RSS_HENA\16GET_RSS_HENA_CAPS\17CONFIG_RSS_LUT"
69 #define IXLV_PRINTF_VF_OFFLOAD_FLAGS \
70     "\20\1L2" \
71     "\2IWARP" \
72     "\3RSVD" \
73     "\4RSS_AQ" \
74     "\5RSS_REG" \
75     "\6WB_ON_ITR" \
76     "\7REQ_QUEUES" \
77     "\21VLAN" \
78     "\22RX_POLLING" \
79     "\23RSS_PCTYPE_V2" \
80     "\24RSS_PF" \
81     "\25ENCAP" \
82     "\26ENCAP_CSUM" \
83     "\27RX_ENCAP_CSUM"
84
85 MALLOC_DECLARE(M_IXLV);
86
87 /* Driver state */
88 enum ixlv_state_t {
89         IXLV_RESET_REQUIRED,
90         IXLV_RESET_PENDING,
91         IXLV_INIT_READY,
92         IXLV_RUNNING,
93 };
94
95 /* Structs */
96
97 struct ixlv_mac_filter {
98         SLIST_ENTRY(ixlv_mac_filter)  next;
99         u8      macaddr[ETHER_ADDR_LEN];
100         u16     flags;
101 };
102 SLIST_HEAD(mac_list, ixlv_mac_filter);
103
104 struct ixlv_vlan_filter {
105         SLIST_ENTRY(ixlv_vlan_filter)  next;
106         u16     vlan;
107         u16     flags;
108 };
109 SLIST_HEAD(vlan_list, ixlv_vlan_filter);
110
111 /* Software controller structure */
112 struct ixlv_sc {
113         struct ixl_vsi          vsi;
114
115         struct i40e_hw          hw;
116         struct i40e_osdep       osdep;
117         device_t                dev;
118
119         struct resource         *pci_mem;
120
121         enum ixlv_state_t       init_state;
122
123         struct ifmedia          media;
124         struct virtchnl_version_info    version;
125         enum ixl_dbg_mask       dbg_mask;
126         u16                     promisc_flags;
127
128         bool                            link_up;
129         enum virtchnl_link_speed        link_speed;
130
131         /* Tunable settings */
132         int                     tx_itr;
133         int                     rx_itr;
134         int                     dynamic_tx_itr;
135         int                     dynamic_rx_itr;
136
137         /* Filter lists */
138         struct mac_list         *mac_filters;
139         struct vlan_list        *vlan_filters;
140
141         /* Virtual comm channel */
142         struct virtchnl_vf_resource *vf_res;
143         struct virtchnl_vsi_resource *vsi_res;
144
145         /* Misc stats maintained by the driver */
146         u64                     admin_irq;
147
148         /* Buffer used for reading AQ responses */
149         u8                      aq_buffer[IXL_AQ_BUF_SZ];
150
151         /* State flag used in init/stop */
152         u32                     queues_enabled;
153         u8                      enable_queues_chan;
154         u8                      disable_queues_chan;
155 };
156
157 /*
158 ** This checks for a zero mac addr, something that will be likely
159 ** unless the Admin on the Host has created one.
160 */
161 static inline bool
162 ixlv_check_ether_addr(u8 *addr)
163 {
164         bool status = TRUE;
165
166         if ((addr[0] == 0 && addr[1]== 0 && addr[2] == 0 &&
167             addr[3] == 0 && addr[4]== 0 && addr[5] == 0))
168                 status = FALSE;
169         return (status);
170 }
171
172 /* Debug printing */
173 #define ixlv_dbg(sc, m, s, ...)         ixl_debug_core(sc->dev, sc->dbg_mask, m, s, ##__VA_ARGS__)
174 #define ixlv_dbg_init(sc, s, ...)       ixl_debug_core(sc->dev, sc->dbg_mask, IXLV_DBG_INIT, s, ##__VA_ARGS__)
175 #define ixlv_dbg_info(sc, s, ...)       ixl_debug_core(sc->dev, sc->dbg_mask, IXLV_DBG_INFO, s, ##__VA_ARGS__)
176 #define ixlv_dbg_vc(sc, s, ...)         ixl_debug_core(sc->dev, sc->dbg_mask, IXLV_DBG_VC, s, ##__VA_ARGS__)
177 #define ixlv_dbg_filter(sc, s, ...)     ixl_debug_core(sc->dev, sc->dbg_mask, IXLV_DBG_FILTER, s, ##__VA_ARGS__)
178
179 /*
180 ** VF Common function prototypes
181 */
182 void    ixlv_if_init(if_ctx_t ctx);
183
184 int     ixlv_send_api_ver(struct ixlv_sc *);
185 int     ixlv_verify_api_ver(struct ixlv_sc *);
186 int     ixlv_send_vf_config_msg(struct ixlv_sc *);
187 int     ixlv_get_vf_config(struct ixlv_sc *);
188 void    ixlv_init(void *);
189 int     ixlv_reinit_locked(struct ixlv_sc *);
190 int     ixlv_configure_queues(struct ixlv_sc *);
191 int     ixlv_enable_queues(struct ixlv_sc *);
192 int     ixlv_disable_queues(struct ixlv_sc *);
193 int     ixlv_map_queues(struct ixlv_sc *);
194 void    ixlv_enable_intr(struct ixl_vsi *);
195 void    ixlv_disable_intr(struct ixl_vsi *);
196 int     ixlv_add_ether_filters(struct ixlv_sc *);
197 int     ixlv_del_ether_filters(struct ixlv_sc *);
198 int     ixlv_request_stats(struct ixlv_sc *);
199 int     ixlv_request_reset(struct ixlv_sc *);
200 void    ixlv_vc_completion(struct ixlv_sc *,
201         enum virtchnl_ops, enum virtchnl_status_code,
202         u8 *, u16);
203 int     ixlv_add_ether_filter(struct ixlv_sc *);
204 int     ixlv_add_vlans(struct ixlv_sc *);
205 int     ixlv_del_vlans(struct ixlv_sc *);
206 void    ixlv_update_stats_counters(struct ixlv_sc *,
207                     struct i40e_eth_stats *);
208 void    ixlv_update_link_status(struct ixlv_sc *);
209 int     ixlv_get_default_rss_key(u32 *, bool);
210 int     ixlv_config_rss_key(struct ixlv_sc *);
211 int     ixlv_set_rss_hena(struct ixlv_sc *);
212 int     ixlv_config_rss_lut(struct ixlv_sc *);
213 int     ixlv_config_promisc_mode(struct ixlv_sc *);
214
215 int     ixl_vc_send_cmd(struct ixlv_sc *sc, uint32_t request);
216 char    *ixlv_vc_speed_to_string(enum virtchnl_link_speed link_speed);
217 void    *ixl_vc_get_op_chan(struct ixlv_sc *sc, uint32_t request);
218 #endif /* _IXLV_H_ */