1
2
3
4 #ifndef __HCLGE_MBX_H
5 #define __HCLGE_MBX_H
6 #include <linux/init.h>
7 #include <linux/mutex.h>
8 #include <linux/types.h>
9
10 #define HCLGE_MBX_VF_MSG_DATA_NUM 16
11
12 enum HCLGE_MBX_OPCODE {
13 HCLGE_MBX_RESET = 0x01,
14 HCLGE_MBX_ASSERTING_RESET,
15 HCLGE_MBX_SET_UNICAST,
16 HCLGE_MBX_SET_MULTICAST,
17 HCLGE_MBX_SET_VLAN,
18 HCLGE_MBX_MAP_RING_TO_VECTOR,
19 HCLGE_MBX_UNMAP_RING_TO_VECTOR,
20 HCLGE_MBX_SET_PROMISC_MODE,
21 HCLGE_MBX_SET_MACVLAN,
22 HCLGE_MBX_API_NEGOTIATE,
23 HCLGE_MBX_GET_QINFO,
24 HCLGE_MBX_GET_QDEPTH,
25 HCLGE_MBX_GET_TCINFO,
26 HCLGE_MBX_GET_RETA,
27 HCLGE_MBX_GET_RSS_KEY,
28 HCLGE_MBX_GET_MAC_ADDR,
29 HCLGE_MBX_PF_VF_RESP,
30 HCLGE_MBX_GET_BDNUM,
31 HCLGE_MBX_GET_BUFSIZE,
32 HCLGE_MBX_GET_STREAMID,
33 HCLGE_MBX_SET_AESTART,
34 HCLGE_MBX_SET_TSOSTATS,
35 HCLGE_MBX_LINK_STAT_CHANGE,
36 HCLGE_MBX_GET_BASE_CONFIG,
37 HCLGE_MBX_BIND_FUNC_QUEUE,
38 HCLGE_MBX_GET_LINK_STATUS,
39 HCLGE_MBX_QUEUE_RESET,
40 HCLGE_MBX_KEEP_ALIVE,
41 HCLGE_MBX_SET_ALIVE,
42 HCLGE_MBX_SET_MTU,
43 HCLGE_MBX_GET_QID_IN_PF,
44 HCLGE_MBX_LINK_STAT_MODE,
45 HCLGE_MBX_GET_LINK_MODE,
46 HCLGE_MBX_PUSH_VLAN_INFO,
47 HCLGE_MBX_GET_MEDIA_TYPE,
48
49 HCLGE_MBX_GET_VF_FLR_STATUS = 200,
50 HCLGE_MBX_PUSH_LINK_STATUS,
51 HCLGE_MBX_NCSI_ERROR,
52 };
53
54
55 enum hclge_mbx_mac_vlan_subcode {
56 HCLGE_MBX_MAC_VLAN_UC_MODIFY = 0,
57 HCLGE_MBX_MAC_VLAN_UC_ADD,
58 HCLGE_MBX_MAC_VLAN_UC_REMOVE,
59 HCLGE_MBX_MAC_VLAN_MC_MODIFY,
60 HCLGE_MBX_MAC_VLAN_MC_ADD,
61 HCLGE_MBX_MAC_VLAN_MC_REMOVE,
62 };
63
64
65 enum hclge_mbx_vlan_cfg_subcode {
66 HCLGE_MBX_VLAN_FILTER = 0,
67 HCLGE_MBX_VLAN_TX_OFF_CFG,
68 HCLGE_MBX_VLAN_RX_OFF_CFG,
69 HCLGE_MBX_PORT_BASE_VLAN_CFG,
70 HCLGE_MBX_GET_PORT_BASE_VLAN_STATE,
71 };
72
73 #define HCLGE_MBX_MAX_MSG_SIZE 16
74 #define HCLGE_MBX_MAX_RESP_DATA_SIZE 8
75 #define HCLGE_MBX_RING_MAP_BASIC_MSG_NUM 3
76 #define HCLGE_MBX_RING_NODE_VARIABLE_NUM 3
77
78 struct hclgevf_mbx_resp_status {
79 struct mutex mbx_mutex;
80 u32 origin_mbx_msg;
81 bool received_resp;
82 int resp_status;
83 u8 additional_info[HCLGE_MBX_MAX_RESP_DATA_SIZE];
84 };
85
86 struct hclge_mbx_vf_to_pf_cmd {
87 u8 rsv;
88 u8 mbx_src_vfid;
89 u8 mbx_need_resp;
90 u8 rsv1[1];
91 u8 msg_len;
92 u8 rsv2[3];
93 u8 msg[HCLGE_MBX_MAX_MSG_SIZE];
94 };
95
96 #define HCLGE_MBX_NEED_RESP_BIT BIT(0)
97
98 struct hclge_mbx_pf_to_vf_cmd {
99 u8 dest_vfid;
100 u8 rsv[3];
101 u8 msg_len;
102 u8 rsv1[3];
103 u16 msg[8];
104 };
105
106 struct hclge_vf_rst_cmd {
107 u8 dest_vfid;
108 u8 vf_rst;
109 u8 rsv[22];
110 };
111
112
113 struct hclgevf_mbx_arq_ring {
114 #define HCLGE_MBX_MAX_ARQ_MSG_SIZE 8
115 #define HCLGE_MBX_MAX_ARQ_MSG_NUM 1024
116 struct hclgevf_dev *hdev;
117 u32 head;
118 u32 tail;
119 atomic_t count;
120 u16 msg_q[HCLGE_MBX_MAX_ARQ_MSG_NUM][HCLGE_MBX_MAX_ARQ_MSG_SIZE];
121 };
122
123 #define hclge_mbx_ring_ptr_move_crq(crq) \
124 (crq->next_to_use = (crq->next_to_use + 1) % crq->desc_num)
125 #define hclge_mbx_tail_ptr_move_arq(arq) \
126 (arq.tail = (arq.tail + 1) % HCLGE_MBX_MAX_ARQ_MSG_SIZE)
127 #define hclge_mbx_head_ptr_move_arq(arq) \
128 (arq.head = (arq.head + 1) % HCLGE_MBX_MAX_ARQ_MSG_SIZE)
129 #endif