1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
/*
* Copyright (c) 2015-2016 Quantenna Communications, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef _QTN_FMAC_PCIE_IPC_H_
#define _QTN_FMAC_PCIE_IPC_H_
#include <linux/types.h>
#include "shm_ipc_defs.h"
/* bitmap for EP status and flags: updated by EP, read by RC */
#define QTN_EP_HAS_UBOOT BIT(0)
#define QTN_EP_HAS_FIRMWARE BIT(1)
#define QTN_EP_REQ_UBOOT BIT(2)
#define QTN_EP_REQ_FIRMWARE BIT(3)
#define QTN_EP_ERROR_UBOOT BIT(4)
#define QTN_EP_ERROR_FIRMWARE BIT(5)
#define QTN_EP_FW_LOADRDY BIT(8)
#define QTN_EP_FW_SYNC BIT(9)
#define QTN_EP_FW_RETRY BIT(10)
#define QTN_EP_FW_QLINK_DONE BIT(15)
#define QTN_EP_FW_DONE BIT(16)
/* bitmap for RC status and flags: updated by RC, read by EP */
#define QTN_RC_PCIE_LINK BIT(0)
#define QTN_RC_NET_LINK BIT(1)
#define QTN_RC_FW_FLASHBOOT BIT(5)
#define QTN_RC_FW_QLINK BIT(7)
#define QTN_RC_FW_LOADRDY BIT(8)
#define QTN_RC_FW_SYNC BIT(9)
/* state transition timeouts */
#define QTN_FW_DL_TIMEOUT_MS 3000
#define QTN_FW_QLINK_TIMEOUT_MS 30000
#define PCIE_HDP_INT_RX_BITS (0 \
| PCIE_HDP_INT_EP_TXDMA \
| PCIE_HDP_INT_EP_TXEMPTY \
)
#define PCIE_HDP_INT_TX_BITS (0 \
| PCIE_HDP_INT_EP_RXDMA \
)
#if BITS_PER_LONG == 64
#define QTN_HOST_HI32(a) ((u32)(((u64)a) >> 32))
#define QTN_HOST_LO32(a) ((u32)(((u64)a) & 0xffffffffUL))
#define QTN_HOST_ADDR(h, l) ((((u64)h) << 32) | ((u64)l))
#elif BITS_PER_LONG == 32
#define QTN_HOST_HI32(a) 0
#define QTN_HOST_LO32(a) ((u32)(((u32)a) & 0xffffffffUL))
#define QTN_HOST_ADDR(h, l) ((u32)l)
#else
#error Unexpected BITS_PER_LONG value
#endif
#define QTN_SYSCTL_BAR 0
#define QTN_SHMEM_BAR 2
#define QTN_DMA_BAR 3
#define QTN_PCIE_BDA_VERSION 0x1002
#define PCIE_BDA_NAMELEN 32
#define PCIE_HHBM_MAX_SIZE 512
#define SKB_BUF_SIZE 2048
#define QTN_PCIE_BOARDFLG "PCIEQTN"
#define QTN_PCIE_FW_DLMASK 0xF
#define QTN_PCIE_FW_BUFSZ 2048
#define QTN_ENET_ADDR_LENGTH 6
#define QTN_TXDONE_MASK ((u32)0x80000000)
#define QTN_GET_LEN(x) ((x) & 0xFFFF)
#define QTN_PCIE_TX_DESC_LEN_MASK 0xFFFF
#define QTN_PCIE_TX_DESC_LEN_SHIFT 0
#define QTN_PCIE_TX_DESC_PORT_MASK 0xF
#define QTN_PCIE_TX_DESC_PORT_SHIFT 16
#define QTN_PCIE_TX_DESC_TQE_BIT BIT(24)
#define QTN_EP_LHOST_TQE_PORT 4
enum qtnf_pcie_bda_ipc_flags {
QTN_PCIE_IPC_FLAG_HBM_MAGIC = BIT(0),
QTN_PCIE_IPC_FLAG_SHM_PIO = BIT(1),
};
struct qtnf_pcie_bda {
__le16 bda_len;
__le16 bda_version;
__le32 bda_pci_endian;
__le32 bda_ep_state;
__le32 bda_rc_state;
__le32 bda_dma_mask;
__le32 bda_msi_addr;
__le32 bda_flashsz;
u8 bda_boardname[PCIE_BDA_NAMELEN];
__le32 bda_rc_msi_enabled;
__le32 bda_hhbm_list[PCIE_HHBM_MAX_SIZE];
__le32 bda_dsbw_start_index;
__le32 bda_dsbw_end_index;
__le32 bda_dsbw_total_bytes;
__le32 bda_rc_tx_bd_base;
__le32 bda_rc_tx_bd_num;
u8 bda_pcie_mac[QTN_ENET_ADDR_LENGTH];
struct qtnf_shm_ipc_region bda_shm_reg1 __aligned(4096); /* host TX */
struct qtnf_shm_ipc_region bda_shm_reg2 __aligned(4096); /* host RX */
} __packed;
struct qtnf_tx_bd {
__le32 addr;
__le32 addr_h;
__le32 info;
__le32 info_h;
} __packed;
struct qtnf_rx_bd {
__le32 addr;
__le32 addr_h;
__le32 info;
__le32 info_h;
__le32 next_ptr;
__le32 next_ptr_h;
} __packed;
enum qtnf_fw_loadtype {
QTN_FW_DBEGIN,
QTN_FW_DSUB,
QTN_FW_DEND,
QTN_FW_CTRL
};
struct qtnf_pcie_fw_hdr {
u8 boardflg[8];
__le32 fwsize;
__le32 seqnum;
__le32 type;
__le32 pktlen;
__le32 crc;
} __packed;
#endif /* _QTN_FMAC_PCIE_IPC_H_ */
|