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 _IXL_PF_H_ 37 #define _IXL_PF_H_ 38 39 #define VF_FLAG_ENABLED 0x01 40 #define VF_FLAG_SET_MAC_CAP 0x02 41 #define VF_FLAG_VLAN_CAP 0x04 42 #define VF_FLAG_PROMISC_CAP 0x08 43 #define VF_FLAG_MAC_ANTI_SPOOF 0x10 44 45 struct ixl_vf { 46 struct ixl_vsi vsi; 47 uint32_t vf_flags; 48 49 uint8_t mac[ETHER_ADDR_LEN]; 50 uint16_t vf_num; 51 52 struct sysctl_ctx_list ctx; 53 }; 54 55 /* Physical controller structure */ 56 struct ixl_pf { 57 struct i40e_hw hw; 58 struct i40e_osdep osdep; 59 struct device *dev; 60 61 struct resource *pci_mem; 62 struct resource *msix_mem; 63 64 /* 65 * Interrupt resources: this set is 66 * either used for legacy, or for Link 67 * when doing MSIX 68 */ 69 void *tag; 70 struct resource *res; 71 72 struct callout timer; 73 int msix; 74 int if_flags; 75 76 struct mtx pf_mtx; 77 78 u32 qbase; 79 u32 admvec; 80 struct task adminq; 81 struct taskqueue *tq; 82 83 bool link_up; 84 u32 link_speed; 85 int advertised_speed; 86 int fc; /* local flow ctrl setting */ 87 88 /* 89 ** Network interfaces 90 ** These are the traffic class holders, and 91 ** will have a stack interface and queues 92 ** associated with them. 93 ** NOTE: The PF has only a single interface, 94 ** so it is embedded in the PF struct. 95 */ 96 struct ixl_vsi vsi; 97 98 /* Misc stats maintained by the driver */ 99 u64 watchdog_events; 100 u64 admin_irq; 101 102 /* Statistics from hw */ 103 struct i40e_hw_port_stats stats; 104 struct i40e_hw_port_stats stats_offsets; 105 bool stat_offsets_loaded; 106 107 struct ixl_vf *vfs; 108 int num_vfs; 109 uint16_t veb_seid; 110 struct task vflr_task; 111 int vc_debug_lvl; 112 }; 113 114 #define IXL_SET_ADVERTISE_HELP \ 115 "Control link advertise speed:\n" \ 116 "\tFlags:\n" \ 117 "\t\t0x1 - advertise 100 Mb\n" \ 118 "\t\t0x2 - advertise 1G\n" \ 119 "\t\t0x4 - advertise 10G\n" \ 120 "\t\t0x8 - advertise 20G\n\n" \ 121 "\tDoes not work on 40G devices." 122 123 #define I40E_VC_DEBUG(pf, level, ...) \ 124 do { \ 125 if ((pf)->vc_debug_lvl >= (level)) \ 126 device_printf((pf)->dev, __VA_ARGS__); \ 127 } while (0) 128 129 #define i40e_send_vf_nack(pf, vf, op, st) \ 130 ixl_send_vf_nack_msg((pf), (vf), (op), (st), __FILE__, __LINE__) 131 132 #define IXL_PF_LOCK_INIT(_sc, _name) \ 133 mtx_init(&(_sc)->pf_mtx, _name, "IXL PF Lock", MTX_DEF) 134 #define IXL_PF_LOCK(_sc) mtx_lock(&(_sc)->pf_mtx) 135 #define IXL_PF_UNLOCK(_sc) mtx_unlock(&(_sc)->pf_mtx) 136 #define IXL_PF_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->pf_mtx) 137 #define IXL_PF_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->pf_mtx, MA_OWNED) 138 139 #endif /* _IXL_PF_H_ */ 140