xref: /freebsd/sys/dev/ixl/ixl_pf.h (revision 61ae650d55553d48c55fbe023706dfa4b97483bb)
1*61ae650dSJack F Vogel /******************************************************************************
2*61ae650dSJack F Vogel 
3*61ae650dSJack F Vogel   Copyright (c) 2013-2014, Intel Corporation
4*61ae650dSJack F Vogel   All rights reserved.
5*61ae650dSJack F Vogel 
6*61ae650dSJack F Vogel   Redistribution and use in source and binary forms, with or without
7*61ae650dSJack F Vogel   modification, are permitted provided that the following conditions are met:
8*61ae650dSJack F Vogel 
9*61ae650dSJack F Vogel    1. Redistributions of source code must retain the above copyright notice,
10*61ae650dSJack F Vogel       this list of conditions and the following disclaimer.
11*61ae650dSJack F Vogel 
12*61ae650dSJack F Vogel    2. Redistributions in binary form must reproduce the above copyright
13*61ae650dSJack F Vogel       notice, this list of conditions and the following disclaimer in the
14*61ae650dSJack F Vogel       documentation and/or other materials provided with the distribution.
15*61ae650dSJack F Vogel 
16*61ae650dSJack F Vogel    3. Neither the name of the Intel Corporation nor the names of its
17*61ae650dSJack F Vogel       contributors may be used to endorse or promote products derived from
18*61ae650dSJack F Vogel       this software without specific prior written permission.
19*61ae650dSJack F Vogel 
20*61ae650dSJack F Vogel   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21*61ae650dSJack F Vogel   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22*61ae650dSJack F Vogel   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23*61ae650dSJack F Vogel   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24*61ae650dSJack F Vogel   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25*61ae650dSJack F Vogel   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26*61ae650dSJack F Vogel   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27*61ae650dSJack F Vogel   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28*61ae650dSJack F Vogel   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29*61ae650dSJack F Vogel   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30*61ae650dSJack F Vogel   POSSIBILITY OF SUCH DAMAGE.
31*61ae650dSJack F Vogel 
32*61ae650dSJack F Vogel ******************************************************************************/
33*61ae650dSJack F Vogel /*$FreeBSD$*/
34*61ae650dSJack F Vogel 
35*61ae650dSJack F Vogel 
36*61ae650dSJack F Vogel #ifndef _IXL_PF_H_
37*61ae650dSJack F Vogel #define _IXL_PF_H_
38*61ae650dSJack F Vogel 
39*61ae650dSJack F Vogel /* Physical controller structure */
40*61ae650dSJack F Vogel struct ixl_pf {
41*61ae650dSJack F Vogel 	struct i40e_hw		hw;
42*61ae650dSJack F Vogel 	struct i40e_osdep	osdep;
43*61ae650dSJack F Vogel 	struct device		*dev;
44*61ae650dSJack F Vogel 
45*61ae650dSJack F Vogel 	struct resource		*pci_mem;
46*61ae650dSJack F Vogel 	struct resource		*msix_mem;
47*61ae650dSJack F Vogel 
48*61ae650dSJack F Vogel 	/*
49*61ae650dSJack F Vogel 	 * Interrupt resources: this set is
50*61ae650dSJack F Vogel 	 * either used for legacy, or for Link
51*61ae650dSJack F Vogel 	 * when doing MSIX
52*61ae650dSJack F Vogel 	 */
53*61ae650dSJack F Vogel 	void			*tag;
54*61ae650dSJack F Vogel 	struct resource 	*res;
55*61ae650dSJack F Vogel 
56*61ae650dSJack F Vogel 	struct callout		timer;
57*61ae650dSJack F Vogel 	int			msix;
58*61ae650dSJack F Vogel 	int			if_flags;
59*61ae650dSJack F Vogel 
60*61ae650dSJack F Vogel 	struct mtx		pf_mtx;
61*61ae650dSJack F Vogel 
62*61ae650dSJack F Vogel 	u32			qbase;
63*61ae650dSJack F Vogel 	u32 			admvec;
64*61ae650dSJack F Vogel 	struct task     	adminq;
65*61ae650dSJack F Vogel 	struct taskqueue	*tq;
66*61ae650dSJack F Vogel 
67*61ae650dSJack F Vogel 	int			advertised_speed;
68*61ae650dSJack F Vogel 
69*61ae650dSJack F Vogel 	/*
70*61ae650dSJack F Vogel 	** VSI - Stations:
71*61ae650dSJack F Vogel 	**   These are the traffic class holders, and
72*61ae650dSJack F Vogel 	**   will have a stack interface and queues
73*61ae650dSJack F Vogel 	**   associated with them.
74*61ae650dSJack F Vogel 	** NOTE: for now using just one, so embed it.
75*61ae650dSJack F Vogel 	*/
76*61ae650dSJack F Vogel 	struct ixl_vsi		vsi;
77*61ae650dSJack F Vogel 
78*61ae650dSJack F Vogel 	/* Misc stats maintained by the driver */
79*61ae650dSJack F Vogel 	u64			watchdog_events;
80*61ae650dSJack F Vogel 	u64			admin_irq;
81*61ae650dSJack F Vogel 
82*61ae650dSJack F Vogel 	/* Statistics from hw */
83*61ae650dSJack F Vogel 	struct i40e_hw_port_stats 	stats;
84*61ae650dSJack F Vogel 	struct i40e_hw_port_stats	stats_offsets;
85*61ae650dSJack F Vogel 	bool 				stat_offsets_loaded;
86*61ae650dSJack F Vogel };
87*61ae650dSJack F Vogel 
88*61ae650dSJack F Vogel 
89*61ae650dSJack F Vogel #define IXL_PF_LOCK_INIT(_sc, _name) \
90*61ae650dSJack F Vogel         mtx_init(&(_sc)->pf_mtx, _name, "IXL PF Lock", MTX_DEF)
91*61ae650dSJack F Vogel #define IXL_PF_LOCK(_sc)              mtx_lock(&(_sc)->pf_mtx)
92*61ae650dSJack F Vogel #define IXL_PF_UNLOCK(_sc)            mtx_unlock(&(_sc)->pf_mtx)
93*61ae650dSJack F Vogel #define IXL_PF_LOCK_DESTROY(_sc)      mtx_destroy(&(_sc)->pf_mtx)
94*61ae650dSJack F Vogel #define IXL_PF_LOCK_ASSERT(_sc)       mtx_assert(&(_sc)->pf_mtx, MA_OWNED)
95*61ae650dSJack F Vogel 
96*61ae650dSJack F Vogel #endif /* _IXL_PF_H_ */
97