xref: /freebsd/sys/dev/e1000/e1000_mbx.h (revision 71625ec9ad2a9bc8c09784fbd23b759830e0ee5f)
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_MBX_H_
36b8270585SJack F Vogel #define _E1000_MBX_H_
37b8270585SJack F Vogel 
38b8270585SJack F Vogel #include "e1000_api.h"
39b8270585SJack F Vogel 
40b8270585SJack F Vogel /* Define mailbox register bits */
41b8270585SJack F Vogel #define E1000_V2PMAILBOX_REQ	0x00000001 /* Request for PF Ready bit */
42b8270585SJack F Vogel #define E1000_V2PMAILBOX_ACK	0x00000002 /* Ack PF message received */
43b8270585SJack F Vogel #define E1000_V2PMAILBOX_VFU	0x00000004 /* VF owns the mailbox buffer */
44b8270585SJack F Vogel #define E1000_V2PMAILBOX_PFU	0x00000008 /* PF owns the mailbox buffer */
45b8270585SJack F Vogel #define E1000_V2PMAILBOX_PFSTS	0x00000010 /* PF wrote a message in the MB */
46b8270585SJack F Vogel #define E1000_V2PMAILBOX_PFACK	0x00000020 /* PF ack the previous VF msg */
47b8270585SJack F Vogel #define E1000_V2PMAILBOX_RSTI	0x00000040 /* PF has reset indication */
48b8270585SJack F Vogel #define E1000_V2PMAILBOX_RSTD	0x00000080 /* PF has indicated reset done */
49b8270585SJack F Vogel #define E1000_V2PMAILBOX_R2C_BITS 0x000000B0 /* All read to clear bits */
50b8270585SJack F Vogel 
51b8270585SJack F Vogel #define E1000_P2VMAILBOX_STS	0x00000001 /* Initiate message send to VF */
52b8270585SJack F Vogel #define E1000_P2VMAILBOX_ACK	0x00000002 /* Ack message recv'd from VF */
53b8270585SJack F Vogel #define E1000_P2VMAILBOX_VFU	0x00000004 /* VF owns the mailbox buffer */
54b8270585SJack F Vogel #define E1000_P2VMAILBOX_PFU	0x00000008 /* PF owns the mailbox buffer */
55b8270585SJack F Vogel #define E1000_P2VMAILBOX_RVFU	0x00000010 /* Reset VFU - used when VF stuck */
56b8270585SJack F Vogel 
57b8270585SJack F Vogel #define E1000_MBVFICR_VFREQ_MASK 0x000000FF /* bits for VF messages */
58b8270585SJack F Vogel #define E1000_MBVFICR_VFREQ_VF1	0x00000001 /* bit for VF 1 message */
59b8270585SJack F Vogel #define E1000_MBVFICR_VFACK_MASK 0x00FF0000 /* bits for VF acks */
60b8270585SJack F Vogel #define E1000_MBVFICR_VFACK_VF1	0x00010000 /* bit for VF 1 ack */
61b8270585SJack F Vogel 
62b8270585SJack F Vogel #define E1000_VFMAILBOX_SIZE	16 /* 16 32 bit words - 64 bytes */
63b8270585SJack F Vogel 
64b8270585SJack F Vogel /* If it's a E1000_VF_* msg then it originates in the VF and is sent to the
65*1bbdc25fSKevin Bowling  * PF.  The reverse is true if it is E1000_PF_*.
66b8270585SJack F Vogel  * Message ACK's are the value or'd with 0xF0000000
67b8270585SJack F Vogel  */
688cc64f1eSJack F Vogel /* Msgs below or'd with this are the ACK */
698cc64f1eSJack F Vogel #define E1000_VT_MSGTYPE_ACK	0x80000000
708cc64f1eSJack F Vogel /* Msgs below or'd with this are the NACK */
718cc64f1eSJack F Vogel #define E1000_VT_MSGTYPE_NACK	0x40000000
728cc64f1eSJack F Vogel /* Indicates that VF is still clear to send requests */
738cc64f1eSJack F Vogel #define E1000_VT_MSGTYPE_CTS	0x20000000
74b8270585SJack F Vogel #define E1000_VT_MSGINFO_SHIFT	16
758cc64f1eSJack F Vogel /* bits 23:16 are used for extra info for certain messages */
76b8270585SJack F Vogel #define E1000_VT_MSGINFO_MASK	(0xFF << E1000_VT_MSGINFO_SHIFT)
77b8270585SJack F Vogel 
78b8270585SJack F Vogel #define E1000_VF_RESET			0x01 /* VF requests reset */
79b8270585SJack F Vogel #define E1000_VF_SET_MAC_ADDR		0x02 /* VF requests to set MAC addr */
80b8270585SJack F Vogel #define E1000_VF_SET_MULTICAST		0x03 /* VF requests to set MC addr */
81b8270585SJack F Vogel #define E1000_VF_SET_MULTICAST_COUNT_MASK (0x1F << E1000_VT_MSGINFO_SHIFT)
82b8270585SJack F Vogel #define E1000_VF_SET_MULTICAST_OVERFLOW	(0x80 << E1000_VT_MSGINFO_SHIFT)
83b8270585SJack F Vogel #define E1000_VF_SET_VLAN		0x04 /* VF requests to set VLAN */
84b8270585SJack F Vogel #define E1000_VF_SET_VLAN_ADD		(0x01 << E1000_VT_MSGINFO_SHIFT)
858cc64f1eSJack F Vogel #define E1000_VF_SET_LPE		0x05 /* reqs to set VMOLR.LPE */
868cc64f1eSJack F Vogel #define E1000_VF_SET_PROMISC		0x06 /* reqs to clear VMOLR.ROPE/MPME*/
87b8270585SJack F Vogel #define E1000_VF_SET_PROMISC_UNICAST	(0x01 << E1000_VT_MSGINFO_SHIFT)
88b8270585SJack F Vogel #define E1000_VF_SET_PROMISC_MULTICAST	(0x02 << E1000_VT_MSGINFO_SHIFT)
89b8270585SJack F Vogel 
90b8270585SJack F Vogel #define E1000_PF_CONTROL_MSG		0x0100 /* PF control message */
91b8270585SJack F Vogel 
92b8270585SJack F Vogel #define E1000_VF_MBX_INIT_TIMEOUT	2000 /* number of retries on mailbox */
93b8270585SJack F Vogel #define E1000_VF_MBX_INIT_DELAY		500  /* microseconds between retries */
94b8270585SJack F Vogel 
95b8270585SJack F Vogel s32 e1000_read_mbx(struct e1000_hw *, u32 *, u16, u16);
96b8270585SJack F Vogel s32 e1000_write_mbx(struct e1000_hw *, u32 *, u16, u16);
97b8270585SJack F Vogel s32 e1000_read_posted_mbx(struct e1000_hw *, u32 *, u16, u16);
98b8270585SJack F Vogel s32 e1000_write_posted_mbx(struct e1000_hw *, u32 *, u16, u16);
99b8270585SJack F Vogel s32 e1000_check_for_msg(struct e1000_hw *, u16);
100b8270585SJack F Vogel s32 e1000_check_for_ack(struct e1000_hw *, u16);
101b8270585SJack F Vogel s32 e1000_check_for_rst(struct e1000_hw *, u16);
102b8270585SJack F Vogel void e1000_init_mbx_ops_generic(struct e1000_hw *hw);
103b8270585SJack F Vogel s32 e1000_init_mbx_params_vf(struct e1000_hw *);
104b8270585SJack F Vogel s32 e1000_init_mbx_params_pf(struct e1000_hw *);
105b8270585SJack F Vogel 
106b8270585SJack F Vogel #endif /* _E1000_MBX_H_ */
107