OSDN Git Service

4115d08d825592a7e4b564b372ead3ac63ac091a
[tomoyo/tomoyo-test1.git] / drivers / net / ethernet / huawei / hinic / hinic_port.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Huawei HiNIC PCI Express Linux driver
4  * Copyright(c) 2017 Huawei Technologies Co., Ltd
5  */
6
7 #ifndef HINIC_PORT_H
8 #define HINIC_PORT_H
9
10 #include <linux/types.h>
11 #include <linux/etherdevice.h>
12 #include <linux/bitops.h>
13
14 #include "hinic_dev.h"
15
16 enum hinic_rx_mode {
17         HINIC_RX_MODE_UC        = BIT(0),
18         HINIC_RX_MODE_MC        = BIT(1),
19         HINIC_RX_MODE_BC        = BIT(2),
20         HINIC_RX_MODE_MC_ALL    = BIT(3),
21         HINIC_RX_MODE_PROMISC   = BIT(4),
22 };
23
24 enum hinic_port_link_state {
25         HINIC_LINK_STATE_DOWN,
26         HINIC_LINK_STATE_UP,
27 };
28
29 enum hinic_port_state {
30         HINIC_PORT_DISABLE      = 0,
31         HINIC_PORT_ENABLE       = 3,
32 };
33
34 enum hinic_func_port_state {
35         HINIC_FUNC_PORT_DISABLE = 0,
36         HINIC_FUNC_PORT_ENABLE  = 2,
37 };
38
39 enum hinic_autoneg_cap {
40         HINIC_AUTONEG_UNSUPPORTED,
41         HINIC_AUTONEG_SUPPORTED,
42 };
43
44 enum hinic_autoneg_state {
45         HINIC_AUTONEG_DISABLED,
46         HINIC_AUTONEG_ACTIVE,
47 };
48
49 enum hinic_duplex {
50         HINIC_DUPLEX_HALF,
51         HINIC_DUPLEX_FULL,
52 };
53
54 enum hinic_speed {
55         HINIC_SPEED_10MB_LINK = 0,
56         HINIC_SPEED_100MB_LINK,
57         HINIC_SPEED_1000MB_LINK,
58         HINIC_SPEED_10GB_LINK,
59         HINIC_SPEED_25GB_LINK,
60         HINIC_SPEED_40GB_LINK,
61         HINIC_SPEED_100GB_LINK,
62
63         HINIC_SPEED_UNKNOWN = 0xFF,
64 };
65
66 enum hinic_tso_state {
67         HINIC_TSO_DISABLE = 0,
68         HINIC_TSO_ENABLE  = 1,
69 };
70
71 struct hinic_port_mac_cmd {
72         u8              status;
73         u8              version;
74         u8              rsvd0[6];
75
76         u16             func_idx;
77         u16             vlan_id;
78         u16             rsvd1;
79         unsigned char   mac[ETH_ALEN];
80 };
81
82 struct hinic_port_mtu_cmd {
83         u8      status;
84         u8      version;
85         u8      rsvd0[6];
86
87         u16     func_idx;
88         u16     rsvd1;
89         u32     mtu;
90 };
91
92 struct hinic_port_vlan_cmd {
93         u8      status;
94         u8      version;
95         u8      rsvd0[6];
96
97         u16     func_idx;
98         u16     vlan_id;
99 };
100
101 struct hinic_port_rx_mode_cmd {
102         u8      status;
103         u8      version;
104         u8      rsvd0[6];
105
106         u16     func_idx;
107         u16     rsvd;
108         u32     rx_mode;
109 };
110
111 struct hinic_port_link_cmd {
112         u8      status;
113         u8      version;
114         u8      rsvd0[6];
115
116         u16     func_idx;
117         u8      state;
118         u8      rsvd1;
119 };
120
121 struct hinic_port_state_cmd {
122         u8      status;
123         u8      version;
124         u8      rsvd0[6];
125
126         u8      state;
127         u8      rsvd1[3];
128 };
129
130 struct hinic_port_link_status {
131         u8      status;
132         u8      version;
133         u8      rsvd0[6];
134
135         u16     rsvd1;
136         u8      link;
137         u8      rsvd2;
138 };
139
140 struct hinic_port_func_state_cmd {
141         u8      status;
142         u8      version;
143         u8      rsvd0[6];
144
145         u16     func_idx;
146         u16     rsvd1;
147         u8      state;
148         u8      rsvd2[3];
149 };
150
151 struct hinic_port_cap {
152         u8      status;
153         u8      version;
154         u8      rsvd0[6];
155
156         u16     func_idx;
157         u16     rsvd1;
158         u8      port_type;
159         u8      autoneg_cap;
160         u8      autoneg_state;
161         u8      duplex;
162         u8      speed;
163         u8      rsvd2[3];
164 };
165
166 struct hinic_tso_config {
167         u8      status;
168         u8      version;
169         u8      rsvd0[6];
170
171         u16     func_id;
172         u16     rsvd1;
173         u8      tso_en;
174         u8      resv2[3];
175 };
176
177 struct hinic_checksum_offload {
178         u8      status;
179         u8      version;
180         u8      rsvd0[6];
181
182         u16     func_id;
183         u16     rsvd1;
184         u32     rx_csum_offload;
185 };
186
187 struct hinic_rq_num {
188         u8      status;
189         u8      version;
190         u8      rsvd0[6];
191
192         u16     func_id;
193         u16     rsvd1[33];
194         u32     num_rqs;
195         u32     rq_depth;
196 };
197
198 struct hinic_lro_config {
199         u8      status;
200         u8      version;
201         u8      rsvd0[6];
202
203         u16     func_id;
204         u16     rsvd1;
205         u8      lro_ipv4_en;
206         u8      lro_ipv6_en;
207         u8      lro_max_wqe_num;
208         u8      resv2[13];
209 };
210
211 struct hinic_lro_timer {
212         u8      status;
213         u8      version;
214         u8      rsvd0[6];
215
216         u8      type;   /* 0: set timer value, 1: get timer value */
217         u8      enable; /* when set lro time, enable should be 1 */
218         u16     rsvd1;
219         u32     timer;
220 };
221
222 int hinic_port_add_mac(struct hinic_dev *nic_dev, const u8 *addr,
223                        u16 vlan_id);
224
225 int hinic_port_del_mac(struct hinic_dev *nic_dev, const u8 *addr,
226                        u16 vlan_id);
227
228 int hinic_port_get_mac(struct hinic_dev *nic_dev, u8 *addr);
229
230 int hinic_port_set_mtu(struct hinic_dev *nic_dev, int new_mtu);
231
232 int hinic_port_add_vlan(struct hinic_dev *nic_dev, u16 vlan_id);
233
234 int hinic_port_del_vlan(struct hinic_dev *nic_dev, u16 vlan_id);
235
236 int hinic_port_set_rx_mode(struct hinic_dev *nic_dev, u32 rx_mode);
237
238 int hinic_port_link_state(struct hinic_dev *nic_dev,
239                           enum hinic_port_link_state *link_state);
240
241 int hinic_port_set_state(struct hinic_dev *nic_dev,
242                          enum hinic_port_state state);
243
244 int hinic_port_set_func_state(struct hinic_dev *nic_dev,
245                               enum hinic_func_port_state state);
246
247 int hinic_port_get_cap(struct hinic_dev *nic_dev,
248                        struct hinic_port_cap *port_cap);
249
250 int hinic_set_max_qnum(struct hinic_dev *nic_dev, u8 num_rqs);
251
252 int hinic_port_set_tso(struct hinic_dev *nic_dev, enum hinic_tso_state state);
253
254 int hinic_set_rx_csum_offload(struct hinic_dev *nic_dev, u32 en);
255
256 int hinic_set_rx_lro_state(struct hinic_dev *nic_dev, u8 lro_en,
257                            u32 lro_timer, u32 wqe_num);
258 #endif