Commit | Line | Data |
---|---|---|
3d396eb1 | 1 | /* |
5d242f1c | 2 | * Copyright (C) 2003 - 2009 NetXen, Inc. |
3d396eb1 | 3 | * All rights reserved. |
80922fbc | 4 | * |
3d396eb1 AK |
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. | |
80922fbc | 9 | * |
3d396eb1 AK |
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. | |
80922fbc | 14 | * |
3d396eb1 AK |
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. | |
80922fbc | 19 | * |
3d396eb1 AK |
20 | * The full GNU General Public License is included in this distribution |
21 | * in the file called LICENSE. | |
80922fbc | 22 | * |
3d396eb1 AK |
23 | * Contact Information: |
24 | * info@netxen.com | |
5d242f1c DP |
25 | * NetXen Inc, |
26 | * 18922 Forge Drive | |
27 | * Cupertino, CA 95014-0701 | |
3d396eb1 AK |
28 | * |
29 | */ | |
30 | ||
31 | #include <linux/types.h> | |
27d2ab54 | 32 | #include <linux/delay.h> |
3d396eb1 AK |
33 | #include <linux/pci.h> |
34 | #include <asm/io.h> | |
35 | #include <linux/netdevice.h> | |
36 | #include <linux/ethtool.h> | |
3d396eb1 | 37 | |
3d396eb1 | 38 | #include "netxen_nic.h" |
6c80b18d | 39 | #include "netxen_nic_hw.h" |
3d396eb1 AK |
40 | |
41 | struct netxen_nic_stats { | |
42 | char stat_string[ETH_GSTRING_LEN]; | |
43 | int sizeof_stat; | |
44 | int stat_offset; | |
45 | }; | |
46 | ||
3176ff3e MT |
47 | #define NETXEN_NIC_STAT(m) sizeof(((struct netxen_adapter *)0)->m), \ |
48 | offsetof(struct netxen_adapter, m) | |
3d396eb1 | 49 | |
cb8011ad AK |
50 | #define NETXEN_NIC_PORT_WINDOW 0x10000 |
51 | #define NETXEN_NIC_INVALID_DATA 0xDEADBEEF | |
52 | ||
3d396eb1 | 53 | static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = { |
3d396eb1 | 54 | {"xmit_called", NETXEN_NIC_STAT(stats.xmitcalled)}, |
3d396eb1 | 55 | {"xmit_finished", NETXEN_NIC_STAT(stats.xmitfinished)}, |
e98e3350 | 56 | {"rx_dropped", NETXEN_NIC_STAT(stats.rxdropped)}, |
3d396eb1 | 57 | {"tx_dropped", NETXEN_NIC_STAT(stats.txdropped)}, |
3d396eb1 | 58 | {"csummed", NETXEN_NIC_STAT(stats.csummed)}, |
1bb482f8 NK |
59 | {"rx_pkts", NETXEN_NIC_STAT(stats.rx_pkts)}, |
60 | {"lro_pkts", NETXEN_NIC_STAT(stats.lro_pkts)}, | |
3d396eb1 AK |
61 | {"rx_bytes", NETXEN_NIC_STAT(stats.rxbytes)}, |
62 | {"tx_bytes", NETXEN_NIC_STAT(stats.txbytes)}, | |
63 | }; | |
64 | ||
92104e94 | 65 | #define NETXEN_NIC_STATS_LEN ARRAY_SIZE(netxen_nic_gstrings_stats) |
3d396eb1 AK |
66 | |
67 | static const char netxen_nic_gstrings_test[][ETH_GSTRING_LEN] = { | |
0c25cfe1 | 68 | "Register_Test_on_offline", |
3d396eb1 AK |
69 | "Link_Test_on_offline" |
70 | }; | |
71 | ||
4c3616cd | 72 | #define NETXEN_NIC_TEST_LEN ARRAY_SIZE(netxen_nic_gstrings_test) |
3d396eb1 AK |
73 | |
74 | #define NETXEN_NIC_REGS_COUNT 42 | |
75 | #define NETXEN_NIC_REGS_LEN (NETXEN_NIC_REGS_COUNT * sizeof(__le32)) | |
76 | #define NETXEN_MAX_EEPROM_LEN 1024 | |
77 | ||
78 | static int netxen_nic_get_eeprom_len(struct net_device *dev) | |
79 | { | |
0d04761d | 80 | return NETXEN_FLASH_TOTAL_SIZE; |
3d396eb1 AK |
81 | } |
82 | ||
83 | static void | |
84 | netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) | |
85 | { | |
3176ff3e | 86 | struct netxen_adapter *adapter = netdev_priv(dev); |
3ce06a32 | 87 | unsigned long flags; |
cb8011ad AK |
88 | u32 fw_major = 0; |
89 | u32 fw_minor = 0; | |
90 | u32 fw_build = 0; | |
3d396eb1 | 91 | |
80922fbc | 92 | strncpy(drvinfo->driver, netxen_nic_driver_name, 32); |
3d396eb1 | 93 | strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32); |
3ce06a32 | 94 | write_lock_irqsave(&adapter->adapter_lock, flags); |
f98a9f69 DP |
95 | fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR); |
96 | fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR); | |
97 | fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB); | |
3ce06a32 | 98 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
3d396eb1 AK |
99 | sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); |
100 | ||
3176ff3e | 101 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); |
3d396eb1 AK |
102 | drvinfo->regdump_len = NETXEN_NIC_REGS_LEN; |
103 | drvinfo->eedump_len = netxen_nic_get_eeprom_len(dev); | |
104 | } | |
105 | ||
106 | static int | |
107 | netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |
108 | { | |
3176ff3e | 109 | struct netxen_adapter *adapter = netdev_priv(dev); |
3bf26ce3 | 110 | int check_sfp_module = 0; |
3d396eb1 AK |
111 | |
112 | /* read which mode */ | |
1e2d0059 | 113 | if (adapter->ahw.port_type == NETXEN_NIC_GBE) { |
3d396eb1 AK |
114 | ecmd->supported = (SUPPORTED_10baseT_Half | |
115 | SUPPORTED_10baseT_Full | | |
116 | SUPPORTED_100baseT_Half | | |
117 | SUPPORTED_100baseT_Full | | |
118 | SUPPORTED_1000baseT_Half | | |
cb8011ad | 119 | SUPPORTED_1000baseT_Full); |
3d396eb1 AK |
120 | |
121 | ecmd->advertising = (ADVERTISED_100baseT_Half | | |
122 | ADVERTISED_100baseT_Full | | |
123 | ADVERTISED_1000baseT_Half | | |
cb8011ad | 124 | ADVERTISED_1000baseT_Full); |
3d396eb1 AK |
125 | |
126 | ecmd->port = PORT_TP; | |
127 | ||
c7860a2a DP |
128 | ecmd->speed = adapter->link_speed; |
129 | ecmd->duplex = adapter->link_duplex; | |
130 | ecmd->autoneg = adapter->link_autoneg; | |
24a7a455 | 131 | |
1e2d0059 | 132 | } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { |
24a7a455 DP |
133 | u32 val; |
134 | ||
f98a9f69 | 135 | val = NXRD32(adapter, NETXEN_PORT_MODE_ADDR); |
24a7a455 DP |
136 | if (val == NETXEN_PORT_MODE_802_3_AP) { |
137 | ecmd->supported = SUPPORTED_1000baseT_Full; | |
138 | ecmd->advertising = ADVERTISED_1000baseT_Full; | |
139 | } else { | |
140 | ecmd->supported = SUPPORTED_10000baseT_Full; | |
141 | ecmd->advertising = ADVERTISED_10000baseT_Full; | |
142 | } | |
143 | ||
3bf26ce3 DP |
144 | if (netif_running(dev) && adapter->has_link_events) { |
145 | ecmd->speed = adapter->link_speed; | |
146 | ecmd->autoneg = adapter->link_autoneg; | |
147 | ecmd->duplex = adapter->link_duplex; | |
148 | goto skip; | |
149 | } | |
150 | ||
3d396eb1 AK |
151 | ecmd->port = PORT_TP; |
152 | ||
24a7a455 DP |
153 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { |
154 | u16 pcifn = adapter->ahw.pci_func; | |
155 | ||
f98a9f69 | 156 | val = NXRD32(adapter, P3_LINK_SPEED_REG(pcifn)); |
24a7a455 DP |
157 | ecmd->speed = P3_LINK_SPEED_MHZ * |
158 | P3_LINK_SPEED_VAL(pcifn, val); | |
159 | } else | |
160 | ecmd->speed = SPEED_10000; | |
161 | ||
3d396eb1 | 162 | ecmd->duplex = DUPLEX_FULL; |
3d396eb1 | 163 | ecmd->autoneg = AUTONEG_DISABLE; |
cb8011ad AK |
164 | } else |
165 | return -EIO; | |
166 | ||
3bf26ce3 | 167 | skip: |
c7860a2a | 168 | ecmd->phy_address = adapter->physical_port; |
cb8011ad AK |
169 | ecmd->transceiver = XCVR_EXTERNAL; |
170 | ||
e98e3350 | 171 | switch (adapter->ahw.board_type) { |
cb8011ad AK |
172 | case NETXEN_BRDTYPE_P2_SB35_4G: |
173 | case NETXEN_BRDTYPE_P2_SB31_2G: | |
e4c93c81 DP |
174 | case NETXEN_BRDTYPE_P3_REF_QG: |
175 | case NETXEN_BRDTYPE_P3_4_GB: | |
176 | case NETXEN_BRDTYPE_P3_4_GB_MM: | |
e4c93c81 | 177 | |
cb8011ad AK |
178 | ecmd->supported |= SUPPORTED_Autoneg; |
179 | ecmd->advertising |= ADVERTISED_Autoneg; | |
180 | case NETXEN_BRDTYPE_P2_SB31_10G_CX4: | |
e4c93c81 DP |
181 | case NETXEN_BRDTYPE_P3_10G_CX4: |
182 | case NETXEN_BRDTYPE_P3_10G_CX4_LP: | |
c7860a2a | 183 | case NETXEN_BRDTYPE_P3_10000_BASE_T: |
cb8011ad AK |
184 | ecmd->supported |= SUPPORTED_TP; |
185 | ecmd->advertising |= ADVERTISED_TP; | |
186 | ecmd->port = PORT_TP; | |
1e2d0059 | 187 | ecmd->autoneg = (adapter->ahw.board_type == |
cb8011ad | 188 | NETXEN_BRDTYPE_P2_SB31_10G_CX4) ? |
3176ff3e | 189 | (AUTONEG_DISABLE) : (adapter->link_autoneg); |
cb8011ad AK |
190 | break; |
191 | case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ: | |
192 | case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: | |
e4c93c81 DP |
193 | case NETXEN_BRDTYPE_P3_IMEZ: |
194 | case NETXEN_BRDTYPE_P3_XG_LOM: | |
195 | case NETXEN_BRDTYPE_P3_HMEZ: | |
cb8011ad AK |
196 | ecmd->supported |= SUPPORTED_MII; |
197 | ecmd->advertising |= ADVERTISED_MII; | |
3bf26ce3 | 198 | ecmd->port = PORT_MII; |
cb8011ad AK |
199 | ecmd->autoneg = AUTONEG_DISABLE; |
200 | break; | |
e4c93c81 | 201 | case NETXEN_BRDTYPE_P3_10G_SFP_PLUS: |
a70f9393 DP |
202 | case NETXEN_BRDTYPE_P3_10G_SFP_CT: |
203 | case NETXEN_BRDTYPE_P3_10G_SFP_QT: | |
c7860a2a DP |
204 | ecmd->advertising |= ADVERTISED_TP; |
205 | ecmd->supported |= SUPPORTED_TP; | |
3bf26ce3 DP |
206 | check_sfp_module = netif_running(dev) && |
207 | adapter->has_link_events; | |
c7860a2a | 208 | case NETXEN_BRDTYPE_P2_SB31_10G: |
e4c93c81 | 209 | case NETXEN_BRDTYPE_P3_10G_XFP: |
cb8011ad AK |
210 | ecmd->supported |= SUPPORTED_FIBRE; |
211 | ecmd->advertising |= ADVERTISED_FIBRE; | |
212 | ecmd->port = PORT_FIBRE; | |
213 | ecmd->autoneg = AUTONEG_DISABLE; | |
214 | break; | |
c7860a2a | 215 | case NETXEN_BRDTYPE_P3_10G_TP: |
1e2d0059 | 216 | if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { |
c7860a2a DP |
217 | ecmd->autoneg = AUTONEG_DISABLE; |
218 | ecmd->supported |= (SUPPORTED_FIBRE | SUPPORTED_TP); | |
219 | ecmd->advertising |= | |
220 | (ADVERTISED_FIBRE | ADVERTISED_TP); | |
221 | ecmd->port = PORT_FIBRE; | |
3bf26ce3 DP |
222 | check_sfp_module = netif_running(dev) && |
223 | adapter->has_link_events; | |
c7860a2a DP |
224 | } else { |
225 | ecmd->autoneg = AUTONEG_ENABLE; | |
226 | ecmd->supported |= (SUPPORTED_TP |SUPPORTED_Autoneg); | |
227 | ecmd->advertising |= | |
228 | (ADVERTISED_TP | ADVERTISED_Autoneg); | |
229 | ecmd->port = PORT_TP; | |
230 | } | |
231 | break; | |
cb8011ad | 232 | default: |
71bd7877 | 233 | printk(KERN_ERR "netxen-nic: Unsupported board model %d\n", |
e98e3350 | 234 | adapter->ahw.board_type); |
cb8011ad | 235 | return -EIO; |
3d396eb1 AK |
236 | } |
237 | ||
3bf26ce3 DP |
238 | if (check_sfp_module) { |
239 | switch (adapter->module_type) { | |
240 | case LINKEVENT_MODULE_OPTICAL_UNKNOWN: | |
241 | case LINKEVENT_MODULE_OPTICAL_SRLR: | |
242 | case LINKEVENT_MODULE_OPTICAL_LRM: | |
243 | case LINKEVENT_MODULE_OPTICAL_SFP_1G: | |
244 | ecmd->port = PORT_FIBRE; | |
245 | break; | |
246 | case LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLE: | |
247 | case LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLELEN: | |
248 | case LINKEVENT_MODULE_TWINAX: | |
249 | ecmd->port = PORT_TP; | |
5103c9f7 | 250 | break; |
3bf26ce3 DP |
251 | default: |
252 | ecmd->port = -1; | |
253 | } | |
254 | } | |
255 | ||
cb8011ad | 256 | return 0; |
3d396eb1 AK |
257 | } |
258 | ||
259 | static int | |
260 | netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |
261 | { | |
3176ff3e | 262 | struct netxen_adapter *adapter = netdev_priv(dev); |
a608ab9c | 263 | __u32 status; |
3d396eb1 AK |
264 | |
265 | /* read which mode */ | |
1e2d0059 | 266 | if (adapter->ahw.port_type == NETXEN_NIC_GBE) { |
3d396eb1 | 267 | /* autonegotiation */ |
80922fbc | 268 | if (adapter->phy_write |
13ba9c77 | 269 | && adapter->phy_write(adapter, |
80922fbc | 270 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, |
a608ab9c | 271 | ecmd->autoneg) != 0) |
3d396eb1 AK |
272 | return -EIO; |
273 | else | |
3176ff3e | 274 | adapter->link_autoneg = ecmd->autoneg; |
3d396eb1 | 275 | |
80922fbc | 276 | if (adapter->phy_read |
13ba9c77 | 277 | && adapter->phy_read(adapter, |
80922fbc AK |
278 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
279 | &status) != 0) | |
3d396eb1 AK |
280 | return -EIO; |
281 | ||
282 | /* speed */ | |
283 | switch (ecmd->speed) { | |
284 | case SPEED_10: | |
285 | netxen_set_phy_speed(status, 0); | |
286 | break; | |
287 | case SPEED_100: | |
288 | netxen_set_phy_speed(status, 1); | |
289 | break; | |
290 | case SPEED_1000: | |
291 | netxen_set_phy_speed(status, 2); | |
292 | break; | |
293 | } | |
294 | /* set duplex mode */ | |
295 | if (ecmd->duplex == DUPLEX_HALF) | |
296 | netxen_clear_phy_duplex(status); | |
297 | if (ecmd->duplex == DUPLEX_FULL) | |
298 | netxen_set_phy_duplex(status); | |
80922fbc | 299 | if (adapter->phy_write |
13ba9c77 | 300 | && adapter->phy_write(adapter, |
80922fbc AK |
301 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
302 | *((int *)&status)) != 0) | |
3d396eb1 AK |
303 | return -EIO; |
304 | else { | |
3176ff3e MT |
305 | adapter->link_speed = ecmd->speed; |
306 | adapter->link_duplex = ecmd->duplex; | |
3d396eb1 AK |
307 | } |
308 | } else | |
309 | return -EOPNOTSUPP; | |
310 | ||
1abd266f SH |
311 | if (!netif_running(dev)) |
312 | return 0; | |
313 | ||
314 | dev->netdev_ops->ndo_stop(dev); | |
315 | return dev->netdev_ops->ndo_open(dev); | |
3d396eb1 AK |
316 | } |
317 | ||
318 | static int netxen_nic_get_regs_len(struct net_device *dev) | |
319 | { | |
320 | return NETXEN_NIC_REGS_LEN; | |
321 | } | |
322 | ||
323 | struct netxen_niu_regs { | |
a608ab9c | 324 | __u32 reg[NETXEN_NIC_REGS_COUNT]; |
3d396eb1 AK |
325 | }; |
326 | ||
327 | static struct netxen_niu_regs niu_registers[] = { | |
328 | { | |
329 | /* GB Mode */ | |
330 | { | |
331 | NETXEN_NIU_GB_SERDES_RESET, | |
332 | NETXEN_NIU_GB0_MII_MODE, | |
333 | NETXEN_NIU_GB1_MII_MODE, | |
334 | NETXEN_NIU_GB2_MII_MODE, | |
335 | NETXEN_NIU_GB3_MII_MODE, | |
336 | NETXEN_NIU_GB0_GMII_MODE, | |
337 | NETXEN_NIU_GB1_GMII_MODE, | |
338 | NETXEN_NIU_GB2_GMII_MODE, | |
339 | NETXEN_NIU_GB3_GMII_MODE, | |
340 | NETXEN_NIU_REMOTE_LOOPBACK, | |
341 | NETXEN_NIU_GB0_HALF_DUPLEX, | |
342 | NETXEN_NIU_GB1_HALF_DUPLEX, | |
343 | NETXEN_NIU_RESET_SYS_FIFOS, | |
344 | NETXEN_NIU_GB_CRC_DROP, | |
345 | NETXEN_NIU_GB_DROP_WRONGADDR, | |
346 | NETXEN_NIU_TEST_MUX_CTL, | |
347 | ||
348 | NETXEN_NIU_GB_MAC_CONFIG_0(0), | |
349 | NETXEN_NIU_GB_MAC_CONFIG_1(0), | |
350 | NETXEN_NIU_GB_HALF_DUPLEX_CTRL(0), | |
351 | NETXEN_NIU_GB_MAX_FRAME_SIZE(0), | |
352 | NETXEN_NIU_GB_TEST_REG(0), | |
353 | NETXEN_NIU_GB_MII_MGMT_CONFIG(0), | |
354 | NETXEN_NIU_GB_MII_MGMT_COMMAND(0), | |
355 | NETXEN_NIU_GB_MII_MGMT_ADDR(0), | |
356 | NETXEN_NIU_GB_MII_MGMT_CTRL(0), | |
357 | NETXEN_NIU_GB_MII_MGMT_STATUS(0), | |
358 | NETXEN_NIU_GB_MII_MGMT_INDICATE(0), | |
359 | NETXEN_NIU_GB_INTERFACE_CTRL(0), | |
360 | NETXEN_NIU_GB_INTERFACE_STATUS(0), | |
361 | NETXEN_NIU_GB_STATION_ADDR_0(0), | |
362 | NETXEN_NIU_GB_STATION_ADDR_1(0), | |
363 | -1, | |
364 | } | |
365 | }, | |
366 | { | |
367 | /* XG Mode */ | |
368 | { | |
369 | NETXEN_NIU_XG_SINGLE_TERM, | |
370 | NETXEN_NIU_XG_DRIVE_HI, | |
371 | NETXEN_NIU_XG_DRIVE_LO, | |
372 | NETXEN_NIU_XG_DTX, | |
373 | NETXEN_NIU_XG_DEQ, | |
374 | NETXEN_NIU_XG_WORD_ALIGN, | |
375 | NETXEN_NIU_XG_RESET, | |
376 | NETXEN_NIU_XG_POWER_DOWN, | |
377 | NETXEN_NIU_XG_RESET_PLL, | |
378 | NETXEN_NIU_XG_SERDES_LOOPBACK, | |
379 | NETXEN_NIU_XG_DO_BYTE_ALIGN, | |
380 | NETXEN_NIU_XG_TX_ENABLE, | |
381 | NETXEN_NIU_XG_RX_ENABLE, | |
382 | NETXEN_NIU_XG_STATUS, | |
383 | NETXEN_NIU_XG_PAUSE_THRESHOLD, | |
384 | NETXEN_NIU_XGE_CONFIG_0, | |
385 | NETXEN_NIU_XGE_CONFIG_1, | |
386 | NETXEN_NIU_XGE_IPG, | |
387 | NETXEN_NIU_XGE_STATION_ADDR_0_HI, | |
388 | NETXEN_NIU_XGE_STATION_ADDR_0_1, | |
389 | NETXEN_NIU_XGE_STATION_ADDR_1_LO, | |
390 | NETXEN_NIU_XGE_STATUS, | |
391 | NETXEN_NIU_XGE_MAX_FRAME_SIZE, | |
392 | NETXEN_NIU_XGE_PAUSE_FRAME_VALUE, | |
393 | NETXEN_NIU_XGE_TX_BYTE_CNT, | |
394 | NETXEN_NIU_XGE_TX_FRAME_CNT, | |
395 | NETXEN_NIU_XGE_RX_BYTE_CNT, | |
396 | NETXEN_NIU_XGE_RX_FRAME_CNT, | |
397 | NETXEN_NIU_XGE_AGGR_ERROR_CNT, | |
398 | NETXEN_NIU_XGE_MULTICAST_FRAME_CNT, | |
399 | NETXEN_NIU_XGE_UNICAST_FRAME_CNT, | |
400 | NETXEN_NIU_XGE_CRC_ERROR_CNT, | |
401 | NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR, | |
402 | NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR, | |
403 | NETXEN_NIU_XGE_LOCAL_ERROR_CNT, | |
404 | NETXEN_NIU_XGE_REMOTE_ERROR_CNT, | |
405 | NETXEN_NIU_XGE_CONTROL_CHAR_CNT, | |
406 | NETXEN_NIU_XGE_PAUSE_FRAME_CNT, | |
407 | -1, | |
408 | } | |
409 | } | |
410 | }; | |
411 | ||
412 | static void | |
413 | netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) | |
414 | { | |
3176ff3e | 415 | struct netxen_adapter *adapter = netdev_priv(dev); |
a608ab9c | 416 | __u32 mode, *regs_buff = p; |
3d396eb1 AK |
417 | int i, window; |
418 | ||
419 | memset(p, 0, NETXEN_NIC_REGS_LEN); | |
420 | regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) | | |
3176ff3e | 421 | (adapter->pdev)->device; |
3d396eb1 | 422 | /* which mode */ |
f98a9f69 | 423 | regs_buff[0] = NXRD32(adapter, NETXEN_NIU_MODE); |
3d396eb1 AK |
424 | mode = regs_buff[0]; |
425 | ||
426 | /* Common registers to all the modes */ | |
f98a9f69 | 427 | regs_buff[2] = NXRD32(adapter, NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER); |
3d396eb1 AK |
428 | /* GB/XGB Mode */ |
429 | mode = (mode / 2) - 1; | |
430 | window = 0; | |
431 | if (mode <= 1) { | |
432 | for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) { | |
433 | /* GB: port specific registers */ | |
434 | if (mode == 0 && i >= 19) | |
3276fbad | 435 | window = adapter->physical_port * |
3176ff3e | 436 | NETXEN_NIC_PORT_WINDOW; |
3d396eb1 | 437 | |
f98a9f69 | 438 | regs_buff[i] = NXRD32(adapter, |
1fbe6323 | 439 | niu_registers[mode].reg[i - 3] + window); |
3d396eb1 AK |
440 | } |
441 | ||
442 | } | |
443 | } | |
444 | ||
e45d9ab4 | 445 | static u32 netxen_nic_test_link(struct net_device *dev) |
3d396eb1 | 446 | { |
3176ff3e | 447 | struct netxen_adapter *adapter = netdev_priv(dev); |
a608ab9c | 448 | __u32 status; |
0c25cfe1 | 449 | int val; |
3d396eb1 AK |
450 | |
451 | /* read which mode */ | |
1e2d0059 | 452 | if (adapter->ahw.port_type == NETXEN_NIC_GBE) { |
80922fbc | 453 | if (adapter->phy_read |
13ba9c77 | 454 | && adapter->phy_read(adapter, |
80922fbc AK |
455 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
456 | &status) != 0) | |
3d396eb1 | 457 | return -EIO; |
0c25cfe1 LCMT |
458 | else { |
459 | val = netxen_get_phy_link(status); | |
460 | return !val; | |
461 | } | |
1e2d0059 | 462 | } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { |
f98a9f69 | 463 | val = NXRD32(adapter, CRB_XG_STATE); |
0c25cfe1 | 464 | return (val == XG_LINK_UP) ? 0 : 1; |
3d396eb1 AK |
465 | } |
466 | return -EIO; | |
467 | } | |
468 | ||
469 | static int | |
470 | netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, | |
471 | u8 * bytes) | |
472 | { | |
3176ff3e | 473 | struct netxen_adapter *adapter = netdev_priv(dev); |
3d396eb1 | 474 | int offset; |
27d2ab54 | 475 | int ret; |
3d396eb1 AK |
476 | |
477 | if (eeprom->len == 0) | |
478 | return -EINVAL; | |
479 | ||
4790654c | 480 | eeprom->magic = (adapter->pdev)->vendor | |
3176ff3e | 481 | ((adapter->pdev)->device << 16); |
27d2ab54 AK |
482 | offset = eeprom->offset; |
483 | ||
4790654c | 484 | ret = netxen_rom_fast_read_words(adapter, offset, bytes, |
27d2ab54 AK |
485 | eeprom->len); |
486 | if (ret < 0) | |
487 | return ret; | |
488 | ||
3d396eb1 AK |
489 | return 0; |
490 | } | |
491 | ||
492 | static void | |
7042cd8f AKS |
493 | netxen_nic_get_ringparam(struct net_device *dev, |
494 | struct ethtool_ringparam *ring) | |
3d396eb1 | 495 | { |
3176ff3e | 496 | struct netxen_adapter *adapter = netdev_priv(dev); |
3d396eb1 | 497 | |
24767ab1 DP |
498 | ring->rx_pending = adapter->num_rxd; |
499 | ring->rx_jumbo_pending = adapter->num_jumbo_rxd; | |
500 | ring->rx_jumbo_pending += adapter->num_lro_rxd; | |
438627c7 | 501 | ring->tx_pending = adapter->num_txd; |
3d396eb1 | 502 | |
24767ab1 | 503 | if (adapter->ahw.port_type == NETXEN_NIC_GBE) { |
32ec8033 | 504 | ring->rx_max_pending = MAX_RCV_DESCRIPTORS_1G; |
24767ab1 DP |
505 | ring->rx_jumbo_max_pending = MAX_JUMBO_RCV_DESCRIPTORS_1G; |
506 | } else { | |
32ec8033 | 507 | ring->rx_max_pending = MAX_RCV_DESCRIPTORS_10G; |
24767ab1 DP |
508 | ring->rx_jumbo_max_pending = MAX_JUMBO_RCV_DESCRIPTORS_10G; |
509 | } | |
510 | ||
511 | ring->tx_max_pending = MAX_CMD_DESCRIPTORS; | |
512 | ||
3d396eb1 AK |
513 | ring->rx_mini_max_pending = 0; |
514 | ring->rx_mini_pending = 0; | |
3d396eb1 AK |
515 | } |
516 | ||
7042cd8f AKS |
517 | static u32 |
518 | netxen_validate_ringparam(u32 val, u32 min, u32 max, char *r_name) | |
519 | { | |
520 | u32 num_desc; | |
521 | num_desc = max(val, min); | |
522 | num_desc = min(num_desc, max); | |
523 | num_desc = roundup_pow_of_two(num_desc); | |
524 | ||
525 | if (val != num_desc) { | |
526 | printk(KERN_INFO "%s: setting %s ring size %d instead of %d\n", | |
527 | netxen_nic_driver_name, r_name, num_desc, val); | |
528 | } | |
529 | ||
530 | return num_desc; | |
531 | } | |
532 | ||
533 | static int | |
534 | netxen_nic_set_ringparam(struct net_device *dev, | |
535 | struct ethtool_ringparam *ring) | |
536 | { | |
537 | struct netxen_adapter *adapter = netdev_priv(dev); | |
538 | u16 max_rcv_desc = MAX_RCV_DESCRIPTORS_10G; | |
539 | u16 max_jumbo_desc = MAX_JUMBO_RCV_DESCRIPTORS_10G; | |
540 | u16 num_rxd, num_jumbo_rxd, num_txd; | |
541 | ||
542 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) | |
543 | return -EOPNOTSUPP; | |
544 | ||
545 | if (ring->rx_mini_pending) | |
546 | return -EOPNOTSUPP; | |
547 | ||
548 | if (adapter->ahw.port_type == NETXEN_NIC_GBE) { | |
549 | max_rcv_desc = MAX_RCV_DESCRIPTORS_1G; | |
550 | max_jumbo_desc = MAX_JUMBO_RCV_DESCRIPTORS_10G; | |
551 | } | |
552 | ||
553 | num_rxd = netxen_validate_ringparam(ring->rx_pending, | |
554 | MIN_RCV_DESCRIPTORS, max_rcv_desc, "rx"); | |
555 | ||
556 | num_jumbo_rxd = netxen_validate_ringparam(ring->rx_jumbo_pending, | |
557 | MIN_JUMBO_DESCRIPTORS, max_jumbo_desc, "rx jumbo"); | |
558 | ||
559 | num_txd = netxen_validate_ringparam(ring->tx_pending, | |
560 | MIN_CMD_DESCRIPTORS, MAX_CMD_DESCRIPTORS, "tx"); | |
561 | ||
562 | if (num_rxd == adapter->num_rxd && num_txd == adapter->num_txd && | |
563 | num_jumbo_rxd == adapter->num_jumbo_rxd) | |
564 | return 0; | |
565 | ||
566 | adapter->num_rxd = num_rxd; | |
567 | adapter->num_jumbo_rxd = num_jumbo_rxd; | |
568 | adapter->num_txd = num_txd; | |
569 | ||
570 | return netxen_nic_reset_context(adapter); | |
571 | } | |
572 | ||
3d396eb1 AK |
573 | static void |
574 | netxen_nic_get_pauseparam(struct net_device *dev, | |
575 | struct ethtool_pauseparam *pause) | |
576 | { | |
3176ff3e | 577 | struct netxen_adapter *adapter = netdev_priv(dev); |
a608ab9c | 578 | __u32 val; |
3276fbad | 579 | int port = adapter->physical_port; |
3d396eb1 | 580 | |
1e2d0059 | 581 | if (adapter->ahw.port_type == NETXEN_NIC_GBE) { |
6c80b18d MT |
582 | if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) |
583 | return; | |
3d396eb1 | 584 | /* get flow control settings */ |
f98a9f69 | 585 | val = NXRD32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port)); |
3d396eb1 | 586 | pause->rx_pause = netxen_gb_get_rx_flowctl(val); |
f98a9f69 | 587 | val = NXRD32(adapter, NETXEN_NIU_GB_PAUSE_CTL); |
6c80b18d MT |
588 | switch (port) { |
589 | case 0: | |
590 | pause->tx_pause = !(netxen_gb_get_gb0_mask(val)); | |
591 | break; | |
592 | case 1: | |
593 | pause->tx_pause = !(netxen_gb_get_gb1_mask(val)); | |
594 | break; | |
595 | case 2: | |
596 | pause->tx_pause = !(netxen_gb_get_gb2_mask(val)); | |
597 | break; | |
598 | case 3: | |
599 | default: | |
600 | pause->tx_pause = !(netxen_gb_get_gb3_mask(val)); | |
601 | break; | |
602 | } | |
1e2d0059 | 603 | } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { |
6c80b18d MT |
604 | if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) |
605 | return; | |
606 | pause->rx_pause = 1; | |
f98a9f69 | 607 | val = NXRD32(adapter, NETXEN_NIU_XG_PAUSE_CTL); |
6c80b18d MT |
608 | if (port == 0) |
609 | pause->tx_pause = !(netxen_xg_get_xg0_mask(val)); | |
610 | else | |
611 | pause->tx_pause = !(netxen_xg_get_xg1_mask(val)); | |
612 | } else { | |
4790654c | 613 | printk(KERN_ERR"%s: Unknown board type: %x\n", |
1e2d0059 | 614 | netxen_nic_driver_name, adapter->ahw.port_type); |
3d396eb1 AK |
615 | } |
616 | } | |
617 | ||
618 | static int | |
619 | netxen_nic_set_pauseparam(struct net_device *dev, | |
620 | struct ethtool_pauseparam *pause) | |
621 | { | |
3176ff3e | 622 | struct netxen_adapter *adapter = netdev_priv(dev); |
a608ab9c | 623 | __u32 val; |
3276fbad | 624 | int port = adapter->physical_port; |
3d396eb1 | 625 | /* read mode */ |
1e2d0059 | 626 | if (adapter->ahw.port_type == NETXEN_NIC_GBE) { |
6c80b18d MT |
627 | if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) |
628 | return -EIO; | |
3d396eb1 | 629 | /* set flow control */ |
f98a9f69 | 630 | val = NXRD32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port)); |
4790654c | 631 | |
3d396eb1 AK |
632 | if (pause->rx_pause) |
633 | netxen_gb_rx_flowctl(val); | |
634 | else | |
635 | netxen_gb_unset_rx_flowctl(val); | |
636 | ||
f98a9f69 | 637 | NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), |
6c80b18d | 638 | val); |
3d396eb1 | 639 | /* set autoneg */ |
f98a9f69 | 640 | val = NXRD32(adapter, NETXEN_NIU_GB_PAUSE_CTL); |
6c80b18d MT |
641 | switch (port) { |
642 | case 0: | |
643 | if (pause->tx_pause) | |
644 | netxen_gb_unset_gb0_mask(val); | |
645 | else | |
646 | netxen_gb_set_gb0_mask(val); | |
647 | break; | |
648 | case 1: | |
649 | if (pause->tx_pause) | |
650 | netxen_gb_unset_gb1_mask(val); | |
651 | else | |
652 | netxen_gb_set_gb1_mask(val); | |
653 | break; | |
654 | case 2: | |
655 | if (pause->tx_pause) | |
656 | netxen_gb_unset_gb2_mask(val); | |
657 | else | |
658 | netxen_gb_set_gb2_mask(val); | |
659 | break; | |
660 | case 3: | |
661 | default: | |
662 | if (pause->tx_pause) | |
663 | netxen_gb_unset_gb3_mask(val); | |
664 | else | |
665 | netxen_gb_set_gb3_mask(val); | |
666 | break; | |
667 | } | |
f98a9f69 | 668 | NXWR32(adapter, NETXEN_NIU_GB_PAUSE_CTL, val); |
1e2d0059 | 669 | } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { |
6c80b18d | 670 | if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) |
3d396eb1 | 671 | return -EIO; |
f98a9f69 | 672 | val = NXRD32(adapter, NETXEN_NIU_XG_PAUSE_CTL); |
6c80b18d MT |
673 | if (port == 0) { |
674 | if (pause->tx_pause) | |
675 | netxen_xg_unset_xg0_mask(val); | |
676 | else | |
677 | netxen_xg_set_xg0_mask(val); | |
678 | } else { | |
679 | if (pause->tx_pause) | |
680 | netxen_xg_unset_xg1_mask(val); | |
681 | else | |
682 | netxen_xg_set_xg1_mask(val); | |
3d396eb1 | 683 | } |
f98a9f69 | 684 | NXWR32(adapter, NETXEN_NIU_XG_PAUSE_CTL, val); |
6c80b18d MT |
685 | } else { |
686 | printk(KERN_ERR "%s: Unknown board type: %x\n", | |
4790654c | 687 | netxen_nic_driver_name, |
1e2d0059 | 688 | adapter->ahw.port_type); |
6c80b18d MT |
689 | } |
690 | return 0; | |
3d396eb1 AK |
691 | } |
692 | ||
693 | static int netxen_nic_reg_test(struct net_device *dev) | |
694 | { | |
0c25cfe1 LCMT |
695 | struct netxen_adapter *adapter = netdev_priv(dev); |
696 | u32 data_read, data_written; | |
3d396eb1 | 697 | |
f98a9f69 | 698 | data_read = NXRD32(adapter, NETXEN_PCIX_PH_REG(0)); |
0c25cfe1 LCMT |
699 | if ((data_read & 0xffff) != PHAN_VENDOR_ID) |
700 | return 1; | |
3d396eb1 | 701 | |
0c25cfe1 | 702 | data_written = (u32)0xa5a5a5a5; |
3d396eb1 | 703 | |
f98a9f69 DP |
704 | NXWR32(adapter, CRB_SCRATCHPAD_TEST, data_written); |
705 | data_read = NXRD32(adapter, CRB_SCRATCHPAD_TEST); | |
0c25cfe1 LCMT |
706 | if (data_written != data_read) |
707 | return 1; | |
3d396eb1 | 708 | |
0c25cfe1 | 709 | return 0; |
3d396eb1 AK |
710 | } |
711 | ||
b9f2c044 | 712 | static int netxen_get_sset_count(struct net_device *dev, int sset) |
3d396eb1 | 713 | { |
b9f2c044 JG |
714 | switch (sset) { |
715 | case ETH_SS_TEST: | |
716 | return NETXEN_NIC_TEST_LEN; | |
717 | case ETH_SS_STATS: | |
718 | return NETXEN_NIC_STATS_LEN; | |
719 | default: | |
720 | return -EOPNOTSUPP; | |
721 | } | |
3d396eb1 AK |
722 | } |
723 | ||
724 | static void | |
725 | netxen_nic_diag_test(struct net_device *dev, struct ethtool_test *eth_test, | |
726 | u64 * data) | |
727 | { | |
6c80b18d MT |
728 | memset(data, 0, sizeof(uint64_t) * NETXEN_NIC_TEST_LEN); |
729 | if ((data[0] = netxen_nic_reg_test(dev))) | |
730 | eth_test->flags |= ETH_TEST_FL_FAILED; | |
731 | /* link test */ | |
732 | if ((data[1] = (u64) netxen_nic_test_link(dev))) | |
733 | eth_test->flags |= ETH_TEST_FL_FAILED; | |
3d396eb1 AK |
734 | } |
735 | ||
736 | static void | |
737 | netxen_nic_get_strings(struct net_device *dev, u32 stringset, u8 * data) | |
738 | { | |
739 | int index; | |
740 | ||
741 | switch (stringset) { | |
742 | case ETH_SS_TEST: | |
743 | memcpy(data, *netxen_nic_gstrings_test, | |
744 | NETXEN_NIC_TEST_LEN * ETH_GSTRING_LEN); | |
745 | break; | |
746 | case ETH_SS_STATS: | |
747 | for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) { | |
748 | memcpy(data + index * ETH_GSTRING_LEN, | |
749 | netxen_nic_gstrings_stats[index].stat_string, | |
750 | ETH_GSTRING_LEN); | |
751 | } | |
752 | break; | |
753 | } | |
754 | } | |
755 | ||
3d396eb1 AK |
756 | static void |
757 | netxen_nic_get_ethtool_stats(struct net_device *dev, | |
758 | struct ethtool_stats *stats, u64 * data) | |
759 | { | |
3176ff3e | 760 | struct netxen_adapter *adapter = netdev_priv(dev); |
3d396eb1 AK |
761 | int index; |
762 | ||
763 | for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) { | |
764 | char *p = | |
3176ff3e MT |
765 | (char *)adapter + |
766 | netxen_nic_gstrings_stats[index].stat_offset; | |
3d396eb1 AK |
767 | data[index] = |
768 | (netxen_nic_gstrings_stats[index].sizeof_stat == | |
769 | sizeof(u64)) ? *(u64 *) p : *(u32 *) p; | |
770 | } | |
3d396eb1 AK |
771 | } |
772 | ||
200eef20 DP |
773 | static u32 netxen_nic_get_rx_csum(struct net_device *dev) |
774 | { | |
775 | struct netxen_adapter *adapter = netdev_priv(dev); | |
776 | return adapter->rx_csum; | |
777 | } | |
778 | ||
779 | static int netxen_nic_set_rx_csum(struct net_device *dev, u32 data) | |
780 | { | |
781 | struct netxen_adapter *adapter = netdev_priv(dev); | |
782 | adapter->rx_csum = !!data; | |
783 | return 0; | |
784 | } | |
785 | ||
cd1f8160 DP |
786 | static u32 netxen_nic_get_tso(struct net_device *dev) |
787 | { | |
788 | struct netxen_adapter *adapter = netdev_priv(dev); | |
789 | ||
790 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) | |
791 | return (dev->features & (NETIF_F_TSO | NETIF_F_TSO6)) != 0; | |
792 | ||
793 | return (dev->features & NETIF_F_TSO) != 0; | |
794 | } | |
795 | ||
796 | static int netxen_nic_set_tso(struct net_device *dev, u32 data) | |
797 | { | |
798 | if (data) { | |
799 | struct netxen_adapter *adapter = netdev_priv(dev); | |
800 | ||
801 | dev->features |= NETIF_F_TSO; | |
802 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) | |
803 | dev->features |= NETIF_F_TSO6; | |
804 | } else | |
805 | dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); | |
806 | ||
807 | return 0; | |
808 | } | |
809 | ||
4da12942 DP |
810 | static void |
811 | netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |
812 | { | |
813 | struct netxen_adapter *adapter = netdev_priv(dev); | |
814 | u32 wol_cfg = 0; | |
815 | ||
816 | wol->supported = 0; | |
817 | wol->wolopts = 0; | |
818 | ||
819 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) | |
820 | return; | |
821 | ||
f98a9f69 | 822 | wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG_NV); |
4da12942 DP |
823 | if (wol_cfg & (1UL << adapter->portnum)) |
824 | wol->supported |= WAKE_MAGIC; | |
825 | ||
f98a9f69 | 826 | wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG); |
4da12942 DP |
827 | if (wol_cfg & (1UL << adapter->portnum)) |
828 | wol->wolopts |= WAKE_MAGIC; | |
829 | } | |
830 | ||
831 | static int | |
832 | netxen_nic_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |
833 | { | |
834 | struct netxen_adapter *adapter = netdev_priv(dev); | |
835 | u32 wol_cfg = 0; | |
836 | ||
837 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) | |
838 | return -EOPNOTSUPP; | |
839 | ||
840 | if (wol->wolopts & ~WAKE_MAGIC) | |
841 | return -EOPNOTSUPP; | |
842 | ||
f98a9f69 | 843 | wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG_NV); |
4da12942 DP |
844 | if (!(wol_cfg & (1 << adapter->portnum))) |
845 | return -EOPNOTSUPP; | |
846 | ||
f98a9f69 | 847 | wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG); |
4da12942 DP |
848 | if (wol->wolopts & WAKE_MAGIC) |
849 | wol_cfg |= 1UL << adapter->portnum; | |
850 | else | |
851 | wol_cfg &= ~(1UL << adapter->portnum); | |
f98a9f69 | 852 | NXWR32(adapter, NETXEN_WOL_CONFIG, wol_cfg); |
4da12942 DP |
853 | |
854 | return 0; | |
855 | } | |
856 | ||
cd1f8160 DP |
857 | /* |
858 | * Set the coalescing parameters. Currently only normal is supported. | |
859 | * If rx_coalesce_usecs == 0 or rx_max_coalesced_frames == 0 then set the | |
860 | * firmware coalescing to default. | |
861 | */ | |
862 | static int netxen_set_intr_coalesce(struct net_device *netdev, | |
863 | struct ethtool_coalesce *ethcoal) | |
864 | { | |
865 | struct netxen_adapter *adapter = netdev_priv(netdev); | |
866 | ||
867 | if (!NX_IS_REVISION_P3(adapter->ahw.revision_id)) | |
868 | return -EINVAL; | |
869 | ||
870 | if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) | |
871 | return -EINVAL; | |
872 | ||
873 | /* | |
874 | * Return Error if unsupported values or | |
875 | * unsupported parameters are set. | |
876 | */ | |
877 | if (ethcoal->rx_coalesce_usecs > 0xffff || | |
878 | ethcoal->rx_max_coalesced_frames > 0xffff || | |
879 | ethcoal->tx_coalesce_usecs > 0xffff || | |
880 | ethcoal->tx_max_coalesced_frames > 0xffff || | |
881 | ethcoal->rx_coalesce_usecs_irq || | |
882 | ethcoal->rx_max_coalesced_frames_irq || | |
883 | ethcoal->tx_coalesce_usecs_irq || | |
884 | ethcoal->tx_max_coalesced_frames_irq || | |
885 | ethcoal->stats_block_coalesce_usecs || | |
886 | ethcoal->use_adaptive_rx_coalesce || | |
887 | ethcoal->use_adaptive_tx_coalesce || | |
888 | ethcoal->pkt_rate_low || | |
889 | ethcoal->rx_coalesce_usecs_low || | |
890 | ethcoal->rx_max_coalesced_frames_low || | |
891 | ethcoal->tx_coalesce_usecs_low || | |
892 | ethcoal->tx_max_coalesced_frames_low || | |
893 | ethcoal->pkt_rate_high || | |
894 | ethcoal->rx_coalesce_usecs_high || | |
895 | ethcoal->rx_max_coalesced_frames_high || | |
896 | ethcoal->tx_coalesce_usecs_high || | |
897 | ethcoal->tx_max_coalesced_frames_high) | |
898 | return -EINVAL; | |
899 | ||
900 | if (!ethcoal->rx_coalesce_usecs || | |
901 | !ethcoal->rx_max_coalesced_frames) { | |
902 | adapter->coal.flags = NETXEN_NIC_INTR_DEFAULT; | |
903 | adapter->coal.normal.data.rx_time_us = | |
904 | NETXEN_DEFAULT_INTR_COALESCE_RX_TIME_US; | |
905 | adapter->coal.normal.data.rx_packets = | |
906 | NETXEN_DEFAULT_INTR_COALESCE_RX_PACKETS; | |
907 | } else { | |
908 | adapter->coal.flags = 0; | |
909 | adapter->coal.normal.data.rx_time_us = | |
910 | ethcoal->rx_coalesce_usecs; | |
911 | adapter->coal.normal.data.rx_packets = | |
912 | ethcoal->rx_max_coalesced_frames; | |
913 | } | |
914 | adapter->coal.normal.data.tx_time_us = ethcoal->tx_coalesce_usecs; | |
915 | adapter->coal.normal.data.tx_packets = | |
916 | ethcoal->tx_max_coalesced_frames; | |
917 | ||
918 | netxen_config_intr_coalesce(adapter); | |
919 | ||
920 | return 0; | |
921 | } | |
922 | ||
923 | static int netxen_get_intr_coalesce(struct net_device *netdev, | |
924 | struct ethtool_coalesce *ethcoal) | |
925 | { | |
926 | struct netxen_adapter *adapter = netdev_priv(netdev); | |
927 | ||
928 | if (!NX_IS_REVISION_P3(adapter->ahw.revision_id)) | |
929 | return -EINVAL; | |
930 | ||
931 | if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) | |
932 | return -EINVAL; | |
933 | ||
934 | ethcoal->rx_coalesce_usecs = adapter->coal.normal.data.rx_time_us; | |
935 | ethcoal->tx_coalesce_usecs = adapter->coal.normal.data.tx_time_us; | |
936 | ethcoal->rx_max_coalesced_frames = | |
937 | adapter->coal.normal.data.rx_packets; | |
938 | ethcoal->tx_max_coalesced_frames = | |
939 | adapter->coal.normal.data.tx_packets; | |
940 | ||
941 | return 0; | |
942 | } | |
943 | ||
1bb482f8 NK |
944 | static int netxen_nic_set_flags(struct net_device *netdev, u32 data) |
945 | { | |
946 | struct netxen_adapter *adapter = netdev_priv(netdev); | |
947 | int hw_lro; | |
948 | ||
949 | if (!(adapter->capabilities & NX_FW_CAPABILITY_HW_LRO)) | |
950 | return -EINVAL; | |
951 | ||
952 | ethtool_op_set_flags(netdev, data); | |
953 | ||
954 | hw_lro = (data & ETH_FLAG_LRO) ? NETXEN_NIC_LRO_ENABLED : 0; | |
955 | ||
956 | if (netxen_config_hw_lro(adapter, hw_lro)) | |
957 | return -EIO; | |
958 | ||
959 | if ((hw_lro == 0) && netxen_send_lro_cleanup(adapter)) | |
960 | return -EIO; | |
961 | ||
962 | ||
963 | return 0; | |
964 | } | |
965 | ||
0fc0b732 | 966 | const struct ethtool_ops netxen_nic_ethtool_ops = { |
3d396eb1 AK |
967 | .get_settings = netxen_nic_get_settings, |
968 | .set_settings = netxen_nic_set_settings, | |
969 | .get_drvinfo = netxen_nic_get_drvinfo, | |
970 | .get_regs_len = netxen_nic_get_regs_len, | |
971 | .get_regs = netxen_nic_get_regs, | |
e45d9ab4 | 972 | .get_link = ethtool_op_get_link, |
3d396eb1 AK |
973 | .get_eeprom_len = netxen_nic_get_eeprom_len, |
974 | .get_eeprom = netxen_nic_get_eeprom, | |
975 | .get_ringparam = netxen_nic_get_ringparam, | |
7042cd8f | 976 | .set_ringparam = netxen_nic_set_ringparam, |
3d396eb1 AK |
977 | .get_pauseparam = netxen_nic_get_pauseparam, |
978 | .set_pauseparam = netxen_nic_set_pauseparam, | |
3d396eb1 | 979 | .set_tx_csum = ethtool_op_set_tx_csum, |
3d396eb1 | 980 | .set_sg = ethtool_op_set_sg, |
cd1f8160 DP |
981 | .get_tso = netxen_nic_get_tso, |
982 | .set_tso = netxen_nic_set_tso, | |
4da12942 DP |
983 | .get_wol = netxen_nic_get_wol, |
984 | .set_wol = netxen_nic_set_wol, | |
3d396eb1 AK |
985 | .self_test = netxen_nic_diag_test, |
986 | .get_strings = netxen_nic_get_strings, | |
3d396eb1 | 987 | .get_ethtool_stats = netxen_nic_get_ethtool_stats, |
b9f2c044 | 988 | .get_sset_count = netxen_get_sset_count, |
200eef20 DP |
989 | .get_rx_csum = netxen_nic_get_rx_csum, |
990 | .set_rx_csum = netxen_nic_set_rx_csum, | |
cd1f8160 DP |
991 | .get_coalesce = netxen_get_intr_coalesce, |
992 | .set_coalesce = netxen_set_intr_coalesce, | |
1bb482f8 NK |
993 | .get_flags = ethtool_op_get_flags, |
994 | .set_flags = netxen_nic_set_flags, | |
3d396eb1 | 995 | }; |