static int qlcnic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) { u32 ret = 0; struct qlcnic_adapter *adapter = netdev_priv(dev); if (adapter->ahw->port_type != QLCNIC_GBE) return -EOPNOTSUPP; if (qlcnic_83xx_check(adapter)) ret = qlcnic_83xx_set_settings(adapter, ecmd); else ret = qlcnic_set_port_config(adapter, ecmd); if (!ret) return ret; adapter->ahw->link_speed = ethtool_cmd_speed(ecmd); adapter->ahw->link_duplex = ecmd->duplex; adapter->ahw->link_autoneg = ecmd->autoneg; if (!netif_running(dev)) return 0; dev->netdev_ops->ndo_stop(dev); return dev->netdev_ops->ndo_open(dev); }
static int qlcnic_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) { struct qlcnic_adapter *adapter = netdev_priv(dev); u32 wol_cfg; if (qlcnic_83xx_check(adapter)) return -EOPNOTSUPP; if (wol->wolopts & ~WAKE_MAGIC) return -EINVAL; wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG_NV); if (!(wol_cfg & (1 << adapter->portnum))) return -EOPNOTSUPP; wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG); if (wol->wolopts & WAKE_MAGIC) wol_cfg |= 1UL << adapter->portnum; else wol_cfg &= ~(1UL << adapter->portnum); QLCWR32(adapter, QLCNIC_WOL_CONFIG, wol_cfg); return 0; }
static int qlcnic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 *bytes) { struct qlcnic_adapter *adapter = netdev_priv(dev); int offset; int ret = -1; if (qlcnic_83xx_check(adapter)) return 0; if (eeprom->len == 0) return -EINVAL; eeprom->magic = (adapter->pdev)->vendor | ((adapter->pdev)->device << 16); offset = eeprom->offset; if (qlcnic_82xx_check(adapter)) ret = qlcnic_rom_fast_read_words(adapter, offset, bytes, eeprom->len); if (ret < 0) return ret; return 0; }
static int qlcnic_dev_statistics_len(struct qlcnic_adapter *adapter) { if (qlcnic_82xx_check(adapter)) return qlcnic_82xx_statistics(); else if (qlcnic_83xx_check(adapter)) return qlcnic_83xx_statistics(); else return -1; }
static void qlcnic_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause) { struct qlcnic_adapter *adapter = netdev_priv(netdev); int port = adapter->ahw->physical_port; int err = 0; __u32 val; if (qlcnic_83xx_check(adapter)) { qlcnic_83xx_get_pauseparam(adapter, pause); return; } if (adapter->ahw->port_type == QLCNIC_GBE) { if ((port < 0) || (port > QLCNIC_NIU_MAX_GBE_PORTS)) return; /* get flow control settings */ val = QLCRD32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port), &err); if (err == -EIO) return; pause->rx_pause = qlcnic_gb_get_rx_flowctl(val); val = QLCRD32(adapter, QLCNIC_NIU_GB_PAUSE_CTL, &err); if (err == -EIO) return; switch (port) { case 0: pause->tx_pause = !(qlcnic_gb_get_gb0_mask(val)); break; case 1: pause->tx_pause = !(qlcnic_gb_get_gb1_mask(val)); break; case 2: pause->tx_pause = !(qlcnic_gb_get_gb2_mask(val)); break; case 3: default: pause->tx_pause = !(qlcnic_gb_get_gb3_mask(val)); break; } } else if (adapter->ahw->port_type == QLCNIC_XGBE) { if ((port < 0) || (port > QLCNIC_NIU_MAX_XG_PORTS)) return; pause->rx_pause = 1; val = QLCRD32(adapter, QLCNIC_NIU_XG_PAUSE_CTL, &err); if (err == -EIO) return; if (port == 0) pause->tx_pause = !(qlcnic_xg_get_xg0_mask(val)); else pause->tx_pause = !(qlcnic_xg_get_xg1_mask(val)); } else { dev_err(&netdev->dev, "Unknown board type: %x\n", adapter->ahw->port_type); } }
static int qlcnic_get_regs_len(struct net_device *dev) { struct qlcnic_adapter *adapter = netdev_priv(dev); u32 len; if (qlcnic_83xx_check(adapter)) len = qlcnic_83xx_get_regs_len(adapter); else len = sizeof(ext_diag_registers) + sizeof(diag_registers); return QLCNIC_RING_REGS_LEN + len + QLCNIC_DEV_INFO_SIZE + 1; }
static int qlcnic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) { struct qlcnic_adapter *adapter = netdev_priv(dev); if (qlcnic_82xx_check(adapter)) return qlcnic_82xx_get_settings(adapter, ecmd); else if (qlcnic_83xx_check(adapter)) return qlcnic_83xx_get_settings(adapter, ecmd); return -EIO; }
static u32 qlcnic_test_link(struct net_device *dev) { struct qlcnic_adapter *adapter = netdev_priv(dev); u32 val; if (qlcnic_83xx_check(adapter)) { val = qlcnic_83xx_test_link(adapter); return (val & 1) ? 0 : 1; } val = QLCRD32(adapter, CRB_XG_STATE_P3P); val = XG_LINK_STATE_P3P(adapter->ahw->pci_func, val); return (val == XG_LINK_UP_P3P) ? 0 : 1; }
static void qlcnic_get_strings(struct net_device *dev, u32 stringset, u8 *data) { struct qlcnic_adapter *adapter = netdev_priv(dev); int index, i, num_stats; switch (stringset) { case ETH_SS_TEST: memcpy(data, *qlcnic_gstrings_test, QLCNIC_TEST_LEN * ETH_GSTRING_LEN); break; case ETH_SS_STATS: for (index = 0; index < QLCNIC_STATS_LEN; index++) { memcpy(data + index * ETH_GSTRING_LEN, qlcnic_gstrings_stats[index].stat_string, ETH_GSTRING_LEN); } if (qlcnic_83xx_check(adapter)) { num_stats = ARRAY_SIZE(qlcnic_83xx_tx_stats_strings); for (i = 0; i < num_stats; i++, index++) memcpy(data + index * ETH_GSTRING_LEN, qlcnic_83xx_tx_stats_strings[i], ETH_GSTRING_LEN); num_stats = ARRAY_SIZE(qlcnic_83xx_mac_stats_strings); for (i = 0; i < num_stats; i++, index++) memcpy(data + index * ETH_GSTRING_LEN, qlcnic_83xx_mac_stats_strings[i], ETH_GSTRING_LEN); num_stats = ARRAY_SIZE(qlcnic_83xx_rx_stats_strings); for (i = 0; i < num_stats; i++, index++) memcpy(data + index * ETH_GSTRING_LEN, qlcnic_83xx_rx_stats_strings[i], ETH_GSTRING_LEN); return; } else { num_stats = ARRAY_SIZE(qlcnic_83xx_mac_stats_strings); for (i = 0; i < num_stats; i++, index++) memcpy(data + index * ETH_GSTRING_LEN, qlcnic_83xx_mac_stats_strings[i], ETH_GSTRING_LEN); } if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) return; num_stats = ARRAY_SIZE(qlcnic_device_gstrings_stats); for (i = 0; i < num_stats; index++, i++) { memcpy(data + index * ETH_GSTRING_LEN, qlcnic_device_gstrings_stats[i], ETH_GSTRING_LEN); } } }
static int qlcnic_reg_test(struct net_device *dev) { struct qlcnic_adapter *adapter = netdev_priv(dev); u32 data_read; if (qlcnic_83xx_check(adapter)) return qlcnic_83xx_reg_test(adapter); data_read = QLCRD32(adapter, QLCNIC_PCIX_PH_REG(0)); if ((data_read & 0xffff) != adapter->pdev->vendor) return 1; return 0; }
static void qlcnic_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data) { struct qlcnic_adapter *adapter = netdev_priv(dev); struct qlcnic_esw_statistics port_stats; struct qlcnic_mac_statistics mac_stats; int index, ret, length, size; char *p; memset(data, 0, stats->n_stats * sizeof(u64)); length = QLCNIC_STATS_LEN; for (index = 0; index < length; index++) { p = (char *)adapter + qlcnic_gstrings_stats[index].stat_offset; size = qlcnic_gstrings_stats[index].sizeof_stat; *data++ = (size == sizeof(u64)) ? (*(u64 *)p) : ((*(u32 *)p)); } if (qlcnic_83xx_check(adapter)) { if (adapter->ahw->linkup) qlcnic_83xx_get_stats(adapter, data); return; } else { /* Retrieve MAC statistics from firmware */ memset(&mac_stats, 0, sizeof(struct qlcnic_mac_statistics)); qlcnic_get_mac_stats(adapter, &mac_stats); data = qlcnic_fill_stats(data, &mac_stats, QLCNIC_MAC_STATS); } if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) return; memset(&port_stats, 0, sizeof(struct qlcnic_esw_statistics)); ret = qlcnic_get_port_stats(adapter, adapter->ahw->pci_func, QLCNIC_QUERY_RX_COUNTER, &port_stats.rx); if (ret) return; data = qlcnic_fill_stats(data, &port_stats.rx, QLCNIC_ESW_STATS); ret = qlcnic_get_port_stats(adapter, adapter->ahw->pci_func, QLCNIC_QUERY_TX_COUNTER, &port_stats.tx); if (ret) return; qlcnic_fill_stats(data, &port_stats.tx, QLCNIC_ESW_STATS); }
static int qlcnic_get_sset_count(struct net_device *dev, int sset) { int len; struct qlcnic_adapter *adapter = netdev_priv(dev); switch (sset) { case ETH_SS_TEST: return QLCNIC_TEST_LEN; case ETH_SS_STATS: len = qlcnic_dev_statistics_len(adapter) + QLCNIC_STATS_LEN; if ((adapter->flags & QLCNIC_ESWITCH_ENABLED) || qlcnic_83xx_check(adapter)) return len; return qlcnic_82xx_statistics(); default: return -EOPNOTSUPP; } }
static void qlcnic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) { struct qlcnic_adapter *adapter = netdev_priv(dev); u32 wol_cfg; if (qlcnic_83xx_check(adapter)) return; wol->supported = 0; wol->wolopts = 0; wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG_NV); if (wol_cfg & (1UL << adapter->portnum)) wol->supported |= WAKE_MAGIC; wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG); if (wol_cfg & (1UL << adapter->portnum)) wol->wolopts |= WAKE_MAGIC; }
static int qlcnic_irq_test(struct net_device *netdev) { struct qlcnic_adapter *adapter = netdev_priv(netdev); struct qlcnic_hardware_context *ahw = adapter->ahw; struct qlcnic_cmd_args cmd; int ret, max_sds_rings = adapter->max_sds_rings; if (qlcnic_83xx_check(adapter)) return qlcnic_83xx_interrupt_test(netdev); if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) return -EIO; ret = qlcnic_diag_alloc_res(netdev, QLCNIC_INTERRUPT_TEST); if (ret) goto clear_diag_irq; ahw->diag_cnt = 0; ret = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_INTRPT_TEST); if (ret) goto free_diag_res; cmd.req.arg[1] = ahw->pci_func; ret = qlcnic_issue_cmd(adapter, &cmd); if (ret) goto done; usleep_range(1000, 12000); ret = !ahw->diag_cnt; done: qlcnic_free_mbx_args(&cmd); free_diag_res: qlcnic_diag_free_res(netdev, max_sds_rings); clear_diag_irq: adapter->max_sds_rings = max_sds_rings; clear_bit(__QLCNIC_RESETTING, &adapter->state); return ret; }
int qlcnic_loopback_test(struct net_device *netdev, u8 mode) { struct qlcnic_adapter *adapter = netdev_priv(netdev); int max_sds_rings = adapter->max_sds_rings; struct qlcnic_host_sds_ring *sds_ring; struct qlcnic_hardware_context *ahw = adapter->ahw; int loop = 0; int ret; if (qlcnic_83xx_check(adapter)) return qlcnic_83xx_loopback_test(netdev, mode); if (!(ahw->capabilities & QLCNIC_FW_CAPABILITY_MULTI_LOOPBACK)) { dev_info(&adapter->pdev->dev, "Firmware do not support loopback test\n"); return -EOPNOTSUPP; } dev_warn(&adapter->pdev->dev, "%s loopback test in progress\n", mode == QLCNIC_ILB_MODE ? "internal" : "external"); if (ahw->op_mode == QLCNIC_NON_PRIV_FUNC) { dev_warn(&adapter->pdev->dev, "Loopback test not supported in nonprivileged mode\n"); return 0; } if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) return -EBUSY; ret = qlcnic_diag_alloc_res(netdev, QLCNIC_LOOPBACK_TEST); if (ret) goto clear_it; sds_ring = &adapter->recv_ctx->sds_rings[0]; ret = qlcnic_set_lb_mode(adapter, mode); if (ret) goto free_res; ahw->diag_cnt = 0; do { msleep(500); qlcnic_process_rcv_ring_diag(sds_ring); if (loop++ > QLCNIC_ILB_MAX_RCV_LOOP) { netdev_info(netdev, "firmware didnt respond to loopback" " configure request\n"); ret = -QLCNIC_FW_NOT_RESPOND; goto free_res; } else if (adapter->ahw->diag_cnt) { ret = adapter->ahw->diag_cnt; goto free_res; } } while (!QLCNIC_IS_LB_CONFIGURED(ahw->loopback_state)); ret = qlcnic_do_lb_test(adapter, mode); qlcnic_clear_lb_mode(adapter, mode); free_res: qlcnic_diag_free_res(netdev, max_sds_rings); clear_it: adapter->max_sds_rings = max_sds_rings; clear_bit(__QLCNIC_RESETTING, &adapter->state); return ret; }
static int qlcnic_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause) { struct qlcnic_adapter *adapter = netdev_priv(netdev); int port = adapter->ahw->physical_port; __u32 val; if (qlcnic_83xx_check(adapter)) return qlcnic_83xx_set_pauseparam(adapter, pause); /* read mode */ if (adapter->ahw->port_type == QLCNIC_GBE) { if ((port < 0) || (port > QLCNIC_NIU_MAX_GBE_PORTS)) return -EIO; /* set flow control */ val = QLCRD32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port)); if (pause->rx_pause) qlcnic_gb_rx_flowctl(val); else qlcnic_gb_unset_rx_flowctl(val); QLCWR32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port), val); QLCWR32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port), val); /* set autoneg */ val = QLCRD32(adapter, QLCNIC_NIU_GB_PAUSE_CTL); switch (port) { case 0: if (pause->tx_pause) qlcnic_gb_unset_gb0_mask(val); else qlcnic_gb_set_gb0_mask(val); break; case 1: if (pause->tx_pause) qlcnic_gb_unset_gb1_mask(val); else qlcnic_gb_set_gb1_mask(val); break; case 2: if (pause->tx_pause) qlcnic_gb_unset_gb2_mask(val); else qlcnic_gb_set_gb2_mask(val); break; case 3: default: if (pause->tx_pause) qlcnic_gb_unset_gb3_mask(val); else qlcnic_gb_set_gb3_mask(val); break; } QLCWR32(adapter, QLCNIC_NIU_GB_PAUSE_CTL, val); } else if (adapter->ahw->port_type == QLCNIC_XGBE) { if (!pause->rx_pause || pause->autoneg) return -EOPNOTSUPP; if ((port < 0) || (port > QLCNIC_NIU_MAX_XG_PORTS)) return -EIO; val = QLCRD32(adapter, QLCNIC_NIU_XG_PAUSE_CTL); if (port == 0) { if (pause->tx_pause) qlcnic_xg_unset_xg0_mask(val); else qlcnic_xg_set_xg0_mask(val); } else { if (pause->tx_pause) qlcnic_xg_unset_xg1_mask(val); else qlcnic_xg_set_xg1_mask(val); } QLCWR32(adapter, QLCNIC_NIU_XG_PAUSE_CTL, val); } else { dev_err(&netdev->dev, "Unknown board type: %x\n", adapter->ahw->port_type); } return 0; }
static int qlcnic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) { struct qlcnic_adapter *adapter = netdev_priv(dev); struct qlcnic_hardware_context *ahw = adapter->ahw; u32 speed, reg; int check_sfp_module = 0; u16 pcifn = ahw->pci_func; /* read which mode */ if (adapter->ahw->port_type == QLCNIC_GBE) { ecmd->supported = (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full); ecmd->advertising = (ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full | ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full); ethtool_cmd_speed_set(ecmd, adapter->ahw->link_speed); ecmd->duplex = adapter->ahw->link_duplex; ecmd->autoneg = adapter->ahw->link_autoneg; } else if (adapter->ahw->port_type == QLCNIC_XGBE) { u32 val = 0; if (qlcnic_83xx_check(adapter)) qlcnic_83xx_get_settings(adapter); else val = QLCRD32(adapter, QLCNIC_PORT_MODE_ADDR); if (val == QLCNIC_PORT_MODE_802_3_AP) { ecmd->supported = SUPPORTED_1000baseT_Full; ecmd->advertising = ADVERTISED_1000baseT_Full; } else { ecmd->supported = SUPPORTED_10000baseT_Full; ecmd->advertising = ADVERTISED_10000baseT_Full; } if (netif_running(dev) && adapter->ahw->has_link_events) { if (qlcnic_82xx_check(adapter)) { reg = QLCRD32(adapter, P3P_LINK_SPEED_REG(pcifn)); speed = P3P_LINK_SPEED_VAL(pcifn, reg); ahw->link_speed = speed * P3P_LINK_SPEED_MHZ; } ethtool_cmd_speed_set(ecmd, adapter->ahw->link_speed); ecmd->autoneg = adapter->ahw->link_autoneg; ecmd->duplex = adapter->ahw->link_duplex; goto skip; } ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN); ecmd->duplex = DUPLEX_UNKNOWN; ecmd->autoneg = AUTONEG_DISABLE; } else return -EIO; skip: ecmd->phy_address = adapter->ahw->physical_port; ecmd->transceiver = XCVR_EXTERNAL; switch (adapter->ahw->board_type) { case QLCNIC_BRDTYPE_P3P_REF_QG: case QLCNIC_BRDTYPE_P3P_4_GB: case QLCNIC_BRDTYPE_P3P_4_GB_MM: ecmd->supported |= SUPPORTED_Autoneg; ecmd->advertising |= ADVERTISED_Autoneg; case QLCNIC_BRDTYPE_P3P_10G_CX4: case QLCNIC_BRDTYPE_P3P_10G_CX4_LP: case QLCNIC_BRDTYPE_P3P_10000_BASE_T: ecmd->supported |= SUPPORTED_TP; ecmd->advertising |= ADVERTISED_TP; ecmd->port = PORT_TP; ecmd->autoneg = adapter->ahw->link_autoneg; break; case QLCNIC_BRDTYPE_P3P_IMEZ: case QLCNIC_BRDTYPE_P3P_XG_LOM: case QLCNIC_BRDTYPE_P3P_HMEZ: ecmd->supported |= SUPPORTED_MII; ecmd->advertising |= ADVERTISED_MII; ecmd->port = PORT_MII; ecmd->autoneg = AUTONEG_DISABLE; break; case QLCNIC_BRDTYPE_P3P_10G_SFP_PLUS: case QLCNIC_BRDTYPE_P3P_10G_SFP_CT: case QLCNIC_BRDTYPE_P3P_10G_SFP_QT: ecmd->advertising |= ADVERTISED_TP; ecmd->supported |= SUPPORTED_TP; check_sfp_module = netif_running(dev) && adapter->ahw->has_link_events; case QLCNIC_BRDTYPE_P3P_10G_XFP: ecmd->supported |= SUPPORTED_FIBRE; ecmd->advertising |= ADVERTISED_FIBRE; ecmd->port = PORT_FIBRE; ecmd->autoneg = AUTONEG_DISABLE; break; case QLCNIC_BRDTYPE_P3P_10G_TP: if (adapter->ahw->port_type == QLCNIC_XGBE) { ecmd->autoneg = AUTONEG_DISABLE; ecmd->supported |= (SUPPORTED_FIBRE | SUPPORTED_TP); ecmd->advertising |= (ADVERTISED_FIBRE | ADVERTISED_TP); ecmd->port = PORT_FIBRE; check_sfp_module = netif_running(dev) && adapter->ahw->has_link_events; } else { ecmd->autoneg = AUTONEG_ENABLE; ecmd->supported |= (SUPPORTED_TP | SUPPORTED_Autoneg); ecmd->advertising |= (ADVERTISED_TP | ADVERTISED_Autoneg); ecmd->port = PORT_TP; } break; case QLCNIC_BRDTYPE_83XX_10G: ecmd->autoneg = AUTONEG_DISABLE; ecmd->supported |= (SUPPORTED_FIBRE | SUPPORTED_TP); ecmd->advertising |= (ADVERTISED_FIBRE | ADVERTISED_TP); ecmd->port = PORT_FIBRE; check_sfp_module = netif_running(dev) && ahw->has_link_events; break; default: dev_err(&adapter->pdev->dev, "Unsupported board model %d\n", adapter->ahw->board_type); return -EIO; } if (check_sfp_module) { switch (adapter->ahw->module_type) { case LINKEVENT_MODULE_OPTICAL_UNKNOWN: case LINKEVENT_MODULE_OPTICAL_SRLR: case LINKEVENT_MODULE_OPTICAL_LRM: case LINKEVENT_MODULE_OPTICAL_SFP_1G: ecmd->port = PORT_FIBRE; break; case LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLE: case LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLELEN: case LINKEVENT_MODULE_TWINAX: ecmd->port = PORT_TP; break; default: ecmd->port = PORT_OTHER; } } return 0; }
/* * Set the coalescing parameters. Currently only normal is supported. * If rx_coalesce_usecs == 0 or rx_max_coalesced_frames == 0 then set the * firmware coalescing to default. */ static int qlcnic_set_intr_coalesce(struct net_device *netdev, struct ethtool_coalesce *ethcoal) { struct qlcnic_adapter *adapter = netdev_priv(netdev); struct qlcnic_nic_intr_coalesce *coal; u32 rx_coalesce_usecs, rx_max_frames; u32 tx_coalesce_usecs, tx_max_frames; if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) return -EINVAL; /* * Return Error if unsupported values or * unsupported parameters are set. */ if (ethcoal->rx_coalesce_usecs > 0xffff || ethcoal->rx_max_coalesced_frames > 0xffff || ethcoal->tx_coalesce_usecs > 0xffff || ethcoal->tx_max_coalesced_frames > 0xffff || ethcoal->rx_coalesce_usecs_irq || ethcoal->rx_max_coalesced_frames_irq || ethcoal->tx_coalesce_usecs_irq || ethcoal->tx_max_coalesced_frames_irq || ethcoal->stats_block_coalesce_usecs || ethcoal->use_adaptive_rx_coalesce || ethcoal->use_adaptive_tx_coalesce || ethcoal->pkt_rate_low || ethcoal->rx_coalesce_usecs_low || ethcoal->rx_max_coalesced_frames_low || ethcoal->tx_coalesce_usecs_low || ethcoal->tx_max_coalesced_frames_low || ethcoal->pkt_rate_high || ethcoal->rx_coalesce_usecs_high || ethcoal->rx_max_coalesced_frames_high || ethcoal->tx_coalesce_usecs_high || ethcoal->tx_max_coalesced_frames_high) return -EINVAL; coal = &adapter->ahw->coal; if (qlcnic_83xx_check(adapter)) { if (!ethcoal->tx_coalesce_usecs || !ethcoal->tx_max_coalesced_frames || !ethcoal->rx_coalesce_usecs || !ethcoal->rx_max_coalesced_frames) { coal->flag = QLCNIC_INTR_DEFAULT; coal->type = QLCNIC_INTR_COAL_TYPE_RX; coal->rx_time_us = QLCNIC_DEF_INTR_COALESCE_RX_TIME_US; coal->rx_packets = QLCNIC_DEF_INTR_COALESCE_RX_PACKETS; coal->tx_time_us = QLCNIC_DEF_INTR_COALESCE_TX_TIME_US; coal->tx_packets = QLCNIC_DEF_INTR_COALESCE_TX_PACKETS; } else { tx_coalesce_usecs = ethcoal->tx_coalesce_usecs; tx_max_frames = ethcoal->tx_max_coalesced_frames; rx_coalesce_usecs = ethcoal->rx_coalesce_usecs; rx_max_frames = ethcoal->rx_max_coalesced_frames; coal->flag = 0; if ((coal->rx_time_us == rx_coalesce_usecs) && (coal->rx_packets == rx_max_frames)) { coal->type = QLCNIC_INTR_COAL_TYPE_TX; coal->tx_time_us = tx_coalesce_usecs; coal->tx_packets = tx_max_frames; } else if ((coal->tx_time_us == tx_coalesce_usecs) && (coal->tx_packets == tx_max_frames)) { coal->type = QLCNIC_INTR_COAL_TYPE_RX; coal->rx_time_us = rx_coalesce_usecs; coal->rx_packets = rx_max_frames; } else { coal->type = QLCNIC_INTR_COAL_TYPE_RX; coal->rx_time_us = rx_coalesce_usecs; coal->rx_packets = rx_max_frames; coal->tx_time_us = tx_coalesce_usecs; coal->tx_packets = tx_max_frames; } } } else { if (!ethcoal->rx_coalesce_usecs || !ethcoal->rx_max_coalesced_frames) { coal->flag = QLCNIC_INTR_DEFAULT; coal->rx_time_us = QLCNIC_DEF_INTR_COALESCE_RX_TIME_US; coal->rx_packets = QLCNIC_DEF_INTR_COALESCE_RX_PACKETS; } else { coal->flag = 0; coal->rx_time_us = ethcoal->rx_coalesce_usecs; coal->rx_packets = ethcoal->rx_max_coalesced_frames; } } qlcnic_config_intr_coalesce(adapter); return 0; }
static int qlcnic_set_led(struct net_device *dev, enum ethtool_phys_id_state state) { struct qlcnic_adapter *adapter = netdev_priv(dev); int max_sds_rings = adapter->max_sds_rings; int err = -EIO, active = 1; if (qlcnic_83xx_check(adapter)) return qlcnic_83xx_set_led(dev, state); if (adapter->ahw->op_mode == QLCNIC_NON_PRIV_FUNC) { netdev_warn(dev, "LED test not supported for non " "privilege function\n"); return -EOPNOTSUPP; } switch (state) { case ETHTOOL_ID_ACTIVE: if (test_and_set_bit(__QLCNIC_LED_ENABLE, &adapter->state)) return -EBUSY; if (test_bit(__QLCNIC_RESETTING, &adapter->state)) break; if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) { if (qlcnic_diag_alloc_res(dev, QLCNIC_LED_TEST)) break; set_bit(__QLCNIC_DIAG_RES_ALLOC, &adapter->state); } if (adapter->nic_ops->config_led(adapter, 1, 0xf) == 0) { err = 0; break; } dev_err(&adapter->pdev->dev, "Failed to set LED blink state.\n"); break; case ETHTOOL_ID_INACTIVE: active = 0; if (test_bit(__QLCNIC_RESETTING, &adapter->state)) break; if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) { if (qlcnic_diag_alloc_res(dev, QLCNIC_LED_TEST)) break; set_bit(__QLCNIC_DIAG_RES_ALLOC, &adapter->state); } if (adapter->nic_ops->config_led(adapter, 0, 0xf)) dev_err(&adapter->pdev->dev, "Failed to reset LED blink state.\n"); break; default: return -EINVAL; } if (test_and_clear_bit(__QLCNIC_DIAG_RES_ALLOC, &adapter->state)) qlcnic_diag_free_res(dev, max_sds_rings); if (!active || err) clear_bit(__QLCNIC_LED_ENABLE, &adapter->state); return err; }