xref: /dpdk/drivers/net/ngbe/base/ngbe_mbx.h (revision 66070ca419c1675c5f64f32908f1eae510dd3637)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
3  * Copyright(c) 2010-2017 Intel Corporation
4  */
5 
6 #ifndef _NGBE_MBX_H_
7 #define _NGBE_MBX_H_
8 
9 #define NGBE_ERR_MBX		-100
10 
11 /* If it's a NGBE_VF_* msg then it originates in the VF and is sent to the
12  * PF.  The reverse is true if it is NGBE_PF_*.
13  * Message ACK's are the value or'd with 0xF0000000
14  */
15 /* Messages below or'd with this are the ACK */
16 #define NGBE_VT_MSGTYPE_ACK	0x80000000
17 /* Messages below or'd with this are the NACK */
18 #define NGBE_VT_MSGTYPE_NACK	0x40000000
19 /* Indicates that VF is still clear to send requests */
20 #define NGBE_VT_MSGTYPE_CTS	0x20000000
21 
22 #define NGBE_VT_MSGINFO_SHIFT	16
23 /* bits 23:16 are used for extra info for certain messages */
24 #define NGBE_VT_MSGINFO_MASK	(0xFF << NGBE_VT_MSGINFO_SHIFT)
25 
26 /*
27  * each element denotes a version of the API; existing numbers may not
28  * change; any additions must go at the end
29  */
30 enum ngbe_pfvf_api_rev {
31 	ngbe_mbox_api_null,
32 	ngbe_mbox_api_10,	/* API version 1.0, linux/freebsd VF driver */
33 	ngbe_mbox_api_11,	/* API version 1.1, linux/freebsd VF driver */
34 	ngbe_mbox_api_12,	/* API version 1.2, linux/freebsd VF driver */
35 	ngbe_mbox_api_13,	/* API version 1.3, linux/freebsd VF driver */
36 	ngbe_mbox_api_20,	/* API version 2.0, solaris Phase1 VF driver */
37 	/* This value should always be last */
38 	ngbe_mbox_api_unknown,	/* indicates that API version is not known */
39 };
40 
41 /* mailbox API, legacy requests */
42 #define NGBE_VF_RESET		0x01 /* VF requests reset */
43 #define NGBE_VF_SET_MAC_ADDR	0x02 /* VF requests PF to set MAC addr */
44 #define NGBE_VF_SET_MULTICAST	0x03 /* VF requests PF to set MC addr */
45 #define NGBE_VF_SET_VLAN	0x04 /* VF requests PF to set VLAN */
46 
47 /* mailbox API, version 1.0 VF requests */
48 #define NGBE_VF_SET_LPE	0x05 /* VF requests PF to set VMOLR.LPE */
49 #define NGBE_VF_SET_MACVLAN	0x06 /* VF requests PF for unicast filter */
50 #define NGBE_VF_API_NEGOTIATE	0x08 /* negotiate API version */
51 
52 /* mailbox API, version 1.1 VF requests */
53 #define NGBE_VF_GET_QUEUES	0x09 /* get queue configuration */
54 
55 /* mailbox API, version 1.2 VF requests */
56 #define NGBE_VF_GET_RETA      0x0a    /* VF request for RETA */
57 #define NGBE_VF_GET_RSS_KEY	0x0b    /* get RSS key */
58 #define NGBE_VF_UPDATE_XCAST_MODE	0x0c
59 
60 #define NGBE_VF_BACKUP		0x8001 /* VF requests backup */
61 
62 /* mode choices for NGBE_VF_UPDATE_XCAST_MODE */
63 enum ngbevf_xcast_modes {
64 	NGBEVF_XCAST_MODE_NONE = 0,
65 	NGBEVF_XCAST_MODE_MULTI,
66 	NGBEVF_XCAST_MODE_ALLMULTI,
67 	NGBEVF_XCAST_MODE_PROMISC,
68 };
69 
70 /* GET_QUEUES return data indices within the mailbox */
71 #define NGBE_VF_TX_QUEUES	1	/* number of Tx queues supported */
72 #define NGBE_VF_RX_QUEUES	2	/* number of Rx queues supported */
73 #define NGBE_VF_TRANS_VLAN	3	/* Indication of port vlan */
74 #define NGBE_VF_DEF_QUEUE	4	/* Default queue offset */
75 
76 /* length of permanent address message returned from PF */
77 #define NGBE_VF_PERMADDR_MSG_LEN	4
78 /* word in permanent address message with the current multicast type */
79 #define NGBE_VF_MC_TYPE_WORD		3
80 
81 #define NGBE_PF_CONTROL_MSG		0x0100 /* PF control message */
82 
83 /* mailbox API, version 2.0 VF requests */
84 #define NGBE_VF_API_NEGOTIATE		0x08 /* negotiate API version */
85 #define NGBE_VF_GET_QUEUES		0x09 /* get queue configuration */
86 #define NGBE_VF_ENABLE_MACADDR		0x0A /* enable MAC address */
87 #define NGBE_VF_DISABLE_MACADDR	0x0B /* disable MAC address */
88 #define NGBE_VF_GET_MACADDRS		0x0C /* get all configured MAC addrs */
89 #define NGBE_VF_SET_MCAST_PROMISC	0x0D /* enable multicast promiscuous */
90 #define NGBE_VF_GET_MTU		0x0E /* get bounds on MTU */
91 #define NGBE_VF_SET_MTU		0x0F /* set a specific MTU */
92 
93 /* mailbox API, version 2.0 PF requests */
94 #define NGBE_PF_TRANSPARENT_VLAN	0x0101 /* enable transparent vlan */
95 
96 #define NGBE_VF_MBX_INIT_TIMEOUT	2000 /* number of retries on mailbox */
97 #define NGBE_VF_MBX_INIT_DELAY		500  /* microseconds between retries */
98 s32 ngbe_read_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
99 s32 ngbe_write_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
100 s32 ngbe_read_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
101 s32 ngbe_write_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
102 s32 ngbe_check_for_msg(struct ngbe_hw *hw, u16 mbx_id);
103 s32 ngbe_check_for_ack(struct ngbe_hw *hw, u16 mbx_id);
104 s32 ngbe_check_for_rst(struct ngbe_hw *hw, u16 mbx_id);
105 void ngbe_init_mbx_params_vf(struct ngbe_hw *hw);
106 void ngbe_init_mbx_params_pf(struct ngbe_hw *hw);
107 
108 s32 ngbe_read_mbx_pf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
109 s32 ngbe_write_mbx_pf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
110 s32 ngbe_check_for_msg_pf(struct ngbe_hw *hw, u16 vf_number);
111 s32 ngbe_check_for_ack_pf(struct ngbe_hw *hw, u16 vf_number);
112 s32 ngbe_check_for_rst_pf(struct ngbe_hw *hw, u16 vf_number);
113 
114 s32 ngbe_read_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
115 s32 ngbe_write_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
116 s32 ngbe_check_for_msg_vf(struct ngbe_hw *hw, u16 mbx_id);
117 s32 ngbe_check_for_ack_vf(struct ngbe_hw *hw, u16 mbx_id);
118 s32 ngbe_check_for_rst_vf(struct ngbe_hw *hw, u16 mbx_id);
119 
120 #endif /* _NGBE_MBX_H_ */
121