1b8270585SJack F Vogel /****************************************************************************** 27282444bSPedro F. Giffuni SPDX-License-Identifier: BSD-3-Clause 3b8270585SJack F Vogel 4702cac6cSKevin Bowling Copyright (c) 2001-2020, Intel Corporation 5b8270585SJack F Vogel All rights reserved. 6b8270585SJack F Vogel 7b8270585SJack F Vogel Redistribution and use in source and binary forms, with or without 8b8270585SJack F Vogel modification, are permitted provided that the following conditions are met: 9b8270585SJack F Vogel 10b8270585SJack F Vogel 1. Redistributions of source code must retain the above copyright notice, 11b8270585SJack F Vogel this list of conditions and the following disclaimer. 12b8270585SJack F Vogel 13b8270585SJack F Vogel 2. Redistributions in binary form must reproduce the above copyright 14b8270585SJack F Vogel notice, this list of conditions and the following disclaimer in the 15b8270585SJack F Vogel documentation and/or other materials provided with the distribution. 16b8270585SJack F Vogel 17b8270585SJack F Vogel 3. Neither the name of the Intel Corporation nor the names of its 18b8270585SJack F Vogel contributors may be used to endorse or promote products derived from 19b8270585SJack F Vogel this software without specific prior written permission. 20b8270585SJack F Vogel 21b8270585SJack F Vogel THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22b8270585SJack F Vogel AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23b8270585SJack F Vogel IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24b8270585SJack F Vogel ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25b8270585SJack F Vogel LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26b8270585SJack F Vogel CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27b8270585SJack F Vogel SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28b8270585SJack F Vogel INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29b8270585SJack F Vogel CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30b8270585SJack F Vogel ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31b8270585SJack F Vogel POSSIBILITY OF SUCH DAMAGE. 32b8270585SJack F Vogel 33b8270585SJack F Vogel ******************************************************************************/ 34b8270585SJack F Vogel 35b8270585SJack F Vogel #ifndef _E1000_VF_H_ 36b8270585SJack F Vogel #define _E1000_VF_H_ 37b8270585SJack F Vogel 38b8270585SJack F Vogel #include "e1000_osdep.h" 39b8270585SJack F Vogel #include "e1000_regs.h" 40b8270585SJack F Vogel #include "e1000_defines.h" 41b8270585SJack F Vogel 42b8270585SJack F Vogel struct e1000_hw; 43b8270585SJack F Vogel 44b8270585SJack F Vogel #define E1000_DEV_ID_82576_VF 0x10CA 45f0ecc46dSJack F Vogel #define E1000_DEV_ID_I350_VF 0x1520 46b8270585SJack F Vogel 477609433eSJack F Vogel #define E1000_VF_INIT_TIMEOUT 200 /* Num of retries to clear RSTI */ 48b8270585SJack F Vogel 49b8270585SJack F Vogel /* Additional Descriptor Control definitions */ 507609433eSJack F Vogel #define E1000_TXDCTL_QUEUE_ENABLE 0x02000000 /* Ena specific Tx Queue */ 517609433eSJack F Vogel #define E1000_RXDCTL_QUEUE_ENABLE 0x02000000 /* Ena specific Rx Queue */ 52b8270585SJack F Vogel 53b8270585SJack F Vogel /* SRRCTL bit definitions */ 547609433eSJack F Vogel #define E1000_SRRCTL(_n) ((_n) < 4 ? (0x0280C + ((_n) * 0x100)) : \ 557609433eSJack F Vogel (0x0C00C + ((_n) * 0x40))) 56b8270585SJack F Vogel #define E1000_SRRCTL_BSIZEPKT_SHIFT 10 /* Shift _right_ */ 57b8270585SJack F Vogel #define E1000_SRRCTL_BSIZEHDRSIZE_MASK 0x00000F00 58b8270585SJack F Vogel #define E1000_SRRCTL_BSIZEHDRSIZE_SHIFT 2 /* Shift _left_ */ 59b8270585SJack F Vogel #define E1000_SRRCTL_DESCTYPE_LEGACY 0x00000000 60b8270585SJack F Vogel #define E1000_SRRCTL_DESCTYPE_ADV_ONEBUF 0x02000000 61b8270585SJack F Vogel #define E1000_SRRCTL_DESCTYPE_HDR_SPLIT 0x04000000 62b8270585SJack F Vogel #define E1000_SRRCTL_DESCTYPE_HDR_SPLIT_ALWAYS 0x0A000000 63b8270585SJack F Vogel #define E1000_SRRCTL_DESCTYPE_HDR_REPLICATION 0x06000000 64b8270585SJack F Vogel #define E1000_SRRCTL_DESCTYPE_HDR_REPLICATION_LARGE_PKT 0x08000000 65b8270585SJack F Vogel #define E1000_SRRCTL_DESCTYPE_MASK 0x0E000000 66b8270585SJack F Vogel #define E1000_SRRCTL_DROP_EN 0x80000000 67b8270585SJack F Vogel 68b8270585SJack F Vogel #define E1000_SRRCTL_BSIZEPKT_MASK 0x0000007F 69b8270585SJack F Vogel #define E1000_SRRCTL_BSIZEHDR_MASK 0x00003F00 70b8270585SJack F Vogel 71b8270585SJack F Vogel /* Interrupt Defines */ 72b8270585SJack F Vogel #define E1000_EICR 0x01580 /* Ext. Interrupt Cause Read - R/clr */ 73b8270585SJack F Vogel #define E1000_EITR(_n) (0x01680 + ((_n) << 2)) 747609433eSJack F Vogel #define E1000_EICS 0x01520 /* Ext. Intr Cause Set -W0 */ 757609433eSJack F Vogel #define E1000_EIMS 0x01524 /* Ext. Intr Mask Set/Read -RW */ 767609433eSJack F Vogel #define E1000_EIMC 0x01528 /* Ext. Intr Mask Clear -WO */ 777609433eSJack F Vogel #define E1000_EIAC 0x0152C /* Ext. Intr Auto Clear -RW */ 787609433eSJack F Vogel #define E1000_EIAM 0x01530 /* Ext. Intr Ack Auto Clear Mask -RW */ 797609433eSJack F Vogel #define E1000_IVAR0 0x01700 /* Intr Vector Alloc (array) -RW */ 80b8270585SJack F Vogel #define E1000_IVAR_MISC 0x01740 /* IVAR for "other" causes -RW */ 81b8270585SJack F Vogel #define E1000_IVAR_VALID 0x80 82b8270585SJack F Vogel 83b8270585SJack F Vogel /* Receive Descriptor - Advanced */ 84b8270585SJack F Vogel union e1000_adv_rx_desc { 85b8270585SJack F Vogel struct { 86b8270585SJack F Vogel u64 pkt_addr; /* Packet buffer address */ 87b8270585SJack F Vogel u64 hdr_addr; /* Header buffer address */ 88b8270585SJack F Vogel } read; 89b8270585SJack F Vogel struct { 90b8270585SJack F Vogel struct { 91b8270585SJack F Vogel union { 92b8270585SJack F Vogel u32 data; 93b8270585SJack F Vogel struct { 94f0ecc46dSJack F Vogel /* RSS type, Packet type */ 95f0ecc46dSJack F Vogel u16 pkt_info; 96f0ecc46dSJack F Vogel /* Split Header, header buffer len */ 97f0ecc46dSJack F Vogel u16 hdr_info; 98b8270585SJack F Vogel } hs_rss; 99b8270585SJack F Vogel } lo_dword; 100b8270585SJack F Vogel union { 101b8270585SJack F Vogel u32 rss; /* RSS Hash */ 102b8270585SJack F Vogel struct { 103b8270585SJack F Vogel u16 ip_id; /* IP id */ 104b8270585SJack F Vogel u16 csum; /* Packet Checksum */ 105b8270585SJack F Vogel } csum_ip; 106b8270585SJack F Vogel } hi_dword; 107b8270585SJack F Vogel } lower; 108b8270585SJack F Vogel struct { 109b8270585SJack F Vogel u32 status_error; /* ext status/error */ 110b8270585SJack F Vogel u16 length; /* Packet length */ 111b8270585SJack F Vogel u16 vlan; /* VLAN tag */ 112b8270585SJack F Vogel } upper; 113b8270585SJack F Vogel } wb; /* writeback */ 114b8270585SJack F Vogel }; 115b8270585SJack F Vogel 116b8270585SJack F Vogel #define E1000_RXDADV_HDRBUFLEN_MASK 0x7FE0 117b8270585SJack F Vogel #define E1000_RXDADV_HDRBUFLEN_SHIFT 5 118b8270585SJack F Vogel 119b8270585SJack F Vogel /* Transmit Descriptor - Advanced */ 120b8270585SJack F Vogel union e1000_adv_tx_desc { 121b8270585SJack F Vogel struct { 122b8270585SJack F Vogel u64 buffer_addr; /* Address of descriptor's data buf */ 123b8270585SJack F Vogel u32 cmd_type_len; 124b8270585SJack F Vogel u32 olinfo_status; 125b8270585SJack F Vogel } read; 126b8270585SJack F Vogel struct { 127b8270585SJack F Vogel u64 rsvd; /* Reserved */ 128b8270585SJack F Vogel u32 nxtseq_seed; 129b8270585SJack F Vogel u32 status; 130b8270585SJack F Vogel } wb; 131b8270585SJack F Vogel }; 132b8270585SJack F Vogel 133b8270585SJack F Vogel /* Adv Transmit Descriptor Config Masks */ 134b8270585SJack F Vogel #define E1000_ADVTXD_DTYP_CTXT 0x00200000 /* Advanced Context Descriptor */ 135b8270585SJack F Vogel #define E1000_ADVTXD_DTYP_DATA 0x00300000 /* Advanced Data Descriptor */ 136b8270585SJack F Vogel #define E1000_ADVTXD_DCMD_EOP 0x01000000 /* End of Packet */ 137b8270585SJack F Vogel #define E1000_ADVTXD_DCMD_IFCS 0x02000000 /* Insert FCS (Ethernet CRC) */ 138b8270585SJack F Vogel #define E1000_ADVTXD_DCMD_RS 0x08000000 /* Report Status */ 139b8270585SJack F Vogel #define E1000_ADVTXD_DCMD_DEXT 0x20000000 /* Descriptor extension (1=Adv) */ 140b8270585SJack F Vogel #define E1000_ADVTXD_DCMD_VLE 0x40000000 /* VLAN pkt enable */ 141b8270585SJack F Vogel #define E1000_ADVTXD_DCMD_TSE 0x80000000 /* TCP Seg enable */ 142b8270585SJack F Vogel #define E1000_ADVTXD_PAYLEN_SHIFT 14 /* Adv desc PAYLEN shift */ 143b8270585SJack F Vogel 144b8270585SJack F Vogel /* Context descriptors */ 145b8270585SJack F Vogel struct e1000_adv_tx_context_desc { 146b8270585SJack F Vogel u32 vlan_macip_lens; 147b8270585SJack F Vogel u32 seqnum_seed; 148b8270585SJack F Vogel u32 type_tucmd_mlhl; 149b8270585SJack F Vogel u32 mss_l4len_idx; 150b8270585SJack F Vogel }; 151b8270585SJack F Vogel 152b8270585SJack F Vogel #define E1000_ADVTXD_MACLEN_SHIFT 9 /* Adv ctxt desc mac len shift */ 153b8270585SJack F Vogel #define E1000_ADVTXD_TUCMD_IPV4 0x00000400 /* IP Packet Type: 1=IPv4 */ 154b8270585SJack F Vogel #define E1000_ADVTXD_TUCMD_L4T_TCP 0x00000800 /* L4 Packet TYPE of TCP */ 155b8270585SJack F Vogel #define E1000_ADVTXD_L4LEN_SHIFT 8 /* Adv ctxt L4LEN shift */ 156b8270585SJack F Vogel #define E1000_ADVTXD_MSS_SHIFT 16 /* Adv ctxt MSS shift */ 157b8270585SJack F Vogel 158b8270585SJack F Vogel enum e1000_mac_type { 159b8270585SJack F Vogel e1000_undefined = 0, 160b8270585SJack F Vogel e1000_vfadapt, 161f0ecc46dSJack F Vogel e1000_vfadapt_i350, 162*1bbdc25fSKevin Bowling e1000_num_macs /* List is 1-based, so subtract 1 for true count. */ 163b8270585SJack F Vogel }; 164b8270585SJack F Vogel 165b8270585SJack F Vogel struct e1000_vf_stats { 166b8270585SJack F Vogel u64 base_gprc; 167b8270585SJack F Vogel u64 base_gptc; 168b8270585SJack F Vogel u64 base_gorc; 169b8270585SJack F Vogel u64 base_gotc; 170b8270585SJack F Vogel u64 base_mprc; 171b8270585SJack F Vogel u64 base_gotlbc; 172b8270585SJack F Vogel u64 base_gptlbc; 173b8270585SJack F Vogel u64 base_gorlbc; 174b8270585SJack F Vogel u64 base_gprlbc; 175b8270585SJack F Vogel 176b8270585SJack F Vogel u32 last_gprc; 177b8270585SJack F Vogel u32 last_gptc; 178b8270585SJack F Vogel u32 last_gorc; 179b8270585SJack F Vogel u32 last_gotc; 180b8270585SJack F Vogel u32 last_mprc; 181b8270585SJack F Vogel u32 last_gotlbc; 182b8270585SJack F Vogel u32 last_gptlbc; 183b8270585SJack F Vogel u32 last_gorlbc; 184b8270585SJack F Vogel u32 last_gprlbc; 185b8270585SJack F Vogel 186b8270585SJack F Vogel u64 gprc; 187b8270585SJack F Vogel u64 gptc; 188b8270585SJack F Vogel u64 gorc; 189b8270585SJack F Vogel u64 gotc; 190b8270585SJack F Vogel u64 mprc; 191b8270585SJack F Vogel u64 gotlbc; 192b8270585SJack F Vogel u64 gptlbc; 193b8270585SJack F Vogel u64 gorlbc; 194b8270585SJack F Vogel u64 gprlbc; 195b8270585SJack F Vogel }; 196b8270585SJack F Vogel 197b8270585SJack F Vogel #include "e1000_mbx.h" 198b8270585SJack F Vogel 199b8270585SJack F Vogel struct e1000_mac_operations { 200b8270585SJack F Vogel /* Function pointers for the MAC. */ 201b8270585SJack F Vogel s32 (*init_params)(struct e1000_hw *); 202b8270585SJack F Vogel s32 (*check_for_link)(struct e1000_hw *); 203b8270585SJack F Vogel void (*clear_vfta)(struct e1000_hw *); 204b8270585SJack F Vogel s32 (*get_bus_info)(struct e1000_hw *); 205b8270585SJack F Vogel s32 (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *); 206b8270585SJack F Vogel void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32); 207b8270585SJack F Vogel s32 (*reset_hw)(struct e1000_hw *); 208b8270585SJack F Vogel s32 (*init_hw)(struct e1000_hw *); 209b8270585SJack F Vogel s32 (*setup_link)(struct e1000_hw *); 210b8270585SJack F Vogel void (*write_vfta)(struct e1000_hw *, u32, u32); 2118cc64f1eSJack F Vogel int (*rar_set)(struct e1000_hw *, u8*, u32); 212b8270585SJack F Vogel s32 (*read_mac_addr)(struct e1000_hw *); 213b8270585SJack F Vogel }; 214b8270585SJack F Vogel 215b8270585SJack F Vogel struct e1000_mac_info { 216b8270585SJack F Vogel struct e1000_mac_operations ops; 217b8270585SJack F Vogel u8 addr[6]; 218b8270585SJack F Vogel u8 perm_addr[6]; 219b8270585SJack F Vogel 220b8270585SJack F Vogel enum e1000_mac_type type; 221b8270585SJack F Vogel 222b8270585SJack F Vogel u16 mta_reg_count; 223b8270585SJack F Vogel u16 rar_entry_count; 224b8270585SJack F Vogel 225b8270585SJack F Vogel bool get_link_status; 226b8270585SJack F Vogel }; 227b8270585SJack F Vogel 228b8270585SJack F Vogel struct e1000_mbx_operations { 229b8270585SJack F Vogel s32 (*init_params)(struct e1000_hw *hw); 230b8270585SJack F Vogel s32 (*read)(struct e1000_hw *, u32 *, u16, u16); 231b8270585SJack F Vogel s32 (*write)(struct e1000_hw *, u32 *, u16, u16); 232b8270585SJack F Vogel s32 (*read_posted)(struct e1000_hw *, u32 *, u16, u16); 233b8270585SJack F Vogel s32 (*write_posted)(struct e1000_hw *, u32 *, u16, u16); 234b8270585SJack F Vogel s32 (*check_for_msg)(struct e1000_hw *, u16); 235b8270585SJack F Vogel s32 (*check_for_ack)(struct e1000_hw *, u16); 236b8270585SJack F Vogel s32 (*check_for_rst)(struct e1000_hw *, u16); 237b8270585SJack F Vogel }; 238b8270585SJack F Vogel 239b8270585SJack F Vogel struct e1000_mbx_stats { 240b8270585SJack F Vogel u32 msgs_tx; 241b8270585SJack F Vogel u32 msgs_rx; 242b8270585SJack F Vogel 243b8270585SJack F Vogel u32 acks; 244b8270585SJack F Vogel u32 reqs; 245b8270585SJack F Vogel u32 rsts; 246b8270585SJack F Vogel }; 247b8270585SJack F Vogel 248b8270585SJack F Vogel struct e1000_mbx_info { 249b8270585SJack F Vogel struct e1000_mbx_operations ops; 250b8270585SJack F Vogel struct e1000_mbx_stats stats; 251b8270585SJack F Vogel u32 timeout; 252b8270585SJack F Vogel u32 usec_delay; 253b8270585SJack F Vogel u16 size; 254b8270585SJack F Vogel }; 255b8270585SJack F Vogel 256b8270585SJack F Vogel struct e1000_dev_spec_vf { 257b8270585SJack F Vogel u32 vf_number; 258b8270585SJack F Vogel u32 v2p_mailbox; 259b8270585SJack F Vogel }; 260b8270585SJack F Vogel 261b8270585SJack F Vogel struct e1000_hw { 262b8270585SJack F Vogel void *back; 263b8270585SJack F Vogel 264b8270585SJack F Vogel u8 *hw_addr; 265b8270585SJack F Vogel u8 *flash_address; 266b8270585SJack F Vogel unsigned long io_base; 267b8270585SJack F Vogel 268b8270585SJack F Vogel struct e1000_mac_info mac; 269b8270585SJack F Vogel struct e1000_mbx_info mbx; 270b8270585SJack F Vogel 271b8270585SJack F Vogel union { 272b8270585SJack F Vogel struct e1000_dev_spec_vf vf; 273b8270585SJack F Vogel } dev_spec; 274b8270585SJack F Vogel 275b8270585SJack F Vogel u16 device_id; 276b8270585SJack F Vogel u16 subsystem_vendor_id; 277b8270585SJack F Vogel u16 subsystem_device_id; 278b8270585SJack F Vogel u16 vendor_id; 279b8270585SJack F Vogel 280b8270585SJack F Vogel u8 revision_id; 281b8270585SJack F Vogel }; 282b8270585SJack F Vogel 283b8270585SJack F Vogel enum e1000_promisc_type { 284b8270585SJack F Vogel e1000_promisc_disabled = 0, /* all promisc modes disabled */ 285b8270585SJack F Vogel e1000_promisc_unicast = 1, /* unicast promiscuous enabled */ 286b8270585SJack F Vogel e1000_promisc_multicast = 2, /* multicast promiscuous enabled */ 287b8270585SJack F Vogel e1000_promisc_enabled = 3, /* both uni and multicast promisc */ 288b8270585SJack F Vogel e1000_num_promisc_types 289b8270585SJack F Vogel }; 290b8270585SJack F Vogel 291b8270585SJack F Vogel /* These functions must be implemented by drivers */ 292b8270585SJack F Vogel s32 e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value); 293b8270585SJack F Vogel void e1000_vfta_set_vf(struct e1000_hw *, u16, bool); 294b8270585SJack F Vogel void e1000_rlpml_set_vf(struct e1000_hw *, u16); 295b8270585SJack F Vogel s32 e1000_promisc_set_vf(struct e1000_hw *, enum e1000_promisc_type); 296b8270585SJack F Vogel #endif /* _E1000_VF_H_ */ 297