net/iavf: fix mbuf leak
[dpdk.git] / drivers / net / hinic / base / hinic_pmd_mbox.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Huawei Technologies Co., Ltd
3  */
4
5 #ifndef _HINIC_PMD_MBOX_H_
6 #define _HINIC_PMD_MBOX_H_
7
8 #define HINIC_MBOX_PF_SEND_ERR          0x1
9 #define HINIC_MBOX_PF_BUSY_ACTIVE_FW    0x2
10 #define HINIC_MBOX_VF_CMD_ERROR         0x3
11
12 /* PFs do not support enable SR-IOV cap when PFs use PMD, VFs just receive
13  * mailbox message from PFs. The max number of PFs is 16, so the max number
14  * of mailbox buffer for functions is also 16.
15  */
16 #define HINIC_MAX_FUNCTIONS             16
17 #define HINIC_MAX_PF_FUNCS              16
18
19 #define HINIC_MGMT_CMD_UNSUPPORTED      0xFF
20
21 #define HINIC_SEQ_ID_MAX_VAL            42
22 #define HINIC_MSG_SEG_LEN               48
23
24 enum hinic_mbox_ack_type {
25         MBOX_ACK,
26         MBOX_NO_ACK,
27 };
28
29 struct mbox_msg_info {
30         u8 msg_id;
31         u8 status; /*can only use 6 bit*/
32 };
33
34 struct hinic_recv_mbox {
35         void *mbox;
36         u8 cmd;
37         enum hinic_mod_type mod;
38         u16 mbox_len;
39         void *buf_out;
40         enum hinic_mbox_ack_type ack_type;
41         struct mbox_msg_info msg_info;
42         u8 seq_id;
43 };
44
45 struct hinic_send_mbox {
46         u8 *data;
47         volatile u64 *wb_status;
48         void *wb_vaddr;
49         dma_addr_t wb_paddr;
50 };
51
52 enum mbox_event_state {
53         EVENT_START = 0,
54         EVENT_TIMEOUT,
55         EVENT_END,
56 };
57
58 struct hinic_mbox_func_to_func {
59         struct hinic_hwdev *hwdev;
60
61         pthread_mutex_t     mbox_send_mutex;
62         pthread_mutex_t     msg_send_mutex;
63
64         struct hinic_send_mbox send_mbox;
65
66         struct hinic_recv_mbox mbox_resp[HINIC_MAX_FUNCTIONS];
67         struct hinic_recv_mbox mbox_send[HINIC_MAX_FUNCTIONS];
68
69         struct hinic_eq *ack_aeq;
70         struct hinic_eq *recv_aeq;
71
72         u8 send_msg_id;
73         enum mbox_event_state event_flag;
74         spinlock_t mbox_lock; /* lock for mbox event flag */
75 };
76
77 /*
78  * mbox function prototypes
79  */
80 int hinic_comm_func_to_func_init(struct hinic_hwdev *hwdev);
81 void hinic_comm_func_to_func_free(struct hinic_hwdev *hwdev);
82 int hinic_mbox_func_aeqe_handler(void *handle, u8 *header,
83                                         u8 size, void *param);
84 int hinic_mbox_to_pf(struct hinic_hwdev *hwdev, enum hinic_mod_type mod, u8 cmd,
85                         void *buf_in, u16 in_size,
86                         void *buf_out, u16 *out_size, u32 timeout);
87 int hinic_mbox_to_pf_no_ack(struct hinic_hwdev *hwdev, enum hinic_mod_type mod,
88                                 u8 cmd, void *buf_in, u16 in_size);
89
90 #endif /* _HINIC_PMD_MBOX_H_ */