aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/marvell/octeontx2/bphy/cnf10k_bphy_netdev_comm_if.h
blob: f9307b1e489e061c552487d5a63260eb0266334f (plain)
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/* SPDX-License-Identifier: GPL-2.0 */
/* Marvell CNF10K BPHY Netdev Driver
 *
 * Copyright (C) 2021 Marvell.
 */

#ifndef _CNF10K_BPHY_NETDEV_COMM_IF_H_
#define _CNF10K_BPHY_NETDEV_COMM_IF_H_

#include <linux/etherdevice.h>
#include "bphy_netdev_comm_if.h"

#define BPHY_MAX_RFOE_MHAB		8	/* Max RFOE MHAB instances */
#define BPHY_MAX_CPRI_MHAB		4	/* Max CPRI MHAB instances */

#define MAX_PTP_RING			4	/* Max ptp rings per lmac */

#define CNF10KB_VERSION			2	/* chip version */
#define CNF10KA_VERSION			3	/* chip version */

#define CHIP_CNF10KB(v)			(((v) == CNF10KB_VERSION) ? 1 : 0)
#define CHIP_CNF10KA(v)			(((v) == CNF10KA_VERSION) ? 1 : 0)

#define CHIP_CNF10K(v) ({ \
	typeof(v) _v = (v); \
	(CHIP_CNF10KB(_v) | CHIP_CNF10KA(_v)); \
})

/**
 * @enum BPHY_NETDEV_CPRI_RX_GP_INT_e_
 * @brief GP_INT numbers for CPRI Ethernet packet Rx notification
 *        by BPHY to netdev.
 *
 */
enum bphy_netdev_cpri_rx_gp_int {
	CNF10K_RX_GP_INT_CPRI0_ETH = 93, //PSM_GPINT93,
	CNF10K_RX_GP_INT_CPRI1_ETH = 94, //PSM_GPINT94,
	CNF10K_RX_GP_INT_CPRI2_ETH = 95, //PSM_GPINT95
};

/**
 * @enum BPHY_NETDEV_TX_GP_INT_e_
 * @brief GP_INT numbers for packet notification by netdev to BPHY.
 *
 */
#ifdef CNF10KB
enum bphy_netdev_tx_gp_int {
	CNF10K_TX_GP_INT_RFOE0_LMAC0     = 32, //PSM_GPINT32,
	CNF10K_TX_GP_INT_RFOE0_LMAC1     = 33, //PSM_GPINT33,

	CNF10K_TX_GP_INT_RFOE1_LMAC2     = 34, //PSM_GPINT34,
	CNF10K_TX_GP_INT_RFOE1_LMAC3     = 35, //PSM_GPINT35,

	CNF10K_TX_GP_INT_RFOE2_LMAC0     = 36, //PSM_GPINT36,
	CNF10K_TX_GP_INT_RFOE2_LMAC1     = 37, //PSM_GPINT37,

	CNF10K_TX_GP_INT_RFOE3_LMAC2     = 38, //PSM_GPINT38,
	CNF10K_TX_GP_INT_RFOE3_LMAC3     = 39, //PSM_GPINT39,

	CNF10K_TX_GP_INT_RFOE4_LMAC0     = 40, //PSM_GPINT40,
	CNF10K_TX_GP_INT_RFOE4_LMAC1     = 41, //PSM_GPINT41

	CNF10K_TX_GP_INT_RFOE5_LMAC0     = 42, //PSM_GPINT42,
	CNF10K_TX_GP_INT_RFOE5_LMAC1     = 43, //PSM_GPINT43,

	CNF10K_TX_GP_INT_RFOE6_LMAC2     = 44, //PSM_GPINT44,
	CNF10K_TX_GP_INT_RFOE6_LMAC3     = 45, //PSM_GPINT45,
};
#else
enum bphy_netdev_tx_gp_int {
	CNF10K_TX_GP_INT_RFOE0_LMAC0     = 32, //PSM_GPINT32,
	CNF10K_TX_GP_INT_RFOE0_LMAC1     = 33, //PSM_GPINT33,
	CNF10K_TX_GP_INT_RFOE0_LMAC2     = 34, //PSM_GPINT34,
	CNF10K_TX_GP_INT_RFOE0_LMAC3     = 35, //PSM_GPINT35,

	CNF10K_TX_GP_INT_RFOE1_LMAC0     = 36, //PSM_GPINT36,
	CNF10K_TX_GP_INT_RFOE1_LMAC1     = 37, //PSM_GPINT37,
	CNF10K_TX_GP_INT_RFOE1_LMAC2     = 38, //PSM_GPINT38,
	CNF10K_TX_GP_INT_RFOE1_LMAC3     = 39, //PSM_GPINT39,
};
#endif

/**
 * @enum BPHY_NETDEV_CNF10K_RX_GP_INT_e_
 * @brief GP_INT numbers for packet notification by BPHY to netdev.
 *
 */
enum bphy_netdev_rx_gp_int {
	CNF10K_RX_GP_INT_RFOE0_PTP       = 63, //PSM_GPINT63,
	CNF10K_RX_GP_INT_RFOE0_ECPRI     = 62, //PSM_GPINT62,
	CNF10K_RX_GP_INT_RFOE0_GENERIC   = 61, //PSM_GPINT61,

	CNF10K_RX_GP_INT_RFOE1_PTP       = 60, //PSM_GPINT60,
	CNF10K_RX_GP_INT_RFOE1_ECPRI     = 59, //PSM_GPINT59,
	CNF10K_RX_GP_INT_RFOE1_GENERIC   = 58, //PSM_GPINT58,
#ifdef CNF10KB
	CNF10K_RX_GP_INT_RFOE2_PTP       = 57, //PSM_GPINT57,
	CNF10K_RX_GP_INT_RFOE2_ECPRI     = 56, //PSM_GPINT56,
	CNF10K_RX_GP_INT_RFOE2_GENERIC   = 55, //PSM_GPINT55,

	CNF10K_RX_GP_INT_RFOE3_PTP       = 54, //PSM_GPINT54,
	CNF10K_RX_GP_INT_RFOE3_ECPRI     = 53, //PSM_GPINT53,
	CNF10K_RX_GP_INT_RFOE3_GENERIC   = 52, //PSM_GPINT52,

	CNF10K_RX_GP_INT_RFOE4_PTP       = 51, //PSM_GPINT51,
	CNF10K_RX_GP_INT_RFOE4_ECPRI     = 50, //PSM_GPINT50,
	CNF10K_RX_GP_INT_RFOE4_GENERIC   = 49, //PSM_GPINT49,

	CNF10K_RX_GP_INT_RFOE5_PTP       = 48, //PSM_GPINT48,
	CNF10K_RX_GP_INT_RFOE5_ECPRI     = 47, //PSM_GPINT47,
	CNF10K_RX_GP_INT_RFOE5_GENERIC   = 46, //PSM_GPINT46,

	CNF10K_RX_GP_INT_RFOE6_PTP       = 66, //PSM_GPINT66,
	CNF10K_RX_GP_INT_RFOE6_ECPRI     = 65, //PSM_GPINT65,
	CNF10K_RX_GP_INT_RFOE6_GENERIC   = 64, //PSM_GPINT64,
#endif
};

/**
 * @struct BPHY_NETDEV_RBUF_INFO_s
 * @brief Information about the packet ring buffer which shall be used to
 *        send the packets from BPHY to netdev.
 *
 */
struct cnf10k_bphy_ndev_rbuf_info {
	enum bphy_netdev_packet_type pkt_type;
	enum bphy_netdev_rx_gp_int gp_int_num;
	u16 flow_id;
	u16 mbt_index;
	/**Maximum number of buffers in the Ring/Pool*/
	u16 num_bufs;
	/**MAX Buffer Size configured */
	u16 buf_size; // TBC: 1536?
	/**MBT byffer target memory*/
	u8 mbt_target_mem;
	/**Buffers starting address*/
	u64 mbt_iova_addr;
	u16 jdt_index;
	/**Maximum number of JD buffers in the Ring/Pool*/
	u16 num_jd;
	/**MAX JD size configured */
	u8 jd_size;
	/**MBT byffer target memory*/
	u8 jdt_target_mem;
	/**Buffers starting address*/
	u64 jdt_iova_addr;
	u64 reserved[4];
};

/**
 * @struct BPHY_NETDEV_TX_PSM_CMD_INFO_s
 * @brief TX PSM command information defnition to be shared with
 *        netdev for TX communication.
 *
 */
struct cnf10k_bphy_ndev_tx_psm_cmd_info {
	enum bphy_netdev_tx_gp_int gp_int_num; // Valid only for PTP messages
	u64 jd_iova_addr;
	u64 rd_dma_iova_addr;
	u64 low_cmd;
	u64 high_cmd;
	u64 reserved[4];
};

/**
 * @struct BPHY_NETDEV_TX_PTP_RING_INFO_s
 * @brief TX PTP timestamp ring buffer configuration to be shared
 *        with netdev for reading ptp timestamp.
 *
 */
struct cnf10k_bphy_ndev_tx_ptp_ring_info {
	u8 is_enable;
	u8 ring_idx;
	/**Number of TX PTP timestamp entries in ring */
	u8 ring_size;
	/**PTP Ring buffer target memory*/
	u8 ring_target_mem;
	/**PTP Ring buffer byte swap mode when TMEM is LLC/DRAM*/
	u8 dswap;
	/**Stream ID*/
	u8 gmid;
	/**Buffers starting address*/
	u64 ring_iova_addr;
	u64 reserved[4];
};

/**
 * @struct cnf10k_bphy_netdev_intf_info
 * @brief LMAC lane number, mac address and status information
 *
 */
struct cnf10k_bphy_ndev_intf_info {
	u8 rfoe_num;
	u8 lane_num;
	/* Source mac address */
	u8 eth_addr[ETH_ALEN];
	/* LMAC interface status */
	u8 status; //0-DOWN, 1-UP
	/* Configuration valid status; This interface shall be
	 * invalid if this field is set to 0
	 */
	u8 is_valid;
	u64 reserved;
};

/**
 * @struct BPHY_NETDEV_COMM_IF_s
 * @brief The communication interface defnitions which would be used
 *        by the netdev and bphy application.
 *
 */
struct cnf10k_bphy_ndev_comm_if {
	struct cnf10k_bphy_ndev_intf_info lmac_info;
	struct cnf10k_bphy_ndev_rbuf_info rbuf_info[PACKET_TYPE_MAX];
	/** Defining single array to handle both PTP and OTHER cmds info.
	 */
	struct cnf10k_bphy_ndev_tx_psm_cmd_info
					ptp_pkt_info[MAX_PTP_MSG_PER_LMAC];
	struct cnf10k_bphy_ndev_tx_ptp_ring_info
					ptp_ts_ring_info[MAX_PTP_RING];
	u64 reserved[4];
};

/**
 * @struct BPHY_NETDEV_CPRI_IF_s
 * @brief Communication interface structure defnition to be used by BPHY
 *        and NETDEV applications for CPRI Interface.
 *
 */
struct cnf10k_bphy_ndev_cpri_intf_cfg {
	u8 id;                 /**< CPRI_ID 0..2 */
	u8 active_lane_mask;   /**< Lane Id mask */
	u8 ul_gp_int_num;      /**< UL GP INT NUM */
	u8 ul_int_threshold;   /**< UL INT THRESHOLD */
	u8 num_ul_buf;         /**< Num UL Buffers */
	u8 num_dl_buf;         /**< Num DL Buffers */
	u64 ul_circ_buf_iova_addr; /**< UL circular buffer base address */
	u64 dl_circ_buf_iova_addr; /**< DL circular buffer base address */
	u8 eth_addr[MAX_LANE_PER_CPRI][ETH_ALEN];
	u64 reserved[4];
};

/**
 * @struct BPHY_NETDEV_RFOE_10x_IF_s
 * @brief New Communication interface structure defnition to be used
 *        by BPHY and NETDEV applications for RFOE Interface.
 *
 */
struct cnf10k_bphy_ndev_rfoe_if {
	/**< Interface configuration */
	struct cnf10k_bphy_ndev_comm_if if_cfg[MAX_LMAC_PER_RFOE];
	/**TX JD cmds to send packets other than PTP;
	 * These are defined per RFoE and all LMAC can share
	 */
	struct cnf10k_bphy_ndev_tx_psm_cmd_info
					oth_pkt_info[MAX_OTH_MSG_PER_RFOE];
	/**Packet types for which the RX flows are configured.*/
	u8 pkt_type_mask;
	u64 reserved[4];
};

/* hardware specific information */
struct bphy_hw_params {
	u32 chip_ver;		/* (version << 4) | revision */
	u32 reserved[15];	/* reserved for future extension */
};

/**
 * @struct BPHY_NETDEV_COMM_INTF_CFG_s
 * @brief ODP-NETDEV communication interface defnition structure to
 *        share the RX/TX intrefaces information.
 *
 */
struct cnf10k_rfoe_ndev_comm_intf_cfg {
	/**< BPHY Hardware parameters */
	struct bphy_hw_params hw_params;
	/**< RFOE Interface Configuration */
	struct cnf10k_bphy_ndev_rfoe_if rfoe_if_cfg[BPHY_MAX_RFOE_MHAB];
	u64 reserved[4];
};

/**
 * @struct BPHY_CPRI_NETDEV_COMM_INTF_CFG_s
 * @brief Main Communication interface structure definition to be used
 *        by BPHY and NETDEV applications for CPRI Interface.
 *
 */
struct cnf10k_bphy_cpri_netdev_comm_intf_cfg {
	/**< BPHY Hardware parameters */
	struct bphy_hw_params hw_params;
	/**< RFOE Interface Configuration */
	struct cnf10k_bphy_ndev_cpri_intf_cfg cpri_if_cfg[BPHY_MAX_CPRI_MHAB];
	u64 reserved[4];
};

#endif //_CNF10K_BPHY_NETDEV_COMM_IF_H_