xref: /linux/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.h (revision 24f171c7e145f43b9f187578e89b0982ce87e54c)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2020 - 2025 Mucse Corporation. */
3 
4 #ifndef _RNPGBE_MBX_FW_H
5 #define _RNPGBE_MBX_FW_H
6 
7 #include <linux/types.h>
8 
9 #include "rnpgbe.h"
10 
11 #define MUCSE_MBX_REQ_HDR_LEN 24
12 
13 enum MUCSE_FW_CMD {
14 	GET_HW_INFO     = 0x0601,
15 	GET_MAC_ADDRESS = 0x0602,
16 	RESET_HW        = 0x0603,
17 	POWER_UP        = 0x0803,
18 };
19 
20 struct mucse_hw_info {
21 	u8 link_stat;
22 	u8 port_mask;
23 	__le32 speed;
24 	__le16 phy_type;
25 	__le16 nic_mode;
26 	__le16 pfnum;
27 	__le32 fw_version;
28 	__le32 axi_mhz;
29 	union {
30 		u8 port_id[4];
31 		__le32 port_ids;
32 	};
33 	__le32 bd_uid;
34 	__le32 phy_id;
35 	__le32 wol_status;
36 	__le32 ext_info;
37 } __packed;
38 
39 struct mbx_fw_cmd_req {
40 	__le16 flags;
41 	__le16 opcode;
42 	__le16 datalen;
43 	__le16 ret_value;
44 	__le32 cookie_lo;
45 	__le32 cookie_hi;
46 	__le32 reply_lo;
47 	__le32 reply_hi;
48 	union {
49 		u8 data[32];
50 		struct {
51 			__le32 version;
52 			__le32 status;
53 		} powerup;
54 		struct {
55 			__le32 port_mask;
56 			__le32 pfvf_num;
57 		} get_mac_addr;
58 	};
59 } __packed;
60 
61 struct mbx_fw_cmd_reply {
62 	__le16 flags;
63 	__le16 opcode;
64 	__le16 error_code;
65 	__le16 datalen;
66 	__le32 cookie_lo;
67 	__le32 cookie_hi;
68 	union {
69 		u8 data[40];
70 		struct mac_addr {
71 			__le32 ports;
72 			struct _addr {
73 				/* for macaddr:01:02:03:04:05:06
74 				 * mac-hi=0x01020304 mac-lo=0x05060000
75 				 */
76 				u8 mac[8];
77 			} addrs[4];
78 		} mac_addr;
79 		struct mucse_hw_info hw_info;
80 	};
81 } __packed;
82 
83 int mucse_mbx_sync_fw(struct mucse_hw *hw);
84 int mucse_mbx_powerup(struct mucse_hw *hw, bool is_powerup);
85 int mucse_mbx_reset_hw(struct mucse_hw *hw);
86 int mucse_mbx_get_macaddr(struct mucse_hw *hw, int pfvfnum,
87 			  u8 *mac_addr, int port);
88 #endif /* _RNPGBE_MBX_FW_H */
89