1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Marvell Octeon EP (EndPoint) Ethernet Driver
4 * Copyright (C) 2020 Marvell.
7 #ifndef __OCTEP_CTRL_NET_H__
8 #define __OCTEP_CTRL_NET_H__
10 #include "octep_cp_version.h"
12 #define OCTEP_CTRL_NET_INVALID_VFID (-1)
14 /* Supported commands */
15 enum octep_ctrl_net_cmd {
16 OCTEP_CTRL_NET_CMD_GET = 0,
17 OCTEP_CTRL_NET_CMD_SET,
20 /* Supported states */
21 enum octep_ctrl_net_state {
22 OCTEP_CTRL_NET_STATE_DOWN = 0,
23 OCTEP_CTRL_NET_STATE_UP,
26 /* Supported replies */
27 enum octep_ctrl_net_reply {
28 OCTEP_CTRL_NET_REPLY_OK = 0,
29 OCTEP_CTRL_NET_REPLY_GENERIC_FAIL,
30 OCTEP_CTRL_NET_REPLY_INVALID_PARAM,
33 /* Supported host to fw commands */
34 enum octep_ctrl_net_h2f_cmd {
35 OCTEP_CTRL_NET_H2F_CMD_INVALID = 0,
36 OCTEP_CTRL_NET_H2F_CMD_MTU,
37 OCTEP_CTRL_NET_H2F_CMD_MAC,
38 OCTEP_CTRL_NET_H2F_CMD_GET_IF_STATS,
39 OCTEP_CTRL_NET_H2F_CMD_GET_XSTATS,
40 OCTEP_CTRL_NET_H2F_CMD_GET_Q_STATS,
41 OCTEP_CTRL_NET_H2F_CMD_LINK_STATUS,
42 OCTEP_CTRL_NET_H2F_CMD_RX_STATE,
43 OCTEP_CTRL_NET_H2F_CMD_LINK_INFO,
44 OCTEP_CTRL_NET_H2F_CMD_GET_INFO,
45 OCTEP_CTRL_NET_H2F_CMD_DEV_REMOVE,
46 OCTEP_CTRL_NET_H2F_CMD_OFFLOADS,
47 OCTEP_CTRL_NET_H2F_CMD_MAX
50 /* Supported fw to host commands */
51 enum octep_ctrl_net_f2h_cmd {
52 OCTEP_CTRL_NET_F2H_CMD_INVALID = 0,
53 OCTEP_CTRL_NET_F2H_CMD_LINK_STATUS,
54 OCTEP_CTRL_NET_F2H_CMD_MAX
57 union octep_ctrl_net_req_hdr {
64 /* octep_ctrl_net_h2t_cmd */
71 /* get/set mtu request */
72 struct octep_ctrl_net_h2f_req_cmd_mtu {
73 /* enum octep_ctrl_net_cmd */
79 /* get/set mac request */
80 struct octep_ctrl_net_h2f_req_cmd_mac {
81 /* enum octep_ctrl_net_cmd */
83 /* xx:xx:xx:xx:xx:xx */
87 /* get/set link state, rx state */
88 struct octep_ctrl_net_h2f_req_cmd_state {
89 /* enum octep_ctrl_net_cmd */
91 /* enum octep_ctrl_net_state */
96 struct octep_ctrl_net_link_info {
97 /* Bitmap of Supported link speeds/modes */
99 /* Bitmap of Advertised link speeds/modes */
100 u64 advertised_modes;
101 /* Autonegotation state; bit 0=disabled; bit 1=enabled */
103 /* Pause frames setting. bit 0=disabled; bit 1=enabled */
105 /* Negotiated link speed in Mbps */
109 /* get/set link info */
110 struct octep_ctrl_net_h2f_req_cmd_link_info {
111 /* enum octep_ctrl_net_cmd */
113 /* struct octep_ctrl_net_link_info */
114 struct octep_ctrl_net_link_info info;
118 struct octep_ctrl_net_offloads {
119 /* supported rx offloads OCTEP_RX_OFFLOAD_* */
121 /* supported tx offloads OCTEP_TX_OFFLOAD_* */
124 u32 reserved_offloads;
129 /* get/set offloads */
130 struct octep_ctrl_net_h2f_req_cmd_offloads {
131 /* enum octep_ctrl_net_cmd */
133 /* struct octep_ctrl_net_offloads */
134 struct octep_ctrl_net_offloads offloads;
137 /* Host to fw request data */
138 struct octep_ctrl_net_h2f_req {
139 union octep_ctrl_net_req_hdr hdr;
141 struct octep_ctrl_net_h2f_req_cmd_mtu mtu;
142 struct octep_ctrl_net_h2f_req_cmd_mac mac;
143 struct octep_ctrl_net_h2f_req_cmd_state link;
144 struct octep_ctrl_net_h2f_req_cmd_state rx;
145 struct octep_ctrl_net_h2f_req_cmd_link_info link_info;
146 struct octep_ctrl_net_h2f_req_cmd_offloads offloads;
150 union octep_ctrl_net_resp_hdr {
157 /* octep_ctrl_net_h2t_cmd */
159 /* octep_ctrl_net_reply */
164 /* get mtu response */
165 struct octep_ctrl_net_h2f_resp_cmd_mtu {
170 /* get mac response */
171 struct octep_ctrl_net_h2f_resp_cmd_mac {
172 /* xx:xx:xx:xx:xx:xx */
176 /* get if_stats, xstats, q_stats request */
177 struct octep_ctrl_net_h2f_resp_cmd_get_stats {
178 struct octep_iface_rx_stats rx_stats;
179 struct octep_iface_tx_stats tx_stats;
182 /* get link state, rx state response */
183 struct octep_ctrl_net_h2f_resp_cmd_state {
184 /* enum octep_ctrl_net_state */
188 /* get info request */
189 struct octep_ctrl_net_h2f_resp_cmd_get_info {
190 struct octep_fw_info fw_info;
193 /* Host to fw response data */
194 struct octep_ctrl_net_h2f_resp {
195 union octep_ctrl_net_resp_hdr hdr;
197 struct octep_ctrl_net_h2f_resp_cmd_mtu mtu;
198 struct octep_ctrl_net_h2f_resp_cmd_mac mac;
199 struct octep_ctrl_net_h2f_resp_cmd_get_stats if_stats;
200 struct octep_ctrl_net_h2f_resp_cmd_state link;
201 struct octep_ctrl_net_h2f_resp_cmd_state rx;
202 struct octep_ctrl_net_link_info link_info;
203 struct octep_ctrl_net_h2f_resp_cmd_get_info info;
204 struct octep_ctrl_net_offloads offloads;
208 /* link state notofication */
209 struct octep_ctrl_net_f2h_req_cmd_state {
210 /* enum octep_ctrl_net_state */
214 /* Fw to host request data */
215 struct octep_ctrl_net_f2h_req {
216 union octep_ctrl_net_req_hdr hdr;
218 struct octep_ctrl_net_f2h_req_cmd_state link;
222 /* Fw to host response data */
223 struct octep_ctrl_net_f2h_resp {
224 union octep_ctrl_net_resp_hdr hdr;
227 /* Max data size to be transferred over mbox */
228 union octep_ctrl_net_max_data {
229 struct octep_ctrl_net_h2f_req h2f_req;
230 struct octep_ctrl_net_h2f_resp h2f_resp;
231 struct octep_ctrl_net_f2h_req f2h_req;
232 struct octep_ctrl_net_f2h_resp f2h_resp;
235 struct octep_ctrl_net_wait_data {
236 struct list_head list;
238 struct octep_ctrl_mbox_msg msg;
240 struct octep_ctrl_net_h2f_req req;
241 struct octep_ctrl_net_h2f_resp resp;
246 * octep_ctrl_net_init() - Initialize data for ctrl net.
248 * @oct: non-null pointer to struct octep_device.
250 * return value: 0 on success, -errno on error.
252 int octep_ctrl_net_init(struct octep_device *oct);
255 * octep_ctrl_net_get_link_status() - Get link status from firmware.
257 * @oct: non-null pointer to struct octep_device.
258 * @vfid: Index of virtual function.
260 * return value: link status 0=down, 1=up.
262 int octep_ctrl_net_get_link_status(struct octep_device *oct, int vfid);
265 * octep_ctrl_net_set_link_status() - Set link status in firmware.
267 * @oct: non-null pointer to struct octep_device.
268 * @vfid: Index of virtual function.
269 * @up: boolean status.
270 * @wait_for_response: poll for response.
272 * return value: 0 on success, -errno on failure
274 int octep_ctrl_net_set_link_status(struct octep_device *oct, int vfid, bool up,
275 bool wait_for_response);
278 * octep_ctrl_net_set_rx_state() - Set rx state in firmware.
280 * @oct: non-null pointer to struct octep_device.
281 * @vfid: Index of virtual function.
282 * @up: boolean status.
283 * @wait_for_response: poll for response.
285 * return value: 0 on success, -errno on failure.
287 int octep_ctrl_net_set_rx_state(struct octep_device *oct, int vfid, bool up,
288 bool wait_for_response);
291 * octep_ctrl_net_get_mac_addr() - Get mac address from firmware.
293 * @oct: non-null pointer to struct octep_device.
294 * @vfid: Index of virtual function.
295 * @addr: non-null pointer to mac address.
297 * return value: 0 on success, -errno on failure.
299 int octep_ctrl_net_get_mac_addr(struct octep_device *oct, int vfid, u8 *addr);
302 * octep_ctrl_net_set_mac_addr() - Set mac address in firmware.
304 * @oct: non-null pointer to struct octep_device.
305 * @vfid: Index of virtual function.
306 * @addr: non-null pointer to mac address.
307 * @wait_for_response: poll for response.
309 * return value: 0 on success, -errno on failure.
311 int octep_ctrl_net_set_mac_addr(struct octep_device *oct, int vfid, u8 *addr,
312 bool wait_for_response);
315 * octep_ctrl_net_get_mtu() - Get max MTU from firmware.
317 * @oct: non-null pointer to struct octep_device.
318 * @vfid: Index of virtual function.
320 * return value: mtu on success, -errno on failure.
322 int octep_ctrl_net_get_mtu(struct octep_device *oct, int vfid);
325 * octep_ctrl_net_set_mtu() - Set mtu in firmware.
327 * @oct: non-null pointer to struct octep_device.
328 * @vfid: Index of virtual function.
330 * @wait_for_response: poll for response.
332 * return value: 0 on success, -errno on failure.
334 int octep_ctrl_net_set_mtu(struct octep_device *oct, int vfid, int mtu,
335 bool wait_for_response);
338 * octep_ctrl_net_get_if_stats() - Get interface statistics from firmware.
340 * @oct: non-null pointer to struct octep_device.
341 * @vfid: Index of virtual function.
342 * @rx_stats: non-null pointer struct octep_iface_rx_stats.
343 * @tx_stats: non-null pointer struct octep_iface_tx_stats.
345 * return value: 0 on success, -errno on failure.
347 int octep_ctrl_net_get_if_stats(struct octep_device *oct, int vfid,
348 struct octep_iface_rx_stats *rx_stats,
349 struct octep_iface_tx_stats *tx_stats);
352 * octep_ctrl_net_get_link_info() - Get link info from firmware.
354 * @oct: non-null pointer to struct octep_device.
355 * @vfid: Index of virtual function.
356 * @link_info: non-null pointer to struct octep_iface_link_info.
358 * return value: 0 on success, -errno on failure.
360 int octep_ctrl_net_get_link_info(struct octep_device *oct, int vfid,
361 struct octep_iface_link_info *link_info);
364 * octep_ctrl_net_set_link_info() - Set link info in firmware.
366 * @oct: non-null pointer to struct octep_device.
367 * @vfid: Index of virtual function.
368 * @link_info: non-null pointer to struct octep_iface_link_info.
369 * @wait_for_response: poll for response.
371 * return value: 0 on success, -errno on failure.
373 int octep_ctrl_net_set_link_info(struct octep_device *oct,
375 struct octep_iface_link_info *link_info,
376 bool wait_for_response);
379 * octep_ctrl_net_recv_fw_messages() - Poll for firmware messages and process them.
381 * @oct: non-null pointer to struct octep_device.
383 void octep_ctrl_net_recv_fw_messages(struct octep_device *oct);
386 * octep_ctrl_net_get_info() - Get info from firmware.
388 * @oct: non-null pointer to struct octep_device.
389 * @vfid: Index of virtual function.
390 * @info: non-null pointer to struct octep_fw_info.
392 * return value: 0 on success, -errno on failure.
394 int octep_ctrl_net_get_info(struct octep_device *oct, int vfid,
395 struct octep_fw_info *info);
398 * octep_ctrl_net_dev_remove() - Indicate to firmware that a device unload has happened.
400 * @oct: non-null pointer to struct octep_device.
401 * @vfid: Index of virtual function.
403 * return value: 0 on success, -errno on failure.
405 int octep_ctrl_net_dev_remove(struct octep_device *oct, int vfid);
408 * octep_ctrl_net_set_offloads() - Set offloads in firmware.
410 * @oct: non-null pointer to struct octep_device.
411 * @vfid: Index of virtual function.
412 * @offloads: non-null pointer to struct octep_ctrl_net_offloads.
413 * @wait_for_response: poll for response.
415 * return value: 0 on success, -errno on failure.
417 int octep_ctrl_net_set_offloads(struct octep_device *oct, int vfid,
418 struct octep_ctrl_net_offloads *offloads,
419 bool wait_for_response);
422 * octep_ctrl_net_uninit() - Uninitialize data for ctrl net.
424 * @oct: non-null pointer to struct octep_device.
426 * return value: 0 on success, -errno on error.
428 int octep_ctrl_net_uninit(struct octep_device *oct);
430 #endif /* __OCTEP_CTRL_NET_H__ */