2 * Copyright (C) 2009 - QLogic Corporation.
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.
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.
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,
20 * The full GNU General Public License is included in this distribution
21 * in the file called "COPYING".
25 #include <linux/types.h>
26 #include <linux/delay.h>
27 #include <linux/pci.h>
29 #include <linux/netdevice.h>
30 #include <linux/ethtool.h>
35 char stat_string[ETH_GSTRING_LEN];
40 #define QLC_SIZEOF(m) FIELD_SIZEOF(struct qlcnic_adapter, m)
41 #define QLC_OFF(m) offsetof(struct qlcnic_adapter, m)
43 static const struct qlcnic_stats qlcnic_gstrings_stats[] = {
45 QLC_SIZEOF(stats.xmitcalled), QLC_OFF(stats.xmitcalled)},
47 QLC_SIZEOF(stats.xmitfinished), QLC_OFF(stats.xmitfinished)},
49 QLC_SIZEOF(stats.rxdropped), QLC_OFF(stats.rxdropped)},
51 QLC_SIZEOF(stats.txdropped), QLC_OFF(stats.txdropped)},
53 QLC_SIZEOF(stats.csummed), QLC_OFF(stats.csummed)},
55 QLC_SIZEOF(stats.rx_pkts), QLC_OFF(stats.rx_pkts)},
57 QLC_SIZEOF(stats.lro_pkts), QLC_OFF(stats.lro_pkts)},
59 QLC_SIZEOF(stats.rxbytes), QLC_OFF(stats.rxbytes)},
61 QLC_SIZEOF(stats.txbytes), QLC_OFF(stats.txbytes)},
64 #define QLCNIC_STATS_LEN ARRAY_SIZE(qlcnic_gstrings_stats)
66 static const char qlcnic_gstrings_test[][ETH_GSTRING_LEN] = {
67 "Register_Test_on_offline",
68 "Link_Test_on_offline"
71 #define QLCNIC_TEST_LEN ARRAY_SIZE(qlcnic_gstrings_test)
73 #define QLCNIC_RING_REGS_COUNT 20
74 #define QLCNIC_RING_REGS_LEN (QLCNIC_RING_REGS_COUNT * sizeof(u32))
75 #define QLCNIC_MAX_EEPROM_LEN 1024
77 static const u32 diag_registers[] = {
81 CRB_FW_CAPABILITIES_1,
83 QLCNIC_CRB_DEV_REF_COUNT,
86 QLCNIC_CRB_DRV_SCRATCH,
87 QLCNIC_CRB_DEV_PARTITION_INFO,
88 QLCNIC_CRB_DRV_IDC_VER,
89 QLCNIC_PEG_ALIVE_COUNTER,
90 QLCNIC_PEG_HALT_STATUS1,
91 QLCNIC_PEG_HALT_STATUS2,
92 QLCNIC_CRB_PEG_NET_0+0x3c,
93 QLCNIC_CRB_PEG_NET_1+0x3c,
94 QLCNIC_CRB_PEG_NET_2+0x3c,
95 QLCNIC_CRB_PEG_NET_4+0x3c,
99 static int qlcnic_get_regs_len(struct net_device *dev)
101 return sizeof(diag_registers) + QLCNIC_RING_REGS_LEN;
104 static int qlcnic_get_eeprom_len(struct net_device *dev)
106 return QLCNIC_FLASH_TOTAL_SIZE;
110 qlcnic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
112 struct qlcnic_adapter *adapter = netdev_priv(dev);
113 u32 fw_major, fw_minor, fw_build;
115 fw_major = QLCRD32(adapter, QLCNIC_FW_VERSION_MAJOR);
116 fw_minor = QLCRD32(adapter, QLCNIC_FW_VERSION_MINOR);
117 fw_build = QLCRD32(adapter, QLCNIC_FW_VERSION_SUB);
118 sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build);
120 strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
121 strlcpy(drvinfo->driver, qlcnic_driver_name, 32);
122 strlcpy(drvinfo->version, QLCNIC_LINUX_VERSIONID, 32);
126 qlcnic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
128 struct qlcnic_adapter *adapter = netdev_priv(dev);
129 int check_sfp_module = 0;
130 u16 pcifn = adapter->ahw.pci_func;
132 /* read which mode */
133 if (adapter->ahw.port_type == QLCNIC_GBE) {
134 ecmd->supported = (SUPPORTED_10baseT_Half |
135 SUPPORTED_10baseT_Full |
136 SUPPORTED_100baseT_Half |
137 SUPPORTED_100baseT_Full |
138 SUPPORTED_1000baseT_Half |
139 SUPPORTED_1000baseT_Full);
141 ecmd->advertising = (ADVERTISED_100baseT_Half |
142 ADVERTISED_100baseT_Full |
143 ADVERTISED_1000baseT_Half |
144 ADVERTISED_1000baseT_Full);
146 ecmd->speed = adapter->link_speed;
147 ecmd->duplex = adapter->link_duplex;
148 ecmd->autoneg = adapter->link_autoneg;
150 } else if (adapter->ahw.port_type == QLCNIC_XGBE) {
153 val = QLCRD32(adapter, QLCNIC_PORT_MODE_ADDR);
154 if (val == QLCNIC_PORT_MODE_802_3_AP) {
155 ecmd->supported = SUPPORTED_1000baseT_Full;
156 ecmd->advertising = ADVERTISED_1000baseT_Full;
158 ecmd->supported = SUPPORTED_10000baseT_Full;
159 ecmd->advertising = ADVERTISED_10000baseT_Full;
162 if (netif_running(dev) && adapter->has_link_events) {
163 ecmd->speed = adapter->link_speed;
164 ecmd->autoneg = adapter->link_autoneg;
165 ecmd->duplex = adapter->link_duplex;
169 val = QLCRD32(adapter, P3_LINK_SPEED_REG(pcifn));
170 ecmd->speed = P3_LINK_SPEED_MHZ *
171 P3_LINK_SPEED_VAL(pcifn, val);
172 ecmd->duplex = DUPLEX_FULL;
173 ecmd->autoneg = AUTONEG_DISABLE;
178 ecmd->phy_address = adapter->physical_port;
179 ecmd->transceiver = XCVR_EXTERNAL;
181 switch (adapter->ahw.board_type) {
182 case QLCNIC_BRDTYPE_P3_REF_QG:
183 case QLCNIC_BRDTYPE_P3_4_GB:
184 case QLCNIC_BRDTYPE_P3_4_GB_MM:
186 ecmd->supported |= SUPPORTED_Autoneg;
187 ecmd->advertising |= ADVERTISED_Autoneg;
188 case QLCNIC_BRDTYPE_P3_10G_CX4:
189 case QLCNIC_BRDTYPE_P3_10G_CX4_LP:
190 case QLCNIC_BRDTYPE_P3_10000_BASE_T:
191 ecmd->supported |= SUPPORTED_TP;
192 ecmd->advertising |= ADVERTISED_TP;
193 ecmd->port = PORT_TP;
194 ecmd->autoneg = adapter->link_autoneg;
196 case QLCNIC_BRDTYPE_P3_IMEZ:
197 case QLCNIC_BRDTYPE_P3_XG_LOM:
198 case QLCNIC_BRDTYPE_P3_HMEZ:
199 ecmd->supported |= SUPPORTED_MII;
200 ecmd->advertising |= ADVERTISED_MII;
201 ecmd->port = PORT_MII;
202 ecmd->autoneg = AUTONEG_DISABLE;
204 case QLCNIC_BRDTYPE_P3_10G_SFP_PLUS:
205 case QLCNIC_BRDTYPE_P3_10G_SFP_CT:
206 case QLCNIC_BRDTYPE_P3_10G_SFP_QT:
207 ecmd->advertising |= ADVERTISED_TP;
208 ecmd->supported |= SUPPORTED_TP;
209 check_sfp_module = netif_running(dev) &&
210 adapter->has_link_events;
211 case QLCNIC_BRDTYPE_P3_10G_XFP:
212 ecmd->supported |= SUPPORTED_FIBRE;
213 ecmd->advertising |= ADVERTISED_FIBRE;
214 ecmd->port = PORT_FIBRE;
215 ecmd->autoneg = AUTONEG_DISABLE;
217 case QLCNIC_BRDTYPE_P3_10G_TP:
218 if (adapter->ahw.port_type == QLCNIC_XGBE) {
219 ecmd->autoneg = AUTONEG_DISABLE;
220 ecmd->supported |= (SUPPORTED_FIBRE | SUPPORTED_TP);
222 (ADVERTISED_FIBRE | ADVERTISED_TP);
223 ecmd->port = PORT_FIBRE;
224 check_sfp_module = netif_running(dev) &&
225 adapter->has_link_events;
227 ecmd->autoneg = AUTONEG_ENABLE;
228 ecmd->supported |= (SUPPORTED_TP | SUPPORTED_Autoneg);
230 (ADVERTISED_TP | ADVERTISED_Autoneg);
231 ecmd->port = PORT_TP;
235 dev_err(&adapter->pdev->dev, "Unsupported board model %d\n",
236 adapter->ahw.board_type);
240 if (check_sfp_module) {
241 switch (adapter->module_type) {
242 case LINKEVENT_MODULE_OPTICAL_UNKNOWN:
243 case LINKEVENT_MODULE_OPTICAL_SRLR:
244 case LINKEVENT_MODULE_OPTICAL_LRM:
245 case LINKEVENT_MODULE_OPTICAL_SFP_1G:
246 ecmd->port = PORT_FIBRE;
248 case LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLE:
249 case LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLELEN:
250 case LINKEVENT_MODULE_TWINAX:
251 ecmd->port = PORT_TP;
254 ecmd->port = PORT_OTHER;
262 qlcnic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
264 struct qlcnic_adapter *adapter = netdev_priv(dev);
267 /* read which mode */
268 if (adapter->ahw.port_type == QLCNIC_GBE) {
269 /* autonegotiation */
270 if (qlcnic_fw_cmd_set_phy(adapter,
271 QLCNIC_NIU_GB_MII_MGMT_ADDR_AUTONEG,
275 adapter->link_autoneg = ecmd->autoneg;
277 if (qlcnic_fw_cmd_query_phy(adapter,
278 QLCNIC_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
282 switch (ecmd->speed) {
284 qlcnic_set_phy_speed(status, 0);
287 qlcnic_set_phy_speed(status, 1);
290 qlcnic_set_phy_speed(status, 2);
294 if (ecmd->duplex == DUPLEX_HALF)
295 qlcnic_clear_phy_duplex(status);
296 if (ecmd->duplex == DUPLEX_FULL)
297 qlcnic_set_phy_duplex(status);
298 if (qlcnic_fw_cmd_set_phy(adapter,
299 QLCNIC_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
300 *((int *)&status)) != 0)
303 adapter->link_speed = ecmd->speed;
304 adapter->link_duplex = ecmd->duplex;
309 if (!netif_running(dev))
312 dev->netdev_ops->ndo_stop(dev);
313 return dev->netdev_ops->ndo_open(dev);
317 qlcnic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
319 struct qlcnic_adapter *adapter = netdev_priv(dev);
320 struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx;
321 struct qlcnic_host_sds_ring *sds_ring;
325 memset(p, 0, qlcnic_get_regs_len(dev));
326 regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) |
327 (adapter->pdev)->device;
329 if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC)
332 for (i = 0; diag_registers[i] != -1; i++)
333 regs_buff[i] = QLCRD32(adapter, diag_registers[i]);
335 regs_buff[i++] = 0xFFEFCDAB; /* Marker btw regs and ring count*/
337 regs_buff[i++] = 1; /* No. of tx ring */
338 regs_buff[i++] = le32_to_cpu(*(adapter->tx_ring->hw_consumer));
339 regs_buff[i++] = readl(adapter->tx_ring->crb_cmd_producer);
341 regs_buff[i++] = 2; /* No. of rx ring */
342 regs_buff[i++] = readl(recv_ctx->rds_rings[0].crb_rcv_producer);
343 regs_buff[i++] = readl(recv_ctx->rds_rings[1].crb_rcv_producer);
345 regs_buff[i++] = adapter->max_sds_rings;
347 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
348 sds_ring = &(recv_ctx->sds_rings[ring]);
349 regs_buff[i++] = readl(sds_ring->crb_sts_consumer);
353 static u32 qlcnic_test_link(struct net_device *dev)
355 struct qlcnic_adapter *adapter = netdev_priv(dev);
358 val = QLCRD32(adapter, CRB_XG_STATE_P3);
359 val = XG_LINK_STATE_P3(adapter->ahw.pci_func, val);
360 return (val == XG_LINK_UP_P3) ? 0 : 1;
364 qlcnic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
367 struct qlcnic_adapter *adapter = netdev_priv(dev);
371 if (eeprom->len == 0)
374 eeprom->magic = (adapter->pdev)->vendor |
375 ((adapter->pdev)->device << 16);
376 offset = eeprom->offset;
378 ret = qlcnic_rom_fast_read_words(adapter, offset, bytes,
387 qlcnic_get_ringparam(struct net_device *dev,
388 struct ethtool_ringparam *ring)
390 struct qlcnic_adapter *adapter = netdev_priv(dev);
392 ring->rx_pending = adapter->num_rxd;
393 ring->rx_jumbo_pending = adapter->num_jumbo_rxd;
394 ring->rx_jumbo_pending += adapter->num_lro_rxd;
395 ring->tx_pending = adapter->num_txd;
397 if (adapter->ahw.port_type == QLCNIC_GBE) {
398 ring->rx_max_pending = MAX_RCV_DESCRIPTORS_1G;
399 ring->rx_jumbo_max_pending = MAX_JUMBO_RCV_DESCRIPTORS_1G;
401 ring->rx_max_pending = MAX_RCV_DESCRIPTORS_10G;
402 ring->rx_jumbo_max_pending = MAX_JUMBO_RCV_DESCRIPTORS_10G;
405 ring->tx_max_pending = MAX_CMD_DESCRIPTORS;
407 ring->rx_mini_max_pending = 0;
408 ring->rx_mini_pending = 0;
412 qlcnic_validate_ringparam(u32 val, u32 min, u32 max, char *r_name)
415 num_desc = max(val, min);
416 num_desc = min(num_desc, max);
417 num_desc = roundup_pow_of_two(num_desc);
419 if (val != num_desc) {
420 printk(KERN_INFO "%s: setting %s ring size %d instead of %d\n",
421 qlcnic_driver_name, r_name, num_desc, val);
428 qlcnic_set_ringparam(struct net_device *dev,
429 struct ethtool_ringparam *ring)
431 struct qlcnic_adapter *adapter = netdev_priv(dev);
432 u16 max_rcv_desc = MAX_RCV_DESCRIPTORS_10G;
433 u16 max_jumbo_desc = MAX_JUMBO_RCV_DESCRIPTORS_10G;
434 u16 num_rxd, num_jumbo_rxd, num_txd;
437 if (ring->rx_mini_pending)
440 if (adapter->ahw.port_type == QLCNIC_GBE) {
441 max_rcv_desc = MAX_RCV_DESCRIPTORS_1G;
442 max_jumbo_desc = MAX_JUMBO_RCV_DESCRIPTORS_10G;
445 num_rxd = qlcnic_validate_ringparam(ring->rx_pending,
446 MIN_RCV_DESCRIPTORS, max_rcv_desc, "rx");
448 num_jumbo_rxd = qlcnic_validate_ringparam(ring->rx_jumbo_pending,
449 MIN_JUMBO_DESCRIPTORS, max_jumbo_desc, "rx jumbo");
451 num_txd = qlcnic_validate_ringparam(ring->tx_pending,
452 MIN_CMD_DESCRIPTORS, MAX_CMD_DESCRIPTORS, "tx");
454 if (num_rxd == adapter->num_rxd && num_txd == adapter->num_txd &&
455 num_jumbo_rxd == adapter->num_jumbo_rxd)
458 adapter->num_rxd = num_rxd;
459 adapter->num_jumbo_rxd = num_jumbo_rxd;
460 adapter->num_txd = num_txd;
462 return qlcnic_reset_context(adapter);
466 qlcnic_get_pauseparam(struct net_device *netdev,
467 struct ethtool_pauseparam *pause)
469 struct qlcnic_adapter *adapter = netdev_priv(netdev);
470 int port = adapter->physical_port;
473 if (adapter->ahw.port_type == QLCNIC_GBE) {
474 if ((port < 0) || (port > QLCNIC_NIU_MAX_GBE_PORTS))
476 /* get flow control settings */
477 val = QLCRD32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port));
478 pause->rx_pause = qlcnic_gb_get_rx_flowctl(val);
479 val = QLCRD32(adapter, QLCNIC_NIU_GB_PAUSE_CTL);
482 pause->tx_pause = !(qlcnic_gb_get_gb0_mask(val));
485 pause->tx_pause = !(qlcnic_gb_get_gb1_mask(val));
488 pause->tx_pause = !(qlcnic_gb_get_gb2_mask(val));
492 pause->tx_pause = !(qlcnic_gb_get_gb3_mask(val));
495 } else if (adapter->ahw.port_type == QLCNIC_XGBE) {
496 if ((port < 0) || (port > QLCNIC_NIU_MAX_XG_PORTS))
499 val = QLCRD32(adapter, QLCNIC_NIU_XG_PAUSE_CTL);
501 pause->tx_pause = !(qlcnic_xg_get_xg0_mask(val));
503 pause->tx_pause = !(qlcnic_xg_get_xg1_mask(val));
505 dev_err(&netdev->dev, "Unknown board type: %x\n",
506 adapter->ahw.port_type);
511 qlcnic_set_pauseparam(struct net_device *netdev,
512 struct ethtool_pauseparam *pause)
514 struct qlcnic_adapter *adapter = netdev_priv(netdev);
515 int port = adapter->physical_port;
519 if (adapter->ahw.port_type == QLCNIC_GBE) {
520 if ((port < 0) || (port > QLCNIC_NIU_MAX_GBE_PORTS))
522 /* set flow control */
523 val = QLCRD32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port));
526 qlcnic_gb_rx_flowctl(val);
528 qlcnic_gb_unset_rx_flowctl(val);
530 QLCWR32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port),
533 val = QLCRD32(adapter, QLCNIC_NIU_GB_PAUSE_CTL);
537 qlcnic_gb_unset_gb0_mask(val);
539 qlcnic_gb_set_gb0_mask(val);
543 qlcnic_gb_unset_gb1_mask(val);
545 qlcnic_gb_set_gb1_mask(val);
549 qlcnic_gb_unset_gb2_mask(val);
551 qlcnic_gb_set_gb2_mask(val);
556 qlcnic_gb_unset_gb3_mask(val);
558 qlcnic_gb_set_gb3_mask(val);
561 QLCWR32(adapter, QLCNIC_NIU_GB_PAUSE_CTL, val);
562 } else if (adapter->ahw.port_type == QLCNIC_XGBE) {
563 if ((port < 0) || (port > QLCNIC_NIU_MAX_XG_PORTS))
565 val = QLCRD32(adapter, QLCNIC_NIU_XG_PAUSE_CTL);
568 qlcnic_xg_unset_xg0_mask(val);
570 qlcnic_xg_set_xg0_mask(val);
573 qlcnic_xg_unset_xg1_mask(val);
575 qlcnic_xg_set_xg1_mask(val);
577 QLCWR32(adapter, QLCNIC_NIU_XG_PAUSE_CTL, val);
579 dev_err(&netdev->dev, "Unknown board type: %x\n",
580 adapter->ahw.port_type);
585 static int qlcnic_reg_test(struct net_device *dev)
587 struct qlcnic_adapter *adapter = netdev_priv(dev);
588 u32 data_read, data_written;
590 data_read = QLCRD32(adapter, QLCNIC_PCIX_PH_REG(0));
591 if ((data_read & 0xffff) != adapter->pdev->vendor)
594 data_written = (u32)0xa5a5a5a5;
596 QLCWR32(adapter, CRB_SCRATCHPAD_TEST, data_written);
597 data_read = QLCRD32(adapter, CRB_SCRATCHPAD_TEST);
598 if (data_written != data_read)
604 static int qlcnic_get_sset_count(struct net_device *dev, int sset)
608 return QLCNIC_TEST_LEN;
610 return QLCNIC_STATS_LEN;
617 qlcnic_diag_test(struct net_device *dev, struct ethtool_test *eth_test,
620 memset(data, 0, sizeof(u64) * QLCNIC_TEST_LEN);
621 data[0] = qlcnic_reg_test(dev);
623 eth_test->flags |= ETH_TEST_FL_FAILED;
626 data[1] = (u64) qlcnic_test_link(dev);
628 eth_test->flags |= ETH_TEST_FL_FAILED;
632 qlcnic_get_strings(struct net_device *dev, u32 stringset, u8 * data)
638 memcpy(data, *qlcnic_gstrings_test,
639 QLCNIC_TEST_LEN * ETH_GSTRING_LEN);
642 for (index = 0; index < QLCNIC_STATS_LEN; index++) {
643 memcpy(data + index * ETH_GSTRING_LEN,
644 qlcnic_gstrings_stats[index].stat_string,
652 qlcnic_get_ethtool_stats(struct net_device *dev,
653 struct ethtool_stats *stats, u64 * data)
655 struct qlcnic_adapter *adapter = netdev_priv(dev);
658 for (index = 0; index < QLCNIC_STATS_LEN; index++) {
661 qlcnic_gstrings_stats[index].stat_offset;
663 (qlcnic_gstrings_stats[index].sizeof_stat ==
664 sizeof(u64)) ? *(u64 *)p:(*(u32 *)p);
668 static u32 qlcnic_get_rx_csum(struct net_device *dev)
670 struct qlcnic_adapter *adapter = netdev_priv(dev);
671 return adapter->rx_csum;
674 static int qlcnic_set_rx_csum(struct net_device *dev, u32 data)
676 struct qlcnic_adapter *adapter = netdev_priv(dev);
677 adapter->rx_csum = !!data;
681 static u32 qlcnic_get_tso(struct net_device *dev)
683 return (dev->features & (NETIF_F_TSO | NETIF_F_TSO6)) != 0;
686 static int qlcnic_set_tso(struct net_device *dev, u32 data)
689 dev->features |= (NETIF_F_TSO | NETIF_F_TSO6);
691 dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
697 qlcnic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
699 struct qlcnic_adapter *adapter = netdev_priv(dev);
705 wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG_NV);
706 if (wol_cfg & (1UL << adapter->portnum))
707 wol->supported |= WAKE_MAGIC;
709 wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG);
710 if (wol_cfg & (1UL << adapter->portnum))
711 wol->wolopts |= WAKE_MAGIC;
715 qlcnic_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
717 struct qlcnic_adapter *adapter = netdev_priv(dev);
720 if (wol->wolopts & ~WAKE_MAGIC)
723 wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG_NV);
724 if (!(wol_cfg & (1 << adapter->portnum)))
727 wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG);
728 if (wol->wolopts & WAKE_MAGIC)
729 wol_cfg |= 1UL << adapter->portnum;
731 wol_cfg &= ~(1UL << adapter->portnum);
733 QLCWR32(adapter, QLCNIC_WOL_CONFIG, wol_cfg);
739 * Set the coalescing parameters. Currently only normal is supported.
740 * If rx_coalesce_usecs == 0 or rx_max_coalesced_frames == 0 then set the
741 * firmware coalescing to default.
743 static int qlcnic_set_intr_coalesce(struct net_device *netdev,
744 struct ethtool_coalesce *ethcoal)
746 struct qlcnic_adapter *adapter = netdev_priv(netdev);
748 if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC)
752 * Return Error if unsupported values or
753 * unsupported parameters are set.
755 if (ethcoal->rx_coalesce_usecs > 0xffff ||
756 ethcoal->rx_max_coalesced_frames > 0xffff ||
757 ethcoal->tx_coalesce_usecs > 0xffff ||
758 ethcoal->tx_max_coalesced_frames > 0xffff ||
759 ethcoal->rx_coalesce_usecs_irq ||
760 ethcoal->rx_max_coalesced_frames_irq ||
761 ethcoal->tx_coalesce_usecs_irq ||
762 ethcoal->tx_max_coalesced_frames_irq ||
763 ethcoal->stats_block_coalesce_usecs ||
764 ethcoal->use_adaptive_rx_coalesce ||
765 ethcoal->use_adaptive_tx_coalesce ||
766 ethcoal->pkt_rate_low ||
767 ethcoal->rx_coalesce_usecs_low ||
768 ethcoal->rx_max_coalesced_frames_low ||
769 ethcoal->tx_coalesce_usecs_low ||
770 ethcoal->tx_max_coalesced_frames_low ||
771 ethcoal->pkt_rate_high ||
772 ethcoal->rx_coalesce_usecs_high ||
773 ethcoal->rx_max_coalesced_frames_high ||
774 ethcoal->tx_coalesce_usecs_high ||
775 ethcoal->tx_max_coalesced_frames_high)
778 if (!ethcoal->rx_coalesce_usecs ||
779 !ethcoal->rx_max_coalesced_frames) {
780 adapter->coal.flags = QLCNIC_INTR_DEFAULT;
781 adapter->coal.normal.data.rx_time_us =
782 QLCNIC_DEFAULT_INTR_COALESCE_RX_TIME_US;
783 adapter->coal.normal.data.rx_packets =
784 QLCNIC_DEFAULT_INTR_COALESCE_RX_PACKETS;
786 adapter->coal.flags = 0;
787 adapter->coal.normal.data.rx_time_us =
788 ethcoal->rx_coalesce_usecs;
789 adapter->coal.normal.data.rx_packets =
790 ethcoal->rx_max_coalesced_frames;
792 adapter->coal.normal.data.tx_time_us = ethcoal->tx_coalesce_usecs;
793 adapter->coal.normal.data.tx_packets =
794 ethcoal->tx_max_coalesced_frames;
796 qlcnic_config_intr_coalesce(adapter);
801 static int qlcnic_get_intr_coalesce(struct net_device *netdev,
802 struct ethtool_coalesce *ethcoal)
804 struct qlcnic_adapter *adapter = netdev_priv(netdev);
806 if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC)
809 ethcoal->rx_coalesce_usecs = adapter->coal.normal.data.rx_time_us;
810 ethcoal->tx_coalesce_usecs = adapter->coal.normal.data.tx_time_us;
811 ethcoal->rx_max_coalesced_frames =
812 adapter->coal.normal.data.rx_packets;
813 ethcoal->tx_max_coalesced_frames =
814 adapter->coal.normal.data.tx_packets;
819 static int qlcnic_set_flags(struct net_device *netdev, u32 data)
821 struct qlcnic_adapter *adapter = netdev_priv(netdev);
824 if (!(adapter->capabilities & QLCNIC_FW_CAPABILITY_HW_LRO))
827 ethtool_op_set_flags(netdev, data);
829 hw_lro = (data & ETH_FLAG_LRO) ? QLCNIC_LRO_ENABLED : 0;
831 if (qlcnic_config_hw_lro(adapter, hw_lro))
834 if ((hw_lro == 0) && qlcnic_send_lro_cleanup(adapter))
841 const struct ethtool_ops qlcnic_ethtool_ops = {
842 .get_settings = qlcnic_get_settings,
843 .set_settings = qlcnic_set_settings,
844 .get_drvinfo = qlcnic_get_drvinfo,
845 .get_regs_len = qlcnic_get_regs_len,
846 .get_regs = qlcnic_get_regs,
847 .get_link = ethtool_op_get_link,
848 .get_eeprom_len = qlcnic_get_eeprom_len,
849 .get_eeprom = qlcnic_get_eeprom,
850 .get_ringparam = qlcnic_get_ringparam,
851 .set_ringparam = qlcnic_set_ringparam,
852 .get_pauseparam = qlcnic_get_pauseparam,
853 .set_pauseparam = qlcnic_set_pauseparam,
854 .set_tx_csum = ethtool_op_set_tx_csum,
855 .set_sg = ethtool_op_set_sg,
856 .get_tso = qlcnic_get_tso,
857 .set_tso = qlcnic_set_tso,
858 .get_wol = qlcnic_get_wol,
859 .set_wol = qlcnic_set_wol,
860 .self_test = qlcnic_diag_test,
861 .get_strings = qlcnic_get_strings,
862 .get_ethtool_stats = qlcnic_get_ethtool_stats,
863 .get_sset_count = qlcnic_get_sset_count,
864 .get_rx_csum = qlcnic_get_rx_csum,
865 .set_rx_csum = qlcnic_set_rx_csum,
866 .get_coalesce = qlcnic_get_intr_coalesce,
867 .set_coalesce = qlcnic_set_intr_coalesce,
868 .get_flags = ethtool_op_get_flags,
869 .set_flags = qlcnic_set_flags,