]> CyberLeo.Net >> Repos - FreeBSD/releng/10.3.git/blob - sys/dev/ixl/ixlv.h
- Copy stable/10@296371 to releng/10.3 in preparation for 10.3-RC1
[FreeBSD/releng/10.3.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         1000
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)
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
59 /* printf %b arg */
60 #define IXLV_FLAGS \
61     "\20\1ENABLE_QUEUES\2DISABLE_QUEUES\3ADD_MAC_FILTER" \
62     "\4ADD_VLAN_FILTER\5DEL_MAC_FILTER\6DEL_VLAN_FILTER" \
63     "\7CONFIGURE_QUEUES\10MAP_VECTORS\11HANDLE_RESET" \
64     "\12CONFIGURE_PROMISC\13GET_STATS"
65
66 /* Hack for compatibility with 1.0.x linux pf driver */
67 #define I40E_VIRTCHNL_OP_EVENT 17
68
69 /* Driver state */
70 enum ixlv_state_t {
71         IXLV_START,
72         IXLV_FAILED,
73         IXLV_RESET_REQUIRED,
74         IXLV_RESET_PENDING,
75         IXLV_VERSION_CHECK,
76         IXLV_GET_RESOURCES,
77         IXLV_INIT_READY,
78         IXLV_INIT_START,
79         IXLV_INIT_CONFIG,
80         IXLV_INIT_MAPPING,
81         IXLV_INIT_ENABLE,
82         IXLV_INIT_COMPLETE,
83         IXLV_RUNNING,   
84 };
85
86 struct ixlv_mac_filter {
87         SLIST_ENTRY(ixlv_mac_filter)  next;
88         u8      macaddr[ETHER_ADDR_LEN];
89         u16     flags;
90 };
91 SLIST_HEAD(mac_list, ixlv_mac_filter);
92
93 struct ixlv_vlan_filter {
94         SLIST_ENTRY(ixlv_vlan_filter)  next;
95         u16     vlan;
96         u16     flags;
97 };
98 SLIST_HEAD(vlan_list, ixlv_vlan_filter);
99
100 /* Software controller structure */
101 struct ixlv_sc {
102         struct i40e_hw          hw;
103         struct i40e_osdep       osdep;
104         struct device           *dev;
105
106         struct resource         *pci_mem;
107         struct resource         *msix_mem;
108
109         enum ixlv_state_t       init_state;
110
111         /*
112          * Interrupt resources
113          */
114         void                    *tag;
115         struct resource         *res; /* For the AQ */
116
117         struct ifmedia          media;
118         struct callout          timer;
119         int                     msix;
120         int                     pf_version;
121         int                     if_flags;
122
123         bool                    link_up;
124         u32                     link_speed;
125
126         struct mtx              mtx;
127
128         u32                     qbase;
129         u32                     admvec;
130         struct timeout_task     timeout;
131         struct task             aq_irq;
132         struct task             aq_sched;
133         struct taskqueue        *tq;
134
135         struct ixl_vsi          vsi;
136
137         /* Filter lists */
138         struct mac_list         *mac_filters;
139         struct vlan_list        *vlan_filters;
140
141         /* Promiscuous mode */
142         u32                     promiscuous_flags;
143
144         /* Admin queue task flags */
145         u32                     aq_wait_count;
146
147         struct ixl_vc_mgr       vc_mgr;
148         struct ixl_vc_cmd       add_mac_cmd;
149         struct ixl_vc_cmd       del_mac_cmd;
150         struct ixl_vc_cmd       config_queues_cmd;
151         struct ixl_vc_cmd       map_vectors_cmd;
152         struct ixl_vc_cmd       enable_queues_cmd;
153         struct ixl_vc_cmd       add_vlan_cmd;
154         struct ixl_vc_cmd       del_vlan_cmd;
155         struct ixl_vc_cmd       add_multi_cmd;
156         struct ixl_vc_cmd       del_multi_cmd;
157
158         /* Virtual comm channel */
159         struct i40e_virtchnl_vf_resource *vf_res;
160         struct i40e_virtchnl_vsi_resource *vsi_res;
161
162         /* Misc stats maintained by the driver */
163         u64                     watchdog_events;
164         u64                     admin_irq;
165
166         u8                      aq_buffer[IXL_AQ_BUF_SZ];
167 };
168
169 #define IXLV_CORE_LOCK_ASSERT(sc)       mtx_assert(&(sc)->mtx, MA_OWNED)
170 /*
171 ** This checks for a zero mac addr, something that will be likely
172 ** unless the Admin on the Host has created one.
173 */
174 static inline bool
175 ixlv_check_ether_addr(u8 *addr)
176 {
177         bool status = TRUE;
178
179         if ((addr[0] == 0 && addr[1]== 0 && addr[2] == 0 &&
180             addr[3] == 0 && addr[4]== 0 && addr[5] == 0))
181                 status = FALSE;
182         return (status);
183 }
184
185 /*
186 ** VF Common function prototypes
187 */
188 int     ixlv_send_api_ver(struct ixlv_sc *);
189 int     ixlv_verify_api_ver(struct ixlv_sc *);
190 int     ixlv_send_vf_config_msg(struct ixlv_sc *);
191 int     ixlv_get_vf_config(struct ixlv_sc *);
192 void    ixlv_init(void *);
193 int     ixlv_reinit_locked(struct ixlv_sc *);
194 void    ixlv_configure_queues(struct ixlv_sc *);
195 void    ixlv_enable_queues(struct ixlv_sc *);
196 void    ixlv_disable_queues(struct ixlv_sc *);
197 void    ixlv_map_queues(struct ixlv_sc *);
198 void    ixlv_enable_intr(struct ixl_vsi *);
199 void    ixlv_disable_intr(struct ixl_vsi *);
200 void    ixlv_add_ether_filters(struct ixlv_sc *);
201 void    ixlv_del_ether_filters(struct ixlv_sc *);
202 void    ixlv_request_stats(struct ixlv_sc *);
203 void    ixlv_request_reset(struct ixlv_sc *);
204 void    ixlv_vc_completion(struct ixlv_sc *,
205         enum i40e_virtchnl_ops, i40e_status, u8 *, u16);
206 void    ixlv_add_ether_filter(struct ixlv_sc *);
207 void    ixlv_add_vlans(struct ixlv_sc *);
208 void    ixlv_del_vlans(struct ixlv_sc *);
209 void    ixlv_update_stats_counters(struct ixlv_sc *,
210                     struct i40e_eth_stats *);
211 void    ixlv_update_link_status(struct ixlv_sc *);
212
213 #endif /* _IXLV_H_ */