1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef HINIC_PORT_H
17#define HINIC_PORT_H
18
19#include <linux/types.h>
20#include <linux/etherdevice.h>
21#include <linux/bitops.h>
22
23#include "hinic_dev.h"
24
25enum hinic_rx_mode {
26 HINIC_RX_MODE_UC = BIT(0),
27 HINIC_RX_MODE_MC = BIT(1),
28 HINIC_RX_MODE_BC = BIT(2),
29 HINIC_RX_MODE_MC_ALL = BIT(3),
30 HINIC_RX_MODE_PROMISC = BIT(4),
31};
32
33enum hinic_port_link_state {
34 HINIC_LINK_STATE_DOWN,
35 HINIC_LINK_STATE_UP,
36};
37
38enum hinic_port_state {
39 HINIC_PORT_DISABLE = 0,
40 HINIC_PORT_ENABLE = 3,
41};
42
43enum hinic_func_port_state {
44 HINIC_FUNC_PORT_DISABLE = 0,
45 HINIC_FUNC_PORT_ENABLE = 2,
46};
47
48enum hinic_autoneg_cap {
49 HINIC_AUTONEG_UNSUPPORTED,
50 HINIC_AUTONEG_SUPPORTED,
51};
52
53enum hinic_autoneg_state {
54 HINIC_AUTONEG_DISABLED,
55 HINIC_AUTONEG_ACTIVE,
56};
57
58enum hinic_duplex {
59 HINIC_DUPLEX_HALF,
60 HINIC_DUPLEX_FULL,
61};
62
63enum hinic_speed {
64 HINIC_SPEED_10MB_LINK = 0,
65 HINIC_SPEED_100MB_LINK,
66 HINIC_SPEED_1000MB_LINK,
67 HINIC_SPEED_10GB_LINK,
68 HINIC_SPEED_25GB_LINK,
69 HINIC_SPEED_40GB_LINK,
70 HINIC_SPEED_100GB_LINK,
71
72 HINIC_SPEED_UNKNOWN = 0xFF,
73};
74
75struct hinic_port_mac_cmd {
76 u8 status;
77 u8 version;
78 u8 rsvd0[6];
79
80 u16 func_idx;
81 u16 vlan_id;
82 u16 rsvd1;
83 unsigned char mac[ETH_ALEN];
84};
85
86struct hinic_port_mtu_cmd {
87 u8 status;
88 u8 version;
89 u8 rsvd0[6];
90
91 u16 func_idx;
92 u16 rsvd1;
93 u32 mtu;
94};
95
96struct hinic_port_vlan_cmd {
97 u8 status;
98 u8 version;
99 u8 rsvd0[6];
100
101 u16 func_idx;
102 u16 vlan_id;
103};
104
105struct hinic_port_rx_mode_cmd {
106 u8 status;
107 u8 version;
108 u8 rsvd0[6];
109
110 u16 func_idx;
111 u16 rsvd;
112 u32 rx_mode;
113};
114
115struct hinic_port_link_cmd {
116 u8 status;
117 u8 version;
118 u8 rsvd0[6];
119
120 u16 func_idx;
121 u8 state;
122 u8 rsvd1;
123};
124
125struct hinic_port_state_cmd {
126 u8 status;
127 u8 version;
128 u8 rsvd0[6];
129
130 u8 state;
131 u8 rsvd1[3];
132};
133
134struct hinic_port_link_status {
135 u8 status;
136 u8 version;
137 u8 rsvd0[6];
138
139 u16 rsvd1;
140 u8 link;
141 u8 rsvd2;
142};
143
144struct hinic_port_func_state_cmd {
145 u8 status;
146 u8 version;
147 u8 rsvd0[6];
148
149 u16 func_idx;
150 u16 rsvd1;
151 u8 state;
152 u8 rsvd2[3];
153};
154
155struct hinic_port_cap {
156 u8 status;
157 u8 version;
158 u8 rsvd0[6];
159
160 u16 func_idx;
161 u16 rsvd1;
162 u8 port_type;
163 u8 autoneg_cap;
164 u8 autoneg_state;
165 u8 duplex;
166 u8 speed;
167 u8 rsvd2[3];
168};
169
170int hinic_port_add_mac(struct hinic_dev *nic_dev, const u8 *addr,
171 u16 vlan_id);
172
173int hinic_port_del_mac(struct hinic_dev *nic_dev, const u8 *addr,
174 u16 vlan_id);
175
176int hinic_port_get_mac(struct hinic_dev *nic_dev, u8 *addr);
177
178int hinic_port_set_mtu(struct hinic_dev *nic_dev, int new_mtu);
179
180int hinic_port_add_vlan(struct hinic_dev *nic_dev, u16 vlan_id);
181
182int hinic_port_del_vlan(struct hinic_dev *nic_dev, u16 vlan_id);
183
184int hinic_port_set_rx_mode(struct hinic_dev *nic_dev, u32 rx_mode);
185
186int hinic_port_link_state(struct hinic_dev *nic_dev,
187 enum hinic_port_link_state *link_state);
188
189int hinic_port_set_state(struct hinic_dev *nic_dev,
190 enum hinic_port_state state);
191
192int hinic_port_set_func_state(struct hinic_dev *nic_dev,
193 enum hinic_func_port_state state);
194
195int hinic_port_get_cap(struct hinic_dev *nic_dev,
196 struct hinic_port_cap *port_cap);
197
198#endif
199