]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/ixl/ixlv.h
MFV: r313101
[FreeBSD/FreeBSD.git] / sys / dev / ixl / ixlv.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 /*$FreeBSD$*/
34
35
36 #ifndef _IXLV_H_
37 #define _IXLV_H_
38
39 #include "ixlv_vc_mgr.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 #define IXLV_CALLOUT_TIMO       (hz / 50)       /* 20 msec */
46
47 #define IXLV_FLAG_AQ_ENABLE_QUEUES            (u32)(1 << 0)
48 #define IXLV_FLAG_AQ_DISABLE_QUEUES           (u32)(1 << 1)
49 #define IXLV_FLAG_AQ_ADD_MAC_FILTER           (u32)(1 << 2)
50 #define IXLV_FLAG_AQ_ADD_VLAN_FILTER          (u32)(1 << 3)
51 #define IXLV_FLAG_AQ_DEL_MAC_FILTER           (u32)(1 << 4)
52 #define IXLV_FLAG_AQ_DEL_VLAN_FILTER          (u32)(1 << 5)
53 #define IXLV_FLAG_AQ_CONFIGURE_QUEUES         (u32)(1 << 6)
54 #define IXLV_FLAG_AQ_MAP_VECTORS              (u32)(1 << 7)
55 #define IXLV_FLAG_AQ_HANDLE_RESET             (u32)(1 << 8)
56 #define IXLV_FLAG_AQ_CONFIGURE_PROMISC        (u32)(1 << 9)
57 #define IXLV_FLAG_AQ_GET_STATS                (u32)(1 << 10)
58 #define IXLV_FLAG_AQ_CONFIG_RSS_KEY           (u32)(1 << 11)
59 #define IXLV_FLAG_AQ_SET_RSS_HENA             (u32)(1 << 12)
60 #define IXLV_FLAG_AQ_GET_RSS_HENA_CAPS        (u32)(1 << 13)
61 #define IXLV_FLAG_AQ_CONFIG_RSS_LUT          (u32)(1 << 14)
62
63 /* printf %b arg */
64 #define IXLV_FLAGS \
65     "\20\1ENABLE_QUEUES\2DISABLE_QUEUES\3ADD_MAC_FILTER" \
66     "\4ADD_VLAN_FILTER\5DEL_MAC_FILTER\6DEL_VLAN_FILTER" \
67     "\7CONFIGURE_QUEUES\10MAP_VECTORS\11HANDLE_RESET" \
68     "\12CONFIGURE_PROMISC\13GET_STATS"
69 #define IXLV_PRINTF_VF_OFFLOAD_FLAGS \
70     "\20\1I40E_VIRTCHNL_VF_OFFLOAD_L2" \
71     "\2I40E_VIRTCHNL_VF_OFFLOAD_IWARP" \
72     "\3I40E_VIRTCHNL_VF_OFFLOAD_FCOE" \
73     "\4I40E_VIRTCHNL_VF_OFFLOAD_RSS_AQ" \
74     "\5I40E_VIRTCHNL_VF_OFFLOAD_RSS_REG" \
75     "\6I40E_VIRTCHNL_VF_OFFLOAD_WB_ON_ITR" \
76     "\21I40E_VIRTCHNL_VF_OFFLOAD_VLAN" \
77     "\22I40E_VIRTCHNL_VF_OFFLOAD_RX_POLLING" \
78     "\23I40E_VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2" \
79     "\24I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF"
80
81 /* Driver state */
82 enum ixlv_state_t {
83         IXLV_START,
84         IXLV_FAILED,
85         IXLV_RESET_REQUIRED,
86         IXLV_RESET_PENDING,
87         IXLV_VERSION_CHECK,
88         IXLV_GET_RESOURCES,
89         IXLV_INIT_READY,
90         IXLV_INIT_START,
91         IXLV_INIT_CONFIG,
92         IXLV_INIT_MAPPING,
93         IXLV_INIT_ENABLE,
94         IXLV_INIT_COMPLETE,
95         IXLV_RUNNING,
96 };
97
98 /* Structs */
99
100 struct ixlv_mac_filter {
101         SLIST_ENTRY(ixlv_mac_filter)  next;
102         u8      macaddr[ETHER_ADDR_LEN];
103         u16     flags;
104 };
105 SLIST_HEAD(mac_list, ixlv_mac_filter);
106
107 struct ixlv_vlan_filter {
108         SLIST_ENTRY(ixlv_vlan_filter)  next;
109         u16     vlan;
110         u16     flags;
111 };
112 SLIST_HEAD(vlan_list, ixlv_vlan_filter);
113
114 /* Software controller structure */
115 struct ixlv_sc {
116         struct i40e_hw          hw;
117         struct i40e_osdep       osdep;
118         device_t                dev;
119
120         struct resource         *pci_mem;
121         struct resource         *msix_mem;
122
123         enum ixlv_state_t       init_state;
124         int                     init_in_progress;
125
126         /*
127          * Interrupt resources
128          */
129         void                    *tag;
130         struct resource         *res; /* For the AQ */
131
132         struct ifmedia          media;
133         struct callout          timer;
134         int                     msix;
135         int                     pf_version;
136         int                     if_flags;
137
138         bool                    link_up;
139         u32                     link_speed;
140
141         struct mtx              mtx;
142
143         u32                     qbase;
144         u32                     admvec;
145         struct timeout_task     timeout;
146         struct task             aq_irq;
147         struct task             aq_sched;
148         struct taskqueue        *tq;
149
150         struct ixl_vsi          vsi;
151
152         /* Filter lists */
153         struct mac_list         *mac_filters;
154         struct vlan_list        *vlan_filters;
155
156         /* Promiscuous mode */
157         u32                     promiscuous_flags;
158
159         /* Admin queue task flags */
160         u32                     aq_wait_count;
161
162         struct ixl_vc_mgr       vc_mgr;
163         struct ixl_vc_cmd       add_mac_cmd;
164         struct ixl_vc_cmd       del_mac_cmd;
165         struct ixl_vc_cmd       config_queues_cmd;
166         struct ixl_vc_cmd       map_vectors_cmd;
167         struct ixl_vc_cmd       enable_queues_cmd;
168         struct ixl_vc_cmd       add_vlan_cmd;
169         struct ixl_vc_cmd       del_vlan_cmd;
170         struct ixl_vc_cmd       add_multi_cmd;
171         struct ixl_vc_cmd       del_multi_cmd;
172         struct ixl_vc_cmd       config_rss_key_cmd;
173         struct ixl_vc_cmd       get_rss_hena_caps_cmd;
174         struct ixl_vc_cmd       set_rss_hena_cmd;
175         struct ixl_vc_cmd       config_rss_lut_cmd;
176
177         /* Virtual comm channel */
178         struct i40e_virtchnl_vf_resource *vf_res;
179         struct i40e_virtchnl_vsi_resource *vsi_res;
180
181         /* Misc stats maintained by the driver */
182         u64                     watchdog_events;
183         u64                     admin_irq;
184
185         u8                      aq_buffer[IXL_AQ_BUF_SZ];
186 };
187
188 #define IXLV_CORE_LOCK_ASSERT(sc)       mtx_assert(&(sc)->mtx, MA_OWNED)
189 /*
190 ** This checks for a zero mac addr, something that will be likely
191 ** unless the Admin on the Host has created one.
192 */
193 static inline bool
194 ixlv_check_ether_addr(u8 *addr)
195 {
196         bool status = TRUE;
197
198         if ((addr[0] == 0 && addr[1]== 0 && addr[2] == 0 &&
199             addr[3] == 0 && addr[4]== 0 && addr[5] == 0))
200                 status = FALSE;
201         return (status);
202 }
203
204 /*
205 ** VF Common function prototypes
206 */
207 int     ixlv_send_api_ver(struct ixlv_sc *);
208 int     ixlv_verify_api_ver(struct ixlv_sc *);
209 int     ixlv_send_vf_config_msg(struct ixlv_sc *);
210 int     ixlv_get_vf_config(struct ixlv_sc *);
211 void    ixlv_init(void *);
212 int     ixlv_reinit_locked(struct ixlv_sc *);
213 void    ixlv_configure_queues(struct ixlv_sc *);
214 void    ixlv_enable_queues(struct ixlv_sc *);
215 void    ixlv_disable_queues(struct ixlv_sc *);
216 void    ixlv_map_queues(struct ixlv_sc *);
217 void    ixlv_enable_intr(struct ixl_vsi *);
218 void    ixlv_disable_intr(struct ixl_vsi *);
219 void    ixlv_add_ether_filters(struct ixlv_sc *);
220 void    ixlv_del_ether_filters(struct ixlv_sc *);
221 void    ixlv_request_stats(struct ixlv_sc *);
222 void    ixlv_request_reset(struct ixlv_sc *);
223 void    ixlv_vc_completion(struct ixlv_sc *,
224         enum i40e_virtchnl_ops, i40e_status, u8 *, u16);
225 void    ixlv_add_ether_filter(struct ixlv_sc *);
226 void    ixlv_add_vlans(struct ixlv_sc *);
227 void    ixlv_del_vlans(struct ixlv_sc *);
228 void    ixlv_update_stats_counters(struct ixlv_sc *,
229                     struct i40e_eth_stats *);
230 void    ixlv_update_link_status(struct ixlv_sc *);
231 void    ixlv_get_default_rss_key(u32 *, bool);
232 void    ixlv_config_rss_key(struct ixlv_sc *);
233 void    ixlv_set_rss_hena(struct ixlv_sc *);
234 void    ixlv_config_rss_lut(struct ixlv_sc *);
235
236 #endif /* _IXLV_H_ */