net/ngbe: support flow control
[dpdk.git] / drivers / net / ngbe / base / ngbe_mng.h
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_MNG_H_
7 #define _NGBE_MNG_H_
8
9 #include "ngbe_type.h"
10
11 #define NGBE_PMMBX_QSIZE       64 /* Num of dwords in range */
12 #define NGBE_PMMBX_BSIZE       (NGBE_PMMBX_QSIZE * 4)
13 #define NGBE_PMMBX_DATA_SIZE   (NGBE_PMMBX_BSIZE - FW_NVM_DATA_OFFSET * 4)
14 #define NGBE_HI_COMMAND_TIMEOUT        5000 /* Process HI command limit */
15
16 /* CEM Support */
17 #define FW_CEM_MAX_RETRIES              3
18 #define FW_CEM_RESP_STATUS_SUCCESS      0x1
19 #define FW_READ_SHADOW_RAM_CMD          0x31
20 #define FW_READ_SHADOW_RAM_LEN          0x6
21 #define FW_DEFAULT_CHECKSUM             0xFF /* checksum always 0xFF */
22 #define FW_NVM_DATA_OFFSET              3
23 #define FW_EEPROM_CHECK_STATUS          0xE9
24
25 #define FW_CHECKSUM_CAP_ST_PASS 0x80658383
26 #define FW_CHECKSUM_CAP_ST_FAIL 0x70657376
27
28 /* Host Interface Command Structures */
29 struct ngbe_hic_hdr {
30         u8 cmd;
31         u8 buf_len;
32         union {
33                 u8 cmd_resv;
34                 u8 ret_status;
35         } cmd_or_resp;
36         u8 checksum;
37 };
38
39 struct ngbe_hic_hdr2_req {
40         u8 cmd;
41         u8 buf_lenh;
42         u8 buf_lenl;
43         u8 checksum;
44 };
45
46 struct ngbe_hic_hdr2_rsp {
47         u8 cmd;
48         u8 buf_lenl;
49         u8 ret_status;     /* 7-5: high bits of buf_len, 4-0: status */
50         u8 checksum;
51 };
52
53 union ngbe_hic_hdr2 {
54         struct ngbe_hic_hdr2_req req;
55         struct ngbe_hic_hdr2_rsp rsp;
56 };
57
58 /* These need to be dword aligned */
59 struct ngbe_hic_read_shadow_ram {
60         union ngbe_hic_hdr2 hdr;
61         u32 address;
62         u16 length;
63         u16 pad2;
64         u16 data;
65         u16 pad3;
66 };
67
68 s32 ngbe_hic_sr_read(struct ngbe_hw *hw, u32 addr, u8 *buf, int len);
69 s32 ngbe_hic_check_cap(struct ngbe_hw *hw);
70 #endif /* _NGBE_MNG_H_ */