Commit | Line | Data |
---|---|---|
af19b491 AKS |
1 | /* |
2 | * Copyright (C) 2009 - QLogic Corporation. | |
3 | * All rights reserved. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or | |
6 | * modify it under the terms of the GNU General Public License | |
7 | * as published by the Free Software Foundation; either version 2 | |
8 | * of the License, or (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | |
18 | * MA 02111-1307, USA. | |
19 | * | |
20 | * The full GNU General Public License is included in this distribution | |
21 | * in the file called "COPYING". | |
22 | * | |
23 | */ | |
24 | ||
25 | #include <linux/types.h> | |
26 | #include <linux/delay.h> | |
27 | #include <linux/pci.h> | |
28 | #include <linux/io.h> | |
29 | #include <linux/netdevice.h> | |
30 | #include <linux/ethtool.h> | |
31 | ||
32 | #include "qlcnic.h" | |
33 | ||
34 | struct qlcnic_stats { | |
35 | char stat_string[ETH_GSTRING_LEN]; | |
36 | int sizeof_stat; | |
37 | int stat_offset; | |
38 | }; | |
39 | ||
40 | #define QLC_SIZEOF(m) FIELD_SIZEOF(struct qlcnic_adapter, m) | |
41 | #define QLC_OFF(m) offsetof(struct qlcnic_adapter, m) | |
42 | ||
43 | static const struct qlcnic_stats qlcnic_gstrings_stats[] = { | |
44 | {"xmit_called", | |
45 | QLC_SIZEOF(stats.xmitcalled), QLC_OFF(stats.xmitcalled)}, | |
46 | {"xmit_finished", | |
47 | QLC_SIZEOF(stats.xmitfinished), QLC_OFF(stats.xmitfinished)}, | |
48 | {"rx_dropped", | |
49 | QLC_SIZEOF(stats.rxdropped), QLC_OFF(stats.rxdropped)}, | |
50 | {"tx_dropped", | |
51 | QLC_SIZEOF(stats.txdropped), QLC_OFF(stats.txdropped)}, | |
52 | {"csummed", | |
53 | QLC_SIZEOF(stats.csummed), QLC_OFF(stats.csummed)}, | |
54 | {"rx_pkts", | |
55 | QLC_SIZEOF(stats.rx_pkts), QLC_OFF(stats.rx_pkts)}, | |
56 | {"lro_pkts", | |
57 | QLC_SIZEOF(stats.lro_pkts), QLC_OFF(stats.lro_pkts)}, | |
58 | {"rx_bytes", | |
59 | QLC_SIZEOF(stats.rxbytes), QLC_OFF(stats.rxbytes)}, | |
60 | {"tx_bytes", | |
61 | QLC_SIZEOF(stats.txbytes), QLC_OFF(stats.txbytes)}, | |
8bfe8b91 SC |
62 | {"lrobytes", |
63 | QLC_SIZEOF(stats.lrobytes), QLC_OFF(stats.lrobytes)}, | |
64 | {"lso_frames", | |
65 | QLC_SIZEOF(stats.lso_frames), QLC_OFF(stats.lso_frames)}, | |
66 | {"xmit_on", | |
67 | QLC_SIZEOF(stats.xmit_on), QLC_OFF(stats.xmit_on)}, | |
68 | {"xmit_off", | |
69 | QLC_SIZEOF(stats.xmit_off), QLC_OFF(stats.xmit_off)}, | |
70 | {"skb_alloc_failure", QLC_SIZEOF(stats.skb_alloc_failure), | |
71 | QLC_OFF(stats.skb_alloc_failure)}, | |
8ae6df97 AKS |
72 | {"null rxbuf", |
73 | QLC_SIZEOF(stats.null_rxbuf), QLC_OFF(stats.null_rxbuf)}, | |
74 | {"rx dma map error", QLC_SIZEOF(stats.rx_dma_map_error), | |
75 | QLC_OFF(stats.rx_dma_map_error)}, | |
76 | {"tx dma map error", QLC_SIZEOF(stats.tx_dma_map_error), | |
77 | QLC_OFF(stats.tx_dma_map_error)}, | |
8bfe8b91 | 78 | |
af19b491 AKS |
79 | }; |
80 | ||
81 | #define QLCNIC_STATS_LEN ARRAY_SIZE(qlcnic_gstrings_stats) | |
82 | ||
83 | static const char qlcnic_gstrings_test[][ETH_GSTRING_LEN] = { | |
84 | "Register_Test_on_offline", | |
7eb9855d | 85 | "Link_Test_on_offline", |
cdaff185 AKS |
86 | "Interrupt_Test_offline", |
87 | "Loopback_Test_offline" | |
af19b491 AKS |
88 | }; |
89 | ||
90 | #define QLCNIC_TEST_LEN ARRAY_SIZE(qlcnic_gstrings_test) | |
91 | ||
92 | #define QLCNIC_RING_REGS_COUNT 20 | |
93 | #define QLCNIC_RING_REGS_LEN (QLCNIC_RING_REGS_COUNT * sizeof(u32)) | |
94 | #define QLCNIC_MAX_EEPROM_LEN 1024 | |
95 | ||
96 | static const u32 diag_registers[] = { | |
97 | CRB_CMDPEG_STATE, | |
98 | CRB_RCVPEG_STATE, | |
99 | CRB_XG_STATE_P3, | |
100 | CRB_FW_CAPABILITIES_1, | |
101 | ISR_INT_STATE_REG, | |
102 | QLCNIC_CRB_DEV_REF_COUNT, | |
103 | QLCNIC_CRB_DEV_STATE, | |
104 | QLCNIC_CRB_DRV_STATE, | |
105 | QLCNIC_CRB_DRV_SCRATCH, | |
106 | QLCNIC_CRB_DEV_PARTITION_INFO, | |
107 | QLCNIC_CRB_DRV_IDC_VER, | |
108 | QLCNIC_PEG_ALIVE_COUNTER, | |
109 | QLCNIC_PEG_HALT_STATUS1, | |
110 | QLCNIC_PEG_HALT_STATUS2, | |
111 | QLCNIC_CRB_PEG_NET_0+0x3c, | |
112 | QLCNIC_CRB_PEG_NET_1+0x3c, | |
113 | QLCNIC_CRB_PEG_NET_2+0x3c, | |
114 | QLCNIC_CRB_PEG_NET_4+0x3c, | |
115 | -1 | |
116 | }; | |
117 | ||
118 | static int qlcnic_get_regs_len(struct net_device *dev) | |
119 | { | |
120 | return sizeof(diag_registers) + QLCNIC_RING_REGS_LEN; | |
121 | } | |
122 | ||
123 | static int qlcnic_get_eeprom_len(struct net_device *dev) | |
124 | { | |
125 | return QLCNIC_FLASH_TOTAL_SIZE; | |
126 | } | |
127 | ||
128 | static void | |
129 | qlcnic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) | |
130 | { | |
131 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
132 | u32 fw_major, fw_minor, fw_build; | |
133 | ||
134 | fw_major = QLCRD32(adapter, QLCNIC_FW_VERSION_MAJOR); | |
135 | fw_minor = QLCRD32(adapter, QLCNIC_FW_VERSION_MINOR); | |
136 | fw_build = QLCRD32(adapter, QLCNIC_FW_VERSION_SUB); | |
137 | sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); | |
138 | ||
139 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); | |
140 | strlcpy(drvinfo->driver, qlcnic_driver_name, 32); | |
141 | strlcpy(drvinfo->version, QLCNIC_LINUX_VERSIONID, 32); | |
142 | } | |
143 | ||
144 | static int | |
145 | qlcnic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |
146 | { | |
147 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
148 | int check_sfp_module = 0; | |
149 | u16 pcifn = adapter->ahw.pci_func; | |
150 | ||
151 | /* read which mode */ | |
152 | if (adapter->ahw.port_type == QLCNIC_GBE) { | |
153 | ecmd->supported = (SUPPORTED_10baseT_Half | | |
154 | SUPPORTED_10baseT_Full | | |
155 | SUPPORTED_100baseT_Half | | |
156 | SUPPORTED_100baseT_Full | | |
157 | SUPPORTED_1000baseT_Half | | |
158 | SUPPORTED_1000baseT_Full); | |
159 | ||
160 | ecmd->advertising = (ADVERTISED_100baseT_Half | | |
161 | ADVERTISED_100baseT_Full | | |
162 | ADVERTISED_1000baseT_Half | | |
163 | ADVERTISED_1000baseT_Full); | |
164 | ||
165 | ecmd->speed = adapter->link_speed; | |
166 | ecmd->duplex = adapter->link_duplex; | |
167 | ecmd->autoneg = adapter->link_autoneg; | |
168 | ||
169 | } else if (adapter->ahw.port_type == QLCNIC_XGBE) { | |
170 | u32 val; | |
171 | ||
172 | val = QLCRD32(adapter, QLCNIC_PORT_MODE_ADDR); | |
173 | if (val == QLCNIC_PORT_MODE_802_3_AP) { | |
174 | ecmd->supported = SUPPORTED_1000baseT_Full; | |
175 | ecmd->advertising = ADVERTISED_1000baseT_Full; | |
176 | } else { | |
177 | ecmd->supported = SUPPORTED_10000baseT_Full; | |
178 | ecmd->advertising = ADVERTISED_10000baseT_Full; | |
179 | } | |
180 | ||
181 | if (netif_running(dev) && adapter->has_link_events) { | |
182 | ecmd->speed = adapter->link_speed; | |
183 | ecmd->autoneg = adapter->link_autoneg; | |
184 | ecmd->duplex = adapter->link_duplex; | |
185 | goto skip; | |
186 | } | |
187 | ||
188 | val = QLCRD32(adapter, P3_LINK_SPEED_REG(pcifn)); | |
189 | ecmd->speed = P3_LINK_SPEED_MHZ * | |
190 | P3_LINK_SPEED_VAL(pcifn, val); | |
191 | ecmd->duplex = DUPLEX_FULL; | |
192 | ecmd->autoneg = AUTONEG_DISABLE; | |
193 | } else | |
194 | return -EIO; | |
195 | ||
196 | skip: | |
197 | ecmd->phy_address = adapter->physical_port; | |
198 | ecmd->transceiver = XCVR_EXTERNAL; | |
199 | ||
200 | switch (adapter->ahw.board_type) { | |
201 | case QLCNIC_BRDTYPE_P3_REF_QG: | |
202 | case QLCNIC_BRDTYPE_P3_4_GB: | |
203 | case QLCNIC_BRDTYPE_P3_4_GB_MM: | |
204 | ||
205 | ecmd->supported |= SUPPORTED_Autoneg; | |
206 | ecmd->advertising |= ADVERTISED_Autoneg; | |
207 | case QLCNIC_BRDTYPE_P3_10G_CX4: | |
208 | case QLCNIC_BRDTYPE_P3_10G_CX4_LP: | |
209 | case QLCNIC_BRDTYPE_P3_10000_BASE_T: | |
210 | ecmd->supported |= SUPPORTED_TP; | |
211 | ecmd->advertising |= ADVERTISED_TP; | |
212 | ecmd->port = PORT_TP; | |
213 | ecmd->autoneg = adapter->link_autoneg; | |
214 | break; | |
215 | case QLCNIC_BRDTYPE_P3_IMEZ: | |
216 | case QLCNIC_BRDTYPE_P3_XG_LOM: | |
217 | case QLCNIC_BRDTYPE_P3_HMEZ: | |
218 | ecmd->supported |= SUPPORTED_MII; | |
219 | ecmd->advertising |= ADVERTISED_MII; | |
220 | ecmd->port = PORT_MII; | |
221 | ecmd->autoneg = AUTONEG_DISABLE; | |
222 | break; | |
223 | case QLCNIC_BRDTYPE_P3_10G_SFP_PLUS: | |
224 | case QLCNIC_BRDTYPE_P3_10G_SFP_CT: | |
225 | case QLCNIC_BRDTYPE_P3_10G_SFP_QT: | |
226 | ecmd->advertising |= ADVERTISED_TP; | |
227 | ecmd->supported |= SUPPORTED_TP; | |
228 | check_sfp_module = netif_running(dev) && | |
229 | adapter->has_link_events; | |
230 | case QLCNIC_BRDTYPE_P3_10G_XFP: | |
231 | ecmd->supported |= SUPPORTED_FIBRE; | |
232 | ecmd->advertising |= ADVERTISED_FIBRE; | |
233 | ecmd->port = PORT_FIBRE; | |
234 | ecmd->autoneg = AUTONEG_DISABLE; | |
235 | break; | |
236 | case QLCNIC_BRDTYPE_P3_10G_TP: | |
237 | if (adapter->ahw.port_type == QLCNIC_XGBE) { | |
238 | ecmd->autoneg = AUTONEG_DISABLE; | |
239 | ecmd->supported |= (SUPPORTED_FIBRE | SUPPORTED_TP); | |
240 | ecmd->advertising |= | |
241 | (ADVERTISED_FIBRE | ADVERTISED_TP); | |
242 | ecmd->port = PORT_FIBRE; | |
243 | check_sfp_module = netif_running(dev) && | |
244 | adapter->has_link_events; | |
245 | } else { | |
246 | ecmd->autoneg = AUTONEG_ENABLE; | |
247 | ecmd->supported |= (SUPPORTED_TP | SUPPORTED_Autoneg); | |
248 | ecmd->advertising |= | |
249 | (ADVERTISED_TP | ADVERTISED_Autoneg); | |
250 | ecmd->port = PORT_TP; | |
251 | } | |
252 | break; | |
253 | default: | |
254 | dev_err(&adapter->pdev->dev, "Unsupported board model %d\n", | |
255 | adapter->ahw.board_type); | |
256 | return -EIO; | |
257 | } | |
258 | ||
259 | if (check_sfp_module) { | |
260 | switch (adapter->module_type) { | |
261 | case LINKEVENT_MODULE_OPTICAL_UNKNOWN: | |
262 | case LINKEVENT_MODULE_OPTICAL_SRLR: | |
263 | case LINKEVENT_MODULE_OPTICAL_LRM: | |
264 | case LINKEVENT_MODULE_OPTICAL_SFP_1G: | |
265 | ecmd->port = PORT_FIBRE; | |
266 | break; | |
267 | case LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLE: | |
268 | case LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLELEN: | |
269 | case LINKEVENT_MODULE_TWINAX: | |
270 | ecmd->port = PORT_TP; | |
271 | break; | |
272 | default: | |
273 | ecmd->port = PORT_OTHER; | |
274 | } | |
275 | } | |
276 | ||
277 | return 0; | |
278 | } | |
279 | ||
280 | static int | |
281 | qlcnic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |
282 | { | |
283 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
284 | __u32 status; | |
285 | ||
286 | /* read which mode */ | |
287 | if (adapter->ahw.port_type == QLCNIC_GBE) { | |
288 | /* autonegotiation */ | |
289 | if (qlcnic_fw_cmd_set_phy(adapter, | |
290 | QLCNIC_NIU_GB_MII_MGMT_ADDR_AUTONEG, | |
291 | ecmd->autoneg) != 0) | |
292 | return -EIO; | |
293 | else | |
294 | adapter->link_autoneg = ecmd->autoneg; | |
295 | ||
296 | if (qlcnic_fw_cmd_query_phy(adapter, | |
297 | QLCNIC_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | |
298 | &status) != 0) | |
299 | return -EIO; | |
300 | ||
301 | switch (ecmd->speed) { | |
302 | case SPEED_10: | |
303 | qlcnic_set_phy_speed(status, 0); | |
304 | break; | |
305 | case SPEED_100: | |
306 | qlcnic_set_phy_speed(status, 1); | |
307 | break; | |
308 | case SPEED_1000: | |
309 | qlcnic_set_phy_speed(status, 2); | |
310 | break; | |
311 | } | |
312 | ||
313 | if (ecmd->duplex == DUPLEX_HALF) | |
314 | qlcnic_clear_phy_duplex(status); | |
315 | if (ecmd->duplex == DUPLEX_FULL) | |
316 | qlcnic_set_phy_duplex(status); | |
317 | if (qlcnic_fw_cmd_set_phy(adapter, | |
318 | QLCNIC_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | |
319 | *((int *)&status)) != 0) | |
320 | return -EIO; | |
321 | else { | |
322 | adapter->link_speed = ecmd->speed; | |
323 | adapter->link_duplex = ecmd->duplex; | |
324 | } | |
325 | } else | |
326 | return -EOPNOTSUPP; | |
327 | ||
328 | if (!netif_running(dev)) | |
329 | return 0; | |
330 | ||
331 | dev->netdev_ops->ndo_stop(dev); | |
332 | return dev->netdev_ops->ndo_open(dev); | |
333 | } | |
334 | ||
335 | static void | |
336 | qlcnic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) | |
337 | { | |
338 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
339 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | |
340 | struct qlcnic_host_sds_ring *sds_ring; | |
341 | u32 *regs_buff = p; | |
342 | int ring, i = 0; | |
343 | ||
344 | memset(p, 0, qlcnic_get_regs_len(dev)); | |
345 | regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) | | |
346 | (adapter->pdev)->device; | |
347 | ||
af19b491 AKS |
348 | for (i = 0; diag_registers[i] != -1; i++) |
349 | regs_buff[i] = QLCRD32(adapter, diag_registers[i]); | |
350 | ||
8a15ad1f | 351 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) |
ce668443 AKS |
352 | return; |
353 | ||
af19b491 AKS |
354 | regs_buff[i++] = 0xFFEFCDAB; /* Marker btw regs and ring count*/ |
355 | ||
356 | regs_buff[i++] = 1; /* No. of tx ring */ | |
357 | regs_buff[i++] = le32_to_cpu(*(adapter->tx_ring->hw_consumer)); | |
358 | regs_buff[i++] = readl(adapter->tx_ring->crb_cmd_producer); | |
359 | ||
360 | regs_buff[i++] = 2; /* No. of rx ring */ | |
361 | regs_buff[i++] = readl(recv_ctx->rds_rings[0].crb_rcv_producer); | |
362 | regs_buff[i++] = readl(recv_ctx->rds_rings[1].crb_rcv_producer); | |
363 | ||
364 | regs_buff[i++] = adapter->max_sds_rings; | |
365 | ||
366 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { | |
367 | sds_ring = &(recv_ctx->sds_rings[ring]); | |
368 | regs_buff[i++] = readl(sds_ring->crb_sts_consumer); | |
369 | } | |
370 | } | |
371 | ||
372 | static u32 qlcnic_test_link(struct net_device *dev) | |
373 | { | |
374 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
375 | u32 val; | |
376 | ||
377 | val = QLCRD32(adapter, CRB_XG_STATE_P3); | |
378 | val = XG_LINK_STATE_P3(adapter->ahw.pci_func, val); | |
379 | return (val == XG_LINK_UP_P3) ? 0 : 1; | |
380 | } | |
381 | ||
382 | static int | |
383 | qlcnic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, | |
384 | u8 *bytes) | |
385 | { | |
386 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
387 | int offset; | |
388 | int ret; | |
389 | ||
390 | if (eeprom->len == 0) | |
391 | return -EINVAL; | |
392 | ||
393 | eeprom->magic = (adapter->pdev)->vendor | | |
394 | ((adapter->pdev)->device << 16); | |
395 | offset = eeprom->offset; | |
396 | ||
397 | ret = qlcnic_rom_fast_read_words(adapter, offset, bytes, | |
398 | eeprom->len); | |
399 | if (ret < 0) | |
400 | return ret; | |
401 | ||
402 | return 0; | |
403 | } | |
404 | ||
405 | static void | |
406 | qlcnic_get_ringparam(struct net_device *dev, | |
407 | struct ethtool_ringparam *ring) | |
408 | { | |
409 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
410 | ||
411 | ring->rx_pending = adapter->num_rxd; | |
412 | ring->rx_jumbo_pending = adapter->num_jumbo_rxd; | |
af19b491 AKS |
413 | ring->tx_pending = adapter->num_txd; |
414 | ||
415 | if (adapter->ahw.port_type == QLCNIC_GBE) { | |
416 | ring->rx_max_pending = MAX_RCV_DESCRIPTORS_1G; | |
417 | ring->rx_jumbo_max_pending = MAX_JUMBO_RCV_DESCRIPTORS_1G; | |
418 | } else { | |
419 | ring->rx_max_pending = MAX_RCV_DESCRIPTORS_10G; | |
420 | ring->rx_jumbo_max_pending = MAX_JUMBO_RCV_DESCRIPTORS_10G; | |
421 | } | |
422 | ||
423 | ring->tx_max_pending = MAX_CMD_DESCRIPTORS; | |
424 | ||
425 | ring->rx_mini_max_pending = 0; | |
426 | ring->rx_mini_pending = 0; | |
427 | } | |
428 | ||
429 | static u32 | |
430 | qlcnic_validate_ringparam(u32 val, u32 min, u32 max, char *r_name) | |
431 | { | |
432 | u32 num_desc; | |
433 | num_desc = max(val, min); | |
434 | num_desc = min(num_desc, max); | |
435 | num_desc = roundup_pow_of_two(num_desc); | |
436 | ||
437 | if (val != num_desc) { | |
438 | printk(KERN_INFO "%s: setting %s ring size %d instead of %d\n", | |
439 | qlcnic_driver_name, r_name, num_desc, val); | |
440 | } | |
441 | ||
442 | return num_desc; | |
443 | } | |
444 | ||
445 | static int | |
446 | qlcnic_set_ringparam(struct net_device *dev, | |
447 | struct ethtool_ringparam *ring) | |
448 | { | |
449 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
450 | u16 max_rcv_desc = MAX_RCV_DESCRIPTORS_10G; | |
451 | u16 max_jumbo_desc = MAX_JUMBO_RCV_DESCRIPTORS_10G; | |
452 | u16 num_rxd, num_jumbo_rxd, num_txd; | |
453 | ||
454 | ||
455 | if (ring->rx_mini_pending) | |
456 | return -EOPNOTSUPP; | |
457 | ||
458 | if (adapter->ahw.port_type == QLCNIC_GBE) { | |
459 | max_rcv_desc = MAX_RCV_DESCRIPTORS_1G; | |
460 | max_jumbo_desc = MAX_JUMBO_RCV_DESCRIPTORS_10G; | |
461 | } | |
462 | ||
463 | num_rxd = qlcnic_validate_ringparam(ring->rx_pending, | |
464 | MIN_RCV_DESCRIPTORS, max_rcv_desc, "rx"); | |
465 | ||
466 | num_jumbo_rxd = qlcnic_validate_ringparam(ring->rx_jumbo_pending, | |
467 | MIN_JUMBO_DESCRIPTORS, max_jumbo_desc, "rx jumbo"); | |
468 | ||
469 | num_txd = qlcnic_validate_ringparam(ring->tx_pending, | |
470 | MIN_CMD_DESCRIPTORS, MAX_CMD_DESCRIPTORS, "tx"); | |
471 | ||
472 | if (num_rxd == adapter->num_rxd && num_txd == adapter->num_txd && | |
473 | num_jumbo_rxd == adapter->num_jumbo_rxd) | |
474 | return 0; | |
475 | ||
476 | adapter->num_rxd = num_rxd; | |
477 | adapter->num_jumbo_rxd = num_jumbo_rxd; | |
478 | adapter->num_txd = num_txd; | |
479 | ||
480 | return qlcnic_reset_context(adapter); | |
481 | } | |
482 | ||
483 | static void | |
484 | qlcnic_get_pauseparam(struct net_device *netdev, | |
485 | struct ethtool_pauseparam *pause) | |
486 | { | |
487 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | |
488 | int port = adapter->physical_port; | |
489 | __u32 val; | |
490 | ||
491 | if (adapter->ahw.port_type == QLCNIC_GBE) { | |
492 | if ((port < 0) || (port > QLCNIC_NIU_MAX_GBE_PORTS)) | |
493 | return; | |
494 | /* get flow control settings */ | |
495 | val = QLCRD32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port)); | |
496 | pause->rx_pause = qlcnic_gb_get_rx_flowctl(val); | |
497 | val = QLCRD32(adapter, QLCNIC_NIU_GB_PAUSE_CTL); | |
498 | switch (port) { | |
499 | case 0: | |
500 | pause->tx_pause = !(qlcnic_gb_get_gb0_mask(val)); | |
501 | break; | |
502 | case 1: | |
503 | pause->tx_pause = !(qlcnic_gb_get_gb1_mask(val)); | |
504 | break; | |
505 | case 2: | |
506 | pause->tx_pause = !(qlcnic_gb_get_gb2_mask(val)); | |
507 | break; | |
508 | case 3: | |
509 | default: | |
510 | pause->tx_pause = !(qlcnic_gb_get_gb3_mask(val)); | |
511 | break; | |
512 | } | |
513 | } else if (adapter->ahw.port_type == QLCNIC_XGBE) { | |
514 | if ((port < 0) || (port > QLCNIC_NIU_MAX_XG_PORTS)) | |
515 | return; | |
516 | pause->rx_pause = 1; | |
517 | val = QLCRD32(adapter, QLCNIC_NIU_XG_PAUSE_CTL); | |
518 | if (port == 0) | |
519 | pause->tx_pause = !(qlcnic_xg_get_xg0_mask(val)); | |
520 | else | |
521 | pause->tx_pause = !(qlcnic_xg_get_xg1_mask(val)); | |
522 | } else { | |
523 | dev_err(&netdev->dev, "Unknown board type: %x\n", | |
524 | adapter->ahw.port_type); | |
525 | } | |
526 | } | |
527 | ||
528 | static int | |
529 | qlcnic_set_pauseparam(struct net_device *netdev, | |
530 | struct ethtool_pauseparam *pause) | |
531 | { | |
532 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | |
533 | int port = adapter->physical_port; | |
534 | __u32 val; | |
535 | ||
536 | /* read mode */ | |
537 | if (adapter->ahw.port_type == QLCNIC_GBE) { | |
538 | if ((port < 0) || (port > QLCNIC_NIU_MAX_GBE_PORTS)) | |
539 | return -EIO; | |
540 | /* set flow control */ | |
541 | val = QLCRD32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port)); | |
542 | ||
543 | if (pause->rx_pause) | |
544 | qlcnic_gb_rx_flowctl(val); | |
545 | else | |
546 | qlcnic_gb_unset_rx_flowctl(val); | |
547 | ||
548 | QLCWR32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port), | |
549 | val); | |
550 | /* set autoneg */ | |
551 | val = QLCRD32(adapter, QLCNIC_NIU_GB_PAUSE_CTL); | |
552 | switch (port) { | |
553 | case 0: | |
554 | if (pause->tx_pause) | |
555 | qlcnic_gb_unset_gb0_mask(val); | |
556 | else | |
557 | qlcnic_gb_set_gb0_mask(val); | |
558 | break; | |
559 | case 1: | |
560 | if (pause->tx_pause) | |
561 | qlcnic_gb_unset_gb1_mask(val); | |
562 | else | |
563 | qlcnic_gb_set_gb1_mask(val); | |
564 | break; | |
565 | case 2: | |
566 | if (pause->tx_pause) | |
567 | qlcnic_gb_unset_gb2_mask(val); | |
568 | else | |
569 | qlcnic_gb_set_gb2_mask(val); | |
570 | break; | |
571 | case 3: | |
572 | default: | |
573 | if (pause->tx_pause) | |
574 | qlcnic_gb_unset_gb3_mask(val); | |
575 | else | |
576 | qlcnic_gb_set_gb3_mask(val); | |
577 | break; | |
578 | } | |
579 | QLCWR32(adapter, QLCNIC_NIU_GB_PAUSE_CTL, val); | |
580 | } else if (adapter->ahw.port_type == QLCNIC_XGBE) { | |
6d181688 RB |
581 | if (!pause->rx_pause || pause->autoneg) |
582 | return -EOPNOTSUPP; | |
583 | ||
af19b491 AKS |
584 | if ((port < 0) || (port > QLCNIC_NIU_MAX_XG_PORTS)) |
585 | return -EIO; | |
6d181688 | 586 | |
af19b491 AKS |
587 | val = QLCRD32(adapter, QLCNIC_NIU_XG_PAUSE_CTL); |
588 | if (port == 0) { | |
589 | if (pause->tx_pause) | |
590 | qlcnic_xg_unset_xg0_mask(val); | |
591 | else | |
592 | qlcnic_xg_set_xg0_mask(val); | |
593 | } else { | |
594 | if (pause->tx_pause) | |
595 | qlcnic_xg_unset_xg1_mask(val); | |
596 | else | |
597 | qlcnic_xg_set_xg1_mask(val); | |
598 | } | |
599 | QLCWR32(adapter, QLCNIC_NIU_XG_PAUSE_CTL, val); | |
600 | } else { | |
601 | dev_err(&netdev->dev, "Unknown board type: %x\n", | |
602 | adapter->ahw.port_type); | |
603 | } | |
604 | return 0; | |
605 | } | |
606 | ||
607 | static int qlcnic_reg_test(struct net_device *dev) | |
608 | { | |
609 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
deffab05 | 610 | u32 data_read; |
af19b491 AKS |
611 | |
612 | data_read = QLCRD32(adapter, QLCNIC_PCIX_PH_REG(0)); | |
613 | if ((data_read & 0xffff) != adapter->pdev->vendor) | |
614 | return 1; | |
615 | ||
af19b491 AKS |
616 | return 0; |
617 | } | |
618 | ||
619 | static int qlcnic_get_sset_count(struct net_device *dev, int sset) | |
620 | { | |
621 | switch (sset) { | |
622 | case ETH_SS_TEST: | |
623 | return QLCNIC_TEST_LEN; | |
624 | case ETH_SS_STATS: | |
625 | return QLCNIC_STATS_LEN; | |
626 | default: | |
627 | return -EOPNOTSUPP; | |
628 | } | |
629 | } | |
630 | ||
cdaff185 AKS |
631 | #define QLC_ILB_PKT_SIZE 64 |
632 | ||
633 | static void qlcnic_create_loopback_buff(unsigned char *data) | |
634 | { | |
635 | unsigned char random_data[] = {0xa8, 0x06, 0x45, 0x00}; | |
636 | memset(data, 0x4e, QLC_ILB_PKT_SIZE); | |
637 | memset(data, 0xff, 12); | |
638 | memcpy(data + 12, random_data, sizeof(random_data)); | |
639 | } | |
640 | ||
641 | int qlcnic_check_loopback_buff(unsigned char *data) | |
642 | { | |
643 | unsigned char buff[QLC_ILB_PKT_SIZE]; | |
644 | qlcnic_create_loopback_buff(buff); | |
645 | return memcmp(data, buff, QLC_ILB_PKT_SIZE); | |
646 | } | |
647 | ||
648 | static int qlcnic_do_ilb_test(struct qlcnic_adapter *adapter) | |
649 | { | |
650 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | |
651 | struct qlcnic_host_sds_ring *sds_ring = &recv_ctx->sds_rings[0]; | |
652 | struct sk_buff *skb; | |
653 | int i; | |
654 | ||
655 | for (i = 0; i < 16; i++) { | |
656 | skb = dev_alloc_skb(QLC_ILB_PKT_SIZE); | |
657 | qlcnic_create_loopback_buff(skb->data); | |
658 | skb_put(skb, QLC_ILB_PKT_SIZE); | |
659 | ||
660 | adapter->diag_cnt = 0; | |
661 | ||
662 | qlcnic_xmit_frame(skb, adapter->netdev); | |
663 | ||
664 | msleep(5); | |
665 | ||
666 | qlcnic_process_rcv_ring_diag(sds_ring); | |
667 | ||
668 | dev_kfree_skb_any(skb); | |
669 | if (!adapter->diag_cnt) | |
670 | return -1; | |
671 | } | |
672 | return 0; | |
673 | } | |
674 | ||
675 | static int qlcnic_loopback_test(struct net_device *netdev) | |
676 | { | |
677 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | |
678 | int max_sds_rings = adapter->max_sds_rings; | |
679 | int ret; | |
680 | ||
36a1898d AKS |
681 | if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) { |
682 | dev_warn(&adapter->pdev->dev, "Loopback test not supported" | |
683 | "for non privilege function\n"); | |
684 | return 0; | |
685 | } | |
686 | ||
cdaff185 AKS |
687 | if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) |
688 | return -EIO; | |
689 | ||
690 | ret = qlcnic_diag_alloc_res(netdev, QLCNIC_LOOPBACK_TEST); | |
691 | if (ret) | |
692 | goto clear_it; | |
693 | ||
36a1898d | 694 | ret = qlcnic_set_ilb_mode(adapter); |
cdaff185 AKS |
695 | if (ret) |
696 | goto done; | |
697 | ||
698 | ret = qlcnic_do_ilb_test(adapter); | |
699 | ||
36a1898d | 700 | qlcnic_clear_ilb_mode(adapter); |
cdaff185 AKS |
701 | |
702 | done: | |
703 | qlcnic_diag_free_res(netdev, max_sds_rings); | |
704 | ||
705 | clear_it: | |
706 | adapter->max_sds_rings = max_sds_rings; | |
707 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | |
708 | return ret; | |
709 | } | |
710 | ||
7eb9855d AKS |
711 | static int qlcnic_irq_test(struct net_device *netdev) |
712 | { | |
713 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | |
714 | int max_sds_rings = adapter->max_sds_rings; | |
715 | int ret; | |
716 | ||
717 | if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) | |
718 | return -EIO; | |
719 | ||
720 | ret = qlcnic_diag_alloc_res(netdev, QLCNIC_INTERRUPT_TEST); | |
721 | if (ret) | |
722 | goto clear_it; | |
723 | ||
724 | adapter->diag_cnt = 0; | |
725 | ret = qlcnic_issue_cmd(adapter, adapter->ahw.pci_func, | |
2e9d722d AC |
726 | adapter->fw_hal_version, adapter->portnum, |
727 | 0, 0, 0x00000011); | |
7eb9855d AKS |
728 | if (ret) |
729 | goto done; | |
730 | ||
731 | msleep(10); | |
732 | ||
733 | ret = !adapter->diag_cnt; | |
734 | ||
735 | done: | |
736 | qlcnic_diag_free_res(netdev, max_sds_rings); | |
737 | ||
738 | clear_it: | |
739 | adapter->max_sds_rings = max_sds_rings; | |
740 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | |
741 | return ret; | |
742 | } | |
743 | ||
af19b491 AKS |
744 | static void |
745 | qlcnic_diag_test(struct net_device *dev, struct ethtool_test *eth_test, | |
746 | u64 *data) | |
747 | { | |
748 | memset(data, 0, sizeof(u64) * QLCNIC_TEST_LEN); | |
897d3596 | 749 | |
7eb9855d AKS |
750 | if (eth_test->flags == ETH_TEST_FL_OFFLINE) { |
751 | data[2] = qlcnic_irq_test(dev); | |
752 | if (data[2]) | |
753 | eth_test->flags |= ETH_TEST_FL_FAILED; | |
cdaff185 AKS |
754 | |
755 | data[3] = qlcnic_loopback_test(dev); | |
756 | if (data[3]) | |
757 | eth_test->flags |= ETH_TEST_FL_FAILED; | |
758 | ||
7eb9855d AKS |
759 | } |
760 | ||
af19b491 AKS |
761 | data[0] = qlcnic_reg_test(dev); |
762 | if (data[0]) | |
763 | eth_test->flags |= ETH_TEST_FL_FAILED; | |
764 | ||
765 | /* link test */ | |
766 | data[1] = (u64) qlcnic_test_link(dev); | |
767 | if (data[1]) | |
768 | eth_test->flags |= ETH_TEST_FL_FAILED; | |
769 | } | |
770 | ||
771 | static void | |
772 | qlcnic_get_strings(struct net_device *dev, u32 stringset, u8 * data) | |
773 | { | |
774 | int index; | |
775 | ||
776 | switch (stringset) { | |
777 | case ETH_SS_TEST: | |
778 | memcpy(data, *qlcnic_gstrings_test, | |
779 | QLCNIC_TEST_LEN * ETH_GSTRING_LEN); | |
780 | break; | |
781 | case ETH_SS_STATS: | |
782 | for (index = 0; index < QLCNIC_STATS_LEN; index++) { | |
783 | memcpy(data + index * ETH_GSTRING_LEN, | |
784 | qlcnic_gstrings_stats[index].stat_string, | |
785 | ETH_GSTRING_LEN); | |
786 | } | |
787 | break; | |
788 | } | |
789 | } | |
790 | ||
791 | static void | |
792 | qlcnic_get_ethtool_stats(struct net_device *dev, | |
793 | struct ethtool_stats *stats, u64 * data) | |
794 | { | |
795 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
796 | int index; | |
797 | ||
798 | for (index = 0; index < QLCNIC_STATS_LEN; index++) { | |
799 | char *p = | |
800 | (char *)adapter + | |
801 | qlcnic_gstrings_stats[index].stat_offset; | |
802 | data[index] = | |
803 | (qlcnic_gstrings_stats[index].sizeof_stat == | |
804 | sizeof(u64)) ? *(u64 *)p:(*(u32 *)p); | |
805 | } | |
806 | } | |
807 | ||
8bae5698 SC |
808 | static u32 qlcnic_get_tx_csum(struct net_device *dev) |
809 | { | |
810 | return dev->features & NETIF_F_IP_CSUM; | |
811 | } | |
812 | ||
af19b491 AKS |
813 | static u32 qlcnic_get_rx_csum(struct net_device *dev) |
814 | { | |
815 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
816 | return adapter->rx_csum; | |
817 | } | |
818 | ||
819 | static int qlcnic_set_rx_csum(struct net_device *dev, u32 data) | |
820 | { | |
821 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
822 | adapter->rx_csum = !!data; | |
823 | return 0; | |
824 | } | |
825 | ||
826 | static u32 qlcnic_get_tso(struct net_device *dev) | |
827 | { | |
828 | return (dev->features & (NETIF_F_TSO | NETIF_F_TSO6)) != 0; | |
829 | } | |
830 | ||
831 | static int qlcnic_set_tso(struct net_device *dev, u32 data) | |
832 | { | |
ac8d0c4f AC |
833 | struct qlcnic_adapter *adapter = netdev_priv(dev); |
834 | if (!(adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO)) | |
835 | return -EOPNOTSUPP; | |
af19b491 AKS |
836 | if (data) |
837 | dev->features |= (NETIF_F_TSO | NETIF_F_TSO6); | |
838 | else | |
839 | dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); | |
840 | ||
841 | return 0; | |
842 | } | |
843 | ||
897d3596 SC |
844 | static int qlcnic_blink_led(struct net_device *dev, u32 val) |
845 | { | |
846 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
847 | int ret; | |
848 | ||
8a15ad1f AKS |
849 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) |
850 | return -EIO; | |
851 | ||
2e9d722d | 852 | ret = adapter->nic_ops->config_led(adapter, 1, 0xf); |
897d3596 SC |
853 | if (ret) { |
854 | dev_err(&adapter->pdev->dev, | |
855 | "Failed to set LED blink state.\n"); | |
856 | return ret; | |
857 | } | |
858 | ||
859 | msleep_interruptible(val * 1000); | |
860 | ||
2e9d722d | 861 | ret = adapter->nic_ops->config_led(adapter, 0, 0xf); |
897d3596 SC |
862 | if (ret) { |
863 | dev_err(&adapter->pdev->dev, | |
864 | "Failed to reset LED blink state.\n"); | |
865 | return ret; | |
866 | } | |
867 | ||
868 | return 0; | |
869 | } | |
870 | ||
af19b491 AKS |
871 | static void |
872 | qlcnic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |
873 | { | |
874 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
875 | u32 wol_cfg; | |
876 | ||
877 | wol->supported = 0; | |
878 | wol->wolopts = 0; | |
879 | ||
880 | wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG_NV); | |
881 | if (wol_cfg & (1UL << adapter->portnum)) | |
882 | wol->supported |= WAKE_MAGIC; | |
883 | ||
884 | wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG); | |
885 | if (wol_cfg & (1UL << adapter->portnum)) | |
886 | wol->wolopts |= WAKE_MAGIC; | |
887 | } | |
888 | ||
889 | static int | |
890 | qlcnic_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |
891 | { | |
892 | struct qlcnic_adapter *adapter = netdev_priv(dev); | |
893 | u32 wol_cfg; | |
894 | ||
895 | if (wol->wolopts & ~WAKE_MAGIC) | |
896 | return -EOPNOTSUPP; | |
897 | ||
898 | wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG_NV); | |
899 | if (!(wol_cfg & (1 << adapter->portnum))) | |
900 | return -EOPNOTSUPP; | |
901 | ||
902 | wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG); | |
903 | if (wol->wolopts & WAKE_MAGIC) | |
904 | wol_cfg |= 1UL << adapter->portnum; | |
905 | else | |
906 | wol_cfg &= ~(1UL << adapter->portnum); | |
907 | ||
908 | QLCWR32(adapter, QLCNIC_WOL_CONFIG, wol_cfg); | |
909 | ||
910 | return 0; | |
911 | } | |
912 | ||
913 | /* | |
914 | * Set the coalescing parameters. Currently only normal is supported. | |
915 | * If rx_coalesce_usecs == 0 or rx_max_coalesced_frames == 0 then set the | |
916 | * firmware coalescing to default. | |
917 | */ | |
918 | static int qlcnic_set_intr_coalesce(struct net_device *netdev, | |
919 | struct ethtool_coalesce *ethcoal) | |
920 | { | |
921 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | |
922 | ||
8a15ad1f | 923 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) |
af19b491 AKS |
924 | return -EINVAL; |
925 | ||
926 | /* | |
927 | * Return Error if unsupported values or | |
928 | * unsupported parameters are set. | |
929 | */ | |
930 | if (ethcoal->rx_coalesce_usecs > 0xffff || | |
931 | ethcoal->rx_max_coalesced_frames > 0xffff || | |
932 | ethcoal->tx_coalesce_usecs > 0xffff || | |
933 | ethcoal->tx_max_coalesced_frames > 0xffff || | |
934 | ethcoal->rx_coalesce_usecs_irq || | |
935 | ethcoal->rx_max_coalesced_frames_irq || | |
936 | ethcoal->tx_coalesce_usecs_irq || | |
937 | ethcoal->tx_max_coalesced_frames_irq || | |
938 | ethcoal->stats_block_coalesce_usecs || | |
939 | ethcoal->use_adaptive_rx_coalesce || | |
940 | ethcoal->use_adaptive_tx_coalesce || | |
941 | ethcoal->pkt_rate_low || | |
942 | ethcoal->rx_coalesce_usecs_low || | |
943 | ethcoal->rx_max_coalesced_frames_low || | |
944 | ethcoal->tx_coalesce_usecs_low || | |
945 | ethcoal->tx_max_coalesced_frames_low || | |
946 | ethcoal->pkt_rate_high || | |
947 | ethcoal->rx_coalesce_usecs_high || | |
948 | ethcoal->rx_max_coalesced_frames_high || | |
949 | ethcoal->tx_coalesce_usecs_high || | |
950 | ethcoal->tx_max_coalesced_frames_high) | |
951 | return -EINVAL; | |
952 | ||
953 | if (!ethcoal->rx_coalesce_usecs || | |
954 | !ethcoal->rx_max_coalesced_frames) { | |
955 | adapter->coal.flags = QLCNIC_INTR_DEFAULT; | |
956 | adapter->coal.normal.data.rx_time_us = | |
957 | QLCNIC_DEFAULT_INTR_COALESCE_RX_TIME_US; | |
958 | adapter->coal.normal.data.rx_packets = | |
959 | QLCNIC_DEFAULT_INTR_COALESCE_RX_PACKETS; | |
960 | } else { | |
961 | adapter->coal.flags = 0; | |
962 | adapter->coal.normal.data.rx_time_us = | |
963 | ethcoal->rx_coalesce_usecs; | |
964 | adapter->coal.normal.data.rx_packets = | |
965 | ethcoal->rx_max_coalesced_frames; | |
966 | } | |
967 | adapter->coal.normal.data.tx_time_us = ethcoal->tx_coalesce_usecs; | |
968 | adapter->coal.normal.data.tx_packets = | |
969 | ethcoal->tx_max_coalesced_frames; | |
970 | ||
971 | qlcnic_config_intr_coalesce(adapter); | |
972 | ||
973 | return 0; | |
974 | } | |
975 | ||
976 | static int qlcnic_get_intr_coalesce(struct net_device *netdev, | |
977 | struct ethtool_coalesce *ethcoal) | |
978 | { | |
979 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | |
980 | ||
981 | if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC) | |
982 | return -EINVAL; | |
983 | ||
984 | ethcoal->rx_coalesce_usecs = adapter->coal.normal.data.rx_time_us; | |
985 | ethcoal->tx_coalesce_usecs = adapter->coal.normal.data.tx_time_us; | |
986 | ethcoal->rx_max_coalesced_frames = | |
987 | adapter->coal.normal.data.rx_packets; | |
988 | ethcoal->tx_max_coalesced_frames = | |
989 | adapter->coal.normal.data.tx_packets; | |
990 | ||
991 | return 0; | |
992 | } | |
993 | ||
994 | static int qlcnic_set_flags(struct net_device *netdev, u32 data) | |
995 | { | |
996 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | |
997 | int hw_lro; | |
998 | ||
deaec0f6 | 999 | if (data & ~ETH_FLAG_LRO) |
97d1935a | 1000 | return -EINVAL; |
deaec0f6 | 1001 | |
af19b491 AKS |
1002 | if (!(adapter->capabilities & QLCNIC_FW_CAPABILITY_HW_LRO)) |
1003 | return -EINVAL; | |
1004 | ||
deaec0f6 SG |
1005 | if (data & ETH_FLAG_LRO) { |
1006 | hw_lro = QLCNIC_LRO_ENABLED; | |
1007 | netdev->features |= NETIF_F_LRO; | |
1008 | } else { | |
1009 | hw_lro = 0; | |
1010 | netdev->features &= ~NETIF_F_LRO; | |
1011 | } | |
af19b491 AKS |
1012 | |
1013 | if (qlcnic_config_hw_lro(adapter, hw_lro)) | |
1014 | return -EIO; | |
1015 | ||
1016 | if ((hw_lro == 0) && qlcnic_send_lro_cleanup(adapter)) | |
1017 | return -EIO; | |
1018 | ||
1019 | ||
1020 | return 0; | |
1021 | } | |
1022 | ||
65b5b420 AKS |
1023 | static u32 qlcnic_get_msglevel(struct net_device *netdev) |
1024 | { | |
1025 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | |
1026 | ||
1027 | return adapter->msg_enable; | |
1028 | } | |
1029 | ||
1030 | static void qlcnic_set_msglevel(struct net_device *netdev, u32 msglvl) | |
1031 | { | |
1032 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | |
1033 | ||
1034 | adapter->msg_enable = msglvl; | |
1035 | } | |
1036 | ||
af19b491 AKS |
1037 | const struct ethtool_ops qlcnic_ethtool_ops = { |
1038 | .get_settings = qlcnic_get_settings, | |
1039 | .set_settings = qlcnic_set_settings, | |
1040 | .get_drvinfo = qlcnic_get_drvinfo, | |
1041 | .get_regs_len = qlcnic_get_regs_len, | |
1042 | .get_regs = qlcnic_get_regs, | |
1043 | .get_link = ethtool_op_get_link, | |
1044 | .get_eeprom_len = qlcnic_get_eeprom_len, | |
1045 | .get_eeprom = qlcnic_get_eeprom, | |
1046 | .get_ringparam = qlcnic_get_ringparam, | |
1047 | .set_ringparam = qlcnic_set_ringparam, | |
1048 | .get_pauseparam = qlcnic_get_pauseparam, | |
1049 | .set_pauseparam = qlcnic_set_pauseparam, | |
8bae5698 | 1050 | .get_tx_csum = qlcnic_get_tx_csum, |
af19b491 AKS |
1051 | .set_tx_csum = ethtool_op_set_tx_csum, |
1052 | .set_sg = ethtool_op_set_sg, | |
1053 | .get_tso = qlcnic_get_tso, | |
1054 | .set_tso = qlcnic_set_tso, | |
1055 | .get_wol = qlcnic_get_wol, | |
1056 | .set_wol = qlcnic_set_wol, | |
1057 | .self_test = qlcnic_diag_test, | |
1058 | .get_strings = qlcnic_get_strings, | |
1059 | .get_ethtool_stats = qlcnic_get_ethtool_stats, | |
1060 | .get_sset_count = qlcnic_get_sset_count, | |
1061 | .get_rx_csum = qlcnic_get_rx_csum, | |
1062 | .set_rx_csum = qlcnic_set_rx_csum, | |
1063 | .get_coalesce = qlcnic_get_intr_coalesce, | |
1064 | .set_coalesce = qlcnic_set_intr_coalesce, | |
1065 | .get_flags = ethtool_op_get_flags, | |
1066 | .set_flags = qlcnic_set_flags, | |
897d3596 | 1067 | .phys_id = qlcnic_blink_led, |
65b5b420 AKS |
1068 | .set_msglevel = qlcnic_set_msglevel, |
1069 | .get_msglevel = qlcnic_get_msglevel, | |
af19b491 | 1070 | }; |