net/ice/base: add helper function to redirect flags
[dpdk.git] / drivers / net / txgbe / base / txgbe_mbx.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020 Beijing WangXun Technology Co., Ltd.
3  * Copyright(c) 2010-2017 Intel Corporation
4  */
5
6 #ifndef _TXGBE_MBX_H_
7 #define _TXGBE_MBX_H_
8
9 #include "txgbe_type.h"
10
11 #define TXGBE_ERR_MBX           -100
12
13 /* If it's a TXGBE_VF_* msg then it originates in the VF and is sent to the
14  * PF.  The reverse is true if it is TXGBE_PF_*.
15  * Message ACK's are the value or'd with 0xF0000000
16  */
17 /* Messages below or'd with this are the ACK */
18 #define TXGBE_VT_MSGTYPE_ACK    0x80000000
19 /* Messages below or'd with this are the NACK */
20 #define TXGBE_VT_MSGTYPE_NACK   0x40000000
21 /* Indicates that VF is still clear to send requests */
22 #define TXGBE_VT_MSGTYPE_CTS    0x20000000
23
24 #define TXGBE_VT_MSGINFO_SHIFT  16
25 /* bits 23:16 are used for extra info for certain messages */
26 #define TXGBE_VT_MSGINFO_MASK   (0xFF << TXGBE_VT_MSGINFO_SHIFT)
27
28 /* definitions to support mailbox API version negotiation */
29
30 /*
31  * each element denotes a version of the API; existing numbers may not
32  * change; any additions must go at the end
33  */
34 enum txgbe_pfvf_api_rev {
35         txgbe_mbox_api_null,
36         txgbe_mbox_api_10,      /* API version 1.0, linux/freebsd VF driver */
37         txgbe_mbox_api_11,      /* API version 1.1, linux/freebsd VF driver */
38         txgbe_mbox_api_12,      /* API version 1.2, linux/freebsd VF driver */
39         txgbe_mbox_api_13,      /* API version 1.3, linux/freebsd VF driver */
40         txgbe_mbox_api_20,      /* API version 2.0, solaris Phase1 VF driver */
41         /* This value should always be last */
42         txgbe_mbox_api_unknown, /* indicates that API version is not known */
43 };
44
45 /* mailbox API, legacy requests */
46 #define TXGBE_VF_RESET          0x01 /* VF requests reset */
47 #define TXGBE_VF_SET_MAC_ADDR   0x02 /* VF requests PF to set MAC addr */
48 #define TXGBE_VF_SET_MULTICAST  0x03 /* VF requests PF to set MC addr */
49 #define TXGBE_VF_SET_VLAN       0x04 /* VF requests PF to set VLAN */
50
51 /* mailbox API, version 1.0 VF requests */
52 #define TXGBE_VF_SET_LPE        0x05 /* VF requests PF to set VMOLR.LPE */
53 #define TXGBE_VF_SET_MACVLAN    0x06 /* VF requests PF for unicast filter */
54 #define TXGBE_VF_API_NEGOTIATE  0x08 /* negotiate API version */
55
56 /* mailbox API, version 1.1 VF requests */
57 #define TXGBE_VF_GET_QUEUES     0x09 /* get queue configuration */
58
59 /* mailbox API, version 1.2 VF requests */
60 #define TXGBE_VF_GET_RETA      0x0a    /* VF request for RETA */
61 #define TXGBE_VF_GET_RSS_KEY    0x0b    /* get RSS key */
62 #define TXGBE_VF_UPDATE_XCAST_MODE      0x0c
63
64 #define TXGBE_VF_BACKUP         0x8001 /* VF requests backup */
65
66 /* mode choices for TXGBE_VF_UPDATE_XCAST_MODE */
67 enum txgbevf_xcast_modes {
68         TXGBEVF_XCAST_MODE_NONE = 0,
69         TXGBEVF_XCAST_MODE_MULTI,
70         TXGBEVF_XCAST_MODE_ALLMULTI,
71         TXGBEVF_XCAST_MODE_PROMISC,
72 };
73
74 /* GET_QUEUES return data indices within the mailbox */
75 #define TXGBE_VF_TX_QUEUES      1       /* number of Tx queues supported */
76 #define TXGBE_VF_RX_QUEUES      2       /* number of Rx queues supported */
77 #define TXGBE_VF_TRANS_VLAN     3       /* Indication of port vlan */
78 #define TXGBE_VF_DEF_QUEUE      4       /* Default queue offset */
79
80 /* length of permanent address message returned from PF */
81 #define TXGBE_VF_PERMADDR_MSG_LEN       4
82 /* word in permanent address message with the current multicast type */
83 #define TXGBE_VF_MC_TYPE_WORD           3
84
85 #define TXGBE_PF_CONTROL_MSG            0x0100 /* PF control message */
86
87 #define TXGBE_VF_MBX_INIT_TIMEOUT       2000 /* number of retries on mailbox */
88 #define TXGBE_VF_MBX_INIT_DELAY         500  /* microseconds between retries */
89
90 s32 txgbe_read_mbx(struct txgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
91 s32 txgbe_write_mbx(struct txgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
92 s32 txgbe_read_posted_mbx(struct txgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
93 s32 txgbe_write_posted_mbx(struct txgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
94 s32 txgbe_check_for_msg(struct txgbe_hw *hw, u16 mbx_id);
95 s32 txgbe_check_for_ack(struct txgbe_hw *hw, u16 mbx_id);
96 s32 txgbe_check_for_rst(struct txgbe_hw *hw, u16 mbx_id);
97 void txgbe_init_mbx_params_vf(struct txgbe_hw *hw);
98 void txgbe_init_mbx_params_pf(struct txgbe_hw *hw);
99
100 s32 txgbe_read_mbx_pf(struct txgbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
101 s32 txgbe_write_mbx_pf(struct txgbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
102 s32 txgbe_check_for_msg_pf(struct txgbe_hw *hw, u16 vf_number);
103 s32 txgbe_check_for_ack_pf(struct txgbe_hw *hw, u16 vf_number);
104 s32 txgbe_check_for_rst_pf(struct txgbe_hw *hw, u16 vf_number);
105
106 s32 txgbe_read_mbx_vf(struct txgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
107 s32 txgbe_write_mbx_vf(struct txgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
108 s32 txgbe_check_for_msg_vf(struct txgbe_hw *hw, u16 mbx_id);
109 s32 txgbe_check_for_ack_vf(struct txgbe_hw *hw, u16 mbx_id);
110 s32 txgbe_check_for_rst_vf(struct txgbe_hw *hw, u16 mbx_id);
111
112 #endif /* _TXGBE_MBX_H_ */